Repository navigation
Report every problem from one page check, and judge CSS by the reader delivery uses - #4619
Conversation
Behavior that changes: `page check`, `page init` and `package check` now refuse a registry with the first problem in each independent unit at once, where they stopped at the first problem anywhere. An author with faults in three page declarations used to need three runs; now one names all three. Each finding's code and text are unchanged. Validation keeps its dependency order and gathers within each stage (`registry.contract.gathering`): - the layer facts' shape, reporting the first departure in each `$` fact; - then, together, the layer's other facts (each event kind's clauses, documenting fact, idiom, the languages and each data contract) and each element declaration on its own; - once every declaration holds alone, each declaration against the others, its own checks still in order, shown answers and answered conditions now part of that per-declaration sequence rather than separate passes; - once the vocabulary holds, each example and each widget's module. A later stage still waits for the one it reads, so a declaration's relations never read another half-validated, and the worst case is three runs rather than one per problem. `RegistryError` takes a list of findings, as `ArtifactError` does, and a re-vendor refusal marks every finding rather than the first. `deciding_outcomes` no longer assumes the deciding verb declares `outcome` words: a child's `x-retired-when` check now reads its parent in the same run as the parent's own check, and a parent missing them crashed `page check` with a KeyError (already reachable on main through `x-awaits.all`, before the parent's own deciding-verb check).
…wner
`check_source` skipped the capture whenever the markup check found anything,
so a page with one markup error and one bad file reference needed two runs.
The capture now runs whenever the page's vocabulary reads; a document that
parses badly still captures accurately, since the capture reads its scripts,
links, styles and references from the parsed tree whatever its shape. A
source with errors still keeps no capture.
Running both exposed problems each side reported, so each now has one owner:
- A document's own CSS (`<style>` and style attributes) is the markup check's
`css-syntax`. The capture no longer refuses it as `css-invalid`, which is
gone: `_read_css` records a parse error as the sheet being undeliverable,
and `rewrite_css` still refuses such a sheet.
- A page file's stylesheet is the capture's, now under the same rule
(`styles.css_syntax_errors`) as the document's, so a declaration the
browser drops (`p { color: red; broken; }`) in `page/style.css` is refused
with its row and column, where only token-level errors were before.
- A `/media/` file the page won't answer is the capture's, in the words the
message door uses (`missing-media`, `unserved-media`) instead of
`dependency-unreadable`, wherever the page names it, a stylesheet
included; markup's page-door media check is gone. A message, which no
capture reads, keeps the check for itself and for its samples' children.
Since the capture now refuses an unserved name, CSS under `media/` can't be
captured, and the branch that read it is gone.
- The message door now checks the syntax of a message's style attributes, as
the page door does, since delivery can't re-address a malformed one.
`styles.authored_sheets` names each sheet a document writes for both
readers, so a capture refusal in a `<style>` names that sheet rather than
`/index.html`.
Tests: `tests/model` in full. The inspection fixtures drop CSS and a
non-UTF-8 script under `media/`, which no page can serve; the test of the
latter is deleted, since a revision can no longer hold one.
…yer fact Behavior that changes: - A declaration whose attribute schema is `true` or `false` is refused for what it lacks, where `page check` crashed with an AttributeError. A pane requiring `id` with `properties.id: false` read `.get` off the boolean (`reading-role-attr`'s id and label lookups). That crash was on main too, without any other fault; gathering only made it reachable beside a layer fault such as an undeclared `$languages.paths` language, where it then lost that collected finding. The staging is right: the relation stage reads nothing a layer-declaration unit checks, only the layer facts' shape, which gates every later stage. Every "attribute declared as an object of this type" test in `registry.widgets` now reads through one `_typed`, which treats a boolean schema as naming no type. - An attribute taking the layer's tones or languages (`x-tone`, `x-language`) with a boolean schema no longer crashes composition when stamping its words: `true` becomes the words alone, `false` admits none and is left as it is. - Missing layer facts are each named: removing `$languages` and `$tones` reports both. `LAYER_FACTS` is now a map of fact to schema, each required, and `check_layer_facts` holds each fact to its own schema, so a missing fact's `required` error belongs to that fact rather than to the root, where grouping by path merged every missing one. Each finding's code and text are unchanged.
Two parsers decided whether a sheet's syntax was acceptable, and they
disagreed. Validation parsed a style attribute as a block's contents and
delivery as a declaration list, so `<p style="& { color: red; }">` passed
check_source, capture, message validation and inspection, and then delivery
refused it with `ArtifactError([])` and no reason.
Delivery's reader (`revision_artifact._read_css`) now decides what a sheet
must not hold, and it carries its diagnostic: each parse error becomes a
`css-syntax` finding with row, column and message. Capture reaches it for the
page's own sheets and files, and the message gate for messages
(`uncaptured_errors`). `rewrite_css` refuses with the same findings, so it can
no longer raise an empty refusal.
The markup check's deeper parse (`styles.dropped_css`, which replaces
`styles.css_syntax_errors`) now reports only what that reader reads but a
browser drops, such as `broken;` in `p { color: red; broken; }`, as a new
`css-dropped` code. The source check reports it for the document's sheets and
for each stylesheet under `page/`, so nothing is reported twice. It still
refuses. Its severity is set in `styles.DROPPED_SEVERITY` alone: check_source
sends a finding below "error" to `notes`, which `source_advice` reports, the
message gate keeps only refusals, and layer validation refuses only errors.
Behavior that changed:
- A nested rule or malformed declaration in a style attribute is refused at
the page and message doors with the reader's message, instead of failing at
delivery.
- An unterminated string in a quoted `url()` is one `css-syntax`; it no longer
also gets `css-url`.
- A message names pictures through the same CSS reference reader as the page:
a `/media/` file in a style attribute that the page won't serve, or that is
missing, is refused (`unserved-media`, `missing-media`). Before, the message
was accepted and delivered broken. Media checks for messages and their sample
children now go through `uncaptured_errors`, which replaces
`validation.markup.media_errors`.
- `page inspect` lists both kinds in `syntax_errors` through
`revision_artifact.css_syntax_errors`. Like any capture refusal, a sheet
delivery can't read stops the inspection, now with that sheet's diagnostic.
Tests: `tests/model` in full (1866). New cases cover both doors refusing what
delivery can't read, with the message delivery itself would give; the
unterminated `url()` string; a message's CSS media; and the severity switch
at "error" and "advice".
… no drops past a refusal
Capture and the message gate found a document's stylesheets through the
authoring reading, which leaves out template contents and declarative shadow
roots, while delivery rewrites the CSS in both. So
`<template><p style="& { color: red; }">X</p></template>` passed check_source
with a capture and passed message validation, and then delivery refused it.
`structure.delivered_elements` is now the one walk of what a document
delivers (its elements, each template's contents and each declarative shadow
root), and `revision_delivery.rebase_document` iterates it.
`structure.delivered_sheets` reads each `<style>` and `style` attribute from
that walk for every other reader: capture reads it once for the document, a
sample's sheets among its page's, instead of per sample document; the message
gate does the same through `uncaptured_errors`; and `revision_artifact.
document_drops` reports dropped declarations over it, for the page in
check_source and for a message in its gate. `styles.authored_sheets` and
`validation.markup.dropped_styles` are gone, and a message sample child's own
walk now asks only of the pictures its attributes name.
The deeper parse no longer reports on a sheet delivery's reader refuses:
`revision_artifact.css_drops` returns nothing for one, so `p { ] }` is one
`css-syntax: Unmatched ]` rather than that plus a cascading `css-dropped`, in
a page, its samples and a message's samples. Inspection's and layer
validation's `css_syntax_errors` goes through it too.
Tests: `tests/model` in full. New cases refuse a malformed style attribute at
the page and message doors in the document, a template and a shadow root, each
with the message delivery itself gives; and a sheet the reader refuses reports
its syntax error alone. A control run without the reader gate fails the
latter.
# Conflicts: # src/leaf/page_inspection.py # src/leaf/registry/storage.py # tests/model/interact_contract/test_vocabulary.py
…eep refusing it in a package's sheets By the maintainer's decision, css-dropped is advice for a page's own sheets: delivery's reader reads such a sheet whole, so refusing it protected nothing of Leaf's. CSS that reader can't read is still refused. A layer's sheets, which are a package's maintained code, still refuse a dropped declaration.
leaf-agent
left a comment
There was a problem hiding this comment.
[P2] The server CSS recovery test still expects dropped declarations to refuse activation. test_state_validation_follows_css_edits_and_recovers_cached_readings changes the custom property to a missing-colon declaration and then searches source_error for a syntax error. With this PR that declaration correctly becomes advice, so source_error is None and the test raises TypeError. I reproduced this with uv run pytest tests/process/test_interact_server.py::test_state_validation_follows_css_edits_and_recovers_cached_readings -q -n0.
The test can retain its cache, refusal and recovery coverage by using a CSS input delivery still refuses, such as an unmatched closing square bracket, for its middle state. The intended advice behavior can remain as implemented here. This failing consumer test withholds approval.
…declaration is now advice The cached-reading test edited a declaration's colon away to make the middle state refuse; that declaration is now dropped as advice, so the page activates. An unmatched ] is still a syntax error, which keeps the test's cache, refusal and recovery coverage.
page checknow reports everything wrong with a page in one run, and the CSS it refuses is decided by the same reader delivery uses, so nothing passes the check and then fails at delivery. Part of the "Primitives, not a template" survey (SOUL.md), after #4490, #4546 and #4554.Behavior that changes
page/file or broken stylesheet surfaced only on the next run. Capture now runs beside markup validation over one walk of the document, and each problem is reported once, by the check that owns it (validation/source.py,revision_artifact._collect).page/registry.jsonreports one problem per declaration. The registry stopped at its first error. It now collects the first problem in each widget entry and each missing layer fact (registry/state.gathering()), so a registry with several bad entries takes at most a few runs instead of one per entry.RegistryErrorand the layer refusals carry a list of findings. A boolean attribute schema (true/false) reads as typeless instead of crashing the check.revision_artifact._read_css, the reader delivery rewrites sheets with, decidescss-syntaxfor pages, messages, templates and declarative shadow roots alike; the walk check and delivery share (structure.delivered_elements/delivered_sheets) means a sheet the check skips is one delivery skips too.css-dropped(for examplecolor: ;or a straybroken;) no longer refuses a page: the browser ignores the declaration, the page renders the same outside Leaf, and the author sees the finding. A package's stylesheet still refuses it, since packages are maintained code (layer._stylesheet).validation.mdsays so.Checks
The model tests for authored markup, the layer and registry contracts, media, vocabulary, document and layer inspection, module delivery and page inspection (885 passed, after merging current
main), andpnpm run check. Codex reviewed each commit; its findings (the two CSS parsers disagreeing, a problem reported twice, the template and shadow-root walks diverging, a crash on boolean schemas, several missing layer facts merged into one finding) are fixed here.