The token audit — the interface twin of the kit validator. Two token
files are on deck: the approved set, and a draft a contractor sent
over at 11pm. Write audit_tokens(tokens) returning a list of fault
strings, checks in this order:
- Grid — for each value in
tokens["space"]that isn't a multiple ofBASE, in list order:"off-grid spacing: {v}" - Scale — for each adjacent pair
a -> bintokens["type"]whereb / ais less thanMIN_RATIO:"flat type step: {a} -> {b} (ratio {b/a:.2f})" - Text floor — if
textonbackgroundis under 4.5:1:"text contrast {c:.2f}:1 below 4.5:1" - Component floor — if
accentonbackgroundis under 3.0:1 (WCAG's non-text rule — the button floor):"accent contrast {c:.2f}:1 below 3.0:1"
contrast() is the one you wrote two drills ago, provided. The
harness prints SHIP for a clean set, REJECT plus the fault list
otherwise. Expected output:
halfmoon-app-v1: SHIP
halfmoon-app-v2-draft: REJECT
- off-grid spacing: 18
- flat type step: 16 -> 18 (ratio 1.12)
- text contrast 2.68:1 below 4.5:1
- accent contrast 1.78:1 below 3.0:1
The draft fails all four ways — sage text nobody can read, goldenrod buttons nobody can find, a typo'd margin, and a type step that isn't a step. Better a script says so tonight than a client tomorrow.