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

Show on the map →

Called by none

Calls none

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

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-012measured
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
lines 70–70db = self_index_dblines 71–71hits = search(db, query, limit=25)lines 72–72files = {hit.file for hit in hits}lines 73–73assert files, f"{query!r} returned nothing at all"lines 74–74assert expected_file in files, f"{query!r} reached {sorted(files)}, not {expected_file}"

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

Show on the map →

Called by none

Calls none

Checks

  • assert search(db, "server entry command args build") == []
  • assert search(db, "server entry", limit=25)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-012measured
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
lines 89–89db = self_index_dblines 90–90assert search(db, "server entry command args build") == []lines 92–92assert search(db, "server entry", limit=25)

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

Show on the map →

Called by none

Calls none

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

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-012measured
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

Activity · 6 steps
lines 104–104db = self_index_dblines 105–105hits = search(db, "ingest_file_docs", limit=10)lines 106–106assert hits[0].kind == "function"lines 107–107assert hits[0].name == "ingest_file_docs"lines 108–108◇ for hit in hitslines 109–109assert hit.kind != "file" or hit.provenance == "file_doc"