Skip to content

feat(diff): compare computed values canonically — a re-serialization isn't a change#161

Merged
BenSheridanEdwards merged 2 commits into
mainfrom
feat/canonicalize-values
Jul 5, 2026
Merged

feat(diff): compare computed values canonically — a re-serialization isn't a change#161
BenSheridanEdwards merged 2 commits into
mainfrom
feat/canonicalize-values

Conversation

@BenSheridanEdwards

Copy link
Copy Markdown
Owner

What and why

StyleProof stops reporting a change when the browser merely re-serialized an identical
value.
Dogfooding a real re-baseline exposed it: a newer Chromium rewrote
rgba(8, 18, 32, 0.62) as #0812209e, a Tailwind migration reformatted a font list's
comma spacing — and the diff flagged every one as a difference, drowning the review in
changes that aren't changes and blowing the report up to hundreds of MB. A green flickered
red purely across browser/build versions.

The diff now compares by a canonical form: colours parse to one rgba() (hex / rgb /
rgba / hsl / hsla, short + long hex, comma + modern space syntax), and comma/whitespace
runs normalize outside quotes. Captures become serialization-independent — the root fix
for re-baseline noise, at the diff, not the report.

Safety bar — only provably-equal values collapse. An unparseable value (or anything
inside a quoted string) is left byte-for-byte, so a real change always still surfaces. The
report shows the real captured strings; only the equality test is canonical. Custom props
stay ignored; content/text diffs stay exact.

Stacks on #160 (3.14.0) → this is 3.15.0. Merge #160 first; I'll rebase if needed.

Proof (required)

Screenshots Not applicable — diff-logic change, no browser surface. Receipts in
test/canonicalize.test.mjs:

✓ equal spellings collapse: rgba(8,18,32,0.62) ~ #0812209e, rgb~#f00, hsl(0,100%,50%)~red,
  "…",ui-mono ~ "…", ui-mono, rgb(8 18 32 / .62) ~ rgba(...)
✓ real changes NEVER collapse: #ff0000≠#ff0001, alpha .5≠.6, 10px≠11px, red≠blue, diff font
✓ quoted / unparseable left byte-for-byte: "#fff" untouched, rgb(var(--x)) untouched
✓ diffStyleMaps: a serialization-only difference → 0 findings; a real colour change → a finding

Full suite 255/255no existing diff test regressed (nothing relied on treating a
re-serialization as a change). build / typecheck / lint / format:check clean.

Checklist

  • Proof above (unit + integration regression tests); screenshots N/A with reason
  • build && typecheck && lint && format:check pass · npm test 255/255
  • Added test/canonicalize.test.mjs · Updated CHANGELOG ([3.15.0])
  • Safety: only provably-equal values collapse; report shows real strings
  • No bare screenshot links, local paths, relative paths, or placeholders

…isn't a change

Dogfooding a real re-baseline showed StyleProof reporting a flood of "changes" that
weren't: a newer Chromium serialized identical values differently — rgba(8, 18, 32, 0.62)
became #0812209e, a font list's comma spacing shifted — and every one read as a diff,
drowning the review and blowing the report up to hundreds of MB. A green flickered red
purely across browser versions.

Compare by a canonical form instead: colours parse to one rgba() (hex / rgb / rgba / hsl /
hsla, short+long hex, comma + modern space syntax), and comma/whitespace runs normalize
outside quotes. Captures become serialization-independent.

Safety bar — only PROVABLY-equal values collapse: an unparseable value (or anything inside
a quoted string) is left byte-for-byte, so a real change (#ff0000 → #ff0001, 0.5 → 0.6
alpha, a different font) always still surfaces. The report shows the real captured strings;
only the equality test is canonical. Custom props stay ignored; content/text diffs stay
exact.

Tests: test/canonicalize.test.mjs — equal spellings collapse, real changes never do,
quoted/unparseable left untouched, and diffStyleMaps yields zero findings for a
serialization-only difference. Full suite 255/255 (no existing diff test regressed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

🗺️ StyleProof report

📊 View the side-by-side visual report →


To accept: rebuild the map with styleproof-map, then rerun the report.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Fallow audit report

No GitHub PR/MR findings.

Generated by fallow.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Fallow audit report

0 inline findings selected for GitHub review.

@BenSheridanEdwards BenSheridanEdwards merged commit 598df30 into main Jul 5, 2026
7 checks passed
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