drift measures the system a site ships
The app
The window below is drift's audit screen, on a saved crawl of two pages of picocss.com. A health line, a verdict per category, then a tab per category with every value, its count and the pages it appears on. In Colour, choosing a swatch opens a rail of its near-duplicates (less than CIEDE2000 ΔE 2 apart) and its alpha variants, so colours that should be one sit side by side.
The problem
A design file says what a system is meant to be. Over time the live site stops matching it, one value at a time, and checking pages one by one rarely shows where. drift crawls a site and reads every element, so the inventory is what the site actually renders, ranked by use. It is computed, with no model, so the same pages give the same audit.
Product decisions
Measure, never propose. Every value is reported against a stated reference (a modular ratio, a spacing grid, CIEDE2000 ΔE, WCAG 2.1) and the audit stops there. An earlier version also suggested fixes: a merged palette, a clean type scale, a spacing grid. It was cut, because drift's only reason for any of them was that the numbers came out neater, and a neater number is not a reason to change a product's design. drift can show what a site ships and how it measures; what to change is the team's call. I kept the parts that only measure: the selectable references, near-duplicate detection and the export.
A reference you pick. A size is off the scale only relative to a scale, so the type tab lists every named ratio with how many sizes miss it, and picking one redraws the ruler and the table. The automatic pick is the ratio the fewest sizes miss. The Overview stays on that automatic fit, so trying the golden ratio never rewrites the diagnosis.
Contrast, composited. Muted text is often written as a dark colour at partial alpha. Measured as written, #111 at 50% on white passes AAA; it renders as #888 and fails AA. drift composites the text over its nearest background before taking the ratio, and the export keeps the authored colour beside the resolved one, because the fix is made in the stylesheet.
| Text | Background | Renders as | Ratio | AA |
|---|---|---|---|---|
| #00000040% | #ffffff | Aa | 2.85:1 | fail |
| #11111150% | #ffffff | Aa | 3.54:1 | fail |
| #23728f | #23728f13% | Aa | 4.55:1 | pass |
| #ffffff80% | #1d4ed8 | Aa | 4.89:1 | pass |
| #00000060% | #ffffff | Aa | 5.74:1 | pass |
What was authored. getComputedStyle returns pixels: the authored unit is gone and custom properties are invisible. So each page is read twice, the computed styles for what rendered and the CSSOM for what was written. That is how the audit flags font sizes authored in px, which ignore a reader's font setting, and reports the site's own token names.
| Property | CSSOM (as written) | getComputedStyle |
|---|
An export for machines. The export is written for a CI job or a diff of two runs, not a person, so it leads with the judgement: the health line, typed findings with severity and evidence, a verdict per category, and the rules every number was measured against. A consumer given only counts would have to rebuild the verdicts. The inventory follows as evidence.
{
"health": "7 of 29 colours are near-duplicates, 6 of 9 type sizes fall off the scale, and 14 of 21 spacing values miss the 4px grid. No issues found in radius, shadows, and contrast.",
"findings": [
{
"id": "colour-near-duplicates",
"category": "colour",
"severity": "review",
"title": "7 of 29 colours are near-duplicates",
"count": 7,
"of": 29,
"evidence": [
{
"hex": "#ffffff",
"nearest": "#fbfcfc",
"deltaE": 0.8
},
{
"hex": "#fbfcfc",
"nearest": "#ffffff",
"deltaE": 0.8
}
]
}
]
}The interaction decisions are in DESIGN.md, and the measurement mechanisms in ARCHITECTURE.md.
Design system
I started drift on haus, the design system I publish, and after ten days gave it a design system of its own. drift audits other products' token layers, so its interface should not be an instance of one, and its look should not change when haus releases. It still uses haus's colour maths and style probe, which are analysis code rather than design.
The same layer is in drift's Figma file: 238 variables under the code's names, its text and effect styles, the five components, and every screen drawn from the running app. A parity check compares the two on every pull request: each token resolved to its final value in a headless browser, and each component's variants and states. Code that moves ahead of Figma fails the build.
Its own token layer. drift defines every custom property it reads, in seven cascade layers declared before any file opens one, so import order cannot change them. Every name is --drift-{category}-{name}. Primitives are named by value (--drift-type-leading-140), roles by job (--drift-radius-control), so the two read apart in one group. Components read roles only.
An accent from two numbers. drift's accent is not picked shade by shade. The ten-step ramp is generated in OKLCH from a hue (239, the blue) and a chroma, with each step's lightness fixed, so changing the hue retints every accent surface at once and each step keeps its job: 600 is the button, 700 and 800 its hover and press, 400 the link. Fixed lightness keeps white text on that step near 5:1, though for teals it falls just under AA.
Type roles by job. A role carries only the properties its element sets: the typeset roles set size, weight, leading and tracking, a table cell sets family and size and takes leading from its row. Faces are roles too, for interface, headings and code. A role that sets more than its element needs forces overrides, and every override is a primitive read.
Enforced, and accessible. The token tests fail any property a stylesheet reads that nothing defines: an undefined --duration-default once left five animations with no duration. The audit's tabs were tabs in name only until an audit found them; they are now a full tablist with arrow keys, and the end-to-end suite drives the audit by keyboard.
The token layer, the type roles and the checks are in DESIGN.md.
Engineering
A crawl runs in seven steps: five on the server, from finding the pages to auditing every value they use, and two in the client, which turn that audit into a diagnosis and an export.
One process, a queue. A crawl drives headless Chromium over a site of unknown size: it is slow, can fail part-way and outlives the request that started it. One Node process runs the Express API, the WebSocket progress server and a BullMQ worker; Redis holds the queue. Progress arrives over the socket, but completion is read from the API, so a dropped socket does not stall the client.
Ten pages, no retries. A crawl of a content site once ran the backend out of memory, and BullMQ re-ran the job on restart, which crashed it again. Every element of every page is kept until the audit runs, so the fix bounds that: ten pages, 12,000 elements a page, and each job runs once. Most values come from shared stylesheets, so a few pages find most of a site's values.
A guarded crawler. Every URL drift fetches comes from a caller, so each is a server-side request forgery risk. A host passes only when every address it resolves to is public, and the check runs on the site to crawl, on every request the browser makes (a public page can redirect, embed or load from anywhere), on sitemaps and on webhook callbacks. Exposed beyond loopback, the API takes a bearer token and rate-limits crawls.
// src/crawler/guard.ts: a public page can redirect, embed or load from anywhere
if (parsed.protocol === "data:" || parsed.protocol === "blob:") return "continue"
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return "abort"
// isCrawlableHost: every address the host resolves to must be public
return (await check(parsed.hostname)) ? "continue" : "abort"
// fetched with redirects off; each hop is checked again, at most five
if (hop === MAX_REDIRECTS) return falseA published contract. The client is one consumer of the API a CI job would use. openapi.yaml covers every endpoint, a contract test validates the app's responses against it, and it is published as an API reference. A CI job queues a crawl with a callback and gets the audit POSTed back, signed with an HMAC of the body. A crawl that reads no page fails with its reason rather than returning an empty audit, which a CI job would read as a clean site.
POST /crawl { "url": "https://example.com", "callbackUrl": "https://ci.example/hook" }
202 { "jobId": "…" }
# drift crawls, then POSTs the audit to the callback, signed:
# x-drift-event: crawl.completed (or crawl.failed, with a reason)
# x-drift-signature: sha256=<HMAC of the body>
GET /crawl/:jobId/result # the job’s state, if no callback arrives
GET /crawl/:jobId/audit # 409 until the crawl has completedTested from outside. A separate repository, drift-tests, runs 18 BDD scenarios over HTTP against a real server, Redis and Chromium, and imports nothing from drift. It runs on every drift pull request, against that change's own server, so a change that breaks the contract fails before it merges. It never touches the internet: drift crawls a fixture site on loopback, seeded with four faults it must report (a near-duplicate blue, off-grid padding, off-scale type and a failing contrast pair). The practice comes from pendula.
One scenario holds attribution: a finding citing four pages after a three-page crawl means a page was counted twice, which no single-page test can show.
# features/audit.feature
Feature: The audit
A completed crawl yields a deterministic audit of every design token actually
shipped: colours, type and spacing, with WCAG contrast findings and a summary.
The fixture site seeds known inconsistencies, so the audit's verdicts are
predictable run to run.
Background:
Given a completed crawl of the fixture site
Scenario: Colour and contrast findings cite only pages that were crawled
Then every colour and contrast finding cites only pages that were crawledThe processes, security, the audit's mechanisms and the tests are in ARCHITECTURE.md.
Where it stands
The public site replays the captured audit rather than crawling on demand, because a headless browser behind a queue is not safe to leave open to anonymous callers. What is open: a guard against DNS rebinding between the check and the fetch; folding each page into tallies as it arrives, which would lift the page cap; and a single viewport and resting states only, so breakpoints and hover styles go unseen.
The design notes are in DESIGN.md and the engineering notes in ARCHITECTURE.md.