test_conceptual_search.py¶
tests/integration/test_conceptual_search.py
The seven queries that misled a real agent, as tests, on this repo's own index.
test_a_conceptual_query_reaches_the_relevant_file
None test_conceptual_search.test_a_conceptual_query_reaches_the_relevant_file(str query, str expected_file, Path self_index_db)
A conceptual query reaches the code that is about that concept.
tests/integration/test_conceptual_search.py:64
Checks
assert files, f"{query!r} returned nothing at all"assert expected_file in files, f"{query!r} reached {sorted(files)}, not {expected_file}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | |
| REQ-DDB-QUERY-001 | measured | |
| REQ-DDB-QUERY-003 | measured | |
| REQ-DDB-QUERY-007 | measured | |
| REQ-DDB-QUERY-012 | measured |
Source · 13 lines
def test_a_conceptual_query_reaches_the_relevant_file(
query: str, expected_file: str, self_index_db: Path
) -> None:
"""Asserts on the FILE and not on a rank position. Ranking is allowed to move as the
corpus grows; reachability is the contract, and pinning "first hit" would make an
unrelated new module a test failure."""
db = self_index_db
hits = search(db, query, limit=25)
files = {hit.file for hit in hits}
assert files, f"{query!r} returned nothing at all"
assert expected_file in files, f"{query!r} reached {sorted(files)}, not {expected_file}"
Activity · 5 steps
test_an_over_specified_query_is_reported_not_answered
None test_conceptual_search.test_an_over_specified_query_is_reported_not_answered(Path self_index_db)
The seventh query is honestly reported as over-specified, not as absent.
tests/integration/test_conceptual_search.py:81
Checks
assert search(db, "server entry command args build") == []assert search(db, "server entry", limit=25)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | |
| REQ-DDB-QUERY-001 | measured | |
| REQ-DDB-QUERY-003 | measured | |
| REQ-DDB-QUERY-007 | measured | |
| REQ-DDB-QUERY-012 | measured |
Source · 14 lines
def test_an_over_specified_query_is_reported_not_answered(self_index_db: Path) -> None:
"""The one documented query the fix does NOT turn into hits, recorded as such rather
than quietly dropped from the list. Five tokens, each matching something on its own,
no single unit carrying all five. The right outcome is an empty result that says it
is not definitive and hands over the per-token counts — which
`test_emptiness.test_a_miss_with_every_token_matching_advises_fewer_tokens` pins at
unit scale. Here the claim is only that it is still empty, so nobody reads the
before/after table as if all seven became hits."""
db = self_index_db
assert search(db, "server entry command args build") == []
## And the shorter form a caller is now told to retry does work.
assert search(db, "server entry", limit=25)
Activity · 3 steps
test_file_hits_are_labelled_and_do_not_displace_symbols
None test_conceptual_search.test_file_hits_are_labelled_and_do_not_displace_symbols(Path self_index_db)
A file hit is labelled as a file, so it cannot be mistaken for a symbol.
tests/integration/test_conceptual_search.py:99
Checks
assert hits[0].kind == "function"assert hits[0].name == "ingest_file_docs"assert hit.kind != "file" or hit.provenance == "file_doc"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | |
| REQ-DDB-QUERY-001 | measured | |
| REQ-DDB-QUERY-003 | measured | |
| REQ-DDB-QUERY-007 | measured | |
| REQ-DDB-QUERY-012 | measured |
Source · 11 lines
def test_file_hits_are_labelled_and_do_not_displace_symbols(self_index_db: Path) -> None:
"""Two properties at once. A `kind == 'file'` hit must never be handed to `dossier`
as if it were a function name, so the label has to be there; and on a query that
matches a real symbol strongly, the symbol must still come first — the file corpus
exists to make a concept findable, not to bury the function that implements it."""
db = self_index_db
hits = search(db, "ingest_file_docs", limit=10)
assert hits[0].kind == "function"
assert hits[0].name == "ingest_file_docs"
for hit in hits:
assert hit.kind != "file" or hit.provenance == "file_doc"1 more lines, not shown