fix(pdf): candidates sorted by data offset, JSON depth pre-scan before parse, budget wording; chore(memory): BLK-009 mitigated with gate, EVAL-014, journal, TODO, CLAUDE.md import notes

This commit is contained in:
bchanot committed 2026-10-11 17:31:07 +02:00
1 parent 3a6e92625a
commit 62b2b9d86a
9 files changed
+188 -30

No files matched your search

+3 -1
View File
@@ -269,7 +269,8 @@ PDF export (app side: apps/app/src/pdf, engine: packages/pdf)
PDF import
→ importReportFromPdf(bytes, migrationMap) → readReportArchive (engine)
→ attachment osteo-report* first → layered reading: report (v3 as is, v2 migrated, else incompatible_version),
→ byte scan for the EmbeddedFile stream (no pdf-lib parse on untrusted bytes, BLK-009): named osteo-report* first,
capped native inflation → layered reading: report (v3 as is, v2 migrated, else incompatible_version),
envelope metadata tolerant, snapshot/branding/labels strict → archive kept or snapshotRejected (closed reason)
→ rebaseReportOnSheet(report, index, archivedSnapshot) when the loaded sheet differs (unresolved flags, labels kept)
→ hydrateImport({ report, archive }) → one alert (archive_ok / snapshot_rejected / rebased / migrated) → navigate /editor
@@ -430,6 +431,7 @@ Database (Supabase)
- Never modify the legacy sources under `supabase/seed/anatomical-sheets/equine/legacy-sources/` — they are the
importer's input (the user's historical files).
- Ask before any change to `readReportArchive`, `readArchiveDocument`, `readAttachedDocument` or `rebaseReportOnSheet` — they handle user data; archive readers never drop a schema version (envelope v1, Report v2/v3, sheet document v2).
- Import never parses untrusted PDF object graphs: the attachment is located by byte scan and inflated under the 16 MiB cap (BLK-009). Opening the import to external users is gated by `docs/development/PDF_IMPORT_HARDENING.md` §5 (BDR-040).
- After PDF roundtrip tests fail: check attachment bytes, then the layered reader (report first, envelope metadata, snapshot/branding/labels), then DecompressionStream inflation. Goldens under `apps/app/tests/fixtures/goldens/step6` are never regenerated without a user decision.
- Node 24 / pnpm 10.13.1: `corepack enable` or `corepack pnpm`; never a global install.
- SQL change: `pnpm --filter @faunosteo/supabase test:run` (PGlite) before commit; `pnpm db:reset && pnpm db:test`