ADR-0042: The layer that styles two thirds of what it ships
- Status: Accepted
- Date: 2026-08-21
- Deciders: Renaissance workstream 002, open-items ledger rows 10 / 115; builds the check ADR-0023 proposed and deferred
Context
ADR-0020 made
the standalone component layer a first-class artefact, and build-css.mjs
checks it in one direction: no selector inside it may reach outside the
.lk-/.studio- namespace, because namespace containment is what makes
taking one layer alone safe.
Nothing checked the other direction. ADR-0023 was written after DataTable
came one commit from rendering <caption class="visually-hidden"> on
fourteen screens against a .visually-hidden that lives in the a11y layer
the app does not import — a visible caption in body copy, invisible to
tsc, ESLint, every parity gate, the namespace check, the Studio lint and
all 119 tests then in the tree. It named the mechanical form of the missing
check, found a second escape in the same component (.t-mono, for a
numeric column that never got tabular figures), and deferred building it.
In the two days since, the same trap was hit six more times and found by
hand every time, one component at a time: .lk-seg (row 19),
.lk-btn--danger, .lk-stack and the layout primitives (row 113, which
blocks phase 03), .lk-card__* (row 105), .lk-menu (row 124), and
CodeEditor's .lk-code__hint, which was committed and caught inside one
sitting. Row 115 calls it "the highest-value gate not built".
Decision
scripts/check-layer-completeness.mjs, wired into npm run verify.
It reads every class name in a className position in
studio/packages/react/src/*.jsx and subtracts what
dist/studio.components.css and dist/studio.resource.css define. Two
rules, deliberately the same shape as the parity gate's S1/S2:
- L1 — every emitted class the layer does not define carries a row in
studio/parity/layer-classes.jsonnaming the Studio layer that does define it and what a component-layer consumer therefore sees. An undocumented gap fails the build. A component rendering unstyled may exist; silently doing so may not. - L2 — a disposition for a class the layer now defines, or for one no component emits any more, fails the build. The ledger describes the tree as it is.
Two extraction decisions are load-bearing and worth stating, because a noisy gate is a gate people route around:
- Comparison operands are not classes. In
size === 'sm' && 'lk-x--sm'the class islk-x--sm;smis a prop value. A first pass that counted both reported 108 gaps includingaccent,narrow,neutral,sm,xlandradio— a third of the output was noise, and noise is what buriesvisually-hidden. - A template literal contributes a prefix, not a name.
`lk-status--${tone}`cannot be resolved statically, so the gate asks only that some rule start withlk-status--. That is weaker than a name check and still catches a whole family being absent — it found three on its first run (lk-panel--*,lk-paneltoggle--*,lk-pill--*).
Consequences
The measurement is the finding. 293 classes are emitted by 11 React modules; 193 are defined in the layer a consumer can import, and 100 are not — plus three template families. Roughly one third of Studio React's class surface is unreachable for the consumer the layer exists to serve. The seven hand-found escapes were not a run of bad luck; they were the visible part of this.
Grouped by where the rule actually lives:
| Where it is defined | Classes | What a component-layer consumer gets |
|---|---|---|
40/41/42/43/44-shell-*.css | 62 | Unstyled shell structure. The largest block by far. |
30-primitives.css | 10 | Unstyled layout primitives — row 113, blocks phase 03 |
70-patterns.css | 9 | The element without its composition (row 105 is part of this) |
60-sections.css | 5 | Unstyled hero / CTA / section rhythm |
dist/studio.type.css | 4 | Unstyled type scale — importable as css/type, and this app does not |
90-a11y.css | 2 | visually-hidden, lk-skip — no standalone export exists |
15-material.css | 1 | glass: an unfrosted panel |
| Phosphor (external) | 7 | Blank space; row 4, fixed per component as each converts |
Most of it is latent here and would not be for the next consumer.
Cardsite mounts no Studio shell — it has its own shell.css — so the 62
shell classes cost it nothing today. The primitives are the ones that bite:
row 113 already blocks promoting .stack (167 positions across 73 files)
and the 50 hand-rolled <form>s.
Recording is not fixing, and the numbers say which. 103 dispositions
land here with no rule moved. The fix for a whole group is to widen the
allowlist, which is a decision rather than a patch: the two-file allowlist
is why the layer is safe to take alone, so 30-primitives.css has to be
shown namespace-clean before it joins. This gate makes that a countdown
instead of a memory, the same way the parity ledger did for components —
and, like it, the success line prints the number a future phase drives
down.
Not wired into .github/workflows/ci.yml. It runs inside
npm run verify, which is the gate that decides merges while the Actions
outage holds. Adding the line to the CI Studio job is a workflow change,
which this session is not permitted to make; it should ride with the next
one that is.
Watched failing before being trusted, all four ways: a component naming
lk-nope (L1), a template prefix with no matching rule (L1 — it found three
real ones unprompted), a disposition for a class added to the layer (L2),
and a disposition for a class nothing emits (L2).
Source: docs/decisions/0042-the-layer-that-styles-two-thirds-of-what-it-ships.md