Skip to content

fix(remap): fail closed on global CSS Module selectors - #1430

Open
BenSheridanEdwards wants to merge 3 commits into
mainfrom
fix/css-module-element-selectors-all
Open

BenSheridanEdwards wants to merge 3 commits into
mainfrom
fix/css-module-element-selectors-all

Conversation

@BenSheridanEdwards

@BenSheridanEdwards BenSheridanEdwards commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Why

Selective remapping must re-capture a non-importing surface when a CSS Module can emit a global selector. A module imported only by Home can still style About through h1; the previous classifier treated this as local, including when a URL or Sass interpolation concealed the selector boundary.

Closes #1413.

What changed

  • Require class/id-led rule headers before narrowing a CSS Module to its importers.
  • Preserve quoted values and URLs while finding selector boundaries, so https:// cannot erase a later global selector and quoted braces cannot invent a rule.
  • Fail closed on unresolved Sass interpolation, ambiguous syntax and indented Sass/Stylus. Preserve ordinary static local rules and normal SCSS comments.
  • Add public classifier and Home/About selection regressions, with README, reference and changelog updates. Public API and protected gates are unchanged.

Reviewer view

Module content Capture plan
Static local .card / #title rules Follow the import graph
A global h1, including after a quoted/unquoted URL Re-capture every surface
.foo#{", h1,"}.bar { color: red } Re-capture every surface
Syntax whose scope cannot be proven Re-capture every surface

Sass can remove quotes during selector interpolation, so interpolation cannot establish a local-only bound before preprocessing.

Proof

  • Six of eight new URL/syntax cases failed against the old exact source; the other two are compatibility guards. The repaired affected-surface suite passes 101 cases.
  • Astra found the remaining interpolation case on the first repair. Two independent regressions against its actual compiled code failed: classifier scope, and affectedSurfaces selecting only Home. With the escape guard, the final compiled focused run passes 103 cases, including both Home and About coverage.
  • Screenshots and report excerpts: Not applicable. This changes a pure classification/capture-plan decision, not report rendering or capture payloads. Literal public-function outcomes prove which surfaces must be captured.

Behaviour changes

Global, ambiguous and interpolated module styles force a full remap, including non-importers. Proven static local modules remain selective. The feature stays opt-in; the default still captures every surface.

Not asked for

No Sass compiler, bundled-app fixture, new dependencies, public schema, workflow/gate changes, releases or held report work. No merge or human signoff was performed.

Review guide

Read MODULE_ESCAPES, STYLE_MODULE_TOKENS and moduleEscapes in src/affected-surfaces.ts, followed by test/affected-surfaces.test.mjs and test/affected-surfaces-interpolation.test.mjs.

Verification summary

Current security hold — not merge-ready. A fresh bounded pnpm audit --audit-level=high fails for locked picomatch 4.0.5 (GHSA-fc5q-39xc-vjpf). No validated compatible remedy is currently available. No dependency, audit-threshold, release-age or other security control was changed. Earlier passing implementation/hosted checks below do not establish current security readiness.

  • Exact final head: 1bc3d60a6ff7acd2589fd98d62d938a3112928c4; actual remote and PR head readback match.
  • Final full pnpm run verify: 7,084 tests passed, zero failures, plus build, typecheck, lint, formatting, privacy, context and suppression checks.
  • Normal pre-commit hooks passed: lint, formatting, gitleaks, Fallow and commitlint. Normal pre-push hooks passed: 863 affected unit tests and 1,267 Chromium cases; one existing non-Chromium-only case skipped and selected by hosted Firefox.
  • Independent Astra review of the full candidate at 4f4b08ef requested changes for one P2 interpolation finding. The owner addressed it with the guard and two red-then-green regressions; no additional review delegate was used for this small follow-up. This is not an Astra approval recommendation on the final head.
  • Hosted results are settled on this head: required fails because the HIGH dependency audit fails; the other six protected contexts pass. Existing release, queue and human holds remain unchanged.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Note

Synthetic action dogfood receipt. This report is the final deliberately failing fixture in the action contract suite. It proves that unproven evidence is rejected; it does not certify this pull request.

🗺️ StyleProof report

📊 View the side-by-side visual report →


Coverage, determinism, report/diff consistency, or Change Reach (changeReach: 'gate') evidence is incomplete — this is not a base recapture failure. Repair the named evidence in the report.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Note

Live StyleProof-on-StyleProof (advisory). This report is captured from the surfaces declared in styleproof.config.ts (example/demo). home@* carries matching productState {id, revision} (comparable / certifying path); the product-state acknowledgement file stays armed but empty so undeclared new pairs fail closed. fail-on-diff is false; the check is not part of hosted required CI. The synthetic Action contract suite remains action-dogfood.yml.

🗺️ StyleProof report

Nothing changed, so no report was uploaded. The verdict is in the run summary.


Advisory-only mode: no reviewable changes detected — the StyleProof dogfood check remains green.

@BenSheridanEdwards

Copy link
Copy Markdown
Owner Author

Tie-off 17 Nov 2026, 07:50 GMT Europe/London (Goji relaying Ben). All queued Opus GOs are cancelled; no review is started in this tie-off.

This PR (Fixes #1413) is green and CLEAN at 811f62f7. Next: on a fresh GO, Opus-review, then merge. Not merged here.

@BenSheridanEdwards

BenSheridanEdwards commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner Author

Independent Astra review found a P2 blocker on 811f62f7d3454e2f0eb645b85cf1ca8157add890: comment stripping treats // inside a CSS URL as a line comment and can hide a later global selector. For example:

.card { background: url("https://assets.example.invalid/a.png"); } h1 { font-size: 80px }

The exact-head classifier still returns scope, and selective remapping omits a non-importing surface. I am repairing token handling with regression evidence. This head is not merge-ready despite its green checks. No merge or release is authorized in this sweep.

The URL repair is delivered at 4f4b08ef3b80c43ef6d4d9a2d093b54774526e85 with 101 compiled checks, 7,082 full-verify tests and normal hooks passing. Independent Astra review found one remaining P2: SCSS selector interpolation can still inject a global selector. The owner is adding a conservative escape guard and two public-function regressions; both tests reproduce the old classifier and Home-only verdict. This intermediate head remains unready. No merge is authorized.

Source findings addressed at 1bc3d60a6ff7acd2589fd98d62d938a3112928c4. The URL repair and conservative interpolation escape guard now pass 103 compiled focused cases. Both new interpolation regressions failed against the prior compiled code. Final full verify passed 7,084 tests; normal hooks passed 863 affected unit tests and 1,267 Chromium cases (one existing non-Chromium-only skip). The owner fixed Astra's sole P2 finding without another delegate; no new independent approval is claimed. Hosted gates remain pending on this final head. No merge or human signoff was performed.

@BenSheridanEdwards BenSheridanEdwards changed the title fix(remap): classify CSS Modules with bare element selectors as all fix(remap): fail closed on global CSS Module selectors Nov 17, 2026
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.

Selective remap treats a CSS Module with bare element selectors as scoped

1 participant