Skip to content

test(ci): theme var guard accepts an inherited seam like --link-hover-color - #12611

Closed
astracat-bot[bot] wants to merge 1 commit into
mainfrom
codebunny/fix/test-ci-theme-var-guard-accepts-an-inherited-seam-like-link-hover-color-420c01
Closed

astracat-bot[bot] wants to merge 1 commit into
mainfrom
codebunny/fix/test-ci-theme-var-guard-accepts-an-inherited-seam-like-link-hover-color-420c01

Conversation

@astracat-bot

@astracat-bot astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

validation: ran pnpm storybook:build then node .github/scripts/theme-var-reachability.js --storybook-dir apps/storybook/dist: on the unchanged code it failed 2 of 2 runs with only Link --link-hover-color: nothing declares it; with this change it passed 2 of 2 runs, all 12 public component vars settable from a theme (Link --link-hover-color — .astryx-link sets it ( → 9987px)), and the other 11 vars resolve exactly as before.

CI impact: pr-a11y (audit and guards) keeps its runner class before and after: standard GitHub-hosted ubuntu-24.04-arm for pull requests and bot-triggered release checks, and the existing non-standard 2-core-ubuntu-arm for human-triggered release checks. Job-minutes per pull-request update before → after: expected unchanged (0 added job-minutes); runner-pool usage before → after: expected unchanged (0 added runner-minutes/day and 0 added average concurrent jobs); time to green before → after: expected unchanged (0 added minutes). This CI script change is not measured; workflow routing, runners, job count and scheduling are unchanged.

What failed

The release-check a11y guards job's theme var reachability guard failed on main from 3b4c199 (#12081):

✗ Link --link-hover-color: nothing declares it — no element in any Link story has a value (#5012)

Cause

#12081 documents --link-hover-color as a public Link var. Per the Link spec (component:Link FR11 and DEC-1, authority current), an accent link's hover reads var(--link-hover-color, <default mix>) and Link never sets the var, so a value set on an ancestor container reaches the link. That is by design: the var is unset by default.

The guard finds the "declaring" element as the topmost element whose computed style has a value for the var. A var that is read with a fallback and never declared has no value on any element until a container or a theme sets one, so the guard reported it as unread (#5012), although the compiled CSS reads it and a theme rule on .astryx-link does reach the link.

Declaring a default on the Link root instead would mask an ancestor's value and contradict DEC-1 (and the container case in Link.hoverColor.a11y.chromium.spec.ts), so the fix is in the guard.

Fix

.github/scripts/theme-var-reachability.js now recognises an inherited seam. When no story declares the var, it falls back to this check:

The fallback is used only after every story came back undeclared, so vars that some story declares follow the existing path unchanged.

Unsure

Another option was a new doc field that marks a var as an inherited seam explicitly, rather than detecting it from the page's CSS. That would change the doc schema, so I kept the change inside the guard. A maintainer may prefer the explicit marker.

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 18, 2026 9:17am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 18, 2026
@astracat-bot

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 18, 2026, 9:22 AM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b550d08

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the guard fix looks right, but the description is missing one required line.

  • Add a CI impact: line to the description, as AST-030 FR19 and CONTRIBUTING.md require for any change to a CI script: give the runner class of pr-a11y (audit and guards), job-minutes and runner-pool usage before and after, and time to green (all unchanged here).

Two optional hardening ideas are in the inline comments: the stylesheet read check matches longer var names by prefix, and the declaration check cannot see values written through a style prop. A maintainer can add ci:run-a11y to run the guard at this head before merge.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: the guard has failed on main since the Link doc listed the var. Verified from the code: no story or theme sets it, so the base probe prints the quoted line (theme-var-reachability.js:159-165, :279-282).
  • Claim: the earlier change documents --link-hover-color as a public Link var. Verified (Link.doc.mjs:20-29).
  • Claim: the Link spec's FR11 and DEC-1 are current and say Link reads the var with a fallback and never sets it. Verified (Link.spec.md:123, :223-233).
  • Claim: the guard treats the topmost element with a value as the declaring element. Verified (:159-165).
  • Claim: a default on the Link root would contradict DEC-1 and the hover-color spec's container case. Verified (DEC-1; Link.hoverColor.a11y.chromium.spec.ts:116).
  • Claim: the fallback requires the page CSS to read the var. Verified (:194).
  • Claim: the fallback rejects a var that any rule declares. Verified for stylesheet rules (:195); inline writes are not covered (inline comment).
  • Claim: the theme rule must reach a rendered target, or the guard fails as before. Verified (:196-200, :234, :279-291).
  • Claim: the fallback applies only after every story is undeclared, and declared vars keep the old path. Verified (:223, :232-234; themeSets matches the old probe).
  • Claim: a Storybook run fails before and passes after, across 12 public vars. Not reproduced here; the component docs list 12 public vars, and Link's is the only one no source declares.
  • Claim: the title. It matches the change.
  • File .github/scripts/theme-var-reachability.js: the description lacks the CI impact line (blocking), plus two non-blocking notes; consistent with the workflow step and its comment (ci.yml:3463-3472).

Automated review (maintainer link)

// A cross-origin sheet hides its rules; Core's CSS is same-origin.
}
}
if (!rules.some(text => text.includes(`var(${name}`))) return null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this also matches a longer var name (var(--link-hover-color-strong for --link-hover-color), so a documented var that nothing reads could pass. Matching var(${name}) or var(${name}, closes that. No current var name is a prefix of another.

}
}
if (!rules.some(text => text.includes(`var(${name}`))) return null;
if (rules.some(text => text.includes(`${name}:`))) return null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this sees stylesheet rules only. A var that a component writes through a style prop, in a state no story renders, would pass here and skip the #4530 inline-write check. No public var is written that way today.

cixzhang added a commit that referenced this pull request Nov 18, 2026
…-color (#12616)

test(ci): theme var guard accepts an inherited seam like --link-hover-color

Re-cut of #12611 by astracat-bot, byte-identical.

Co-authored-by: astracat-bot[bot] <astracat-bot[bot]@users.noreply.github.com>
@astracat-bot

astracat-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Landed on main as #12616 (re-cut by @cixzhang). Thanks!

@astracat-bot astracat-bot Bot closed this Nov 18, 2026
@github-actions
github-actions Bot deleted the codebunny/fix/test-ci-theme-var-guard-accepts-an-inherited-seam-like-link-hover-color-420c01 branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — b550d084 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants