test_a_response_over_budget_is_trimmed_AND_says_so¶
Tests › tests/test_mcp_server.py
What this test is for
Why it exists
A hub symbol must not blow a model's context, and must not lie about it.
Verifies REQ-DDB-MCP-001 REQ-DDB-MCP-003 REQ-DDB-QUERY-006 REQ-DDB-QUERY-008 REQ-DDB-QUERY-009
Given
payload = { "kind": "callers", "count": 400, "results": [ {"name": f"caller_{i}", "source": "ast_member", "confidence": "resolved", "edge_class": "call", "implementors": [], "padding": "x" * 120} for i in range(400) ], }
When
cut = tq._shrink_to_budget(payload, ("results",))block = tq._limited_block("callers", cut["results"], len(payload["results"]), "narrow it")
Then
- ✓ len(json.dumps(payload)) is greater than tq.RESPONSE_BUDGET_BYTES
- ✓ len(json.dumps(payload)) is at most tq.RESPONSE_BUDGET_BYTES
- ✓ cut equals {"results": 400}
- ✓ block["total_available"] equals 400
- ✓ block["adjusted"]["callers"].startswith("400 -> ") holds
- ✓ len(payload["results"]) is less than 400
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 · 1 of 226 steps
… 97 earlier steps
… 124 later steps
tests/test_mcp_server.py:1104 · its file's page
What it checks (6)
assert len(json.dumps(payload)) > tq.RESPONSE_BUDGET_BYTES, "premise: must start over budget"not attributedassert len(json.dumps(payload)) <= tq.RESPONSE_BUDGET_BYTES, ( "the trimmed payload must fit the cap — a cap that can be exceeded is not a cap" )not attributedassert cut == {"results": 400}, f"the ORIGINAL length must be reported, got {cut}"observes_shrink_to_budgetviacutassert block["total_available"] == 400, "a model must be told the true total"observes_limited_blockviablockassert block["adjusted"]["callers"].startswith("400 -> "), ( f"before/after must be explicit, got {block['adjusted']}" )observes_limited_blockviablockassert len(payload["results"]) < 400, "something must actually have been dropped"not attributed
Where the product reaches it
Call flow
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.
Requirements it verifies (5)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-MCP-001 | catalog | unknown |
| REQ-DDB-MCP-003 | catalog | unknown |
| REQ-DDB-QUERY-006 | catalog | unknown |
| REQ-DDB-QUERY-008 | catalog | unknown |
| REQ-DDB-QUERY-009 | catalog | unknown |