test_self_edges.py

tests/test_self_edges.py

The self-edge guard (#61): genuine recursion kept, fabrications dropped.

test_attribute_call_on_another_object_is_dropped

None test_self_edges.test_attribute_call_on_another_object_is_dropped(tmp_path)

Mechanism 2, and the one that proves uniqueness is the wrong test: `IndexCache.close` is the ONLY `close` memberdef in clew's index, yet `self.conn.close()` is sqlite3's method on a different object. Bound back to the wrapper, it reads to a consumer as infinite recursion.

tests/test_self_edges.py:321

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == set()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_attribute_call_on_another_object_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_attribute_call_on_another_object_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 10 lines
def test_attribute_call_on_another_object_is_dropped(tmp_path) -> None:
    """Mechanism 2, and the one that proves uniqueness is the wrong test:
    `IndexCache.close` is the ONLY `close` memberdef in clew's index, yet
    `self.conn.close()` is sqlite3's method on a different object. Bound back to
    the wrapper, it reads to a consumer as infinite recursion."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["close"])
    assert _prune(db, tmp_path) == set()

Activity · 3 steps
lines 326–326db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 327–327_seed_self_edges(db, rowids, ["close"])lines 328–328assert _prune(db, tmp_path) == set()

test_bare_c_recursion_is_kept

None test_self_edges.test_bare_c_recursion_is_kept(tmp_path)

a C++ codebase's one genuine self-edge shape, kept alongside 442 fabricated rows in the same database — the reason the guard has to judge per caller.

tests/test_self_edges.py:365

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["brace_expand"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_bare_c_recursion_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_bare_c_recursion_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 8 lines
def test_bare_c_recursion_is_kept(tmp_path) -> None:
    """a C++ codebase's one genuine self-edge shape, kept alongside 442 fabricated rows in
    the same database — the reason the guard has to judge per caller."""
    db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)
    _seed_self_edges(db, rowids, ["brace_expand"])
    assert _prune(db, tmp_path) == {rowids["brace_expand"]}

Activity · 3 steps
lines 368–368db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)lines 369–369_seed_self_edges(db, rowids, ["brace_expand"])lines 370–370assert _prune(db, tmp_path) == {rowids["brace_expand"]}

test_bare_call_in_a_cpp_method_is_kept

None test_self_edges.test_bare_call_in_a_cpp_method_is_kept(tmp_path)

The rule is conditional on the LANGUAGE, not on method-ness: C++ DOES have an implicit `this`, so a bare `compact(n - 1)` inside `Buffer::compact` is genuine recursion. Dropping it would regress the language the bare-name rule was always correct for, which is the risk this whole change carries.

tests/test_self_edges.py:388

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["compact"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_bare_call_in_a_cpp_method_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_bare_call_in_a_cpp_method_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 10 lines
def test_bare_call_in_a_cpp_method_is_kept(tmp_path) -> None:
    """The rule is conditional on the LANGUAGE, not on method-ness: C++ DOES
    have an implicit `this`, so a bare `compact(n - 1)` inside `Buffer::compact`
    is genuine recursion. Dropping it would regress the language the bare-name
    rule was always correct for, which is the risk this whole change carries."""
    db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)
    _seed_self_edges(db, rowids, ["compact"])
    assert _prune(db, tmp_path) == {rowids["compact"]}

Activity · 3 steps
lines 393–393db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)lines 394–394_seed_self_edges(db, rowids, ["compact"])lines 395–395assert _prune(db, tmp_path) == {rowids["compact"]}

test_bare_call_in_a_decorated_python_method_is_dropped

None test_self_edges.test_bare_call_in_a_decorated_python_method_is_dropped(tmp_path)

A `@property`/`@staticmethod` sits under an extra `decorated_definition` node, so the walk from the function to its owning scope has to step over it. Without that step a decorated method reads as module-level and gh#30's rule silently stops applying to it — which is most of a real class's surface.

tests/test_self_edges.py:409

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == set()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_bare_call_in_a_decorated_python_method_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_bare_call_in_a_decorated_python_method_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 10 lines
def test_bare_call_in_a_decorated_python_method_is_dropped(tmp_path) -> None:
    """A `@property`/`@staticmethod` sits under an extra `decorated_definition`
    node, so the walk from the function to its owning scope has to step over it.
    Without that step a decorated method reads as module-level and gh#30's rule
    silently stops applying to it — which is most of a real class's surface."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["refresh"])
    assert _prune(db, tmp_path) == set()

Activity · 3 steps
lines 414–414db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 415–415_seed_self_edges(db, rowids, ["refresh"])lines 416–416assert _prune(db, tmp_path) == set()

test_bare_call_in_a_python_method_is_dropped

None test_self_edges.test_bare_call_in_a_python_method_is_dropped(tmp_path)

gh#30. Python has NO implicit `this`, so a bare `cull(...)` inside a method named `cull` cannot reach the method — it names a module-level or imported `cull`. `DocsDbServer.cull` is the measured instance: its body's bare `cull(self.registry, ...)` is the `state.cull` it imports, and the guard kept that self-edge as the eighth of eight "genuine" recursions when the other seven were real.

tests/test_self_edges.py:373

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == set()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_bare_call_in_a_python_method_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_bare_call_in_a_python_method_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 15 lines
def test_bare_call_in_a_python_method_is_dropped(tmp_path) -> None:
    """gh#30. Python has NO implicit `this`, so a bare `cull(...)` inside a
    method named `cull` cannot reach the method — it names a module-level or
    imported `cull`. `DocsDbServer.cull` is the measured instance: its body's
    bare `cull(self.registry, ...)` is the `state.cull` it imports, and the
    guard kept that self-edge as the eighth of eight "genuine" recursions when
    the other seven were real.

    This is the ONE shape the language-conditional rule removes. Every other
    test in this file pins something it must NOT remove."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["cull"])
    assert _prune(db, tmp_path) == set()

Activity · 3 steps
lines 383–383db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 384–384_seed_self_edges(db, rowids, ["cull"])lines 385–385assert _prune(db, tmp_path) == set()

test_bare_self_call_is_kept

None test_self_edges.test_bare_self_call_is_kept(tmp_path)

Mechanism 1. `scope._classify` really does contain `_classify(child)`; deleting that edge would delete a true fact, which is why a blanket drop of self-edges is wrong however much noise sits beside it.

tests/test_self_edges.py:294

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["descend"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_bare_self_call_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_bare_self_call_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 9 lines
def test_bare_self_call_is_kept(tmp_path) -> None:
    """Mechanism 1. `scope._classify` really does contain `_classify(child)`;
    deleting that edge would delete a true fact, which is why a blanket drop of
    self-edges is wrong however much noise sits beside it."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["descend"])
    assert _prune(db, tmp_path) == {rowids["descend"]}

Activity · 3 steps
lines 298–298db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 299–299_seed_self_edges(db, rowids, ["descend"])lines 300–300assert _prune(db, tmp_path) == {rowids["descend"]}

test_caller_with_no_same_named_call_site_is_dropped

None test_self_edges.test_caller_with_no_same_named_call_site_is_dropped(tmp_path)

The DOMINANT mechanism, and one the original three-way split missed: 442 of a C++ codebase's 458 self-edge rows are anonymous-namespace functions that never name themselves anywhere, and 21 of clew's 70 are a `main()` invoked from a `if __name__ == "__main__":` guard which doxygen files inside `main`. Both carry source='doxygen_sqlite', so no change to the AST extractor could have reached them.

tests/test_self_edges.py:340

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(py_db, tmp_path / "py") == set()
  • assert _prune(cpp_db, tmp_path / "cpp") == set()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_caller_with_no_same_named_call_site_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_caller_with_no_same_named_call_site_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 16 lines
def test_caller_with_no_same_named_call_site_is_dropped(tmp_path) -> None:
    """The DOMINANT mechanism, and one the original three-way split missed: 442
    of a C++ codebase's 458 self-edge rows are anonymous-namespace functions that never
    name themselves anywhere, and 21 of clew's 70 are a `main()` invoked from
    a `if __name__ == "__main__":` guard which doxygen files inside `main`. Both
    carry source='doxygen_sqlite', so no change to the AST
    extractor could have reached them."""
    py_db, py_rowids = _make_db(tmp_path / "py", "fixture.py", _PY_FIXTURE)
    _seed_self_edges(py_db, py_rowids, ["main"])
    assert _prune(py_db, tmp_path / "py") == set()

    cpp_db, cpp_rowids = _make_db(tmp_path / "cpp", "fixture.cpp", _CPP_FIXTURE)
    _seed_self_edges(cpp_db, cpp_rowids, ["warn_failure"])
    assert _prune(cpp_db, tmp_path / "cpp") == set()

Activity · 6 steps
lines 347–347py_db, py_rowids = _make_db(tmp_path / "py", "fixture.py", _PY_FIXTURE)lines 348–348_seed_self_edges(py_db, py_rowids, ["main"])lines 349–349assert _prune(py_db, tmp_path / "py") == set()lines 351–351cpp_db, cpp_rowids = _make_db(tmp_path / "cpp", "fixture.cpp", _CPP_FIXTURE)lines 352–352_seed_self_edges(cpp_db, cpp_rowids, ["warn_failure"])lines 353–353assert _prune(cpp_db, tmp_path / "cpp") == set()

test_caller_without_a_body_range_is_left_alone

None test_self_edges.test_caller_without_a_body_range_is_left_alone(tmp_path)

A declaration-only memberdef has no usable body range, so there is nowhere to look for a call site. That is UNVERIFIABLE, not fabricated.

tests/test_self_edges.py:457

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {declared_only}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_caller_without_a_body_range_is_left_alone → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_caller_without_a_body_range_is_left_alone → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 19 lines
def test_caller_without_a_body_range_is_left_alone(tmp_path) -> None:
    """A declaration-only memberdef has no usable body range, so there is
    nowhere to look for a call site. That is UNVERIFIABLE, not fabricated."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    conn = sqlite3.connect(str(db))
    conn.execute(
        "INSERT INTO memberdef (kind, name, file_id, bodyfile_id, bodystart, bodyend) "
        "VALUES ('function', 'declared_only', 1, 1, 0, 0)"
    )
    conn.commit()
    declared_only = conn.execute(
        "SELECT rowid FROM memberdef WHERE name = 'declared_only'"
    ).fetchone()[0]
    conn.close()
    rowids["declared_only"] = declared_only
    _seed_self_edges(db, rowids, ["declared_only"])
    assert _prune(db, tmp_path) == {declared_only}

Activity · 9 steps
lines 460–460db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 461–461conn = sqlite3.connect(str(db))lines 462–465conn.execute( "INSERT INTO memberdef (kind, name, file_id, bodyfile_id, bodystart, bodyend) " "VALUES ('function', 'declared_only', 1, 1, 0, 0)" )lines 466–466conn.commit()lines 467–469declared_only = conn.execute( "SELECT rowid FROM memberdef WHERE name = 'declared_only'" ).fetchone()[0]lines 470–470conn.close()lines 471–471rowids["declared_only"] = declared_onlylines 472–472_seed_self_edges(db, rowids, ["declared_only"])lines 473–473assert _prune(db, tmp_path) == {declared_only}

test_end_to_end_layer3_prunes_what_it_and_doxygen_wrote

None test_self_edges.test_end_to_end_layer3_prunes_what_it_and_doxygen_wrote(tmp_path)

The wiring: `import_ast_call_edges` runs the guard itself, so a build that reaches Layer 3 is guarded with no pipeline-driver change — and a build without tree-sitter skips both together rather than pruning unguarded.

tests/test_self_edges.py:531

Show on the map →

Called by none

Calls _seed_self_edges, import_ast_call_edges

Checks

  • assert survivors == {rowids["descend"], rowids["walk"], rowids["prune"]}
  • assert rowids["cull"] not in survivors, "a bare call in a Python method is not recursion"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_end_to_end_layer3_prunes_what_it_and_doxygen_wrote → import_ast_call_edges → run_harvest
REQ-DDB-PIPE-011measuredtest_end_to_end_layer3_prunes_what_it_and_doxygen_wrote → import_ast_call_edges → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_end_to_end_layer3_prunes_what_it_and_doxygen_wrote → import_ast_call_edges → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-WIKI-054inferredtest_end_to_end_layer3_prunes_what_it_and_doxygen_wrote → import_ast_call_edges → _fold_all_files → _fold_call_payload → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 26 lines
def test_end_to_end_layer3_prunes_what_it_and_doxygen_wrote(tmp_path) -> None:
    """The wiring: `import_ast_call_edges` runs the guard itself, so a build
    that reaches Layer 3 is guarded with no pipeline-driver change — and a build
    without tree-sitter skips both together rather than pruning unguarded.

    Also the end-to-end statement of gh#30: Layer 3 does not merely INHERIT the
    fabricated `cull` self-edge from doxygen, it MANUFACTURES one, because the
    bare `cull(registry)` resolves by name straight back onto the method. So the
    guard is the only thing standing between that call site and a self-edge, and
    `cull` must be absent from the survivors while `prune` — which really does
    call `self.prune` — is present."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["main", "close", "__init__", "descend", "walk", "cull", "prune"])
    import_ast_call_edges(db, tmp_path, None)
    conn = sqlite3.connect(str(db))
    survivors = {
        r[0]
        for r in conn.execute(
            "SELECT DISTINCT caller_rowid FROM call_edges WHERE caller_rowid = callee_rowid"
        ).fetchall()
    }
    conn.close()
    assert survivors == {rowids["descend"], rowids["walk"], rowids["prune"]}
    assert rowids["cull"] not in survivors, "a bare call in a Python method is not recursion"

Activity · 8 steps
lines 542–542db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 543–543_seed_self_edges(db, rowids, ["main", "close", "__init__", "descend", "walk", "cull", "prune"])lines 544–544import_ast_call_edges(db, tmp_path, None)lines 545–545conn = sqlite3.connect(str(db))lines 546–551survivors = { r[0] for r in conn.execute( "SELECT DISTINCT caller_rowid FROM call_edges WHERE caller_rowid = callee_rowid" ).fetchall() }lines 552–552conn.close()lines 553–553assert survivors == {rowids["descend"], rowids["walk"], rowids["prune"]}lines 554–554assert rowids["cull"] not in survivors, "a bare call in a Python method is not recursion"

test_global_scope_qualified_call_is_dropped

None test_self_edges.test_global_scope_qualified_call_is_dropped(tmp_path)

`::close(fd_)` inside a member named `close` calls POSIX close, not the member. Accepting any qualified shape as self-directed would have kept all ten of a C++ codebase's `::close()`/`::open()` rows as recursion.

tests/test_self_edges.py:356

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == set()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_global_scope_qualified_call_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_global_scope_qualified_call_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 9 lines
def test_global_scope_qualified_call_is_dropped(tmp_path) -> None:
    """`::close(fd_)` inside a member named `close` calls POSIX close, not the
    member. Accepting any qualified shape as self-directed would have kept all
    ten of a C++ codebase's `::close()`/`::open()` rows as recursion."""
    db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)
    _seed_self_edges(db, rowids, ["close"])
    assert _prune(db, tmp_path) == set()

Activity · 3 steps
lines 360–360db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)lines 361–361_seed_self_edges(db, rowids, ["close"])lines 362–362assert _prune(db, tmp_path) == set()

test_indirection_layers_are_outside_the_guards_jurisdiction

None test_self_edges.test_indirection_layers_are_outside_the_guards_jurisdiction(tmp_path)

`fnptr` and `declared_dispatch` assert an INDIRECTION no call site names — a stored function pointer, an author-declared virtual seam — so the call-shape rule has no evidence to apply and must not delete them. Neither produced a self-edge on either codebase; this pins the intent.

tests/test_self_edges.py:476

Show on the map →

Called by none

Calls _prune

Checks

  • assert _prune(db, tmp_path) == {rowids["close"], rowids["main"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-011measuredtest_indirection_layers_are_outside_the_guards_jurisdiction → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_indirection_layers_are_outside_the_guards_jurisdiction → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 19 lines
def test_indirection_layers_are_outside_the_guards_jurisdiction(tmp_path) -> None:
    """`fnptr` and `declared_dispatch` assert an INDIRECTION no call site names —
    a stored function pointer, an author-declared virtual seam — so the
    call-shape rule has no evidence to apply and must not delete them. Neither
    produced a self-edge on either codebase; this pins the intent."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    conn = sqlite3.connect(str(db))
    conn.executemany(
        "INSERT INTO call_edges VALUES (?, ?, ?, 'resolved')",
        [
            (rowids["close"], rowids["close"], CALL_SOURCE_FNPTR),
            (rowids["main"], rowids["main"], CALL_SOURCE_DECLARED_DISPATCH),
        ],
    )
    conn.commit()
    conn.close()
    assert _prune(db, tmp_path) == {rowids["close"], rowids["main"]}

Activity · 6 steps
lines 481–481db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 482–482conn = sqlite3.connect(str(db))lines 483–489conn.executemany( "INSERT INTO call_edges VALUES (?, ?, ?, 'resolved')", [ (rowids["close"], rowids["close"], CALL_SOURCE_FNPTR), (rowids["main"], rowids["main"], CALL_SOURCE_DECLARED_DISPATCH), ], )lines 490–490conn.commit()lines 491–491conn.close()lines 492–492assert _prune(db, tmp_path) == {rowids["close"], rowids["main"]}

test_non_self_edges_are_untouched

None test_self_edges.test_non_self_edges_are_untouched(tmp_path)

The guard's whole jurisdiction is the diagonal. An ordinary edge in the same layers must survive byte for byte, including a `main -> descend` edge whose caller IS a pruned self-edge caller.

tests/test_self_edges.py:495

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert remaining == [(rowids["main"], rowids["descend"], CALL_SOURCE_DOXYGEN_SQLITE)]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_non_self_edges_are_untouched → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_non_self_edges_are_untouched → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 20 lines
def test_non_self_edges_are_untouched(tmp_path) -> None:
    """The guard's whole jurisdiction is the diagonal. An ordinary edge in the
    same layers must survive byte for byte, including a `main -> descend` edge
    whose caller IS a pruned self-edge caller."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["main", "close"])
    conn = sqlite3.connect(str(db))
    conn.execute(
        "INSERT INTO call_edges VALUES (?, ?, ?, 'exact')",
        (rowids["main"], rowids["descend"], CALL_SOURCE_DOXYGEN_SQLITE),
    )
    conn.commit()
    conn.close()
    _prune(db, tmp_path)
    conn = sqlite3.connect(str(db))
    remaining = conn.execute("SELECT caller_rowid, callee_rowid, source FROM call_edges").fetchall()
    conn.close()
    assert remaining == [(rowids["main"], rowids["descend"], CALL_SOURCE_DOXYGEN_SQLITE)]

Activity · 11 steps
lines 499–499db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 500–500_seed_self_edges(db, rowids, ["main", "close"])lines 501–501conn = sqlite3.connect(str(db))lines 502–505conn.execute( "INSERT INTO call_edges VALUES (?, ?, ?, 'exact')", (rowids["main"], rowids["descend"], CALL_SOURCE_DOXYGEN_SQLITE), )lines 506–506conn.commit()lines 507–507conn.close()lines 508–508_prune(db, tmp_path)lines 509–509conn = sqlite3.connect(str(db))lines 510–510remaining = conn.execute("SELECT caller_rowid, callee_rowid, source FROM call_edges").fetchall()lines 511–511conn.close()lines 512–512assert remaining == [(rowids["main"], rowids["descend"], CALL_SOURCE_DOXYGEN_SQLITE)]

test_python_module_level_bare_recursion_is_still_kept

None test_self_edges.test_python_module_level_bare_recursion_is_still_kept(tmp_path)

The other half of the guard against over-reach: the rule keys on the enclosing function being a METHOD, not on the file being Python. A module-level `descend(child)` is still recursion, so a rule that keyed on the file's language alone would delete every recursive free function in every Python codebase.

tests/test_self_edges.py:398

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["descend"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_python_module_level_bare_recursion_is_still_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_python_module_level_bare_recursion_is_still_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 11 lines
def test_python_module_level_bare_recursion_is_still_kept(tmp_path) -> None:
    """The other half of the guard against over-reach: the rule keys on the
    enclosing function being a METHOD, not on the file being Python. A
    module-level `descend(child)` is still recursion, so a rule that keyed on
    the file's language alone would delete every recursive free function in
    every Python codebase."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["descend"])
    assert _prune(db, tmp_path) == {rowids["descend"]}

Activity · 3 steps
lines 404–404db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 405–405_seed_self_edges(db, rowids, ["descend"])lines 406–406assert _prune(db, tmp_path) == {rowids["descend"]}

test_self_directed_sites_reads_shape_not_name

None test_self_edges.test_self_directed_sites_reads_shape_not_name(tmp_path)

Unit-level statement of the rule the mechanisms above exercise: a bare call and a `self.`-rooted call are self-directed; `self.conn.close()`, `super().__init__()` and `::close()` are not.

tests/test_self_edges.py:515

Show on the map →

Called by none

Calls _self_directed_sites

Checks

  • assert {"descend", "walk"} <= names
  • assert "close" not in names, "self.conn.close() has a receiver of its own"
  • assert "__init__" not in names, "super().__init__() is not rooted at self"
  • assert {"walk", "brace_expand", "log_warn"} <= names
  • assert "close" not in names, "::close() is the global-scope function"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measured
Source · 16 lines
def test_self_directed_sites_reads_shape_not_name(tmp_path) -> None:
    """Unit-level statement of the rule the mechanisms above exercise: a bare
    call and a `self.`-rooted call are self-directed; `self.conn.close()`,
    `super().__init__()` and `::close()` are not."""
    tree, src = _parse(tmp_path, "fixture.py", _PY_FIXTURE)
    names = {name for name, _line in _self_directed_sites(tree, src)}
    assert {"descend", "walk"} <= names
    assert "close" not in names, "self.conn.close() has a receiver of its own"
    assert "__init__" not in names, "super().__init__() is not rooted at self"

    tree, src = _parse(tmp_path, "fixture.cpp", _CPP_FIXTURE)
    names = {name for name, _line in _self_directed_sites(tree, src)}
    assert {"walk", "brace_expand", "log_warn"} <= names
    assert "close" not in names, "::close() is the global-scope function"

Activity · 9 steps
lines 519–519tree, src = _parse(tmp_path, "fixture.py", _PY_FIXTURE)lines 520–520names = {name for name, _line in _self_directed_sites(tree, src)}lines 521–521assert {"descend", "walk"} <= nameslines 522–522assert "close" not in names, "self.conn.close() has a receiver of its own"lines 523–523assert "__init__" not in names, "super().__init__() is not rooted at self"lines 525–525tree, src = _parse(tmp_path, "fixture.cpp", _CPP_FIXTURE)lines 526–526names = {name for name, _line in _self_directed_sites(tree, src)}lines 527–527assert {"walk", "brace_expand", "log_warn"} <= nameslines 528–528assert "close" not in names, "::close() is the global-scope function"

test_self_rooted_method_recursion_is_kept

None test_self_edges.test_self_rooted_method_recursion_is_kept(tmp_path)

`self.walk(child)` is the ONLY way a Python method can recurse — a bare `walk(child)` inside a method does not resolve to the method at all. A rule that accepted only bare calls would therefore discard every recursive method in every Python codebase, so the receiver has to be inspected, not just the presence of a dot.

tests/test_self_edges.py:303

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["walk"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_self_rooted_method_recursion_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_self_rooted_method_recursion_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 11 lines
def test_self_rooted_method_recursion_is_kept(tmp_path) -> None:
    """`self.walk(child)` is the ONLY way a Python method can recurse — a bare
    `walk(child)` inside a method does not resolve to the method at all. A rule
    that accepted only bare calls would therefore discard every recursive method
    in every Python codebase, so the receiver has to be inspected, not just the
    presence of a dot."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["walk"])
    assert _prune(db, tmp_path) == {rowids["walk"]}

Activity · 3 steps
lines 309–309db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 310–310_seed_self_edges(db, rowids, ["walk"])lines 311–311assert _prune(db, tmp_path) == {rowids["walk"]}

test_self_rooted_recursion_survives_a_bare_call_in_the_same_method

None test_self_edges.test_self_rooted_recursion_survives_a_bare_call_in_the_same_method(tmp_path)

Per CALL SITE, not per function. `prune` makes both a bare `prune(node)` and a real `self.prune(node.next)`; the bare one proves nothing and the self-rooted one proves recursion, so the edge stays. A rule that rejected the whole method on seeing a bare call would drop a true fact.

tests/test_self_edges.py:419

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["prune"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_self_rooted_recursion_survives_a_bare_call_in_the_same_method → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_self_rooted_recursion_survives_a_bare_call_in_the_same_method → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 10 lines
def test_self_rooted_recursion_survives_a_bare_call_in_the_same_method(tmp_path) -> None:
    """Per CALL SITE, not per function. `prune` makes both a bare `prune(node)`
    and a real `self.prune(node.next)`; the bare one proves nothing and the
    self-rooted one proves recursion, so the edge stays. A rule that rejected
    the whole method on seeing a bare call would drop a true fact."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["prune"])
    assert _prune(db, tmp_path) == {rowids["prune"]}

Activity · 3 steps
lines 424–424db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 425–425_seed_self_edges(db, rowids, ["prune"])lines 426–426assert _prune(db, tmp_path) == {rowids["prune"]}

test_super_init_is_dropped

None test_self_edges.test_super_init_is_dropped(tmp_path)

Mechanism 3. `super().__init__()` is DOUBLE damage — it fabricates the self-edge and loses the real subclass-&gt;baseclass edge — so the drop removes a false claim without removing a true one that was ever present.

tests/test_self_edges.py:331

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == set()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_super_init_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_super_init_is_dropped → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 9 lines
def test_super_init_is_dropped(tmp_path) -> None:
    """Mechanism 3. `super().__init__()` is DOUBLE damage — it fabricates the
    self-edge and loses the real subclass->baseclass edge — so the drop removes
    a false claim without removing a true one that was ever present."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["__init__"])
    assert _prune(db, tmp_path) == set()

Activity · 3 steps
lines 335–335db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 336–336_seed_self_edges(db, rowids, ["__init__"])lines 337–337assert _prune(db, tmp_path) == set()

test_the_guard_does_not_reparse_a_file_whose_sites_are_cached

None test_self_edges.test_the_guard_does_not_reparse_a_file_whose_sites_are_cached(Path tmp_path, monkeypatch)

A second guarded run with a warm cache parses nothing.

tests/test_self_edges.py:557

Show on the map →

Called by none

Calls _build_function_indexes, _seed_self_edges, prune_fabricated_self_edges

Checks

  • assert after_cold > 0, "the cold run must actually parse, or this asserts nothing"
  • assert parsed["n"] == after_cold, (f"a warm run must parse nothing; it parsed {parsed['n'] - after_cold} more file(s)" )
  • assert second_survivors == first_survivors, "the cached verdict must match the parsed one"
  • assert rowids["cull"] not in second_survivors, "the guard must still delete a bare call"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-002measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_the_guard_does_not_reparse_a_file_whose_sites_are_cached → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_guard_does_not_reparse_a_file_whose_sites_are_cached → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 69 lines
def test_the_guard_does_not_reparse_a_file_whose_sites_are_cached(
    tmp_path: Path, monkeypatch
) -> None:
    """gh#34. THE GUARD WAS THE LAST PARSER IN A REFRESH THAT PARSES NOTHING ELSE. Measured on
    a 6.8 GB repository with every call payload served from cache, `prune_fabricated_self_edges`
    cost 1,225 ms of a 2,968 ms stage, re-parsing 138 files to ask which of their calls are
    self-rooted.

    THE DOCSTRING WEIGHED TWO OPTIONS AND BOTH WERE WORSE. Widening the shared `ast_calls`
    payload would invalidate every file's cached extraction on every repository for a question
    that concerns under 1% of call sites; parsing here keeps that payload untouched. What it did
    not consider is a payload of this pass's OWN — its own stage tag, its own version — which
    keeps the shared key untouched AND stops re-reading a file nothing changed. The site list is
    `(name, line)` pairs, which is all `_file_self_edge_verdicts` ever took from the tree.

    ASSERTED ON PARSER INVOCATIONS, not on time: a timing assertion in a unit test measures the
    machine, while a parse that did not happen is the mechanism itself.

    @brief A second guarded run with a warm cache parses nothing.
    @version 1
    """
    from clew import call_edges as ce
    from clew.indexcache import IndexCache

    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["descend", "walk", "cull", "prune"])
    cache_path = tmp_path / "clew.db.idxcache"

    parsed = {"n": 0}
    original = ce._ast_parse_one_file

    def counting(*args, **kwargs):  # noqa: ANN002, ANN003, ANN202
        parsed["n"] += 1
        return original(*args, **kwargs)

    monkeypatch.setattr(ce, "_ast_parse_one_file", counting)

    def guarded(run: int) -> set[int]:
        """COPIES THE SEEDED DATABASE so both runs start from identical rows and share only the
        cache — re-seeding in place would re-insert the self-edges the first run deleted."""
        import shutil

        working = tmp_path / f"guarded-{run}.db"
        shutil.copy(db, working)
        conn = sqlite3.connect(str(working))
        _names, file_funcs = _build_function_indexes(conn)
        cache = IndexCache(cache_path, tmp_path)
        prune_fabricated_self_edges(conn, tmp_path, file_funcs, cache=cache)
        conn.commit()
        cache.commit()
        survivors = {
            r[0]
            for r in conn.execute(
                "SELECT DISTINCT caller_rowid FROM call_edges WHERE caller_rowid = callee_rowid"
            ).fetchall()
        }
        conn.close()
        return survivors

    first_survivors = guarded(1)
    after_cold = parsed["n"]
    second_survivors = guarded(2)

    assert after_cold > 0, "the cold run must actually parse, or this asserts nothing"
    assert parsed["n"] == after_cold, (
        f"a warm run must parse nothing; it parsed {parsed['n'] - after_cold} more file(s)"
    )
    assert second_survivors == first_survivors, "the cached verdict must match the parsed one"
    assert rowids["cull"] not in second_survivors, "the guard must still delete a bare call"

1 more lines, not shown

Activity · 17 steps
lines 578–578from clew import call_edges as celines 579–579from clew.indexcache import IndexCachelines 581–581db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 582–582_seed_self_edges(db, rowids, ["descend", "walk", "cull", "prune"])lines 583–583cache_path = tmp_path / "clew.db.idxcache"lines 585–585parsed = {"n": 0}lines 586–586original = ce._ast_parse_one_filelines 588–590def counting(*args, **kwargs): # noqa: ANN002, ANN003, ANN202 parsed["n"] += 1 return original(*args, **kwargs)lines 592–592monkeypatch.setattr(ce, "_ast_parse_one_file", counting)lines 594–614def guarded(run: int) -> set[int]: """COPIES THE SEEDED DATABASE so both runs start from identical rows and share only the cache — re-seeding in place would re-insert the self-edges the first run deleted.""" import shutil working = tmp_path / f"guarded-{run}.db" shutil.copy(db, working) conn = sqlite3.connect(str(working)) _names, file_funcs = _build_function_indexes(conn) cache = IndexCache(cache_path, tmp_path) prune_fabricated_self_edges(conn, tmp_path, file_funcs, cache=cache) conn.commit() cache.commit() survivors = { r[0] for r in conn.execute( "SELECT DISTINCT caller_rowid FROM call_edges WHERE caller_rowid = callee_rowid" ).fetchall() } conn.close() return survivorslines 616–616first_survivors = guarded(1)lines 617–617after_cold = parsed["n"]lines 618–618second_survivors = guarded(2)lines 620–620assert after_cold > 0, "the cold run must actually parse, or this asserts nothing"lines 621–623assert parsed["n"] == after_cold, ( f"a warm run must parse nothing; it parsed {parsed['n'] - after_cold} more file(s)" )lines 624–624assert second_survivors == first_survivors, "the cached verdict must match the parsed one"lines 625–625assert rowids["cull"] not in second_survivors, "the guard must still delete a bare call"

test_this_rooted_method_recursion_is_kept

None test_self_edges.test_this_rooted_method_recursion_is_kept(tmp_path)

The C++ half of the same rule: `this-&gt;walk(...)` inside `Tree::walk`.

tests/test_self_edges.py:314

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["walk"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_this_rooted_method_recursion_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_this_rooted_method_recursion_is_kept → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 7 lines
def test_this_rooted_method_recursion_is_kept(tmp_path) -> None:
    """The C++ half of the same rule: `this->walk(...)` inside `Tree::walk`."""
    db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)
    _seed_self_edges(db, rowids, ["walk"])
    assert _prune(db, tmp_path) == {rowids["walk"]}

Activity · 3 steps
lines 316–316db, rowids = _make_db(tmp_path, "fixture.cpp", _CPP_FIXTURE)lines 317–317_seed_self_edges(db, rowids, ["walk"])lines 318–318assert _prune(db, tmp_path) == {rowids["walk"]}

test_unreadable_caller_file_leaves_its_edges_alone

None test_self_edges.test_unreadable_caller_file_leaves_its_edges_alone(tmp_path)

FAIL CLOSED, and in the direction that matters: a file that will not parse is a fact about the DETECTOR, not about the code, so its self-edges survive unjudged rather than being deleted on absence of evidence.

tests/test_self_edges.py:447

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert _prune(db, tmp_path) == {rowids["close"], rowids["main"]}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-011measuredtest_unreadable_caller_file_leaves_its_edges_alone → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_unreadable_caller_file_leaves_its_edges_alone → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 10 lines
def test_unreadable_caller_file_leaves_its_edges_alone(tmp_path) -> None:
    """FAIL CLOSED, and in the direction that matters: a file that will not
    parse is a fact about the DETECTOR, not about the code, so its self-edges
    survive unjudged rather than being deleted on absence of evidence."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["close", "main"])
    (tmp_path / "fixture.py").unlink()
    assert _prune(db, tmp_path) == {rowids["close"], rowids["main"]}

Activity · 4 steps
lines 451–451db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 452–452_seed_self_edges(db, rowids, ["close", "main"])lines 453–453(tmp_path / "fixture.py").unlink()lines 454–454assert _prune(db, tmp_path) == {rowids["close"], rowids["main"]}

test_verdict_log_identifies_callers_by_rowid

None test_self_edges.test_verdict_log_identifies_callers_by_rowid(tmp_path, caplog)

gh#30's third requirement. The verdict log used to print BARE names, and this repo holds three unrelated `_classify` functions — so `KEPT ... _classify` named a symbol a reader could not locate, and was mistaken for evidence of gh#26, a different defect in a different layer.

tests/test_self_edges.py:429

Show on the map →

Called by none

Calls _prune, _seed_self_edges

Checks

  • assert f"descend#{rowids['descend']}" in text, "a kept caller must carry its rowid"
  • assert f"cull#{rowids['cull']}" in text, "a dropped caller must carry its rowid"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_verdict_log_identifies_callers_by_rowid → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_verdict_log_identifies_callers_by_rowid → _prune → prune_fabricated_self_edges → _gather_self_call_evidence → _self_sites_for → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 18 lines
def test_verdict_log_identifies_callers_by_rowid(tmp_path, caplog) -> None:
    """gh#30's third requirement. The verdict log used to print BARE names, and
    this repo holds three unrelated `_classify` functions — so `KEPT ...
    _classify` named a symbol a reader could not locate, and was mistaken for
    evidence of gh#26, a different defect in a different layer.

    `name#rowid` is checkable against `memberdef`. Asserting the rowid is
    PRESENT is the whole point: a bare name would satisfy any test that only
    looked for the name."""
    db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)
    _seed_self_edges(db, rowids, ["descend", "cull"])
    with caplog.at_level(logging.DEBUG, logger="clew"):
        _prune(db, tmp_path)
    text = caplog.text
    assert f"descend#{rowids['descend']}" in text, "a kept caller must carry its rowid"
    assert f"cull#{rowids['cull']}" in text, "a dropped caller must carry its rowid"

Activity · 7 steps
lines 438–438db, rowids = _make_db(tmp_path, "fixture.py", _PY_FIXTURE)lines 439–439_seed_self_edges(db, rowids, ["descend", "cull"])lines 440–440with caplog.at_level(logging.DEBUG, logger="clew")lines 441–441_prune(db, tmp_path)lines 442–442text = caplog.textlines 443–443assert f"descend#{rowids['descend']}" in text, "a kept caller must carry its rowid"lines 444–444assert f"cull#{rowids['cull']}" in text, "a dropped caller must carry its rowid"