Skip to content

fix(cli): Type the kernel's daemon-absent refusal in the machine envelope - #5474

Merged
Sinity merged 1 commit into
masterfrom
fix/daemon-required-mutation-envelope
Sep 23, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/daemon-required-mutation-envelope

Conversation

@Sinity

@Sinity Sinity commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Summary

tests/unit/cli/test_cli_operation_authority.py had 8 failures on master: a daemon-down CLI mutation emitted code: "runtime_error" instead of the typed daemon_required. 8 red -> 4 red.

Root cause

OperationUnavailableError is a RuntimeError, not a ClickException, so it missed machine_main's DaemonRequiredError branch and reached the generic handler. That branch's own comment states exactly what this breaks:

"the daemon-absent refusal is the one case a machine caller can act on directly, and folding it into runtime_error is exactly what made it unactionable."

The flattening arrived by the other door once #5453 stopped the CLI executing operations in-process (polylogue-3eexy). The guard existed; the new path went around it.

Fix

machine_main maps OperationUnavailableError, emitting error_daemon_required with operation carried as an envelope field so a client need not parse it from the message (polylogue-re6s3 AC4). The refusal message also names the operation, because the terminal format has no field to read it from — an operator told only "start polylogued run" cannot tell which route refused.

Verification

devtools verify --quick                                      ->  PASSED exit=0
devtools test test_cli_operation_authority.py + companion    ->  28 passed / 4 failed  (was 24 / 8)

The remaining 4 are a different question, not this mapping

A mark refuses at the cli.query that resolves its target, so the message truthfully names cli.query while the test expects mutation.annotation.save.

That is a decision about which operation a compound verb should name — the one that actually refused, or the one the operator asked for. Both are defensible and the tests encode the second. Forcing them green here would mean naming an operation that did not fail, so they are left red with the reason recorded rather than papered over.

How it was found

A gpt-5.6-luna worker checking whether polylogue-d02y8 was close-ready reported these as inherited baseline failures. It is the third time this session a worker with no stake in a file surfaced a regression on master that verify --quick cannot see — none of these suites are in the quick set.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

…lope

test_cli_operation_authority.py had 8 red on master: a daemon-down CLI
mutation emitted code "runtime_error" instead of "daemon_required".

OperationUnavailableError is a RuntimeError, not a ClickException, so it
missed the DaemonRequiredError branch and reached the generic handler --
the exact flattening that branch's own comment says it exists to prevent,
arriving by the other door once the CLI stopped executing in-process
(polylogue-3eexy).

machine_main now maps it, carrying `operation` as an envelope field, and
the refusal message names the operation so the terminal format -- which
has no field to read -- says which route refused.

8 red -> 4 red. The remaining 4 are a separate, pre-existing question:
a `mark` refuses at the cli.query that resolves its target, so the
message names cli.query while the test expects the mutation the operator
asked for. That is a decision about which operation a compound verb
should name, not this mapping.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@Sinity
Sinity enabled auto-merge (squash) September 23, 2026 08:12
@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 12 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: 8ce866e4-7bc4-4a96-bab7-60ce1e47ff1b

📥 Commits

Reviewing files that changed from the base of the PR and between 1adc1fe and 6b7bca4.

📒 Files selected for processing (2)
  • polylogue/cli/machine_main.py
  • polylogue/cli/operation_kernel.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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T08:17:44.934434Z 6b7bca4 PR opened
🔒 Security Review ✅ Completed 2026-09-23T08:17:58.895443Z 6b7bca4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b7bca44ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/cli/machine_main.py Resolved
Comment thread polylogue/cli/machine_main.py Resolved
@Sinity
Sinity merged commit 64ee004 into master Sep 23, 2026
3 checks passed
@Sinity
Sinity deleted the fix/daemon-required-mutation-envelope branch September 23, 2026 08:25
Sinity added a commit that referenced this pull request Sep 23, 2026
…essors (#5479)

## Summary

Third single-wave batch: **12 `gpt-5.6-luna` workers, 24 beads**. Eight
write lanes produced commits, four wrote to the tracker rather than the
tree. **Zero merge conflicts across eight worktrees**, third wave
running.

## What landed

| commit | bead |
|---|---|
| `test(cli): retire direct-read expectations` | `3eexy` AC5 — the last
blocker; AC1–4 were already proven |
| `fix(status): attach sibling tiers for embed fast path` | `gqkae` —
the bead filed earlier today |
| `fix(storage): fail closed on unknown revision authority` | `sze30`
AC1–3, `3szyi` AC1–3 |
| `fix(daemon): settle failed admission telemetry` | `8qm4k` AC2–AC5 |
| `fix(polylogue-wzgpf): preserve split identity fallback reasons` |
`wzgpf` AC2/4/5/7 |
| `test(api): prove bounded attachment page delegation` | `q54dt` — all
five ACs now satisfied |
| `fix(polylogue-bp12n.5): validate halted-unit status evidence` |
`bp12n.5` AC2 |
| `perf(test): defer pilot resource imports` | `1xc.14.1`, `016xl` |
| `fix(test): type the api facade double…` | coordinator integration
fixes |

`gqkae` is the notable one: I filed it this session after diagnosing
that `embed.py`'s fast path performs no `ATTACH`, so ops and embeddings
state read as *absent* rather than *not consulted*. A wave-3 lane picked
it up and fixed it — the tiers are now attached explicitly, with a
missing tier remaining a measured absence.

## Tracker work — the part that actually moves the closure

Four lanes changed bead records, not code:

- **Three unbounded epics split into nine dispatchable successors**
(`tar1n` ×4, `va9vx` ×2, `a7xr.27` ×3), each with real acceptance
criteria naming its anti-vacuity mutation, wired with dependency edges.
`bd dep cycles` clean. This *raises* the nonclosed count, correctly:
undispatchable epics became workable beads.
- **Five beads moved `specification-required` →
`implementation-residual`** (`016xl`, `pnxl6`, `uty2s`, `4wqi2`,
`xul7`). Wave 2 measured that their premises were false; wave 3 applied
the rewritten criteria. `016xl` now requires ≤22.3 KiB/item instead of a
430 MiB target derived from a node-id length that measures 119.6, not
242.
- **`k8wv` dispositioned** `final-build-evidence` — it was the only
unblocked campaign record without a token.
- **`gd9i1` measured**: warm status **3288.8 ms against a 400/800 ms
target**, mixed load **3552.66 ms against 250/500** — roughly an order
of magnitude over budget, both baselines `rounds=1` and informational. A
stale "identical reads" claim was refuted against
`test_daemon_operation_profile.py:147-168`.

## Verification — once, over the integrated result

```
devtools verify --quick  ->  PASSED exit=0
devtools test <11 touched test files>  ->  1 pre-existing failure, rest green
```

## Residual, stated honestly

-
`test_daemon_and_direct_status_share_zero_head_unavailable_ops_semantics`
fails. **Confirmed failing on clean `origin/master`** in a detached
worktree, so it is not from this branch. It expects direct status to
work without a daemon, which `#5474` made refuse typed.
- `test_status_json_reports_ready_next_action` and
`test_status_json_includes_latest_catchup_run` still fail. The attach
now happens, but the non-pinned path reads `root / "ops.db"` directly
and the fixture's `root` resolution is not settled. These fixtures
hand-build tier shapes; the ops tier is now seeded from production DDL
here, which is strictly better but not sufficient. Tracked on `gqkae`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 23, 2026
## Problem

```
$ polylogue --plain --no-daemon facets
$ echo $?
1
```

Exit 1, and **no output at all**. Not an error message, not a hint — a
blank screen.

The kernel's `OperationUnavailableError` is a `RuntimeError`, not a
`ClickException`, so it escaped the command and Click printed nothing.
This is the same flattening #5474 fixed for the machine envelope,
arriving on the human-facing path.

The delete route already handles it correctly, converting to
`DaemonRequiredError` at `archive_query.py:1590`. `facets` was the
read-side gap.

It matters because the project's rule is that a missing daemon must
refuse *typed*, never break — and "exit 1, say nothing" is the worst
version of breaking.

## Fix

`facets` converts the refusal the same way delete does, carrying the
operation name:

```
$ polylogue --plain --no-daemon facets
Error: start polylogued run to serve this operation: facets
```

## The three red tests

`TestCliTerminalOutcomes` asserted `exit 0` and an `outcome` from an
in-process facets read over an empty and a populated archive.
`polylogue-3eexy` retired the CLI's direct-read execution mode, so no
such route exists to produce one — these have been red on master since,
unnoticed while the pytest pool sat paused.

They now pin the refusal, and specifically that it is **not silent**.
That is deliberate: a zero-output render is the same "answer nothing,
say nothing" defect the original tests were written against, so the
replacement guards the same property on the route that actually exists.

Their outcome semantics stay pinned closer to the data, where they are
stronger:
- `FacetsResponse` refuses construction without an outcome
(`test_facets_response_refuses_construction_without_one`)
- the daemon facets route is covered in
`tests/unit/operations/test_daemon_reads.py`

Anti-vacuity: drop the handler in `cli/commands/facets.py` and the
output is empty again, failing the message assertion.

## Verification

```
devtools test tests/unit/surfaces/test_terminal_outcomes.py  -> PASSED exit=0
devtools verify --quick                                      -> PASSED exit=0
```

Red before this change (3 failed), green after. Confirmed pre-existing
on clean `origin/master` at `97215a437` before fixing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 23, 2026
## Problem

`polylogue-tar1n.2` (wave 4) routed MCP privileged writes through the
daemon, which is correct. But its refusal said only:

```
start polylogued run to serve this operation
```

The MCP error payload carries no separate field for the operation name,
so a client is told that *something* privileged refused, without being
told which route.
`test_rebuild_insights_with_confirm_names_its_sealed_owner` asserts the
message names `maintenance.insights.rebuild`.

The lane that wrote this never saw the failure: its focused run was
still queued in the shared pytest pool when it handed off, and it
reported `MCP-4 BLOCKED-ON shared pytest pool result` honestly rather
than claiming a pass. I ran it during closure review.

## Fix

Both refusal sites interpolate the operation, as the CLI machine
envelope already does since #5474.

## Verification

```
devtools test tests/unit/mcp/test_privileged_tools.py -> PASSED exit=0
devtools verify --quick                               -> PASSED exit=0
```

Red before this change, green after.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 23, 2026
…5486)

## What this fixes

A full-corpus `verify --all` at master `2df6e2fa9` returned **259
failures**, dominated by one cause.

`polylogue-3eexy` retired the CLI's direct-read execution mode: the
daemon is the required executor and the CLI is a thin client, so a CLI
command with no daemon returns a typed daemon-required refusal and exits
1. Every test invoking a CLI surface in-process failed with `cli surface
failed (1) for '<expression>'`.

Four instances were fixed piecemeal earlier today (#5474, #5476, #5481,
#5484). They were samples, not the population.

## The fix was already in the repo

`tests/infra/daemon_operations.py:194` — **`cli_daemon_archive`** runs a
real `DaemonOperationRuntime` behind a real UDS listener and points the
CLI at it. Its docstring states the rule: *"A CLI test that wants to
observe what a mutation actually does therefore has to supply the daemon
the command requires."* **Nine test files already used it**; every
failing file used it zero times.

So this is a mechanical migration onto an established pattern, not a
redesign. Each test got one of two treatments:

- **FIXTURE** — the test observes CLI behaviour → take
`cli_daemon_archive`
- **REFUSAL-ASSERT** — the test pins daemon-*absent* behaviour → assert
non-zero exit, a message naming the operation, and non-empty output (the
shape #5481 established for `facets`)

No assertion was weakened and no test deleted to reduce the count.

## Result

| lane | files | before | after |
|---|---|---|---|
| m1 | documented query corpus, query route differential | 36 | 0 |
| m2 | messages, plain CLI snapshots | 30 | 0 |
| m3 | status ×2, json envelope contract | 25 | 3 |
| m4 | reference/query-law differentials, basic usage CLI | 26 | 4 |
| m5 | query mutation authority, expression, contextual errors,
pagination | 22 | 0 |
| m6 | plain output contract, interactive, output schemas, operation
authority | 16 | 0 |
| m7 | product query workflows (+ source cache reuse) | 13 | 8 |
| **total** | | **168** | **15** |

**All 15 remaining failures are pre-existing**, each verified by exact
test name in the pre-migration corpus log: 3 `TestArchiveTableCounts`
archive-count assertions, 4 query-law census plan-classification cases,
8 `test_source_cache_reuse` cache-semantics failures unrelated to the
CLI.

## Verification

```
devtools verify --quick                  ->  PASSED exit=0
devtools test <18 migrated files>        ->  3 failed (all pre-existing), rest green
```

## Coordinator notes

Three of seven lanes (`m1`, `m2`, `m5`) completed correct work and left
it **uncommitted** in their worktrees; committed here after `ruff`
import-order and format fixes. A secret-scan candidate in
`test_complete_selection_pagination.py` was reviewed and is a false
positive — it matches the parameter name `row_key` and a query-token
constant, not a credential.

`polylogue-3eexy` was closed earlier today on a lane's report that its
AC5 ("no tests exercise the retired direct path") held over the three
files that lane owned. The corpus showed hundreds still did. That
premature close is recorded on the bead, with `n57xe` as its successor.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Behavior Changes**
* CLI operations that require archive access now report a typed status
refusal when the daemon is unavailable, rather than presenting a
successful direct-archive fallback.
* Status-related errors are checked for clear messages and nonzero exit
results.
* **Testing**
* Expanded coverage of CLI, query, transcript, usage, and MCP workflows
using daemon-backed archives, including multi-page selections and
cross-origin search.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):

Resolving the fixed, stale and refuted threads; tracked threads stay open.

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