Repository navigation
test: Drive CLI mutation tests through the daemon that owns those writes - #5035
Conversation
`ops excise --yes` stopped being a writer when the CLI direct-writer bypasses were deleted (6be5d2f): it lowers to mutation.session.excision / mutation.session.lifecycle-request, and configured_mutation_operation refuses without a resident daemon. The six mutating cases here still assumed the in-process route and had been invisible until the corpus could collect as one unit (#5031). Each case is answered with (b), drive the daemon operation: the behaviour they cover did not disappear, it moved behind the daemon, so the test follows it. tests/infra/daemon_operations.py gains cli_daemon_archive(), which runs the existing production stack (real write coordinator, DaemonOperationRuntime, real UDS listener) and points the CLI's socket probe at it. The two audit-precondition cases now corrupt the audit tier after daemon startup, because startup prepares the operation journals and would undo a pre-boot deletion. Their refusals are asserted by typed reason (AuditContinuityError; audit-tier open failure naming audit.db) instead of the old locally-raised prose, and the "no lifecycle request was written" assertions are unchanged. Adds (a) test_excision_without_a_daemon_refuses_and_mutates_nothing as the file's anti-vacuity guard: restoring an in-process CLI excision writer makes it succeed offline and delete the seeded session, turning the test red. Verification: devtools test tests/unit/cli/test_excise.py -- 13 passed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
`ops reset` previews and confirms locally, then lowers to maintenance.reset / mutation.identity-reset; configured_mutation_operation only sends those to a resident daemon (6be5d2f). The twenty mutating cases here still assumed the in-process route and were invisible until the corpus collected as one unit (#5031). Eighteen in-process cases are answered with (b), drive the daemon operation: what they cover -- which targets a reset deletes, which durable tiers survive without an explicit opt-in, the suppression and archive-row effects of --session/--source, the JSON envelope of a real mutation -- did not disappear, it moved behind the daemon, so the tests follow it via cli_daemon_archive(). Targets are now materialised where _reset_targets resolves them (polylogue.paths under redirected XDG roots) rather than at paths patched into the CLI module, which no longer does the deleting. The two subprocess cases are answered with (a), typed refusal, and are the file's anti-vacuity guard: an isolated CLI subprocess with no daemon is exactly the offline scenario, and it is the only genuinely separate process here. Restoring an in-process reset writer makes both succeed offline and delete the archive, turning them red. Three fixture facts had to change because a real daemon opens what it deletes: tiers are the bootstrapped databases instead of files containing the text "test database"; "nothing to reset" is asserted on the preview branch that still emits it plus a zero-delete daemon result; and the deletion-failure case produces a real unremovable target instead of patching pathlib.Path.unlink, which would now break the daemon's own bookkeeping. That last assertion was the tautology `"failed" in output or exit_code == 0` and is now the contract the daemon provides: the failure is reported and success is not claimed. Verification: devtools test tests/unit/cli/test_reset.py -- 32 passed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
raw-authority-blocker-resolve and gc-recover lower to declared mutations that configured_mutation_operation sends to the resident daemon only (6be5d2f). The four cases here still assumed the in-process route and were invisible until the corpus collected as one unit (#5031). Three are answered with (b), drive the daemon operation: the confirmation gate, the blocker listing whose tail resolves a blocker, and the unknown-blocker judgment all still exist, behind the daemon. The gc-recover authority gate is answered with (a): the --yes refusal happens before dispatch and needs no daemon. Driving these through the real writer exposed two product defects. Neither is blessed by an assertion; each is pinned with a strict xfail that turns red the moment it is fixed: 1. `gc-recover --abandon ... --yes` cannot execute in any daemon state. Stopped, the CLI refuses ("daemon is unavailable; it must execute maintenance.blob-gc.recover"); running, PendingBlobGCGenerationAbandonActuator._require_offline_writer_ownership refuses because a writer lease is active. Deleting the direct-writer bypasses left this operation's offline-only precondition unreconciled with its daemon-only transport. 2. Plain-mode raw-authority-blocker-resolve prints "Resolved <id>" and exits 0 for a blocker that never existed. The actuator does return already_satisfied / blocker_not_found_or_already_resolved / affected_count 0, but _execute_named_mutation forwards only domain_receipt, so no status reaches the command. Before the bypasses were deleted this exited non-zero with "not found or already resolved" -- a string that now survives nowhere in the product. The unknown-blocker test keeps the strongest CLI-observable contract: a typo'd id causes no durable mutation. Verification: devtools test tests/unit/cli/test_archive_maintenance_cli.py -- 115 passed, 2 xfailed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
`ops maintenance status` and `ops maintenance preview` were deleted in cfc4c73 along with the rest of the generic repair product -- convergence owns those semantics and "a standing repair concept is a second truth". No successor command was introduced, so this is (c): the four failing parametrisations memorialised a route that is genuinely gone, not one that moved. They are removed rather than relocated. _COMMANDS is a literal table rather than a walk of the Click tree, so deleting a command cannot fail collection -- it only surfaces as `No such command` when that one parametrisation runs, which is why these two entries outlived the command deletion. Adds test_command_table_names_only_commands_that_exist, which resolves every listed path against the live Click tree. Anti-vacuity (verified): re-adding ["ops", "maintenance", "status"] to _COMMANDS turns the guard red with "_COMMANDS lists 'ops maintenance status', but 'ops maintenance status' does not exist". Verification: devtools test tests/unit/cli/test_json_output.py -- 57 passed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
The seed-returning context managers added in the two previous commits yielded `object`, so mypy could not determine the type of any value unpacked from them (9 has-type errors under `devtools verify --quick`). The seed result is deliberately per-test, so it is typed as Any with an explicit `_no_seed` default rather than a TypeVar that no-seed call sites leave unsolved. Verification: devtools verify --quick -- exit 0, all gates ok. 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 46 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 (5)
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-wgago(P1). All 34 stale CLI failures resolved: 215 passed,2 xfailed.
Summary
Drive the CLI mutation tests through the daemon that now owns those writes,
rather than asserting a bypass that no longer exists.
Problem
Commit
6be5d2fd7deleted the CLI's direct-writer bypasses, andcfc4c73ecdeleted the generic repair product. These four files still asserted the old
routes. They were invisible until PR #5031 made the corpus collect as one unit —
every focused selection touching them was green because it never included the
colliding half.
Solution — the behavior moved, so the tests followed it
Mostly (b) drive the daemon operation.
cli_daemon_archive()intests/infra/daemon_operations.pyruns the existing production stack — realDaemonWriteCoordinator, realDaemonOperationRuntime, real UDS listener — andpoints the CLI's socket probe at it. No new mock layer was introduced, which
matters given how much of this campaign's red surface turned out to be doubles
that had drifted from the production types they imitated.
test_excise.pytest_reset.pytest_archive_maintenance_cli.py--yesgate fires before dispatchtest_json_output.py(c) was used once and only once:
ops maintenance status/previewweredeleted in
cfc4c73ecalong with the whole generic repair product ("a standingrepair concept is a second truth"). No successor exists — that route is gone,
not relocated. Everywhere else the behavior had moved, so deleting the test would
have destroyed real coverage.
No surviving unauthorized CLI mutation path was found. All four command
modules go through
configured_mutation_operation, which has no direct-executionbranch, and none contains an
unlink/rmtree/SQL write.Two product bugs — reported, not blessed
Driving these through the real writer exposed defects. Rather than writing
agreeable tests, each is pinned with
xfail(strict=True), so fixing it turnsthe test red and it cannot rot:
gc-recover --abandon … --yescannot execute in any daemon state. Daemonstopped → the CLI refuses (
daemon is unavailable). Daemon running →PendingBlobGCGenerationAbandonActuator._require_offline_writer_ownershiprefuses (
requires the daemon to be stopped; a daemon writer lease is active). Deleting the bypasses left this operation's offline-onlyprecondition unreconciled with its now daemon-only transport — completion
work, exactly as CLAUDE.md frames it.
raw-authority-blocker-resolveprintsResolved <id>and exits0 for a blocker that never existed. The actuator does return
already_satisfied/blocker_not_found_or_already_resolved/affected_count 0, but_execute_named_mutationforwards onlydomain_receipt, so no status reaches the command. The old string"not found or already resolved"now survives nowhere in the product —only in that test. The strongest true contract was kept: a typo'd id mutates
nothing.
Filed as
polylogue-hnqy1andpolylogue-4kt2r.Anti-vacuity
in-process writer and it succeeds offline, deleting the session → red.
offline and delete the archive → red.
--yesgate case, plus both strict xfails.re-adding
ops maintenance status, which failed with_COMMANDS lists 'ops maintenance status', but 'ops maintenance status' does not exist.Fixture changes, because a real daemon opens what it deletes
Three facts had to change: tiers are now bootstrapped databases rather than files
containing the text
"test database"; and the deletion-failure case produces areal unremovable target instead of patching
pathlib.Path.unlink, which wouldnow break the daemon's own bookkeeping.
That last test's assertion was
"failed" in output or exit_code == 0— atautology that could not fail. It now asserts the real contract.
Verification
No product code changed; scope is the four files plus the shared test harness.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK