8000 feat(autofix): font-display-swap — measurement-picked repair by jangtrinh · Pull Request #200 · jangtrinh/design-os · GitHub
[go: up one dir, main page]

Skip to content

feat(autofix): font-display-swap — measurement-picked repair - #200

Merged
jangtrinh merged 2 commits into
mainfrom
feat/font-display-autofix
Aug 19, 2026
Merged

jangtrinh merged 2 commits into
mainfrom
feat/font-display-autofix

Conversation

@jangtrinh
Copy link
Copy Markdown
Owner

The born-passing A/B (plans/reports/evaluation-260819-2016) identified font-display-missing as the ONE floor that teaching could not move (6→6 across both knowledge arms — generators pick fonts before thinking about loading behaviour). Per the triage doctrine: a floor teaching can't move and a machine can fix belongs to autofix.

  • @font-face without the descriptor → font-display: swap; inserted as first declaration (existing author choices respected via the shared checker gate — checker and repair share checkFontDisplayMissing).
  • Google-Fonts <link> hrefs without display= → &display=swap / ?display=swap appended.
  • Non-markup mask discipline: quoted samples in <pre>/<code>/scripts never rewritten.

Measured on the A/B corpus: 12→0 findings in one pass. Red-first tests (author-choice respect, ?/& forms, pre/code exclusion, idempotency, runAutofix registration); catalog row with repair subject (the catalog pairing test derives autofix ids from RULES, so the row was mandatory, not optional). Gates: typecheck, lint, build, 3620 passed / 203 files.

🤖 Generated with Claude Code

…could not move

The born-passing A/B (evaluation-260819-2016) showed font-display-missing
as the one floor knowledge-teaching did not shift (6→6 across arms): a
generator picks fonts before it thinks about loading behaviour, so this
floor belongs to the machine. fixFontDisplaySwap inserts font-display: swap
as the first declaration of @font-face blocks lacking the descriptor and
appends display=swap to Google-Fonts hrefs (? vs & handled); both edits
locate on the non-markup mask so quoted samples in pre/code are never
rewritten, and the repair is gated by the same checkFontDisplayMissing that
reports the finding. On the A/B corpus: 12→0 findings in one pass.

Registered in RULES, the check catalog (with its repair subject), and the
autofix help; red-first tests including author-choice respect, ?/& href
forms, pre/code exclusion, and idempotency.
…, index-anchored

The checker and repair now read ONE world (blankDeadMarkup in
taste-checks-shared: scripts + comments dead, pre/code elements live — the
HTML parser instantiates them, so the checker was right and the repair's
mask was wrong): only rel~=stylesheet links flag or get rewritten (a
preconnect hint to the fonts origin is correct markup — Google's own
canonical snippet was being rewritten, and the same false positive existed
in the checker as a warning all along); @font-face repairs scan real CSS
regions only (style blocks + style attributes), so prose quoting CSS in a
paragraph is never edited; href edits locate by /d capture indices, killing
the indexOf class where a duplicate URL in another attribute received the
edit forever (unbounded growth + permanent autofix-not-clean);
&amp;display= counts as compliant on both sides; overlapping edits are
skipped defensively (a miss beats corruption).

Red-first fixtures for every blocker shape, each asserting CHECKER AND
FIXER agree; the phantom entity-encoded pre test replaced. Adversarial
E2E: triple --write converges after one pass, preconnect and prose intact,
the A/B corpus still goes 12→0.
@jangtrinh
Copy link
Copy Markdown
Owner Author

Stage-4 review resolved (fix round in 1f2b0d1 — every blocker fixture ships red-first, asserting checker AND fixer agree):

  • B1: rel~=stylesheet gate on BOTH sides (shared-layer fix — the preconnect rewrite was riding a pre-existing checker FP; Google's canonical snippet now passes untouched, warning included).
  • B2: @font-face repairs scan real CSS regions only (style blocks + style attributes) — prose quoting CSS is never rewritten; the family invariant holds again.
  • B3: href edits locate via /d capture indices — the duplicate-URL tag converges in one pass (probe: triple --write, passes 2–3 apply 0 fixes; no growth, no permanent autofix-not-clean).
  • H1 ruled + unified: blankDeadMarkup in taste-checks-shared is the ONE mask (scripts/comments dead; pre/code elements LIVE — the parser instantiates them, so the checker was right and the fixer's mask was what moved). All five divergence shapes now agree on both sides.
  • H2: &amp;display= compliant on both sides. H3: phantom test replaced with fixtures that pair every rewrite/no-rewrite claim with the checker's verdict. M1 (data-href) killed by the indices fix; M2 overlap guard added (skip, miss-beats-corruption); M4 changelog states exactly which measurement produced 12→0.

Re-verified: A/B corpus still 12→0 in one pass; adversarial file (preconnect + dup-URL + brace-in-font-url + prose snippet) converges with correct output. Gates: typecheck, lint, build, 3625 passed / 203 files.

On the unresolved pre/code question: ruled as the checker's semantics — elements in <pre> are live per the HTML parser; displayed code samples are entity-encoded in practice and match no tag. Noted for a follow-up sweep: the focus-outline class-token pass still blanks pre/code (shipped in #195) — same doctrine question, left untouched here to keep this round scoped.

@jangtrinh
jangtrinh merged commit 5c0924c into main Aug 19, 2026
4 checks passed
@jangtrinh
jangtrinh deleted the feat/font-display-autofix branch August 19, 2026 13:51
jangtrinh added a commit that referenced this pull request Oct 29, 2026
* feat(autofix): font-display-swap — the repair for the floor teaching could not move

The born-passing A/B (evaluation-260819-2016) showed font-display-missing
as the one floor knowledge-teaching did not shift (6→6 across arms): a
generator picks fonts before it thinks about loading behaviour, so this
floor belongs to the machine. fixFontDisplaySwap inserts font-display: swap
as the first declaration of @font-face blocks lacking the descriptor and
appends display=swap to Google-Fonts hrefs (? vs & handled); both edits
locate on the non-markup mask so quoted samples in pre/code are never
rewritten, and the repair is gated by the same checkFontDisplayMissing that
reports the finding. On the A/B corpus: 12→0 findings in one pass.

Registered in RULES, the check catalog (with its repair subject), and the
autofix help; red-first tests including author-choice respect, ?/& href
forms, pre/code exclusion, and idempotency.

* fix(autofix): font-display round — one mask contract, stylesheet-only, index-anchored

The checker and repair now read ONE world (blankDeadMarkup in
taste-checks-shared: scripts + comments dead, pre/code elements live — the
HTML parser instantiates them, so the checker was right and the repair's
mask was wrong): only rel~=stylesheet links flag or get rewritten (a
preconnect hint to the fonts origin is correct markup — Google's own
canonical snippet was being rewritten, and the same false positive existed
in the checker as a warning all along); @font-face repairs scan real CSS
regions only (style blocks + style attributes), so prose quoting CSS in a
paragraph is never edited; href edits locate by /d capture indices, killing
the indexOf class where a duplicate URL in another attribute received the
edit forever (unbounded growth + permanent autofix-not-clean);
&amp;display= counts as compliant on both sides; overlapping edits are
skipped defensively (a miss beats corruption).

Red-first fixtures for every blocker shape, each asserting CHECKER AND
FIXER agree; the phantom entity-encoded pre test replaced. Adversarial
E2E: triple --write converges after one pass, preconnect and prose intact,
the A/B corpus still goes 12→0.
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

0