Skip to content

test(a11y): reusable button-pattern accessibility contract, bound to five components - #6131

Merged
cixzhang merged 17 commits into
mainfrom
a11y-button-contract-20260907
Sep 7, 2026
Merged

cixzhang merged 17 commits into
mainfrom
a11y-button-contract-20260907

Conversation

@cixzhang

@cixzhang cixzhang commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Who this is for

Anyone who reaches a control with a keyboard, a screen reader, or speech input.
A button is the most common thing on a page, and the ways it breaks are boringly
consistent: a div a screen reader never announces, an icon with no name, a
control that answers Enter but not Space, an anchor doing a button's job and
promising navigation it will not perform, a disabled control that never says it
is disabled.

This adds the second reusable accessibility spec-test pattern — the WAI-ARIA APG
button pattern — and binds
five components to it. Every component that adopts the pattern is held to the
same twelve outcomes, so "is this button accessible" stops being a
per-component judgement.

It found two component defects, recorded as six known-failure records —
one per expectation each defect breaks, because a record names exactly one
outcome. None are fixed here; both are linked to public issues.

The expectations

Every expectation names one user outcome, the exact clause it comes from, the
evidence layer that can honestly observe it, and whether it gates. An
expectation only runs against a state it can apply to; otherwise the run reports
not-applicable with the reason.

Expectation User outcome Source Applies when Evidence layer Enforcement
button.role.exposed Announced as a button, so the user knows it acts here rather than taking them elsewhere. WCAG 4.1.2 (A) · APG "The button has role of button." always accessibility tree required
button.name.exposed It has a name, so the user knows what pressing it will do. WCAG 4.1.2 (A) · APG accessible label always accessibility tree required
button.name.matches-visible-label Saying the visible label reaches the control. WCAG 2.5.3 Label in Name (A) always — both sides observed, never declared accessibility tree + real browser required
button.description.resolvable Every piece of supporting text it points at exists. WCAG 1.3.1 (A) · APG aria-describedby the state renders supporting text DOM required
button.description.exposed That text reaches the user as the control's description. WCAG 4.1.2 (A) the state renders supporting text accessibility tree required
button.unavailable.exposed A button whose action is unavailable says so. WCAG 4.1.2 (A) · APG "When the action associated with a button is unavailable, the button has aria-disabled set to true." the state is unavailable accessibility tree required
button.action.runs-on-pointer Clicking it runs its action. Astryx family:buttons FR2 · APG role the state is operable real browser required
button.action.runs-on-enter Enter runs its action. WCAG 2.1.1 Keyboard (A) · APG "Enter: Activates the button." operable and focusable real browser required
button.action.runs-on-space Space runs it too. WCAG 2.1.1 Keyboard (A) · APG "Space: Activates the button." operable and focusable real browser required
button.action.survives-an-aborted-press A press slid off and released elsewhere runs nothing. WCAG 2.5.2 Pointer Cancellation (A) the state is operable real browser required
button.focus.reachable-and-escapable Tab reaches it, Tab leaves it. WCAG 2.1.1 (A) · 2.1.2 No Keyboard Trap (A) the state is focusable real browser required
button.unavailable.inert An unavailable button runs nothing on click, Enter, or Space. Astryx family:buttons FR3 · APG unavailable the state is unavailable real browser required

Every expectation gates, and two of them do so on an Astryx record rather than
on WCAG.
WCAG 4.1.2 governs how a control is exposed — name, role, value —
not what it does when pressed, so neither "clicking runs the action" nor "an
unavailable button declines to act" is required by it. What requires them is
docs/families/buttons.md, authority: current:

  • FR2 — "A momentary or persistent action renders an operable button with
    keyboard activation, focus-visible feedback, and type="button"…"
    — adopts
    operability and keyboard activation as two distinct properties, so a control
    that does nothing when clicked fails the first. button.action.runs-on-pointer
    gates on it.
  • FR3 — "A disabled member MUST NOT invoke its callback or Action." —
    button.unavailable.inert gates on it. Quoted as the MUST sentence alone: the
    sentence after it is a MAY about focusable aria-disabled, and splicing them
    would quote a requirement the record does not make.

Both are cited Astryx-primary, with 4.1.2 listed after as the outcome they
support. Under AST-020 FR9 that is the honest ordering: leading with 4.1.2 would
buy the gate with a citation that does not carry the claim.

Two more expectations survived review by being deleted. An earlier revision had a busy.exposed advisory citing WCAG
4.1.2 while its own reasoning said 4.1.2 does not cover a pending action, and a
busy.keeps-focus gate citing 3.2.2 On Input. 3.2.2 does not reach a button at
all — "checking a checkbox, entering text into a text field, or changing the
selected option in a list control changes its setting, but activating a link
or a button does not
"
— and a button has no setting. Both are gone. The
outcome the second was reaching for, a busy button a keyboard user can still get
back to, is already owned by focus.reachable-and-escapable on 2.1.1, which
fails for exactly the same states. Button's own suite keeps its aria-busy test.

Why a button needs an activation counter. A switch says whether it is on, so
"pressing it worked" is readable from the control. A button's action leaves no
trace on the button at all. The contract therefore asks the binding how many
times the action ran, and a binding that cannot answer fails loudly rather than
passing quietly.

What it binds to

Component States
Button text label · icon-only · composed label (children + separate name) · disabled · disabled with tooltip (focusable, so the reason stays reachable) · loading
IconButton default · disabled · loading
ClickableCard action card · disabled
SideNavCollapseButton icon-only · labelled
ChatSendButton send · disabled · Stop

Sixteen states, each with a checked-in story the browser lane drives, so any
failure has a URL a person can open. Each story counts its own activations and
shows the count on screen — the same fact the test reads.

What is deliberately excluded

Excluded Why
ToggleButton (aria-pressed) The APG treats a toggle as its own thing, with a state and a label-stability rule a command button does not have. Separate pattern.
Button or ClickableCard given href Renders an anchor and navigates. The APG's own note: "the types of actions performed by buttons are distinctly different from the function of a link".

An exclusion is part of the inventory, not an omission from it, and each lane
checks it at the layer it can honestly reach: jsdom asserts the DOM presents
link semantics and no button, Chromium asserts the engine computes the role as
link. So an exclusion cannot quietly become wrong.

Known failures — two defects, six records, none fixed here

Each record is one expectation, one binding, one state, one issue — a defect
breaking three outcomes gets three records, because a record naming two could be
satisfied by half a fix. A known failure runs and must still fail: the day a component is fixed, the record stops
matching and the run reports unexpected-pass, which gates.

Expectation Binding · state Issue
button.focus.reachable-and-escapable Button · loading #4871
button.focus.reachable-and-escapable IconButton · loading #4871
button.action.runs-on-pointer ClickableCard · action card #6132
button.unavailable.inert Button · loading #4871
button.unavailable.inert IconButton · loading #4871
button.action.survives-an-aborted-press ClickableCard · action card #6132

The busy gap. Button sets the native disabled attribute while a
clickAction is pending, and a natively disabled element cannot hold focus. A
keyboard user who presses Save is dropped to the top of the document the moment
the action starts, and the button leaves the tab sequence, so they cannot get
back to it. IconButton inherits it exactly. Already tracked, with two fixes open.

The card gap (#6132, filed
by this work). ClickableCard puts the button role and name on a 1×1 hidden
control that the card's own content paints over, so a pointer aimed at the
element that is the button never reaches it. A sighted mouse user is
unaffected — they click the card surface. Anyone whose tooling acts on the
accessible object is not.

Adjacent finding, not filed as a defect

SideNavCollapseButton documents label as "renders as a text button with
chevron", but the component passes isIconOnly unconditionally, so a label
never becomes visible text — it reaches the accessible name only. No user is
harmed (the control is named either way), so the inventory records what the
component actually does and this note flags the documentation mismatch for its
owner rather than filing a defect.

Mutation proof

Every expectation is proven twice: green against a conforming fixture, red
against a fixture that removes its outcome, over hand-written HTML with no
Astryx in it — what is under test there is whether the contract can actually
fail. Both lanes read the same fixtures, so each proof runs at every layer that
can see it; since only two expectations are DOM-layer, most of these are proven
in Chromium alone and reported unrun in jsdom rather than skipped.

The fixture does this and this expectation must fail
no role at all role.exposed
an anchor doing a button's job role.exposed
icon-only with nothing to name it name.exposed
an aria-label that replaces the readable words name.matches-visible-label
aria-describedby pointing at nothing description.resolvable
a description element that renders no text description.exposed
does nothing when pressed action.runs-on-pointer, runs-on-enter, runs-on-space
answers a pointer but not the keyboard runs-on-enter, runs-on-space
answers Enter but not Space runs-on-space
answers Space but not Enter runs-on-enter
acts on the way down action.survives-an-aborted-press
not in the tab sequence focus.reachable-and-escapable
swallows the Tab that would leave focus.reachable-and-escapable
refuses to act without saying it is unavailable unavailable.exposed
marked unavailable and acts anyway unavailable.inert
marked unavailable, refuses a click but still runs on Enter or Space unavailable.inert
declared focusable so its reason stays reachable, then cannot take focus unavailable.inert
goes natively disabled while busy focus.reachable-and-escapable

Completeness

Every dimension of the AST-020 checklist is either carried by an expectation or
exempted with a named owner and verification method. Silence is not an
exemption, and neither is "not applicable" — the contract refuses both.
unansweredDimensions returns [], asserted by the pattern's own suite.

Encoded here: 1.3.1, 2.1.1, 2.1.2, 2.5.2, 2.5.3, 4.1.2, and the APG interaction
requirements.

Exempted with owners: 1.1.1, 1.3.2, 1.4.1, 1.4.3, 1.4.11, 2.4.2, 2.4.3, 2.4.4,
2.4.6 (remainder-only — a name exists is encoded; whether it describes the
action well is a judgement about wording), 2.4.7, 2.4.11, 2.5.8, 3.1.1, 3.2.2,
3.2.4, 3.3.1, 3.3.2, 4.1.3, forced-colors, reduced-motion, and
at-facing-strings. Each names who owns it and how it is verified.

Evidence layers — AST-009 and AST-013

No claim here is about what a screen reader says. Nothing in this contract
triggers a real assistive technology, so nothing reports what one would
announce. What the expectations observe is what the browser computes — role,
name, description, disabled — and what a real engine does when a pointer or a
key arrives. Under AST-009 those are accessibility-tree and real-browser claims,
not real-AT claims, and the report never upgrades one into the other.

Per AST-013, every browser claim is made in a browser: Chromium, over checked-in
stories. jsdom runs the DOM-layer checks and reports the rest as
unrun — naming the layers it could not see — rather than pretending markup
proves them. jsdom cannot compute an accessibility tree, resolve a real tab
sequence, or turn a key press into an activation, and reporting those as passes
because the attributes look right is exactly the substitution the layer rules
exist to prevent.

Local tests retained

Nothing was removed from any component's own suite. Callback payloads, icon
resolution from the registry, composer wiring, elevation, width, end content and
styling all stay where they are: they are each component's own contract, not the
button pattern's.

Three harness bugs the bindings found

Binding real components to the shared harness exposed three defects in it, all
now fixed and each a case Astryx actually hits:

  • Visible text counted hidden children. It read textContent, so a button's
    visually-hidden live region made a loading button "render" the word Loading
    that nobody can see. It now walks the tree and drops subtrees that do not paint.
  • A display: contents wrapper read as invisible. It generates no box, so
    the old rule judged it hidden — and Astryx wraps every button's content in
    one, so the harness found no label at all. It is now treated as transparent:
    each child is judged on its own.
  • Fully transparent text read as readable. Astryx dims a button's label with
    color: transparent while it waits on an action. Text that cannot be read is
    not visible text.

Plus: a pointer that cannot reach a control now fails in two seconds saying
why
, instead of hanging until the test times out saying nothing. That is what
turned the ClickableCard gap from a mystery timeout into a legible finding.

Results

internal/a11y-spec           105 tests   jsdom + node   pass
Button family + Switch       181 tests   jsdom          pass
accessibility contracts       93 tests   Chromium       pass

Both typechecks, pnpm check:repo, and lint are clean. No component behaviour
changed
— no file under a component's own source was touched.

Self-review

Two reviewers ran against this exact head, one on the repository's own standards
plus the Fowler smell baseline, one on AST-020/021/009/013 and the exact public
sources. Every finding is resolved; the substantive ones changed the work rather
than the prose:

  • the two deleted expectations above;
  • 3.3.2 was claimed as encoded by a name check and is now exempted with an owner;
  • runs-on-pointer cited 4.1.2 without owning its dimension;
  • unavailable.inert declared an evidence layer it never read, and returned
    silently for states no keyboard can reach — it now says why, and a new fixture
    proves the keyboard half can fail;
  • the WCAG 2.5.3 word comparison existed twice, once per pattern, with one copy
    exported — now one module, both patterns on it;
  • an aborted press against a control no pointer can land on was reporting a
    pass. That was the vacuous green this whole design exists to prevent; it now
    fails, which is how ClickableCard's defect gained its second record;
  • transparent text was judged on ancestors rather than on the node owning the
    text, so a transparent wrapper around a re-coloured child erased readable words.

A second standards round found six more, all resolved: unavailable.inert
returned silently when a state it had just been told is focusable could not take
focus — a pass from the check meant to catch exactly that; the known-failure
header cited the wrong spec clause (AST-020 FR12 is independent review; the
rules are AST-021 FR8–FR10); busy still sat in the facts after both
expectations reading it were deleted, along with two now-dead source constants;
the sixteen-case render switch became one typed map that the jsdom lane and the
Storybook stories both render through; and the Playwright timeout is matched by
its own error type rather than a regex over prose.

The typed map is worth one more line, because the first attempt at it did not
work. A : ReadonlyArray<ButtonBindingState> annotation widens every id to
string, which quietly widens the map's key type to Record<string, …> — so a
missing rendering and an invented one both compiled. It is
as const satisfies ReadonlyArray<ButtonBindingState> now, and both directions
were verified to fail the build.

A third spec round corrected four more things. The loading states declared
themselves available while the components natively disable them, so the
unavailable expectations never ran — the facts are honest now, which ADDED
coverage and produced two more known-failure records rather than hiding
anything. A new browser check compares every applicability fact against what the
page exposes, because those facts can switch a required expectation off: a
mismatch is a stale inventory unless the row lists it as declared-but-not-
delivered with a record behind it, and listing a fact that actually matches
fails too. Two expectations were reclassified under FR9 and then, on a closer
reading of the family record, reclassified back to required against its exact
clauses — see the enforcement note above. And two local
Button-family tests were narrowed: they asserted role and accessible name, which
the shared contract proves in a real engine, and now keep only what each
component owns — that label renders as readable text, and that isIconOnly
routes it to aria-label with the icon still present.

CI integration

Three gates failed on an earlier head and are fixed at this one, each from a
real cause rather than a flake:

  • Lint — the ClickableCard fixtures rendered a raw <p>, which the repo
    bans in component source (a <p> cannot contain block children, so nested
    block content triggers hydration mismatches). Now <div>. Local lint showed
    these as warnings; CI runs ASTRYX_STRICT_LINT=1, where they are errors.
  • Stable visual regression — the gate could not resolve which package owns
    a11y-button-pattern--*, and threw before photographing anything. These
    stories declare no component, and moving them to a relative import (the fix
    for the false @astryxdesign/core/…/__tests__ specifier) removed the last
    import the gate could read ownership from. They are now tagged no-visual —
    the gate's supported explicit exclusion — because they exist to be driven by
    the contract rather than photographed, and several render states no product
    ships, so a baseline frame would be a picture nobody reviews. This costs no
    coverage: every one of them is still driven in a real browser by the Chromium
    contract lane. No baselines added, and no existing story's treatment changed.
  • pr-rtl — narrowing the two duplicate local tests marks Button and
    IconButton as modified, which scopes the RTL audit to them, and neither has
    ever had RTL coverage. The audit calls that a finding, so both now carry
    verified-not-applicable entries whose reasons are evidence, not assertion:
    the detectors ran over all 25 Button and IconButton stories with zero not-RTL
    findings, and the source uses logical properties throughout, with the only
    positioned affordance (the disabled-reason tooltip) on the block axis.
    Reproduced locally before and after — 2 gaps to 0, exit 0.

Fourteen expectations over the adopted pattern: the control is reported as a
button and not a link, it is named, its description reaches the user, a pointer
runs its action, BOTH Enter and Space run it, a press slid off is taken back,
focus reaches it and leaves it, and a button that cannot act says so and stays
inert. Each one is proven twice — green against a conforming fixture, red
against a fixture that removes its outcome — at jsdom and in real Chromium.

Two seams the switch pattern did not need:
- a button's action leaves no trace on the button, so the contract asks the
  BINDING how many times the action ran rather than reading the control. A
  pattern that needs it and a binding that does not supply it is a loud fault,
  never a quiet pass;
- Enter joins Space as a key an expectation can send.

Toggle buttons (aria-pressed) and anything that adopts link semantics are out
of scope, per the APG's own note that the two functions are distinct.
Button, IconButton, ClickableCard, SideNavCollapseButton, and ChatSendButton all
adopt the same contract, over sixteen states that can change what the pattern
promises — text and icon-only names, a composed label, disabled, disabled with a
tooltip keeping it focusable, loading, and the send control's Stop face.

Two parts are excluded rather than omitted: a Button or ClickableCard given href
renders an anchor, and the APG is explicit that a link is a different function.
The suite asserts each really does present link semantics, so an exclusion
cannot quietly become wrong.

Each state has a checked-in story that counts its own activations, because a
button leaves no trace of having been pressed and a browser claim needs a
reproduction path a person can open.
@vercel

vercel Bot commented Sep 7, 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 Sep 7, 2026 11:18pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 7, 2026
github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Button (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 517 -
Complexity N/A Very High (66) -
IconButton (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 17 -
Complexity N/A Low (1) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: No visual change across 2 compared shot(s).


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Five real gaps, all recorded and linked, none patched:

- Button and IconButton go natively DISABLED while an action is pending, so a
  keyboard user who presses Save is dropped to the top of the document and
  cannot tab back. Four records (two components x two broken outcomes) against
  the existing public issue, which already has two fixes open;
- ClickableCard puts the button role and name on a 1x1 hidden control the card's
  own content paints over, so a pointer aimed at the element that IS the button
  never reaches it. New public issue; a mouse user is unaffected, anyone whose
  tooling acts on the accessible object is not.

Three harness corrections the bindings forced, each a real bug:
- visible text now walks the tree and drops subtrees that do not paint. It was
  counting an sr-only live region, so a loading button 'rendered' the word
  Loading nobody can see;
- a display:contents wrapper is transparent rather than invisible. Astryx wraps
  every button's content in one, so the old rule found no label at all;
- fully transparent text is not readable text. Astryx dims a button's label that
  way while it waits, and the old rule called it visible.

And a pointer that cannot reach a control now fails in two seconds saying why,
instead of hanging until the test times out saying nothing.
Self-review found both, and the WCAG text settles both outright.

- button.busy.keeps-focus cited 3.2.2 On Input, which does not reach a button at
  all: 'checking a checkbox, entering text into a text field, or changing the
  selected option in a list control changes its setting, but activating a link
  or a button does not'. A button has no setting. The outcome it was reaching
  for — a busy button a keyboard user can still get back to — is already owned
  by focus.reachable-and-escapable on 2.1.1, which fails for exactly the same
  states. Two known-failure records collapse into two better ones;
- button.busy.exposed cited 4.1.2 while its own reasoning said 4.1.2 does not
  cover a pending action. Same contradiction the switch pattern already deleted
  a busy expectation for; Button's own suite keeps its aria-busy test.

Also from review:
- 3.3.2 is about what a form tells someone to enter, not whether a control has a
  name. Exempted, with the owner named, instead of claimed;
- runs-on-pointer now owns the 4.1.2 dimension it cites;
- unavailable.inert declared a tree layer it never reads, and returned silently
  for states no keyboard can reach — now it says why, and a new fixture proves
  the keyboard half can fail;
- the 2.5.3 word comparison was implemented twice, once per pattern, with one
  copy exported. One rule, one module, both patterns on it;
- an aborted press on a control no pointer can land on was reporting a serene
  pass. It now fails, saying so — which is how ClickableCard's defect gained its
  second record rather than hiding behind a green;
- transparent text was judged on ancestors, so a transparent wrapper around a
  re-coloured child erased readable words. Judged on the node that owns the text;
- the package README documents the second pattern, and the story header names
  the attribute the story actually writes.
… as a pass

Standards review, six findings:

- unavailable.inert returned silently when a state it had just been told is
  focusable could not take focus — reporting a pass for the check meant to catch
  exactly that. It now fails, with a fixture that is natively disabled while
  declaring itself focusable to prove it (tabindex=-1 would not: it leaves an
  element programmatically focusable, so focus() still succeeds);
- the known-failure header cited AST-020 FR12, which is about independent
  review. The rules it meant are AST-021 FR8-FR10, and FR9 is the exact gate.
  Audited every other AST citation in the package and the bindings: no other
  drift;
- busy left ButtonStateFacts. Both expectations that read it are gone, so
  keeping it implied it still selected something;
- WCAG_3_2_2 and APG_FOCUS_REMAINS went with them;
- the 16-case render switch is gone. Each state's rendering now lives in one
  map, keyed by an id union so a state without one does not compile, and the
  jsdom lane and the Storybook story both render through it — three places to
  edit became one. The inventory stays data-only: the browser lane runs under
  plain Node with no StyleX transform, so a component import there would break
  it before it started;
- the Playwright timeout is matched by its own error type rather than a regex
  over prose that any release can reword, and runs-on-pointer dropped the
  wcagOutcome it should never have carried — that field is for an APG-primary
  expectation, and its primary source is 4.1.2.
…hat survived

Self-review caught the last round claiming two things that were not true.

- ButtonStateId was 'string', not a union. A ': ReadonlyArray<ButtonBindingState>'
  annotation widens every literal id, and the render map's key type with it, so
  Record<ButtonStateId, …> was Record<string, …> — a missing rendering AND an
  invented one both compiled, and the comments promising otherwise were wrong.
  'as const satisfies' keeps the literals and still checks every row; both
  directions were verified to fail the build;
- WCAG_3_2_2 and APG_FOCUS_REMAINS were still in the file. The commit that said
  they went with their expectations did not remove them — eslint had been
  flagging both as unused since.

Also: the jsdom binding's header still claimed to import five components it no
longer touches, the stories cited a .tsx inventory that is now .ts, and the SYNC
note asked for a rendering the compiler now demands by itself.
- ButtonA11y.stories.tsx reached the shared inventory through
  '@astryxdesign/core/Button/__tests__/…'. That specifier says these are
  published entry points; they are not, and never will be — __tests__ is
  excluded from the build and ships in no dist. It resolved only because
  Storybook aliases the whole package to source. A relative path says what it
  actually is, and is how other stories already reach package internals;
- the SYNC notes claimed a jsdom inventory test catches a missing story export.
  No such test exists. What catches it is the Chromium binding navigating to the
  row's storyId, and the notes now say so — alongside the half that IS compile-
  time checked, so a reader can tell which is which.
The same correction as the story file, on the file the previous commit's script
aborted before reaching — it claimed a jsdom inventory test catches a missing
story export, and no such test exists. What catches it is the Chromium binding
navigating to each row's storyId, verified by pointing a row at a story that
does not exist and watching that lane fail.
The facts doc still listed busy among the flags that select expectations. It was
removed from ButtonStateFacts two commits ago, when both expectations reading it
were deleted, so the comment was describing a field a reader would go looking
for and not find.
… gate

- the loading states declared themselves available while both components
  natively disable them, so every unavailable expectation was not-applicable and
  never ran. Correcting the facts ADDS coverage: unavailable.exposed now passes
  for both, unavailable.inert now fails for both, and those are two more
  known-failure records against the same open issue. focusable stays declared
  true on purpose — it is what a busy button is SUPPOSED to be, and recording
  what the component does instead is how a contract quietly stops noticing a
  defect. A new declaredNotDelivered field says which declarations are
  aspirational, and which record owns each;
- a new browser check compares every applicability fact against the page. Those
  facts can switch a required expectation off, so a wrong one is not cosmetic; a
  mismatch is a stale inventory unless the row excuses it, and an excuse for a
  fact that actually matches fails too. Verified by flipping a fact and watching
  it fail;
- runs-on-pointer and unavailable.inert are advisory. 4.1.2 governs how a
  control is EXPOSED, not what it does when pressed, so both are APG-only, and
  FR9 gates an APG outcome only when a current Astryx record adopts it. Neither
  citation is reordered to buy required. Their neighbours still gate: the
  keyboard equivalents on 2.1.1, the exposure half on 4.1.2, cancellation on
  2.5.2;
- two local tests asserted role and accessible name, which the shared contract
  proves in a real engine. Narrowed to what each component owns: label renders
  as readable text, isIconOnly routes it to aria-label with the icon present.
Self-review found the demotion wrong. docs/families/buttons.md is
authority: current and its FR3 says 'A disabled member MUST NOT invoke its
callback or Action... while still blocking activation' — the expectation,
verbatim. Under AST-020 FR9 that is a current Astryx record adopting the
outcome, so button.unavailable.inert is required again, cited Astryx-primary.
runs-on-pointer stays advisory, but for the right reason: the record that adopts
activation, FR2, says 'keyboard activation', so the pointer half is genuinely
unadopted rather than unmentioned.

Three more from the same review:
- the fact-truth check read two of the four facts. It now reads described too,
  which gates two required expectations, and says why operable has no
  counterpart: observing it would mean running the expectations the check exists
  to protect;
- it measured focusability with element.focus(), which succeeds on a
  tabindex=-1 control no Tab will ever reach — so a real gap read as a match. It
  now Tabs, which is what the expectations mean by focusable;
- declaredNotDelivered named a fact but no record, so an unowned exception
  passed. Each entry now names the known-failure record that owns it, and an
  entry with no matching record fails.
…nter gate

FR2 reads 'an operable button with keyboard activation' — operability and
keyboard activation as two properties, not one — so a control that does nothing
when clicked fails the first of them. button.action.runs-on-pointer gates on
that record rather than reporting; the ClickableCard record it holds is now a
required failure.

The source shape was doing violence to the citation: a 113-character quote spliced
across a MUST and a MAY sentence, stuffed into the id, pointing at a repo-relative
path a reviewer outside the checkout cannot open. AstryxRecord now carries id,
clause, requirement, and url separately — the same discipline the APG sources
already follow — and definePattern refuses a record missing any of them, a
non-public URL, or a branch URL whose bytes move underneath the quote. Six new
tests, including the citation label.

FR3 is quoted as its MUST sentence alone. The sentence after it is a MAY about
focusable aria-disabled, and splicing them quoted a requirement the record does
not make. Both clauses link to the commit that wrote them.
Self-review of the last commit, and the PR body was still arguing the position
the code had already left: it claimed runs-on-pointer reports because FR2 is
keyboard-specific, next to the paragraph explaining why it gates. It also still
carried the FR3 splice this branch removed from source. Both gone, and the test
counts reconciled.

The URL rule was a list of ways to be wrong, which let through everything not on
the list: /blob/HEAD/, /blob/develop/, a tag, /raw/, refs/heads/main, a short
sha, and any https host at all — including an internal one, which must never
appear in this repository. It is now one shape, github.com/<org>/<repo>/blob/
<full sha>/<path>, with eleven cases proving what it refuses.

Also: the cited line ranges stop where each quote stops, so FR3's no longer
highlights the MAY sentence the citation deliberately excludes; the FR2 comment
says plainly that reading it as adopting POINTER operability is an
interpretation, and what to change if the family owner reads it more narrowly;
and the README documents the citation rules, since they now throw.
The FR3 comment said the cited range does not highlight the MAY sentence. It
does: the MUST ends partway through L114 and the MAY begins on the same line, so
a line anchor cannot exclude it. FR2's range overruns the same way.

Both comments now say what is true — the range shows the lines the sentence
spans, and `requirement` is the exact text the expectation rests on. The
citation itself was never wrong; only the claim about it was.
Two commits, no conflicts, no file overlap with this branch's 22.

- #6120 gives AvatarGroupOverflow its own audit coverage and story;
- #6097 simplifies Stepper's collapse and context APIs.

Stepper renders an IconButton, which this branch binds to the button pattern, so
that coupling was checked rather than assumed: the incoming diff does not touch
the IconButton call, and nothing here changes component behaviour. Neither
commit touches internal/a11y-spec, the a11y stories, the workflows, or the
Playwright config.
@cixzhang
cixzhang marked this pull request as ready for review September 7, 2026 22:27
github-actions Bot added a commit that referenced this pull request Sep 7, 2026
Lint (strict): the ClickableCard fixtures rendered <p>Billing</p>, and the repo
bans a raw <p> in component source — a <p> cannot contain block children, so
nested block content triggers hydration mismatches. These are under
packages/core/src, so the rule applies. Now <div>. Local lint had been showing
them as warnings; CI runs ASTRYX_STRICT_LINT=1, where they are errors.

Stable visual regression: 'Story a11y-button-pattern--button-text has ambiguous
package ownership'. The gate resolves a story's owning package from its
component path, then its @astryxdesign imports, then its title. These stories
declare no component, and switching them to a relative import — the fix for the
false package-specifier finding — removed the last @astryxdesign import the gate
could read. 'a11y/Button pattern' names no package, so ownership was
unresolvable and the whole gate threw before photographing anything.

They are tagged no-visual, which the visual gate's own README prescribes for
audit-only fixtures. They exist to be driven by the contract, and several render
states no product ships, so a baseline frame would be a picture nobody reviews.
Verified: the gate now reads all 1895 stories and none of mine are in scope.

pr-rtl: narrowing the two duplicate local tests marked Button and IconButton
modified, which scopes the RTL audit to them — and neither has ever had RTL
coverage, so both came back as gaps. Not a false alarm: the audit calls a gap a
finding. Both now carry verified-not-applicable entries, and the reasons are
evidence rather than assertion — the detectors ran over all 25 stories with zero
not-RTL findings, and the source uses logical properties throughout. Reproduced
locally before and after: 2 gap -> 0 gap, exit 0.
Writing the file back through json.dumps(ensure_ascii=False) re-encoded four
reason strings that have nothing to do with this PR — Collapsible, ToggleButton,
Spinner, Text — from their \u2014 escapes to literal em-dashes. Same bytes to a
reader, pure noise to a reviewer, and it put four unrelated components in the
blame for a Button change. Restored from origin/main and the two new entries
appended in the file's own escaping style; the diff is now additions only.

Also: the no-visual justification said the README prescribes that tag for
audit-only fixtures. It does not — it says such fixtures take no visual tag, and
describes no-visual as excluding an unstable story from capture. The tag is
still the right call and the supported explicit exclusion, so the comment and
the PR body now say that instead, and note what makes it cost nothing: every one
of these stories is still driven in a real browser by the contract lane.
github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@cixzhang
cixzhang merged commit 5967c07 into main Sep 7, 2026
27 checks passed
@github-actions
github-actions Bot deleted the a11y-button-contract-20260907 branch September 8, 2026 06:22
sangwook-dev added a commit to sangwook-dev/astryx that referenced this pull request Sep 10, 2026
Dropping the hoisted layout removes the flat root copy that three
resolutions quietly relied on. Each landed on main after this branch's
previous rebase, so CI met them for the first time here.

- packages/core used @heroicons/react in its Button accessibility
  fixtures without declaring it (meta#6131). Storybook's typecheck and the
  Button a11y suite could not resolve it.
- build.packed-old-core.test.mjs staged the packed CLI's runtime
  dependencies from the repo root, where only a hoisted node_modules puts
  a package's own dependencies (meta#5543).
- core-interception's CommonJS probe reached a core through NODE_PATH,
  which is where pnpm's isolated layout exposes every package and where
  Vitest points it. Wrapping that core fails on a require(esm) namespace,
  and the coverage gap it then reported rejected every theme whose
  lineage was unobserved (meta#5543).

doctor's findInstalledPackage moves to foundation/fs/paths.mjs and is now
the single chain walk all three share. It answers only from the caller's
own node_modules, never from the ambient environment.
sangwook-dev added a commit to sangwook-dev/astryx that referenced this pull request Sep 10, 2026
Dropping the hoisted layout removes the flat root copy that three
resolutions quietly relied on. Each landed on main after this branch's
previous rebase, so CI met them for the first time here.

- packages/core used @heroicons/react in its Button accessibility
  fixtures without declaring it (meta#6131). Storybook's typecheck and the
  Button a11y suite could not resolve it.
- build.packed-old-core.test.mjs staged the packed CLI's runtime
  dependencies from the repo root, where only a hoisted node_modules puts
  a package's own dependencies (meta#5543).
- core-interception's CommonJS probe reached a core through NODE_PATH,
  which is where pnpm's isolated layout exposes every package and where
  Vitest points it. Wrapping that core fails on a require(esm) namespace,
  and the coverage gap it then reported rejected every theme whose
  lineage was unobserved (meta#5543).

doctor's findInstalledPackage moves to foundation/fs/paths.mjs and is now
the single chain walk all three share. It answers only from the caller's
own node_modules, never from the ambient environment.
sangwook-dev added a commit to sangwook-dev/astryx that referenced this pull request Sep 11, 2026
Dropping the hoisted layout removes the flat root copy that three
resolutions quietly relied on. Each landed on main after this branch's
previous rebase, so CI met them for the first time here.

- packages/core used @heroicons/react in its Button accessibility
  fixtures without declaring it (meta#6131). Storybook's typecheck and the
  Button a11y suite could not resolve it.
- build.packed-old-core.test.mjs staged the packed CLI's runtime
  dependencies from the repo root, where only a hoisted node_modules puts
  a package's own dependencies (meta#5543).
- core-interception's CommonJS probe reached a core through NODE_PATH,
  which is where pnpm's isolated layout exposes every package and where
  Vitest points it. Wrapping that core fails on a require(esm) namespace,
  and the coverage gap it then reported rejected every theme whose
  lineage was unobserved (meta#5543).

doctor's findInstalledPackage moves to foundation/fs/paths.mjs and is now
the single chain walk all three share. It answers only from the caller's
own node_modules, never from the ambient environment.
sangwook-dev added a commit to sangwook-dev/astryx that referenced this pull request Sep 13, 2026
Dropping the hoisted layout removes the flat root copy that three
resolutions quietly relied on. Each landed on main after this branch's
previous rebase, so CI met them for the first time here.

- packages/core used @heroicons/react in its Button accessibility
  fixtures without declaring it (meta#6131). Storybook's typecheck and the
  Button a11y suite could not resolve it.
- build.packed-old-core.test.mjs staged the packed CLI's runtime
  dependencies from the repo root, where only a hoisted node_modules puts
  a package's own dependencies (meta#5543).
- core-interception's CommonJS probe reached a core through NODE_PATH,
  which is where pnpm's isolated layout exposes every package and where
  Vitest points it. Wrapping that core fails on a require(esm) namespace,
  and the coverage gap it then reported rejected every theme whose
  lineage was unobserved (meta#5543).

doctor's findInstalledPackage moves to foundation/fs/paths.mjs and is now
the single chain walk all three share. It answers only from the caller's
own node_modules, never from the ambient environment.
cixzhang pushed a commit that referenced this pull request Sep 14, 2026
…rts (#5327)

* chore(deps): make node_modules strict, declare what each package imports

Drops `nodeLinker: hoisted` and `shamefullyHoist: true`, both inherited
verbatim from the pre-pnpm-11 .npmrc (#3700). nodeLinker was annotated there
as pnpm's default, which it is not -- the default is `isolated` -- and pairing
it with shamefullyHoist is pnpm/pnpm#6620. shamefullyHoist is
`publicHoistPattern: '*'`, which let eleven packages import modules they never
declared; all eleven are now declared, at the versions the workspace already
resolved. The Babel toolchain and Testing Library move into the catalog, each
having been duplicated across 4-6 packages.

Consolidating them surfaced an incoherent Babel pin: Dependabot had raised
`@babel/cli` (#4067) and `@babel/preset-react` (#3839) to 8.x on their own
while `@babel/core` and `@babel/preset-typescript` stayed on 7.x, and the 8.x
releases peer on `@babel/core: ^8.0.0` -- a set no single core version can
satisfy. All four now sit on ^7.29.7, matching the core that actually runs;
`pnpm peers check` drops from 4 unmet peers to 2 unrelated ones. Moving to
Babel 8 is a migration of its own.

Also fixes a latent `astryx doctor` bug the linker change exposed:
checkPeerDeps resolved peers with `require.resolve(name, {paths: [cwd]})`, but
Node folds NODE_PATH in regardless, so a peer merely reachable from the ambient
environment read as installed and doctor stayed silent about a missing one. It
now walks the project's own node_modules and reads package.json off disk, so
every peer gets range-checked. The existing test caught this unmodified.

One test read a bin the same way. public-artifact-cli.test.mjs spawns tsx by
absolute path out of the repo root's node_modules/.bin, which only ever held
one because shamefullyHoist published every bin there; tsx is declared by
internal/vibe-tests, so it now spawns that package's own bin. Scripts were
never at risk -- pnpm puts both bin directories on PATH -- and the repo's only
other hardcoded root bin, tsc in cli-api-types-verify.mjs, resolves because
typescript is a root devDependency.

Verified on a recreated node_modules: build, test, storybook:build, docsite and
sandbox builds, check:repo, verify-exports, eslint, and every typecheck CI gates
all pass. The local test failures that remain reproduce on main from a clean
worktree -- BSD `cp` has no `--reflink`, and two story titles predate the story
tree's shape rule -- and CI reported none of them.

* chore(changeset): patch @astryxdesign/cli for the doctor peer-resolution fix

The linker change also alters published behavior in `astryx doctor`, so the
fix needs a changeset to reach users in the next release.

* fix(cli): resolve packages through the project's own node_modules chain

Dropping the hoisted layout removes the flat root copy that three
resolutions quietly relied on. Each landed on main after this branch's
previous rebase, so CI met them for the first time here.

- packages/core used @heroicons/react in its Button accessibility
  fixtures without declaring it (#6131). Storybook's typecheck and the
  Button a11y suite could not resolve it.
- build.packed-old-core.test.mjs staged the packed CLI's runtime
  dependencies from the repo root, where only a hoisted node_modules puts
  a package's own dependencies (#5543).
- core-interception's CommonJS probe reached a core through NODE_PATH,
  which is where pnpm's isolated layout exposes every package and where
  Vitest points it. Wrapping that core fails on a require(esm) namespace,
  and the coverage gap it then reported rejected every theme whose
  lineage was unobserved (#5543).

doctor's findInstalledPackage moves to foundation/fs/paths.mjs and is now
the single chain walk all three share. It answers only from the caller's
own node_modules, never from the ambient environment.

* fix(deps): declare what the shadcn registry work reaches for

The shadcn registry (#5973, #6228, #6231) landed against the hoisted layout and
reaches for three things the workspace root only carries when hoisted.

- apps/docsite's generate-data.mjs requires `recharts/package.json` to pin the
  registry's external dependency specs. docsite declares the other three of
  that list; recharts was missing, so `pnpm generate` failed and 14 docsite
  test files could not load.
- generate-shadcn-registry.mjs named `@babel/preset-typescript` as a string.
  Babel resolves a string preset from `cwd`, and the registry-contract job runs
  the script from the repo root. It is now imported, the way the StyleX plugin
  beside it already was, so it resolves through docsite's own node_modules.
- generate-shadcn-registry.test.mjs spawned `node_modules/.bin/shadcn` from the
  repo root, at four call sites. shadcn is a docsite dependency, so its bin
  lives beside that package. The test now walks up from apps/docsite to find it.

* fix(cli): resolve a package through Yarn PnP when there is no chain to walk

Addresses the review on #5327. `findInstalledPackage` walked the node_modules
chain and stopped there, so a Yarn Plug'n'Play project — which has no
node_modules at all — read as missing every Core peer.

It now asks the PnP runtime when the walk comes up empty. PnP resolves from the
project's own dependency graph and ignores NODE_PATH, so the lookup stays
project-local, which is the property the filesystem walk was introduced for.

Verified against a real Yarn 4 PnP project with @astryxdesign/core installed:
declared packages resolve and their versions read off disk, an undeclared one
is still reported missing, and poisoning NODE_PATH changes nothing. That is
strictly better than the previous `require.resolve`, which could confirm a peer
was present under PnP but never read its version, because Core does not export
`./package.json`.

Covers both layouts in paths.test.mjs, including a case pinning that a package
reachable only from NODE_PATH is not accepted.

* fix(deps): cover the shadcn variant work added since the branch base

#6246 landed against the hoisted layout after this branch was last rebased,
and reaches for two things the workspace root only carries when hoisted.

- packages/cli/authoring/shadcn/source-variants.mjs imports `@babel/core`.
  cli declares the runtime package but not its types, so `sync:api-types`
  failed with TS7016 on two lines and took `pnpm build` down with it.
  `@types/babel__core` is now declared beside it, as packages/core already
  does for the same import.
- generate-shadcn-registry.test.mjs gained a fifth call site spawning
  `node_modules/.bin/shadcn` from the repo root. The other four already go
  through shadcnBin(), which walks up from apps/docsite — the package that
  declares shadcn, and so the only place its bin lives. The new one now does
  too, and the suite is back to 24 passing.

* fix(docsite): resolve playground and shadcn dependencies through Node

Two places computed a path into the repo root instead of resolving a package,
which only works when node_modules is hoisted. Node already walks up from the
module doing the asking, so both now let it.

- generate-playground-types.mjs read @heroicons/react and recharts off the
  root. Both degraded in silence — the heroicon loop `continue`d and the
  Recharts builder returned {} — so the playground shipped without the types
  rather than failing. Recharts arrived with #6264 and is covered by
  playground-scope.test.ts, which is how it surfaced; the heroicon path has
  been there since #2535 and nothing asserts on it, so it was quietly
  producing zero variants. Resolving now throws if either is missing.
- generate-shadcn-registry.test.mjs spawned node_modules/.bin/shadcn. shadcn
  does not export ./package.json, but its bin *is* its entry, so resolving
  `shadcn` from apps/docsite and running it through process.execPath needs no
  path assumption and no NODE_PATH.

Net -8 lines in the generator. findInstalledPackage is unchanged: it reads a
consumer project, where there is no module of ours to resolve from and
NODE_PATH must not count as installed.

This branch was successfully deployed

1 active deployment
Preview — 32da9992 Deployed Sep 7, 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.

1 participant