Components and retired treatments
A design system is more than its tokens. It is also the list of things it agreed to build, and the list of things it agreed to stop doing. Airframe keeps both as files beside the tokens and lints them:
- The component inventory. Each component has a file under
<content>/components/naming the ruling it answers to, the tokens it owns, the files allowed to read them, and where each platform builds it. A component with no ruling is not in the system. - Retired tokens and treatments. A token marked
retired: trueis still emitted, so code keeps compiling while it migrates, but nothing may read it. A treatment with no token to delete (a 3px inset bar, a hand-drawn shadow) is held in<content>/retired.yamlby its spellings on every platform, so it cannot quietly come back.
Three lint rules hold them:
component-unruled,
component-incomplete and
retired-used. They run in every lint output
format, the gate included, and each reports what it checked.
This guide uses the token set from the repository’s
internal/selftest/fixtures/clean-consumers fixture: semantic surface,
ink, accent, gap, hairline and the retired legacy-ink;
primitives gray-50, gray-900, blue-500, space-2, space-4 and
line-1; and the button component’s button-bg and button-ink. The
consumer rules themselves (declaring consumers, wrappers, owners) are in
Consumers: checking where tokens are read.
1. The project
Section titled “1. The project”Two platforms declare consumer files:
version: 1content: design-systemmodes: appearance: {values: [light, dark], binding: runtime, web: {light: ":root", dark: ":root[data-theme='dark']"}} density: {values: [compact, standard], base: standard, binding: runtime, web: {attr: data-density}}platforms: web: emit: [css] out: {css: web/src/generated/tokens.css} consumers: ["web/src/**/*.{css,tsx}"] apple: emit: [swift, colorsets] out: {swift: apple/Generated/DesignTokens.swift, colorsets: apple/Generated/Assets.xcassets/Tokens/} consumers: ["apple/Sources/**/*.swift"]2. Component files
Section titled “2. Component files”A component is <content>/components/<id>.yaml:
id: buttonnoun: Buttonruling: "@ruling:button"tokens: [button-bg, button-ink]owners: - web/src/button/** - apple/Sources/Button*.swiftimplementations: web: web/src/button/Button.tsx apple: apple/Sources/ButtonStyle.swift| Field | Required | What it says |
|---|---|---|
id |
yes | The component’s id, kebab-case; it equals the file’s basename. |
noun |
no | What people call it, for show and the inventory. |
ruling |
yes | "@ruling:<id>": the Gantry ruling it answers to (§3). |
tokens |
no | The component tokens it owns. Each must exist, be tier component and say component: <id>; every token that names the component must be listed. |
owners |
unless shared |
Repo-relative globs: the files allowed to read its tokens. Declared, never inferred. |
shared |
no | true lets any consumer read its tokens. Default false. |
hostedBy |
no | The container component that hosts this one (§5), or null. |
implementations |
for each platform with consumers | Platform name to the file that builds it there, or "n/a: <reason>" (§4). |
Any other key is schema-invalid, and airframe fmt rewrites the file
in canonical form. Both files the button names exist:
export const Button = () => <button style={{ background: "var(--button-bg)", color: "var(--button-ink)" }} />;import SwiftUI
struct PrimaryButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .background(DesignTokens.buttonBg) .foregroundStyle(DesignTokens.buttonInk) }}3. Rulings and Gantry
Section titled “3. Rulings and Gantry”ruling is always checked for its shape: @ruling: followed by an id of
a-z, 0-9 and -, starting with a letter or digit. A missing or
misspelt ruling is component-unruled.
When the repository is also a Gantry project, the reference is resolved against Gantry’s records. Airframe reads the files only; Gantry is not run and not a dependency.
- Which Gantry project. A
gantry.yamlnext toairframe.yamlis used when one exists. To use another, set the top-level keygantry: tools/gantry/gantry.yaml(a repo-relative path to the file) inairframe.yaml. A configured file that does not exist isschema-invalid; with no key and no file, resolution is syntax only. - Where the rulings are. Gantry’s
content(defaultdocs/design) is relative to the folder holdinggantry.yaml, and must stay inside it. Each ruling is<content>/rulings/<id>.md. - What is read. The front matter, between
---lines at the top of the file:id(equal to the file name),status(proposed,ruled,supersededorretired) and, for a superseded ruling,supersededBy. Anchors, aliases, merge keys and duplicate keys are refused. A record that does not read (no closing---, invalid YAML, an id that does not match its file name) is acomponent-unruledfinding at the record, never a crash. - Symlinks are refused at every level:
gantry.yaml, the content andrulingsfolders (schema-invalid), and each ruling file (component-unruledat the record). A link could lead the resolver out of the repository.
version: 1content: docs/designdocs/design/rulings/button.md
---id: buttonstatus: ruled---Buttons are drawn by the app: one filled shape, the accent behind the ink.docs/design/rulings/old-menu.md
---id: old-menustatus: supersededsupersededBy: menu---The first menu ruling, before menus could nest.docs/design/rulings/menu.md
---id: menustatus: ruled---Menus nest, and open on press.docs/design/rulings/toast.md
---id: toaststatus: proposed---Toasts are still being argued.docs/design/rulings/selection-treatment.md
---id: selection-treatmentstatus: ruled---A selected row is filled with accent-soft, never marked by a bar.Only ruled passes. A proposed ruling is not yet ruled; a superseded
one names its replacement; a retired one is no longer in force. Two
components that answer to the wrong rulings:
id: menunoun: Menuruling: "@ruling:old-menu"owners: [web/src/menu/**]implementations: web: web/src/menu/Menu.tsx apple: n/aid: toastruling: "@ruling:toast"owners: [web/src/toast/**]implementations: web: "n/a: the web app shows inline banners instead"design-system/components/menu.yaml:4: error component-unruled: component menu: ruling old-menu is superseded by menu; point ruling at @ruling:menu (ruling)design-system/components/toast.yaml:3: error component-unruled: component toast: ruling toast is proposed, not yet ruled; a component answers to a ruled ruling (ruling)A ruling the Gantry project has no record of is reported too, naming the
gantry.yaml it looked in. With no Gantry project, all three components
above would pass this rule: the check is syntax only.
4. Implementations and n/a
Section titled “4. Implementations and n/a”implementations says where each platform builds the component, and
component-incomplete holds it to
being complete and true:
- every platform that declares
consumersneeds an entry; - every key must be a configured platform;
- every value is a repo-relative file that exists (not a folder, and not
a symlink or a path through one), or
n/a: <reason>saying why that platform does not build it. A baren/a, orn/a:with nothing after it, says nothing and is reported.
menu.yaml above names a file that does not exist and gives apple no
reason; toast.yaml has no apple entry at all:
design-system/components/menu.yaml:7: error component-incomplete: component menu: implementations.web: web/src/menu/Menu.tsx does not exist; implementations are checked, so name the file that builds the component (implementations.web)design-system/components/menu.yaml:8: error component-incomplete: component menu: implementations.apple: n/a needs a reason: "n/a: <why this platform does not build it>" (implementations.apple)design-system/components/toast.yaml:5: error component-incomplete: component toast: platform apple declares consumers, but implementations has no apple entry; name the file that builds the component there, or "n/a: <reason>" (implementations)The check is that the file exists, not that it builds the component.
5. hostedBy
Section titled “5. hostedBy”hostedBy names the container a component lives in: a split button’s
menu half is hosted by the button.
id: split-buttonnoun: Split buttonruling: "@ruling:button"hostedBy: buttonowners: [web/src/button/**]implementations: web: web/src/button/Button.tsx apple: "n/a: the Mac app uses a pull-down button"A hostedBy that names no component is component-incomplete. So is a
chain of hosts that never ends: if button also said hostedBy: split-button, the cycle is reported once, at its first member in id
order, naming every member (hostedBy cycles: button → split-button → button), rather than once per component.
6. airframe show <component>
Section titled “6. airframe show <component>”show prints a component’s inventory, its ruling resolved against
Gantry, and who reads its tokens, from the same consumer scan lint runs:
$ airframe show buttonbuttonnoun: Buttonruling: @ruling:button (ruled)shared: falsehostedBy: -hosts: split-buttontokens: button-bg: component button-ink: componentowners: apple/Sources/Button*.swift web/src/button/**implementations: apple: apple/Sources/ButtonStyle.swift web: web/src/button/Button.tsxconsumers: apple: apple/Sources/ButtonStyle.swift: 2 references web: web/src/button/Button.tsx: 2 references--json prints the same fields with stable keys. A superseded ruling
carries its replacement in supersededBy, which is omitted otherwise:
$ airframe show menu --json{ "id": "menu", "noun": "Menu", "ruling": { "ref": "@ruling:old-menu", "status": "superseded", "supersededBy": "menu" }, "shared": false, "hostedBy": "", "hosts": [], "tokens": [], "owners": [ "web/src/menu/**" ], "implementations": { "apple": "n/a", "web": "web/src/menu/Menu.tsx" }, "consumers": {}}A ruling’s status is ruled, proposed, superseded or retired from
Gantry; unchecked with no Gantry project; missing when Gantry has no
such ruling; unreadable when its record did not read; and malformed
when the reference is not @ruling:<id>.
A name is looked up as a token first, then as a component. When it is
both, show prints the token and says on stderr how to get the
component: airframe show --component <name> forces component mode.
show exits 1 when there is no such token or component.
7. Retired tokens
Section titled “7. Retired tokens”A token is retired in its own file, with retired: true in its Airframe
extensions. It is still emitted, on every platform, so code that
reads it keeps compiling while it migrates. What
retired-used reports is reading it:
- a consumer reference to it, direct (
var(--legacy-ink),DesignTokens.legacyInk) or through a declared wrapper; - a non-retired token that aliases it directly, at that token. Only the first hop counts: a token that aliases a token that aliases a retired one is fixed by fixing the middle token, which is reported.
.app { color: var(--legacy-ink); background: var(--surface);}web/src/app.css:3:14: error retired-used: platform web: --legacy-ink is token legacy-ink, which is retired; it is still emitted so code compiles while it migrates, but nothing may read it: read what replaced it8. Retired treatments: retired.yaml
Section titled “8. Retired treatments: retired.yaml”A treatment with no token to delete is held by how it is spelt. The file is optional, a list of entries:
- id: flush-left-selection-bar ruling: "@ruling:selection-treatment" spellings: css: ["inset 3px 0 0"] swift: ["\\.frame\\(width: 3\\)"] marker: audited-selection-barid(required) is kebab-case and unique in the file.ruling(optional) is checked like a component’s: its shape always, and against Gantry when there is a Gantry project.spellings(required) maps an adapter name (css,swift,kotlin,xamlorcs, the consumer adapters of the consumers guide) to a non-empty list of RE2 patterns. Each pattern is matched against the consumer files that adapter reads, so acssspelling is looked for in stylesheets and in.tsx,.htmland the other web files.- Spellings are RE2 regexes, not literals: escape
. ( ) [ ] { } * + ? | ^ $ \with\, so the Swift.frame(width: 3)is the pattern\.frame\(width: 3\). - Single-quoted YAML keeps
\as typed:swift: ['\.frame\(width: 3\)']. - Double quotes need
\\for each\:swift: ["\\.frame\\(width: 3\\)"], as above.
- Spellings are RE2 regexes, not literals: escape
marker(optional) is the treatment’s own escape word (§9).
airframe schema retired prints the file’s JSON Schema, and airframe fmt formats it. A spelling in a component’s code is a finding, naming
the treatment and its ruling:
export const Row = () => <li style={{ boxShadow: "inset 3px 0 0 var(--accent)" }} />;web/src/row.tsx:2:51: error retired-used: platform web: "inset 3px 0 0" is a spelling of retired treatment flush-left-selection-bar (@ruling:selection-treatment), matched by css pattern "inset 3px 0 0"; it must not come back: use what replaced it, or mark an audited use with audited-selection-bar: <reason> (or airframe-exempt retired-used: <reason>)9. Treatment markers
Section titled “9. Treatment markers”An audited use is escaped by the treatment’s marker followed by a
reason, audited-selection-bar: <reason>, or by the generic
airframe-exempt retired-used: <reason>:
.mail-row { /* was: box-shadow: inset 3px 0 0 var(--accent); */ box-shadow: inset 3px 0 0 red; /* audited-selection-bar: email clients ignore custom properties, see #42 */}- A marker works only inside a comment, on the matched line or alone
on the comment-only line above it, as
airframe-exemptmarkers are placed. The same word in code or in a string marks nothing. - It needs a reason. A marker with none escapes nothing, and the finding says so.
- Every escape is listed in the gate JSON’s
exemptions, with its file, line and reason, therule(retired-used) and themarkerword that escaped it, so an audited use is visible in review. - Stylesheet comments are blanked before spellings are matched, so
the commented-out
was:line above does not fire.
10. The rules
Section titled “10. The rules”| Rule | Default | Fires on |
|---|---|---|
component-unruled |
error | a component with no ruling, or one not @ruling:<id>; with Gantry, a ruling that does not exist or is not ruled; the same for a retired.yaml entry’s ruling; a ruling record that does not read |
component-incomplete |
error | an implementations key that is no configured platform; a platform with consumers and no entry; a value that is neither an existing file nor n/a: <reason>; an unknown hostedBy; a hostedBy cycle, once |
retired-used |
error | a consumer read of a retired token, direct or through a wrapper; a token that aliases a retired token directly; a retired.yaml spelling in a consumer file |
Each reports what it checked: in text output a tally line such as
component-unruled 5 components and retired treatments, and in --format gate a check with a scanned count. A rule with nothing to check says
why (n/a (no components declared)), and the gate’s self-test checks
that each still fires on a fixture built to trip it and stays silent on
a clean one.
Limits
Section titled “Limits”- Spellings match one line at a time. A treatment written across two
lines (
box-shadow:on one,inset 3px 0 0on the next) is not seen. Write patterns for the form your code is formatted in. - Code-file comments are not blanked. Only stylesheets have their
comments blanked, so
// was: inset 3px 0 0in a.tsxfile is a match. A marker comment that repeats the spelling in a code file is itself a match, so it does not exempt the line below it: put the marker on the matched line. - Rulings are read, not judged. Airframe checks that the ruling exists and is ruled, not that it says anything about the component.
- Implementations are checked to exist, not to build the component.
Upgrading from v0.6.0
Section titled “Upgrading from v0.6.0”v0.6.0 accepted ruling and implementations without checking them, so
a v0.6.0 project with components fails lint after the upgrade until each
component file has:
- a
ruling,"@ruling:<id>"(resolved against Gantry when agantry.yamlis present; syntax only otherwise), or it iscomponent-unruled; - an
implementationsentry for every platform that declaresconsumers: the file that builds the component there, or"n/a: <reason>", or it iscomponent-incomplete.
A token already marked retired: true (v0.6.0 parsed the flag and did
nothing with it) is now retired-used wherever consumer code reads it or
a token aliases it directly. Nothing else changes: owners, shared and
the consumer rules behave as in v0.6.0.
airframe lint --format gate (the c65llc/airframe@v0 Action with
args: lint --format gate) runs these rules with every other rule: a
finding fails the gate, and the JSON lists each rule’s scanned count and
every honoured exemption, treatment markers included.