test_emptiness.py

tests/test_emptiness.py

gh#21 + gh#31 — an empty result claims only the confidence it has earned.

test_a_conjunction_miss_names_the_dead_token

None test_emptiness.test_a_conjunction_miss_names_the_dead_token(QueryTools tools)

A multi-token miss is not definitive and names the token that emptied it.

tests/test_emptiness.py:150

Show on the map →

Called by none

Calls none

Checks

  • assert out["count"] == 0
  • assert out["token_hits"] == {"roots": 1, "target": 2, "resolution": 0}
  • assert "NOT a definitive negative" in note
  • assert "Do not retry" not in note, "the correct retry must not be forbidden"
  • assert "'resolution'" in note, "the note must name the token that emptied it"
  • assert "CONJUNCTION" in note

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 15 lines
def test_a_conjunction_miss_names_the_dead_token(tools: QueryTools) -> None:
    """gh#31 verbatim. `roots` matches, `target` matches, `resolution` matches nothing,
    and the OLD reply told the caller not to retry — forbidding the one correct next
    move. Dropping a token that matches nothing is not guessing."""
    out = tools.search("roots target resolution")
    assert out["count"] == 0
    ## `target` matches two symbols by name, `roots` one by brief, `resolution` nothing.
    assert out["token_hits"] == {"roots": 1, "target": 2, "resolution": 0}
    note = out["note"]
    assert "NOT a definitive negative" in note
    assert "Do not retry" not in note, "the correct retry must not be forbidden"
    assert "'resolution'" in note, "the note must name the token that emptied it"
    assert "CONJUNCTION" in note

Activity · 8 steps
lines 154–154out = tools.search("roots target resolution")lines 155–155assert out["count"] == 0lines 157–157assert out["token_hits"] == {"roots": 1, "target": 2, "resolution": 0}lines 158–158note = out["note"]lines 159–159assert "NOT a definitive negative" in notelines 160–160assert "Do not retry" not in note, "the correct retry must not be forbidden"lines 161–161assert "'resolution'" in note, "the note must name the token that emptied it"lines 162–162assert "CONJUNCTION" in note

test_a_miss_with_every_token_matching_advises_fewer_tokens

None test_emptiness.test_a_miss_with_every_token_matching_advises_fewer_tokens(QueryTools tools)

A multi-token miss where every token matches advises fewer tokens.

tests/test_emptiness.py:169

Show on the map →

Called by none

Calls none

Checks

  • assert out["count"] == 0
  • assert min(out["token_hits"].values()) > 0
  • assert "NOT a definitive negative" in note
  • assert "FEWER TOKENS" in note

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 12 lines
def test_a_miss_with_every_token_matching_advises_fewer_tokens(tools: QueryTools) -> None:
    """A different diagnosis in KIND, not degree: nothing is deletable because every
    token is pulling its weight, and the problem is that no ONE unit carries them all.
    Naming a guilty token here would be a fabrication."""
    out = tools.search("roots pump")
    assert out["count"] == 0
    assert min(out["token_hits"].values()) > 0
    note = out["note"]
    assert "NOT a definitive negative" in note
    assert "FEWER TOKENS" in note

Activity · 6 steps
lines 173–173out = tools.search("roots pump")lines 174–174assert out["count"] == 0lines 175–175assert min(out["token_hits"].values()) > 0lines 176–176note = out["note"]lines 177–177assert "NOT a definitive negative" in notelines 178–178assert "FEWER TOKENS" in note

test_a_schema_stale_index_withdraws_the_definitive_claim

None test_emptiness.test_a_schema_stale_index_withdraws_the_definitive_claim(Path db)

A schema-stale index must not call an empty result definitive.

tests/test_emptiness.py:413

Show on the map →

Called by none

Calls none

Checks

  • assert current_out["note"], "the control must produce a note at all, or it proves nothing"
  • assert "definitive" in current_out["note"].lower(), ("a CURRENT index must keep the strong wording — a hedge on every reply is a hedge " "nobody reads" )
  • assert "staleness" not in current_out
  • assert stale_out.get("staleness"), "the stale reply must carry the axis this fix keys on"
  • assert "is a definitive" not in stale_out["note"].lower(), ("a reply whose own staleness block says whole layers may be missing must not also call " "its empty result definitive" )
  • assert "not definitive" in stale_out["note"].lower(), "and must say so positively"
  • assert "do not retry" not in stale_out["note"].lower(), ("and must not tell the caller that retrying is wrong, when refreshing is the fix" )
  • assert "refresh" in stale_out["note"].lower(), "it must name the action that resolves it"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-MCP-004measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 66 lines
def test_a_schema_stale_index_withdraws_the_definitive_claim(db: Path) -> None:
    """THE REPLY CONTRADICTED ITSELF, and the half a caller acts on was the wrong half.

    A schema-stale index is one built by an older pipeline than the server expects, and its
    staleness message says so plainly: it "may be missing whole layers rather than merely being
    out of date". A query against it that finds nothing then attached the standard empty note —
    "a definitive empty result from the database ... Do not retry this query or fall back to
    guessing" — beside that very warning. One payload, two incompatible claims.

    THE CONSUMER-VISIBLE SHAPE is the one this project has hit repeatedly from the other side:
    "the lock layer is empty on my repo" is indistinguishable from "my repo has no locks", and an
    unrebuilt index is the likeliest cause for someone who has just upgraded. Their bug report
    then quotes a zero instead of quoting the reason.

    NOT AN ABSENT-CORPUS DOWNGRADE. gh#393 proposed a second one of those inside `_verdict`, and
    it was built and REVERTED because it hedged nearly every reply — most indexes lacking a layer
    lack it because a fixture never made one. This is different in kind and narrower: it fires
    only when the SAME REPLY already carries a schema staleness axis, which is a measured fact
    about this database rather than an inference from a missing layer, and it fires at the one
    place staleness is stamped rather than inside the per-query verdict.

    BOTH DIRECTIONS ASSERTED. A current index must keep the strong wording — spending it is what
    gh#31 fought for, and a guard that fires on the ordinary case gets switched off.

    @brief The definitive claim is withdrawn on a schema-stale index, and kept on a current one.
    @return None.
    @version 1
    """
    schema_stale = [
        {
            "axis": "schema",
            "message": (
                "This index was built by pipeline version 44 and this server expects 50, so the "
                "index predates the server and may be missing whole layers."
            ),
        }
    ]
    stale = QueryTools(lambda: db, lambda: db.parent, lambda: schema_stale)
    current = QueryTools(lambda: db, lambda: db.parent, list)

    absent = "zzznosuchtoken"
    stale_out = stale.search(absent)
    current_out = current.search(absent)

    assert current_out["note"], "the control must produce a note at all, or it proves nothing"
    assert "definitive" in current_out["note"].lower(), (
        "a CURRENT index must keep the strong wording — a hedge on every reply is a hedge "
        "nobody reads"
    )
    assert "staleness" not in current_out

    assert stale_out.get("staleness"), "the stale reply must carry the axis this fix keys on"
    ## THE CLAIM, not the word: the replacement text says "NOT DEFINITIVE", which contains it.
    ## A test that greps for the substring would fail on the correct fix, which is how a good
    ## fix gets reverted to satisfy a bad assertion.
    assert "is a definitive" not in stale_out["note"].lower(), (
        "a reply whose own staleness block says whole layers may be missing must not also call "
        "its empty result definitive"
    )
    assert "not definitive" in stale_out["note"].lower(), "and must say so positively"
    assert "do not retry" not in stale_out["note"].lower(), (
        "and must not tell the caller that retrying is wrong, when refreshing is the fix"
    )
    assert "refresh" in stale_out["note"].lower(), "it must name the action that resolves it"

Activity · 14 steps
lines 441–449schema_stale = [ { "axis": "schema", "message": ( "This index was built by pipeline version 44 and this server expects 50, so the " "index predates the server and may be missing whole layers." ), } ]lines 450–450stale = QueryTools(lambda: db, lambda: db.parent, lambda: schema_stale)lines 451–451current = QueryTools(lambda: db, lambda: db.parent, list)lines 453–453absent = "zzznosuchtoken"lines 454–454stale_out = stale.search(absent)lines 455–455current_out = current.search(absent)lines 457–457assert current_out["note"], "the control must produce a note at all, or it proves nothing"lines 458–461assert "definitive" in current_out["note"].lower(), ( "a CURRENT index must keep the strong wording — a hedge on every reply is a hedge " "nobody reads" )lines 462–462assert "staleness" not in current_outlines 464–464assert stale_out.get("staleness"), "the stale reply must carry the axis this fix keys on"lines 468–471assert "is a definitive" not in stale_out["note"].lower(), ( "a reply whose own staleness block says whole layers may be missing must not also call " "its empty result definitive" )lines 472–472assert "not definitive" in stale_out["note"].lower(), "and must say so positively"lines 473–475assert "do not retry" not in stale_out["note"].lower(), ( "and must not tell the caller that retrying is wrong, when refreshing is the fix" )lines 476–476assert "refresh" in stale_out["note"].lower(), "it must name the action that resolves it"

test_an_absent_symbol_keeps_the_definitive_note

None test_emptiness.test_an_absent_symbol_keeps_the_definitive_note(QueryTools tools)

A genuinely absent single token still gets the full definitive note.

tests/test_emptiness.py:131

Show on the map →

Called by none

Calls none

Checks

  • assert out["count"] == 0
  • assert "definitive" in note
  • assert "Do not retry this query or fall back to guessing" in note
  • assert "NOT an error and NOT a malformed call" in note
  • assert "token_hits" not in out

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 15 lines
def test_an_absent_symbol_keeps_the_definitive_note(tools: QueryTools) -> None:
    """THE CONTROL ON THE WHOLE CHANGE. An agent that retries a well-formed query or
    falls back to guessing wastes a turn and may fabricate, so the strong wording has
    to survive where it is earned. If this test ever needs weakening, the fix has
    become a blanket hedge and has lost its point."""
    out = tools.search("zzznosuchtoken")
    assert out["count"] == 0
    note = out["note"]
    assert "definitive" in note
    assert "Do not retry this query or fall back to guessing" in note
    assert "NOT an error and NOT a malformed call" in note
    ## A single token cannot be an over-specified conjunction, so no diagnosis is paid.
    assert "token_hits" not in out

Activity · 7 steps
lines 136–136out = tools.search("zzznosuchtoken")lines 137–137assert out["count"] == 0lines 138–138note = out["note"]lines 139–139assert "definitive" in notelines 140–140assert "Do not retry this query or fall back to guessing" in notelines 141–141assert "NOT an error and NOT a malformed call" in notelines 143–143assert "token_hits" not in out

test_an_empty_reply_does_not_repeat_the_scope_DERIVATION

None test_emptiness.test_an_empty_reply_does_not_repeat_the_scope_DERIVATION(Path wide_db)

A per-query empty reply carries the covered shape, never the derivation paragraph.

tests/test_emptiness.py:309

Show on the map →

Called by none

Calls none

Checks

  • assert out["count"] == 0
  • assert "definitive" in out["note"]
  • assert out["scope"]["source"] == "whole-repo"
  • assert out["scope"]["extensions"] == [".md", ".py"]
  • assert "reason" not in out["scope"], "the derivation belongs to status, not to a query"
  • assert "index_scope:" not in body, "declaration advice is operator guidance, not an answer"
  • assert "no index_scope is declared for this repo" not in body
  • assert len(note) < NOTE_BUDGET, (f"the empty-search note is {len(note)} chars against a {NOTE_BUDGET} budget, and the " f"client cuts a served string at {_SERVED_STRING_CAP} in silence. Shorten it rather " f"than raising this: the derived corpus list is load-bearing, the prose around it is not." )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 51 lines
def test_an_empty_reply_does_not_repeat_the_scope_DERIVATION(wide_db: Path) -> None:
    """MEASURED on the mbedtls acceptance cell: a zero-row `search` cost 2,556 bytes, two
    thirds of it this paragraph emitted TWICE — once as prose in the note, once as
    `scope.reason` in the payload — and it appeared three times across the one cell. Its
    closing sentence tells the reader to declare an `index_scope:`, which is operator
    configuration a mid-session agent cannot act on.

    Asserted as an ABSENCE plus a byte ceiling, because either alone is weak: an absence
    check passes if the paragraph is merely reworded, and a ceiling passes if the grading is
    gutted instead. The grade itself is pinned by the tests above.

    `status.scope.reason` is where it lives now, and `tests/test_freshness.py` pins that
    verbatim — so this cannot be satisfied by deleting the paragraph from the pipeline."""
    out = QueryTools(lambda: wide_db, lambda: wide_db.parent).search("zzznosuchtoken")
    assert out["count"] == 0
    ## The grade survives — this is not a blanket hedge.
    assert "definitive" in out["note"]
    ## The covered SHAPE still rides in the payload: that is what tells a caller whether a
    ## miss could be a scope miss at all.
    assert out["scope"]["source"] == "whole-repo"
    assert out["scope"]["extensions"] == [".md", ".py"]
    body = str(out)
    assert "reason" not in out["scope"], "the derivation belongs to status, not to a query"
    assert "index_scope:" not in body, "declaration advice is operator guidance, not an answer"
    ## ASSERTED ON A STRING THE TREE ACTUALLY PRODUCES (group C, 1.1.0). This named
    ## doxygen-guard's search clause, which nothing has emitted since `.doxygen-guard.yaml`
    ## stopped being read — so it passed by vacuity. The derivation's own opening clause is
    ## the thing that must not reach a query reply.
    assert "no index_scope is declared for this repo" not in body

    ## MEASURED ON THE NOTE, NOT ON THE REPLY'S REPR (gh#30). This asserted
    ## `len(str(out)) < 900`, and two things were wrong with that. The repr carries `target`,
    ## whose length is a property of somebody's checkout path — so the threshold moved with the
    ## machine, and a real index already produced 927 bytes while this fixture's tmp_path kept
    ## it under. And 900 was a round number rather than a constraint: the actual ceiling is the
    ## 2,048-character per-STRING cap `server.py` measured, which cuts a served string in
    ## silence.
    ##
    ## So the budget is now the note — the string that is actually capped — against a number
    ## with real headroom. `_SEARCHED` is DERIVED from `SEARCHED_MEMBERDEF_KINDS` on purpose, so
    ## the reply grows every time a corpus is added; adding `enumvalue` for gh#6 tripped the old
    ## threshold and was paid for by compressing prose, which does not scale. The headroom is
    ## what lets the derivation keep its promise.
    note = out["note"]
    assert len(note) < NOTE_BUDGET, (
        f"the empty-search note is {len(note)} chars against a {NOTE_BUDGET} budget, and the "
        f"client cuts a served string at {_SERVED_STRING_CAP} in silence. Shorten it rather "
        f"than raising this: the derived corpus list is load-bearing, the prose around it is not."
    )

Activity · 11 steps
lines 322–322out = QueryTools(lambda: wide_db, lambda: wide_db.parent).search("zzznosuchtoken")lines 323–323assert out["count"] == 0lines 325–325assert "definitive" in out["note"]lines 328–328assert out["scope"]["source"] == "whole-repo"lines 329–329assert out["scope"]["extensions"] == [".md", ".py"]lines 330–330body = str(out)lines 331–331assert "reason" not in out["scope"], "the derivation belongs to status, not to a query"lines 332–332assert "index_scope:" not in body, "declaration advice is operator guidance, not an answer"lines 337–337assert "no index_scope is declared for this repo" not in bodylines 352–352note = out["note"]lines 353–357assert len(note) < NOTE_BUDGET, ( f"the empty-search note is {len(note)} chars against a {NOTE_BUDGET} budget, and the " f"client cuts a served string at {_SERVED_STRING_CAP} in silence. Shorten it rather " f"than raising this: the derived corpus list is load-bearing, the prose around it is not." )

test_an_index_without_the_corpus_is_not_definitive

None test_emptiness.test_an_index_without_the_corpus_is_not_definitive(Path tmp_path)

An index with no file-doc corpus says so instead of asserting a negative.

tests/test_emptiness.py:236

Show on the map →

Called by none

Calls none

Checks

  • assert out["count"] == 0
  • assert "NO file-level documentation corpus" in note
  • assert "NOT definitive" in note
  • assert "Do not retry" not in note

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 21 lines
def test_an_index_without_the_corpus_is_not_definitive(tmp_path: Path) -> None:
    """An index built before build 23 has no `file_docs` table. A detector that cannot
    look must not report a negative — the standing lesson, applied to the newest table.
    Note this is the ONLY case where a single-token miss is graded down."""
    path = tmp_path / "old.db"
    conn = sqlite3.connect(path)
    conn.execute("CREATE TABLE path (name TEXT, type INTEGER)")
    conn.execute("INSERT INTO path (name, type) VALUES ('a/b.py', 1)")
    conn.execute(
        "CREATE TABLE memberdef (name TEXT, kind TEXT, briefdescription TEXT, file_id INT)"
    )
    conn.commit()
    conn.close()
    out = QueryTools(lambda: path, lambda: tmp_path).search("deadlock")
    assert out["count"] == 0
    note = out["note"]
    assert "NO file-level documentation corpus" in note
    assert "NOT definitive" in note
    assert "Do not retry" not in note

Activity · 13 steps
lines 240–240path = tmp_path / "old.db"lines 241–241conn = sqlite3.connect(path)lines 242–242conn.execute("CREATE TABLE path (name TEXT, type INTEGER)")lines 243–243conn.execute("INSERT INTO path (name, type) VALUES ('a/b.py', 1)")lines 244–246conn.execute( "CREATE TABLE memberdef (name TEXT, kind TEXT, briefdescription TEXT, file_id INT)" )lines 247–247conn.commit()lines 248–248conn.close()lines 249–249out = QueryTools(lambda: path, lambda: tmp_path).search("deadlock")lines 250–250assert out["count"] == 0lines 251–251note = out["note"]lines 252–252assert "NO file-level documentation corpus" in notelines 253–253assert "NOT definitive" in notelines 254–254assert "Do not retry" not in note

test_data_staleness_alone_keeps_the_definitive_claim

None test_emptiness.test_data_staleness_alone_keeps_the_definitive_claim(Path db)

DATA staleness alone must not withdraw the definitive claim.

tests/test_emptiness.py:483

Show on the map →

Called by none

Calls none

Checks

  • assert out.get("staleness"), "the reply must still carry the data axis"
  • assert "is a definitive" in out["note"].lower(), ("data staleness is the ordinary state of a live repository; hedging on it would hedge " "nearly every reply and spend the strong wording on the common case" )
  • assert "not definitive" not in out["note"].lower()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-MCP-004measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 28 lines
def test_data_staleness_alone_keeps_the_definitive_claim(db: Path) -> None:
    """THE CONTROL ON THE SCHEMA DOWNGRADE, and the one that decides whether it is worth having.

    `data` staleness — some indexed files changed since the build — is the NORMAL state of any
    repository under active development. Nearly every reply in every session of this project has
    carried it. Hedging on it would hedge almost everything, which is precisely the failure that
    made gh#393's absent-corpus downgrade get built and reverted: a warning attached to the
    ordinary case is a warning the reader learns to skip, and then the one that mattered is
    skipped too.

    The two axes say different things and only one undermines the claim. `data` means the index
    describes slightly older code — which does not make "this database holds no such row" false.
    `schema` means the index predates the server and may be missing WHOLE LAYERS — which makes it
    exactly that.

    @brief Data staleness keeps the strong wording; only schema staleness withdraws it.
    @return None.
    @version 1
    """
    data_stale = [{"axis": "data", "message": "3 indexed source file(s) have changed"}]
    out = QueryTools(lambda: db, lambda: db.parent, lambda: data_stale).search("zzznosuchtoken")

    assert out.get("staleness"), "the reply must still carry the data axis"
    assert "is a definitive" in out["note"].lower(), (
        "data staleness is the ordinary state of a live repository; hedging on it would hedge "
        "nearly every reply and spend the strong wording on the common case"
    )
    assert "not definitive" not in out["note"].lower()

1 more lines, not shown

Activity · 5 steps
lines 502–502data_stale = [{"axis": "data", "message": "3 indexed source file(s) have changed"}]lines 503–503out = QueryTools(lambda: db, lambda: db.parent, lambda: data_stale).search("zzznosuchtoken")lines 505–505assert out.get("staleness"), "the reply must still carry the data axis"lines 506–509assert "is a definitive" in out["note"].lower(), ( "data staleness is the ordinary state of a live repository; hedging on it would hedge " "nearly every reply and spend the strong wording on the common case" )lines 510–510assert "not definitive" not in out["note"].lower()

test_extension_certainty_reads_the_uncapped_list

None test_emptiness.test_extension_certainty_reads_the_uncapped_list(Path db)

THE TWO list_files GRADING TESTS LIVED HERE — test_an_out_of_scope_extension_is_ certain_with_a_reason (gh#21's opening *.c case) and test_a_pattern_miss_inside_ the_scope_is_not_definitive — and are DELETED with the tool and its grader.

tests/test_emptiness.py:212

Checks

  • assert index_scope(db, cap=1).extensions == (".md",)
  • assert indexed_extensions(db) == (".md", ".py")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_extension_certainty_reads_the_uncapped_list → index_scope → connect
REQ-DDB-QUERY-003measuredtest_extension_certainty_reads_the_uncapped_list → index_scope → _indexed_paths → table_exists
REQ-DDB-QUERY-007measuredtest_extension_certainty_reads_the_uncapped_list → index_scope
Source · 8 lines
def test_extension_certainty_reads_the_uncapped_list(db: Path) -> None:
    """`IndexScope.extensions` is TRUNCATED for display. Deriving "no `.c` file is
    indexed" from a truncated list would manufacture exactly the false certainty this
    change removes, so the two accessors are separate and this pins that they are."""
    assert index_scope(db, cap=1).extensions == (".md",)
    assert indexed_extensions(db) == (".md", ".py")

Activity · 2 steps
lines 216–216assert index_scope(db, cap=1).extensions == (".md",)lines 217–217assert indexed_extensions(db) == (".md", ".py")

test_index_scope_summarises_provenance_and_shape

None test_emptiness.test_index_scope_summarises_provenance_and_shape(Path db)

The scope summary reports provenance and the covered shape.

tests/test_emptiness.py:115

Show on the map →

Called by none

Calls index_scope

Checks

  • assert scope.source == "doxygen-guard"
  • assert "pre-commit-config" in scope.reason
  • assert scope.file_count == 3
  • assert scope.top_levels == ("app", "docs")
  • assert scope.extensions == (".md", ".py")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_index_scope_summarises_provenance_and_shape → index_scope → connect
REQ-DDB-QUERY-003measuredtest_index_scope_summarises_provenance_and_shape → index_scope → _indexed_paths → table_exists
REQ-DDB-QUERY-007measuredtest_index_scope_summarises_provenance_and_shape → index_scope
Source · 12 lines
def test_index_scope_summarises_provenance_and_shape(db: Path) -> None:
    """This is the information gh#21 says an empty result must carry, and which only
    `status` could produce — a separate call the caller had no reason to make."""
    scope = index_scope(db)
    assert scope.source == "doxygen-guard"
    assert "pre-commit-config" in scope.reason
    ## The synthetic `[STL]` row and the directory row are not files.
    assert scope.file_count == 3
    assert scope.top_levels == ("app", "docs")
    assert scope.extensions == (".md", ".py")

Activity · 6 steps
lines 118–118scope = index_scope(db)lines 119–119assert scope.source == "doxygen-guard"lines 120–120assert "pre-commit-config" in scope.reasonlines 122–122assert scope.file_count == 3lines 123–123assert scope.top_levels == ("app", "docs")lines 124–124assert scope.extensions == (".md", ".py")

test_other_corpora_keep_the_undiluted_definitive_note

None test_emptiness.test_other_corpora_keep_the_undiluted_definitive_note(QueryTools tools)

The other list-returning tools keep the strong note unchanged.

tests/test_emptiness.py:364

Show on the map →

Called by none

Calls none

Checks

  • assert absent["count"] == 0
  • assert "carries NO ingested markdown corpus" in absent["note"], ("a corpus that was never built must say so — 'we looked and it is not there' and " "'there was nothing to look in' are different facts" )
  • assert "NOT definitive" in absent["note"]
  • assert "NOT definitive" not in note, (f"an inventory corpus's emptiness IS absence — grading it would be exactly the dilution " f"this test exists to prevent: {note!r}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-011measured
REQ-DDB-QUERY-014measured
Source · 45 lines
def test_other_corpora_keep_the_undiluted_definitive_note(tools: QueryTools) -> None:
    """The fix is scoped to the corpus whose emptiness can have a cause OTHER than
    absence. A grading applied everywhere would trade one wrong answer for fifteen vague
    ones — which is the failure mode this whole change is a reaction to, inverted.

    THE SCOPE MOVED FROM TOOLS TO CORPORA (gh#372) without moving the line. `search`'s
    SYMBOL corpus is the graded one, because its match is a conjunction a single token can
    empty; both are now the same tool, so what carries the diagnosis is the corpus argument.

    THE PROSE HALF OF THIS TEST IS RETRACTED (gh#404), and the retraction is the point rather
    than a concession. It used to assert prose keeps the undiluted note, on the stated premise
    that "an FTS miss on markdown is a miss". That premise was measured FALSE twice over:
    prose also reads member documentation now, and even before that a token absent from prose
    can sit in three `memberdef` rows of the same index —
    `search(corpus='prose', 'MBEDTLS_ALLOW_PRIVATE_ACCESS')` said "definitive… do not retry"
    about exactly that, and a graded cell obeyed it and ran three greps.

    So prose IS graded now, and this fixture carries no `supplementary_docs` at all — which is
    the ABSENT-CORPUS case, where the honest answer names the absence. That is the same rule
    `_NO_FILE_DOCS` established one corpus over: an index that cannot look must not report a
    negative.

    WHAT THIS TEST STILL GUARDS, undiluted, is the thing it was written for: a surface whose
    emptiness can ONLY mean absence keeps the strong wording. A function with no callers has no
    callers, and weakening that would trade one wrong answer for fifteen vague ones.
    """
    absent = tools.search("no_such_token_anywhere_xyz", corpus="prose")
    assert absent["count"] == 0
    assert "carries NO ingested markdown corpus" in absent["note"], (
        "a corpus that was never built must say so — 'we looked and it is not there' and "
        "'there was nothing to look in' are different facts"
    )
    assert "NOT definitive" in absent["note"]

    ## THE ANTI-DILUTION HALF, on a corpus whose emptiness genuinely cannot mean anything else.
    ## An inventory corpus enumerates a layer; nothing about a token can empty it, so there is
    ## no second cause to grade for and the strong wording is correct.
    inventory = tools.search("no_such_token_anywhere_xyz", corpus="threads")
    note = str(inventory.get("note", ""))
    assert "NOT definitive" not in note, (
        f"an inventory corpus's emptiness IS absence — grading it would be exactly the dilution "
        f"this test exists to prevent: {note!r}"
    )

Activity · 7 steps
lines 390–390absent = tools.search("no_such_token_anywhere_xyz", corpus="prose")lines 391–391assert absent["count"] == 0lines 392–395assert "carries NO ingested markdown corpus" in absent["note"], ( "a corpus that was never built must say so — 'we looked and it is not there' and " "'there was nothing to look in' are different facts" )lines 396–396assert "NOT definitive" in absent["note"]lines 401–401inventory = tools.search("no_such_token_anywhere_xyz", corpus="threads")lines 402–402note = str(inventory.get("note", ""))lines 403–406assert "NOT definitive" not in note, ( f"an inventory corpus's emptiness IS absence — grading it would be exactly the dilution " f"this test exists to prevent: {note!r}" )

test_the_token_diagnosis_is_capped

None test_emptiness.test_the_token_diagnosis_is_capped(QueryTools tools)

The per-token diagnosis is capped, not unbounded.

tests/test_emptiness.py:185

Show on the map →

Called by none

Calls none

Checks

  • assert out["count"] == 0
  • assert len(out["token_hits"]) == 8

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 9 lines
def test_the_token_diagnosis_is_capped(tools: QueryTools) -> None:
    """The diagnosis costs one COUNT per token. It is paid only on a call that has
    already returned nothing, and the worst case is bounded by the TOOL rather than by
    the length of whatever sentence a caller pasted in."""
    out = tools.search("a b c d e f g h i j k l")
    assert out["count"] == 0
    assert len(out["token_hits"]) == 8

Activity · 3 steps
lines 189–189out = tools.search("a b c d e f g h i j k l")lines 190–190assert out["count"] == 0lines 191–191assert len(out["token_hits"]) == 8

test_token_counts_span_symbols_and_file_docs

None test_emptiness.test_token_counts_span_symbols_and_file_docs(Path db)

Token counts span both corpora search reads.

tests/test_emptiness.py:224

Checks

  • assert token_hit_counts(db, ["re-entry"]) == {"re-entry": 1}
  • assert token_hit_counts(db, ["nowhere"]) == {"nowhere": 0}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_token_counts_span_symbols_and_file_docs → token_hit_counts → connect
REQ-DDB-QUERY-003measuredtest_token_counts_span_symbols_and_file_docs → token_hit_counts → _one_token_count → table_exists
REQ-DDB-QUERY-007measuredtest_token_counts_span_symbols_and_file_docs → token_hit_counts
Source · 8 lines
def test_token_counts_span_symbols_and_file_docs(db: Path) -> None:
    """A token matching only a file's documentation did NOT empty the query, and saying
    otherwise would send the caller to drop the one token that was working."""
    ## 'reentry' is in no symbol name or brief; only in fsm.py's file documentation.
    assert token_hit_counts(db, ["re-entry"]) == {"re-entry": 1}
    assert token_hit_counts(db, ["nowhere"]) == {"nowhere": 0}

Activity · 2 steps
lines 228–228assert token_hit_counts(db, ["re-entry"]) == {"re-entry": 1}lines 229–229assert token_hit_counts(db, ["nowhere"]) == {"nowhere": 0}