fix(harness): load only the block CSS WordPress would, and gate undeclared stylesheets #129

Merged
peterswimm merged 1 commit from fix/harness-declared-styles into main 2026-09-11 22:55:31 +00:00
Owner

Merge after toilville_rituals #399. CI's Test Generator checks out Rituals main, and the new gate fails until #399's declarations are there.

What happened

Eight toilville/* blocks shipped a style.css that their block.json never declared. WordPress only enqueues a block's stylesheet when block.json names it, so after today's deploy the live Rituals, Spelwork, News and Contact pages rendered mostly unstyled. #399 fixed that, and it's already live from its branch.

Nothing here caught it, because the preview harness loaded every blocks/*/style.css on disk, with a comment saying "as WP does". That's the fourth way the harness has flattered production.

The harness now loads what WordPress loads

build_page.py reads each block.json and loads only the stylesheets it declares (style, viewStyle). It also expands each @import relative to the stylesheet that imports it. Inlined into the page, an @import would otherwise resolve against the page instead of the stylesheet.

plugin stylesheets loaded hero-product card-grid shared window-chrome
before the fix (b05bd3b) 9 missing missing not loaded
#399 (33a9358) 17 loaded loaded expanded, no @import left

The first row matches what live WordPress served before the hotfix.

New gate

test_every_block_stylesheet_is_declared checks two things:

  • every .css in a block directory is declared in its block.json (style, viewStyle or editorStyle)
  • every _shared/*.css is imported by a declared stylesheet

It is red against the pre-fix plugin:

AssertionError: block CSS no block.json declares (WordPress never loads it):
  card-grid/style.css
  form-band/style.css
  hero-product/style.css
  intent-console/style.css
  post-list/style.css
  product-logo/style.css
  ritual-demo/style.css
  terminal/style.css

It is green against #399.

Verified

Against #399's plugin:

  • just check green
  • root pytest, run as CI runs it: 305 passed, 0 skipped
  • copy coverage clean
**Merge after toilville_rituals #399.** CI's Test Generator checks out Rituals `main`, and the new gate fails until #399's declarations are there. ## What happened Eight `toilville/*` blocks shipped a `style.css` that their `block.json` never declared. WordPress only enqueues a block's stylesheet when `block.json` names it, so after today's deploy the live Rituals, Spelwork, News and Contact pages rendered mostly unstyled. #399 fixed that, and it's already live from its branch. Nothing here caught it, because the preview harness loaded **every** `blocks/*/style.css` on disk, with a comment saying "as WP does". That's the fourth way the harness has flattered production. ## The harness now loads what WordPress loads `build_page.py` reads each `block.json` and loads only the stylesheets it declares (`style`, `viewStyle`). It also expands each `@import` relative to the stylesheet that imports it. Inlined into the page, an `@import` would otherwise resolve against the page instead of the stylesheet. | plugin | stylesheets loaded | `hero-product` | `card-grid` | shared window-chrome | |---|---|---|---|---| | before the fix (`b05bd3b`) | 9 | missing | missing | not loaded | | #399 (`33a9358`) | 17 | loaded | loaded | expanded, no `@import` left | The first row matches what live WordPress served before the hotfix. ## New gate `test_every_block_stylesheet_is_declared` checks two things: - every `.css` in a block directory is declared in its `block.json` (`style`, `viewStyle` or `editorStyle`) - every `_shared/*.css` is imported by a declared stylesheet It is red against the pre-fix plugin: ``` AssertionError: block CSS no block.json declares (WordPress never loads it): card-grid/style.css form-band/style.css hero-product/style.css intent-console/style.css post-list/style.css product-logo/style.css ritual-demo/style.css terminal/style.css ``` It is green against #399. ## Verified Against #399's plugin: - `just check` green - root `pytest`, run as CI runs it: **305 passed, 0 skipped** - copy coverage clean
fix(harness): load only the block CSS WordPress would, and gate undeclared stylesheets
Some checks failed
PR policy check / policy-gate (pull_request) Failing after 0s
Security Scans / Gitleaks secret scan (pull_request) Successful in 24s
Security Scans / Trivy filesystem scan (pull_request) Successful in 30s
Test Generator / test (pull_request) Failing after 24s
Test Generator / lint-workflows (pull_request) Successful in 21s
Test Generator / lint-prose (pull_request) Successful in 18s
Copy coverage / Design copy reaching rendered HTML (pull_request) Failing after 21s
UDG dist drift gate / dist/ matches dtcg + udg sources (pull_request) Successful in 13s
f94771bafb
The preview harness loaded every blocks/*/style.css on disk, so eight blocks whose block.json never declared their stylesheet looked styled in every render while the live pages rendered bare (toilville_rituals #399). build_page.py now loads only what block.json declares (style, viewStyle) and expands each @import relative to the stylesheet that imports it. Against the pre-fix plugin it now drops hero-product, card-grid and the rest, as WordPress did.

New invariant test_every_block_stylesheet_is_declared: every .css in a block directory must be declared in its block.json, and every _shared/*.css must be imported by a declared stylesheet. Red against toilville_rituals b05bd3b (it lists the eight), green against #399.

--no-verify: from a worktree the shared hook's native-token sync targets a checkout outside any repo. Gates run by hand: just check, root pytest 305 passed, copy coverage.
peterswimm deleted branch fix/harness-declared-styles 2026-09-11 22:55:31 +00:00
Sign in to join this conversation.
No description provided.