test_dossier_one_shot.py

tests/test_dossier_one_shot.py

The one-shot dossier: body, lock panels, and unresolvable callee names.

test_a_clipped_body_says_so_and_still_reports_its_full_extent

None test_dossier_one_shot.test_a_clipped_body_says_so_and_still_reports_its_full_extent(Path rich_db, Path repo_root)

A SILENTLY clipped body is worse than no body: a reader who cannot see that lines were dropped reasons about a function it has only half read, and a body looks like proof. So `truncated` must flip, `end_line` must describe only what arrived, and `total_lines` must still report the whole extent so the reader knows how much is missing and can call `source` for the rest.

tests/test_dossier_one_shot.py:63

Checks

  • assert d is not None and d.body is not None
  • assert len(d.body.lines) == 2
  • assert d.body.truncated is True
  • assert d.body.end_line == d.body.start_line + 1
  • assert d.body.total_lines > 2, "the full extent must survive the clip"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier
REQ-DDB-QUERY-006measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier
REQ-DDB-QUERY-010measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier
REQ-DDB-QUERY-012measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_a_clipped_body_says_so_and_still_reports_its_full_extent → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 19 lines
def test_a_clipped_body_says_so_and_still_reports_its_full_extent(
    rich_db: Path, repo_root: Path
) -> None:
    """A SILENTLY clipped body is worse than no body: a reader who cannot see that
    lines were dropped reasons about a function it has only half read, and a body looks
    like proof. So `truncated` must flip, `end_line` must describe only what arrived,
    and `total_lines` must still report the whole extent so the reader knows how much
    is missing and can call `source` for the rest.

    Two lines rather than a boundary value, so the clip is unmistakable.
    """
    d = q.function_dossier(rich_db, SETTER, repo_root=repo_root, max_body_lines=2)
    assert d is not None and d.body is not None
    assert len(d.body.lines) == 2
    assert d.body.truncated is True
    assert d.body.end_line == d.body.start_line + 1
    assert d.body.total_lines > 2, "the full extent must survive the clip"

Activity · 6 steps
lines 74–74d = q.function_dossier(rich_db, SETTER, repo_root=repo_root, max_body_lines=2)lines 75–75assert d is not None and d.body is not Nonelines 76–76assert len(d.body.lines) == 2lines 77–77assert d.body.truncated is Truelines 78–78assert d.body.end_line == d.body.start_line + 1lines 79–79assert d.body.total_lines > 2, "the full extent must survive the clip"

test_a_dossier_without_a_working_tree_keeps_every_index_panel

None test_dossier_one_shot.test_a_dossier_without_a_working_tree_keeps_every_index_panel(Path rich_db)

`repo_root` is OPTIONAL and its absence is a supported mode, not a degraded one: the R2 library is used directly by consumers holding only a database file, and a tool set bound without a repo provider is the shape most of this suite uses.

tests/test_dossier_one_shot.py:193

Checks

  • assert without is not None
  • assert without.body is None
  • assert without.external_callees == []
  • assert without.sections, "the lock panels come from the index, not the working tree"
  • assert without.callers == q.function_dossier(rich_db, SETTER).callers

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003inferredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011inferredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier
REQ-DDB-QUERY-006measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier
REQ-DDB-QUERY-010measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier
REQ-DDB-QUERY-012measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_a_dossier_without_a_working_tree_keeps_every_index_panel → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 17 lines
def test_a_dossier_without_a_working_tree_keeps_every_index_panel(rich_db: Path) -> None:
    """`repo_root` is OPTIONAL and its absence is a supported mode, not a degraded one:
    the R2 library is used directly by consumers holding only a database file, and a
    tool set bound without a repo provider is the shape most of this suite uses.

    So the two panels that read bytes go quiet and NOTHING ELSE CHANGES. Compared
    field by field against the full payload rather than spot-checked, so a panel that
    silently depended on the working tree fails here.
    """
    without = q.function_dossier(rich_db, SETTER)
    assert without is not None
    assert without.body is None
    assert without.external_callees == []
    assert without.sections, "the lock panels come from the index, not the working tree"
    assert without.callers == q.function_dossier(rich_db, SETTER).callers

Activity · 6 steps
lines 202–202without = q.function_dossier(rich_db, SETTER)lines 203–203assert without is not Nonelines 204–204assert without.body is Nonelines 205–205assert without.external_callees == []lines 206–206assert without.sections, "the lock panels come from the index, not the working tree"lines 207–207assert without.callers == q.function_dossier(rich_db, SETTER).callers

test_an_external_callee_is_never_promoted_to_a_call_edge

None test_dossier_one_shot.test_an_external_callee_is_never_promoted_to_a_call_edge(Path rich_db, Path repo_root)

A synthetic edge inherits the weakest link. `mark_reachability` and the thread BFS both traverse `call_edges`, so inserting a row for a name that resolves to nothing would propagate an unresolvable premise as fact — and worse, this panel is computed at QUERY time, so it would be a query mutating the index it reads.

tests/test_dossier_one_shot.py:134

Checks

  • assert d is not None and d.external_callees
  • assert after == before, "the external-callee panel must not write edges"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier
REQ-DDB-QUERY-006measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier
REQ-DDB-QUERY-010measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier
REQ-DDB-QUERY-012measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_an_external_callee_is_never_promoted_to_a_call_edge → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 28 lines
def test_an_external_callee_is_never_promoted_to_a_call_edge(
    rich_db: Path, repo_root: Path
) -> None:
    """A synthetic edge inherits the weakest link. `mark_reachability` and the thread
    BFS both traverse `call_edges`, so inserting a row for a name that resolves to
    nothing would propagate an unresolvable premise as fact — and worse, this panel is
    computed at QUERY time, so it would be a query mutating the index it reads.

    Pinned by counting `call_edges` before and after the query rather than by reading
    the payload: the payload cannot show a write that did not happen.
    """
    conn = sqlite3.connect(f"file:{rich_db}?mode=ro", uri=True)
    try:
        before = conn.execute("SELECT COUNT(*) FROM call_edges").fetchone()[0]
    finally:
        conn.close()

    d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)
    assert d is not None and d.external_callees

    conn = sqlite3.connect(f"file:{rich_db}?mode=ro", uri=True)
    try:
        after = conn.execute("SELECT COUNT(*) FROM call_edges").fetchone()[0]
    finally:
        conn.close()
    assert after == before, "the external-callee panel must not write edges"

Activity · 9 steps
lines 145–145conn = sqlite3.connect(f"file:{rich_db}?mode=ro", uri=True)lines 146–146trylines 147–147before = conn.execute("SELECT COUNT(*) FROM call_edges").fetchone()[0]lines 151–151d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)lines 152–152assert d is not None and d.external_calleeslines 154–154conn = sqlite3.connect(f"file:{rich_db}?mode=ro", uri=True)lines 155–155trylines 156–156after = conn.execute("SELECT COUNT(*) FROM call_edges").fetchone()[0]lines 159–159assert after == before, "the external-callee panel must not write edges"

test_an_unreadable_working_tree_loses_the_body_and_not_the_dossier

None test_dossier_one_shot.test_an_unreadable_working_tree_loses_the_body_and_not_the_dossier(Path rich_db, Path tmp_path)

The failure mode of a stale registry entry or a moved checkout. `dossier` must degrade to its index-only panels rather than raising, because the identity, the requirements and the call graph are all still true — and because a raise here would make the composite payload fail where the narrow `source` tool merely returns None.

tests/test_dossier_one_shot.py:355

Checks

  • assert d is not None
  • assert d.body is None
  • assert d.external_callees == []
  • assert d.sections, "the index panels are unaffected by an unreadable tree"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003inferredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011inferredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier
REQ-DDB-QUERY-006measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier
REQ-DDB-QUERY-010measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier
REQ-DDB-QUERY-012measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_an_unreadable_working_tree_loses_the_body_and_not_the_dossier → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 15 lines
def test_an_unreadable_working_tree_loses_the_body_and_not_the_dossier(
    rich_db: Path, tmp_path: Path
) -> None:
    """The failure mode of a stale registry entry or a moved checkout. `dossier` must
    degrade to its index-only panels rather than raising, because the identity, the
    requirements and the call graph are all still true — and because a raise here would
    make the composite payload fail where the narrow `source` tool merely returns None.
    """
    d = q.function_dossier(rich_db, SETTER, repo_root=tmp_path / "no_such_checkout")
    assert d is not None
    assert d.body is None
    assert d.external_callees == []
    assert d.sections, "the index panels are unaffected by an unreadable tree"

Activity · 5 steps
lines 363–363d = q.function_dossier(rich_db, SETTER, repo_root=tmp_path / "no_such_checkout")lines 364–364assert d is not Nonelines 365–365assert d.body is Nonelines 366–366assert d.external_callees == []lines 367–367assert d.sections, "the index panels are unaffected by an unreadable tree"

test_call_lines_are_reported_in_source_order

None test_dossier_one_shot.test_call_lines_are_reported_in_source_order(Path rich_db, Path repo_root)

The harvester walks the tree with a STACK, so a body's sites arrive in roughly REVERSE source order — the first unfiltered output read `[208, 207, 205, 202, 198, 192]`. Descending line numbers read as corrupt, and worse, the per-name cap would then keep a function's LAST few call sites and drop the first, which is backwards for a panel whose value is "what does this thing do".

tests/test_dossier_one_shot.py:452

Checks

  • assert d is not None and d.external_callees
  • assert list(edge.call_lines) == sorted(edge.call_lines), (f"{edge.name} reports {edge.call_lines}, not in source order" )
  • assert firsts == sorted(firsts)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_call_lines_are_reported_in_source_order → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_call_lines_are_reported_in_source_order → function_dossier
REQ-DDB-QUERY-006measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_call_lines_are_reported_in_source_order → function_dossier
REQ-DDB-QUERY-010measuredtest_call_lines_are_reported_in_source_order → function_dossier
REQ-DDB-QUERY-012measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_call_lines_are_reported_in_source_order → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 19 lines
def test_call_lines_are_reported_in_source_order(rich_db: Path, repo_root: Path) -> None:
    """The harvester walks the tree with a STACK, so a body's sites arrive in roughly
    REVERSE source order — the first unfiltered output read `[208, 207, 205, 202, 198,
    192]`. Descending line numbers read as corrupt, and worse, the per-name cap would
    then keep a function's LAST few call sites and drop the first, which is backwards
    for a panel whose value is "what does this thing do".
    """
    d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)
    assert d is not None and d.external_callees
    for edge in d.external_callees:
        assert list(edge.call_lines) == sorted(edge.call_lines), (
            f"{edge.name} reports {edge.call_lines}, not in source order"
        )
    ## And the panel itself is in source order, so the first row is the first thing the
    ## function calls: mbedtls's wrappers lock before they unlock.
    firsts = [e.call_lines[0] for e in d.external_callees]
    assert firsts == sorted(firsts)

Activity · 6 steps
lines 459–459d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)lines 460–460assert d is not None and d.external_calleeslines 461–461◇ for edge in d.external_calleeslines 462–464assert list(edge.call_lines) == sorted(edge.call_lines), ( f"{edge.name} reports {edge.call_lines}, not in source order" )lines 467–467firsts = [e.call_lines[0] for e in d.external_callees]lines 468–468assert firsts == sorted(firsts)

test_the_body_clip_does_not_hide_calls_below_the_cut

None test_dossier_one_shot.test_the_body_clip_does_not_hide_calls_below_the_cut(Path rich_db, Path repo_root)

THE ONE WAY THESE TWO PANELS COULD SILENTLY CONTRADICT EACH OTHER.

tests/test_dossier_one_shot.py:82

Show on the map →

Called by none

Calls _expected_externals, function_dossier

Checks

  • assert clipped is not None
  • assert {e.name for e in clipped.external_callees} == _expected_externals()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier
REQ-DDB-QUERY-006measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier
REQ-DDB-QUERY-010measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier
REQ-DDB-QUERY-012measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_body_clip_does_not_hide_calls_below_the_cut → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 14 lines
def test_the_body_clip_does_not_hide_calls_below_the_cut(rich_db: Path, repo_root: Path) -> None:
    """THE ONE WAY THESE TWO PANELS COULD SILENTLY CONTRADICT EACH OTHER.

    `external_callees` walks the body's RECORDED extent, not the excerpt's clipped one.
    Wiring it to the excerpt instead would have made a display cap quietly delete facts
    — the panel would report fewer callees the smaller the body window got, with
    nothing saying so. `pthread_mutex_unlock` sits several lines below a 2-line cut and
    must still be named.
    """
    clipped = q.function_dossier(rich_db, SETTER, repo_root=repo_root, max_body_lines=2)
    assert clipped is not None
    assert {e.name for e in clipped.external_callees} == _expected_externals()

Activity · 3 steps
lines 91–91clipped = q.function_dossier(rich_db, SETTER, repo_root=repo_root, max_body_lines=2)lines 92–92assert clipped is not Nonelines 93–93assert {e.name for e in clipped.external_callees} == _expected_externals()

test_the_dossier_carries_the_function_body_it_describes

None test_dossier_one_shot.test_the_dossier_carries_the_function_body_it_describes(Path rich_db, Path repo_root)

The body is what seven `source` calls were spent on in one graded cell.

tests/test_dossier_one_shot.py:43

Checks

  • assert d is not None
  • assert d.body is not None, "the one-shot body panel is missing"
  • assert d.body.file == d.file, "the body must come from the file the identity names"
  • assert any("pthread_mutex_lock" in line for line in d.body.lines), ("the body panel is not showing this function's actual source" )
  • assert d.body.truncated is False
  • assert d.body.end_line - d.body.start_line + 1 == len(d.body.lines)
  • assert d.body.total_lines == len(d.body.lines)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier
REQ-DDB-QUERY-006measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier
REQ-DDB-QUERY-010measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier
REQ-DDB-QUERY-012measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_dossier_carries_the_function_body_it_describes → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 20 lines
def test_the_dossier_carries_the_function_body_it_describes(rich_db: Path, repo_root: Path) -> None:
    """The body is what seven `source` calls were spent on in one graded cell.

    Asserts a REAL LINE of the fixture's source, not merely that `lines` is non-empty:
    a body panel wired to the wrong file, or to the wrong extent, still produces a
    plausible-looking list of strings. The line span must also describe exactly what
    arrived, because a reader given `start_line` will use it to quote the code.
    """
    d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)
    assert d is not None
    assert d.body is not None, "the one-shot body panel is missing"
    assert d.body.file == d.file, "the body must come from the file the identity names"
    assert any("pthread_mutex_lock" in line for line in d.body.lines), (
        "the body panel is not showing this function's actual source"
    )
    assert d.body.truncated is False
    assert d.body.end_line - d.body.start_line + 1 == len(d.body.lines)
    assert d.body.total_lines == len(d.body.lines)

Activity · 8 steps
lines 51–51d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)lines 52–52assert d is not Nonelines 53–53assert d.body is not None, "the one-shot body panel is missing"lines 54–54assert d.body.file == d.file, "the body must come from the file the identity names"lines 55–57assert any("pthread_mutex_lock" in line for line in d.body.lines), ( "the body panel is not showing this function's actual source" )lines 58–58assert d.body.truncated is Falselines 59–59assert d.body.end_line - d.body.start_line + 1 == len(d.body.lines)lines 60–60assert d.body.total_lines == len(d.body.lines)

test_the_dossier_names_the_callees_the_index_cannot_resolve

None test_dossier_one_shot.test_the_dossier_names_the_callees_the_index_cannot_resolve(Path rich_db, Path repo_root)

FINDING 5 on mbedtls, reproduced on the synthetic index. `pthread_mutex_lock` has no memberdef row, so `call_edges` — whose `callee_rowid` is `NOT NULL REFERENCES memberdef(rowid)` — cannot represent the call at all, and the graph is silent about the only thing a mutex wrapper does.

tests/test_dossier_one_shot.py:96

Show on the map →

Called by none

Calls _expected_externals, all, function_dossier

Checks

  • assert d is not None
  • assert named == _expected_externals()
  • assert all(e.call_lines for e in d.external_callees), "each must say where it is called"
  • assert d.body is not None
  • assert all(d.body.start_line <= line <= last for line in edge.call_lines), (f"{edge.name} is reported at {edge.call_lines}, outside {d.body.start_line}..{last}" )
  • assert not (named & resolved), "an unresolvable name must never appear as a resolved edge"
  • assert "IntegerStorage_SetUINT8Key" in resolved, ("the resolved edge must survive — the external panel is additive" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier
REQ-DDB-QUERY-006measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier
REQ-DDB-QUERY-010measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier
REQ-DDB-QUERY-012measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_dossier_names_the_callees_the_index_cannot_resolve → function_dossier → _dossier_conn → locks_held_for_rowids
REQ-DDB-WIKI-054inferredtest_the_dossier_names_the_callees_the_index_cannot_resolve → all
Source · 38 lines
def test_the_dossier_names_the_callees_the_index_cannot_resolve(
    rich_db: Path, repo_root: Path
) -> None:
    """FINDING 5 on mbedtls, reproduced on the synthetic index. `pthread_mutex_lock`
    has no memberdef row, so `call_edges` — whose `callee_rowid` is
    `NOT NULL REFERENCES memberdef(rowid)` — cannot represent the call at all, and the
    graph is silent about the only thing a mutex wrapper does.

    THREE claims, and the second two are the guard rails:
      * the unresolvable names are reported, with the line they are called on;
      * they are NOT in `callees`, whose rows are resolved by contract;
      * `callees` still carries the call that DID resolve, so the panel is additive
        rather than a replacement.
    """
    d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)
    assert d is not None
    named = {e.name for e in d.external_callees}
    assert named == _expected_externals()
    assert all(e.call_lines for e in d.external_callees), "each must say where it is called"

    ## BOUNDED BY THIS FUNCTION'S BODY. The walk parses the whole FILE, and the fixture's
    ## `dm.c` calls the same two primitives from a sibling getter — so an unbounded walk
    ## would attribute the getter's call lines to this function and read as a wider
    ## claim than the source supports.
    assert d.body is not None
    last = d.body.start_line + d.body.total_lines - 1
    for edge in d.external_callees:
        assert all(d.body.start_line <= line <= last for line in edge.call_lines), (
            f"{edge.name} is reported at {edge.call_lines}, outside {d.body.start_line}..{last}"
        )

    resolved = {c.name for c in d.callees}
    assert not (named & resolved), "an unresolvable name must never appear as a resolved edge"
    assert "IntegerStorage_SetUINT8Key" in resolved, (
        "the resolved edge must survive — the external panel is additive"
    )

Activity · 12 steps
lines 110–110d = q.function_dossier(rich_db, SETTER, repo_root=repo_root)lines 111–111assert d is not Nonelines 112–112named = {e.name for e in d.external_callees}lines 113–113assert named == _expected_externals()lines 114–114assert all(e.call_lines for e in d.external_callees), "each must say where it is called"lines 120–120assert d.body is not Nonelines 121–121last = d.body.start_line + d.body.total_lines - 1lines 122–122◇ for edge in d.external_calleeslines 123–125assert all(d.body.start_line <= line <= last for line in edge.call_lines), ( f"{edge.name} is reported at {edge.call_lines}, outside {d.body.start_line}..{last}" )lines 127–127resolved = {c.name for c in d.callees}lines 128–128assert not (named & resolved), "an unresolvable name must never appear as a resolved edge"lines 129–131assert "IntegerStorage_SetUINT8Key" in resolved, ( "the resolved edge must survive — the external panel is additive" )

test_the_dossier_returns_detail_prose_and_caps_it_loudly

None test_dossier_one_shot.test_the_dossier_returns_detail_prose_and_caps_it_loudly(Path tmp_path)

The @details prose is RETURNED, and a long one says where it stopped.

tests/test_dossier_one_shot.py:474

Checks

  • assert found is not None
  • assert found.brief == "Brief only."
  • assert "MBEDTLS_ALLOW_PRIVATE_ACCESS" in found.detail, ("the detail prose must be RETURNED — it was already being fetched" )
  • assert _capped_detail(short) == short, "a short detail must not be altered at all"
  • assert capped.startswith("y" * _DETAIL_CAP)
  • assert "truncated" in capped and str(_DETAIL_CAP) in capped and str(len(long_text)) in capped, (f"the notice must name the cap AND the true length, got the tail {capped[-120:]!r}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003inferredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011inferredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier
REQ-DDB-QUERY-006measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier
REQ-DDB-QUERY-010measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier
REQ-DDB-QUERY-012measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_dossier_returns_detail_prose_and_caps_it_loudly → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 61 lines
def test_the_dossier_returns_detail_prose_and_caps_it_loudly(tmp_path: Path) -> None:
    """FETCHED AND THROWN AWAY, for as long as the dossier has existed. `_identity` has always
    selected `detaileddescription` and read only `extract_version` out of it, so a function's
    `@details` text was in hand on every call and never returned.

    Measured on mbedtls 2026-08-14: the deprecation warning about reaching past
    `MBEDTLS_ALLOW_PRIVATE_ACCESS` lives in `mbedtls_ssl_handshake_step`'s detail — two graded Q2
    marks turn on it — and the agent reached it by grepping and then READING
    `include/mbedtls/ssl.h`, because this reply carried one sentence of `brief`. Verified after
    the change: `dossier('mbedtls_ssl_handshake_step').detail` is 1,277 characters and contains
    the token.

    THE CAP SAYS SO. 4,268 mbedtls rows carry detail averaging 1,052 characters, so the common
    case is small and the 14,804-character tail is what the cap is for. A silently truncated
    reply reads as a complete one, which is the failure this project keeps paying for — so the
    notice names both the cap and the true length.
    """
    ## The cap and the capper MOVED to `_common` in C1, when the file subject needed the same
    ## bound on its file-level documentation. Same constant, same notice, one implementation.
    from clew.query._common import DETAIL_CAP as _DETAIL_CAP
    from clew.query._common import capped_detail as _capped_detail

    db = tmp_path / "clew.db"
    conn = sqlite3.connect(str(db))
    conn.executescript(
        """
        CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT);
        INSERT INTO path (rowid, name) VALUES (1, 'library/ssl_tls.c');
        CREATE TABLE memberdef (
            rowid INTEGER PRIMARY KEY, name TEXT, definition TEXT, argsstring TEXT,
            file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER,
            briefdescription TEXT, detaileddescription TEXT, kind TEXT, static INTEGER
        );
        INSERT INTO memberdef VALUES (
            1, 'step', 'int step', '(void)', 1, 1, 10, 20,
            '<para>Brief only.</para>',
            '<para>Defining MBEDTLS_ALLOW_PRIVATE_ACCESS is deprecated.</para>',
            'function', 0
        );
        """
    )
    conn.commit()
    conn.close()

    found = q.function_dossier(db, "step")
    assert found is not None
    assert found.brief == "Brief only."
    assert "MBEDTLS_ALLOW_PRIVATE_ACCESS" in found.detail, (
        "the detail prose must be RETURNED — it was already being fetched"
    )

    ## THE CAP, two-sided: short prose is untouched, long prose is cut AND says so with both
    ## numbers. A cap that reports nothing is the silent-truncation failure.
    short = "x" * (_DETAIL_CAP - 1)
    assert _capped_detail(short) == short, "a short detail must not be altered at all"
    long_text = "y" * (_DETAIL_CAP + 500)
    capped = _capped_detail(long_text)
    assert capped.startswith("y" * _DETAIL_CAP)
    assert "truncated" in capped and str(_DETAIL_CAP) in capped and str(len(long_text)) in capped, (
        f"the notice must name the cap AND the true length, got the tail {capped[-120:]!r}"
    )

1 more lines, not shown

Activity · 17 steps
lines 493–493from clew.query._common import DETAIL_CAP as _DETAIL_CAPlines 494–494from clew.query._common import capped_detail as _capped_detaillines 496–496db = tmp_path / "clew.db"lines 497–497conn = sqlite3.connect(str(db))lines 498–514conn.executescript( """ CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT); INSERT INTO path (rowid, name) VALUES (1, 'library/ssl_tls.c'); CREATE TABLE memberdef ( rowid INTEGER PRIMARY KEY, name TEXT, definition TEXT, argsstring TEXT, file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER, briefdescription TEXT, detaileddescription TEXT, kind TEXT, static INTEGER ); INSERT INTO memberdef VALUES ( 1, 'step', 'int step', '(void)', 1, 1, 10, 20, '<para>Brief only.</para>', '<para>Defining MBEDTLS_ALLOW_PRIVATE_ACCESS is deprecated.</para>', 'function', 0 ); """ )lines 515–515conn.commit()lines 516–516conn.close()lines 518–518found = q.function_dossier(db, "step")lines 519–519assert found is not Nonelines 520–520assert found.brief == "Brief only."lines 521–523assert "MBEDTLS_ALLOW_PRIVATE_ACCESS" in found.detail, ( "the detail prose must be RETURNED — it was already being fetched" )lines 527–527short = "x" * (_DETAIL_CAP - 1)lines 528–528assert _capped_detail(short) == short, "a short detail must not be altered at all"lines 529–529long_text = "y" * (_DETAIL_CAP + 500)lines 530–530capped = _capped_detail(long_text)lines 531–531assert capped.startswith("y" * _DETAIL_CAP)lines 532–534assert "truncated" in capped and str(_DETAIL_CAP) in capped and str(len(long_text)) in capped, ( f"the notice must name the cap AND the true length, got the tail {capped[-120:]!r}" )

test_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed

None test_dossier_one_shot.test_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed(Path tmp_path)

MEASURED AS NOISE BEFORE IT WAS FILTERED. The unfiltered panel reported `len`, `str`, `max`, `range`, `isinstance`, `get`, `items` and `dumps` for one function of this repo's own code — eight rows, none of them a fact about the codebase, crowding out the kind of row the panel exists for.

tests/test_dossier_one_shot.py:423

Show on the map →

Called by none

Calls _noise_db, function_dossier

Checks

  • assert py is not None
  • assert {e.name for e in py.external_callees} == {"helper"}, ("the Python panel must keep the one unindexed project call and drop the rest" )
  • assert c is not None
  • assert {e.name for e in c.external_callees} == {"pow"}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier
REQ-DDB-QUERY-006measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier
REQ-DDB-QUERY-010measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier
REQ-DDB-QUERY-012measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 29 lines
def test_the_external_panel_reports_signal_and_not_every_token_that_is_unindexed(
    tmp_path: Path,
) -> None:
    """MEASURED AS NOISE BEFORE IT WAS FILTERED. The unfiltered panel reported
    `len`, `str`, `max`, `range`, `isinstance`, `get`, `items` and `dumps` for one
    function of this repo's own code — eight rows, none of them a fact about the
    codebase, crowding out the kind of row the panel exists for.

    THREE claims, and the third is the one a language-blind filter would break:
      * a Python BUILTIN is dropped in a Python file;
      * a member TAIL (`rows.append`) is dropped, because resolving it needs the
        receiver's declared type and an unresolved tail says nothing;
      * the SAME name in a C file is KEPT, because `pow` is also libc and a C caller
        of it means it. This is why the builtin filter is gated on the grammar rather
        than applied to the name.
    """
    db = _noise_db(tmp_path)

    py = q.function_dossier(db, "compute", repo_root=tmp_path)
    assert py is not None
    assert {e.name for e in py.external_callees} == {"helper"}, (
        "the Python panel must keep the one unindexed project call and drop the rest"
    )

    c = q.function_dossier(db, "scale", repo_root=tmp_path)
    assert c is not None
    assert {e.name for e in c.external_callees} == {"pow"}

Activity · 7 steps
lines 439–439db = _noise_db(tmp_path)lines 441–441py = q.function_dossier(db, "compute", repo_root=tmp_path)lines 442–442assert py is not Nonelines 443–445assert {e.name for e in py.external_callees} == {"helper"}, ( "the Python panel must keep the one unindexed project call and drop the rest" )lines 447–447c = q.function_dossier(db, "scale", repo_root=tmp_path)lines 448–448assert c is not Nonelines 449–449assert {e.name for e in c.external_callees} == {"pow"}

test_the_lock_panels_agree_with_the_tools_they_replace

None test_dossier_one_shot.test_the_lock_panels_agree_with_the_tools_they_replace(Path rich_db, Path repo_root, Path tmp_path)

`sections` and `locks_held` must be the SAME answers `sections_in` and `locks_held_when` give, or the one-shot is a second implementation of the lock layer rather than a cheaper route to it.

tests/test_dossier_one_shot.py:162

Checks

  • assert setter is not None
  • assert setter.sections == q.sections_in(rich_db, SETTER)
  • assert setter.sections, "the fixture's setter opens a critical section"
  • assert inner is not None
  • assert inner.locks_held == q.locks_held_when(db, "solo")
  • assert [s.lock for s in inner.locks_held] == ["a_mutex"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_lock_panels_agree_with_the_tools_they_replace → sections_in → rowids_for_name
REQ-DDB-QUERY-004measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier
REQ-DDB-QUERY-006measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier
REQ-DDB-QUERY-010measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier
REQ-DDB-QUERY-012measuredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_lock_panels_agree_with_the_tools_they_replace → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_lock_panels_agree_with_the_tools_they_replace → sections_in
Source · 31 lines
def test_the_lock_panels_agree_with_the_tools_they_replace(
    rich_db: Path, repo_root: Path, tmp_path: Path
) -> None:
    """`sections` and `locks_held` must be the SAME answers `sections_in` and
    `locks_held_when` give, or the one-shot is a second implementation of the lock
    layer rather than a cheaper route to it.

    The two panels are asserted on DIFFERENT functions on purpose. They are different
    questions with different join directions — what this function locks
    (`holder_rowid`) versus what is already locked when it runs
    (`critical_section_calls.callee_rowid`) — and a single function that satisfied both
    would let one field be wired to the other's query undetected.
    """
    setter = q.function_dossier(rich_db, SETTER, repo_root=repo_root)
    assert setter is not None
    assert setter.sections == q.sections_in(rich_db, SETTER)
    assert setter.sections, "the fixture's setter opens a critical section"

    ## `locks_held` needs a call site whose callee RESOLVED — csample's two section
    ## members are both `resolution='ambiguous'` and therefore carry a null
    ## `callee_rowid` by design, so the shared fixture cannot state this half. The
    ## hand-built db carries `solo`, whose name is unique so the name-scoped tool and
    ## the identity-scoped panel are asking the same question and equality is a real
    ## claim rather than an artefact of both being empty.
    db = _identity_db(tmp_path)
    inner = q.function_dossier(db, "solo", repo_root=tmp_path)
    assert inner is not None
    assert inner.locks_held == q.locks_held_when(db, "solo")
    assert [s.lock for s in inner.locks_held] == ["a_mutex"]

Activity · 9 steps
lines 175–175setter = q.function_dossier(rich_db, SETTER, repo_root=repo_root)lines 176–176assert setter is not Nonelines 177–177assert setter.sections == q.sections_in(rich_db, SETTER)lines 178–178assert setter.sections, "the fixture's setter opens a critical section"lines 186–186db = _identity_db(tmp_path)lines 187–187inner = q.function_dossier(db, "solo", repo_root=tmp_path)lines 188–188assert inner is not Nonelines 189–189assert inner.locks_held == q.locks_held_when(db, "solo")lines 190–190assert [s.lock for s in inner.locks_held] == ["a_mutex"]

test_the_one_shot_panels_key_on_the_resolved_identity_not_the_name

None test_dossier_one_shot.test_the_one_shot_panels_key_on_the_resolved_identity_not_the_name(Path tmp_path)

gh#26 IS STILL LIVE, and this payload is where it would hurt most: a body quoted under the wrong heading reads as proof, and a lock attributed to the wrong function is a fabricated synchronization claim.

tests/test_dossier_one_shot.py:298

Checks

  • assert d is not None
  • assert d.file == "a.c", "the definition-preferring pick is the a.c helper"
  • assert d.body is not None
  • assert any("port_a_drain" in line for line in d.body.lines)
  • assert not any("port_b_drain" in line for line in d.body.lines)
  • assert {e.name for e in d.external_callees} == {"port_a_drain"}
  • assert [s.lock for s in d.sections] == ["a_mutex"]
  • assert {s.lock for s in q.sections_in(db, "flush")} == {"a_mutex", "b_mutex"}, ("the name-scoped tool must keep unioning — this test is about the DOSSIER" )
  • assert held is not None and held.file == "a.c"
  • assert [s.lock for s in held.locks_held] == ["a_mutex"]
  • assert {s.lock for s in q.locks_held_when(db, "drain")} == {"a_mutex", "b_mutex"}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → sections_in → rowids_for_name
REQ-DDB-QUERY-004measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier
REQ-DDB-QUERY-006measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier
REQ-DDB-QUERY-010measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier
REQ-DDB-QUERY-012measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_one_shot_panels_key_on_the_resolved_identity_not_the_name → sections_in
Source · 36 lines
def test_the_one_shot_panels_key_on_the_resolved_identity_not_the_name(tmp_path: Path) -> None:
    """gh#26 IS STILL LIVE, and this payload is where it would hurt most: a body quoted
    under the wrong heading reads as proof, and a lock attributed to the wrong function
    is a fabricated synchronization claim.

    Both directions are asserted — the picked identity's own facts present, the
    namesake's ABSENT — because a panel that returned the union would satisfy the first
    half alone. `sections_in` on the same name is asserted to return BOTH, which is
    correct for a tool a human typed a name into and is exactly the widening this
    payload must not inherit.
    """
    db = _identity_db(tmp_path)
    d = q.function_dossier(db, "flush", repo_root=tmp_path)
    assert d is not None
    assert d.file == "a.c", "the definition-preferring pick is the a.c helper"

    assert d.body is not None
    assert any("port_a_drain" in line for line in d.body.lines)
    assert not any("port_b_drain" in line for line in d.body.lines)

    assert {e.name for e in d.external_callees} == {"port_a_drain"}

    assert [s.lock for s in d.sections] == ["a_mutex"]
    assert {s.lock for s in q.sections_in(db, "flush")} == {"a_mutex", "b_mutex"}, (
        "the name-scoped tool must keep unioning — this test is about the DOSSIER"
    )

    ## The OTHER lock panel, whose join runs the other way. `drain` exists once per
    ## module and each is called inside its own module's section, so the name-scoped
    ## tool reports two mutexes and the identity-scoped panel must report one.
    held = q.function_dossier(db, "drain", repo_root=tmp_path)
    assert held is not None and held.file == "a.c"
    assert [s.lock for s in held.locks_held] == ["a_mutex"]
    assert {s.lock for s in q.locks_held_when(db, "drain")} == {"a_mutex", "b_mutex"}

Activity · 14 steps
lines 309–309db = _identity_db(tmp_path)lines 310–310d = q.function_dossier(db, "flush", repo_root=tmp_path)lines 311–311assert d is not Nonelines 312–312assert d.file == "a.c", "the definition-preferring pick is the a.c helper"lines 314–314assert d.body is not Nonelines 315–315assert any("port_a_drain" in line for line in d.body.lines)lines 316–316assert not any("port_b_drain" in line for line in d.body.lines)lines 318–318assert {e.name for e in d.external_callees} == {"port_a_drain"}lines 320–320assert [s.lock for s in d.sections] == ["a_mutex"]lines 321–323assert {s.lock for s in q.sections_in(db, "flush")} == {"a_mutex", "b_mutex"}, ( "the name-scoped tool must keep unioning — this test is about the DOSSIER" )lines 328–328held = q.function_dossier(db, "drain", repo_root=tmp_path)lines 329–329assert held is not None and held.file == "a.c"lines 330–330assert [s.lock for s in held.locks_held] == ["a_mutex"]lines 331–331assert {s.lock for s in q.locks_held_when(db, "drain")} == {"a_mutex", "b_mutex"}

test_the_panels_survive_a_database_that_predates_the_lock_layer

None test_dossier_one_shot.test_the_panels_survive_a_database_that_predates_the_lock_layer(Path tmp_path)

A consumer may be pointed at an older artifact and must get an empty answer, not an `OperationalError` — the #41 contract, now reached through a payload that asks four more questions than it used to.

tests/test_dossier_one_shot.py:334

Show on the map →

Called by none

Calls _identity_db, function_dossier

Checks

  • assert d is not None
  • assert d.sections == []
  • assert d.locks_held == []
  • assert d.body is not None, "the body panel does not depend on the lock layer"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier
REQ-DDB-QUERY-006measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier
REQ-DDB-QUERY-010measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier
REQ-DDB-QUERY-012measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_panels_survive_a_database_that_predates_the_lock_layer → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 21 lines
def test_the_panels_survive_a_database_that_predates_the_lock_layer(tmp_path: Path) -> None:
    """A consumer may be pointed at an older artifact and must get an empty answer, not
    an `OperationalError` — the #41 contract, now reached through a payload that asks
    four more questions than it used to.

    Reuses the identity fixture and DROPS the lock tables, so the two lock panels are
    the only difference between this and the test above.
    """
    db = _identity_db(tmp_path)
    conn = sqlite3.connect(db)
    conn.executescript("DROP TABLE critical_section_calls; DROP TABLE lock_acquisitions;")
    conn.commit()
    conn.close()

    d = q.function_dossier(db, "flush", repo_root=tmp_path)
    assert d is not None
    assert d.sections == []
    assert d.locks_held == []
    assert d.body is not None, "the body panel does not depend on the lock layer"

Activity · 10 steps
lines 342–342db = _identity_db(tmp_path)lines 343–343conn = sqlite3.connect(db)lines 344–344conn.executescript("DROP TABLE critical_section_calls; DROP TABLE lock_acquisitions;")lines 345–345conn.commit()lines 346–346conn.close()lines 348–348d = q.function_dossier(db, "flush", repo_root=tmp_path)lines 349–349assert d is not Nonelines 350–350assert d.sections == []lines 351–351assert d.locks_held == []lines 352–352assert d.body is not None, "the body panel does not depend on the lock layer"