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

Show on the map →

Called by none

Calls _ast_record_call_edge

Checks

  • assert resolved == [] and fuzzy == [], "only construction unlocks the fuzzy emission"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_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
lines 413–413resolved: list[tuple[int, int, str]] = []lines 414–414fuzzy: list[tuple[int, int, str]] = []lines 415–424_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"}, )lines 425–425assert resolved == [] and fuzzy == [], "only construction unlocks the fuzzy emission"

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

Show on the map →

Called by none

Calls _ast_record_call_edge

Checks

  • assert resolved == [(1, 40, "ast_member")], ("a relative qualifier must resolve through the enclosing namespace" )
  • assert fuzzy == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_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
lines 261–261from clew.call_edges import _ast_record_call_edgelines 263–263resolved: list[tuple[int, int, str]] = []lines 264–264fuzzy: list[tuple[int, int, str]] = []lines 265–277_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 *)", }, )lines 278–280assert resolved == [(1, 40, "ast_member")], ( "a relative qualifier must resolve through the enclosing namespace" )lines 281–281assert fuzzy == []

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

Show on the map →

Called by none

Calls _ast_record_call_edge

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

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_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
lines 387–387resolved: list[tuple[int, int, str]] = []lines 388–388fuzzy: list[tuple[int, int, str]] = []lines 389–402_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, )lines 403–403assert resolved == [], "two rows is not a pick"lines 404–404assert sorted(fuzzy) == [(1, 4647, SOURCE_AST_MEMBER), (1, 4717, SOURCE_AST_MEMBER)]

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

Show on the map →

Called by none

Calls _ast_harvest_calls

Checks

  • assert parsed is not None
  • 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)}"
  • assert by_name["BashServer"][3] == "entropic::BashServer"
  • assert by_name["FilesystemServer"][3] == "FilesystemServer"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_a_make_unique_site_names_the_constructed_class → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measured
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
lines 330–330parsed = _parse(tmp_path, "w.cpp", _CONSTRUCTION)lines 331–331assert parsed is not Nonelines 332–332tree, src = parsedlines 333–333by_name = {site[0]: site for site in _ast_harvest_calls(tree, src)}lines 335–335assert "make_unique" not in by_name, "the factory template is not the callee — the class is"lines 336–336assert "make_shared" not in by_namelines 337–337assert "FilesystemServer" in by_name, f"got {sorted(by_name)}"lines 338–338assert "BashServer" in by_name, f"got {sorted(by_name)}"lines 341–341assert by_name["BashServer"][3] == "entropic::BashServer"lines 342–342assert by_name["FilesystemServer"][3] == "FilesystemServer"

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

Show on the map →

Called by none

Calls _ast_record_call_edge

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

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_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
lines 161–161from clew.call_edges import _ast_record_call_edgelines 163–163resolved: list[tuple[int, int, str]] = []lines 164–164fuzzy: list[tuple[int, int, str]] = []lines 165–178_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()", }, )lines 179–179assert resolved == [(1, 10, "ast_member")], "the qualified match must resolve to ONE"lines 180–180assert fuzzy == [], "and must not also fan out"

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

Show on the map →

Called by none

Calls _ast_record_call_edge

Checks

  • assert resolved == [] and fuzzy == [], ("a qualified name matching nothing indexed must emit NOTHING, never fall back" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_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
lines 191–191from clew.call_edges import _ast_record_call_edgelines 193–193resolved: list[tuple[int, int, str]] = []lines 194–194fuzzy: list[tuple[int, int, str]] = []lines 195–204_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()"}, )lines 205–207assert resolved == [] and fuzzy == [], ( "a qualified name matching nothing indexed must emit NOTHING, never fall back" )

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

Show on the map →

Called by none

Calls _ast_record_call_edge

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

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_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
lines 224–224from clew.call_edges import _ast_record_call_edgelines 226–226resolved: list[tuple[int, int, str]] = []lines 227–227fuzzy: list[tuple[int, int, str]] = []lines 228–241_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()", }, )lines 242–242assert resolved == [], "two candidates is not one; nothing is resolved"lines 243–246assert 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" )

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

Show on the map →

Called by none

Calls _ast_record_call_edge

Checks

  • assert resolved == [] and fuzzy == [], "CoOwner::run must NOT satisfy Owner::run"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_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
lines 289–289from clew.call_edges import _ast_record_call_edgelines 291–291resolved: list[tuple[int, int, str]] = []lines 292–292fuzzy: list[tuple[int, int, str]] = []lines 293–302_ast_record_call_edge( 1, "run", {"run": [50]}, resolved, fuzzy, "ast_member", qualified="Owner::run", definition_of={50: "void net::CoOwner::run()"}, )lines 303–303assert resolved == [] and fuzzy == [], "CoOwner::run must NOT satisfy Owner::run"

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

Show on the map →

Called by none

Calls _errors, harvest_enumerators

Checks

  • assert parsed is not None
  • assert _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

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_an_enum_class_in_a_dot_h_still_yields_its_values → harvest_enumerators
REQ-DDB-PIPE-011measured
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")}, got

1 more lines, not shown

Activity · 6 steps
lines 451–451parsed = _parse(tmp_path, "scoped.h", _ENUM_CLASS_HEADER)lines 452–452assert parsed is not Nonelines 453–453tree, src = parsedlines 455–457assert _errors(tree.root_node) == 0, ( "the .h was not retried as C++ — gh#50's reparse is what keeps gh#28 unreachable" )lines 458–458got = {(e.enum_name, e.name) for e in harvest_enumerators(tree, src)}lines 459–459assert got == {("Scoped", "X"), ("Scoped", "Y")}, got

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

Show on the map →

Called by none

Calls _ast_harvest_calls

Checks

  • assert parsed is not None
  • assert "fnptr" not in names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_callee_without_a_static_name_is_still_refused → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measured
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
lines 128–128parsed = _parse(tmp_path, "w.cpp", _CALL_SITES)lines 129–129assert parsed is not Nonelines 130–130tree, src = parsedlines 131–131names = {site[0] for site in _ast_harvest_calls(tree, src)}lines 132–132assert "fnptr" not in names

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&lt;std::vector&lt;int&gt;&gt;()` 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

Show on the map →

Called by none

Calls _ast_harvest_calls, _ast_record_call_edge

Checks

  • assert parsed is not None
  • assert "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

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_constructing_an_unindexed_template_still_resolves_to_nothing → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measured
REQ-DDB-WIKI-054inferredtest_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
lines 354–354parsed = _parse(tmp_path, "w.cpp", _CONSTRUCTION)lines 355–355assert parsed is not Nonelines 356–356tree, src = parsedlines 357–357by_name = {site[0]: site for site in _ast_harvest_calls(tree, src)}lines 358–358assert "vector" in by_name, f"the tail of a nested template argument: {sorted(by_name)}"lines 359–359assert by_name["vector"][3] == "std::vector<int>"lines 361–361resolved: list[tuple[int, int, str]] = []lines 362–362fuzzy: list[tuple[int, int, str]] = []lines 363–372_ast_record_call_edge( 1, "vector", {}, resolved, fuzzy, SOURCE_AST_MEMBER, qualified="std::vector<int>", construction=True, )lines 373–373assert resolved == [] and fuzzy == [], "a class the index does not hold earns no edge"

test_cpp_header_named_dot_h_reparses_as_cpp

None test_ast_recovery.test_cpp_header_named_dot_h_reparses_as_cpp(tmp_path)

tests/test_ast_recovery.py:90

Show on the map →

Called by none

Calls _errors

Checks

  • assert parsed is not None
  • assert _errors(tree.root_node) == 0, "a C++ header must not be parsed as C"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-011measured
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
lines 95–95parsed = _parse(tmp_path, "widget.h", _CPP_HEADER)lines 96–96assert parsed is not Nonelines 97–97tree, _ = parsedlines 98–98assert _errors(tree.root_node) == 0, "a C++ header must not be parsed as C"

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

Show on the map →

Called by none

Calls _ast_harvest_calls, all

Checks

  • assert parsed is not None
  • assert 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

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_harvested_sites_carry_provenance → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measured
REQ-DDB-WIKI-054inferredtest_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
lines 139–139parsed = _parse(tmp_path, "w.cpp", _CALL_SITES)lines 140–140assert parsed is not Nonelines 141–141tree, src = parsedlines 142–142sites = _ast_harvest_calls(tree, src)lines 143–143assert sites, "expected call sites"lines 149–149assert all(len(s) >= 3 for s in sites)lines 150–150assert {s[2] for s in sites} <= {SOURCE_AST, SOURCE_AST_MEMBER}

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

Show on the map →

Called by none

Calls _ast_harvest_calls

Checks

  • assert parsed is not None
  • assert found.get("free_fn") == SOURCE_AST
  • assert found.get(name) == SOURCE_AST_MEMBER, f"{name} should be recovered"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_member_qualified_and_template_callees_are_recovered → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measured
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
lines 114–114parsed = _parse(tmp_path, "w.cpp", _CALL_SITES)lines 115–115assert parsed is not Nonelines 116–116tree, src = parsedlines 117–117sites = _ast_harvest_calls(tree, src)lines 118–118found = {site[0]: site[2] for site in sites}lines 120–120assert found.get("free_fn") == SOURCE_ASTlines 121–121◇ for name in ("method", "other", "run", "make")lines 122–122assert found.get(name) == SOURCE_AST_MEMBER, f"{name} should be recovered"

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

Show on the map →

Called by none

Calls _errors

Checks

  • assert parsed is not None
  • assert _errors(tree.root_node) == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-011measured
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

Activity · 4 steps
lines 104–104parsed = _parse(tmp_path, "demo.h", _C_HEADER)lines 105–105assert parsed is not Nonelines 106–106tree, _ = parsedlines 107–107assert _errors(tree.root_node) == 0