fix(format): decide on frontmatter after the repairs, so a second pass changes nothing #290

Merged
abiwab merged 1 commit from fix/format-frontmatter-after-repairs into main 2026-11-26 21:40:46 +01:00
Owner

Follow-up of #285 (#284), unreleased: no new changeset, the pending format-fenced-block-not-frontmatter one still describes the behavior.

#285 decided whether the fenced block opening the file is frontmatter by parsing the raw source, before the repairs (rules 6-8). When only the repairs make the file readable (^ < @eggs), the first pass kept the block as frontmatter, and the second pass, on repaired text, found spans inside it and formatted it as body: format-idempotent violation (fuzz seed 1572729094, index 1472), e.g. au Jean@Example.com lowercased only at the second pass.

  • Rules 6-8 move into repair(). The body of the textual split is repaired first, then the repaired text is parsed once: a span inside the fenced block makes it body, repaired in turn and parsed again. A real frontmatter now costs no extra parse (#285 parsed twice).
  • Tests: one in packages/format/tests/formatter.test.ts and fuzz/regressions/284-fenced-block-repaired.gram (both fail on main).

Checks: 3939 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, deprecations:check, fuzz 50k (seed 3061316216, 0 signature); the earlier fuzz inputs of #284 and #286 still pass. Audit 127 (126 on main): the new flag is the test's deliberate ^ < @eggs parse failure, the input the repair exists for.

Follow-up of #285 (#284), unreleased: no new changeset, the pending `format-fenced-block-not-frontmatter` one still describes the behavior. #285 decided whether the fenced block opening the file is frontmatter by parsing the raw source, before the repairs (rules 6-8). When only the repairs make the file readable (`^ < @eggs`), the first pass kept the block as frontmatter, and the second pass, on repaired text, found spans inside it and formatted it as body: `format-idempotent` violation (fuzz seed 1572729094, index 1472), e.g. `au Jean@Example.com` lowercased only at the second pass. - Rules 6-8 move into `repair()`. The body of the textual split is repaired first, then the repaired text is parsed once: a span inside the fenced block makes it body, repaired in turn and parsed again. A real frontmatter now costs no extra parse (#285 parsed twice). - Tests: one in `packages/format/tests/formatter.test.ts` and `fuzz/regressions/284-fenced-block-repaired.gram` (both fail on main). Checks: 3939 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, `deprecations:check`, fuzz 50k (seed 3061316216, 0 signature); the earlier fuzz inputs of #284 and #286 still pass. Audit 127 (126 on main): the new flag is the test's deliberate `^ < @eggs` parse failure, the input the repair exists for.
fix(format): decide on frontmatter after the repairs, so a second pass changes nothing
All checks were successful
CI / Build & Test (pull_request) Successful in 4m53s
643973c4ce
abiwab merged commit 8868db2189 into main 2026-11-26 21:40:46 +01:00
abiwab deleted branch fix/format-frontmatter-after-repairs 2026-11-26 21:40:46 +01:00
Sign in to join this conversation.
No description provided.