Skip to content

Refuse events on findings with stable codes, not sentences - #2697

Merged
max-sixty merged 6 commits into
mainfrom
event-refusal-findings
Oct 13, 2026
Merged

max-sixty merged 6 commits into
mainfrom
event-refusal-findings

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Every gate at the event log's append door now refuses on a Finding record (#2662, #2686, #2692 built the type) instead of a sentence. Each refusal has a stable code and the values the gate read: the refused event's kind, the identity or field it concerns, and, where a value was refused, what was offered and what would have been admitted. The words for each code are written once, in findings._TEXT.

  • Gates in event_contracts, events.UndoReading, tasks.task_error, work.widget_seat_error, read_state and layer return Finding | None. EventRefused and AttemptConflict carry that one finding. A schema refusal (invalid-event, invalid-detail) names the JSON pointer of its field and the schema rule it breaks (registry.schema.schema_complaint).
  • Layer refusals: layer.incompatible_layer and incompatible_revision return findings too (foreign-layer, retired-layer, foreign-revision, retired-revision), so serving, admission and page check --json report the same record. page check --json reports the layer's own code where it used invalid-registry.
  • User words: refusals.Refusal, the string that carried separate words for the browser, is gone. The two codes that have their own user words (stale-move, stale-edit) get them from findings._USER, through Rejected.user.
  • Transports: the event door's 400/409 answer carries findings beside error, which is still the text the browser shows. Refused.json() is the one JSON shape of a refusal. A failed thread title records the refusal's code.
  • Hook weight: findings imports registry.schema only when it writes words. The event log raises findings, and the Codex tool hook reads a quiet page without importing jsonschema (test_codex_tool_hook_reads_a_quiet_page_without_the_page_model).

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 through refused_on. A heuristic count of test assertions that match the original refusal words fell from 63 to 31. Most of the 31 match the CLI's printed output, and a follow-up PR moves them to a --json refusal shape. The rest assert the user-facing words or text that does not come from the append door.

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

max-sixty and others added 2 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]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The new field value needs JSON Pointer escaping for custom detail keys; the inline suggestion fixes it.

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]>
leaf-agent
leaf-agent previously approved these changes Oct 13, 2026
# 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
leaf-agent
leaf-agent previously approved these changes Oct 13, 2026
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
leaf-agent
leaf-agent previously approved these changes Oct 13, 2026
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
#	tests/model/test_interact_contract.py
@max-sixty
max-sixty merged commit a3a1392 into main Oct 13, 2026
3 checks passed
@max-sixty
max-sixty deleted the event-refusal-findings branch October 13, 2026 01:22
max-sixty added a commit that referenced this pull request Oct 13, 2026
main gained #2697, #2700 and #2708. The three files that conflicted
(event_contracts.py, findings.py, work.py) take main's content with the
sweep's edits re-applied by .tmp/standing/apply.py; the "not visible under the
page's standing outcomes" message moved from work.py to findings.py, and the
script now edits it there. main added no other non-glossary "standing".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 13, 2026
…ls (#2710)

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 #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 #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_

---------

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