Repository navigation
test(ui): lock dark block parity and raw palette immutability (L042) - #19
Merged
Merged
Conversation
The generator renders the dark theme twice per layer and color format: under the explicit data-lai-theme="dark" selector and under prefers-color-scheme for documents that set no theme. Both come from the same call today, but no test compared them, and check:colors only detects drift between generated files and generator output, not a regression of the generator itself. Add color-system/dark-parity.ts, three pure functions over a generated sheet: darkBlocks extracts the dark blocks by exact selector, compareDarkBlocks reports missing, extra, differing or reordered declarations between the explicit and automatic blocks, and rawPaletteOverrides lists any --lai-palette-* color redeclared in a dark block. A sheet where an expected block cannot be found throws a named error instead of reading as parity. The test applies them to every palette, the convergence and the adopted sheet, asserts the volume examined, and checks that the five surface roles resolve to a different color in dark than in light. generate.ts, system.ts, adopt.ts and the generated files are unchanged. What makes these tests fail: a declaration added to, removed from, changed or reordered in only one of the two dark blocks; a raw palette color added to any dark block; a renamed automatic selector; a dark surface equal to its light value. Each case is built by substitution in the real generator output, and dropping one declaration from the automatic block inside formatThemeBlocks turns the suite red. Would an equivalent refactor fail them too: the expected selectors, layer names and layer/format order are the published contract of the sheet, written out in the test; a refactor that keeps the sheet byte-identical stays green. Renaming a layer or a theme selector fails by design. Signed-off-by: Constantin Jais <74049135+constantin-jais@users.noreply.github.com>
Review findings on the dark parity controls, each reproduced by a test that
was red on the previous commit:
1. A rule nested inside a dark block (`& { ... }`, or a nested at-rule) was
parsed as a separate rule and matched no dark selector, so a
--lai-palette-* color declared there escaped both compareDarkBlocks and
rawPaletteOverrides. darkBlocks now throws
color.dark_parity_nested_rule:<layer>/<format>/<kind>, and the two
controls inherit the error. Covered by "refuses a nesting rule / a nested
at-rule inside a dark block" (explicit, media and high contrast blocks).
Neutralization: replacing the throw with a no-op turns 2 tests red.
2. rawPaletteOverrides read only the three exact dark selectors: a raw color
redeclared under :root in a prefers-color-scheme: dark media query of the
primitives layer, or under a selector list naming the dark theme, passed.
It now also reads every rule under a dark media query (any spacing) and
every rule whose selector or an ancestor's names a dark data-lai-theme
value, in any layer. Parity extraction keeps exact selectors. Covered by
four "lists a raw palette color redeclared under ..." cases. Neutralization:
restricting the wider context back to the exact selectors turns 4 tests
red.
3. The previous commit also modified packages/ui/color-system/README.md
without saying so in its message: it added the description of
dark-parity.ts and dark-parity.test.ts. This commit updates that entry for
the nested-rule error and the wider raw palette scope.
Departure from the brief, declared: the brief asks for extraction by exact
selector. Parity still does; the raw palette control is stricter than the
brief (wider contexts), and nested rules in a dark block are now an error.
No public name, data format or exit code changes.
Signed-off-by: Constantin Jais <74049135+constantin-jais@users.noreply.github.com>
constantin-jais
marked this pull request as ready for review
November 17, 2026 20:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Door: two-way
Origin: proposal
Summary
Lot
L042of the rewrite plan: Thème sombre explicite généré de la même source (TypeScript sur Bun).Draft pull request. Base:
migrate/recover-code.packages/ui/color-system/README.mdpackages/ui/color-system/dark-parity.test.tspackages/ui/color-system/dark-parity.tsCommits (2, merges excluded):
8bfc571test(ui): lock dark block parity and raw palette immutabilitya120c64fix(ui): refuse nested dark rules and widen the raw palette controlEvidence
The tests and controls below are local runs on the workstation (Bun 1.4.4), recorded in the commit messages; they were not replayed for this pull request. The CI on this head is authoritative.
Review: read by an independent reviewer (read-only, given the code, the base and the source, never the writer report); the defects found were corrected, each with a test shown red on the unfixed code (see the correction commits).
Commit messages, verbatim (sign-off lines omitted):
Points left to the owner
None named in the commit messages.
Work package
No commit carries a
Work-package:orExempt:trailer. This repository runs no work-package link check; the link to a PRD row, if any, is the owner's to establish.Blast radius
libre-ai/application-development-toolkitonly. While draft, nothing moves outside the branchwork/rewrite-l042; a merge reachesmigrate/recover-code.