test_chain_trace_crosses_thread_key_hop

Tests › tests/test_query.py

passed Passed in the packaged run.

What this test is for

Why it exists

A shared-key hop annotated crosses_thread=1 / to_thread_id surfaces on the Hop with the reader thread's NAME and its dispatch_mode.

Given

  1. db = _hand_db(tmp_path, [(1, "producer"), (2, "consumer")])
  2. conn = sqlite3.connect(str(db))
6 more
  1. conn.execute( """ CREATE TABLE threads ( id INTEGER PRIMARY KEY, name TEXT, entry_memberdef_rowid INTEGER, kind TEXT, source TEXT, confidence TEXT ) """, )
  2. conn.execute( "INSERT INTO threads (id, name, entry_memberdef_rowid, kind, source, " "confidence) VALUES (7, 'consumer_thread', 2, 'task', 'ast_spawn', 'medium')", )
  3. conn.execute( """ CREATE TABLE shared_key_edges ( writer_rowid INTEGER, reader_rowid INTEGER, key_name TEXT, edge_kind TEXT, declared INTEGER, source TEXT, confidence TEXT, dispatch_mode TEXT, edge_triggered INTEGER, crosses_thread INTEGER, to_thread_id INTEGER ) """, )
  4. conn.execute( "INSERT INTO shared_key_edges (writer_rowid, reader_rowid, key_name, " "edge_kind, declared, source, confidence, dispatch_mode, edge_triggered, " "crosses_thread, to_thread_id) VALUES " "(1, 2, 'msg_queue', 'event', 0, 'shared_key_inferred', 'medium', " "'queued', NULL, 1, 7)", )
  5. conn.commit()
  6. conn.close()
→

When

  1. chain = q.chain_trace(db, "producer", max_depth=3)
  2. key_hops = [h for h in chain.hops if h.edge_class == "key"]
  3. hop = key_hops[0]
3 more
  1. d_writer = q.function_dossier(db, "producer")
  2. write = d_writer.writes[0]
  3. roster = q.thread_roster(db)
→

Then

  1. ✓ len(key_hops) equals 1
  2. ✓ (hop.from_name, hop.to_name) equals ("producer", "consumer")
  3. ✓ hop.crosses_thread is True
  4. ✓ hop.dispatch_mode equals "queued"
  5. ✓ hop.to_thread equals "consumer_thread"
  6. ✓ d_writer is not None
  7. ✓ write.crosses_thread is True
  8. ✓ write.to_thread equals "consumer_thread"
  9. ✓ [t.name for t in roster.threads] equals ["consumer_thread"]

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 · 39 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

… 4 steps between

callercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyother filesother filesother filesother filesdossier58. macro_definitions → connect58connect59. macro_definitions → macro_definitions_conn59macro_definitions_conn60. macro_definitions_conn → has_columns60has_columns▶ test enters61–62. macro_definitions_conn → _macro_def61_macro_def +1 more63. gates_covering → table_exists63table_exists▶ test enters64. gates_covering → has_columns64has_columns65. gates_covering → _gate_columns65_gate_columns

… 12 steps between

callercallercallercallerclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyother filesother filesother filesother filesdossier78. _referenced_by → table_exists78table_exists79. _macro_def → symbol_provenance79symbol_provenance80. symbol_provenance → records_provenance80records_provenance▶ test enters81. records_provenance → has_columns81has_columns82. _gate_definitions → _gate_definition_gaps82_gate_definition_gaps83. _flatten_subject → _empty_callers_note83_empty_callers_note

… 51 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

… 21 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

… 6 steps between

callercallercallercallercallerclew/mcp_server/tools_query.pyclew/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/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 429)looploop (line 437)looploop (line 156)looploop (line 191)looploop (line 558)looploop (line 570)loopopt (line 239)optopt (line 285)optloop ×2 (line 208)loop ×2dossier186–187. _identity_walk → _record_identity186_record_identity +1 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_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_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

3 more

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

What it checks (9)

  1. assert len(key_hops) == 1 not attributed
  2. assert (hop.from_name, hop.to_name) == ("producer", "consumer") not attributed
  3. assert hop.crosses_thread is True not attributed
  4. assert hop.dispatch_mode == "queued" not attributed
  5. assert hop.to_thread == "consumer_thread" not attributed
  6. assert d_writer is not None observes function_dossier via d_writer
  7. assert write.crosses_thread is True not attributed
  8. assert write.to_thread == "consumer_thread" not attributed
  9. assert [t.name for t in roster.threads] == ["consumer_thread"] observes thread_roster via roster

Where the product reaches it

  • dossier → _chain_for → chain_trace (flow)
  • main → query_main → _payload → export_search → corpus_payload → thread_roster (flow)

Call flow

test_chain_trace_crosses_thread_key_hop→_hand_db→chain_trace→function_dossier→thread_roster

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_crosses_thread_key_hop · 9 checksfunction_dossier_dossier_connsymbol_provenanceREQ-DDB-INDEX-004 · measuredfunction_dossier… 5 calls …is_python_treeREQ-DDB-PIPE-003 · inferredfunction_dossier… 5 calls …_parseable_fileREQ-DDB-PIPE-011 · inferredfunction_dossier… 5 calls …has_languageREQ-DDB-PIPE-012 · inferredthread_rosterREQ-DDB-QUERY-001 · measuredchain_traceREQ-DDB-QUERY-002 · measuredthread_rostertable_existsREQ-DDB-QUERY-003 · measuredfunction_dossierREQ-DDB-QUERY-004 · measuredchain_trace_make_nodeREQ-DDB-QUERY-005 · measuredfunction_dossier_dossier_conngates_coveringREQ-DDB-QUERY-006 · measuredfunction_dossierREQ-DDB-QUERY-009 · measuredfunction_dossierREQ-DDB-QUERY-010 · measured

and 4 more requirement paths, listed below.

Also reaches 16 requirements

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