test_merged_neighbours_are_a_superset_of_chain_trace_depth_one

Tests › tests/test_query.py

passed Passed in the packaged run.

What this test is for

Why it exists

chain_trace filters `confidence='fuzzy'` because it EXPANDS each hop and one wrong name multiplies into a wrong subtree; the flat neighbour list keeps fuzzy rows so a caller can weigh them (26.1% of a C++ codebase's call edges are fuzzy, and the tool description tells the model to read that field). The divergence is contract, so pin its direction: the flat list can only ever be a SUPERSET, and the difference is fuzzy-only.

Verifies REQ-DDB-QUERY-001

Given

  1. conn = _sqlite3.connect(str(rich_db))
→

When

  1. try: nodes = _all_function_names(rich_db) checked = 0 for name in nodes: for want_callers in (True, False): merged = { (e.name, e.edge_class) for e in _call_edges(conn, name, want_callers, include_dataflow=True) } depth1 = { (n, h.edge_class) for n, h in _neighbors(conn, name, forward=not want_callers) } assert depth1 <= merged, (name, want_callers, depth1 - merged) checked += 1 if depth1 else 0 # Anti-vacuity: a sweep in which every depth1 set was empty would pass # `<=` trivially. Demand that most of the graph actually had neighbours. assert checked > len(nodes), f"only {checked} non-empty pairs over {len(nodes)} nodes" finally: conn.close()
→

Then

  1. —

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 · 22 of 226 steps

… 17 earlier steps

callercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/recovery.pyclew/query/recovery.pyclew/query/recovery.pyclew/query/recovery.pydossier18. _documentation_mentions → table_exists18table_exists19. _documentation_mentions → has_columns19has_columns20. has_columns → table_exists20table_exists21–22. _hint_from → _name_exists21_name_exists +1 more

… 23 steps between

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

… 81 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.pyopt (line 1012)optopt (line 777)optalt (line 780)altopt (line 1014)optdossier135. dossier → connect135connect136. dossier → identity_rowids136identity_rowids137. identity_rowids → function_candidates137function_candidates▶ test enters138–139. identity_rowids → qualified_name_of138qualified_name_of +1 more140–141. identity_rowids → qualified_name_of140qualified_name_of +1 more142. dossier → _selector_from_signature142_selector_from_signature143. _selector_from_signature → qualified_name_of143qualified_name_of

… 37 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.pyother filesother filesother filesother filesloop (line 362)looploop (line 368)looploop (line 429)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. _identity_walk → _cap_at_depth185_cap_at_depth

… 10 steps between

callercallercallercallercallerclew/query/payload.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/_common.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyother filesother filesother filesother filesother filesloop (line 558)looploop (line 156)looploop (line 191)looploop (line 570)loopopt (line 239)optopt (line 285)optloop ×2 (line 208)loop ×2dossier196–197. chain_trace → _cap_at_depth196_cap_at_depth +1 more198. _neighbors → _call_hops198_call_hops▶ test enters199. _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_columns206. _key_r1_projection → table_exists206table_exists207–208. _key_hops → to_bool207to_bool ×2209. chain_trace → _expand_neighbor209_expand_neighbor210. _expand_neighbor → resolve_rowid210resolve_rowid211. resolve_rowid → table_exists211table_exists▶ test enters212. resolve_rowid → function_candidates212function_candidates213. resolve_rowid → _test_scope_term213_test_scope_term214. _expand_neighbor → _make_node214_make_node215. subject_payload → _flatten_subject215_flatten_subject

… 11 later steps

3 more

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

What it checks (2)

  1. assert depth1 <= merged, (name, want_callers, depth1 - merged) observes _neighbors via depth1
  2. assert checked > len(nodes), f"only {checked} non-empty pairs over {len(nodes)} nodes" observes _all_function_names via nodes

Where the product reaches it

  • dossier → _chain_for → chain_trace → _neighbors (flow)

Call flow

test_merged_neighbours_are_a_superset_of_chain_trace_depth_one→_all_function_names→_call_edges→_neighbors

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_merged_neighbours_are_a_superset_of_chain_trace_depth_one · 2 checks_neighborsREQ-DDB-QUERY-002 · measured_call_edges_dataflow_edgesresolve_rowidREQ-DDB-QUERY-003 · measured_call_edges_direct_call_edges_implementors_by_identityREQ-DDB-QUERY-009 · measured_call_edges_dataflow_edgesresolve_rowidREQ-DDB-QUERY-010 · measured

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-QUERY-001catalogunknown
Also reaches 4 requirements

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