test_payload_completeness.py

tests/test_payload_completeness.py

A reply must close the loops it opens, because an open loop costs a whole turn.

test_a_files_miss_routes_rather_than_claiming_exhaustion

None test_payload_completeness.test_a_files_miss_routes_rather_than_claiming_exhaustion(QueryTools tools)

A files miss names its boundary and routes, instead of claiming the index is exhausted.

tests/test_payload_completeness.py:106

Show on the map →

Called by none

Calls none

Checks

  • assert note, "an empty files reply must explain itself"
  • assert "Do not retry this query" not in note, ("a miss in ONE corpus must not be phrased as the index being exhausted — that wording is " "what routed a measured cell to four shell calls while the answer sat in build_meta" )
  • assert "INDEXED SOURCE FILES" in note, "the note must name what this corpus actually holds"
  • assert "doc_scope" in note and "inventory" in note, ("route, do not disclaim: the note must name where the answer IS" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-002measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-007measured
REQ-DDB-QUERY-014measured
Source · 25 lines
def test_a_files_miss_routes_rather_than_claiming_exhaustion(tools: QueryTools) -> None:
    """THE DISTINCTION THIS PINS is between "this corpus does not hold that" and "the index does
    not know that". The first is true and useful; the second is false and sends the caller to the
    shell. The default `_many` wording asserted the second.

    THE NEGATIVE ASSERTION IS THE ONE THAT MATTERS. A note can name the boundary AND still carry
    the old "do not retry" sentence, and the caller would act on the stronger claim — so the test
    requires the exhaustion wording to be ABSENT, not merely the routing to be present.

    @brief An empty glob routes onward.
    @version 1
    """
    reply = tools.search("nosuchdirectory/*", corpus="files")
    note = reply.get("note", "")
    assert note, "an empty files reply must explain itself"
    assert "Do not retry this query" not in note, (
        "a miss in ONE corpus must not be phrased as the index being exhausted — that wording is "
        "what routed a measured cell to four shell calls while the answer sat in build_meta"
    )
    assert "INDEXED SOURCE FILES" in note, "the note must name what this corpus actually holds"
    assert "doc_scope" in note and "inventory" in note, (
        "route, do not disclaim: the note must name where the answer IS"
    )

Activity · 6 steps
lines 118–118reply = tools.search("nosuchdirectory/*", corpus="files")lines 119–119note = reply.get("note", "")lines 120–120assert note, "an empty files reply must explain itself"lines 121–124assert "Do not retry this query" not in note, ( "a miss in ONE corpus must not be phrased as the index being exhausted — that wording is " "what routed a measured cell to four shell calls while the answer sat in build_meta" )lines 125–125assert "INDEXED SOURCE FILES" in note, "the note must name what this corpus actually holds"lines 126–128assert "doc_scope" in note and "inventory" in note, ( "route, do not disclaim: the note must name where the answer IS" )

test_a_named_gate_symbol_resolves_to_its_definition_sites

None test_payload_completeness.test_a_named_gate_symbol_resolves_to_its_definition_sites(Path rich_db)

A gate symbol named in a payload resolves to where it is defined.

tests/test_payload_completeness.py:157

Checks

  • assert "SOUND_FINDME" in resolved, ("a gate symbol the index can place must come back placed — leaving it unresolved is the " "open loop that cost four greps in a measured cell" )
  • assert resolved["SOUND_FINDME"][0]["file"], "a resolved site without a file is not a route"
  • assert _gate_definitions(rich_db, itself)[0] == {}, ("a subject listed among its own gates must not have its sites echoed back" )
  • assert _gate_definitions(rich_db, {"name": "X", "gated_by": []})[0] == {}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_named_gate_symbol_resolves_to_its_definition_sites → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → symbol_provenance
REQ-DDB-QUERY-001measuredtest_a_named_gate_symbol_resolves_to_its_definition_sites → _gate_definitions → macro_definitions → connect
REQ-DDB-QUERY-003measuredtest_a_named_gate_symbol_resolves_to_its_definition_sites → _gate_definitions → macro_definitions → macro_definitions_conn → has_columns
REQ-DDB-QUERY-004inferredtest_a_named_gate_symbol_resolves_to_its_definition_sites → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → gates_covering → _with_defaults → _in_default_build
REQ-DDB-QUERY-006measuredtest_a_named_gate_symbol_resolves_to_its_definition_sites → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → gates_covering
REQ-DDB-QUERY-012measuredtest_a_named_gate_symbol_resolves_to_its_definition_sites → _gate_definitions → macro_definitions
REQ-DDB-QUERY-013inferredtest_a_named_gate_symbol_resolves_to_its_definition_sites → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → gates_covering → _with_defaults → decided_default
Source · 32 lines
def test_a_named_gate_symbol_resolves_to_its_definition_sites(rich_db: Path) -> None:
    """ONE CALL, NOT TWO. Naming a symbol the caller now needs, without saying where it lives, is
    an instruction to go looking — and the tool the caller reaches for is grep, because grep is in
    its training distribution millions of times and our tool is not.

    SELF-REFERENCE IS DROPPED, which is not a tidiness rule: a config symbol's own dossier lists
    itself among its gates, and echoing its sites back under a second key would duplicate the
    payload it is already inside while implying a second symbol exists.

    @brief Gate symbols resolve; self-reference does not.
    @version 1
    """
    payload = {"name": "SOMETHING_ELSE", "gated_by": [{"symbol": "SOUND_FINDME"}]}
    ## Returns (resolved, disclosure) since the cap and the no-definition-site case had to
    ## become distinguishable; this test is about the RESOLVED half.
    resolved, _gaps = _gate_definitions(rich_db, payload)
    assert "SOUND_FINDME" in resolved, (
        "a gate symbol the index can place must come back placed — leaving it unresolved is the "
        "open loop that cost four greps in a measured cell"
    )
    assert resolved["SOUND_FINDME"][0]["file"], "a resolved site without a file is not a route"

    ## SELF-REFERENCE, and the payload is otherwise identical so nothing else can explain a change.
    itself = {"name": "SOUND_FINDME", "gated_by": [{"symbol": "SOUND_FINDME"}]}
    assert _gate_definitions(rich_db, itself)[0] == {}, (
        "a subject listed among its own gates must not have its sites echoed back"
    )

    ## AND AN UNGATED PAYLOAD GAINS NOTHING, so the block cannot appear as noise on every reply.
    assert _gate_definitions(rich_db, {"name": "X", "gated_by": []})[0] == {}

Activity · 7 steps
lines 169–169payload = {"name": "SOMETHING_ELSE", "gated_by": [{"symbol": "SOUND_FINDME"}]}lines 172–172resolved, _gaps = _gate_definitions(rich_db, payload)lines 173–176assert "SOUND_FINDME" in resolved, ( "a gate symbol the index can place must come back placed — leaving it unresolved is the " "open loop that cost four greps in a measured cell" )lines 177–177assert resolved["SOUND_FINDME"][0]["file"], "a resolved site without a file is not a route"lines 180–180itself = {"name": "SOUND_FINDME", "gated_by": [{"symbol": "SOUND_FINDME"}]}lines 181–183assert _gate_definitions(rich_db, itself)[0] == {}, ( "a subject listed among its own gates must not have its sites echoed back" )lines 186–186assert _gate_definitions(rich_db, {"name": "X", "gated_by": []})[0] == {}

test_doc_scope_is_empty_rather_than_invented_when_nothing_is_declared

None test_payload_completeness.test_doc_scope_is_empty_rather_than_invented_when_nothing_is_declared(Path rich_db)

Declared doc scope is returned, and its absence is reported as absence.

tests/test_payload_completeness.py:135

Show on the map →

Called by none

Calls doc_scope

Checks

  • assert doc_scope(rich_db) == {}, ("a repository that declares nothing must return an empty mapping, not a fabricated one" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_doc_scope_is_empty_rather_than_invented_when_nothing_is_declared → doc_scope → connect
REQ-DDB-QUERY-003measuredtest_doc_scope_is_empty_rather_than_invented_when_nothing_is_declared → doc_scope → _scope_provenance → table_exists
REQ-DDB-QUERY-007measuredtest_doc_scope_is_empty_rather_than_invented_when_nothing_is_declared → doc_scope
Source · 18 lines
def test_doc_scope_is_empty_rather_than_invented_when_nothing_is_declared(rich_db: Path) -> None:
    """FAIL CLOSED, AND SAY WHICH. The fixture declares no Doxyfile, so {} is the correct answer
    and is a different fact from "this repository has no doc build" — the caller is told the
    index holds no statement, not that no statement exists.

    The populated direction is asserted against the real target in the acceptance run rather
    than here, because a fixture that declares a Doxyfile would be a fixture built to match the
    reader — the standing lesson that a detector agreeing with its own fixture is blind to the
    world.

    @brief An undeclared doc scope reads empty.
    @version 1
    """
    assert doc_scope(rich_db) == {}, (
        "a repository that declares nothing must return an empty mapping, not a fabricated one"
    )

Activity · 1 steps
lines 148–150assert doc_scope(rich_db) == {}, ( "a repository that declares nothing must return an empty mapping, not a fabricated one" )

test_gate_definitions_are_attached_to_the_payload_not_just_computable

None test_payload_completeness.test_gate_definitions_are_attached_to_the_payload_not_just_computable(QueryTools tools, pytest.MonkeyPatch monkeypatch)

The gate resolver is actually WIRED INTO the dossier payload, not merely importable.

tests/test_payload_completeness.py:195

Show on the map →

Called by none

Calls none

Checks

  • assert reply.get("found") is not False, "the fixture must resolve this subject"
  • assert reply.get("gate_definitions") == sentinel, ("the resolver's output must reach the payload — computing it and dropping it is the " "failure a unit test of the resolver cannot see" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-002measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-006measured
REQ-DDB-QUERY-009measured
REQ-DDB-QUERY-010measured
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-014measured
REQ-DDB-SCHEMA-011measured
Source · 42 lines
def test_gate_definitions_are_attached_to_the_payload_not_just_computable(
    tools: QueryTools, monkeypatch: pytest.MonkeyPatch
) -> None:
    """THIS TEST EXISTS BECAUSE A MUTATION SURVIVED. Deleting the call site in `_flatten_subject`
    — the two lines that put `gate_definitions` on the payload — left the whole suite green,
    including the test directly above, because that one calls `_gate_definitions` itself. It
    proved the function works and said nothing about whether anything invokes it.

    That is the accepted-but-unread class this repo keeps rediscovering: a mechanism that is
    correct, tested, and connected to nothing. The unit test cannot see it by construction, so
    the integration assertion has to be separate.

    PATCHED RATHER THAN FIXTURED, deliberately. `rich_db` records ZERO `kconfig_gates` rows —
    its own docstring says the fixture gates nothing on configuration — so no real subject in it
    can produce a `gated_by` list, and a fixture grown to carry one would be a fixture built to
    satisfy this test. What broke was the WIRING, so the wiring is what is asserted: a sentinel
    return must reach the payload.

    @brief The dossier payload carries whatever the gate resolver returns.
    @version 2
    """
    ## PATCHED WHERE `_flatten_subject` LOOKS IT UP. Since 1.3.1 both live in `clew.query.payload`
    ## (shared with the export API); patching the old name in `tools_query` would leave the
    ## flattener calling the real resolver and test nothing. The wiring asserted is unchanged.
    import clew.query.payload as tq

    sentinel = {"SENTINEL_GATE": [{"file": "x.h", "line": 1, "expansion": ""}]}
    ## Returns (resolved, disclosure) now — the cap and the no-definition-site case had to
    ## become distinguishable. The stub returns no disclosure, so this stays a test of the
    ## WIRING of the resolved half and nothing else.
    monkeypatch.setattr(tq, "_gate_definitions", lambda _db, _payload: (sentinel, None))
    reply = tools.dossier("main")
    ## A MISS ENVELOPE NEVER REACHES `_flatten_subject`, so an unresolvable subject would make
    ## this test pass for the wrong reason under the very mutation it exists to catch. The first
    ## draft named a symbol the fixture does not hold and failed for exactly that reason.
    assert reply.get("found") is not False, "the fixture must resolve this subject"
    assert reply.get("gate_definitions") == sentinel, (
        "the resolver's output must reach the payload — computing it and dropping it is the "
        "failure a unit test of the resolver cannot see"
    )

Activity · 6 steps
lines 219–219import clew.query.payload as tqlines 221–221sentinel = {"SENTINEL_GATE": [{"file": "x.h", "line": 1, "expansion": ""}]}lines 225–225monkeypatch.setattr(tq, "_gate_definitions", lambda _db, _payload: (sentinel, None))lines 226–226reply = tools.dossier("main")lines 230–230assert reply.get("found") is not False, "the fixture must resolve this subject"lines 231–234assert reply.get("gate_definitions") == sentinel, ( "the resolver's output must reach the payload — computing it and dropping it is the " "failure a unit test of the resolver cannot see" )

test_operator_stated_macros_are_distinguished_from_the_repos_own_defaults

None test_payload_completeness.test_operator_stated_macros_are_distinguished_from_the_repos_own_defaults()

A build that turns a macro ON records that the repository ships it OFF.

tests/test_payload_completeness.py:240

Checks

  • assert _stated_only(declared, harvested) == ("MBEDTLS_THREADING_C",), ("only the macro the repository's own header does NOT define ships OFF; " "`WITH_VALUE` differs only in its VALUE and must not count as operator-only" )
  • assert _stated_only(declared, ()) == (), ("with no header read there is no claim to make about the repository's defaults — " "asserting every stated macro ships OFF would invent a fact" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_operator_stated_macros_are_distinguished_from_the_repos_own_defaults → _stated_only
Source · 38 lines
def test_operator_stated_macros_are_distinguished_from_the_repos_own_defaults() -> None:
    """THE ONLY DEFECT IN THIS FAMILY THAT PRODUCED A WRONG ANSWER RATHER THAN A MISSING ONE.

    Measured on mbedtls: the acceptance build declares `MBEDTLS_THREADING_C` as PREDEFINED so
    doxygen can reach the guarded bodies. The repository ships it COMMENTED OUT. An agent asked
    whether threading is on by default, saw the name in `configured_macros`, and concluded the
    opposite of the truth — on two graded marks.

    `macros` is the UNION of what the operator stated and what the repo's own header defines, and
    the union cannot answer "does the repository ship this ON". `stated_only` is the difference,
    and membership is the whole signal: a name in it ships OFF, a name in `macros` but not in it
    was read from the header and ships ON.

    COMPARED BY BARE NAME, asserted here because both sides are rendered doxygen tokens (`"X"`,
    `"X=1"`) and a token comparison would call those two different macros — the exact drift that
    once labelled every declared macro `undeclared`.

    EMPTY WITHOUT A HEADER is the fail-closed half: with nothing harvested there is no statement
    about the repository's defaults to make, and claiming every stated macro ships OFF would be
    inventing a fact.

    @brief stated_only separates this build's variant from the repository's default.
    @version 1
    """
    from clew.preprocessor import _stated_only

    declared = ('"MBEDTLS_THREADING_C"', '"MBEDTLS_HAVE_ASM"', '"WITH_VALUE=1"')
    harvested = ('"MBEDTLS_HAVE_ASM"', '"WITH_VALUE=7"', '"MBEDTLS_CIPHER_C"')
    assert _stated_only(declared, harvested) == ("MBEDTLS_THREADING_C",), (
        "only the macro the repository's own header does NOT define ships OFF; "
        "`WITH_VALUE` differs only in its VALUE and must not count as operator-only"
    )
    assert _stated_only(declared, ()) == (), (
        "with no header read there is no claim to make about the repository's defaults — "
        "asserting every stated macro ships OFF would invent a fact"
    )

Activity · 5 steps
lines 264–264from clew.preprocessor import _stated_onlylines 266–266declared = ('"MBEDTLS_THREADING_C"', '"MBEDTLS_HAVE_ASM"', '"WITH_VALUE=1"')lines 267–267harvested = ('"MBEDTLS_HAVE_ASM"', '"WITH_VALUE=7"', '"MBEDTLS_CIPHER_C"')lines 268–271assert _stated_only(declared, harvested) == ("MBEDTLS_THREADING_C",), ( "only the macro the repository's own header does NOT define ships OFF; " "`WITH_VALUE` differs only in its VALUE and must not count as operator-only" )lines 272–275assert _stated_only(declared, ()) == (), ( "with no header read there is no claim to make about the repository's defaults — " "asserting every stated macro ships OFF would invent a fact" )

test_the_files_inventory_is_not_hidden_behind_an_omitted_argument

None test_payload_completeness.test_the_files_inventory_is_not_hidden_behind_an_omitted_argument(QueryTools tools)

The directory inventory rides along whether or not a glob was given.

tests/test_payload_completeness.py:59

Show on the map →

Called by none

Calls doc_scope

Checks

  • assert "inventory" in reply, (f"the files corpus answered {text!r} without the directory inventory — a caller " f"wanting the breakdown has to ask again, and one extra call costs a full context " f"re-read" )
  • assert reply["inventory"]["directories"], (f"the inventory accompanying {text!r} is empty; the fixture has directories, so this " f"is the block being attached without being populated" )
  • assert rollup["directories"], "the no-text route must still BE the rollup"
  • assert "inventory" not in rollup, ("the no-text reply already IS the inventory; a second copy duplicates every row and the " "whole rollup_meaning sentence" )
  • assert "doc_scope" in rollup or not doc_scope(tools.db(None)), ("doc_scope is genuinely not in the rollup, so it must survive on this route" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-MCP-003measured
REQ-DDB-QUERY-001measuredtest_the_files_inventory_is_not_hidden_behind_an_omitted_argument → doc_scope → connect
REQ-DDB-QUERY-002measured
REQ-DDB-QUERY-003measuredtest_the_files_inventory_is_not_hidden_behind_an_omitted_argument → doc_scope → _scope_provenance → table_exists
REQ-DDB-QUERY-007measuredtest_the_files_inventory_is_not_hidden_behind_an_omitted_argument → doc_scope
REQ-DDB-QUERY-014measured
Source · 43 lines
def test_the_files_inventory_is_not_hidden_behind_an_omitted_argument(tools: QueryTools) -> None:
    """THE LOAD-BEARING HALF IS THE GLOB CASE. The rollup always answered the no-text call; what
    it never did was accompany a glob, and a glob is what a caller with a question actually
    sends. Q4 sent four (`docs/*`, `Doxyfile`, `doxygen`, `library/*`) and saw the inventory
    zero times.

    ASSERTED ON BOTH ROUTES so the fix cannot be read as moving the capability rather than
    widening it: the no-text call must still carry it.

    Behaviour that appears only when a parameter is OMITTED cannot be described, and what cannot
    be described cannot be predicted by a caller choosing arguments from a description.

    @brief Both files routes carry the inventory.
    @version 1
    """
    for text in ("*.c", "nosuchdirectory/*"):
        reply = tools.search(text, corpus="files")
        assert "inventory" in reply, (
            f"the files corpus answered {text!r} without the directory inventory — a caller "
            f"wanting the breakdown has to ask again, and one extra call costs a full context "
            f"re-read"
        )
        assert reply["inventory"]["directories"], (
            f"the inventory accompanying {text!r} is empty; the fixture has directories, so this "
            f"is the block being attached without being populated"
        )

    ## THE NO-TEXT ROUTE IS THE ROLLUP ITSELF, and must not also carry a copy of it. The first
    ## version of this fix merged the context block into BOTH routes, so the empty-text reply
    ## emitted `directories` and the ~700-character `rollup_meaning` TWICE — measured on a real run,
    ## and the ordinary shape of a context block bolted onto a route that already had one. Tokens
    ## are a graded axis, so duplication is not cosmetic.
    rollup = tools.search("", corpus="files")
    assert rollup["directories"], "the no-text route must still BE the rollup"
    assert "inventory" not in rollup, (
        "the no-text reply already IS the inventory; a second copy duplicates every row and the "
        "whole rollup_meaning sentence"
    )
    assert "doc_scope" in rollup or not doc_scope(tools.db(None)), (
        "doc_scope is genuinely not in the rollup, so it must survive on this route"
    )

Activity · 8 steps
lines 74–74◇ for text in ("*.c", "nosuchdirectory/*")lines 75–75reply = tools.search(text, corpus="files")lines 76–80assert "inventory" in reply, ( f"the files corpus answered {text!r} without the directory inventory — a caller " f"wanting the breakdown has to ask again, and one extra call costs a full context " f"re-read" )lines 81–84assert reply["inventory"]["directories"], ( f"the inventory accompanying {text!r} is empty; the fixture has directories, so this " f"is the block being attached without being populated" )lines 91–91rollup = tools.search("", corpus="files")lines 92–92assert rollup["directories"], "the no-text route must still BE the rollup"lines 93–96assert "inventory" not in rollup, ( "the no-text reply already IS the inventory; a second copy duplicates every row and the " "whole rollup_meaning sentence" )lines 97–99assert "doc_scope" in rollup or not doc_scope(tools.db(None)), ( "doc_scope is genuinely not in the rollup, so it must survive on this route" )

test_unresolved_gates_distinguish_no_definition_site_from_never_tried

None test_payload_completeness.test_unresolved_gates_distinguish_no_definition_site_from_never_tried(Path rich_db)

An unresolved gate must say WHICH kind of unresolved it is.

tests/test_payload_completeness.py:282

Checks

  • assert "SOUND_FINDME" in resolved, "precondition: the placeable gate must still resolve"
  • assert gaps is not None, "an unplaceable gate must be disclosed, not silently dropped"
  • assert gaps["no_definition_site"] == ["NOWHERE_DEFINED_XYZ"], (f"the unplaceable gate must be NAMED, not counted — a count leaves a reader unable to ask " f"for the one they care about; got {gaps}" )
  • assert "not_attempted" not in gaps, "nothing was capped here, so nothing may claim it was"
  • assert gaps2 is not None and len(gaps2["not_attempted"]) == 3, (f"the three gates beyond the cap must be named as not attempted; got {gaps2}" )
  • assert gaps3 is None, ("when every gate resolves there is nothing to disclose — a block on every reply is one a " "reader learns to skip" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_unresolved_gates_distinguish_no_definition_site_from_never_tried → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → symbol_provenance
REQ-DDB-QUERY-001measuredtest_unresolved_gates_distinguish_no_definition_site_from_never_tried → _gate_definitions → macro_definitions → connect
REQ-DDB-QUERY-003measuredtest_unresolved_gates_distinguish_no_definition_site_from_never_tried → _gate_definitions → macro_definitions → macro_definitions_conn → has_columns
REQ-DDB-QUERY-004inferredtest_unresolved_gates_distinguish_no_definition_site_from_never_tried → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → gates_covering → _with_defaults → _in_default_build
REQ-DDB-QUERY-006measuredtest_unresolved_gates_distinguish_no_definition_site_from_never_tried → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → gates_covering
REQ-DDB-QUERY-012measuredtest_unresolved_gates_distinguish_no_definition_site_from_never_tried → _gate_definitions → macro_definitions
REQ-DDB-QUERY-013inferredtest_unresolved_gates_distinguish_no_definition_site_from_never_tried → _gate_definitions → macro_definitions → macro_definitions_conn → _macro_def → gates_covering → _with_defaults → decided_default
Source · 53 lines
def test_unresolved_gates_distinguish_no_definition_site_from_never_tried(rich_db: Path) -> None:
    """TWO GAPS THAT LOOKED IDENTICAL AND MEAN OPPOSITE THINGS. `if sites:` dropped the key for a
    gate the index cannot place, so its absence was indistinguishable from having been capped out.

    `no_definition_site` is usually the ANSWER: a `//#define MBEDTLS_THREADING_C` is not a
    definition the preprocessor sees, so it produces no `memberdef` row. "Nowhere actively defined"
    is what a reader asking about the shipped default needs.

    `not_attempted` is a fact about the TOOL. It promises more exists and claims nothing about the
    repository.

    AND THE CAP WAS A LOTTERY. It sliced `sorted(names)`, so with mbedtls' twelve-macro conditional
    the survivors were chosen ALPHABETICALLY and `MBEDTLS_THREADING_C` — tenth of twelve, and the
    symbol two graded marks ask about — silently vanished. The previous comment called 6 "not a
    budget the ordinary case approaches"; twelve is the ordinary case.

    @brief The two unresolved kinds are named separately, and neither fires when all resolve.
    @return None.
    @version 1
    """
    from clew.mcp_server.tools_query import _GATE_DEFINITION_CAP, _gate_definitions

    ## A gate the index genuinely cannot place, beside one it can.
    payload = {
        "name": "subject_fn",
        "gated_by": [{"symbol": "SOUND_FINDME"}, {"symbol": "NOWHERE_DEFINED_XYZ"}],
    }
    resolved, gaps = _gate_definitions(rich_db, payload)

    assert "SOUND_FINDME" in resolved, "precondition: the placeable gate must still resolve"
    assert gaps is not None, "an unplaceable gate must be disclosed, not silently dropped"
    assert gaps["no_definition_site"] == ["NOWHERE_DEFINED_XYZ"], (
        f"the unplaceable gate must be NAMED, not counted — a count leaves a reader unable to ask "
        f"for the one they care about; got {gaps}"
    )
    assert "not_attempted" not in gaps, "nothing was capped here, so nothing may claim it was"

    ## OVER THE CAP: the overflow is named as a TOOL limit, distinctly.
    many = {
        "name": "subject_fn",
        "gated_by": [{"symbol": f"GATE_{i:03d}"} for i in range(_GATE_DEFINITION_CAP + 3)],
    }
    _resolved2, gaps2 = _gate_definitions(rich_db, many)
    assert gaps2 is not None and len(gaps2["not_attempted"]) == 3, (
        f"the three gates beyond the cap must be named as not attempted; got {gaps2}"
    )

    ## THE SILENCE CONTROL: every gate placed means no disclosure at all.
    _r3, gaps3 = _gate_definitions(rich_db, {"name": "f", "gated_by": [{"symbol": "SOUND_FINDME"}]})
    assert gaps3 is None, (
        "when every gate resolves there is nothing to disclose — a block on every reply is one a "
        "reader learns to skip"
    )

1 more lines, not shown

Activity · 12 steps
lines 302–302from clew.mcp_server.tools_query import _GATE_DEFINITION_CAP, _gate_definitionslines 305–308payload = { "name": "subject_fn", "gated_by": [{"symbol": "SOUND_FINDME"}, {"symbol": "NOWHERE_DEFINED_XYZ"}], }lines 309–309resolved, gaps = _gate_definitions(rich_db, payload)lines 311–311assert "SOUND_FINDME" in resolved, "precondition: the placeable gate must still resolve"lines 312–312assert gaps is not None, "an unplaceable gate must be disclosed, not silently dropped"lines 313–316assert gaps["no_definition_site"] == ["NOWHERE_DEFINED_XYZ"], ( f"the unplaceable gate must be NAMED, not counted — a count leaves a reader unable to ask " f"for the one they care about; got {gaps}" )lines 317–317assert "not_attempted" not in gaps, "nothing was capped here, so nothing may claim it was"lines 320–323many = { "name": "subject_fn", "gated_by": [{"symbol": f"GATE_{i:03d}"} for i in range(_GATE_DEFINITION_CAP + 3)], }lines 324–324_resolved2, gaps2 = _gate_definitions(rich_db, many)lines 325–327assert gaps2 is not None and len(gaps2["not_attempted"]) == 3, ( f"the three gates beyond the cap must be named as not attempted; got {gaps2}" )lines 330–330_r3, gaps3 = _gate_definitions(rich_db, {"name": "f", "gated_by": [{"symbol": "SOUND_FINDME"}]})lines 331–334assert gaps3 is None, ( "when every gate resolves there is nothing to disclose — a block on every reply is one a " "reader learns to skip" )