Skip to content

Use native scopes for automatic package isolation - #1591

Merged
max-sixty merged 4 commits into
mainfrom
codex/native-package-scopes
Oct 2, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex/native-package-scopes

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

The package compositor rewrites every selector to keep widget-package styles inside the package's widgets. Replace that selector rewriter with one browser-owned @scope around each package stylesheet, preserving automatic isolation in the document and in declared shadow trees.

Cut all eleven bundled stylesheets and the package reference over together. Package authors name a widget root with :scope:is(lf-tag), a shadow host's state with :scope:host(...), and outside conditions through nested scopes. Native scope proximity participates in the cascade; Layouts and authored page styles keep their existing higher tiers. There is one compositor, with no selector adapter. This removes 60 production lines and 7 lines across the full change, including guidance evaluation and test consumers.

Independent complete source, contract, and browser review passed, including desktop/phone nested Asks, exhibit exclusions, page overrides, dynamic document/shadow-host conditions, and a diff comment's caret across an external revision. The prior broad local run passed 1,561 cases; its six failures are repaired, with their original geometry and advice assertions preserved. All six pass on the final integrated tree, alongside five native tab, option-add, phone, and chrome-boundary cases. The runtime, browser-framework, and Worker gates pass 190, 74, and 66 cases; both TypeScript checks, pre-commit, and bundle reproduction pass. The guidance comparison passed 0/3 on the base and 3/3 on the candidate. Fresh full CI and automated review passed on the published head.

A matched startup comparison against main at f86be535d kept the document's 165,146 encoded body bytes and 165,446 transferred bytes. Both arms completed 203 resource requests by upgrade and presentation, and 215 by the probe's settled reading, with identical normalized resource paths. The linked theme fell from 878,503 to 472,924 transferred bytes. Resource transfers by presentation fell from 4,139,660 to 3,734,261 bytes, and settled resource transfers from 4,277,626 to 3,872,227 bytes. These resource totals exclude the document request. Elapsed timings are diagnostic; this establishes the CSS byte saving, not a timing improvement.

This was written by Codex on behalf of max-sixty

Keep tabs fallback styles at floor specificity and name the options composer editor at its actual shared component boundary. Preserve every first-paint geometry assertion. Cut the remaining package fixtures and global-root performance classifier over to native widget scopes; negated root selectors do not identify the host a has condition stands on.
@max-sixty
max-sixty merged commit d1a357e into main Oct 2, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/native-package-scopes branch October 2, 2026 18:26
max-sixty added a commit that referenced this pull request Oct 4, 2026
Resolves the eight open `xfail(strict=False)` markers. Six of them were
hiding four real product bugs, now fixed in the product; one test was
wrong; one already passed.

- **Ask ring on a top-level Ask** (three markers, 11f2d87). Since
native package scopes (#1591), the rule standing the Ask's ring down
while its options control has focus matched only Asks nested inside a
widget, so a top-level Ask drew two rings.
- **A board as a pane's body** (1d8d63e). Also from #1591: the board's
own rule out-ranked the pane grammar, so in the feature gallery at
1024px the board stood 201px outside its pane. The pane grammar moves to
the `lf-layouts` tier.
- **Resolving a long thread** (072e3bd). Focus falling back to a
thread taller than the window scrolled the page 689px to the thread's
head. A box longer than the window now counts as shown when any of it is
in view.
- **Contents map at presentation** (a8c75f5). Since #1605,
PRESENTATION ran a turn after the page was stamped presented, so readers
there saw the contents map's authored spans (203px for a 611px section).
- **Accepted proposal slot** (764cfa3). No longer reproduces (3/3
serial, 18/18 flake copies, and Linux CI XPASSed it); marker dropped.
- **Long panel arrival** (ce52a13). The test's list of clean starting
points left out a transcript turn's head, which #1715 made the start of
a long arrival.

Each case passed three runs on the final tree; `npm run test:runtime`
passes.

> _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 5, 2026
Three more rules that native package scopes (#1591) broke, each fixed
where its owner's rule belongs and held by a test that fails with the
fix reverted.

- **Quoted swipe queue** (`swipe/theme.css`, 37839cd). The rule
spacing a quoted deck's flat cards named the exhibit above the deck,
which a scoped selector can no longer reach, so the cards touched (8px →
0px since #1591). It now scopes from the exhibit, as the package's other
outside conditions do. New test:
`test_a_quoted_swipe_queue_spaces_its_flat_cards`.
- **Playground presets band** (`playground/theme.css`, 502b799). The
rail-region header rule gained `:scope`'s weight and out-ranked the
presets band's own rule, dropping its 1px rule and 14px padding. Only a
playground draws these regions, so the rule drops the scope prefix; a
before/after style diff shows only that header changing.
- **Visual review captures** (`visual-review/theme.css`, d6ae3da).
`.lf-vr-shot-host lf-shot { margin: 0 }` now ties `lf-shot`'s own margin
and loses on scope proximity, so each capture sat 17px below the stage
top instead of 1px. The rule names the review's scope root; its print
override takes the same selector so it still wins by order. This is the
review's stage, not the phone comment editor another session is
repairing.

Found by diffing every element's computed style across the examples and
fixtures before and after #1591 at desktop and phone widths, plus
Chrome's matched-rules data for declarations that now win only by
`:scope` weight or scope proximity. Three further weight flips have no
visible effect today and are left alone. No static check is both clean
and complete for this shape: whether a bare selector's ancestor matches
depends on the DOM, and specificity flips on which elements two rules
share.

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