chore(memory): capitalize session decisions and learnings

BDR-020 (pathology editor standalone), BDR-021 (zoneMatch inline port),
LRN-025 (importNode XSS), LRN-026 (inline port pattern). Journal
updated for 2026-05-22 sessions.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude committed 2026-05-22 06:17:32 +02:00
1 parent f2c9c9bdb7
commit dee98e3eac
3 files changed
+36

No files matched your search

+18
View File
@@ -143,3 +143,21 @@ Status: closed.
editor.html = ~1630-line standalone SVG annotation tool (DOM manipulation, drag/drop, polygon editing, zoom, categories, export). Integrated into React app via `useRef` + `useEffect` mounting all vanilla JS logic into container refs. Only CSS restyled to Zoosteo tokens.
Alt rejected: full React rewrite (convert all state to Zustand/useState, all DOM ops to React) — massive effort ~10x, high risk of subtle behavior differences in drag/polygon/zoom interactions.
Status: closed.
---
## BDR-020 | 2026-05-22 | Pathology editor: standalone HTML, not React route
pathology-editor.html = standalone tool at project root, same pattern as SVG editor integration. Vanilla JS/CSS, no build step, no deps. Decoupled from React app entirely — zero imports from src/.
**Why:** tool for domain experts editing JSON, not practitioners using main app. No shared state needed. Standalone = deployable anywhere, no Vite required.
Alt rejected: React route with Zustand store — unnecessary coupling, heavier DX for a JSON editing tool.
Status: closed.
---
## BDR-021 | 2026-05-22 | Port zoneMatch.ts inline into pathology editor
Fuzzy matching logic (normalizeLabel, levenshtein, scorePair, matchZone) duplicated inline in pathology-editor.html rather than imported from src/lib/zoneMatch.ts.
**Why:** standalone HTML cannot import TS modules. Keeping identical algorithm ensures matching consistency between main app and editor.
Alt rejected: extract to shared .js file — adds dependency management for a tool that should be zero-dep.
Status: closed.
+2
View File
@@ -92,6 +92,8 @@ User dropped catalog v1.2→v2.0 in place. pathologies.json now schema_version "
Integrated standalone editor.html (~1630 lines vanilla JS SVG annotation tool) into React app at /svg-editor route. Vanilla JS wrapped in useRef+useEffect — zero behavior loss. CSS restyled to Zoosteo tokens (warm palette, accent vars, serif headings). DOMParser used for safe SVG loading (no innerHTML). Page noindexed via dynamic meta tag. 3 files created (SvgEditorRoute.tsx, svg-editor.css), 1 modified (App.tsx route registration), CLAUDE.md folder structure updated.
- 155/155 tests green, typecheck clean, build OK (941KB main). No regressions.
- BDR-017 (vanilla wrap decision), LRN-022 (DOMParser SVG loading) captured.
- feat(editor): standalone pathology-editor.html — JSON pathology tree editor with SVG zone selection. 1390 lines vanilla JS/CSS, zero deps. Pre-wired species list + manual upload. Fuzzy zone matching ported from zoneMatch.ts. Recursive tree editor: add/edit/delete nodes, sources management, auto ID generation. SVG sanitized (scripts/foreignObject/on* stripped). Export full JSON preserving all zones. public/species/equine/pathologies.json added for HTTP access. Docs synced (CLAUDE.md + README).
- BDR-020 (standalone HTML not React route), BDR-021 (inline port of zoneMatch.ts), LRN-025 (importNode XSS), LRN-026 (inline port pattern) captured.
---
+16
View File
@@ -192,3 +192,19 @@ Fix paths:
- Never `corepack prepare pnpm@latest` — re-resolves at every cold build, silently bumps toolchain across deploys with no commit.
**Why:** Floating tag = drift bomb between cached dev + fresh prod resolve. Same risk for unpinned `node:lts`, `:alpine`, GitHub Actions `uses: foo@v1` (prefer SHA). Lockfile pins app deps; Dockerfile must pin toolchain.
**How to apply:** Before first prod deploy, audit every Dockerfile, docker-compose, and CI workflow for floating upstream refs. For pnpm specifically, check Node version against pnpm minimum (pnpm 11 ↔ Node 22.13, pnpm 10 ↔ Node 18+, pnpm 9 ↔ Node 18+).
---
## LRN-025 | 2026-05-22 | SVG importNode executes inline scripts — sanitize before append
`DOMParser.parseFromString(text, 'image/svg+xml')` is safe — doesn't execute scripts during parse. But `document.importNode(svg, true)` into a live document DOES allow `<script>`, `on*` event handlers, and `<foreignObject>` to execute. Must strip these after importNode, before appending to DOM.
**Why:** discovered during pathology editor code review — file upload path accepts arbitrary SVG.
**How to apply:** any tool accepting user-uploaded SVG: strip `script`, `foreignObject`, and all `on*` attributes after importNode. Or use DOMPurify. Applies to both standalone HTML tools and React-wrapped vanilla editors.
---
## LRN-026 | 2026-05-22 | Standalone HTML tools: port logic inline, don't share modules
When standalone .html tools (no build step) need logic from TS modules (zoneMatch, ID generation), port algorithm inline as vanilla JS. Cannot import .ts files. Keep algorithms identical to source for consistency. Document which .ts file was ported so future changes can sync.
**Why:** pathology-editor.html ports normalizeLabel/levenshtein/scorePair/matchZone from src/lib/zoneMatch.ts.
**How to apply:** if zoneMatch.ts changes, pathology-editor.html matching must be updated manually. Consider a test that compares outputs of both implementations on a shared fixture set.