Repository navigation
test: Bind the CLI query-execution store doubles to the production surface - #5037
Conversation
…rface tests/unit/cli/test_query_exec_laws.py carried 38 hand-written FakeArchiveStore copies. Each installed its own ArchiveStore.open_existing lambda and each stub method took **kwargs, so the doubles had stopped proving anything about the production class: a new open_existing keyword broke all of them at once, and a renamed production parameter was absorbed silently. Replace them with one shared ArchiveStoreDouble whose whole surface is read out of the real ArchiveStore. Subclassing checks every declared method name and every explicitly declared parameter against production at class-definition time; the opened-store attributes (operation_identity, operation_vector_connection, operation_schema_versions, operation_degraded_components, index_db_path) and the tier paths are derived from production's own class body, so a rename there fails at import instead of being patched in one attribute at a time. Restate the laws the drifted doubles had been hiding, against the lowering the CLI actually performs now: - list reads serve through the operation kernel, which asks count_sessions for the indexed total instead of over-fetching one row, so the requested page size reaches the store exactly; - list pagination is offset-based against that total; cursors carry a rank and belong to ranked retrieval, which the semantic-search case still asserts; - list_summaries takes a session_id scope parameter; - the delete daemon issues authorization_refs, one per preview reference. Anti-vacuity: renaming or re-signing any ArchiveStore method these tests use, or any opened-store attribute the read path sets, fails the doubles rather than being absorbed -- which is the property the 38 copies had lost. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
test_debug_timing_keeps_query_output_on_stdout required a "db-open" phase on stderr. That checkpoint lives inside archive_read_context in _execute_archive_query_stdout, and a list read served by the daemon session page returns before reaching it, so the phase is genuinely not part of the route this query takes. Drop it from the required phases and assert its absence instead, so the case still claims which route ran rather than carrying a phase list trimmed until it passed. The stdout/stderr contract and every other checkpoint assertion are unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
The delegation fixture inserted a session_links subagent edge without parent_tool_use_block_id. Since e00fa74 (#4674) that column is the key delegation_facts_source joins the dispatch action against, replacing the previous cardinality-gated ordinal pairing, so the fixture's evidence was incomplete rather than redundant: the subagent tool_use produced a dangling unresolved row and the edge produced a dangling edge_only row, two facts where the case asserts one. Carry the dispatch block id onto the link, resolved by query rather than by hardcoding the block-id identity expression. The two halves join into one resolved delegation, which is what the rest of the case already required -- its mapping_state:resolved query, bounded instruction preview and delegation-card read could not have passed against either dangling row. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Checking a double's declared parameters only covers what it names explicitly. A double that takes **kwargs and reads kwargs["origins"] kept passing when production renamed that parameter, because the read path's keyword and the subscript drift together -- measured by renaming list_summaries' origins parameter in production: only the one double that declared it broke. Wrap each double method so the incoming call is bound against production's own signature first. The call the read path makes must now be one the real ArchiveStore could serve. Under the same rename all three affected cases fail, naming the moved parameter. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes
polylogue-banw4, the last classified cluster in the campaign's redsurface. 96/96 passing, 96 collected before and after — no test dropped.
Summary
Replace 38 drifted
FakeArchiveStorecopies with one double derived from theproduction
ArchiveStoresurface, bound at call time to production's realsignatures.
Diagnosis — corrected
in the same file that reproduce in isolation.
method names and declared parameters were checked against production:
0 mismatches. Only 1 of 13
list_summariesstubs restated a signature; theother 12 were already
**kwargs. The breakage was entirely in the 36 identicalclassmethod(lambda cls, root: ...)installs, plus attributesopen_operation_readsets on an opened store.38 edits. The layers were real —
index_path→operation_vector_connection→index_db_path→count_sessions→session_id— and every one was hit again here, but each cost one edit.Shape: one shared double (a), not a real archive (b)
I had steered toward (b), using the real
ArchiveStoreagainst a seeded archive.That would have been wrong and it was rejected with reason:
These tests assert the lowering — exactly which kwargs the CLI planner passes
into the store (
origins == ("codex-session","chatgpt-export"),offset,repo_names,limit). A real seeded archive observes results, not the call,so (b) would have deleted the laws rather than preserved them. Decisively: this
same file already has a real-archive layer (
TestSearchQueryContractsonsearch_workspace), so both layers are deliberate and complementary.The campaign's anti-double lesson is answered structurally instead of by
deletion.
tests/infra/archive_store_double.pyderives its entire surface fromthe real
ArchiveStore— method names, declared parameters, the opened-storeattributes, and the tier paths are all read out of production's class body.
Nothing is manually re-synchronized, which is the property the 38 copies had lost.
Anti-vacuity — measured, and the first attempt was insufficient
A parameter (
originsonlist_summaries) was renamed in production and thetests re-run. First attempt: only 1 of 3 broke. The
**kwargsdoublesabsorbed the rename, because the caller's keyword and the
kwargs["origins"]subscript drift together — the exact failure mode this task existed to eliminate.
So call-time binding against production's signature was added. Under the same
rename, all 3 fail, naming the moved parameter. Production tree restored
clean afterwards.
Laws — all survived, several sharpened
96 collected before and after, none dropped. Restated against the lowering the
CLI actually performs now: list reads serve through the operation kernel, asking
count_sessionsfor the indexed total instead of over-fetching one row (solimitreaches the store exactly); list pagination is offset-based, whilecursors carry a rank and belong to ranked retrieval — still asserted by the
semantic-search case;
list_summariestakes asession_idscope; deleteauthorization is
authorization_refs.One fixture was strengthened: the delegation fixture's
session_linksedgelacked
parent_tool_use_block_id, the join key since #4674, so it produced twodangling halves — meaning its own downstream
mapping_state:resolvedassertionscould not have passed.
Verification
Residual — production, deliberately not fixed
The daemon-served list route has no
db-opentiming checkpoint: it returnsbefore
archive_read_context, so CLI list timing no longer measures archiveopen. This is asserted positively rather than silently trimmed from the
phase list, so the absence is visible and a future fix will have to update the
assertion.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK