fix(contrast-audit): fail when the ruleset shrinks, not just when a theme fails - #262
Open
itsdestin wants to merge 2 commits into
Open
fix(contrast-audit): fail when the ruleset shrinks, not just when a theme fails#262itsdestin wants to merge 2 commits into
itsdestin wants to merge 2 commits into
Conversation
…heme fails The audit counted THEMES but never RULES, so removing a check made it quieter rather than louder. On 2026-07-22 PR #187 dropped `panel/canvas` and `on-destructive/destructive` while consolidating three hand-written tables; the audit went on printing "All 11 themes pass" while creme still shipped panel/canvas at 1.051 and every theme shipped a danger label at 4.21:1. Two open bug entries cited repro commands that had silently stopped reproducing — the next person to check them would reasonably have closed them as already fixed. The lesson recorded at the time was never mechanized: "a consolidation that removes checks needs a before/after count of rules evaluated, because a shrinking rule set is invisible in a green run." This adds that count. A green run must now also prove it CHECKED: - EXPECTED_RULES pins the per-tier table size (HARD 32 / SURFACE 6 / SOFT 3). Rule-table size is a property of the ruleset, not the theme — a rule with a missing token still reports status SKIP — so every theme must agree, and a disagreement is itself an error. - A rule SKIPPED for every theme fails the run. That was the second way the incident hid: destructive/on-destructive were skipped everywhere because most packs never declare those tokens, so the audit was green and blind. - The coverage line reports what ACTUALLY ran, not what was expected. Printing the expected count during a coverage failure would be the same class of lie this guard exists to catch. Verified both directions: clean run exits 0 and reports "coverage: 41 rules x 11 themes = 451 checks"; deleting the `panel vs canvas` rule (reproducing the real incident) exits 1 with "SURFACE: 5 rules evaluated, expected 6". The vendored rules file was restored byte-identical afterwards. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gap
The contrast audit counted themes, never rules. Removing a check therefore made it quieter, not louder.
On 2026-07-22, PR #187 consolidated three hand-written contrast tables and dropped
panel/canvasandon-destructive/destructivein the process. The audit went on printingAll 11 themes passwhile creme still shippedpanel/canvasat 1.051 and all 11 themes shipped a danger label at 4.21:1. Two open bug entries cited repro commands that had silently stopped reproducing — the next person to check them would reasonably have closed them as already fixed.The lesson was recorded in the ROADMAP at the time but never mechanized:
What this adds
A green run must now also prove it checked.
EXPECTED_RULESpins the per-tier table size (HARD 32 / SURFACE 6 / SOFT 3). Table size is a property of the ruleset, not the theme — a rule with a missing token still reportsstatus: SKIP— so every theme must agree, and disagreement is itself an error.destructive/on-destructivewere skipped for all themes because most packs never declare those tokens, so the audit was green and blind.Verification — both directions
Clean run (exit 0):
Reproducing the real incident — deleting the
panel vs canvasrule (exit 1):That same deletion printed
All 11 themes passbefore this change.The vendored
contrast-rules.jswas restored byte-identical after the test (git diff --statclean). No rule content changed in this PR — only the audit script.Note for reviewers
EXPECTED_RULESis meant to be bumped deliberately when rules are added. A change that lowers it is the review conversation this guard exists to force.wecoded-themes/scripts/audit-contrast.mjsis the CI-blocking sibling and has the same blind spot — worth the same treatment in a follow-up.🤖 Generated with Claude Code