Skip to content

test: Drive CLI mutation tests through the daemon that owns those writes - #5035

Merged
Sinity merged 5 commits into
masterfrom
fix/cli-tests-sole-write-authority
Sep 13, 2026
Merged

Sinity merged 5 commits into
masterfrom
fix/cli-tests-sole-write-authority

Conversation

@Sinity

@Sinity Sinity commented Sep 13, 2026

Copy link
Copy Markdown
Owner

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 6be5d2fd7 deleted the CLI's direct-writer bypasses, and cfc4c73ec
deleted 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() in
tests/infra/daemon_operations.py runs the existing production stack — real
DaemonWriteCoordinator, real DaemonOperationRuntime, real UDS listener — and
points 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.

file decision
test_excise.py 6 × (b), plus 1 new (a) refusal guard
test_reset.py 18 × (b); the 2 subprocess cases → (a), since an isolated CLI subprocess with no daemon genuinely is the offline scenario
test_archive_maintenance_cli.py 3 × (b), 1 × (a) — the --yes gate fires before dispatch
test_json_output.py 4 × (c), the only justified deletion

(c) was used once and only once: ops maintenance status / preview were
deleted in cfc4c73ec along with the whole generic repair product ("a standing
repair 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-execution
branch, 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 turns
the test red
and it cannot rot:

  1. gc-recover --abandon … --yes cannot execute in any daemon state. Daemon
    stopped → the CLI refuses (daemon is unavailable). Daemon running →
    PendingBlobGCGenerationAbandonActuator._require_offline_writer_ownership
    refuses (requires the daemon to be stopped; a daemon writer lease is active). Deleting the bypasses left this operation's offline-only
    precondition unreconciled with its now daemon-only transport — completion
    work, exactly as CLAUDE.md frames it.
  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. 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-hnqy1 and polylogue-4kt2r.

Anti-vacuity

  • excise: no-daemon excision must refuse and leave the session. Restore an
    in-process writer and it succeeds offline, deleting the session → red.
  • reset: the two subprocess cases — restore the writer and both succeed
    offline and delete the archive → red.
  • maintenance: the --yes gate case, plus both strict xfails.
  • json_output: the new tree-resolution guard, verified empirically by
    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 a
real unremovable target instead of patching pathlib.Path.unlink, which would
now break the daemon's own bookkeeping.

That last test's assertion was "failed" in output or exit_code == 0 — a
tautology that could not fail. It now asserts the real contract.

Verification

devtools test <the four files>   215 passed, 2 xfailed
devtools verify --quick          exit 0

No product code changed; scope is the four files plus the shared test harness.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

Sinity and others added 5 commits September 14, 2026 01:04
`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
@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 46 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: 60208f89-246a-47fc-8787-42a27be943b1

📥 Commits

Reviewing files that changed from the base of the PR and between 88a3b1b and 410a3b8.

📒 Files selected for processing (5)
  • tests/infra/daemon_operations.py
  • tests/unit/cli/test_archive_maintenance_cli.py
  • tests/unit/cli/test_excise.py
  • tests/unit/cli/test_json_output.py
  • tests/unit/cli/test_reset.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 a538d84 into master Sep 13, 2026
3 checks passed
@Sinity
Sinity deleted the fix/cli-tests-sole-write-authority branch September 13, 2026 23:17
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