Repository navigation
Phase 32 slice C: unknown tokens and derived tints - #257
Merged
Merged
Conversation
A $ref no token defines, of the wrong kind, or on a prop that takes none is an unknown-token warning with a rename fix when one name is closest. Copy props never resolve. The tint layer and danger derive from the inks in the surface's mode instead of dark seeds, and old seeds count as unset.
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.
Phase 32 slice C (
docs/specs/PHASE-32-SPEC.md, FR-C1 to FR-C6, with the contracts pinned in the spec's M1 to M11 block, the as-built notes N1 to N4, and the two verify rounds recorded after them).The problem
A misspelt
$tokenwas silent.gap: "$space-xxs"(the real token is$space-3xs) resolved to nothing, the renderer dropped it, andcanvas_evaluatesaid READY. A token of the wrong kind rendered garbage the same way:fill: "$body"drewcolor: 16. Copy was resolved like style, socontent: "$body"crashed the renderer and a price such as"$49"was one typo away from becoming a token. The tint layer anddangerwere seeded as dark values on every stamp, and no preset defines them, soapply_preset lightafter a stamp left dark chips on a light page.What changed
unknown-token. A new default rule (structure, warning, −10, blocks presenting) on every$refthe resolver reads: a name no token defines, a token of the wrong kind for its prop (a typography or spacing token on a colour prop, a colour on a number prop, a whole token group), a ref on a prop that takes no token (fontFamily: "$display"), a name defined only in the dark layer, and a token whose value is itself a ref. It reads top-level props,padding/cornerRadiusentries, border colours, chart series and segments, and modal and toast action colours, inside components too, reported once per place the ref is written.$space-lgis never renamed to$space-md), and the ref sits on the stored node itself,canvas_autofixrenames it. Apaddingarray or border object is rewritten whole, so two typos in one array share one op.COPY_PROPSset (copy and enum props, pluscontent,text,name,closeLabeland the donut'scenterValue/centerLabel) is skipped by the resolver, the token census and the rule.dangerderive. When no layer defines them, each tint derives from its ink with the generator's own tint rule, in the light or dark mode of the surface (bg-surface,surface,bg-primary,background, else white). A grey ink gets a grey tint.dangerfalls back toerror, then#DC2626on a light surface and#F87171on a dark one. Stamps no longer seed them, and a stamp that reads one seeds the surface instead, so an unthemed stamp stays dark like its inks.get_variables,apply_preset, a canvas-scope generated system, the viewer's token source andgenerate_color_system'soverwrotelist all treat it as unset. A canvas holding a seed gets a newsha256r:version hash once, so an approval recorded on it reads STALE.batch_designinsert have noid. The unknown-icon check crashedcanvas_evaluateon one (on master too); both rules now report such a node on its nearest ancestor with an id, with no fix. The Tailwind importer no longer turns non-colour utilities (text-balance,bg-cover,text-sm/6,bg-red-500/20,bg-(--x)) into colour refs, and a theme colour with such a name still maps.Decisions the spec text did not settle
dangerfalls back by mode, not to#DC2626alone.#DC2626is 3.91:1 on the unthemed scaffold surface#111111, where the old seed#F87171is 6.83:1. A single literal would have turned every unthemed destructive label into a contrast failure.text-secondaryproduced a maroon neutral tint. The generator's own output is unchanged; only the derivation uses the grey rule.s/m/lladder$space-mis a size, so it is never renamed to$space-md. A missed rename is cheaper than a wrong size.Verdicts that moved
test-patterns.tsweb and mobile gatecanvas.variableswholesale, which dropped every seeded spacing, radius and type token: the stamps rendered with those values missing and still scored 99.apply_presetdoes. A new gate holds every structure, unthemed, under each preset and under a generated system, to zerounknown-tokenfindings, with a twin that replaces the variables wholesale and must fail.test-patterns.tsand the twotest/browserdesktop gates$bg-primarybackdrop was undefined on an unthemed canvas and drew nothing.test-patterns.tsdark-tint twinaccent-tintto the old seed.test-desktop-primitives.ts#RGBand named-accent cases.test-structures.tsdangeramong the seeded colours.dangerand the tints never seeded.Measured against master, contrast findings fell under every theme: the old dark seeds failed the initials avatar unthemed and every tint chip under the light, material and minimal presets. Under the light preset the chips now fail only where the preset's own inks do (
success#16a34ais 3.3:1 anderror#ef44443.8:1 even on white), which the contrast check reports as before.Not fixed here
lookupTokenreads spacing before radius, socornerRadius: "$md"under a preset that definesmdin both renders the spacing value (16, not 8). The README's ownget_variablesexample (cornerRadius: "$sm") hits it. The rule sees one number kind and stays silent. It predates this slice, and changing the lookup order changes existing renders.Tests
test/unit/test-unknown-token.ts: every FR-C1 to FR-C4 acceptance, each prop-table entry and copy prop, the fix's edges (distance, ties, ladder rungs, nested borders), origins through components, masters, overrides and id-less nodes, the kill switch, and the autofix ops applied throughbatch_design.test/unit/test-derived-tints.ts: FR-C5 and FR-C6, the surface chain and its aliases, alpha and grey inks, each of the six seeds with a one-digit-off twin, preservation and the version hash, and a sweep holding every structure to no contrast error against a derived tint.test/unit/test-tailwind-map.ts: the non-colour utilities, with theme-colour twins.Docs
The
canvas_evaluate,canvas_autofix,apply_structure,apply_preset,get_variablesand colour-system docstrings, the INSTRUCTIONS and init gotchas, GUIDELINES (new sections on the derived tint layer and unknown tokens, the autofix list and fix workflow), README (the rules table, the structure category, the autofix list,get_variables,apply_preset,apply_structure, the tint layer) and VISION (slice C ticked, plus the two follow-ups it closes).