test_chain_trace_records_what_the_fanout_taper_dropped

Tests › tests/test_query.py

passed Passed in the packaged run.

What this test is for

Why it exists

#134. The taper halves the neighbour budget per level and floors it at 1 — which is what stops a deep trace exploding — but it applied that with a bare slice and recorded NOTHING. A node with 131 callers and a cap of 8 reported 8 and looked exhausted, and the gap was not derivable from the payload: the dropped neighbours leave no trace in `nodes` or `hops`, so "is this all of them?" had no answer.

Verifies REQ-DDB-QUERY-002

Given

  1. db = tmp_path / "taper.db"
  2. conn = sqlite3.connect(str(db))
7 more
  1. callees = 12
  2. cap = 4
  3. rows = ", ".join( f"({10 + i}, 'function', 'callee_{i:02d}', 'void callee_{i:02d}()')" for i in range(callees) )
  4. edges = ", ".join(f"(1, {10 + i}, 'ast', 'resolved')" for i in range(callees))
  5. conn.executescript( "CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, " "definition TEXT, file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, " "bodyend INTEGER);" "CREATE TABLE path (rowid INTEGER PRIMARY KEY, type INTEGER, name TEXT);" "CREATE TABLE call_edges (caller_rowid INTEGER, callee_rowid INTEGER, source TEXT, " "confidence TEXT);" "INSERT INTO memberdef (rowid, kind, name, definition) VALUES " f"(1, 'function', 'root', 'void root()'), {rows};" f"INSERT INTO call_edges VALUES {edges};" )
  6. conn.commit()
  7. conn.close()
→

When

  1. chain = q.chain_trace(db, "root", direction="forward", max_depth=2, max_neighbors=cap)
  2. root = next(n for n in chain.nodes if n.name == "root")
  3. leaves = [n for n in chain.nodes if n.name != "root"]
2 more
  1. all(n.omitted == 0 for n in leaves)
  2. roomy = q.chain_trace(db, "root", direction="forward", max_depth=2, max_neighbors=99)
→

Then

  1. ✓ root.omitted equals callees - cap
  2. ✓ len([h for h in chain.hops if h.from_name == "root"]) equals cap
  3. ✓ root.omitted + cap equals callees
  4. ✓ leaves holds
  5. ✓ all(n.omitted == 0 for n in leaves) holds
  6. ✓ next(n for n in roomy.nodes if n.name == "root").omitted equals 0

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

Look up one name: everything the index holds about it · 28 of 226 steps

… 45 earlier steps

callercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyother filesother filesother filesother filesdossier46. _ambiguity_counts → table_exists46table_exists47. _ambiguity_counts → function_candidates47function_candidates48–51. function_candidates → table_exists48table_exists +3 more52–53. matching_identity → qualified_name_of52qualified_name_of +1 more

… 111 steps between

callercallercallercallerclew/query/subject.pyclew/query/subject.pyclew/query/subject.pyclew/query/subject.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyopt (line 547)optdossier165. dossier → _chain_for165_chain_for166. _chain_for → chain_trace166chain_trace167. chain_trace → _normalize_direction167_normalize_direction▶ test enters168. chain_trace → _identity_chain168_identity_chain169. _identity_chain → connect169connect

… 2 steps between

callercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyloop (line 429)loopdossier172. _identity_walk → qualified_name_of172qualified_name_of173. _identity_walk → _make_node173_make_node174. _make_node → termini_for174termini_for175. termini_for → table_exists175table_exists176. _make_node → _reqs_for176_reqs_for177. _reqs_for → table_exists177table_exists178. _identity_walk → _identity_call_hops178_identity_call_hops179. _identity_call_hops → table_exists179table_exists

… 1 step between

callercallercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyother filesother filesother filesother filesother filesloop (line 362)looploop (line 368)looploop (line 429)looploop (line 156)looploop (line 191)loopdossier181. _identity_call_hops → qualified_name_of181qualified_name_of182. _identity_call_hops → _collapse_variants182_collapse_variants183. _collapse_variants → _variant_rank183_variant_rank184. _identity_walk → identity_rowids184identity_rowids185–187. _identity_walk → _cap_at_depth185_cap_at_depth +2 more188. chain_trace → connect188connect▶ test enters189. chain_trace → function_candidates189function_candidates190. chain_trace → candidate_rows190candidate_rows191–193. candidate_rows → symbol_provenance191symbol_provenance +2 more194. chain_trace → is_overloaded194is_overloaded195–198. chain_trace → _make_node195_make_node +3 more199. _call_hops → table_exists199table_exists200. _call_hops → _collapse_variants200_collapse_variants201. _neighbors → _key_hops201_key_hops202. _key_hops → _key_edge_rows202_key_edge_rows203. _key_edge_rows → table_exists203table_exists204. _key_edge_rows → _key_r1_projection204_key_r1_projection205. _key_r1_projection → has_columns205has_columns

… 1 step between

callercallercallercallerclew/mcp_server/tools_query.pyclew/mcp_server/tools_query.pyclew/mcp_server/tools_query.pyclew/mcp_server/tools_query.pyclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyother filesother filesother filesother filesloop (line 191)looploop (line 558)looploop (line 570)loopopt (line 239)optopt (line 285)optloop ×2 (line 208)loop ×2dossier207–208. _key_hops → to_bool207to_bool ×2209. chain_trace → _expand_neighbor209_expand_neighbor▶ test enters210. _expand_neighbor → resolve_rowid210resolve_rowid211. resolve_rowid → table_exists211table_exists212. resolve_rowid → function_candidates212function_candidates213. resolve_rowid → _test_scope_term213_test_scope_term214. _expand_neighbor → _make_node214_make_node215. subject_payload → _flatten_subject215_flatten_subject216. dossier → db216db

… 10 later steps

1 more

tests/test_query.py:470 · its file's page

What it checks (6)

  1. assert root.omitted == callees - cap not attributed
  2. assert len([h for h in chain.hops if h.from_name == "root"]) == cap observes chain_trace via chain
  3. assert root.omitted + cap == callees not attributed
  4. assert leaves, "the fixture must reach the callees" not attributed
  5. assert all(n.omitted == 0 for n in leaves) observes all
  6. assert next(n for n in roomy.nodes if n.name == "root").omitted == 0 observes chain_trace via roomy

Where the product reaches it

  • dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all (flow)
  • dossier → _chain_for → chain_trace (flow)

Call flow

test_chain_trace_records_what_the_fanout_taper_dropped→chain_trace→all

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

test_chain_trace_records_what_the_fanout_taper_dropped · 6 checkschain_tracecandidate_rowssymbol_provenanceREQ-DDB-INDEX-004 · inferredchain_traceconnectREQ-DDB-QUERY-001 · measuredchain_traceREQ-DDB-QUERY-002 · tagchain_tracefunction_candidatesREQ-DDB-QUERY-003 · measuredchain_trace_make_nodeREQ-DDB-QUERY-005 · measuredchain_tracefunction_candidatesREQ-DDB-QUERY-010 · measuredallREQ-DDB-WIKI-054 · inferred

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-QUERY-002tag6 of 9: _call_hops, _cap_at_depth, _key_hops, _neighbors and 2 more
Also reaches 6 requirements

Its run touches their code; that is reach, not proof.