Malevich

Architecture decision record

ADR-0005 · Token group lifecycle

ADR 0005 — Token group lifecycle

Status

Accepted, 2026-05-17.

Context

Adding a new token group (e.g. size-control in foundations, or color.bone in semantic) requires synchronized changes across multiple files: JSON definition, TypeScript types, resolver, emit pipeline, fixtures, and validation. Without a documented process, new additions risk partial implementation and broken builds.

Decision

Adding a new foundation group requires:

  1. Add to packages/core/tokens/foundations.json — the JSON entries under the new group key
  2. Extend FOUNDATION_GROUPS array in packages/core/src/types.ts
  3. Extend FoundationsTokens interface in packages/core/src/types.ts
  4. Update resolve.ts if cross-tier references will use the new group
  5. Update __tests__/fixtures.ts so existing core tests still pass under the stricter interface
  6. Verify pnpm build && pnpm test passes
  7. Commit as feat(core): add <group-name> foundation tokens

Adding a new semantic group:

  1. Add to packages/core/tokens/semantic.json in BOTH light and dark schemes
  2. Extend SEMANTIC_GROUPS array if it's a new group key
  3. Extend SemanticTier interface if needed
  4. No changes needed in resolve.ts for aliases of existing foundation paths
  5. Verify pnpm build emits the new CSS custom property
  6. Commit as feat(core): add <group-name> semantic tokens

Adding component-specific (tier-3) tokens:

  1. Add to packages/core/tokens/component-specific.json only
  2. No types.ts changes needed — ComponentTier is Record<string, Record<string, string>> (generic)
  3. No resolver changes needed — resolves to semantic via {path} syntax automatically
  4. Verify pipeline emits --{component}-{key} CSS variable
  5. Commit with the component implementation

Promotion criteria

A foundation seed should be promoted to semantic when:

A semantic token should be added when:

A tier-3 token should be used when:

Consequences

Positive:

Negative:

Alternatives considered