chore(memory): TODO + journal + BDR-009..011 + LRN-011..012

Mark B0/B1/B2/B5 done on TODO. Journal 2026-05-20 entry with the three
commit SHAs and a per-phase recap. Three new design decisions captured:
JSON snake_case kept in TS (BDR-009), snapshot labels at selection time
(BDR-010), hard-fail v1 PDF with FR-language message (BDR-011). Two new
learnings: Zod recursive schemas via z.lazy + explicit ZodType<T>
(LRN-011), once-per-session UX modal via sessionStorage flag (LRN-012).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude Opus 4.7 committed 2026-05-20 03:51:36 +02:00
1 parent b67f4cd82b
commit b7b094535e
4 files changed
+79 -65

No files matched your search

+28 -65
View File
@@ -1,13 +1,13 @@
# TODO — Osteo Report MVP
## Status (2026-05-19): editor flow + PDF roundtrip working — V1 pivots toward hierarchical findings + i18n
## Status (2026-05-20): findings tree refactor landed (B0+B1+B2) — i18n + full horse catalog next
Major scope decision: pathology model rewritten from flat `Pathology[]` to
**hierarchical findings tree per zone**, with FR/EN bilingual content for site
and PDF. Schema v1.1 JSON authored by domain expert is in place. Refactor
required before MVP can ship.
Domain pivot bundle (B0 schema, B1 report v2, B2 UI/PDF) shipped on
`feat/findings-tree-v2`. Editor now consumes the hierarchical
`SpeciesFindings` tree; PDF roundtrip green; v1 legacy reports hard-fail
with a French-language message.
All 100 tests green pre-refactor.
107/107 tests green, lint 0, typecheck clean, vite build OK.
---
@@ -37,66 +37,29 @@ All 100 tests green pre-refactor.
## Phase B — V1 REFACTOR (hierarchical findings + i18n)
### B0. Domain model — Findings tree (BLOCKING — foundational)
### B0. Domain model — Findings tree (DONE 2026-05-20)
**Decision**: replace flat `Pathology[]` with `FindingsTree` per zone, path-based
serialization in observations. Bump `ReportSchema.version` 1 → 2. No retro-compat
(no production PDFs).
- [x] **Schema**: `src/domain/schema/findings.ts` — `FindingNodeSchema` (recursive via `z.lazy`), `ZoneFindingsSchema`, `SpeciesFindingsSchema`, `SourceRefSchema`
- [x] **Loader**: `src/domain/species/equine/pathologies.ts` parses the JSON via `SpeciesFindingsSchema.parse(data)` at boot (fail-fast)
- [x] **Species manifest**: `findings: FindingsLoader` replaces `pathologies` in `SpeciesManifest`
- [x] **JSON fix**: `species.id` set to `"equine"` to match registry
- [x] **Tests**: `tests/unit/species.equineFindings.test.ts` (5 cases) replaces deleted `species.equinePathologies.test.ts`
- [ ] **Schema**: `src/domain/schema/findings.ts` (new)
- `FindingNodeSchema`: `{ id, name_fr, name_en, description_fr?, description_en?, requires_vet_referral?, sources?, children? }`
- `ZoneSchema`: `{ id, name_fr, name_en, categories: FindingNode[] }`
- `SpeciesFindingsSchema`: `{ schema_version, scope_disclaimer, species, zones: Record<string, Zone> }`
- Recursive Zod (`z.lazy`) for children
- [ ] **Loader**: rewrite `src/domain/species/equine/pathologies.ts`
- `import data from './pathologies.json'`
- `SpeciesFindingsSchema.parse(data)` at boot → fail-fast on bad JSON
- Export both `default` (parsed object) AND a backward-compat empty `Pathology[]`
until callers migrated, then drop the legacy export
- [ ] **Species manifest** (`types.ts`): replace `pathologies: PathologiesLoader`
with `findings: () => Promise<{ default: SpeciesFindings }>`
- [ ] **Fix JSON**: change `species.id` from `"horse"` → `"equine"` to match registry
- [ ] **Tests**: `tests/unit/species.equineFindings.test.ts`
- Parse succeeds with provided JSON
- Every leaf has `name_fr`+`name_en`
- `scope_disclaimer` non-empty
- At least 1 zone with at least 1 category with at least 1 leaf
- Delete old `species.equinePathologies.test.ts`
### B1. Report schema v2 — observation findings (DONE 2026-05-20)
### B1. Report schema v2 — observation findings
- [x] `ObservationSchema` carries `findings: Finding[]` + `freeTextFindings: string[]`; old `pathologyIds`/`freeTextPathologies` removed
- [x] `ReportSchema.version` literal bumped `1` → `2`
- [x] Store `emptyObservation` + `initReport` updated to the v2 shape
- [x] PDF import surfaces a distinct French-language `IncompatibleReportVersionError` message on v1 attachments (detected before Zod parse)
- [x] Schema + store + PDF tests updated; `pathology.ts` schema + test deleted
- [ ] **Schema**: `src/domain/schema/observation.ts`
- Replace `pathologyIds: string[]` + `freeTextPathologies: string[]` with:
```
findings: Array<{
zoneId: string
path: string[] // ['category','sub','leaf']
labelFrSnapshot: string
labelEnSnapshot: string
requiresVetReferral?: boolean
}>
freeTextFindings: string[]
```
- [ ] **Schema**: `src/domain/schema/report.ts` — bump `version` literal `1` → `2`
- [ ] **Store**: rewrite observation update helpers, drop pathology-specific actions
- [ ] **PDF import**: hard-fail on v1 with friendly message (no v1 PDFs in prod)
- [ ] **Tests**: schema tests for v2 shape
### B2. UI — Findings tree picker (DONE 2026-05-20)
### B2. UI — Findings tree picker (replaces PathologyPicker)
- [ ] **New component**: `src/components/observation/FindingsTreePicker.tsx`
- Receives `zoneId`, `tree: Zone`, `selected: Finding[]`, `onChange`
- Breadcrumb (`Zone > Category > Sub > ...`)
- Click intermediate node → drill into children
- Click leaf → toggle selection
- "Back" button to climb breadcrumb
- Show `description_fr/en` (selected via current locale) when present
- ⚠️ icon badge when `requires_vet_referral` true
- [ ] **Disclaimer**: show `scope_disclaimer` once per session (e.g. in editor or NewReport)
- Track shown-this-session via sessionStorage flag
- [ ] **Migrate ObservationCard**: replace PathologyPicker render with FindingsTreePicker
- [ ] **Delete**: old `PathologyPicker.tsx` + its test + flat schema field cleanup
- [ ] **Tests**: tree navigation, leaf selection, breadcrumb, vet-referral flag
- [x] `src/components/observation/FindingsTreePicker.tsx` (breadcrumb, drill-down, leaf toggle, retour button, vet-referral ⚠ badge, description_fr surfacing)
- [x] `scope_disclaimer` modal shown once per session via `osteo:disclaimer-shown` sessionStorage flag
- [x] `ObservationCard` migrated — one picker per zone with a catalog entry, single `FreeTextFindingInput` below
- [x] `PathologyPicker` + `FreeTextPathologyInput` + their tests deleted; `FreeTextFindingInput` renamed equivalent kept
- [x] `tests/unit/components.FindingsTreePicker.test.tsx` covers navigation, leaf select, vet-referral flag, retour, deselect
### B3. i18n FR/EN — site + PDF
@@ -120,11 +83,11 @@ serialization in observations. Bump `ReportSchema.version` 1 → 2. No retro-com
- [ ] `scope_disclaimer` footer on each obs page or first page only — decide
- [ ] Update `LRN-009`-style layout still applies (text-area reservation)
### B5. Stub cleanup
### B5. Stub cleanup (DONE 2026-05-20)
- [ ] `ZoneTooltip.tsx` — delete (unused)
- [ ] `Toast.tsx` — implement OR delete (decide: notifications for PDF export/import?)
- [ ] `ObservationEditor.tsx` — remove reference from CLAUDE.md folder map
- [x] `ZoneTooltip.tsx` deleted (unused stub)
- [x] `Toast.tsx` deleted (unused stub — re-introduce later if notifications needed)
- [x] CLAUDE.md folder map updated — `ObservationEditor`/`Toast`/`ZoneTooltip` removed, `FindingsTreePicker`/`FreeTextFindingInput`/`findings.ts` added
---