Skip to content

Give the CLI one JSON refusal shape, and thread commands coded refusals - #2710

Merged
max-sixty merged 8 commits into
mainfrom
cli-json-refusals
Oct 13, 2026
Merged

max-sixty merged 8 commits into
mainfrom
cli-json-refusals

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

This follows #2697, which made the append door refuse on Finding records. Here the command line gets one JSON shape for a refusal, and the thread and task commands' own refusals get stable codes, so tests and scripts read the code instead of parsing text.

  • One rendering of a refusal: LeafGroup, the command line's one translation of a refusal, prints Refused.json() (error, plus the findings with each code and its fields) on stdout when the command was given --json. Otherwise it prints the words on stderr, as before. Either way the command exits 1. The HTTP event door's refusal answer has the same error/findings shape.
  • Where --json comes from: json_option records the request where LeafGroup reads it. So page check, package check and page interactions refuse in JSON under the flag they already had. Every write that prints its records (the thread, response and task groups' commands, page stamp and page report) gets --json from its command class (RecordsCommand, set once on RecordsGroup), with no per-command flag.
  • Codes for the thread and task commands: the refusals in thread.py and todos.cmd_open become findings worded in findings._TEXT. An attempt reused for another reply shares the door's attempt-conflict code.
  • Tests: tests that matched these commands' refusal text now read codes through command_refusal (from Report registry problems as findings #2698, which now takes any argument type) or through --json and refused_on. A heuristic count of assertions matching refusal words from the append door or the thread commands fell from 97 before Refuse events on findings with stable codes, not sentences #2697 to 28. What remains is the stop guard's reason, the user-facing words of stale-move/stale-edit, the re-vendor remedy that page init/server start/wait print, and a thread refusal's guidance about which command to use. All of that is wording the reader acts on.

User-visible: --json on those commands prints a refusal as JSON. An anchored comment on an invalid saved source now reads "cannot anchor while index.html is invalid", worded like a reply's "cannot reply while …". Every other refusal reads as before. The help snapshot gains the --json lines.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 8 commits October 12, 2026 16:59
Every gate at the append door now returns a `Finding` (`findings.py`): a stable
code and the values it read, among them the refused event's `kind` and the
identity or field it concerns, with what was offered and what would have been
admitted where a value was refused. `EventRefused` and `AttemptConflict` carry that
one finding; the words for every code live in `findings._TEXT` beside the check
findings, so they are written once. Schema refusals carry the JSON pointer of the
`field` and the schema `rule` it breaks. The layer-protocol refusals
(`foreign-layer`, `foreign-revision`) are findings too, so serving and admission
share them.

The event door's refusal answer (HTTP 400/409) carries `findings` beside `error`,
the words the browser shows; `refusals.Refusal`'s separate user words become a
`_USER` entry per code (`stale-move`, `stale-edit`). `Refused.json()` is the one
JSON shape of a refusal. A failed thread title records the refusal's code.

No user-visible behaviour changed: every refusal reads as it did, in the browser
and on the command line. Tests that matched admission refusal text in-process or
in the door's answer now read the code and fields (`refused_on`); those that read
the CLI's printed text follow with the command line's `--json` refusals.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A custom detail key such as a/b named a nested b; ~ and / now escape as RFC 6901
says. No user-visible behaviour changed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/scripts/leaf/event_contracts.py
#	skills/leaf/scripts/leaf/findings.py
#	skills/leaf/scripts/leaf/layer.py
#	skills/leaf/scripts/leaf/todos.py
#	skills/leaf/scripts/leaf/work.py
#	tests/model/test_asks.py
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
#	tests/model/test_interact_contract.py
`LeafGroup`, the command line's one translation of a refusal, prints it as one JSON
object on stdout (`Refused.json`: `error` and the `findings` it rests on) where the
command was given `--json`, and its words on stderr otherwise. It exits 1 either
way. A command's `--json` comes from `json_option`, which records the request where
`LeafGroup` reads it, so `page check`, `package check` and `page interactions`
refuse in JSON under their own flag. Every write that prints its records (the
`thread`, `response` and `task` groups' commands, `page stamp` and `page report`)
takes `--json` from its command class (`RecordsCommand`), with no per-command flag.

The thread and task commands' own refusals (`thread`, `tasks.cmd_open`) become
findings with stable codes, worded in `findings._TEXT` beside the append door's.
An attempt reused for another reply shares the door's `attempt-conflict` code.

User-visible: `--json` on those commands prints a refusal as JSON. An anchored
comment on an invalid saved source now reads "cannot anchor while index.html is
invalid", as a reply's "cannot reply while ..." does. Every other refusal reads as
before. Tests that matched these commands' refusal text now read codes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
#	skills/leaf/scripts/leaf/refusals.py
#	skills/leaf/scripts/leaf/todos.py
@max-sixty
max-sixty merged commit 3a74141 into main Oct 13, 2026
3 checks passed
@max-sixty
max-sixty deleted the cli-json-refusals branch October 13, 2026 01:41
max-sixty added a commit that referenced this pull request Oct 13, 2026
#2710 moved thread.py's owed-response refusal into a coded finding; the sweep's
`owed` rename now targets that call.

Co-Authored-By: Claude Opus 5.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.

2 participants