From 9cedaccbb31f7aaaeeed39930f69ad5061fd9ab6 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sat, 10 Oct 2026 16:06:00 +0200 Subject: [PATCH] chore(memory): EVAL-012, LRN-044, journal, TODO 5.8-5.10 closed --- .claude/memory/evals.md | 8 ++++++++ .claude/memory/journal.md | 2 ++ .claude/memory/learnings.md | 7 +++++++ .claude/tasks/TODO.md | 8 ++++---- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.claude/memory/evals.md b/.claude/memory/evals.md index dd00ff91..8e80a667 100644 --- a/.claude/memory/evals.md +++ b/.claude/memory/evals.md @@ -89,3 +89,11 @@ Method: golden v2 PDFs frozen from the old pipeline before any change; suites re Result: verifier pass 1 ECARTS(36) = 4 real (golden test not pinning the new generated files, EditorRoute 398 lines, 5 stale doc lines, one eslint-disable) + my contract omissions (scope files, deleted legacy suites) + floor noise ("species" matched "spec"); pass 2 ECARTS(4) = replacement assertions missing for 4 deleted suites; pass 3 ECARTS(4) = doc counts + 3 more suites' assertions (PDF conclusion/metadata/attachment structure, ObservationCard, persistence). All closed by executors (two) and by hand (docs); cap of 3 passes reached → last lot not re-verified. Security PASS with LOW: prototype-key lookup on untrusted ids (fixed: Object.hasOwn + test), unbounded inflate on the primary attachment path + no file cap (fixed: 16 MiB attachment, 50 MB PDF + test), denylist SVG sanitiser acceptable while assets are repo-built (allowlist before Storage-served assets, Step 13). Anomalies: executor ran `pnpm format` repo-wide and reverted by hand (watch for `format` in briefs); foreign JSON attachment (no version) surfaced as incompatible_version → fixed to no_attachment (legacy message); verifier floor counts deleted legacy tests as findings until CLARIFICATIONS name them. Action: user validation of Step 5 (manual FR/EN flow, visual before/after); BDR-038, LRN-043. + +## EVAL-012 | 2026-10-10 | Step 5 addendum during user manual validation — per-leaf migration tests, archive check tool, final controls + +Method: user asked (while testing) for final controls on last lot + per-leaf test beyond the map + simple v2/v3 PDF comparison method. Built: anatomy test all 612 legacy leaves through `migrateReportV2ToV3` with committed map vs draft document (442 identical / 141 moved = 134 category + 7 leaf renames / 29 removed, snapshots + vet flag verbatim, 26 annotations on right view, v3 re-read stable); app test same leaves via `sheetIndex.nodeAt` + v3 PDF roundtrip; CLI `pnpm report:compare` (pure module + entry, `readAttachedDocument` split out of `extractReportJson`, behaviour unchanged). Contract criteria 16-18 added, gates MET, fresh verifier ×3 + security ×2. +Result: verifier pass 1 ECARTS(2) = floor only (EVAL-011 prose "eslint-disable" false positive → CLARIFICATIONS; 11 dropped `regionFromLabel` assertions → new `legacy.regions.test.ts` on `inferRegionCode`); security PASS + 2 MEDIUM (terminal control chars in untrusted strings; free text printed by default) → executor: `esc()` + `--full` privacy default; pass 2 ECARTS(1) (`--diff` still clear text, JSON.parse message echoed attachment fragment) + security PASS 4 LOW → executor: diff follows `--full`, generic reason, Cc/Cf escaping, regular files only; pass 3 CONFORME. Workspace 94/21/119/181, docker build OK. +Anomalies: verifier stage runs after executor edits only (concurrent reads otherwise); gates.sh needs `EVIDENCE: PENDING` placeholder lines on new criteria. Residuals noted, not fixed: ZodError message echoes closed-vocabulary received values (never names), `compareReport` computes v3 lines twice, template-literal lines >80 chars, locals >5 in two functions. +Action: await user manual validation of Step 5; residuals in TODO follow-up. + diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 5ae2f7c1..c08b667d 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -192,3 +192,5 @@ Step 4 validated + finished into develop. User decisions on the 7 open points - Step 5 preparation (2026-10-10): 4 analyzer agents (core/store, rendering, PDF, tests) + plan/spec reading → docs/development/STEP5_MIGRATION_ANALYSIS.md on chore/step-05-migration-analysis. Key facts: all 27 legacy data-anno-ids differ from canonical ids; 170/612 legacy finding paths moved/removed by curation → generated report-migration-map; markers never drawn by the app (in the SVG); PDF depends on markers only for the highlight; 66 tests import the registry. 8 decisions D1–D8 await the user. No implementation. - Step 5 implemented (2026-10-10, feature/step-05-app-on-canonical-sheet): domain report v3 + migration (80 tests), pipeline migration map/sheet-ref/app review drawings + layer renderer (110), app rewritten on the sheet (99 tests: service, store, provider, canvas, pickers, PDF v2/v3, route), legacy code removed, docs rewritten (ANNOTATION-RENDERING.md replaces the SVG convention). Root check green, docker build OK, real stack 267/267, default build carries no sheet. BDR-038, LRN-043. Gates next; awaiting user validation. - Step 5 gates (2026-10-10): verifier 36→4→4 (real gaps closed by 2 executors + doc fixes; cap reached, last test lot unverified by a 4th pass), security PASS (2 LOW fixed: prototype keys, size caps). EVAL-011. Final check green. Awaiting user validation; no publication; default build carries no sheet. +- Step 5 addendum (2026-10-10, user testing manually): per-leaf migration tests (612 leaves, anatomy + app + PDF roundtrip), `pnpm report:compare` archive check tool (privacy default, escaping), stale `scaffold:species` script removed, attachment read/parse split. Gates: verifier 2→1→CONFORME, security PASS ×2 (2 MEDIUM + 4 LOW fixed by executors). EVAL-012, LRN-044. Branch 14 commits ahead, not merged; awaiting user validation; no Step 6. + diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index ced0ccef..04fc8d47 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -330,3 +330,10 @@ Apply: next species/sheet curation; any overlay/diagnostic SVG rasterised with I Freeze golden artifacts with the OLD code before touching it (v2 PDFs via a one-shot vitest, MAKE_GOLDEN=1, deleted after): the new importer is then tested against real archive-like bytes. Generate id/path maps from the pipeline's own records (renames/removals), never hand-written, and commit them as golden-tested data. In React routes, click handlers bound through `useEffect` capture stale closures when two DOM clicks land before a re-render (tests dispatch synchronously): read `store.getState()` inside the handler. A sheet needed to restore a draft but only known from the draft → load the default species' sheet when no report is open. Vitest has its own config: a Vite plugin providing a virtual module must be registered there too. ImageMagick cannot verify marker look with `` children or `fill="none"`: strip titles for the raster only. Apply: Step 6 (PDF v3 snapshot), Step 13 (Supabase SheetProvider), any future schema bump. + +## LRN-044 | 2026-10-10 | CLI over untrusted documents: escape before print, privacy default, generic parse errors + +Context: `report:compare` prints content of archive PDFs (attachment JSON). Security audit: raw interpolation lets a crafted attachment carry ESC/CR sequences that erase or forge lines, including a `!! UNRESOLVED` marker in an integrity tool; free text leaks names when stdout lands in CI logs; V8 `JSON.parse` message echoes ~15 chars of the input. +Pattern: one `esc()` helper (`/[\p{Cc}\p{Cf}\u2028\u2029]/gu` → `\uXXXX`) on every interpolated untrusted string incl. file names and error messages; default output = ids + catalog labels + counts + placeholders, `--full` opt-in for names and free text, same rule in every mode (`--diff` too); `SyntaxError` → generic reason; `statSync().isFile()` + size before `readFileSync`; INIT_CWD for paths under pnpm. +Apply: any future CLI/log over report content (Step 6 server import, worker). Test with `\u001b[2K`, `\n`, `\u009b`, `\u202e`, `__proto__` ids. + diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 30f00fcf..99a4d45c 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -95,10 +95,10 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [x] 5.5 PDF shim + attachment v3 + v2 import (gate D3) - [x] 5.6 delete legacy (registry, species/*, zoneMatch, spineZones, svgConvention, D4 tools), SVG convention doc replaced, CLAUDE.md map, CHANGELOG, plan note, memory - [x] 5.7 visual before/after (cmp renders), root check + docker + real stack green; verifier ×3 (gaps closed), security PASS (LOW fixed); EVAL-011. Manual FR/EN flow = user validation - - [ ] 5.8 per-leaf migration (user ask 2026-10-10, during manual validation): every legacy leaf (612 = 442 identical, 141 moved, 29 removed) as a v2 finding → migrated → resolved to a draft leaf (anatomy, map file) and through sheetIndex.nodeAt + PDF roundtrip (app); the 27 legacy annotations as zones on their views - - [ ] 5.9 archive check tool `pnpm report:compare <pdf|dir>...`: v2 attachment vs migrated v3 side by side, unresolved flagged (removed vs unknown), identity opt-in, --diff of two PDFs, --summary; attachment.ts split read/parse (additive, D3); docs PDF-FORMAT/CLAUDE/README - - [ ] 5.10 final controls on the last lot: stale root script scaffold:species removed; fresh verifier + security on the whole diff (criteria 16-18); EVAL-011 addendum - - [ ] 5 follow-up: allowlist SVG sanitiser before Storage-served assets (Step 13); orphan findings UX (D5) at the report UX step + - [x] 5.8 per-leaf migration (user ask 2026-10-10, during manual validation): every legacy leaf (612 = 442 identical, 141 moved, 29 removed) as a v2 finding → migrated → resolved to a draft leaf (anatomy, map file) and through sheetIndex.nodeAt + PDF roundtrip (app); the 27 legacy annotations as zones on their views + - [x] 5.9 archive check tool `pnpm report:compare <pdf|dir>...`: v2 attachment vs migrated v3 side by side, unresolved flagged (removed vs unknown), `--full` opt-in for names/free text, control chars escaped, --diff of two PDFs, --summary; attachment.ts split read/parse (additive, D3); docs PDF-FORMAT/CLAUDE/README + - [x] 5.10 final controls on the last lot: stale root script scaffold:species removed; verifier ×3 (2→1→CONFORME) + security ×2 PASS on criteria 16-18; EVAL-012 + - [ ] 5 follow-up: allowlist SVG sanitiser before Storage-served assets (Step 13); orphan findings UX (D5) at the report UX step; report:compare residuals (ZodError reason genericised, v3 lines computed once, long template lines); 16 MiB attachment cap without direct test ---