Repository navigation
Report markup validation findings as records - #2686
Merged
Merged
Conversation
Every check behind `page check`'s markup half now produces a `Finding` record where it detects the problem: a stable code, the element it concerns (`at`, with the line in `values`), the offending and expected values, and the live sample whose document it was read in (`samples`). The words are written once, in `findings.py`'s code table, which moves from `render_gate/` to `leaf/` since validation, structure, styles and data contracts all report through it now. `page check --json` carries the real fields where it carried `markup` records whose only value was the text. Message markup refusals raise `Rejected`, a `Refused` that keeps its findings, so a caller reads the records rather than the sentence. User-visible changes, all wording: - an element named by id reads `<lf-suggestion id=sg>`, as the render findings write it, where suggestion, question-context, measurement-lag and owned-twice findings wrote `id='sg'` or `id="sg"`; - every message markup refusal opens "<kind> markup doesn't validate:" and lists its findings, where duplicate ids, taken ids and a looping sample read "<kind> markup: …" on one line. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
#2686 made the markup checks report records. This PR switches the tests that matched `page check`'s words for those findings to read the records. `interact_support.check_findings` runs `page check --json` in process and returns the exit status and the findings. `found` selects them by code, by element, and by values. The assertions now pin facts that the words only suggested: - the reserved markers each element wears, which replaces a count of a phrase and a hand-written negative check for `(note)`; - the line and body of each split pane; - the template ids a sample child's error was read in; - the allowed values for an allocation; - the layer's known words for an unknown tone; - exactly which threads activation would move. That last one now includes the reaction mark that follows its subject. The text assertion it replaced never excluded it. Some assertions still match words, because what they read is not a record yet: - a registry contract's `RegistryError` (the `invalid-registry` finding's `error`); - capture's `ArtifactError` (`capture-failed`); - a sample history's event refusal (`sample-history`); - a page that was never initialized, which `page check` refuses before it checks anything; - refusals at the `thread` and `comment` commands, which have no `--json`. No user-visible behaviour changed. I ran the model files `test_interact_contract`, `test_interact_document`, `test_interact_anchors` and `test_interact_product` in full. I ran each changed journeys test by node ID, in `journeys/test_interact_document.py`, `test_interact_contract.py` and `test_interact_anchors.py`. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This was referenced Oct 13, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 13, 2026
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 #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: ```json 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: ```json 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_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 13, 2026
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_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The markup checks behind
page checknow report findings as records, as #2662 made the render gate do. Each check produces aFindingwhere it detects the problem. The record carries a stable code, the element it concerns asat, and the line and the offending and expected values invalues. A newsamplesfield names the live-sample document it was read in. The words for every code are written once, in the code table infindings.py.page check --jsonnow carries these fields. Before, it wrapped each markup error as amarkuprecord whose only value was the text.What changed
findings.pymoves fromrender_gate/toleaf/, because validation,structure,stylesanddata_contractsnow report through it too. Its code table gains the markup codes, about 75 of them, such asunknown-widget,attribute-schema,not-member,allocation-value,duplicate-ids,unpointable,contract-conflictandcss-syntax.list[str]:validation/markup.py,validation/instances.py,validation/source.py,validation/source_history.py,validation/admission.py, the parser's own errors instructure.py,styles.css_syntax_errors, and the binding conflicts and measurement lag indata_contracts.py.SourceCheck.errorsand.advicearelist[Finding]. Callers that join them into a refusal (page stamp, activation, a reply while the source is invalid, data writes) printstr(finding).keywordandpath. The text of a question context that asks nothing is now built from data: each framed widget and thex-awaitsconditions it lacks (instances.unasked). A reference that breaks a relation carries the relation, its predicate and what the target declares. A sample's errors carry the template ids insamplesinstead of asample 'x':prefix on the sentence.check_markupandread_text_argraisefindings.Rejected, aRefusedthat holdsfindings.message_markup_errors, formerlymessage_markup_error, returns the first failing stage's findings.Wording changes
Two wordings were inconsistent with the rest, and now match them:
<lf-suggestion id=sg>, the form the render findings use. Suggestion, question-context, measurement-lag and owned-twice findings used to writeid='sg'orid="sg".<kind> markup doesn't validate:and lists its findings. Duplicate ids, taken ids and a looping sample used to read<kind> markup: …on one line. Their findings read the same as before.Human output: before and after
leaf page checkprinted byte-identical stdout, stderr and exit status at the merge base and on this branch for five shipped examples copied into fresh pages:triage-board,release-notes(missing media),alert-review,heat-lossandreview-a-plan.I ran it on two fixtures with known errors. The first has 44 errors across most of the codes. The second covers allocations, question contexts, unclosed tags and errors inside nested samples. The only differences are the id spellings above:
On a set of bad reply fragments,
check_markup's refusals were identical, except for the duplicate-id refusal, which now has the shared heading:page check --jsonfor one finding, before and after:{"code":"markup","severity":"error","values":{"text":"<div data-width=\"huge\"> (line 10) has an invalid value; expected one of wide, available"},"text":"…"} {"code":"allocation-value","severity":"error","at":"<div>","values":{"line":10,"attr":"data-width","value":"huge","allowed":["wide","available"]},"text":"<div data-width=\"huge\"> (line 10) has an invalid value; expected one of wide, available"} {"code":"unknown-widget","severity":"error","at":"<lf-bogus>","samples":["kid"],"values":{"line":16},"text":"sample 'kid': <lf-bogus> (line 16): unknown widget — not in the vendored registry.json"}Tests
fragment_errors,reference_errors,check_markup's refusal, anddeclared_data_bindings. They use two newinteract_supporthelpers:check_findings, which runspage check --jsonin-process, andfound, which selects findings by code, element and values.test_interact_product,test_interact_contract,test_interact_document,test_interact_anchors,test_interact_layer,test_render_gate,test_responses,test_receipts,test_wait,test_stop_guard,test_questionsandtest_delivery. I also ran the sample, markup, check and stamp tests inprocess/test_interact_server.py, and the touched journeys nodes.Left for follow-ups
page checktext. About 200check()calls still match the CLI's words. Their words did not change, so they pass. Cutting them over tocheck_findingscomes next, by area.RegistryErroris raised from about 100 sites inregistry/and reachespage checkas oneinvalid-registryfinding whose value is the error's text.ArtifactErrorreaches it ascapture-failed, and a sample's history assample-history. Those exceptions are a separate producer family.EventRefusedis matched by text withpytest.raises(match=…)across the suite. It is larger than this change.