chore(memory): capitalize ⚠ WinAnsi hotfix — LRN-021 + EVAL-003 + journal
- LRN-021: pdf-lib StandardFonts use WinAnsi (cp1252) — any non-Latin-1 codepoint throws on measure or draw. Fix paths: ASCII surrogate (quick) or embed TTF via pdfDoc.embedFont (right). CLAUDE.md spec prescribed TTF; current StandardFonts is a documented drift. - EVAL-003: bug slipped past 154/154 CI because roundtrip tests had no observation with a requires_vet_referral leaf. Regression test now measures a prefixed label via widthOfTextAtSize to canary any future non-WinAnsi marker reintroduction. - journal 2026-05-21 appended with the hotfix note and the TTF-migration follow-up.
This commit is contained in:
1 parent
143fdc3208
commit
f4bb7cf9e0
3 files changed
+21
No files matched your search
@@ -19,3 +19,12 @@ Method: cavecrew-reviewer ran against full diff `0a05c47..HEAD` after self-revie
|
||||
Result: reviewer flagged 3 CRITICAL: pdf/import.ts:9, pdf/attachment.ts:9-10, app/routes/HomeRoute.tsx:32 — hardcoded FR error messages leaking to EN UI.
|
||||
Anomaly: prior i18n grep ('Annuler', 'Valider', etc.) missed these because the error-path files contained different French vocabulary ("Ce PDF n'a pas été..."). Implementer's TODO checklist did not include the PDF import error paths since they were not in the original component migration list. Analyzer also missed because the leak only surfaces under EN locale at runtime (no static signal in code).
|
||||
Action: fixed in d602726+next via typed ImportError discriminant (BDR-015). Future i18n migrations should enumerate ALL files that emit user-facing strings (not just components/routes) — include error path files, exception messages, anything that may end up in window.alert or setError.
|
||||
|
||||
---
|
||||
|
||||
## EVAL-003 | 2026-05-21 | PDF vet-marker ⚠ WinAnsi crash slipped past CI
|
||||
|
||||
Method: user manual export of a v2.0 horse report containing requires_vet_referral leaves → `EditorRoute.tsx:263 PDF export failed Error: WinAnsi cannot encode "⚠" (0x26a0)`.
|
||||
Result: 154/154 tests stayed green; bug shipped to user-facing path. Static signal absent (the ⚠ literal was visible in the source but typecheck/lint don't flag font-encoding issues).
|
||||
Anomaly: pdf.roundtrip.test.ts exercised export with empty observations + no vet findings. The ⚠ prefix was added in 60e1b04-era (`observationPage.ts:407` ternary) without a regression case covering a flagged leaf.
|
||||
Action: hotfix swapped ⚠ → `(!) ` (WinAnsi-safe). Added regression `vet-referral marker is encodable by the body font` that calls `widthOfTextAtSize` on a prefixed label — would catch any future non-WinAnsi marker. LRN-021 captured the pdf-lib StandardFonts WinAnsi limitation. Follow-up: switch PDF body to embedded TTF (Inter/Fraunces per CLAUDE.md spec) so the catalog can carry arbitrary glyphs — out of hotfix scope.
|
||||
@@ -74,6 +74,7 @@ User dropped catalog v1.2→v2.0 in place. pathologies.json now schema_version "
|
||||
- BDR-016 (v2.0 catalog adoption), LRN-020 (forward-compat schema absorbed change), BLK-002 resolved capitalized.
|
||||
- TODO Phase C item 1 "Author full horse.json" → done. B4 still has scope_disclaimer footer decision open.
|
||||
- NEXT: B4 disclaimer footer call + C QA + Scaleway deploy.
|
||||
- hotfix(pdf): PDF export crashed `WinAnsi cannot encode "⚠"` on any obs carrying a requires_vet_referral leaf — StandardFonts.Helvetica is WinAnsi-only. Swapped `⚠ ` PDF marker → `(!) ` (UI keeps ⚠). Regression test added on `widthOfTextAtSize` + prefixed label. LRN-021, EVAL-003 captured. 155/155 green. Follow-up: migrate PDF body to embedded TTF (Inter/Fraunces per CLAUDE.md spec) so future non-Latin-1 glyphs work.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -156,6 +156,17 @@ Inline is simpler when the helper is one expression. Apply: any closure that bri
|
||||
|
||||
---
|
||||
|
||||
## LRN-021 | 2026-05-21 | pdf-lib StandardFonts use WinAnsi — Latin-1 only, throws on any non-WinAnsi char
|
||||
|
||||
`PDFDocument.embedFont(StandardFonts.Helvetica)` (and the 13 other Adobe built-ins) returns a font whose encoding is WinAnsi (cp1252). Any text op (`widthOfTextAtSize`, `drawText`) on a string carrying a non-WinAnsi codepoint throws synchronously: `WinAnsi cannot encode "<glyph>" (0x<hex>)`. Common offenders: ⚠ U+26A0, → U+2192, ✓ U+2713, ★, em-dash variants outside cp1252, all CJK. The error surfaces at the FIRST measurement pass (text-height estimator) — well before any draw call — so even a `try/catch` around drawing won't save you.
|
||||
Fix paths:
|
||||
- Quick: replace the offending glyph with a WinAnsi-safe ASCII surrogate (`(!) ` instead of `⚠ `, `->` instead of `→`).
|
||||
- Right: embed a TTF (Inter, NotoSans, Fraunces…) via `pdfDoc.embedFont(ttfBytes)`. pdf-lib then subsets the actually-used glyphs into the PDF; arbitrary Unicode works. Per CLAUDE.md spec our PDF should already use TTFs — current StandardFonts shipment is a drift.
|
||||
**Why:** Slipped past CI because the existing PDF roundtrip tests exercised observations without vet-referral findings; the WinAnsi error only fires when the offending glyph is present in a measured string.
|
||||
**How to apply:** When a new visual cue (icon, badge, arrow) is added to PDF output, either restrict to ASCII or audit the font path. Add a regression test that exercises the measurement path with a representative string. The cheap canary: `font.widthOfTextAtSize(candidateGlyph, 10)` in a test.
|
||||
|
||||
---
|
||||
|
||||
## LRN-020 | 2026-05-21 | Forward-compat Zod schema absorbs catalog version bump zero-code
|
||||
|
||||
Catalog JSON went v1.2→v2.0 (semantic breaking change per author doc), but `findings.ts` Zod schema declared `requires_vet_referral` boolean + `description_fr` optional from B0 day-one. Result: v2.0 file dropped in, parses clean, 154/154 tests stay green, no schema edit, no consumer rewrite. Picker + PDF already keyed on boolean (no textual `description_fr.includes('vétérinaire')` fallback ever existed in our code), so the v2.0 "removed redundant text" change is a no-op at consumption site. Lesson: when authoring a Zod schema for external content, mark anything that "might or might not" appear as `.optional()` + make booleans authoritative early. The schema then forms a stable contract that absorbs author-side simplifications without code churn.
|
||||
|
||||
Reference in new issue
Block a user