feat(native): emit canonical Swift/Flutter colour tokens from the DTCG #62

Merged
peterswimm merged 1 commit from feat/native-token-emitter into main 2026-07-25 17:47:17 +00:00
Owner

What

Implements recommendation #1 from the theme-alignment strategy (PR #61): the native apps were the drift surface — Swift/Flutter hand-maintained divergent values under the canonical token names, with no emitter. This adds one.

udg/generators/native.py generates, per native-consuming product (rituals, detected from the sync-manifest consumers: block), from the resolved canonical dist/<p>/tokens.dtcg.json (keyed by udg.dart-key):

  • dist/rituals/udg_tokens.dartudgColorLightHex / udgColorDarkHex const maps in the sibling's exact format → a drop-in for the Flutter udg package colour maps.
  • dist/rituals/udg_colors.json{ "<theme>": { "<dartKey>": "#AARRGGBB" } } colour manifest for the macOS Swift app.

It fixes the proven drift

The emitted values are canonical — e.g. brandPrimary 0xFFC05734 where the Flutter package had drifted to #CC5C37; accentWarning, textDim, textMeta likewise. These are exactly the four divergences just align-check reported. Once the sibling repo source-injects dist/rituals/udg_tokens.dart, the drift check goes green.

Generated + gated

  • Wired into just build and just check (native.py check — byte-drift gate, same pattern as artifact.py).
  • The sync-manifest declares the new source-inject consumers (dart colour maps → packages/udg/lib/src/udg_colors.dart; colour JSON → the macOS udg_tokens.json).

Scope

Colour only — the proven drift. The full multi-tier udg_tokens.json (borders / spaces / radii / types / breakpoints / mode_accents / …) is a documented follow-up: those categories are app-specific and the original generator was deleted, so faithful reproduction is riskier and deserves its own change. The remaining cross-repo step (having the sibling adopt the emitted files via the source-inject) is also a follow-up.

Testing

just check green (incl. native.py check — "native OK — 1 product match") · pytest 132 passed · yamllint clean. Verified drift detection (tampering the emitted file fails the gate) and canonical values in both outputs.

## What Implements **recommendation #1** from the theme-alignment strategy (PR #61): the native apps were the drift surface — Swift/Flutter hand-maintained divergent values under the canonical token names, with no emitter. This adds one. `udg/generators/native.py` generates, per native-consuming product (rituals, detected from the sync-manifest `consumers:` block), from the resolved canonical `dist/<p>/tokens.dtcg.json` (keyed by `udg.dart-key`): - **`dist/rituals/udg_tokens.dart`** — `udgColorLightHex` / `udgColorDarkHex` const maps in the sibling's exact format → a **drop-in for the Flutter udg package colour maps**. - **`dist/rituals/udg_colors.json`** — `{ "<theme>": { "<dartKey>": "#AARRGGBB" } }` colour manifest for the **macOS Swift app**. ## It fixes the proven drift The emitted values are canonical — e.g. `brandPrimary 0xFFC05734` where the Flutter package had drifted to `#CC5C37`; `accentWarning`, `textDim`, `textMeta` likewise. These are exactly the four divergences `just align-check` reported. Once the sibling repo source-injects `dist/rituals/udg_tokens.dart`, the drift check goes green. ## Generated + gated - Wired into **`just build`** and **`just check`** (`native.py check` — byte-drift gate, same pattern as `artifact.py`). - The sync-manifest declares the new **source-inject consumers** (dart colour maps → `packages/udg/lib/src/udg_colors.dart`; colour JSON → the macOS `udg_tokens.json`). ## Scope **Colour only** — the proven drift. The full multi-tier `udg_tokens.json` (borders / spaces / radii / types / breakpoints / mode_accents / …) is a documented follow-up: those categories are app-specific and the original generator was deleted, so faithful reproduction is riskier and deserves its own change. The remaining cross-repo step (having the sibling adopt the emitted files via the source-inject) is also a follow-up. ## Testing `just check` green (incl. `native.py check` — "native OK — 1 product match") · `pytest` 132 passed · `yamllint` clean. Verified drift detection (tampering the emitted file fails the gate) and canonical values in both outputs.
feat(native): emit canonical Swift/Flutter colour tokens from the DTCG
All checks were successful
UDG dist drift gate / dist/ matches dtcg + udg sources (pull_request) Successful in 18s
Test Generator / lint-workflows (pull_request) Successful in 21s
Security Scans / Gitleaks secret scan (pull_request) Successful in 25s
Test Generator / lint-prose (pull_request) Successful in 23s
Security Scans / Trivy filesystem scan (pull_request) Successful in 29s
Test Generator / test (pull_request) Successful in 3m14s
7b870bb944
Closes the native colour-drift loop — the drift surface identified in the theme-
alignment strategy. udg/generators/native.py generates, per native-consuming
product (rituals, from the sync-manifest consumers), from the resolved canonical
dist/<p>/tokens.dtcg.json keyed by udg.dart-key:

- dist/rituals/udg_tokens.dart — `udgColorLightHex` / `udgColorDarkHex` const maps
  in the sibling's exact format, a drop-in for the Flutter udg package colour maps.
- dist/rituals/udg_colors.json — { "<theme>": { "<dartKey>": "#AARRGGBB" } } colour
  manifest for the macOS Swift app.

The emitted values are canonical — brandPrimary 0xFFC05734 (the Flutter pkg had
drifted to #CC5C37), and accentWarning / textDim / textMeta likewise (exactly the
divergences `just align-check` reported).

Wired into `just build` + `just check` (byte-drift gate, like artifact.py); the
sync-manifest declares the new source-inject consumers (dart-colors + colour JSON).

Colour only — the proven drift. The full multi-tier udg_tokens.json
(borders/spaces/radii/types/breakpoints/…) is a documented follow-up (its
app-specific categories + deleted original generator make faithful reproduction
riskier). Implements recommendation #1 (colour scope) from
docs/reviews/theme-alignment-strategy.md (PR #61).

just check green · pytest 132/132 · yamllint clean.
peterswimm deleted branch feat/native-token-emitter 2026-07-25 17:47:17 +00:00
Sign in to join this conversation.
No description provided.