Skip to content

Enforce runtime root-state ownership - #637

Merged
max-sixty merged 3 commits into
mainfrom
codex/fix-clipped-reader-heading
Sep 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/fix-clipped-reader-heading

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #621. Version activation keeps the document roots alive while replacing authored state, so runtime-owned root attributes and styles need one enforceable ownership boundary.

This expands the existing architecture lint from inline styles to root state. It covers direct properties, DOM attribute methods, dataset, classList, Object.assign, Reflect.set, stable aliases, and destructured aliases while permitting Leaf-reserved data-lf-* attributes and lf-* class tokens.

Unknown attribute names fail closed. References through the shared PAGE_PAINT_ATTRIBUTE registry are resolved from its canonical declaration, so the runtime's existing house style remains checked without duplicating the registry.

Validated with causal lint probes for accepted and rejected mutation forms, the full pre-commit gate, and independent review.

This was written by Codex on behalf of max-sixty

@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.

Two gaps in the expanded rule, one a narrowing of what it caught before.

The const-only definition filter drops let aliases the base rule reported. Swapping declared.id.type === "Identifier" for parent?.kind === "const" was needed to let initialValue see an ObjectPattern, but it also stops resolving every non-const alias. Probed at both commits with let mutable = document.body; mutable.style.color = "red"; in a runtime module: the merge base reports it, this head does not. So a PR that expands the inline-style boundary also opens a hole in it. Inline suggestion below keeps both forms — it restores the let case, leaves the destructuring support intact, and the repo stays lint- and prettier-clean with it applied.

The setAttribute family fails open where dataset and classList fail closed. if (attribute !== null && !attribute.startsWith("data-lf-")) means an attribute name the rule cannot resolve to a static string is silently permitted, while an unresolvable classList token or dataset key is reported. That asymmetry lands on the form the runtime actually uses: every root attribute write in skills/leaf/assets names the attribute through the imported PAGE_PAINT_ATTRIBUTE map — leaf.js (two sites), runtime/data.js, runtime/traffic.js, runtime/state-application.js (three), runtime/projection/presentation.js (two), runtime/keyboard/go-to-sequence.js — and staticString cannot follow an import, so the rule sees none of them. None is a violation today, since every value in that map except class is data-lf-*. But the house style for naming a root attribute is the one form the boundary does not enforce, so the next writer of a non-reserved root attribute gets no error.

I confirmed the mechanism rather than inferring it: flipping the branch to attribute === null || ... makes the rule report exactly those ten call sites and nothing else. That is not a fix on its own — it would need the rule to recognise the reserved-constant reference, or those sites to pass the literal — so it is a design call rather than something to patch inline. Worth naming which way you want it, because the rule's value is that the boundary is enforceable, and this is its widest branch.

Verification

Installed eslint@10 and ran npx eslint skills/leaf/assets skills/leaf/packages against the merged tree: green, so nothing in the tree violates the new rule as written.

Behaviour probed with a temporary module under skills/leaf/assets/runtime/, removed afterwards. Confirmed permitted: dataset.lfFoo assignment and delete, classList.add("lf-x"), classList.toggle("lf-a", true), setAttribute("data-lf-x", "1"). Confirmed reported: non-reserved dataset keys and class tokens, dynamic class tokens, classList.replace("lf-a", "b"), setAttribute("role", …), and writes through destructured const { body, documentElement } = document aliases. The destructuring support works as claimed.

Also checked the name-based exemption against version.js's replaceAuthoredAttributes, which iterates the prior authored attribute map rather than the live one. Reserved names never enter that map, so permitting them without root-state.js registration is consistent with what activation removes — the exemption is sound.

Comment thread eslint.config.mjs Resolved
Comment thread eslint.config.mjs Resolved
@max-sixty
max-sixty merged commit 983e785 into main Sep 12, 2026
19 checks passed
@max-sixty
max-sixty deleted the codex/fix-clipped-reader-heading branch September 12, 2026 18:03
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