Skip to content

test: Bind the CLI query-execution store doubles to the production surface - #5037

Merged
Sinity merged 4 commits into
masterfrom
fix/query-exec-laws-doubles
Sep 13, 2026
Merged

Sinity merged 4 commits into
masterfrom
fix/query-exec-laws-doubles

Conversation

@Sinity

@Sinity Sinity commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Closes polylogue-banw4, the last classified cluster in the campaign's red
surface. 96/96 passing, 96 collected before and after — no test dropped.

Summary

Replace 38 drifted FakeArchiveStore copies with one double derived from the
production ArchiveStore surface, bound at call time to production's real
signatures.

Diagnosis — corrected

  • 10 failures, not 7. 8 were the store-double cluster; 2 were unrelated drift
    in the same file that reproduce in isolation.
  • The 38 copies were real but were not the drift source. All 38 stubs'
    method names and declared parameters were checked against production:
    0 mismatches. Only 1 of 13 list_summaries stubs restated a signature; the
    other 12 were already **kwargs. The breakage was entirely in the 36 identical
    classmethod(lambda cls, root: ...) installs, plus attributes
    open_operation_read sets on an opened store.
  • The earlier "peel one attribute at a time" attempt failed because each peel was
    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 ArchiveStore against 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 (TestSearchQueryContracts on
search_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.py derives its entire surface from
the real ArchiveStore — method names, declared parameters, the opened-store
attributes, 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 (origins on list_summaries) was renamed in production and the
tests re-run. First attempt: only 1 of 3 broke. The **kwargs doubles
absorbed 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_sessions for the indexed total instead of over-fetching one row (so
limit reaches the store exactly); list pagination is offset-based, while
cursors carry a rank and belong to ranked retrieval — still asserted by the
semantic-search case; list_summaries takes a session_id scope; delete
authorization is authorization_refs.

One fixture was strengthened: the delegation fixture's session_links edge
lacked parent_tool_use_block_id, the join key since #4674, so it produced two
dangling halves — meaning its own downstream mapping_state:resolved assertions
could not have passed.

Verification

devtools test tests/unit/cli/test_query_exec_laws.py   96 passed / 96
devtools verify --quick                                exit 0, all gates ok

Residual — production, deliberately not fixed

The daemon-served list route has no db-open timing checkpoint: it returns
before archive_read_context, so CLI list timing no longer measures archive
open. 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

Sinity and others added 4 commits September 14, 2026 01:46
…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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 6787b295-9f0f-425f-9f33-90cb7957addc

📥 Commits

Reviewing files that changed from the base of the PR and between a538d84 and bdae6ec.

📒 Files selected for processing (2)
  • tests/infra/archive_store_double.py
  • tests/unit/cli/test_query_exec_laws.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 4e38a86 into master Sep 13, 2026
3 checks passed
@Sinity
Sinity deleted the fix/query-exec-laws-doubles branch September 13, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant