An open source design system that's fully customizable and agent ready
TypeScript
spec(AST-080): every PR reports component size; touch-only JS and CSS have a budget (#8271)
Cindy Zhangf574bd0013b8
diff --git a/docs/architecture/component-style-authoring.md b/docs/architecture/component-style-authoring.mdindex d3c8497dc5..401313c0eb 100644--- a/docs/architecture/component-style-authoring.md+++ b/docs/architecture/component-style-authoring.md@@ -7,7 +7,7 @@ authority: currentarchive_reason: nullsuperseded_by: nullapproved_by: cixzhang-approved_at: 2026-09-07+approved_at: 2026-10-24owners: [cixzhang]applies_to: [packages/core/src/, packages/lab/src/]verified_by:@@ -17,7 +17,7 @@ verified_by:internal/eslint-plugin-astryx/no-stylex-null-override.test.mjs,internal/eslint-plugin-astryx/no-style-only-wrapper.test.mjs,]-deciding_specs: []+deciding_specs: [spec:AST-080/DEC-4]---# Component style authoring architecture@@ -28,7 +28,7 @@ deciding_specs: []{"scope": "global","triggers": {- "styling": ["INV1", "INV2", "INV3", "INV4", "INV5"]+ "styling": ["INV1", "INV2", "INV3", "INV4", "INV5", "INV6"]}}```@@ -39,7 +39,7 @@ Astryx component styling should lower to valid maintained CSS, compose predictabwith supported consumer styling, keep relational state scoped to the intendedcomponent, and avoid DOM wrappers with no runtime responsibility.-This record owns five component-level authoring outcomes. It does not redefine+This record owns six component-level authoring outcomes. It does not redefinesemantic tokens, public theme targets, extensible prop axes, public styling props,icon resolution, bidirectionality, or React Server Component boundaries.@@ -95,6 +95,25 @@ not evidence of conformance or violation.owns a compatible style-bearing DOM surface. A wrapper may instead own thatboundary when the child has no compatible surface. Source clarity alone is not anormative responsibility.+- **INV6 — Component size is reported and touch-only cost is budgeted.** Every+ pull request that changes a component's code or styles reports, base against+ head, the gzip size of the JavaScript each changed component's import pulls+ in, including its transitive modules, and that component's gzip CSS delta in+ its package stylesheet (`spec:AST-080` FR8). A feature that runs only on a+ coarse pointer and adds more than 2 KB gzip of JavaScript or 1 KB gzip of CSS+ to one component is flagged. Its pull request either loads that JavaScript+ lazily, only when a coarse pointer needs it, so the component's import does+ not carry it, or justifies the cost. For flagged CSS, its pull request+ justifies the cost, because that CSS stays in the package stylesheet+ (`spec:AST-080` FR1, FR8). Sizes are gzip at the default compression level,+ and 1 KB is 1,024 bytes; measured as `spec:AST-080` FR8 measures CSS, a+ component's JavaScript size is the gzip size of one bundle holding its+ import and every module that import reaches. A shared JavaScript value+ table, such as a gesture or spring tuning table, ships to a component only+ the rows that component uses: importing a component does not pull in rows+ only other components read. The rule covers tuning tables only: StyleX+ variable groups follow `spec:AST-066` FR3, and message catalogs follow+ `architecture:internationalization` INV15.## Authoring guidance@@ -182,8 +201,10 @@ Focused style-authoring review triggers when a component change adds or alters:- shorthand/reset/null behavior that can prevent independent consumer propertycomposition;- ancestor, descendant, or sibling visual state;-- a DOM wrapper around one component or one visual child; or-- a component-owned inline SVG that may represent a shared semantic glyph.+- a DOM wrapper around one component or one visual child;+- a component-owned inline SVG that may represent a shared semantic glyph; or+- code or styles that run only on a coarse pointer, or a shared value table a+ component reads (INV6).Review checks the invariant owned here and follows the delegated authority abovebefore assigning a verdict.@@ -198,16 +219,21 @@ before assigning a verdict.## Deciding specs-None. The icon, theme-token, component-theming, public-API, bidirectionality, and+- `spec:AST-080/DEC-4` — every pull request reports component JavaScript and+ CSS size; touch-only JavaScript over 2 KB or CSS over 1 KB is flagged, and+ shared value tables ship only the rows a component uses (INV6).++The icon, theme-token, component-theming, public-API, bidirectionality, andRSC owners retain the delegated decisions above.## Verification-| Invariant | Evidence | Failure signal |-| ------------------- | ---------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| INV1 | StyleX capability scan plus component-source mutation | Shipped component styling bypasses the maintained lowering path without another named owner, including component-local raw CSS where that path supports the same result |-| INV2 | Equivalent CSS/JS mutation fixtures and real-browser presentation | JavaScript recreates CSS-resolvable presentation, flashes intermediate state, or disagrees with CSS conditions |-| INV3 | StyleX compile fixtures and independent consumer-property override mutations | Input lowers to invalid CSS or changing one supported property cannot compose without removing another |-| INV4 | Nested unrelated-owner browser fixture across hover, focus-within, active, and disabled states | Outer component state activates an inner component's visual treatment |-| INV5 | Wrapper mutations in default and host-composed render paths | Removing a wrapper changes no semantic, behavior/ref, formatting-context, outside-border-spacing, or required style-bearing DOM boundary |-| Capability registry | Registry generation against the installed StyleX package | Recorded and installed StyleX versions differ, so capability-dependent cases are untestable |+| Invariant | Evidence | Failure signal |+| ------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| INV1 | StyleX capability scan plus component-source mutation | Shipped component styling bypasses the maintained lowering path without another named owner, including component-local raw CSS where that path supports the same result |+| INV2 | Equivalent CSS/JS mutation fixtures and real-browser presentation | JavaScript recreates CSS-resolvable presentation, flashes intermediate state, or disagrees with CSS conditions |+| INV3 | StyleX compile fixtures and independent consumer-property override mutations | Input lowers to invalid CSS or changing one supported property cannot compose without removing another |+| INV4 | Nested unrelated-owner browser fixture across hover, focus-within, active, and disabled states | Outer component state activates an inner component's visual treatment |+| INV5 | Wrapper mutations in default and host-composed render paths | Removing a wrapper changes no semantic, behavior/ref, formatting-context, outside-border-spacing, or required style-bearing DOM boundary |+| INV6 | Pull-request size report against base, with value-table import fixtures | A changed component with no base-against-head gzip JavaScript or CSS figure; a touch-only feature over 2 KB gzip JavaScript or 1 KB gzip CSS per component that is not flagged; importing a component pulls in value-table rows only other components read |+| Capability registry | Registry generation against the installed StyleX package | Recorded and installed StyleX versions differ, so capability-dependent cases are untestable |diff --git a/docs/specs/AST-080-package-stylesheets/spec.md b/docs/specs/AST-080-package-stylesheets/spec.mdindex be11e4a958..6779891b3d 100644--- a/docs/specs/AST-080-package-stylesheets/spec.md+++ b/docs/specs/AST-080-package-stylesheets/spec.md@@ -7,10 +7,10 @@ authority: currentarchive_reason: nullsuperseded_by: nullapproved_by: cixzhang-approved_at: 2026-10-16+approved_at: 2026-10-24phase: acceptedowners: [cixzhang]-affects_architecture: []+affects_architecture: [architecture:component-style-authoring]affects_families: []affects_contributing: []affects_consumer_docs: [styling-overview, getting-started, migration-setup]@@ -137,13 +137,30 @@ first.source build needs no data beyond the package's own source, and holds indevelopment builds as in production builds.+- **FR8 — Stylesheet growth is reported and budgeted per component.** Every+ product that loads a package's prebuilt stylesheet loads all of it (FR1), so+ CSS a component adds reaches each of those products, including products that+ never render it. Every pull+ request that changes a package's styled modules MUST report, base against+ head, the gzip size of each package stylesheet it changes and the gzip CSS+ delta of each component that changed. A feature that runs only on a coarse+ pointer and adds more than 1 KB gzip of CSS to one component is flagged, and+ its pull request justifies that cost; the CSS stays in the package+ stylesheet (FR1, FR2). Sizes are gzip at the default compression level, and+ 1 KB is 1,024 bytes. A component's CSS delta is the gzip size of the rules its+ modules contribute to the package stylesheet at head minus the same at base.+ The matching JavaScript report and budget, and the+ rule that a shared value table ships only the rows a component uses, are+ `architecture:component-style-authoring` INV6.+### Platform support- Supported feature/engine floor: unchanged; cascade layers are already requiredby the theme and reset stylesheets.- Unsupported behavior: none added.- Browser evidence: real-browser computed styles for FR2, FR3, and FR7. FR1, FR4,- FR5, and FR6 are proven at the package, bundler, and documentation layer.+ FR5, and FR6 are proven at the package, bundler, and documentation layer. FR8+ is proven by the pull-request size report.## Current-state impact@@ -172,6 +189,11 @@ first.- Lab, Rich Text, and Charts document their stylesheet only in their READMEs;the styling overview's import table lists only Core (FR6).+- The pull-request size report measures no stylesheet, so no CSS size or+ delta is reported, and no touch-only CSS is flagged (FR8). Its JavaScript+ figure is a component's re-export file rather than what its import pulls in,+ its before and delta columns are always empty, and nothing flags touch-only+ JavaScript (`architecture:component-style-authoring` INV6).- The `styling-overview`, `getting-started`, and `migration-setup` consumer docschange. Package stylesheet rules and class names are otherwise unchanged.@@ -185,6 +207,7 @@ first.| FR4 | packed-package and bundler fixtures | each package's stylesheet import in a production bundle | the subpath does not resolve from the packed package; the bundle drops the stylesheet || FR5–FR6 | consumer-doc checks | every setup snippet in the styling overview, getting started, and migration setup; each package README | a default setup omits `astryx.css` or a used package stylesheet; a setup loads a prebuilt stylesheet and compiles the same package's source; a package import is missing || FR7 | build-package compile tests and real-browser cascade | every Core module compiled through the build package; a subset of modules; a development build; Core source-built beside a prebuilt Lab stylesheet; a source-built component under a theme override | the every-module compile differs from the prebuilt rules or order; an Astryx rule sits in a nested or other layer; the theme override loses |+| FR8 | pull-request size report against base | a component whose styles change; a touch-only feature adding 0.9 KB and 1.1 KB gzip CSS to one component; a pull request with no styled change | a changed package stylesheet or component with no base-against-head gzip figure; a touch-only feature over 1 KB gzip CSS per component that is not flagged |The real-browser cascade check uses a component whose theme changes its basecolors, such as a theme that restyles the destructive Button, and asserts the@@ -234,6 +257,25 @@ framework.Rejected: stylesheets imported by component modules, because some frameworks donot load stylesheets that dependency modules import.+### DEC-4 — Component size is reported on every change and budgeted for touch-only work++**Reference:** `spec:AST-080/DEC-4`+**Decider:** `cixzhang`, `2026-10-24`++Because each package's prebuilt stylesheet ships whole (DEC-3) and is the+default setup (DEC-1), CSS for a feature only touch devices use still costs+every desktop product on that setup, and nobody sees the+cost unless each change reports it. A per-component report on every pull+request makes growth visible, for the JavaScript a component's import pulls in+as for its CSS. Touch-only work is flagged at 2 KB gzip of JavaScript or 1 KB+gzip of CSS per component: JavaScript can load lazily, only when a coarse+pointer needs it, or be justified, and CSS, which stays in the stylesheet, is+justified. A shared JavaScript value table ships to a component only the rows it+uses, so one component's tuning does not ride along with every other import.++Rejected: splitting touch-only CSS into a separate stylesheet, because it+breaks the one-import setup DEC-3 keeps.+## Open questionsNone.