Skip to content

Report registry problems as findings - #2698

Merged
max-sixty merged 3 commits into
mainfrom
registry-findings
Oct 13, 2026
Merged

max-sixty merged 3 commits into
mainfrom
registry-findings

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Registry problems now reach page check and package check as records, like the markup and render findings from #2662 and #2686. Before, each one was a RegistryError sentence, and page check --json wrapped it as one invalid-registry record whose only value was that text.

What changed

  • One finding per registry problem. Each of the ~100 raise sites under registry/, plus the example and incoming-layer checks in validation/composition.py, now raises registry_error(code, registry, tag, **values). The result is a RegistryError that carries one Finding:
    • code: one of 104 codes. Sites that raise the same kind of problem share one, so unknown-declarations covers x-owners and x-unique (values.key), and predicate-* covers x-awaits and x-thread-seat.
    • at: the element declaration the problem concerns, such as <lf-local>, or empty for a $ fact.
    • values.registry: the file or composition it was read in.
    • values.revendor: present when the fault is in a vendored layer that re-vendoring fixes.
    • The remaining values hold what the check read: the verb, the attribute, the offending names or value. A JSON Schema complaint also carries keyword, path and reason, from registry.schema.schema_reading. The markup check's attribute-schema now uses the same helper.
  • Words in one place. The words for every code are in findings.py, under _declared. That helper adds the file prefix and the re-vendor suffix.
  • Commands report the record. page check adds the refusal's findings to its errors. When package check --json meets a refusal that carries findings, it reports those findings in place of a package record.
  • findings.Rejected is now Rejected(findings, heading=None). With no heading, its text is the findings' own words. RegistryError subclasses it.
  • layer_facts_error, which returned a string, is replaced by check_layer_facts, which raises. reference_relation_error is now reference_relation_problem and returns a code and values. The invalid-registry code now covers only the refusal Name the code's ask and to-do records asks and to-dos, as the interface does #2658 added for a layer this Leaf cannot serve (layer.incompatible_layer). That refusal is still a sentence that the page servers, the event door and the website also read.

Human output: before and after

Human output is byte-identical. I ran leaf page check from the merge base and from this branch on two broken pages and diffed stdout, stderr and the exit status. The only difference was the base run's leaf-version advice line, which comes from running an exported tree, so I filtered it out.

A page whose own page/registry.json declares an x-awaits answering verb it doesn't have:

Error: index.html has 1 validation issue
  - …/authored/page/registry.json: <lf-local> x-awaits answers with verbs ["submit"], which are not x-state verbs the user writes

A page whose vendored registry.json has $languages.names: 3:

Error: index.html has 1 validation issue
  - …/vendored/registry.json: $languages.names: 3 is not of type "array"; run `leaf page init …/vendored` to re-vendor it

I also compared the refusal text of about 100 broken registries between the two trees. Each one mutated the shipped registry, a registry file, an example, the incoming layer or a fixed $events member, and together they reached nearly every code. All were identical.

page check --json for the second page:

before: {"code": "invalid-registry", "severity": "error", "values": {"error": "…/vendored/registry.json: $languages.names: 3 is not of type \"array\"; run `leaf page init …/vendored` to re-vendor it"}, "text": "…"}
after:  {"code": "layer-facts", "severity": "error", "values": {"keyword": "type", "path": ["$languages", "names"], "reason": "3 is not of type \"array\"", "registry": "…/vendored/registry.json", "revendor": "…/vendored"}, "text": "…"}

For the first page:

after:  {"code": "awaits-verbs", "severity": "error", "at": "<lf-local>", "values": {"verbs": ["submit"], "registry": "…/authored/page/registry.json"}, "text": "…"}

Tests

  • I cut the tests in test_interact_layer.py, test_server_lifetime.py and journeys/test_interact_contract.py that matched registry words over to codes and fields. They use two new interact_support helpers:
    • registry_refusal(read) returns the finding a refusal carries.
    • command_refusal(*args) runs a leaf command in process and returns its refusal's finding. It covers commands with no --json, such as page init and package init.
  • test_package_check_requires_a_non_empty_widget_description now expects no-description where it expected a package record. That is the user-visible change to package check --json.
  • test_interact_contract.py still matches the words, which are unchanged. A follow-up PR cuts it over.
  • I ran tests/model/test_interact_contract.py, test_interact_layer.py and test_server_lifetime.py in full, and the changed journeys test by node ID. To check the cut-over, I replaced every registry finding's words with a constant and reran those files and seven other model files that write registries, with the follow-up's conversion of test_interact_contract.py applied. All 876 tests passed, so no other test in them reads registry words.

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

A registry refusal now carries one `Finding`: a code per kind of problem
(104, such as `layer-facts`, `unknown-declarations`, `awaits-verbs`,
`record-unit`), the element declaration it concerns in `at`, the registry
file in `values.registry`, and what the check read there. `page check
--json` reports that record where it reported one `invalid-registry`
record holding the error's text, and `package check --json` reports it
where it reported a `package` record. The words are written once, in
`findings.py`; the human output of both commands is unchanged.

`RegistryError` is a `findings.Rejected`, which now takes its findings
first and an optional heading. `schema_reading` gives a JSON Schema
complaint's keyword, path and words, shared with `attribute-schema`.
`layer_facts_error` becomes `check_layer_facts`, which raises, and
`reference_relation_error` returns a code and values.

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/registry/state.py
#	skills/leaf/scripts/leaf/registry/widgets.py
leaf-agent
leaf-agent previously approved these changes Oct 13, 2026
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
@max-sixty
max-sixty merged commit dd1103b into main Oct 13, 2026
3 checks passed
@max-sixty
max-sixty deleted the registry-findings branch October 13, 2026 00:52
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]>
max-sixty added a commit that referenced this pull request Oct 16, 2026
Follows #2698 (merged). Capture refusals and sample-history refusals now
reach `page check` as coded records. Before, each was one
`capture-failed` or `sample-history` record whose only value was the
refusal's text. The tests that matched registry, capture and
sample-history words now read the records.

## What changed

- **Capture.** `ArtifactError` is now a `findings.Rejected` carrying one
finding. Its 24 raise sites call `artifact_error(code, file, specifier,
**values)`. The codes include `dependency-unreadable`,
`dependency-not-local`, `module-outside-page`, `module-type`,
`dependency-symlink`, `css-import` and `manifest-digest`. `values.file`
is the file the problem was read in and `values.specifier` is the
reference in it. The words are written in `findings.py` (`_captured`).
`page check` adds the refusal's findings to its errors.
- **Sample history.** `initial_sample_events` raises a `Rejected`
instead of a `ValueError` that wrapped the inner refusal's text. Its
finding names the script (`values.reference`) and, for a problem with
one of its events, which one (`values.event`). The codes include
`sample-script`, `sample-json`, `sample-array`, `fixture-kind`,
`fixture-ts` and `fixture-id-taken`.
- `fixture-markup` holds the message gate's own findings in
`values.findings`, under its kind, and `fixture-media` holds the media
check's findings the same way.
- An event the append door refuses is `fixture-event`, holding the
door's findings (`EventRefused`, or `command_error`'s) in
`values.findings` the same way. An anchor-capture refusal keeps its
words as `fixture-refused` (`values.error`).
- `page check` sets the template ids on each finding's `samples`, as it
does for markup findings. The HTTP sample door catches `Rejected` beside
`ValueError` and answers with the same text.
- **Codes deleted.** `capture-failed` and `sample-history` no longer
exist.
- **Test helper.** `command_findings(*args)` replaces `command_refusal`,
and every caller moves to it. It returns every finding a refused command
carries, or none when the command succeeds. The sample tests read the
message door's refusal through it.

## Human output: before and after

One wording changed, for consistency. The three CSS refusals from the
stylesheet walk (`css-invalid`, `css-url`, `css-import`) used to name no
file. They now carry and print the file whose CSS they read, as every
other capture refusal does. For the page's own `<style>` and `style`
attributes, that file is `/index.html`. Without it, a page with several
stylesheets got a coded refusal with no way to tell which sheet to fix:

```
<   - invalid CSS: bad URL token
>   - /page/style.css: invalid CSS: bad URL token
<   - CSS @import requires a stylesheet with CSS MIME type
>   - /page/style.css: CSS @import requires a stylesheet with CSS MIME type
```

I ran `leaf page check` from the merge base and from this branch on 33
pages. Three changed, all with the CSS wording above. On the other 30,
stdout, stderr and exit status were byte-identical. They cover every
sample-history case the suite exercises (including the three
message-markup ones) and every module and stylesheet capture case. I
filtered out the `leaf-version` advice line, because the two trees run
as different Leafs.

A page whose module imports a missing file:

```
Error: index.html has 1 validation issue
  - /page/missing.js: cannot capture dependency: No such file or directory
```

A page whose sample history has a bad timestamp in its second event:

```
Error: index.html has 1 validation issue
  - sample 'practice': data-sample-events 'fixture', event 2: ts must be an ISO timestamp with a time zone
```

`page check`'s JSON, before and after (`text` omitted):

```json
before: {"code": "capture-failed", "severity": "error", "values": {"error": "/page/missing.js: cannot capture dependency: No such file or directory"}}
after:  {"code": "dependency-unreadable", "severity": "error", "values": {"error": "No such file or directory", "file": "/page/missing.js"}}

before: {"code": "sample-history", "severity": "error", "samples": ["practice"], "values": {"error": "data-sample-events 'fixture', event 2: ts must be an ISO timestamp with a time zone"}}
after:  {"code": "fixture-ts", "severity": "error", "samples": ["practice"], "values": {"reference": "fixture", "event": 2}}
```

## Tests

- **Registry tests.** The rest of the tests that matched registry words
in `test_interact_contract.py` now read records: about 45 tests, through
`check_findings`, `registry_refusal` and, for `page init`,
`command_findings`. So does
`test_a_layer_stamped_with_its_revision_still_names_the_revendor`, which
arrived from main. They pin facts the words only suggested, such as both
verbs that claim one record slot, the slot's kind and attribute, and a
schema complaint's keyword.
- **Capture and sample tests.** The sample-fixture, sample-document and
capture tests in `test_interact_contract.py`,
`test_interact_document.py` and `test_revision_delivery.py` assert codes
and fields.
- The two activation tests still refuse through `activate_source`. They
now read the reason from `page check`'s findings, because
`Activation.error` is a joined string.
- `test_check_validates_each_sample_document` lost its
`sample_holder_check` helper. It asserts codes and `samples` for both
holders now.
- **Runs.** I ran `test_interact_contract`, `test_interact_layer`,
`test_interact_document`, `test_revision_delivery` and
`test_server_lifetime` in full.
- **Word scramble.** I replaced the words of every registry, capture and
sample finding with a constant and ran those files, plus
`test_interact_product`, `test_product_page`, `test_interact_preview`,
`test_live_shell_artifact`, `test_todos`, `test_stop_guard` and
`test_render_gate`. 917 of 919 passed. Both failures read a capture
refusal's file name through text that is still a sentence: the `Refused`
that `page stamp` raises from `Activation.error`, and that same joined
string.

## Left for follow-ups

- **`Activation.error`.** It joins `check_source`'s findings into one
string, and `thread`, `agent_state`, `samples`, `served_state` and
`revisioning` read it as text. Carrying the findings would let those
consumers and their tests read fields.
- **`layer.incompatible_layer`.** Its refusal (#2658) reaches `page
check` as the one remaining `invalid-registry` text record. The page
servers, the event door and the website also read it as a sentence.

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