Skip to content

Declare stylesheet access instead of inferring selector intent - #2997

Merged
max-sixty merged 7 commits into
mainfrom
codex/native-page-css-scope
Oct 15, 2026
Merged

max-sixty merged 7 commits into
mainfrom
codex/native-page-css-scope

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Page and theme CSS currently infer permission to style Leaf controls from selector spelling. Negated widget names can leak, while selectors nested in constructs such as nth-child can be misclassified.

Replace that inference with explicit stylesheet access: page style/link elements use data-controls, and theme packages put deliberate control styling in controls.css. Ordinary selectors retain the existing weightless subject exclusion, preserving root variables, ancestor conditions, pseudo-elements and cross-sheet cascade behavior. Native CSS scopes keep their normal meaning. Widget packages continue styling their own controls through their existing theme sheet.

Carry stylesheet attributes through the canonical source reading, corpus composition and export. A changed stylesheet declaration rebuilds its native CSSOM owner, so a body-only access grant or withdrawal takes effect during a live revision. Update the author contract, examples, core gallery and authoring evaluation together.

Validation: independent review and follow-up review are clean; four focused browser tests, nine focused model checks, 493 runtime tests, changed-file pre-commit and browser bundle checks pass. Root/ancestor/pseudo-element/cascade controls pass Chromium, Firefox and WebKit. The instruction comparison passed 3/3 candidate trials versus 0/3 base trials. Four existing visual states are unchanged; the gallery adds the access demonstration. Startup adds no code requests and reduces JavaScript payload by 685 bytes.

This was written by Codex on behalf of max-sixty

Ordinary page and theme rules stop at chrome and generated controls through a native scope boundary. An explicit authored scope grants access, replacing selector-name inference and the selector list parser. Migrate deliberate example styling and author guidance together.

Browser tests retain generic-rule protection, imports and dynamic rewrites, and now use explicit scope for deliberate control styling. The authoring instruction comparison passes 3/3 on the candidate and 0/3 on the former contract.
Parse and serialize each layer source before wrapping it, so CSS EOF recovery cannot swallow later layers. Keep authored style elements independent for validation, dependency capture and corpus generation. Remove css-unclosed and accept the browser recovery it attempted to police. Correct only tinycss2 surrogate escape output to CSS-required U+FFFD before UTF-8 encoding.
Keep stylesheet attributes in SourceDocument and carry them through corpus hoisting and export. Stylesheet nodes are native CSSOM owners: a changed source declaration reparses its original rules, including a body-only access grant or withdrawal. Keep stylesheet load handling in its one owner.

Focused browser coverage proves grant and withdrawal through live revisions; source/export/corpus tests protect metadata preservation. Independent review found the earlier gaps and confirms they are fixed.
# Conflicts:
#	dev/leaf_dev/commands/corpus.py
#	skills/leaf/scripts/leaf/structure.py
@max-sixty
max-sixty merged commit 48fc4ac into main Oct 15, 2026
3 checks passed
@max-sixty
max-sixty deleted the codex/native-page-css-scope branch October 15, 2026 07:38
leaf-agent added a commit that referenced this pull request Oct 15, 2026
#2997 made stylesheet access to Leaf controls explicit. That left
PhotoSwipe's runtime stylesheet, which Leaf appends inside its image
dialog, subject to page CSS filtering. Its positioning rules no longer
reached the viewer, so the fitted image appeared below the stage. Mark
that sheet `data-controls` before attaching it. Browser probes that
deliberately style Leaf controls now declare the same access, preserving
their original assertions.

This addresses 16 failures in the [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38700868252). The
two other failures in that run were separately repaired by #3003 and
#3005; their current tests pass. The 16 affected browser cases pass
locally, including both online and exported image previews, compositor
frames, the corpus stylesheet-order gate, and control styling. `pnpm run
check`, 487 runtime tests, and changed-file pre-commit checks pass.

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 15, 2026
The [scheduled main
run](https://github.com/max-sixty/leaf/actions/runs/38723388285) failed
response inset, focus-ring, and scaled-panel checks whose test styles
tried to change Leaf controls without the stylesheet access marker
introduced by #2997. Leaf correctly narrowed those selectors, so the
claimed inset, deliberately missing rings, and panel scale never reached
their controls. These test styles now declare `data-controls` before
they attach, preserving the checks while respecting the explicit access
boundary.

The two response inset cases, missing-ring case, and scaled-panel case
failed before their fixes and pass locally afterward.

---------

Co-authored-by: leaf-agent <[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