test_ast_recovery.py¶
tests/test_ast_recovery.py
C++ AST recovery: header grammar disambiguation (#50) + callee unwrapping (#48).
test_a_NON_construction_qualifier_matching_several_still_records_nothing
None test_ast_recovery.test_a_NON_construction_qualifier_matching_several_still_records_nothing()
THE CONTROL that keeps `test_a_qualifier_matching_several_records_NOTHING` true. The fuzzy emission above is unlocked ONLY by the construction flag. An ordinary qualified call that narrows to several is unchanged — still silence, still gh#347's rule that one true observation must not become N assertions.
tests/test_ast_recovery.py:407
Checks
assert resolved == [] and fuzzy == [], "only construction unlocks the fuzzy emission"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_NON_construction_qualifier_matching_several_still_records_nothing → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 21 lines
def test_a_NON_construction_qualifier_matching_several_still_records_nothing() -> None:
"""THE CONTROL that keeps `test_a_qualifier_matching_several_records_NOTHING` true. The
fuzzy emission above is unlocked ONLY by the construction flag. An ordinary qualified call
that narrows to several is unchanged — still silence, still gh#347's rule that one true
observation must not become N assertions.
"""
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"send",
{"send": [30, 31]},
resolved,
fuzzy,
SOURCE_AST_MEMBER,
qualified="Net::send",
definition_of={30: "void Net::send", 31: "void Net::send"},
)
assert resolved == [] and fuzzy == [], "only construction unlocks the fuzzy emission"
Activity · 4 steps
test_a_RELATIVE_qualifier_still_resolves
None test_ast_recovery.test_a_RELATIVE_qualifier_still_resolves()
C++ lets a call site qualify relative to its enclosing namespace: inside `namespace entropic`, `mcp::sanitize_utf8()` names `entropic::mcp::sanitize_utf8`. On the public entropic index this is not a corner case — 92 of 662 matchable qualified sites take the relative form, including `detail::parse_range_header` (19) and `mcp::sanitize_utf8` (12).
tests/test_ast_recovery.py:249
Checks
assert resolved == [(1, 40, "ast_member")], ("a relative qualifier must resolve through the enclosing namespace" )assert fuzzy == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_RELATIVE_qualifier_still_resolves → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 35 lines
def test_a_RELATIVE_qualifier_still_resolves() -> None:
"""C++ lets a call site qualify relative to its enclosing namespace: inside
`namespace entropic`, `mcp::sanitize_utf8()` names `entropic::mcp::sanitize_utf8`. On the
public entropic index this is not a corner case — 92 of 662 matchable qualified sites take
the relative form, including `detail::parse_range_header` (19) and `mcp::sanitize_utf8` (12).
It works only because `_common._IDENT_CHARS` omits ':', so the character before the match
is a boundary. That is an IMPLICIT dependency: adding ':' to that set to tighten some other
comparison would silently delete these edges via the fail-closed path, which is the worst
shape of regression — fewer edges, no error. An audit probe that spelled the boundary rule
out by hand got exactly this wrong and reported 92 false deletions that did not exist.
"""
from clew.call_edges import _ast_record_call_edge
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"sanitize_utf8",
{"sanitize_utf8": [40, 41]},
resolved,
fuzzy,
"ast_member",
qualified="mcp::sanitize_utf8",
definition_of={
40: "std::string entropic::mcp::sanitize_utf8(const std::string &)",
41: "std::string other::text::sanitize_utf8(const char *)",
},
)
assert resolved == [(1, 40, "ast_member")], (
"a relative qualifier must resolve through the enclosing namespace"
)
assert fuzzy == []
Activity · 6 steps
test_a_construction_matching_several_rows_is_fuzzy_not_silence
None test_ast_recovery.test_a_construction_matching_several_rows_is_fuzzy_not_silence()
A constructor has the same decl/def duality as any other method, so the qualifier narrows to TWO rows and the general qualified path — which refuses on more than one, by design and by a pinned test — would emit nothing and reproduce gh#15's silence for every class whose constructor is declared and defined separately.
tests/test_ast_recovery.py:376
Checks
assert resolved == [], "two rows is not a pick"assert sorted(fuzzy) == [(1, 4647, SOURCE_AST_MEMBER), (1, 4717, SOURCE_AST_MEMBER)]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_construction_matching_several_rows_is_fuzzy_not_silence → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 31 lines
def test_a_construction_matching_several_rows_is_fuzzy_not_silence() -> None:
"""A constructor has the same decl/def duality as any other method, so the qualifier
narrows to TWO rows and the general qualified path — which refuses on more than one, by
design and by a pinned test — would emit nothing and reproduce gh#15's silence for every
class whose constructor is declared and defined separately.
Construction is the one case where several survivors are not a name guess: the call site
NAMED the class, so every survivor is a constructor of that class. Emitting them as fuzzy
hands them to `_collapse_duplicate_targets`, which resolves a decl/def pair to one edge and
leaves genuine constructor overloads fuzzy — which is what they are.
"""
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"ServerManager",
{"ServerManager": [4647, 4717]},
resolved,
fuzzy,
SOURCE_AST_MEMBER,
qualified="ServerManager",
definition_of={
4647: "entropic::ServerManager::ServerManager",
4717: "entropic::ServerManager::ServerManager",
},
construction=True,
)
assert resolved == [], "two rows is not a pick"
assert sorted(fuzzy) == [(1, 4647, SOURCE_AST_MEMBER), (1, 4717, SOURCE_AST_MEMBER)]
Activity · 5 steps
test_a_make_unique_site_names_the_constructed_class
None test_ast_recovery.test_a_make_unique_site_names_the_constructed_class(tmp_path)
gh#15. `std::make_unique<FilesystemServer>(...)` unwrapped to `make_unique`, which no index holds, so the sole PRODUCTION construction of a server emitted no edge and `dossier("FilesystemServer")` listed only a test helper that calls the constructor directly. The reporter followed that helper, hit a dead end, and shipped a design document recommending the wrong configuration.
tests/test_ast_recovery.py:318
Checks
assert parsed is not Noneassert "make_unique" not in by_name, "the factory template is not the callee — the class is"assert "make_shared" not in by_nameassert "FilesystemServer" in by_name, f"got {sorted(by_name)}"assert "BashServer" in by_name, f"got {sorted(by_name)}"assert by_name["BashServer"][3] == "entropic::BashServer"assert by_name["FilesystemServer"][3] == "FilesystemServer"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_a_make_unique_site_names_the_constructed_class → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-011 | measured |
Source · 27 lines
def test_a_make_unique_site_names_the_constructed_class(tmp_path) -> None:
"""gh#15. `std::make_unique<FilesystemServer>(...)` unwrapped to `make_unique`, which no
index holds, so the sole PRODUCTION construction of a server emitted no edge and
`dossier("FilesystemServer")` listed only a test helper that calls the constructor
directly. The reporter followed that helper, hit a dead end, and shipped a design document
recommending the wrong configuration.
The class is written OUTRIGHT in the template argument, so this needs no type inference —
only reading the argument the call site already states. The site is rewritten to name the
constructed class, and the full template text rides along as the qualifier so an unrelated
same-named class in another namespace cannot claim it.
"""
parsed = _parse(tmp_path, "w.cpp", _CONSTRUCTION)
assert parsed is not None
tree, src = parsed
by_name = {site[0]: site for site in _ast_harvest_calls(tree, src)}
assert "make_unique" not in by_name, "the factory template is not the callee — the class is"
assert "make_shared" not in by_name
assert "FilesystemServer" in by_name, f"got {sorted(by_name)}"
assert "BashServer" in by_name, f"got {sorted(by_name)}"
# The qualifier keeps the namespace the call site wrote, so `entropic::BashServer` cannot
# resolve to some other `BashServer`.
assert by_name["BashServer"][3] == "entropic::BashServer"
assert by_name["FilesystemServer"][3] == "FilesystemServer"
Activity · 10 steps
test_a_qualified_call_site_resolves_instead_of_fanning_out
None test_ast_recovery.test_a_qualified_call_site_resolves_instead_of_fanning_out()
tests/test_ast_recovery.py:153
Checks
assert resolved == [(1, 10, "ast_member")], "the qualified match must resolve to ONE"assert fuzzy == [], "and must not also fan out"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_qualified_call_site_resolves_instead_of_fanning_out → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 30 lines
def test_a_qualified_call_site_resolves_instead_of_fanning_out() -> None:
"""#75's resolve half. `Ns::Class::method()` writes the class AT the call site, and
`_callee_name_node` peeled it off to match `memberdef.name` — discarding the one piece
of evidence that could say WHICH `method`. Measured on the public entropic index: 2,301
of 10,723 member-ish call sites (21%) are qualified.
Narrowing uses `query._common._qualified_match`, the SAME boundary-checked comparison
`rowids_for_name` relies on, rather than a second matcher that could drift."""
from clew.call_edges import _ast_record_call_edge
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"poll",
{"poll": [10, 11, 12]},
resolved,
fuzzy,
"ast_member",
qualified="net::Socket::poll",
definition_of={
10: "int net::Socket::poll(int)",
11: "int ui::Widget::poll()",
12: "void sched::Loop::poll()",
},
)
assert resolved == [(1, 10, "ast_member")], "the qualified match must resolve to ONE"
assert fuzzy == [], "and must not also fan out"
Activity · 6 steps
test_a_qualified_name_matching_nothing_emits_NOTHING
None test_ast_recovery.test_a_qualified_name_matching_nothing_emits_NOTHING()
THE GUARD, and the reason it matters. When the call site names a class explicitly and no indexed function bears it, the callee is OUTSIDE the index — a stdlib or vendored type. Emitting nothing is what an unknown free function already does.
tests/test_ast_recovery.py:183
Checks
assert resolved == [] and fuzzy == [], ("a qualified name matching nothing indexed must emit NOTHING, never fall back" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_qualified_name_matching_nothing_emits_NOTHING → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 27 lines
def test_a_qualified_name_matching_nothing_emits_NOTHING() -> None:
"""THE GUARD, and the reason it matters. When the call site names a class explicitly and
no indexed function bears it, the callee is OUTSIDE the index — a stdlib or vendored
type. Emitting nothing is what an unknown free function already does.
Falling back to the unqualified fan-out here would reintroduce exactly the fabrication
`fd384e5` removed, but WORSE: with the call site's own evidence contradicting it.
Measured on entropic: 690 edges are removed by this path."""
from clew.call_edges import _ast_record_call_edge
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"size",
{"size": [20, 21]},
resolved,
fuzzy,
"ast_member",
qualified="std::vector::size",
definition_of={20: "int app::Buf::size()", 21: "int app::Ring::size()"},
)
assert resolved == [] and fuzzy == [], (
"a qualified name matching nothing indexed must emit NOTHING, never fall back"
)
Activity · 5 steps
test_a_qualifier_matching_several_records_NOTHING
None test_ast_recovery.test_a_qualifier_matching_several_records_NOTHING()
Narrowing is not a promise of uniqueness. A qualified name that still matches more than one indexed signature (decl/def duality, or a genuine overload set on one class) is UNRESOLVED, and an unresolved call records nothing (gh#347).
tests/test_ast_recovery.py:210
Checks
assert resolved == [], "two candidates is not one; nothing is resolved"assert fuzzy == [], ("narrowed to the class and STILL ambiguous, so the call is unresolved and records " "nothing — emitting one row per candidate asserted two calls where one occurred" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_qualifier_matching_several_records_NOTHING → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 39 lines
def test_a_qualifier_matching_several_records_NOTHING() -> None:
"""Narrowing is not a promise of uniqueness. A qualified name that still matches more than
one indexed signature (decl/def duality, or a genuine overload set on one class) is
UNRESOLVED, and an unresolved call records nothing (gh#347).
THIS TEST'S INTENT IS UNCHANGED AND ITS ASSERTION IS INVERTED. It always guarded against
picking one candidate arbitrarily; it used to satisfy that by emitting ALL of them, which
the owner retired: one true observation must not become N assertions, because a NAME is a
mutable human convention and proves no linkage. Emitting nothing guards the same thing
strictly rather than loudly.
The narrowing itself still matters and is still asserted — by the sibling test where a
qualifier narrows to exactly ONE and earns `resolved`. Here the point is that narrowing to
TWO is not partial credit."""
from clew.call_edges import _ast_record_call_edge
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"send",
{"send": [30, 31, 32]},
resolved,
fuzzy,
"ast_member",
qualified="net::Socket::send",
definition_of={
30: "int net::Socket::send(const char *)",
31: "int net::Socket::send(int)",
32: "int ui::Form::send()",
},
)
assert resolved == [], "two candidates is not one; nothing is resolved"
assert fuzzy == [], (
"narrowed to the class and STILL ambiguous, so the call is unresolved and records "
"nothing — emitting one row per candidate asserted two calls where one occurred"
)
Activity · 6 steps
test_a_relative_qualifier_does_not_match_a_LONGER_identifier
None test_ast_recovery.test_a_relative_qualifier_does_not_match_a_LONGER_identifier()
The boundary rule's real job. `Owner::run` must not match `CoOwner::run` — the ':' tolerance that enables relative lookup must not extend to a partial identifier, or the resolution would be worse than the fan-out it replaces: confidently wrong instead of honestly ambiguous.
tests/test_ast_recovery.py:284
Checks
assert resolved == [] and fuzzy == [], "CoOwner::run must NOT satisfy Owner::run"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_relative_qualifier_does_not_match_a_LONGER_identifier → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 22 lines
def test_a_relative_qualifier_does_not_match_a_LONGER_identifier() -> None:
"""The boundary rule's real job. `Owner::run` must not match `CoOwner::run` — the ':'
tolerance that enables relative lookup must not extend to a partial identifier, or the
resolution would be worse than the fan-out it replaces: confidently wrong instead of
honestly ambiguous."""
from clew.call_edges import _ast_record_call_edge
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"run",
{"run": [50]},
resolved,
fuzzy,
"ast_member",
qualified="Owner::run",
definition_of={50: "void net::CoOwner::run()"},
)
assert resolved == [] and fuzzy == [], "CoOwner::run must NOT satisfy Owner::run"
Activity · 5 steps
test_an_enum_class_in_a_dot_h_still_yields_its_values
None test_ast_recovery.test_an_enum_class_in_a_dot_h_still_yields_its_values(tmp_path)
gh#28, CLOSED AS UNREACHABLE — and pinned here because what makes it unreachable is a heuristic that could change.
tests/test_ast_recovery.py:433
Checks
assert parsed is not Noneassert _errors(tree.root_node) == 0, ("the .h was not retried as C++ — gh#50's reparse is what keeps gh#28 unreachable" )assert got == {("Scoped", "X"), ("Scoped", "Y")}, got
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_an_enum_class_in_a_dot_h_still_yields_its_values → harvest_enumerators |
| REQ-DDB-PIPE-011 | measured |
Source · 27 lines
def test_an_enum_class_in_a_dot_h_still_yields_its_values(tmp_path) -> None:
"""gh#28, CLOSED AS UNREACHABLE — and pinned here because what makes it unreachable is a
heuristic that could change.
Called DIRECTLY, the C grammar reads `enum class Scoped : int { ... }` as an enum named
`class` with no body, so `harvest_enumerators` finds nothing. That is what the issue was
filed on, and the probe behind it bypassed the pipeline.
Through the real parse path it cannot happen: gh#50 retries a `.h` as C++ when the C parse
has errors, and `enum class` ALWAYS errors under C — measured on three shapes, with and
without a base type, alone and beside ordinary C. So the C++ grammar reads it and the values
arrive.
The property this pins is the CONJUNCTION: if gh#50's retry ever became conditional on
something other than a parse error, or if a future C grammar accepted `enum class` without
erroring, the enumerators would silently vanish for every scoped enum in a header. Neither
half is visible from the other's tests.
"""
parsed = _parse(tmp_path, "scoped.h", _ENUM_CLASS_HEADER)
assert parsed is not None
tree, src = parsed
assert _errors(tree.root_node) == 0, (
"the .h was not retried as C++ — gh#50's reparse is what keeps gh#28 unreachable"
)
got = {(e.enum_name, e.name) for e in harvest_enumerators(tree, src)}
assert got == {("Scoped", "X"), ("Scoped", "Y")}, got1 more lines, not shown
Activity · 6 steps
test_callee_without_a_static_name_is_still_refused
None test_ast_recovery.test_callee_without_a_static_name_is_still_refused(tmp_path)
A call through a function POINTER has no static callee name and belongs to the fnptr layer. Unwrapping must not invent one — fail closed.
tests/test_ast_recovery.py:125
Checks
assert parsed is not Noneassert "fnptr" not in names
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_callee_without_a_static_name_is_still_refused → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-011 | measured |
Source · 10 lines
def test_callee_without_a_static_name_is_still_refused(tmp_path) -> None:
"""A call through a function POINTER has no static callee name and belongs
to the fnptr layer. Unwrapping must not invent one — fail closed."""
parsed = _parse(tmp_path, "w.cpp", _CALL_SITES)
assert parsed is not None
tree, src = parsed
names = {site[0] for site in _ast_harvest_calls(tree, src)}
assert "fnptr" not in names
Activity · 5 steps
test_constructing_an_unindexed_template_still_resolves_to_nothing
None test_ast_recovery.test_constructing_an_unindexed_template_still_resolves_to_nothing(tmp_path)
THE NEGATIVE CONTROL. `std::make_unique<std::vector<int>>()` names a class too, and it is one no repository index holds. Naming it is correct — inventing an edge for it is not — and the existing miss path already handles that: a callee name with no candidate row emits nothing, exactly as an unknown free function does.
tests/test_ast_recovery.py:345
Checks
assert parsed is not Noneassert "vector" in by_name, f"the tail of a nested template argument: {sorted(by_name)}"assert by_name["vector"][3] == "std::vector<int>"assert resolved == [] and fuzzy == [], "a class the index does not hold earns no edge"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_constructing_an_unindexed_template_still_resolves_to_nothing → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-WIKI-054 | inferred | test_constructing_an_unindexed_template_still_resolves_to_nothing → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 31 lines
def test_constructing_an_unindexed_template_still_resolves_to_nothing(tmp_path) -> None:
"""THE NEGATIVE CONTROL. `std::make_unique<std::vector<int>>()` names a class too, and it
is one no repository index holds. Naming it is correct — inventing an edge for it is not —
and the existing miss path already handles that: a callee name with no candidate row emits
nothing, exactly as an unknown free function does.
Asserted at the HARVEST, because that is where the nested `<>` could go wrong: the tail
must be `vector`, never `int` and never the whole `std::vector<int>` text.
"""
parsed = _parse(tmp_path, "w.cpp", _CONSTRUCTION)
assert parsed is not None
tree, src = parsed
by_name = {site[0]: site for site in _ast_harvest_calls(tree, src)}
assert "vector" in by_name, f"the tail of a nested template argument: {sorted(by_name)}"
assert by_name["vector"][3] == "std::vector<int>"
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
_ast_record_call_edge(
1,
"vector",
{},
resolved,
fuzzy,
SOURCE_AST_MEMBER,
qualified="std::vector<int>",
construction=True,
)
assert resolved == [] and fuzzy == [], "a class the index does not hold earns no edge"
Activity · 10 steps
test_cpp_header_named_dot_h_reparses_as_cpp
None test_ast_recovery.test_cpp_header_named_dot_h_reparses_as_cpp(tmp_path)
Checks
assert parsed is not Noneassert _errors(tree.root_node) == 0, "a C++ header must not be parsed as C"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-011 | measured |
Source · 11 lines
def test_cpp_header_named_dot_h_reparses_as_cpp(tmp_path) -> None:
"""#50: `.h` went to the C grammar unconditionally. On a C++ header that
yields 7 ERROR/MISSING nodes AND reports TWO function definitions where one
exists — fabricated structure, which is worse than missing structure. Any
C++ project following the Google style guide names its headers `.h`."""
parsed = _parse(tmp_path, "widget.h", _CPP_HEADER)
assert parsed is not None
tree, _ = parsed
assert _errors(tree.root_node) == 0, "a C++ header must not be parsed as C"
Activity · 4 steps
test_harvested_sites_carry_provenance
None test_ast_recovery.test_harvested_sites_carry_provenance(tmp_path)
Provenance rides on each site so an unwrapped member call is separable from a confirmed free-function call downstream — the two have very different reliability and must not be merged into one `ast` bucket.
tests/test_ast_recovery.py:135
Checks
assert parsed is not Noneassert sites, "expected call sites"assert all(len(s) >= 3 for s in sites)assert {s[2] for s in sites} <= {SOURCE_AST, SOURCE_AST_MEMBER}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_harvested_sites_carry_provenance → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-WIKI-054 | inferred | test_harvested_sites_carry_provenance → all |
Source · 18 lines
def test_harvested_sites_carry_provenance(tmp_path) -> None:
"""Provenance rides on each site so an unwrapped member call is separable
from a confirmed free-function call downstream — the two have very
different reliability and must not be merged into one `ast` bucket."""
parsed = _parse(tmp_path, "w.cpp", _CALL_SITES)
assert parsed is not None
tree, src = parsed
sites = _ast_harvest_calls(tree, src)
assert sites, "expected call sites"
## Arity is 4 since #75 (the trailing element is the qualified callee text), and the
## assertion is >= 3 rather than == 4 for the same reason `_fold_call_payload` reads
## `site[2] if len(site) > 2`: the payload is CACHED, so a shorter one from an older
## build must stay readable. Pinning an exact arity would make this test the thing that
## breaks when the payload legitimately grows.
assert all(len(s) >= 3 for s in sites)
assert {s[2] for s in sites} <= {SOURCE_AST, SOURCE_AST_MEMBER}
Activity · 7 steps
test_member_qualified_and_template_callees_are_recovered
None test_ast_recovery.test_member_qualified_and_template_callees_are_recovered(tmp_path)
tests/test_ast_recovery.py:110
Checks
assert parsed is not Noneassert found.get("free_fn") == SOURCE_ASTassert found.get(name) == SOURCE_AST_MEMBER, f"{name} should be recovered"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_member_qualified_and_template_callees_are_recovered → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-011 | measured |
Source · 15 lines
def test_member_qualified_and_template_callees_are_recovered(tmp_path) -> None:
"""#48: requiring a bare `identifier` callee discarded every C++ member,
qualified and template call. Each is now unwrapped to the unqualified tail
that `memberdef.name` actually stores."""
parsed = _parse(tmp_path, "w.cpp", _CALL_SITES)
assert parsed is not None
tree, src = parsed
sites = _ast_harvest_calls(tree, src)
found = {site[0]: site[2] for site in sites}
assert found.get("free_fn") == SOURCE_AST
for name in ("method", "other", "run", "make"):
assert found.get(name) == SOURCE_AST_MEMBER, f"{name} should be recovered"
Activity · 8 steps
test_plain_c_header_is_unaffected
None test_ast_recovery.test_plain_c_header_is_unaffected(tmp_path)
A genuine C header parses cleanly as C, so it never reaches the retry — the fix costs nothing for C repos (IoT drops 0.2% of call sites, not 66%).
tests/test_ast_recovery.py:101
Checks
assert parsed is not Noneassert _errors(tree.root_node) == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-011 | measured |
Source · 9 lines
def test_plain_c_header_is_unaffected(tmp_path) -> None:
"""A genuine C header parses cleanly as C, so it never reaches the retry —
the fix costs nothing for C repos (IoT drops 0.2% of call sites, not 66%)."""
parsed = _parse(tmp_path, "demo.h", _C_HEADER)
assert parsed is not None
tree, _ = parsed
assert _errors(tree.root_node) == 0