test_a_capped_candidate_list_discloses_the_real_total

Tests › tests/test_disambiguation.py

passed Passed in the packaged run.

What this test is for

Why it exists

SILENT TRUNCATION ON THE ONE FIELD WHOSE JOB IS DISAMBIGUATION. `MAX_CANDIDATES` is 8 and `candidate_rows` sliced to it with no disclosure, so `dossier("main")` on mbedtls returned 8 of 143 `main` rows — and the one that mattered, the stub `main` a non-threading build compiles, was not among them. No `_limited` entry, no count, nothing saying a choice had been made, while `candidates` reads as "the identities this name has".

Verifies REQ-DDB-QUERY-010

Given

  1. db = tmp_path / "many.db"
  2. conn = sqlite3.connect(str(db))
6 more
  1. conn.execute( "CREATE TABLE memberdef (rowid_ INTEGER, name TEXT, kind TEXT, definition TEXT, " "file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER)" )
  2. over = _MAX_CANDIDATES + 5
  3. conn.executemany( "INSERT INTO memberdef(name, kind, definition, file_id, bodyfile_id, bodystart) " "VALUES('main', 'function', ?, ?, ?, 1)", [(f"int main{i}(void)", i, i) for i in range(over)], )
  4. conn.execute( "INSERT INTO memberdef(name, kind, definition, file_id, bodyfile_id, bodystart) " "VALUES('solo', 'function', 'int solo(void)', 1, 1, 1)" )
  5. conn.commit()
  6. conn.close()
→

When

  1. _distinct_identities(db, "main")
  2. capped = _candidates_capped(db, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES})
  3. _candidates_capped(db, {"subject": "main", "candidates": [{}] * 2})
2 more
  1. _candidates_capped(db, {"subject": "solo", "candidates": [{}] * _MAX_CANDIDATES})
  2. _candidates_capped(None, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES})
→

Then

  1. ✓ _distinct_identities(db, "main") equals over
  2. ✓ capped is not None
  3. ✓ capped["total_available"] equals over
  4. ✓ capped["reason"] contains "policy"
  5. ✓ capped["how_to_narrow"] contains "SAMPLE"
  6. ✓ _candidates_capped(db, {"subject": "main", "candidates": [{}] * 2}) is None
  7. ✓ _candidates_capped(db, {"subject": "solo", "candidates": [{}] * _MAX_CANDIDATES}) is None
  8. ✓ _candidates_capped(None, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES}) is None

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

… 84 earlier steps

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.pyother filesother filesother filesother filestry (line 224)trydossier85. _empty_callers_note → _refusal_note85_refusal_note86. _flatten_subject → _candidates_capped86_candidates_capped87. _candidates_capped → _distinct_identities87_distinct_identities▶ test enters88. _distinct_identities → connect88connect89. _distinct_identities → table_exists89table_exists90. batch_payload → _hoist_build_wide90_hoist_build_wide91. _batched_dossiers → db91db

… 135 later steps

tests/test_disambiguation.py:466 · its file's page

What it checks (8)

  1. assert _distinct_identities(db, "main") == over, "the total must be counted, not estimated" observes _distinct_identities
  2. assert capped is not None, "a list AT the cap with more rows behind it must disclose" observes _candidates_capped via capped
  3. assert capped["total_available"] == over, f"the total must be the real count; got {capped}" observes _candidates_capped via capped
  4. assert "policy" in capped["reason"], ( "the reason must say it is a policy cap — attributing it to response size sends a reader " "to shrink a payload that was never too big" ) observes _candidates_capped via capped
  5. assert "SAMPLE" in capped["how_to_narrow"], "it must say the rows are a sample, not the set" observes _candidates_capped via capped
  6. assert _candidates_capped(db, {"subject": "main", "candidates": [{}] * 2}) is None, ( "below the cap nothing was dropped, so nothing may be disclosed" ) observes _candidates_capped
  7. assert ( _candidates_capped(db, {"subject": "solo", "candidates": [{}] * _MAX_CANDIDATES}) is None ), "a name AT the cap with no further rows behind it has lost nothing" observes _candidates_capped
  8. assert ( _candidates_capped(None, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES}) is None ), "with no database the total is unknowable and must not be invented" observes _candidates_capped

Where the product reaches it

  • dossier → subject_payload → _flatten_subject → _candidates_capped (flow)
  • dossier → subject_payload → _flatten_subject → _candidates_capped → _distinct_identities (flow)

Call flow

test_a_capped_candidate_list_discloses_the_real_total→_distinct_identities→_candidates_capped

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_a_capped_candidate_list_discloses_the_real_total · 8 checks_distinct_identitiesconnectREQ-DDB-QUERY-001 · measured_distinct_identitiestable_existsREQ-DDB-QUERY-003 · measured

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-QUERY-010catalogunknown
Also reaches 2 requirements

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