Skip to content

fix(cli): make facets refuse in words when no daemon serves it - #5481

Merged
Sinity merged 1 commit into
masterfrom
fix/facets-daemon-refusal
Sep 23, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/facets-daemon-refusal

Conversation

@Sinity

@Sinity Sinity commented Sep 23, 2026

Copy link
Copy Markdown
Owner

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.ai/code/session_01ToWqpkXotr573DiQex5vcy

`polylogue --no-daemon facets` exited 1 with completely empty output. The
kernel's OperationUnavailableError is a RuntimeError, not a ClickException,
so it escaped the command and Click printed nothing at all -- the operator
saw a blank screen where a typed 'start polylogued run' belongs.

The delete route already converts this refusal into DaemonRequiredError
(archive_query.py:1590). facets was the read-side gap. This is the same
flattening #5474 fixed for the machine envelope, arriving on the human path.

The three TestCliTerminalOutcomes facets cases asserted exit 0 and an outcome
from an in-process read. polylogue-3eexy retired the CLI's direct-read
execution mode, so no such route exists to produce one, and the tests had
been red on master since. They now pin the refusal, and specifically that it
is not silent -- a zero-output render is the same 'answer nothing, say
nothing' defect they were written against.

The outcome semantics stay pinned closer to the data: FacetsResponse refuses
construction without an outcome, and the daemon facets route is covered in
tests/unit/operations/test_daemon_reads.py.

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

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 40 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: cb82c90f-1068-4c03-aa31-9ebbee3cba6b

📥 Commits

Reviewing files that changed from the base of the PR and between ef813f3 and a565f95.

📒 Files selected for processing (2)
  • polylogue/cli/commands/facets.py
  • tests/unit/surfaces/test_terminal_outcomes.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-23T10:41:15.907289Z a565f95 PR opened
🔒 Security Review ✅ Completed 2026-09-23T10:42:36.118685Z a565f95 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.

@Sinity
Sinity merged commit 84a09d1 into master Sep 23, 2026
3 checks passed
@Sinity
Sinity deleted the fix/facets-daemon-refusal branch September 23, 2026 10:52
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]>
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