Skip to content

feat(brand-evolution): per-target design-token extraction + wayback CDX fix#84

Open
drewstone wants to merge 2 commits intomainfrom
feat/brand-evolution-and-wayback-fix
Open

feat(brand-evolution): per-target design-token extraction + wayback CDX fix#84
drewstone wants to merge 2 commits intomainfrom
feat/brand-evolution-and-wayback-fix

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

Summary

Two additions on top of the freshly-merged jobs+reports infra (#83):

1. Brand-kit / design-system extraction at every audit target. Comparative-audit jobs now optionally run the existing deterministic `extractDesignTokens` after each audit, persisting `tokens.json` alongside `report.json`. Combined with wayback discovery, this means a single declarative spec produces a full chronological brand evolution for any site.

2. Wayback CDX fix. The previous `limit` param truncated CDX results before `sampleEvenly` ran, so longitudinal jobs over popular sites returned all snapshots clustered in the early window. Replaced with `collapse=timestamp:6` (one capture per month), which bounds payload size while preserving the full window.

What you get

```json
{
"discover": { "source": "wayback", "urls": ["https://stripe.com/"], "snapshotsPerUrl": 3, "since": "2014-01-01", "until": "2024-01-01" },
"audit": { "pages": 1, "extractTokens": true }
}
```

`bad jobs create --spec wayback-tokens.json` → 3 audits + 3 token bundles.
`bad reports generate --template brand-evolution --job ` →

2014-01-02

Top colors: `#6f7c82` ×989 · `#0e3c5654` ×356 · `#008cdd` ×168 · `#292e31` ×90 …
Font families: "Whitney SSm A" (heading), "Lucida Grande" (body)
Type-scale entries: 25

2019-01-01

Top colors: `#6772e5` ×2654 · `#000000` ×1917 · `#525f7f` ×1782 …
Font families: Camphor (heading), Source Code Pro (mono)
Type-scale entries: 38

Δ vs 2014-01-02: +52 new colors · −21 removed · + Camphor, Source Code Pro · − Whitney, Lucida Grande · brand meta: title, description, favicon, ogImage changed

2024-01-01

Top colors: `#425466` ×52139 · `#0a2540` ×33868 · `#635bff` ×19520 …
Font families: sohne-var (heading), Helvetica Neue (body)
Type-scale entries: 61

Δ vs 2019-01-01: +65 new colors · −45 removed · + sohne-var, Helvetica Neue · − Camphor, Open Sans, Source Code Pro · brand meta: …

That's the actual stripe.com brand evolution — Whitney → Camphor → sohne-var, primary blue `#008cdd` → purple `#6772e5` → indigo `#635bff`. Pure deterministic DOM extraction. No LLM.

What's in it

```
src/jobs/types.ts AuditOptions.extractTokens, JobResultEntry.tokensPath
src/jobs/queue.ts AuditFn return adds tokensPath
src/cli-jobs.ts wires extractDesignTokens after each audit
src/reports/tokens.ts aggregateTokens / diffTokens / groupByUrl (pure)
src/reports/templates.ts renderBrandEvolution
src/reports/tools.ts fetchTokens + diffTokens AI SDK tools
renderTemplate accepts 'brand-evolution'
src/discover/wayback.ts CDX collapse=timestamp:6 (was: limit=count*4)
```

Tests

+12 across `reports-tokens` and queue/tools touch-ups. Total: 1460 passing (up from 1448).

Test plan

  • `pnpm lint` clean
  • `pnpm check:boundaries` clean (152 files)
  • `pnpm test` 1460/1460
  • CDX fix verified: stripe.com 2012-2024 with count=5 → 2012-02, 2015-03, 2018-03, 2021-02, 2024-01
  • End-to-end real run: 3 stripe.com wayback snapshots audited + tokens extracted, brand-evolution report rendered with correct typeface/color progression
  • Tier1/Tier2 gates green in CI

Notes

  • Token extraction is additive — failures are warned and never block the parent audit
  • The fix branch was named `fix/wayback-collapse-not-limit` originally and renamed to `feat/brand-evolution-and-wayback-fix` after layering the brand work

A wayback-source job with since=2012, until=2024, snapshotsPerUrl=4 against a
popular site returned all four snapshots clustered in 2012-2013, not spread
across 2012-2024. CDX's `limit` truncates captures *before* we sample, so for
sites with thousands of captures the first 50 chronologically are all in the
start of the window.

Drop `limit`, use `collapse=timestamp:6` (one capture per month). Bounded by
window length, properly distributed.

Verified: stripe.com 2012-2024 with count=5 → 2012-02, 2015-03, 2018-03,
2021-02, 2024-01.
…ution template

Adds AuditOptions.extractTokens. When true, every target in a comparative-audit
job runs the existing deterministic extractDesignTokens after the audit and
persists tokens.json to the per-target output dir. The runner threads
tokensPath through JobResultEntry.

src/reports/tokens.ts — aggregateTokens / diffTokens / groupByUrl. Pure
functions over on-disk data. Same contract as aggregate.ts.

renderBrandEvolution renders per-URL chronological evolution with
snapshot-to-snapshot deltas (colors added/removed, font family swaps,
brand-meta changes, library adoption).

AI SDK tools: fetchTokens, diffTokens. renderTemplate gains
template: 'brand-evolution'.

Verified on stripe.com 2014→2024: Whitney → Camphor → sohne-var
progression, primary color #008cdd → #6772e5 → #635bff, type-scale
grew 25 → 38 → 61 entries.

+12 tests. Total: 1460 passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant