Repository navigation
Scope page author stylesheet variants to routes in place - #3548
Merged
Merged
Conversation
chubes4
force-pushed
the
fix/2755-route-scoped-variants
branch
from
October 26, 2026 23:42
61cbf72 to
37cba59
Compare
chubes4
force-pushed
the
fix/2755-route-scoped-variants
branch
from
October 27, 2026 02:39
6fa3e21 to
ff5af83
Compare
chubes4
marked this pull request as ready for review
October 27, 2026 03:31
…tes by total copy cost
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.
Fixes #2755.
Problem
When pages project a shared author stylesheet differently, the compiler writes a full
.page-<hash>.csscopy for every page that differs. On a 112-route Bootstrap 5 site this produced 489 page copies (75.7 MB), and every page downloads its own uncached copy.Design
Page variants are reconciled into the shared stylesheet in place, at their source cascade position, and scoped to the routes that keep them:
<html>carriesbe-rplus a short collision-freebe-r-<8 hex>route class (DocumentRootContext).RouteSelectorMatchIndex(key prefilter +CssSelectorMatcher) on compiled markup. Undecidable selectors stay scoped.aria-current, current-menu/current_page classes, BE route-state classes) is never proven inert. WordPress sets it at render time, so compiled markup can't disprove it.:where(:root:not(<outside routes>)). Variant-only arms exclude it with the shorter of:where(:root:is(<routes>))or:where(:root.be-r:not(<outside routes>)). Its inertness proof uses only the engine classes carried by shared template-part markup.@importrules that follow other rules, which CSS ignores, are dropped before comparison. Differing leading imports still fall back.author_stylesheet_route_scope_fallbackdiagnostic. So this change never ships more than trunk would.Real-site verification
Full 112-route import (liguetirdauphinesavoie.com capture) through Studio
site create --fromwith SSI vendoring this branch, against the same import on trunk:.page-stylesheet copiesVisual parity: all 110 published URLs (pages, posts, WooCommerce shop/cart/checkout/product/my-account) at desktop 1440 and mobile 390, compared by screenshot and by every element's computed style and geometry. 216 of 220 page-views are identical. The 4 that differ are the product page, whose only difference is the local port in a WooCommerce background URL, and 1 px text-metric shifts in the home page footer.
The visual check caught two regressions in earlier iterations, both fixed here with contract tests: render-time
aria-currenttreated as inert (wrong active dropdown item on 31 routes), and non-plan pages losing base rules (unstyled WooCommerce pages).bootstrap (+5.2 MB vs 4.3 MB limit) and common (+2.3 MB vs 1.9 MB) still fall back on this site, so further scope reduction is possible as a follow-up.
Tests
tests/contract/shared-author-stylesheet-scaling.phpcovers route scoping, the inertness proofs, the render-time state and non-plan cases, ignored imports, the short exclusion scope and the shipped-byte budget. Each case fails without its fix. Also:tests/unit/css-stylesheet-transformer.php,tests/unit/document-root-font-ownership.php,composer test:canonical,composer lint.AI assistance
Implemented by GPT-6.1 Sol and Claude Opus via Homeboy Cook (Pi via Roadie). Claude Opus did the real-site measurement, instrumentation, visual parity check, the
@importfollow-up and review. Chris approved each direction.