diff --git a/.claude/memory/blockers.md b/.claude/memory/blockers.md index 924517ac..419fb589 100644 --- a/.claude/memory/blockers.md +++ b/.claude/memory/blockers.md @@ -81,3 +81,10 @@ Status: open (no real data yet; treat before Step 7+ persistence of user reports Security audit Step 6 (MEDIUM, pre-existing since Step 1 import): `PDFDocument.load` decodes every `/ObjStm` and xref stream eagerly with its own uncapped FlateStream; measured 408 KB PDF → 400 MB in 1.4 s, 468 MB RSS; `MAX_PDF_BYTES` 50 MiB allows ~50 GB. Attachment cap (16 MiB) covers the attachment only. Impact: tab freeze/OOM for the practitioner on a crafted PDF, no code execution. Cannot refuse `/ObjStm` (pdf-lib `save()` emits object streams in our own PDFs). Options: parse in a Web Worker (bounded blast radius), or locate the attachment by scanning bytes without a full load, or a capped custom decoder. pdf-lib 1.17.1 unmaintained since 2021 (LOW in the same audit). Status: MITIGATED on the browser import path 2026-10-11 (60ee712: byte-scan attachment reader, no `PDFDocument.load` on untrusted bytes, export without object streams; ObjStm bomb read in 5 ms, +0.5 MiB RSS). Then 3a6e926: inflater fed in 16 KiB slices (Chromium read-ahead defeated the cancel: 4 GiB bomb +2.2 GB → +192 MB measured), shared 16 MiB candidate budget, bounded endstream search; final loop: candidates sorted by offset, JSON depth pre-scan. Audits ×3 PASS; worst measured costs on crafted files: +192 MB single bomb, ~0.5 s / ≤0.4 GB for 32 failing inflations, ~1 s deep JSON (before the pre-scan). GATE STILL OPEN before any external-user import (BDR-040): Firefox/Safari inflater read-ahead unmeasured (no browser test runner), Worker/server import with time+memory budget, pdf-lib replacement decision (unmaintained), report collection caps on read, `` nesting budget, low-end phone measurement. Plan: docs/development/PDF_IMPORT_HARDENING.md §5. Never close on passing tests alone. + +## BLK-010 | 2026-10-14 | Agent worktrees created on a stale base; their cleanup refused by the classifier + +Friction: the three `isolation: worktree` forks of R2 started at 605ee7c (an old develop merge), not at the feature branch HEAD 22fea87; each fork noticed and moved its own temp branch (`git reset --hard` / `checkout -B` on the empty worktree, flagged by the classifier as a security warning). After merging their diffs by hand, `git worktree remove --force` + `git branch -d worktree-agent-*` refused by the auto-mode classifier. +Root cause: harness side (base commit of the agent worktree), not reproducible from the repo; the removal refusal is the destructive-command policy. +Solution: forks briefed with the exact base commit and told to verify `git log -1`; diffs collected uncommitted and copied by literal paths. Leftover: `.claude/worktrees/agent-{a0cefd439bff650a2,a3f684449d0776ad1,af6ebe79b8f742039}` (3.2 GB) + 3 local temp branches at 22fea87 (merged), owner removes them (`git worktree remove --force `, `git branch -d `). +Status: open (harness); workaround documented. diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index 91a9fd07..b844dc51 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -394,3 +394,15 @@ Status: active; awaiting owner validation (TEST FONCTIONNEL + TEST GRAPHIQUE), n Owner decisions: (1) R1 validated 10/10 manual + graphic → R0 and R1 finished into develop (5cfb6f1, f5865f0; the earlier classifier refusal did not recur); (2) identity final: product/app/site = **Faunosteo**, domain **https://faunosteo.com**, no new brand name, logo/palette/mockups kept; (3) environments: DEV = self-hosted Ubuntu native (Claude Code, git, rustup, Vite, Docker rootless, local Supabase, worker), STAGING = `staging.faunosteo.com` planned not created, PROD = separate VPS, current site preserved, no DNS/cert/proxy/data change; isolation of DB/Storage/secrets/accounts/OAuth/payments/mails/files per env, prod data never copied to DEV, merge ≠ deploy, no CI/CD operational (workflows preparatory); (4) permanent rule: the owner tests from other devices (computer, phone) → every test surface addressed by the DEV origin (LAN address or private name), never 127.0.0.1/localhost, never hard-coded; implemented as `scripts/dev-env.sh` (`FAUNOSTEO_DEV_HOST`, detected via `hostname -I`, prod host refused) + `scripts/supabase.sh` wrapper (config.toml `env()` for api.external_url, auth.site_url, studio.api_url) + `scripts/dev.sh` (`pnpm dev` on the origin, `pnpm dev:offline` without backend) + private-network redirect URLs; (5) exposure: 5173/54321 needed by browsers, Studio 54323 + Mailpit 54324 unauthenticated → private subnet only, PostgreSQL 54322 published by the CLI on 0.0.0.0 (no bind option) → firewall restriction proposed to the owner, not applied; worker no port; (6) Rust native via Cargo, Docker for services/worker/sandbox/images/prod, VPS never compiles. Alt rejected: hard-coded IP in config.toml (first iteration, replaced the same day); Vite `dev:lan` variant (folded into `dev`); binding the CLI ports to loopback (impossible in config.toml). Status: active; `chore/dev-lan-access` awaiting the owner's LAN validation; R2 not started. + +## BDR-050 | 2026-10-14 | R2 implementation choices: Zod semantics in serde, minimal index data, form edits stay Zustand, quarantine, lazy core + +Built on review rev 2 + Annex C; plan `.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md` rev 2 (3 challengers, 45 findings, 1 BLOCKER folded). Choices: (1) JSON read text → `serde_json::Value` (JSON.parse dup-key semantics) → typed; lone surrogate escape → U+FFFD pre-pass (L1, owner to confirm); (2) Zod reproduced by field helpers: `js::present` (optional: absent ok, null refused, skipped), `js::nullable` (required key), `JsInt` (any integer-valued number, JS print), hand-written patterns (no regex crate), `url` crate for `.url()`; unions = untagged enums + literal tag fields at Zod position → byte-equal with `JSON.stringify(Zod.parse(x),null,2)`; PDF label fields in engine dict order → frozen envelopes round-trip byte-equal; (3) quirks ported site by site (Map last-wins, find first-wins, JS truthiness, `??=`, malformed map entry still fails the read); (4) `SheetIndexData` minimal (positions, names, spineIds, nodeKeys as JSON `[zone,...path]`), TS `SheetIndex` = accessors only + `ops`; (5) one core call per user action; form-value observation edits (comment, severity, free text, finding removal) stay Zustand assignments (no per-keystroke wasm, D-R7); store actions answer `{ok}`, callers stop on failure; `hydrateReport` deleted; (6) runtime: sync calls, trap → poison → offline recovery from kept compiled module + pre-imported spare glue record, cap 3, per-generation sheet handles, retry clears all caches; `pkg/` shipped vs `pkg-proofs/`; BUILD_STAMP refuses stale module in tests; (7) quarantine only on content kinds, newest-only keys, source removed after successful copy, pre-rebase raw kept when unresolved > 0; editor never redirects in degraded states; (8) Home and /new read availability from the bundle, core loads at submit / import / editor; (9) import = TS byte scan (until R4) → core `archive.import` (read + rebase one call); export = core `archive.snapshot` → frozen TS engine; (10) publish gate takes the core validator (DI), fails closed; (11) report:compare CLI keeps the frozen domain (R4); practitioner prefill keeps a small Zod schema (D-R7, core not loaded on /new mount); (12) app image wasm stage + gzip_static; DEPLOY: CSP keyword before an R2 image, never built on VPS. +Alt rejected: mutation corpus with full outputs (simplicity challenge: drift-free verdict table + characterisation instead); `report.replace_observation` per keystroke; serde internally tagged enums (tag first breaks byte equality); Web Worker for every call (async races in the click chain); unify duplicate-id policies (behaviour change). +Status: active; R2 delivered on feature/rust-r2-domain-core, awaiting owner validation, no merge. + +## BDR-051 | 2026-10-14 | L1 resolved: lone UTF-16 surrogate refused whole, never replaced (supersedes BDR-050 choice 1 on this point) + +Owner refused U+FFFD replacement of lone surrogate escapes (silent alteration of historical user data). Chosen (owner, 2026-10-14): refusal + quarantine. `js::parse_json` no pre-pass; serde_json refuses escape like any error; failure classified by strict escape scan (on failure only) → `JsonReadError::LoneSurrogate` → closed kind `lone_surrogate` (parse_input, sheet.check, draft.restore, archive.import). App: draft → `osteo:quarantine:draft` verbatim + existing `editor.draft_quarantined`; session archive → `osteo:quarantine:archive`; import → `ImportError('lone_surrogate')` + new `home.import.error_lone_surrogate` (owner-chosen detailed wording FR/EN, file untouched); editor action → refused, report unchanged, `core.action_failed`; publish gate → `invalid_shape`. Oracles untouched: L1 cases now assert TS kept surrogate + Rust refuses; test loader spells lone escapes out as literal text (never U+FFFD). +Alt rejected: faithful preservation (own JSON reader + lossless WTF-16 string type over ~150 contract fields + serialiser, oracles re-frozen; multi-day, for corrupted/pasted-UTF-16 data only; door stays open since nothing is lost); in-band tunnel (placeholder code points mapped back at facade output; collisions with sheet strings, UTF-16 length drift, every output path must be post-processed: hacky). +Status: active; merged with R2. diff --git a/.claude/memory/evals.md b/.claude/memory/evals.md index 58d66e26..70aaa7c1 100644 --- a/.claude/memory/evals.md +++ b/.claude/memory/evals.md @@ -150,3 +150,17 @@ Method: contract-level `STORAGE.md` written first; migration + pgTAP by me while Result: verifier pass 1 ECARTS(4) = oracle (`for update` row-lock grep) + FILE SCOPE (tracking files, lockfile) → rev 2 → CONFORME 15/15, floor clean. Security pass 1 PASS (2 MEDIUM: ceiling ratchet by rejected rows, cleartext http any host; 9 LOW) → fixed; pass 2 PASS but my fixes introduced 2 MEDIUM (bypassable host check `127.*`/numeric, ceiling undercount vs contract) → fixed; pass 3 BLOCK(1) HIGH: my purge-queue join let begin spam pin the ceiling with claims → ceiling rewritten on bytes present + cap per pending claim; pass 4 PASS (MEDIUM residual: per-account holding) → 64 MiB per-account budget; pass 5 PASS (LOW hygiene) → comments/doc. e2e 5/5 ×7 (found the Storage API 400-as-404 making purge acks loop: added queue-drained assertion); smoke 18/18 desktop+mobile; final: pgTAP 140 (real stack 420 total), app 300, supabase 37, worker 21+11 native, sandbox 16, allowlist = 7 syscalls unchanged, image 11.6 MB. Anomalies: EVAL-017 lesson again ×3 — each security fix needed its own adversarial pass and twice created a new finding (host check, ceiling join); a security control I added became the attack lever (BLOCK). Fork B's `database.types.ts` hand-write matched the generator byte-for-byte except ordering; fork A found the 400/404 only via e2e. `gitflow finish` of R0 and any `.env*` write refused by the harness classifier; `git config` reads refused too. Verifier sandbox intercepted the literal `pnpm lint` (rtk wrapper) → oracle uses the binary path. Action: owner's manual validation (TEST FONCTIONNEL + TEST GRAPHIQUE), owner runs `gitflow finish` for R0 then R1 after validation; no merge, no deploy, release 0.2.0 untouched. + +## EVAL-020 | 2026-10-14 | Rust R2 domain core — 3 plan challengers, 4 forks, verifier, security ×2, CSP proof on the image + +Method: plan + contract written first (`.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md`), 3 plan-challengers (correctness, robustness, simplicity) before code; freeze-then-switch: envelopes, Zod output oracles, characterisation and verdict tables written by the TS before trusting Rust; forks A/B/C in worktrees on disjoint files (sheet rules + conformance, report/archive rules, editor rules), runtime + app switch by me, fork D adapted the app suites in tree; browser checks with playwright-core from the scratchpad (dev server, prod build, real image under the DEPLOY CSP); contract `2026-10-14-rust-r2-verify.md` (12 criteria, every oracle dry-run before dispatch) → fresh verifier; security-auditor on the whole range, then a focused pass on the fix commit. +Result: challengers 45 findings incl. 1 BLOCKER (degraded editor redirect could overwrite an unread draft) → plan rev 2 before any app code; contracts byte-equal to Zod on first run; forks merged with zero conflicts (one stub replaced); fork D found 2 real src bugs (Node source path under happy-dom, failed quarantine reported as success) → fixed with tests. Verifier: 12/12 MET, ECARTS(2) = floor DELETED_TEST (zoneInteraction suite ported to cargo; R0 skip helper replaced by a stricter global setup) → human micro-gate for the owner. Security: PASS (3 MEDIUM nginx false positives pre-existing, 5 LOW) → by-reference deserialisation (also −134 KB raw / −31 KB gzip module) + literal delete paths. Final: cargo core 135, worker+wasm 32, Node 906 (app 313), pgTAP PGlite 12 files / real stack 446, CSP proof 15/15, check:all green ×3, module 1,046,498 B raw / 340,929 B gzip. +Anomalies: worktree base stale (BLK-010); harness decodes `\u` escapes in tool inputs (LRN-054); my first runtime test helper reused the pattern Vite rewrites; the CSP proof first failed on its own harness (EN locale, disclaimer modal, caught compile error logs nothing) — proof scripts need the same dry-run discipline as oracles; a security LOW fix improved size, measure before assuming a cost. +Action: owner manual LAN validation, L1 decision, approve the 2 deleted test files (floor), then merge go; R3 next, not started. + +## EVAL-021 | 2026-10-14 | R2 closure — L1 refusal, deletions proof, fresh verifier + security + +Method: owner asked to fix L1 (no silent U+FFFD) + prove the 2 approved deletions + checks before merge. Mapped every JSON entry into the core (TS side always `JSON.stringify` → escapes reach Rust as ASCII); preservation costed (own JSON reader + lossless string type ~150 fields) → AskUserQuestion: refusal + quarantine chosen, detailed import wording chosen. Stale-module proof run before `wasm:build` (suites throw `pkg is stale`). Worktrees checked blob by blob vs branch history (60/66 identical, 6 = stub, merged mod lists, 2 lifted `#[ignore]`). Contract `2026-10-14-rust-r2-l1-verify.md` (13 criteria, each dry-run) → fresh verifier; fresh security-auditor on 36316cf..HEAD. +Result: verifier CONFORME 13/13 (floor 2 = the approved deletions, authorised by REQUEST); security PASS, 6 LOW: wasm-bindgen `&str` would re-encode a raw lone surrogate (unreachable, JSON.stringify callers; documented invariant), `pretty_json` proof op refuses as invalid_json, scanner not string-aware (classification only), newest-only quarantine slot, archive quarantine failure under full storage lets a later reset remove it (pre-existing R2, reported to owner), semgrep partial parse. Final: core 142, Node 915 (app 320, supabase 40, core-wasm 26), PGlite pgTAP 12 files, real stack 446/446, types no drift, check:all green 1 min 32 s, module 1,040,784 B raw / 339,933 B gzip. +Anomalies: refusal broke a test loader (oracle file freezes TS outputs with lone escapes) → loader spells escapes out, never normalises (LRN-055); `cargo deny advisories` (warn-only) shows RUSTSEC-2026-0346/0347/0348 on rustls 0.23.45 (worker, none applicable: no brotli, built-in session cache, no ECH) → bump follow-up; `supabase/.temp/cli-latest` tracked by mistake, rewritten by the CLI, restored; `export PATH=…` denied → absolute `~/.cargo/bin/cargo`; first commit with chained `git config` denied → plain commit OK. +Action: gitflow finish into develop (owner authorised after L1 + checks), worktree cleanup (BLK-010), R3 summary only. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 4363712d..3d90e5dc 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -247,3 +247,11 @@ Owner: R1 10/10 validated, identity final (Faunosteo, faunosteo.com), env DEV/ST - Same day, LAN least privilege (owner brief): measured from a distinct Docker network → Mailpit open without auth, PostgreSQL open, Studio open. Built DEV gateway (nginx, API + Mailpit basic auth on the LAN address), `pnpm dev:gateway`, `pnpm dev:net-check`; gateway proven on alternate ports. Pending owner authorisation: `~/.config/docker/daemon.json {"ip":"127.0.0.1"}` + rootless daemon restart (daemon-wide, only Faunosteo containers on it). LRN-052. Branch not merged; R2 not started. - Same day, owner applied the UFW rules (ENVIRONMENTS.md §3.2) and verified from another device: 54322, 54323, 54324 refused, 54321 answers; app served by the owner's `pnpm dev`. Allowed surfaces 5/5 by dev:net-check. Remaining: owner's 10-step run on computer + phone, then merge go and R2 go. - Owner validated the 10-step path on computer and phone over the LAN; merge go for chore/dev-lan-access. R2 not authorised yet. + +## 2026-10-14 (Rust R2 delivered) + +Owner: LAN validated, R2 go (brief 2026-10-13), 4 new strings validated (recommended wording). feature/rust-r2-domain-core off develop 1a7ee7d. Plan + 3 challengers (45 findings, 1 blocker) → rev 2. Freeze first (envelopes, N-1 copy, Zod oracles, characterisation 84 + verdicts 765 + editor 49 + conformance 26), contracts byte-equal, rules by 3 worktree forks, runtime (lazy, poison, offline recovery, BUILD_STAMP), app switched (sheet, store, click chain, pickers, import, export snapshot, publish gate fail-closed), quarantine, degraded states, Docker wasm stage + gzip_static, CSP proof on the image 15/15. Verifier 12/12 + floor 2 (deleted tests, owner micro-gate); security PASS → by-ref deserialisation (module 341 KB gzip). check:all green. BDR-050, LRN-054, BLK-010, EVAL-020. Stop: owner validation, no merge, R3 not started, release 0.2.0 untouched. + +## 2026-10-14 (R2 closure) + +Owner: manual 10/10 validated, R2 accepted (architecture, migrations, contracts, perf); L1 refused (silent U+FFFD). Costed preservation (own JSON reader + lossless string type) → owner chose refusal + quarantine, detailed import wording. Fixed: core refuses lone surrogate as `lone_surrogate` (draft/archive quarantined verbatim, import refused with message, action refused, gate invalid_shape). Deletions proven covered (12+1 Rust tests + 49 oracle cases; stale module fails suites). Worktrees verified recoverable-free. Gates: verifier CONFORME 13/13, security PASS 6 LOW; check:all green. BDR-051, LRN-055, EVAL-021. Next: finish into develop, worktree cleanup, R3 summary (not started). diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index 0a2a26de..f9ea986a 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -411,3 +411,18 @@ Apply: any DEV service exposure on this machine; future staging compose. - Rootless (slirp/pasta) containers reach the host's own LAN IP by local delivery, never through the LAN interface → firewall refusals on that interface are invisible to any probe run on the host; prove them from another device (`nc -zv -w 3 `). - Lesson: an "it should apply" assumption about a third-party tool's binding must be tested before handing a procedure to the owner (I flagged it as a hypothesis, but the owner still spent a daemon restart on it). Apply: any exposure work on this machine; staging compose (bind explicitly there). + +## LRN-054 | 2026-10-14 | Porting Zod to serde without drift; wasm in Vite; agent and harness traps + +- serde silently widens Zod: a missing `Option` field defaults to None (use `deserialize_with` to make a nullable key required), `null` reads as None for an optional (use a `present` helper refusing null), `u32` refuses `2.0` that `.int()` accepts (JsInt over f64), internally tagged enums print the tag first (untagged enum + literal tag field at the schema position keeps Zod order). Zod drops a `__proto__` key in `z.record`; JS regex `$` = end of input; `.min/.max` count UTF-16. Prove with byte equality against `JSON.stringify(Schema.parse(x),null,2)` on real documents, a characterisation set frozen from the old functions, and a verdict table run by Zod once. +- Vite: `import x from 'pkg/glue.js?url'` emits the wasm-bindgen glue as an asset (no bundling); `import(`${url}?instance=${n}`)` gives a fresh module record in dev (`/@fs/…`) and build; works under CSP `script-src 'self' 'wasm-unsafe-eval'`. In happy-dom suites Vite rewrites `new URL(rel, import.meta.url)` into `/@fs/…` → Node readFile fails: build paths from `fileURLToPath(import.meta.url)`. +- A caught `WebAssembly.compile` CSP refusal logs nothing in the console: read the `securitypolicyviolation` event (`blockedURI` = `wasm-eval`). Headless Chromium defaults to en-US: set the page locale before asserting French strings. The DEPLOY CSP also refuses the footer's external credit logo (img-src). +- This harness decodes `\uXXXX` in tool inputs (heredocs, Write): build escape sequences with python `chr(92)`. +- `isolation: worktree` forks started at an old commit (605ee7c, not HEAD): each fork had to move its temp branch; brief forks to check `git log -1` first. `git worktree remove` / `git branch -d` on those temp branches refused by the auto-mode classifier → leftover worktrees (3.2 GB) for the owner to remove. +- Forks with full context + disjoint file ownership + "no commit, I collect the diff" merged with zero conflicts (one deliberate stub replaced). +Apply: R3/R4/R5 ports (same oracle stack), any wasm loaded by Vite, any agent fan-out. + +## LRN-055 | 2026-10-14 | Lossy normalisation pre-pass hides user-data alteration; classify parser refusal instead + +Context: R2 rewrote lone surrogate escapes to U+FFFD before serde_json so JS-era texts still parsed (L1). Owner refused: silent change of historical data. Fix: drop pre-pass; serde_json already refuses; scan text only after failure to name kind (zero cost on valid input, exact refusal kind for UI message + quarantine). Trap found by fix: oracle file freezing TS outputs carried lone escapes → whole-file parse failed; test loader must spell escapes out as literal text (evidence kept), never re-normalise. Also: `u32::from_str_radix` accepts leading `+` → escape scanner checks hex digits explicitly. +Apply: any reader of user data (R3 SVG, R4 PDF reader, R5 pipeline) → refuse with closed kind + keep original, never repair silently; a leniency step needs explicit owner decision and declared-difference test. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 664ee6df..1a1da669 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -164,6 +164,24 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [ ] R0.11 follow-ups for the CI/CD step (owner): ci.yml push/PR triggers stay live, so registering a runner starts PR builds at once (keep, or switch to workflow_dispatch until then); `actions/*@v4` mutable tags (Step 27); advisories cadence while no nightly runs (`cargo deny check advisories` is warn-only in check:all); `--remap-path-prefix` if native and builder wasm must match byte for byte - [x] R1 = Step 8 worker in Rust (delivered 2026-10-13 on feature/step-08-files-foundation, see Step 8 block; awaiting owner validation): decode child dispatched before any thread, empty env, RLIMIT_AS/CPU, traced seccomp allowlist, `image` + `moxcms` + `libwebp-sys` in the child, parent RIFF-header check only, 512 KiB output cap, per-stage deadlines, service key - [ ] R2 domain core (before Step 9): sheet/report/archive contracts, `SheetHandle` + `SheetIndexData`, reducers, Finding builder, vertebra selection, publish gate; wasm facade (JSON strings, ts-rs types, poison + reinstantiate, lazy init); app switched; 3 envelopes frozen first; N-1 reader test; draft quarantine; conformance fixtures + generated pgTAP; `packages/domain` frozen for engine/pipeline + - plan + contract: `.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md` (rev 2 after 3 challenges, 45 findings folded); branch `feature/rust-r2-domain-core`; owner wording of the 4 new strings validated 2026-10-13 + - [x] R2.0 freeze: 3 archive envelopes (demo, v2full, v2unresolved; FR, no logos, fixed time) + verbatim N-1 Zod copy (`packages/core-wasm/tests/n-1`) (3114d67); Zod output oracles of the reference documents (`crates/core/tests/oracles`) + - [x] R2.0b characterisation frozen from the TS: 84 report/archive cases + 765 Zod verdicts (fork B), 49 editor cases (fork C), 26 conformance fixtures (fork A), horse-slice JSON + - [x] R2.1 Rust contracts (ee07008): byte-equal to Zod output on draft + legacy sheets, demo report; the 3 frozen envelopes round-trip byte-equal + - [x] R2.2 Rust rules (0c47d0f, 21906c4): integrity rules, check, create, index data, read/migrate (612 leaves), rebase, snapshot, layered read, session restore/import; pgTAP 011 generated (PGlite 12/12, real 446/446) + - [x] R2.3 editor rules (3639c87) + facade ops (6c0533c) + - [x] R2.4 runtime (343d6f4): lazy, poison, offline recovery, per-generation handles, cap 3, retry, pkg/pkg-proofs, BUILD_STAMP; browser-checked dev + build; measurements (794dfd9) + - [x] R2.5 app switch (74fcb37) + publish gate fail-closed (6891f9e); app 313/313 on the real core (fork D adapted 17 files, 24 new tests, found 2 src bugs fixed) + - [x] R2.6 image + serving (7be94d4): wasm stage, gzip_static 372 KB served, CSP proof on the image 15/15 (Chromium only; no Firefox/WebKit build here), check:all green 2 min 17 s + - [x] R2.7 docs (8e8c58e: RUST.md §8, CLAUDE.md, WORKSPACE, TEST_STRATEGY, packages/README, DEPLOY, CHANGELOG), verifier 12/12 + floor ECARTS(2) (deleted tests, owner micro-gate), security PASS ×2 (follow-ups e49009e), memory BDR-050 LRN-054 BLK-010 EVAL-020; STOP (no merge) + - [x] R2 owner points (2026-10-14): manual LAN validation 10/10 + graphics accepted; L1 decided (refusal + quarantine, BDR-051); 2 deleted test files approved (coverage proven); worktree cleanup authorised after checks; merge go after L1 + - [x] R2 closure (owner brief 2026-10-14) + - [x] L1.1 core: `parse_json` never rewrites; refusal classified (`JsonReadError::LoneSurrogate`, strict hex scan, on failure only); kind `lone_surrogate` from parse_input, sheet.check, draft.restore, archive.import (20d03cf) + - [x] L1.2 app: quarantine on `lone_surrogate`, `ImportError('lone_surrogate')` + `home.import.error_lone_surrogate` FR/EN (detailed wording), publish gate → `invalid_shape` (da8a037); dead `isCoreBuilt` removed (5020954) + - [x] L1.3 tests: js scanner/parse, session draft/archive/import + normal text, facade kind, characterisation L1 + Zod verdict = explicit refusal (oracles untouched, loader spells escapes out), store quarantine verbatim, editor action refused report unchanged, import kind, real-module call, gate + - [x] L1.4 checks: rust:check, stale-module refusal shown, wasm:build, Node 915, PGlite 12 files, real stack 446/446, types no drift, check:all green; verifier CONFORME 13/13, security PASS (6 LOW) + - [x] L1.5 docs (RUST.md 8.6/8.7, PDF-FORMAT, CHANGELOG) + memory BDR-051, LRN-055, EVAL-021, journal + - [ ] R2 follow-ups: Firefox/WebKit CSP run (no browser build here; owner's manual LAN run covers its browsers), import in a Web Worker + PDF import hardening gate (R4, PDF_IMPORT_HARDENING.md §5), React error boundary (not decided), base images by digest (Step 27), wording of the storage-full degraded notice, CSP refuses the footer's external credit logo (RUST.md 8.8), no CI/CD runner on the forge (workflows prepared, never executed), rustls 0.23.45 advisories RUSTSEC-2026-0346/0347/0348 (worker; not applicable: no brotli, built-in session cache, no ECH) → `cargo update -p rustls` ≥ 0.23.46 + worker:test + e2e:avatar, unreadable session archive under full storage removed by a later reset (security LOW, decision needed), `supabase/.temp/cli-latest` tracked by mistake (untrack + ignore), wasm-bindgen boundary invariant (JSON.stringify callers only, RUST.md 8.7) - [ ] R3 anatomy core: tree, one sanitiser, serialiser, layer renderer, `compose_view_svg`; app canvas switched; composed views frozen as trees first - [ ] R4 pdf core: reader (Web Worker, BLK-009 browser measurements) + writer (`pdf-writer`, Std14 AFM, draw log; lines/rects/colours golden frozen with the TS engine first, D-R2) + `report-compare` tool; `packages/pdf` deleted; N-1 scanner reads R4 PDFs - [ ] R5 curation pipeline + importer + upload tool: seed golden regenerated once (new `documentSha256`, D-R5), `packages/anatomy` + `packages/domain` deleted, docs map; all before Step 13 diff --git a/.claude/tasks/contracts/2026-10-14-rust-r2-l1-verify.md b/.claude/tasks/contracts/2026-10-14-rust-r2-l1-verify.md new file mode 100644 index 00000000..0afcbbee --- /dev/null +++ b/.claude/tasks/contracts/2026-10-14-rust-r2-l1-verify.md @@ -0,0 +1,57 @@ +# CONTRACT — R2 closure: L1 lone UTF-16 surrogates refused, never replaced +- date: 2026-10-14 | flow: ad-hoc fix on the R2 branch, verifier gate | branch: feature/rust-r2-domain-core +- status: dispatched after the code, test and doc commits +- spec: owner brief 2026-10-14 §2 (L1) + §3 (deletions) + answers: approach = refusal + quarantine (not preservation), import message = detailed wording; BDR-051 in `.claude/memory/decisions.md`; `docs/development/RUST.md` §8.7 item 1 +- diff range: 36316cf..HEAD (run every CHECK from the repository root; `. scripts/rust-env.sh` first for cargo) + +## REQUEST (IMMUTABLE) +Do not accept the silent transformation of an isolated UTF-16 surrogate into U+FFFD when historical data is read. Preserve user data integrity strictly: faithful preservation where possible, otherwise controlled refusal or quarantine of the data concerned, with the original content kept and an explicit message. Never delete or silently transform unreadable historical data. Add the non-regression tests needed, covering JSON strings with a lone surrogate and normal data. (Owner chose refusal + quarantine; preservation would need an architecture change.) Also approved: deletion of the old `zoneInteraction` suite and of the helper that skipped tests without the wasm module, provided the behaviours stay covered and the checks fail when an essential Rust feature becomes unavailable; no oracle needed by R3/R4 removed. No GUI change, no deploy. + +## ACCEPTANCE CRITERIA +1. No replacement of lone surrogates remains anywhere in the code. + CHECK: grep -rn "replace_lone_surrogates" crates packages apps --include=*.rs --include=*.ts | wc -l; grep -c 'push_str("\\\\uFFFD")' crates/core/src/domain/js.rs + EXPECT: 0 / 0 +2. The native Rust gate is green. + CHECK: bash scripts/rust-check.sh > /tmp/l1-verify-rust.log 2>&1; echo "exit $?" + EXPECT: exit 0 +3. The core carries at least 142 passing tests, none failing. + CHECK: . scripts/rust-env.sh && cargo test -p faunosteo-core 2>&1 | grep "test result" | awk '{s+=$4; f+=$6} END {print s, f}' + EXPECT: first number ≥ 142, second 0 +4. Every core entry that reads JSON text names the refusal `lone_surrogate` (operation inputs and sheet.check through the `From` impl, draft restore and archive import through their own variants). + CHECK: grep -c '"lone_surrogate"' crates/core/src/ops.rs crates/core/src/facade.rs; grep -c "LoneSurrogate" crates/core/src/domain/session.rs + EXPECT: ops.rs:2 facade.rs:2 / 4 +5. The application treats the kind as unreadable draft content (quarantine), maps it on import to its own error and message in both dictionaries, and the publish gate reads it as content. + CHECK: grep -c "'lone_surrogate'" apps/app/src/state/reportStore.ts apps/app/src/pdf/import.ts apps/app/src/app/routes/HomeRoute.tsx packages/supabase/src/anatomical-sheets.ts; printf "%s/%s\n" $(grep -c "'home.import.error_lone_surrogate'" apps/app/src/i18n/fr.ts) $(grep -c "'home.import.error_lone_surrogate'" apps/app/src/i18n/en.ts) + EXPECT: reportStore.ts:1 import.ts:3 HomeRoute.tsx:1 anatomical-sheets.ts:1 / 1/1 +6. The Node suites pass on the rebuilt module, with the new cases (app 320, supabase 40, core-wasm 26, domain 262). + CHECK: bash scripts/wasm-build.sh > /dev/null 2>&1; for p in app supabase core-wasm domain; do ./node_modules/.bin/pnpm --filter @faunosteo/$p exec vitest run 2>&1 | grep -E "^ +Tests "; done + EXPECT: Tests 320 passed (320) / Tests 40 passed (40) / Tests 26 passed (26) / Tests 262 passed (262) +7. No oracle, frozen fixture, N-1 copy, golden or seed file changed in the range. + CHECK: git diff --stat 36316cf..HEAD -- crates/core/tests/oracles apps/app/tests/fixtures packages/domain/tests/fixtures packages/core-wasm/tests/n-1 supabase/seed packages/pdf/tests packages/anatomy/tests | wc -l + EXPECT: 0 +8. The tests cover a lone surrogate (high, low, in a key, in a v2 and a v3 report, in a draft, an archive, an attachment, an operation input, a sheet document) and normal data (pairs, literal backslash-u text, a genuine U+FFFD) and assert the original text is kept. + CHECK: grep -cE "fn (a_draft_with_a_lone|an_archive_with_a_lone|an_attachment_with_a_lone|normal_text_with_pairs)" crates/core/tests/archive_rules.rs; grep -cE "fn (lone_surrogate_escapes_are_found|a_lone_surrogate_refuses|normal_text_reads_unchanged)" crates/core/src/domain/js.rs; grep -c "lone surrogate" apps/app/tests/unit/state.quarantine.test.ts apps/app/tests/unit/pdf.import.test.ts packages/supabase/tests/anatomical-sheets.test.ts packages/core-wasm/tests/facade.test.ts + EXPECT: 4 / 3 / each file ≥ 1 +9. A missing or stale wasm module fails the suites instead of skipping them, and no core suite is conditionally skipped. + CHECK: grep -c "stale' : 'missing'" packages/core-wasm/tests/global-setup.ts; grep -l "core-wasm/tests/global-setup.ts" apps/app/vitest.config.ts packages/supabase/vitest.config.ts packages/core-wasm/vitest.config.ts | wc -l; grep -rn "skipIf\|runIf\|isCoreBuilt" apps/app/tests packages/core-wasm/tests packages/core-wasm/src packages/supabase/tests --include=*.ts | grep -v "e2e/" | wc -l + EXPECT: 1 / 2 (core-wasm references it as `tests/global-setup.ts`) / 0 +10. The deleted TypeScript editor cases keep a same-named Rust test each. + CHECK: for n in opens_the_detail_view_for_the_trigger_even_without_an_active_observation only_activates_a_fallback_observation_when_none_is_active always_opens_the_vertebra_picker_on_a_spine_zone routes_bilateral_zones_through_the_side_picker_or_clears_both_sides toggle_zone_adds_a_zone_with_snapshots_then_removes_it ensure_zone_keeps_an_existing_zone_and_reports_its_index add_sides_appends_only_the_missing_sides_and_never_removes_one remove_zone_at_removes_one_zone_by_index_and_keeps_findings detail_view_zones_are_distinct_from_main_view_zones_with_the_same_id collects_vertebrae_across_spine_zones_the_priority_zone_first replaces_per_region_prunes_emptied_zones_and_spawns_zones_for_new_regions keeps_non_spine_zones_untouched_and_ignores_unknown_regions; do grep -c "fn $n" crates/core/tests/editor_rules.rs; done | sort | uniq -c + EXPECT: 12 1 +11. No interface component, style or signed-in screen changed; HomeRoute gains only the two lines of the new case. + CHECK: git diff --stat 36316cf..HEAD -- apps/app/src/components apps/app/src/styles apps/app/src/app/routes/app apps/app/src/app/routes/auth | wc -l; git diff 36316cf..HEAD -- apps/app/src/app/routes/HomeRoute.tsx | grep -c "^[+-][^+-]" + EXPECT: 0 / 2 +12. Documentation states the owner's decision and the refusal paths. + CHECK: grep -c "owner decision 2026-10-14, BDR-051" docs/development/RUST.md; grep -c "Lone UTF-16 surrogates refused, never altered" CHANGELOG.md; grep -c "lone_surrogate" docs/PDF-FORMAT.md + EXPECT: 1 / 1 / 1 +13. The whole pre-merge gate passes. + CHECK: bash scripts/check-all.sh > /tmp/l1-verify-all.log 2>&1; echo "exit $?"; grep -c "== all checks passed" /tmp/l1-verify-all.log + EXPECT: exit 0 / 1 + +## CLARIFICATIONS +- The editor test list has 13 TypeScript cases; "toggles plain zones; the ten bilateral annotations and the 18 others split as the sheet says" maps to `toggles_plain_zones_and_splits_the_observable_annotations_as_the_sheet_says` (renamed: 28 is not the draft's count), hence 12 exact names in criterion 10. +- `crates/core/tests/common/mod.rs::oracle_file` writes each lone escape of an oracle file out as literal text for the test loader only: the oracle files are frozen TypeScript evidence, not user data, and their raw text is still what the L1 test reads. +- The RustSec advisories stage of `check-all.sh` is warn-only by design (RUST.md); its rustls findings predate this range. + +## FILE SCOPE +crates/core/**, packages/domain/tests/r2-characterisation.test.ts, apps/app/src/{app/routes/HomeRoute.tsx,core/sheetOps.ts,i18n/fr.ts,i18n/en.ts,pdf/import.ts,state/reportStore.ts}, apps/app/tests/unit/{state.quarantine.test.ts,pdf.import.test.ts,routes.HomeRoute.import.test.tsx}, packages/supabase/src/anatomical-sheets.ts, packages/supabase/tests/anatomical-sheets.test.ts, packages/core-wasm/src/node.ts, packages/core-wasm/tests/facade.test.ts, docs/development/RUST.md, docs/PDF-FORMAT.md, CHANGELOG.md, .claude/tasks/**, .claude/memory/** diff --git a/.claude/tasks/contracts/2026-10-14-rust-r2-verify.md b/.claude/tasks/contracts/2026-10-14-rust-r2-verify.md new file mode 100644 index 00000000..723272e6 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-14-rust-r2-verify.md @@ -0,0 +1,49 @@ +# CONTRACT — Rust R2: domain core in Rust, used by the application +- date: 2026-10-14 | flow: orchestrator + 4 forks (3 worktrees + 1 in tree), plan challenges ×3, verifier gate | branch: feature/rust-r2-domain-core (off develop 1a7ee7d) +- status: dispatched after the implementation, test and doc commits +- spec: `.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md` (plan + revision 2 §5, which wins), `docs/development/RUST_ARCHITECTURE_REVIEW.md` VI.2 R2 row, VI.3, VI.4, owner brief 2026-10-13 (R2 go: §2 scope, §3 compatibility, §5 runtime, §6 CSP and measures, §7 no UI redesign, §9 tests, §12 exclusions) +- diff range: 1a7ee7d..HEAD (run every CHECK from the repository root; `. scripts/rust-env.sh` first for cargo) + +## REQUEST (IMMUTABLE) +Migrate the existing domain core of Faunosteo to Rust and switch the application to it, with no business behaviour change without a separate decision: sheet / report / archive contracts, SheetHandle and index, observation reducers, finding construction, vertebra selection, publish checks, related transformations and validations, in crates/core and the wasm facade; consumers switched; React, DOM, forms and Supabase services stay in their layers. Preserve Report v3, v2 PDF imports, autonomous archives, observations, findings, vertebrae, annotations, sheet versions, unresolved content, FR/EN, old data; freeze the three archive envelopes first; keep a permanent N-1 reader test; JSON rules (absent optionals, nullable, number format) conformant; no silent loss. Lazy wasm, explicit instantiation failures, no reuse after a trap, degraded behaviour when unavailable. CSP with 'wasm-unsafe-eval' only; measure size, init, op times, page impact, memory; no wasm on pages that do not need it. No UI redesign (four new strings validated by the owner). Out: R3, R4, R5, Step 9, CI/CD, deploy, release 0.2.0, merge into develop. + +## ACCEPTANCE CRITERIA +1. The native Rust gate is green (fmt, clippy -D warnings, tests, ts-rs export, cargo deny). + CHECK: bash scripts/rust-check.sh > /tmp/r2-verify-rust.log 2>&1; echo "exit $?" + EXPECT: exit 0 +2. The core carries at least 135 passing tests (contracts, rules, oracles, conformance). + CHECK: . scripts/rust-env.sh && cargo test -p faunosteo-core 2>&1 | grep "test result" | awk '{s+=$4; f+=$6} END {print s, f}' + EXPECT: 135 0 (first number ≥ 135, second 0) +3. The application sources no longer import the TypeScript domain, and no domain rule or the deleted service is reachable from them by name. + CHECK: grep -rln "@faunosteo/domain" apps/app/src | wc -l; grep -rnE "decideZoneClick|collectVertebrae|buildSheetIndex|buildSheetSnapshot|rebaseReportOnSheet|readReportDocument|readArchiveDocument|zoneInteraction" apps/app/src | wc -l; test -e apps/app/src/services/zoneInteraction.ts; echo $? + EXPECT: 0 / 0 / 1 +4. The application suite passes on the real core (313 tests), including the four new R2 suites. + CHECK: bash scripts/wasm-build.sh > /dev/null 2>&1; ./node_modules/.bin/pnpm --filter @faunosteo/app exec vitest run 2>&1 | grep -E "^ +Tests "; ls apps/app/tests/unit/ | grep -cE "n-1.reader|state.quarantine|routes.EditorRoute.degraded|state.coreFailures" + EXPECT: Tests 313 passed (313) / 4 +5. The Step 6 goldens, the seed and the other packages' fixtures are untouched by R2, and the three frozen archive envelopes are unchanged since their freeze commit. + CHECK: git diff --stat 1a7ee7d..HEAD -- apps/app/tests/fixtures/goldens/step6 supabase/seed packages/domain/tests/fixtures packages/pdf/tests packages/anatomy/tests | wc -l; git diff --stat 3114d67..HEAD -- apps/app/tests/fixtures/goldens/r2 | wc -l + EXPECT: 0 / 0 +6. The shipped module carries no trap export and stays under the 600 KB compressed budget. + CHECK: grep -cE "panic_for_test|recurse_for_test" packages/core-wasm/pkg/faunosteo_wasm.d.ts; gzip -9 -c packages/core-wasm/pkg/faunosteo_wasm_bg.wasm | wc -c + EXPECT: 0 / a number ≤ 600000 +7. No auth, account, shell or entry module references the core runtime (the module is only loaded from the sheet pages). + CHECK: grep -rl "@/core/" apps/app/src/app/routes/auth apps/app/src/app/routes/app apps/app/src/components/shell apps/app/src/components/account apps/app/src/app/App.tsx apps/app/src/main.tsx | wc -l + EXPECT: 0 +8. Only the content failure kinds set a draft aside, and the core-wasm suite proves the runtime (lazy load, trap, recovery, handle rebuild, cap, retry, size). + CHECK: grep -c "outcome.kind !== 'invalid' && outcome.kind !== 'unsupported_version'" apps/app/src/state/reportStore.ts; ./node_modules/.bin/pnpm --filter @faunosteo/core-wasm exec vitest run 2>&1 | grep -E "^ +Tests " + EXPECT: 1 / Tests 25 passed (25) +9. The publish gate fails closed and runs on the real core; the SQL suite (incl. the generated conformance file 011) passes on PGlite. + CHECK: grep -c "refuses publication when the validator cannot run" packages/supabase/tests/anatomical-sheets.test.ts; ./node_modules/.bin/pnpm --filter @faunosteo/supabase exec vitest run 2>&1 | grep -E "^ +Tests "; ./node_modules/.bin/pnpm --filter @faunosteo/supabase exec vitest run tests/db/pgtap.test.ts 2>&1 | grep -E "^ +Tests " + EXPECT: 1 / Tests 39 passed (39) / Tests 12 passed (12) +10. The four validated strings exist in both dictionaries. + CHECK: for k in sheet.core_unavailable sheet.core_retry core.action_failed editor.draft_quarantined home.import.error_core_unavailable; do printf "%s/%s " $(grep -c "'$k'" apps/app/src/i18n/fr.ts) $(grep -c "'$k'" apps/app/src/i18n/en.ts); done + EXPECT: 1/1 1/1 1/1 1/1 1/1 +11. Documentation records the migration (RUST.md §8, DEPLOY.md R2 notes, CHANGELOG). + CHECK: grep -c "^## 8. R2" docs/development/RUST.md; grep -c "From R2 on" DEPLOY.md; grep -c "Rust R2" CHANGELOG.md + EXPECT: 1 / 1 / 1 +12. The whole pre-merge gate passes. + CHECK: bash scripts/check-all.sh > /tmp/r2-verify-all.log 2>&1; echo "exit $?"; grep -c "== all checks passed" /tmp/r2-verify-all.log + EXPECT: exit 0 / 1 + +## FILE SCOPE +crates/core/**, crates/wasm/**, Cargo.toml, Cargo.lock, packages/core-wasm/**, packages/supabase/{src/anatomical-sheets.ts,src/index.ts,package.json,tests/anatomical-sheets.test.ts,vitest.config.ts}, packages/domain/tests/r2-*.test.ts, apps/app/{src,tests,scripts,eslint.config.js,vitest.config.ts,package.json}, supabase/tests/011_sheet_conformance.sql, scripts/{wasm-build.sh,wasm-stamp.mjs}, Dockerfile, docker/nginx.conf, docker/csp-proof/app-image.{sh,mjs}, .gitignore, .dockerignore, .prettierignore, pnpm-lock.yaml, docs/development/{RUST,WORKSPACE,TEST_STRATEGY}.md, packages/README.md, CLAUDE.md, DEPLOY.md, CHANGELOG.md, .claude/tasks/** (plan, TODO, this contract), .claude/memory/** (registries). diff --git a/.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md b/.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md new file mode 100644 index 00000000..c06201ca --- /dev/null +++ b/.claude/tasks/plans/2026-10-13-rust-r2-domain-core.md @@ -0,0 +1,113 @@ +# PLAN — Rust R2: domain core (contracts, rules, sheet handle, reducers) + app switch + +- date: 2026-10-13 | branch: `feature/rust-r2-domain-core` (off develop 1a7ee7d) +- spec: `docs/development/RUST_ARCHITECTURE_REVIEW.md` (rev 2 + Annex C), rows II.2 / VI.2 R2 / VI.3 R2 / VI.4, decisions D-R11, D-R12 (gated functions ported, behaviour preserved), D-R13; owner brief 2026-10-13 (R2 go) +- out of scope: R3 (sanitiser, layer renderer, compose), R4 (PDF reader byte scan, writer, report-compare CLI), R5 (pipeline, importer, upload tool, `packages/domain` deletion), Step 9, CI/CD, deploy, release 0.2.0, any graphic change +- stop: after R2 delivery; no merge into develop before the owner's validation + +## 0. Facts this plan rests on (inventory 2026-10-13) + +- `packages/domain` (2,298 lines, 9 test files): sheet schema (strict Zod), 21 integrity rules, `createEmptySheetDocument`, `buildSheetIndex` (10 closures over Maps, last duplicate wins), report v3 / v2 (strip Zod), migration map, `migrateReportV2ToV3`, `readReportDocument`, `rebaseReportOnSheet`, archive snapshot (`buildSheetSnapshot`, `assertSnapshot` with caps, `snapshotIndexSource`), envelope v1 (`readArchiveDocument`, `ReportArchiveEnvelopeSchema`), branding, labels (25 keys). +- Consumers of `packages/domain` after R2: `packages/pdf` (engine, R4), `packages/anatomy` (pipeline + render, R3/R5), `apps/app/scripts` (`report:compare`, R4), N-1 test fixtures. The app `src/` stops importing it (VI.4). +- App logic to move: `services/zoneInteraction.ts` (213 lines: click decision + 7 reducers + `collectVertebrae` / `syncVertebrae`), `FindingsTreePicker.toggleLeaf` (Finding builder), `VertebraPicker` toggle / all / none, `reportStore` rules (`newReport`, `emptyObservation`, add / remove / move / replace), `persistence` parsing (draft via `readReportDocument`, archive via `ReportArchiveEnvelopeSchema`), `sheets/provider` parsing, `pdf/import.ts` layered read (via engine `readReportArchive` = byte scan + `readArchiveDocument`), `pdf/export.ts` `buildSheetSnapshot`, `packages/supabase` publish gate (`assertPublishable`). +- Display helpers kept in TypeScript (review II.2 class C): `zoneLabel`, `describeZone`, `zoneTrees`, `unresolvedFindings`, import message lines, `isIdentityComplete`, `pickLabel`, `FreeTextFindingInput` trimming (form glue), identity / conclusion / recommendations / next-appointment setters (Zustand assignments of form values; no validation exists today, adding one is a behaviour change: deviation from the review's "set_* validation", stated). +- Routes are static imports; `HomeRoute` and `NewReportRoute` call `useSheet` today (the sheet bundle loads on `/`). +- The engine's `readAttachedDocument` returns `JSON.parse` output after a depth pre-scan capped at 64; `readReportArchive` = that + `readArchiveDocument` + error mapping (`incompatible_version` when a numeric unknown version, else `no_attachment`). +- Zod 3.25.76 semantics to reproduce: object output in schema key order; `.optional()` = absent ok, `null` rejected, absent stays absent; `.nullable()` = key required unless `.default(null)`; `.strict()` rejects unknown keys, others strip; `.int()` = `Number.isInteger` (accepts `2.0`, `1e20`); `.min/.max` on strings count UTF-16 units; `.url()` = `new URL()` succeeds; `.uuid()` = Zod regex; JS regex `$` = end of input; discriminated unions dispatch on the tag. +- R0 facts kept: `serde_json` `preserve_order` + `float_roundtrip`, `js_number` formatter, panic = abort on wasm32, an instance is unusable after a trap, a fresh instance needs a fresh glue module record (cache-busting import). + +## 1. Decisions of this plan (internal; trade-offs stated) + +| # | Decision | Why / alternative rejected | +|---|---|---| +| P1 | Every JSON input is read `text → serde_json::Value → typed`. Before parsing, a pre-pass rewrites `\uD800`–`\uDFFF` escapes that are not a valid surrogate pair to `�` (JSON.parse keeps lone surrogates, serde_json refuses them). Recursion limit 128 (drafts and bundles < 20 deep; archive JSON is pre-scanned at 64 by the TS scanner). | Value-first gives JSON.parse duplicate-key semantics (last value, first position) and lets one parse feed both the layered reader and the typed structs. Refusing lone surrogates would lose a whole report that TypeScript accepts; replacing them is the smallest divergence (leniency decision L1, pinned by a fixture, reported). | +| P2 | Typed structs use serde derive plus field helpers that reproduce Zod: `opt` (absent ok, `null` refused, skipped when `None`), `nullable` (key required, `null` ok), `nullable_default` (absent → `null`), `deny_unknown_fields` exactly where Zod is `.strict()`. Integers are `JsInt` (any finite number with an integer value, kept as f64, printed by `js_number`). Constrained strings are newtypes checked by hand (UTF-16 length, the id / region / colour / sha256 / base64 / uuid / branding-URL patterns). `.url()` = `url` crate parse (WHATWG, as `new URL`), size measured; no `regex` crate. | Serde's implicit `None` for a missing `Option` and its `null`-as-`None` would silently widen what Zod accepts. f64 integers keep `1e20` or `2.0` accepted and printed as JavaScript does. | +| P3 | Discriminated unions (views, annotations, geometry, next appointment, image asset) are untagged enums whose variant structs carry a literal tag field at the Zod schema position (annotations and views: `kind` after the common fields; geometry, next appointment, image asset: tag first). Every struct declares its fields in Zod schema order. | Zod parse output order = schema order; serde's internally tagged enums would print the tag first and break byte equality with `JSON.stringify(ZodSchema.parse(x), null, 2)`, which is the strongest serialisation oracle available. D-R11 (struct order) holds. | +| P4 | Behaviour is ported site by site, quirks included: index maps last-duplicate-wins (as `new Map`), `viewsById` first-wins in the rules, `find` first-wins for `spineAnnotation` and tree paths, JS truthiness (`detailSourceId ""` → main view, `vertebrae: []` kept, `requiresVetReferral: false` dropped), `??=` on rebase labels, `unsupported_envelope` keeping the report origin, a malformed map entry failing the read (no new "never throws" behaviour). | Owner rule: no business behaviour change without a decision. Unifying policies is a later decision, not a side effect. | +| P5 | `SheetHandle` (wasm-bindgen struct) owns the loaded sheet: status, ref, species, schema version, normalized document, assets, asset hashes, migration map and the Rust index. `handle.index_data()` returns `SheetIndexData` once: normalized document, `viewById` / `annotationById` / `findingZoneById` / `regionByCode` (positions, last wins), `annotationsByView` (positions, document order), `spine[region][view]` (position, first wins), `spineIds`, `names[annotationId]`, `nodeKeys` (paths reachable by first-wins walk). The app's `SheetIndex` becomes a class over that data with today's method names (accessors only, `Object.hasOwn`), plus `ops` = the sheet-bound core calls. The handle does not run the integrity rules at load (today's behaviour); a missing main view is a load failure. | ~14 modules keep calling `sheet.annotation(id)` etc., no wasm call in a render, no rule in TypeScript. The canvas keeps the TS renderer (R3) on the normalized document and the TS asset record. | +| P6 | One core call per user action. `zone.click` returns the decision and, when the observation changes, the new observation, plus what the UI needs (`sidesPresent` for the laterality picker, `zoneIndex`). The vertebra picker's initial selection (`collectVertebrae`) is computed when the picker opens (click or chip), never in render. Vertebra grid display (`count`, `count_range`, extended state) stays React. | Review III.3 rule 1 (no call in a render path). | +| P7 | Store: every report entering the store passes the core (`report.new`, draft restore, import, `hydrateReport`), every observation write passes `report.replace_observation` (shape-checked, stripped), list rules are core calls (`add` / `remove` / `move` observation). Field assignments of form values stay Zustand (see §0). A failed core call leaves the state unchanged and raises the `core.action_failed` alert. `hydrateReport` now parses (the "stores as is" characterisation test changes by design, stated). | "Rust parser = single entry" (review I.2); one-line delegations. | +| P8 | Lazy core: `useSheet` (editor, new report) and the import action load it; `HomeRoute` gets the sheet availability from the bundle without the core and loads the core only when a file is chosen; `/login`, `/app/*`, Mon compte never reference it. The glue JS and the `.wasm` are emitted as Vite assets (`?url`), never bundled into a route chunk, fetched on first need. | Owner: no wasm on pages that do not need it. | +| P9 | Runtime: synchronous calls after `await ready()`. A `WebAssembly.RuntimeError` poisons the instance: the failing call returns `{ok:false, kind:'internal'}`, a fresh instance is created in the background (cache-busting dynamic import of the glue asset URL + new `WebAssembly` instance), sheet handles are rebuilt lazily from their retained source text, calls made meanwhile return `core_unavailable`. A load failure (fetch, CSP, compile) gives `core_unavailable` with `retry()` evicting the cached promise. | Review III.3 rules 5 and 6; R0 proof (no reuse after a trap). Async calls everywhere would reintroduce the double-click races the click chain avoids with `getState()`. | +| P10 | Two wasm builds: `packages/core-wasm/pkg/` (shipped, no `proofs` feature) and `pkg-proofs/` (trap exports, tests only). | R0 follow-up "drop --features proofs at R2"; the trap test still needs a trap. | +| P11 | Import = engine byte scan (`readAttachedDocument`, TS, frozen until R4) → `JSON.stringify` → core `archive.import` (layered read + rebase in one call) → the same `ImportError` mapping. Export = core `archive.snapshot` → frozen TS engine (still asserts and writes). | D-R12 go; R4 owns the scanner and the writer. | +| P12 | Draft quarantine: an unreadable `osteo:draft` or `osteo:archive` moves to `osteo:quarantine` (JSON list of `{key, at, raw}`, newest last, cap 10) before anything overwrites it; the draft case raises the `editor.draft_quarantined` alert. | VI.3 R2 row; today's silent drop is a loss. | +| P13 | Publish gate: `publishSheetVersion(client, versionId, validate)` takes the core validator (dependency injection); conformance fixtures `crates/core/tests/conformance/*.json` (document, Rust issues with paths, SQL codes) run in cargo and in a generated `supabase/tests/011_sheet_conformance.sql`; a cargo drift test regenerates and compares the SQL file. | Review III.4. | +| P14 | N-1 reader: the Zod schemas shipped at 1a7ee7d copied verbatim under `packages/core-wasm/tests/n-1/` (frozen, survives R5); a vitest parses every Rust-written report, draft, snapshot and envelope fixture with them. | Review III.3 rule 7, VI.3. | +| P15 | Parity corpus: a TS generator mutates small valid bases (report v3, report v2, horse-slice document, snapshot, branding, labels, envelope, migration map) field by field (delete, `null`, wrong type, empty, unknown key, `2.0`, `-1`, `1e20`, long strings at the caps) and records Zod's outcome (accepted output text or refused); committed under `crates/core/tests/parity/`; cargo asserts the same outcome and byte-equal output; a vitest drift test re-runs Zod on it while `packages/domain` exists. | "Freeze with the old code, then switch" without a dual-run harness. | +| P16 | `apps/app/src` imports nothing from `@faunosteo/domain` (ESLint `no-restricted-imports`); `pickLabel` moves to `apps/app/src/i18n/pickLabel.ts`; types come from `@faunosteo/core-wasm` (ts-rs). The `apps/app` package keeps the dependency for `scripts/` (R4). | VI.4. | +| P17 | App image: wasm stage (`rust:1.99.0-bookworm`, wasm target, `wasm-bindgen-cli` at the `Cargo.lock` version, BuildKit cache mounts) before the Node stage; nginx serves a precompressed `.wasm.gz` (`gzip_static`) when the module is present, else `gzip on` for `application/wasm` (decided on the image's `nginx -V`). Size budget test: served module ≤ 600 KB gzip. | D-R13; the VPS never builds (DEPLOY.md note). | +| P18 | CSP proof on the real image: headless Chromium behind an nginx with the DEPLOY.md headers runs the editor path (new report, zone click, picker, export, import); a variant without `'wasm-unsafe-eval'` shows the degraded state while `/login` stays usable. | VI.2 R2 end criteria. | + +Visible strings, wording validated by the owner 2026-10-13 (the recommended options): +- `sheet.core_unavailable`: « Le moteur de calcul de Faunosteo n'a pas pu être chargé. Vos données de session sont conservées. » / "Faunosteo's computation engine could not be loaded. Your session data is kept."; `sheet.core_retry`: « Réessayer » / "Retry" (editor and new-report degraded notice). +- `core.action_failed` (alert): « Cette action n'a pas pu être appliquée. Réessayez ; votre bilan n'a pas été modifié. » / "This action could not be applied. Try again; your report was not changed." +- `editor.draft_quarantined` (alert): « Le brouillon de cet onglet n'a pas pu être relu par cette version de Faunosteo. Il a été mis de côté, pas supprimé. » / "This tab's draft could not be read by this version of Faunosteo. It was set aside, not deleted." +- `home.import.error_core_unavailable` (import error line): « Le moteur de lecture n'a pas pu être chargé. Réessayez l'import. » / "The reading engine could not be loaded. Try the import again." + +## 2. Core operations (facade `call(op, json)` and `SheetHandle.call(op, json)`) + +Envelope unchanged: `{"ok":true,"value":…}` | `{"ok":false,"kind":…,"detail":…}`. Kinds: `invalid_json`, `invalid_shape`, `unknown_op`, `internal`, plus per-op kinds below. + +Free ops: +- `sheet.check` (document) → `{issues: SheetIssue[], publishable}`; `invalid_shape` when the strict schema refuses. +- `sheet.create_empty` ({species_id, name}) → document. +- `report.new` ({draft, sheet: SheetRef, id, createdAt, observationId}) → Report (draft observations kept, else one empty observation with `observationId`). +- `report.add_observation` ({report, id}) → Report; `report.remove_observation` ({report, index}) → Report; `report.move_observation` ({report, index, direction: 'up' | 'down'}) → Report (no-op at the ends); `report.replace_observation` ({report, index, observation}) → Report (`invalid_shape` when the observation does not parse). +- `vertebra.select` ({selection, action: {kind:'toggle', region, index} | {kind:'all', region, count} | {kind:'none', region}}) → Vertebra[]. +- `archive.parse_envelope` (envelope JSON) → envelope (full v1 schema, shape tier, as `ReportArchiveEnvelopeSchema`). + +Sheet ops (`SheetHandle`): +- constructor `SheetHandle.load(bundleJson)` → handle | error kind `invalid_sheet`; `index_data()` → `SheetIndexData`. +- `draft.restore` ({draft: string, archive: envelope | null}) → `{report, rebase: RebaseOutcome}`; kinds `unsupported_version {found}`, `invalid`. +- `archive.import` (attachment data) → `{read: ArchiveReadOutcome, rebase: RebaseOutcome}`; kinds `incompatible_version {found}` (numeric unknown version), `no_attachment` (anything else). +- `archive.snapshot` ({report}) → SheetSnapshot. +- `report.rebase` ({report, archived: snapshot | null}) → RebaseOutcome. +- `zone.click` ({observation: Observation | null, annotationId}) → `{kind: 'ignore' | 'open_view' | 'activate_fallback' | 'open_vertebra_picker' | 'open_laterality_picker' | 'remove_both_sides' | 'toggle', viewId?, observation?, zoneIndex?, sidesPresent?}`. +- `zone.add_sides` ({observation, annotationId, sides}) → Observation; `zone.remove_at` ({observation, index}) → Observation. +- `vertebra.initial` ({observation, zoneIndex}) → Vertebra[]; `vertebra.sync` ({observation, selection, viewId}) → Observation. +- `finding.toggle` ({observation, findingZoneId, path, side?}) → Observation (adds the built finding with snapshots and the vet flag, or removes the matching one). + +## 3. Phases (one commit or more each; checkpoints reported when a consumer switches) + +- **R2.0 Freeze (TS, before any switch)**: the three archive envelopes (`demo`, `v2full`, `v2unresolved`, fr, fixed `exportedAt`) and their bare reports exported by the current path, committed as goldens; N-1 schema copy; parity corpus generator + corpus; `horse-slice.ts` and `mini-sheet.ts` converted to JSON fixtures; characterisation of the click chain and store outputs that no test pins (exact objects). +- **R2.1 Contracts in Rust**: `domain/js.rs` (JsInt, UTF-16 lengths, patterns, own-key semantics, surrogate pre-pass), sheet schema, report v2 / v3 / identity / migration map, snapshot / branding / labels / envelope structs, ts-rs export; parity corpus green; byte equality with `JSON.stringify(Zod.parse(x), null, 2)` on the seed draft, demo report, v2 fixtures. +- **R2.2 Rules in Rust**: 21 rules + `check`, `create_empty`, index + `SheetIndexData`, `readReportDocument` + migration (612-leaf suite), rebase (exact objects), snapshot build / assert (caps, depth), envelope layered read (decision table); suites ported from `packages/domain/tests` with their exact expectations; conformance fixtures + generated pgTAP + drift test. +- **R2.3 Editor rules in Rust**: zone click + reducers (13-case suite + characterisation), finding toggle, vertebra initial / sync / select, report ops. +- **R2.4 Facade + runtime**: `crates/wasm` (`call`, `SheetHandle`, no proofs in the shipped build), `packages/core-wasm` runtime (lazy, poison, re-instantiate, retry, Node and browser sources, typed client), the trap / load-failure / handle-rebuild tests, size test. +- **R2.5 App switch**: provider + `useSheet` (+ degraded state), `SheetIndex` class, store + persistence + quarantine, click chain + pickers + findings picker, import / export, Home lazy core, publish gate, ESLint restriction, `pickLabel` move, codemod of type imports; deletion of `services/zoneInteraction.ts`, `services/sheetIndex.ts` re-exports and the data-building code in components; app suites green with their assertions (renamed calls only, each changed assertion listed). +- **R2.6 Images and serving**: Dockerfile wasm stage, `.dockerignore`, nginx compression, `check:all` stages (two wasm builds), CSP headless proof on the image, measurements (raw / gzip size, instantiate time, op timings, page-load impact, memory). +- **R2.7 Docs and gates**: RUST.md R2 section (migrated components, deleted TS, exceptions, measurements, census), CLAUDE.md, WORKSPACE.md, TEST_STRATEGY.md, packages/README.md, DEPLOY.md note, CHANGELOG; verifier + security gates; memory; owner manual procedure on the LAN. + +## 4. Oracles (end criteria, review VI.2 R2 row) + +1. Domain suites ported to cargo with exact expectations (validate code + path lists, migrate incl. 612 leaves, rebase exact objects, envelope decision table, branding / labels, snapshot caps); parity corpus 100 % equal. +2. App service / store / component / route suites pass on the core with their assertions; changed assertions listed one by one. +3. The three frozen envelopes: the Rust-path export parses with the frozen N-1 Zod schemas and is semantically equal (deep equal) to the frozen one; bytes differ only by key order (D-R11). +4. The 39 step6 goldens and the seed golden untouched (`git diff --stat` on their dirs empty). +5. `pnpm build` with the wasm; the module is not referenced by the auth / account chunks; served module ≤ 600 KB gzip. +6. App image boots under the production CSP headers in headless Chromium (editor path works); without `'wasm-unsafe-eval'` the editor shows the degraded state and `/login` works. +7. A deliberate trap (proofs build) re-instantiates and the next call succeeds with a rebuilt handle. +8. `pnpm check:all` green; `pnpm db:test` on the real stack with the generated pgTAP file; verifier CONFORME; security PASS. +9. Grep census: no `@faunosteo/domain` import under `apps/app/src`; no `decideZoneClick` / `syncVertebrae` / `buildSheetIndex` / `buildSheetSnapshot` / `rebaseReportOnSheet` / `readReportDocument` reachable from `apps/app/src`. +10. Owner manual FR / EN flow on the LAN (procedure delivered). + +## 5. Revision 2 (2026-10-14, after three plan challenges: correctness CONCERNS(2), robustness FATAL(7) incl. 1 BLOCKER, simplicity CONCERNS(3); 45 findings) + +Supersedes the rows of §1–§4 it names. + +- **P7 replaced** (all three lenses): only core-built observations and reports enter the store through the core (`report.new`, draft restore, import, the reducers' outputs). Form-value edits of an observation (comment, severity, free text, finding removal by identity) stay Zustand assignments, like the identity and text setters. `report.replace_observation` is dropped. Store actions that call the core return `{ ok }`; callers (`NewReportRoute`, `HomeRoute`, the click chain) stop on failure (no navigation, no picker). `hydrateReport` is deleted (test-only seam; tests seed with `hydrateImport` or `setState`). +- **Editor degraded state (robustness BLOCKER 1, correctness 11)**: `useSheet` gets `core_unavailable` and `invalid_sheet` states; `EditorRoute` never redirects in those states, renders the notice + retry, and never restores or overwrites `osteo:draft` while the core has not read it. Test: reload `/editor` with the core failing, draft intact. +- **Runtime (robustness 2, 3, 9, 10)**: every sheet op resolves the handle through the runtime with an instance generation; calls into a poisoned glue record are refused (including `free`). The compiled `WebAssembly.Module` is kept; one spare glue record is pre-imported after a successful load so a re-instantiation needs no network; at most 3 re-instantiations per page, then `core_unavailable` ("reload"). `retry()` clears the runtime, `useSheet` and provider caches. A vitest `globalSetup` fails (never skips) when `pkg/` or `pkg-proofs/` is missing or its build stamp (hash of `crates/**` + `Cargo.lock`, written by `scripts/wasm-build.sh`) differs from the tree. The trap → re-instantiate → next call test also runs once in headless Chromium on a build linked to `pkg-proofs` (best effort; recorded if not obtainable). +- **Quarantine (robustness 4, 5, 16; simplicity 13; correctness 10)**: only the content kinds (`invalid`, `unsupported_version`) quarantine; any other kind leaves the keys untouched and shows the degraded state. Raw text goes to `osteo:quarantine:draft` / `osteo:quarantine:archive` (newest only); the source key is removed only after the quarantine write succeeded; a draft rebased with unresolved items keeps its raw pre-rebase text in `osteo:quarantine:draft-pre-rebase`. Paths that never read the draft (New report / Import from Home after a reload) keep today's semantics (a new session replaces the tab draft). No recovery UI at R2 (stated residual). +- **SheetIndexData minimal (simplicity 3, correctness 3)**: `mainViewId` (first `main` view by position), `viewById`, `annotationById`, `findingZoneById` (positions, last wins), `names[annotationId]`, `spineIds` (last-wins annotation, observable with a region), `nodeKeys` keyed by the JSON text of `[zoneId, ...path]` (collision-free) reachable by the first-wins walk on the last-wins zone, plus the normalized document. No `annotationsByView`, `spine`, `regionByCode` (no TS reader after the switch). `regions()` reads the document. +- **Ops (simplicity 4, correctness 4, 8, 13)**: exposed only with a TS caller: `sheet.check` (publish gate), `report.new`, `report.add_observation`, `report.remove_observation`, `report.move_observation`, `vertebra.select` (called in the tap handler, never in a state updater), sheet ops `draft.restore` ({draft: string, archive: string | null} → report, rebase, parsed archive or `archiveRejected`), `archive.import`, `archive.snapshot`, `zone.click` (returns the initial vertebra selection for `open_vertebra_picker`), `zone.add_sides`, `zone.remove_at`, `vertebra.initial` (chip path), `vertebra.sync`, `finding.toggle` (takes the clicked leaf's position among its siblings; parents walked first-wins as `findNode`). `sheet.create_empty`, `report.rebase`, `archive.parse_envelope` are Rust functions with cargo tests, no op. The failure envelope gains an optional numeric `found` (js_number). +- **Oracles (simplicity 2, correctness 1, 5, 6, 7, 12)**: the full mutation corpus is dropped. Instead: (a) Zod output oracles of the reference documents (`crates/core/tests/oracles`, done: draft and legacy sheets, demo v3, v2 fixtures, migration map, byte-equal); (b) a characterisation set frozen from the TS functions for the quirks (`detailSourceId: ""`, `requiresVetReferral: false`, `vertebrae: []`, `collectVertebrae` concatenated-key collision, `syncVertebrae` region order and second spine zone, rebase `??=`, malformed map entry, numeric literals `3.0` / `1e0`, lone surrogate lowercase escapes); (c) a table of hostile inputs per constraint site with Zod's accept/refuse verdict (vitest writes it with `MAKE_R2_ORACLES=1`, cargo asserts it); (d) type-level equality of ts-rs types against `z.output` per contract (vitest `expectTypeOf`); the golden-report helper switches to the core migration for the Rust run; the publish-gate tests use the real Node core. Oracle 9 reworded: "not imported by `apps/app/src`" (the engine keeps its TS index and reader until R4). +- **Fail-closed publish gate (robustness 17)**: `publishSheetVersion(client, versionId, validate)`, `validate` required; anything but `{ok: true, value: {publishable: true}}` throws before the RPC; test with a failing core. +- **Pages (simplicity 11)**: Home and `/new` read the sheet availability from the bundle without the core; the core loads at `/new` submit, on an import file pick, and in the editor. +- **Display glue accepted (simplicity 12)**: `VertebraPicker` `has` and the grid extent, `FindingsTreePicker` `matches` / `isLeafSelected` / `countSelectedUnder`, `ObservationCard` `zoneTrees` / `unresolvedFindings` / `describeZone`, import message lines: render-time predicates over core data, listed in the RUST.md census. +- **Docker / serving (robustness 12, 14, 15, 13; simplicity 9, 10)**: `packages/core-wasm/package.json` in the manifest COPY list; `pkg-proofs/` git- and docker-ignored; wasm-bindgen runs in the same RUN as the cache-mounted cargo build; the wasm-bindgen version shares the builder's `ARG` line, `scripts/wasm-build.sh` keeps the `Cargo.lock` guard; a check that the shipped `pkg/faunosteo_wasm.d.ts` has no proof export. CSP proof = `docker/csp-proof` extended to the app image: with the keyword the editor loads and one zone click works; without it the editor shows the degraded state and `/login` works; network-level assertion that `/login` and `/app/account` request neither the glue nor the `.wasm`; Firefox and WebKit too when their Playwright builds are present (else recorded). DEPLOY.md: R2+ images are never built on the VPS; the CSP must carry `'wasm-unsafe-eval'` before an R2 image is deployed. +- **Kept, with reason**: the N-1 verbatim copy (already committed; permanent, survives R5); `vertebra.select` in the core (review II.2 class A, owner listed "Sélection vertébrale"); one gate for R2 with an owner-facing checkpoint report after R2.4 (no stop: the owner asked to stop after R2). +- **Interim risks stated (robustness 8, 11)**: the import reads up to the 16 MiB attachment in the long-lived main instance until R4 moves it to a Worker; no React error boundary is added (no UI change at R2), every core entry point catches. +- **Owner decision to confirm at delivery (correctness 9)**: L1, a lone UTF-16 surrogate escape in a draft or an archive becomes U+FFFD instead of refusing the document. +- `pickLabel` → the existing `apps/app/src/i18n/pickLocaleLabel.ts` (object overload), no new copy (simplicity 6). `mini-sheet.ts` conversion dropped (R3/R5, simplicity 8). `url` crate size measured at R2.4 against the budget (simplicity 14). diff --git a/.dockerignore b/.dockerignore index e32191b5..9465d471 100644 --- a/.dockerignore +++ b/.dockerignore @@ -20,5 +20,6 @@ docs/ logos/ target/ packages/core-wasm/pkg/ +packages/core-wasm/pkg-proofs/ docker/dev-gateway/htpasswd docker/dev-gateway/mailpit-password diff --git a/.gitignore b/.gitignore index 837d4870..050024ff 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ supabase/.temp/ # Rust workspace (R0): build output and the generated browser module target/ packages/core-wasm/pkg/ +packages/core-wasm/pkg-proofs/ # DEV gateway credentials (generated by scripts/dev-gateway.sh) docker/dev-gateway/htpasswd diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..7b16da12 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +# Byte-exact oracles and generated fixtures: their tests compare bytes, never reformat them. +crates/core/tests/oracles/ +crates/core/tests/conformance/ +crates/core/tests/fixtures/ +apps/app/tests/fixtures/goldens/ +packages/core-wasm/types/ +packages/core-wasm/pkg/ +packages/core-wasm/pkg-proofs/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 44caca9d..d29ae969 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ Versions follow [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Changed (Rust R2, domain core, 2026-10-14) + +- **The application's domain rules run in Rust** (`crates/core`, through the wasm facade and `@faunosteo/core-wasm`): sheet, report and archive contracts with the Zod semantics reproduced, the 21 sheet integrity rules and the publish check, the sheet index, the v2 → v3 migration, the rebase on the loaded sheet, the sheet snapshot, the layered archive reading, the editor's click chain and reducers, the findings and vertebra rules, report creation and the observation list operations. Consumers switched: the editor, the pickers, the store, the draft restore, the PDF import (after the engine's byte scan) and export (snapshot), the Supabase publish gate (fails closed). The module (340 KB gzip) loads only on the sheet pages; sign-in, the `/app` space and Home never request it. Without `'wasm-unsafe-eval'` in the CSP the editor shows a degraded notice with a retry and leaves the session's draft untouched (DEPLOY.md: set the keyword before deploying an R2 image; R2 images are never built on the VPS). +- **Session data never dropped silently**: an unreadable draft or archive is set aside under `osteo:quarantine:*` with a notice; a draft rebased with unresolved items keeps its raw text. +- Behaviour differences, declared in `docs/development/RUST.md` §8.7: drafts and attachments written in contract order (values unchanged, the previous build reads them, D-R11); typed errors on inputs the interface never produced. +- **Lone UTF-16 surrogates refused, never altered** (L1, owner decision): a draft, archive or attachment whose JSON escapes a lone surrogate is no longer read with U+FFFD in its place. The draft or archive is set aside verbatim under its quarantine key with the existing notice; a PDF import is refused with a new message (malformed text, file not modified); an editor action is refused and the report left as it was. +- Proofs: contracts byte-equal to the Zod output on the reference documents, the three archive envelopes frozen before the switch and deep-equal after, 924 cases and verdicts frozen from the TypeScript, permanent N-1 reader test, generated pgTAP conformance file (real stack 446/446), CSP proof on the real image. No interface, archive format, database or graphic change; release 0.2.0 untouched. + ### Changed (development environment, 2026-10-13) - **DEV on the private network** — the owner tests from other devices: the DEV origin (the machine's LAN address, `FAUNOSTEO_DEV_HOST`, detected or set) lives in `scripts/dev-env.sh`; `pnpm dev` serves the app on that origin wired to the local stack, `pnpm dev:offline` keeps the local tool alone; every Supabase CLI call goes through `scripts/supabase.sh` so `config.toml` (API external URL for the mail links, site URL, Studio API URL via `env()`) follows the origin; private-network redirect URLs for the PKCE links. Identity recorded: Faunosteo, https://faunosteo.com; environments DEV / STAGING / PROD and the exposure table in `docs/development/ENVIRONMENTS.md`. diff --git a/CLAUDE.md b/CLAUDE.md index 917d3c3b..cec0d32d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -35,6 +35,12 @@ routes stay unauthenticated. Step 8 (= Rust R1) added the files foundation: the the Rust worker `crates/worker` (keyed job loop + keyless sandboxed decode child) producing 512 × 512 WebP avatars, a deferred purge queue, and the profile photo in Mon compte, the sidebar, the drawer and the top bar (`docs/development/STORAGE.md`). +Rust R2 moved the application's domain rules into `crates/core` (sheet, report and +archive contracts, integrity rules, sheet index, migration, rebase, snapshot, layered +archive reading, editor reducers, findings and vertebra rules, report operations), +reached through the wasm facade and `packages/core-wasm`, loaded lazily by the sheet +pages only (`docs/development/RUST.md` §8); `packages/domain` is frozen for the PDF +engine, the pipeline and the compare CLI. MVP species: equine only. Open-source MIT. --- @@ -198,10 +204,10 @@ faunosteo/ │ ├─ auth/{validation,redirects,useAuthFailureMessage}.ts ← Zod schemas (i18n keys), safe next path, failure phrasing │ ├─ account/{validation,useProfileForm}.ts ← account section schemas + one-save form hook │ ├─ config/env.ts ← runtime config resolution -│ ├─ sheets/{provider,useSheet}.ts ← SheetProvider interface, bundled implementation, per-species hook +│ ├─ sheets/{provider,useSheet}.ts ← raw bundled payload; useSheet loads it into the core (ready / none / core_unavailable / invalid_sheet + retry), useSheetAvailability without the core +│ ├─ core/{runtime,sheetOps,reportOps}.ts ← the page's CoreRuntime (Vite asset URLs, lazy), typed sheet-bound and free core operations │ ├─ services/ -│ │ ├─ sheetIndex.ts ← read-only lookups over the loaded sheet (ids, never labels) -│ │ ├─ zoneInteraction.ts ← pure click decision + observation reducers (zones, sides, vertebrae) +│ │ ├─ sheetIndex.ts ← SheetIndex class: reads the core's SheetIndexData (ids, never labels) + `ops` │ │ └─ localeSync.ts ← profiles.locale ↔ localeStore (account wins on sign-in) │ ├─ i18n/ │ │ ├─ types.ts ← Locale type + Dict type @@ -210,7 +216,7 @@ faunosteo/ │ │ └─ useT.ts ← useT() hook (reads localeStore) │ ├─ state/ │ │ ├─ authStore.ts ← session, user, profile, roles, recovery flag (onAuthStateChange) -│ │ ├─ reportStore.ts ← Zustand store (Report v3) + persistence.ts (sessionStorage adapter, v2 draft migration) +│ │ ├─ reportStore.ts ← Zustand store (Report v3, core-built reports, actions answer { ok }) + persistence.ts (raw texts, quarantine keys) │ │ ├─ localeStore.ts ← locale Zustand store (persisted to localStorage) │ │ └─ practitionerCache.ts ← localStorage prefill │ ├─ anatomy/drawing.ts ← sanitised asset + generated annotation layer → inline per view @@ -271,15 +277,15 @@ faunosteo/ │ │ └─ draft/ ← GENERATED working revision: document, cleaned horse.svg, sheet-ref, report-migration-map, CHANGELOG, REVIEW-REPORT, review/*.svg, equine_draft.sql │ └─ tests/*.sql ← pgTAP: allowed + denied paths per policy ├─ packages/README.md ← shared packages index -├─ packages/core-wasm/ ← @faunosteo/core-wasm: loader of the browser module (pkg/ built, git-ignored), ts-rs types (committed), R0 proofs (panic, serialisation, size) +├─ packages/core-wasm/ ← @faunosteo/core-wasm: CoreRuntime (lazy, poison, recovery) + Node source, pkg/ shipped and pkg-proofs/ (built, git-ignored, BUILD_STAMP), ts-rs types (committed), frozen N-1 reader (tests/n-1), tests ├─ crates/ ← Rust workspace (Cargo.toml, rust-toolchain.toml, deny.toml, clippy.toml, .cargo/config.toml at the root) -│ ├─ core/ ← faunosteo-core: contracts (report types), js_number + JS pretty formatter, facade `call(op, json)`; no I/O, no clock (lint-enforced) -│ ├─ wasm/ ← faunosteo-wasm: wasm-bindgen facade (core_version, call, R0 trap proofs) +│ ├─ core/ ← faunosteo-core: domain/{js,sheet,report,archive,editor,session} (contracts and rules), ops.rs + facade.rs (`call`, `call_with_sheet`), json (JS number printing); tests/{oracles,conformance,fixtures} frozen from the TypeScript; no I/O, no clock (lint-enforced) +│ ├─ wasm/ ← faunosteo-wasm: wasm-bindgen facade (core_version, call, SheetHandle; trap exports in the proofs build only) │ └─ worker/ ← faunosteo-worker: plain main; `decode` sandboxed child (rlimits, seccomp allowlist, image → libwebp), parent Spawner + RIFF check; R1 `run` loop: config, log (JSON lines, allowlist), keys, backend trait + http (ureq, PostgREST rpc + Storage objects), job, sweep, watchdog; Dockerfile, scripts/derive-seccomp.sh -├─ scripts/{rust-env,rust-check,wasm-build,check-all,avatar-e2e}.sh ← native Rust gate, wasm build, the pre-merge gate (`pnpm check:all`), the real-stack avatar e2e +├─ scripts/{rust-env,rust-check,wasm-build,check-all,avatar-e2e}.sh, wasm-stamp.mjs ← native Rust gate, wasm build (pkg + pkg-proofs + stamp), the pre-merge gate (`pnpm check:all`), the real-stack avatar e2e ├─ scripts/{dev-env,supabase,dev}.sh ← the DEV origin (LAN address) in one place; CLI wrapper; `pnpm dev` on that origin ├─ docker-compose.yml ← `app` service; `worker` service under the `worker` profile (read-only, cap_drop ALL, external Supabase network, `.env.worker`) -├─ docker/rust-builder.Dockerfile, rust-run.sh, csp-proof/ ← reproducible Rust builder (alternative) + the CSP proof +├─ docker/rust-builder.Dockerfile, rust-run.sh, csp-proof/ ← reproducible Rust builder (alternative) + the CSP proofs (R0 module, R2 app image: app-image.sh) ├─ .gitea/workflows/ci.yml ← PREPARED, never executed (no runner): rust job (builder image, scripts/rust-check.sh, types drift, wasm), install, typecheck, test, lint, build, docker (app + worker test stage + runtime) ├─ .gitea/workflows/{rust-advisories,release-images}.yml ← nightly RustSec advisories; manual digest-tagged image publication (no deploy) ├─ .claude/{tasks/TODO.md,memory/,audits/} @@ -299,20 +305,22 @@ User interaction → Zustand store (reportStore) → Components read store via selectors (no prop drilling) -Sheet loading - → useSheet(speciesId) → SheetProvider (bundled: virtual:faunosteo-sheet, SHEET_BUNDLE=draft) - → Zod-validated document + assets + migration map → buildSheetIndex() +Sheet loading (Rust core, RUST.md §8) + → useSheet(speciesId) → SheetProvider (bundled: virtual:faunosteo-sheet, SHEET_BUNDLE=draft) → raw payload + → coreRuntime().ready() (lazy; core_unavailable + retry on failure) → SheetHandle(payload): strict parse of the + document and migration map, index → index_data → SheetIndex (tables only) + ops (sheet-bound core calls) SVG interaction - → AnatomyCanvas builds the view: sanitised asset + renderAnnotationLayer() (markers from the document) - → delegated click on [data-anno-id] → decideZoneClick() (services/zoneInteraction, pure) + → AnatomyCanvas builds the view: sanitised asset + renderAnnotationLayer() (markers from the document; TS until R3) + → delegated click on [data-anno-id] → sheet.ops.zoneClick(observation, id) (one core call: decision + new observation) → open_view → DetailModal (same drawing, view_box crop, or the view's own asset) - → open_vertebra_picker / open_laterality_picker → pickers → reducers (ensureZone, addSides, syncVertebrae) - → toggle / remove_both_sides → updateObservation() in store + → open_vertebra_picker (initial selection from the core) / open_laterality_picker (sides present) → pickers + → vertebra.select per tap, vertebra.sync / zone.add_sides on confirm → updateObservation() in store + → toggle / remove_both_sides → the core's observation → updateObservation(); findings picker → finding.toggle PDF export (app side: apps/app/src/pdf, engine: packages/pdf) → exportReportToPdf(report, index, { locale }) - → buildSheetSnapshot(index.sheet, report) + loadBranding() (4 logos bundled at build time, no network) + defaultPdfLabels + → index.ops.snapshot(report) (core: archive.snapshot) + loadBranding() (4 logos bundled at build time, no network) + defaultPdfLabels → exportReportArchive({ report, sheet, branding, labels, locale, rasterizer: browserRasterizer, exportedAt }) assertSnapshot (caps, integrity, sheet invariant) → fonts (WinAnsi StandardFonts, safeText guard) → per observation: composeHighlightedViewSvg (xmldom: sanitise allowlist → composeViewSvg highlight) → rasterizer → page @@ -321,11 +329,11 @@ PDF export (app side: apps/app/src/pdf, engine: packages/pdf) → exportFromEnvelope(envelope, …) re-exports an archive from its own snapshot, branding and labels (no sheet) PDF import - → importReportFromPdf(bytes, migrationMap) → readReportArchive (engine) - → 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) + → readAttachment(bytes) → engine byte scan for the EmbeddedFile stream (TS until R4; no pdf-lib parse on untrusted + bytes, BLK-009): named osteo-report* first, capped native inflation, JSON depth pre-scan + → loadSheetIndex (core loads here) → importAttachment(data, index) → core archive.import: layered reading (report: + v3 as is, v2 migrated, else incompatible_version; envelope metadata tolerant, snapshot/branding/labels strict → + archive kept or snapshotRejected) + rebase on the loaded sheet (unresolved flags, labels kept), one call → hydrateImport({ report, archive }) → one alert (archive_ok / snapshot_rejected / rebased / migrated) → navigate /editor Identity (Step 7, docs/development/IDENTITY.md) @@ -395,9 +403,14 @@ Database (Supabase) and annotations); no graphic redesign without prior validation ### Schemas -- `packages/domain/src/report/*.ts` are the report data contracts (v3 current, v2 input only); never change - without bumping the version on a breaking change (additive optional fields keep it) -- All user-provided data goes through Zod parse before hitting the store +- The data contracts live in Rust since R2 (`crates/core/src/domain/{sheet,report,archive}`, Zod semantics + reproduced: strict where Zod was strict, optional absent, nullable required, Zod schema field order); + `packages/domain` is frozen (no new logic) for the PDF engine, the pipeline and the compare CLI until R4/R5, + and its Zod copy under `packages/core-wasm/tests/n-1` is the permanent N-1 reader. Never change a contract + without bumping the version on a breaking change (additive optional fields keep it); a change touches the + Rust struct, the regenerated ts-rs types and the N-1 test +- Every report entering the store comes from the core (new report, draft restore, import, reducer outputs); + form values are plain assignments (D-R7) - Report version 3: zones by `(annotationId, viewId)`, findings by `(findingZoneId, path)`, severities `mild|moderate|severe`, `sheet` reference; v2 is migrated through `report-migration-map.json` (`migrateReportV2ToV3`, never throws on content, `unresolved: true` marks what the sheet no longer holds); @@ -406,7 +419,7 @@ Database (Supabase) ### Stores - No direct store mutation outside Zustand actions - No business logic in components — delegate to store actions -- sessionStorage keys: osteo:draft (auto-saved on every change, v3; a v2 draft is migrated and a stale draft rebased on restore once the sheet is loaded) and osteo:archive (the imported archive envelope, written only on import / new report / reset, never on edits) +- sessionStorage keys: osteo:draft (auto-saved on every change, v3; a v2 draft is migrated and a stale draft rebased on restore once the sheet is loaded, by the core) and osteo:archive (the imported archive envelope, written only on import / new report / reset, never on edits); osteo:quarantine:{draft,archive} (an unreadable text set aside, newest only, never dropped) and osteo:quarantine:draft-pre-rebase (the raw draft of a rebase that flagged items) - localStorage key: osteo:lastPractitioner (practitioner prefill cache) ### PDF @@ -497,8 +510,10 @@ Database (Supabase) ## Rust by default (rule adopted 2026-10-12, BDR-043) -Study and roadmap: `docs/development/RUST_ARCHITECTURE_REVIEW.md` (awaiting -the owner's validation before any implementation; release 0.2.0 unaffected). +Study and roadmap: `docs/development/RUST_ARCHITECTURE_REVIEW.md` (validated with +the amendments of Annex C). Done: R0, R1 (worker), R2 (domain core used by the app, +`docs/development/RUST.md` §8). Next: R3 (anatomy core), R4 (PDF core), R5 +(pipeline); release 0.2.0 unaffected. - Any logic that can run in Rust with no significant loss (features, UX, graphics, data compatibility, security, reliability, useful performance, @@ -554,12 +569,14 @@ the owner's validation before any implementation; release 0.2.0 unaffected). ## Workflow expectations -- Run `pnpm typecheck && pnpm test:run` before every commit. -- Domain schema changes (`packages/domain/src/report/*.ts`) require updating all callers + bumping version if breaking. +- Run `pnpm typecheck && pnpm test:run` before every commit; after any change under `crates/core` or `crates/wasm`, + `pnpm wasm:build` first (the suites refuse a missing or stale module: BUILD_STAMP). +- Contract changes (`crates/core/src/domain`) require the ts-rs types regenerated and committed, all callers updated, + the N-1 reader test green, and a version bump if breaking. `apps/app/src` never imports `@faunosteo/domain` (ESLint). - Annotation rendering changes require updating docs/ANNOTATION-RENDERING.md first. - 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). +- Ask before any change to `readReportArchive`, `readArchiveDocument`, `readAttachedDocument` or `rebaseReportOnSheet`, and to their Rust ports (`crates/core/src/domain/{archive/read,report/rebase,report/read,session}.rs`) — 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. diff --git a/Cargo.lock b/Cargo.lock index 8f470cab..e6e63164 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -189,6 +189,7 @@ dependencies = [ "serde", "serde_json", "ts-rs", + "url", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5efce14c..1351812e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,9 @@ serde = { version = "1.0.229", features = ["derive"] } # float_roundtrip: the default parser is a fast path that can be one ULP off (found by the R0 # proof: 1715.4285714285713 came back as 1715.428571428571); JavaScript parses correctly. serde_json = { version = "1.0.154", features = ["preserve_order", "float_roundtrip"] } -ts-rs = { version = "12.0", features = ["serde-compat"] } +ts-rs = { version = "12.0", features = ["serde-compat", "no-serde-warnings"] } +# Zod `.url()` is `new URL()`: the WHATWG parser of the url crate reproduces it (R2 plan P2). +url = "2.5.8" # The CLI in docker/rust-builder.Dockerfile must be this exact version. wasm-bindgen = "=0.2.129" image = { version = "0.25.10", default-features = false, features = ["jpeg", "png", "webp"] } diff --git a/DEPLOY.md b/DEPLOY.md index f18bfd39..75c40ae4 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -608,6 +608,13 @@ builds. The procedure below is prepared and documented now; it replaces this way is deployed, after a separate validation**. Until then the live deployment keeps building on the VPS as documented above. +**From R2 on (`feature/rust-r2-domain-core`), the application image +compiles the Rust core** (Dockerfile stage `wasm`: the Rust toolchain and +`wasm-bindgen-cli` in a builder stage). Such an image is never built on the +VPS (1 vCPU, 1 GB): it is built on the development machine or a runner and +pulled by digest, with the CSP of the next section in place first. The live +deployment, built from `main` before R2, is not affected. + 1. Build and publish: run the manual workflow `release-images` (`.gitea/workflows/release-images.yml`, `workflow_dispatch`, never on push) on the forge. Prerequisite not met yet: no runner, registry or @@ -634,14 +641,23 @@ working with the read-only token. ### WebAssembly and the CSP (from R2 on) -The application does not load the Rust core module before plan R2. When it -does, the two `Content-Security-Policy` headers of this file (nginx and -Caddy options) must carry `'wasm-unsafe-eval'` in `script-src`: +From R2 the application loads the Rust core module in the sheet pages (the +editor, the new-report submit, the PDF import). Before an R2 image is +deployed, the two `Content-Security-Policy` headers of this file (nginx and +Caddy options above) must carry `'wasm-unsafe-eval'` in `script-src`; the +examples above still show the header of the live, pre-R2 deployment: ```text script-src 'self' 'wasm-unsafe-eval'; ``` +Without the keyword an R2 image stays usable but degraded: the sign-in and +account pages work, the editor shows "Le moteur de calcul de Faunosteo n'a +pas pu être chargé" with a retry, and the tab's draft is left untouched +(proven on the image by `docker/csp-proof/app-image.sh`, +`docs/development/RUST.md` §8.5). The keyword adds nothing for a pre-R2 +image, so it can be set on the proxy before the switch. + Proven at R0 under the production nginx image and headers with headless Chrome for Testing 156 (`docker/csp-proof/run.sh`, result in `docs/development/RUST.md` §5): with `script-src 'self'` the browser refuses @@ -651,10 +667,10 @@ the module instantiates. `'wasm-unsafe-eval'` allows WebAssembly compilation only, never `eval` or inline scripts (the proof's inline variant was still blocked). Browser floor for the keyword: Chrome 97, Firefox 102, Safari 16 (the Vite 7 baseline). The `.wasm` file is served as `application/wasm` by -`nginx:1.31-alpine` out of the box; at R2 `docker/nginx.conf` gains -`gzip_static on;` for a precompressed `.wasm.gz` (or `gzip_types -application/wasm`) and the served, compressed size is what the D-R13 budget -counts. +`nginx:1.31-alpine` out of the box; since R2 the image precompresses it and +`docker/nginx.conf` serves the `.wasm.gz` with `gzip_static on;` (372 KB +served for 1.18 MB raw, D-R13 budget 600 KB). A proxy in front must pass +`Content-Encoding` through and keep the `application/wasm` type. --- diff --git a/Dockerfile b/Dockerfile index e66a3733..2f78a32d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,28 @@ +# ---- stage 0: wasm -------------------------------------------------- +# The Rust core compiled to the browser module (R2). Same toolchain and wasm-bindgen CLI +# as docker/rust-builder.Dockerfile (keep the two ARG lines equal); scripts/wasm-build.sh +# refuses a CLI that differs from the wasm-bindgen crate in Cargo.lock. The production VPS +# never builds this image: it pulls it by digest (DEPLOY.md). +FROM rust:1.99.0-bookworm AS wasm + +ARG WASM_BINDGEN_VERSION=0.2.129 + +RUN rustup target add wasm32-unknown-unknown \ + && rustup component add rustfmt clippy \ + && cargo install wasm-bindgen-cli --version "${WASM_BINDGEN_VERSION}" --locked \ + && rm -rf /usr/local/cargo/registry + +WORKDIR /w +COPY rust-toolchain.toml Cargo.toml Cargo.lock ./ +COPY .cargo .cargo +COPY crates crates +COPY scripts/rust-env.sh scripts/wasm-build.sh scripts/ +# The build and wasm-bindgen run in one RUN: the cache-mounted target never reaches the +# layer, the generated packages/core-wasm/pkg does. +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/w/target \ + WASM_BUILD_SHIPPED_ONLY=1 bash scripts/wasm-build.sh + # ---- stage 1: builder ----------------------------------------------- # Node 24 LTS (Node 20 reached end-of-life on 2026-04-30). pnpm pinned to the # same version as package.json "packageManager"; pnpm 11 needs Node >= 22.13 @@ -15,6 +40,7 @@ COPY packages/domain/package.json packages/domain/ COPY packages/anatomy/package.json packages/anatomy/ COPY packages/pdf/package.json packages/pdf/ COPY packages/supabase/package.json packages/supabase/ +COPY packages/core-wasm/package.json packages/core-wasm/ RUN pnpm install --frozen-lockfile @@ -25,13 +51,15 @@ RUN pnpm install --frozen-lockfile ARG SHEET_BUNDLE=none ENV SHEET_BUNDLE=$SHEET_BUNDLE COPY . . +COPY --from=wasm /w/packages/core-wasm/pkg packages/core-wasm/pkg RUN pnpm --filter @faunosteo/app build # ---- stage 2: runner ------------------------------------------------ FROM nginx:1.31-alpine AS runner -# Copy built static assets +# Copy built static assets; the core module is served precompressed (gzip_static) COPY --from=builder /app/apps/app/dist /usr/share/nginx/html +RUN gzip -9 -k /usr/share/nginx/html/assets/*.wasm # Copy custom nginx config and entrypoint COPY docker/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/apps/app/eslint.config.js b/apps/app/eslint.config.js index f075753e..12964c78 100644 --- a/apps/app/eslint.config.js +++ b/apps/app/eslint.config.js @@ -38,4 +38,24 @@ export default tseslint.config( ], }, }, + { + // R2: the application's rules run in the Rust core; its contracts come from + // @faunosteo/core-wasm. The TypeScript domain stays frozen for the PDF engine, the + // pipeline and scripts/ until R4/R5 (RUST_ARCHITECTURE_REVIEW VI.4). + files: ['src/**/*.{ts,tsx}'], + rules: { + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: '@faunosteo/domain', + message: 'Use @faunosteo/core-wasm (types) and the core operations.', + }, + ], + patterns: ['@faunosteo/domain/*'], + }, + ], + }, + }, ) diff --git a/apps/app/package.json b/apps/app/package.json index b10b734f..770946bf 100644 --- a/apps/app/package.json +++ b/apps/app/package.json @@ -16,6 +16,7 @@ }, "dependencies": { "@faunosteo/anatomy": "workspace:*", + "@faunosteo/core-wasm": "workspace:*", "@faunosteo/domain": "workspace:*", "@faunosteo/pdf": "workspace:*", "@faunosteo/supabase": "workspace:*", diff --git a/apps/app/scripts/compare-reports.ts b/apps/app/scripts/compare-reports.ts index d93ca7e4..4fcd9e4a 100644 --- a/apps/app/scripts/compare-reports.ts +++ b/apps/app/scripts/compare-reports.ts @@ -27,8 +27,7 @@ import { MAX_PDF_BYTES, readAttachedDocument, } from '@faunosteo/pdf' -import { parseBundledSheet } from '../src/sheets/provider' -import { buildSheetIndex, type SheetIndex } from '../src/services/sheetIndex' +import { compareSheetIndex, type CompareSheetIndex } from './compare/sheet' import { compareReport, diffLines, @@ -47,20 +46,15 @@ const SEED_DIR = resolve( /** pnpm runs the script from apps/app; paths are typed from the caller's folder. */ const CWD = process.env.INIT_CWD ?? process.cwd() -function loadSheet(): SheetIndex { +function loadSheet(): CompareSheetIndex { const json = (name: string) => JSON.parse(readFileSync(join(SEED_DIR, name), 'utf8')) as never // The comparison needs the document and the map, not the drawings. - return buildSheetIndex( - parseBundledSheet({ - status: 'draft', - ref: json('sheet-ref.json'), - document: json('document.json'), - migrationMap: json('report-migration-map.json'), - assets: {}, - assetHashes: {}, - }), - ) + return compareSheetIndex({ + ref: json('sheet-ref.json'), + document: json('document.json'), + migrationMap: json('report-migration-map.json'), + }) } /** A folder stands for its PDFs; any other argument stays one entry. */ @@ -79,7 +73,7 @@ function expandArg(arg: string): string[] { async function compareFile( path: string, - sheet: SheetIndex, + sheet: CompareSheetIndex, args: CliArgs, ): Promise { const st = statSync(path) diff --git a/apps/app/scripts/compare/report.ts b/apps/app/scripts/compare/report.ts index bee013cd..3284851f 100644 --- a/apps/app/scripts/compare/report.ts +++ b/apps/app/scripts/compare/report.ts @@ -1,4 +1,5 @@ import { + pickLabel, ReportV2Schema, findingPathKey, type ArchiveReadOutcome, @@ -9,7 +10,7 @@ import { type ReportZone, } from '@faunosteo/domain' import type { Locale } from '../../src/i18n/types' -import { pickLabel, type SheetIndex } from '../../src/services/sheetIndex' +import type { CompareSheetIndex as SheetIndex } from './sheet' /** * Pure comparison of a report document found in a PDF with its v3 reading: diff --git a/apps/app/scripts/compare/sheet.ts b/apps/app/scripts/compare/sheet.ts new file mode 100644 index 00000000..15f83d22 --- /dev/null +++ b/apps/app/scripts/compare/sheet.ts @@ -0,0 +1,45 @@ +import { + AnatomicalSheetDocumentSchema, + buildSheetIndex, + ReportMigrationMapSchema, + type AnatomicalSheetDocument, + type ReportMigrationMap, + type SheetIndex, + type SheetRef, +} from '@faunosteo/domain' + +/** + * The reference sheet as the archive check tool reads it: the frozen TypeScript domain + * (Zod schemas and index), as the application did before R2. The tool moves to the Rust + * core with the PDF reader at R4 (RUST_ARCHITECTURE_REVIEW VI.4); until then it keeps its + * own reading, independent of the application's core runtime. + */ + +export interface CompareSheet { + status: 'draft' | 'published' + ref: SheetRef + document: AnatomicalSheetDocument + assets: Readonly> + migrationMap: ReportMigrationMap +} + +export type CompareSheetIndex = SheetIndex + +/** The seed files of the reference sheet, parsed and indexed. */ +export function compareSheetIndex(seed: { + ref: { sheet_id: string; version_id: string | null; document_sha256: string } + document: unknown + migrationMap: unknown +}): CompareSheetIndex { + return buildSheetIndex({ + status: 'draft', + ref: { + sheetId: seed.ref.sheet_id, + versionId: seed.ref.version_id, + documentSha256: seed.ref.document_sha256, + }, + document: AnatomicalSheetDocumentSchema.parse(seed.document), + assets: {}, + migrationMap: ReportMigrationMapSchema.parse(seed.migrationMap), + }) +} diff --git a/apps/app/src/anatomy/drawing.ts b/apps/app/src/anatomy/drawing.ts index cbee6683..2f47af67 100644 --- a/apps/app/src/anatomy/drawing.ts +++ b/apps/app/src/anatomy/drawing.ts @@ -3,7 +3,7 @@ import { renderAnnotationLayer, viewBoxOf, } from '@faunosteo/anatomy/render' -import type { SheetView } from '@faunosteo/domain' +import type { SheetView } from '@faunosteo/core-wasm/types' import type { SheetIndex } from '@/services/sheetIndex' /** diff --git a/apps/app/src/app/routes/EditorRoute.tsx b/apps/app/src/app/routes/EditorRoute.tsx index c0858ea1..1c7f31e7 100644 --- a/apps/app/src/app/routes/EditorRoute.tsx +++ b/apps/app/src/app/routes/EditorRoute.tsx @@ -3,7 +3,10 @@ import { useNavigate } from 'react-router-dom' import AnatomyCanvas from '@/components/canvas/AnatomyCanvas' import DetailModal from '@/components/canvas/DetailModal' import ObservationList from '@/components/observation/ObservationList' -import ObservationPickers from '@/components/observation/ObservationPickers' +import ObservationPickers, { + type LateralTarget, + type VertebraTarget, +} from '@/components/observation/ObservationPickers' import ConclusionPanel from '@/components/report/ConclusionPanel' import ReportHeader from '@/components/report/ReportHeader' import EditInfosDialog, { @@ -11,25 +14,22 @@ import EditInfosDialog, { type Identity, } from '@/components/report/EditInfosDialog' import DisclaimerDialog from '@/components/report/DisclaimerDialog' +import CoreUnavailable from '@/components/report/CoreUnavailable' import Button from '@/components/ui/Button' -import { useReportStore } from '@/state/reportStore' +import { + useReportStore, + type ActionResult, + type RestoreResult, +} from '@/state/reportStore' import { writeCachedPractitioner } from '@/state/practitionerCache' import { useLocaleStore } from '@/state/localeStore' import { useSheet } from '@/sheets/useSheet' -import { pickLabel, type SheetIndex } from '@/services/sheetIndex' -import { - decideZoneClick, - ensureZone, - refOf, - removeAllSides, - removeZoneAt, - toggleZone, - type ZoneRef, -} from '@/services/zoneInteraction' +import type { SheetIndex } from '@/services/sheetIndex' +import { pickLabel } from '@/i18n/pickLocaleLabel' import type { ViewStates } from '@/anatomy/drawing' import { exportReportToPdf } from '@/pdf/export' import type { ExportWarning } from '@faunosteo/pdf' -import type { RebaseOutcome } from '@faunosteo/domain' +import type { RebaseOutcome } from '@faunosteo/core-wasm/types' import { useT } from '@/i18n/useT' import { DEFAULT_SPECIES_ID } from './NewReportRoute' @@ -45,6 +45,19 @@ function unresolvedCountOf(outcome: RebaseOutcome): number { return outcome.unresolvedZones + outcome.unresolvedFindings } +/** The alert of a restore, if any: a rebase on another sheet or a draft set aside. */ +function restoreAlert( + result: RestoreResult, + t: ReturnType, +): string | null { + if (result.kind === 'quarantined') return t('editor.draft_quarantined') + if (result.kind === 'restored' && result.rebase.rebased) { + const count = String(unresolvedCountOf(result.rebase)) + return t('editor.draft_rebased').replace('{count}', count) + } + return null +} + /** Editor on the reference sheet: wires the canvas, the pickers and the store. */ export default function EditorRoute() { const navigate = useNavigate() @@ -56,8 +69,14 @@ export default function EditorRoute() { const sheet = useSheet(report?.animal.speciesId ?? DEFAULT_SPECIES_ID) const [detailViewId, setDetailViewId] = useState(null) - const [vertebraTarget, setVertebraTarget] = useState(null) - const [lateralTarget, setLateralTarget] = useState(null) + const [vertebraTarget, setVertebraTarget] = useState( + null, + ) + const [lateralTarget, setLateralTarget] = useState( + null, + ) + // The core failed while reading the draft: stay here, keep the draft, offer a retry. + const [restoreFailed, setRestoreFailed] = useState(false) const [disclaimer, setDisclaimer] = useState(null) const [exporting, setExporting] = useState(false) const [editDraft, setEditDraft] = useState(null) @@ -69,15 +88,24 @@ export default function EditorRoute() { }, []) // No report in memory: restore the per-tab draft once the sheet is known. - // A draft rebased on another sheet is announced with its unresolved count. + // A draft rebased on another sheet is announced with its unresolved count, + // an unreadable one is set aside. While the core cannot run, nothing is + // read or written and the page stays on the degraded notice (no redirect). useEffect(() => { if (report) return + if (sheet.status === 'core_unavailable' || sheet.status === 'invalid_sheet') + return if (sheet.status === 'ready') { - const outcome = store.restoreDraft(sheet.index) - if (outcome?.rebased && !rebaseAlerted.current) { + const result = store.restoreDraft(sheet.index) + // Nothing could be read or set aside: stay, keep the draft where it is. + if (result?.kind === 'core_unavailable' || result?.kind === 'unreadable_kept') { + setRestoreFailed(true) + return + } + const alert = result ? restoreAlert(result, t) : null + if (alert && !rebaseAlerted.current) { rebaseAlerted.current = true - const count = String(unresolvedCountOf(outcome)) - window.alert(t('editor.draft_rebased').replace('{count}', count)) + window.alert(alert) } } if (sheet.status !== 'loading' && !useReportStore.getState().report) @@ -111,42 +139,56 @@ export default function EditorRoute() { if (sheet.status !== 'ready' || !report) return const activeObs = activeIndex >= 0 ? report.observations[activeIndex] : undefined - const index = sheet.index - const annotation = index.annotation(annotationId) - const decision = decideZoneClick(annotation, activeObs) - if (!annotation) return - switch (decision.kind) { - case 'ignore': - return + const outcome = sheet.index.ops.zoneClick(activeObs ?? null, annotationId) + if (!outcome.ok) return window.alert(t('core.action_failed')) + const click = outcome.value + if (click.observation) store.updateObservation(activeIndex, click.observation) + switch (click.kind) { case 'open_view': - return setDetailViewId(decision.viewId) + return setDetailViewId(click.viewId ?? null) case 'activate_fallback': return store.setActiveObservation(report.observations.length - 1) - case 'open_vertebra_picker': { - const { observation, index: zoneIndex } = ensureZone( - activeObs!, - annotation, - ) - store.updateObservation(activeIndex, observation) - return setVertebraTarget(zoneIndex) - } + case 'open_vertebra_picker': + return setVertebraTarget({ + zoneIndex: click.zoneIndex ?? 0, + initial: click.vertebrae ?? [], + }) case 'open_laterality_picker': - return setLateralTarget(refOf(annotation)) - case 'remove_both_sides': - return store.updateObservation( - activeIndex, - removeAllSides(activeObs!, refOf(annotation)), - ) - case 'toggle': - return store.updateObservation( - activeIndex, - toggleZone(activeObs!, annotation), - ) + return setLateralTarget({ + annotationId, + sidesPresent: click.sidesPresent ?? [], + }) + default: + return } }, - [sheet, store], + [sheet, store, t], ) + /** A store action the core ran: the practitioner hears about a failure. */ + const guarded = useCallback( + (result: ActionResult) => { + if (!result.ok) window.alert(t('core.action_failed')) + }, + [t], + ) + + /** The vertebra picker opened from a zone chip: the core computes its selection. */ + function openVertebraPicker(index: SheetIndex, zoneIndex: number) { + if (!activeObs) return + const outcome = index.ops.vertebraInitial(activeObs, zoneIndex) + if (!outcome.ok) return window.alert(t('core.action_failed')) + setVertebraTarget({ zoneIndex, initial: outcome.value }) + } + + function removeZone(index: SheetIndex, i: number, zoneIndex: number) { + const obs = report?.observations[i] + if (!obs) return + const outcome = index.ops.removeZoneAt(obs, zoneIndex) + if (outcome.ok) store.updateObservation(i, outcome.value) + else window.alert(t('core.action_failed')) + } + function acknowledgeDisclaimer() { sessionStorage?.setItem(DISCLAIMER_FLAG, '1') setDisclaimer(null) @@ -190,6 +232,12 @@ export default function EditorRoute() { } } + if (sheet.status === 'core_unavailable' || sheet.status === 'invalid_sheet') { + return + } + if (restoreFailed) { + return window.location.reload()} /> + } if (!report) return null if (sheet.status === 'loading') { return ( @@ -218,7 +266,7 @@ export default function EditorRoute() {
store.setActiveObservation(activeIndex === i ? -1 : i) } - onAdd={store.addObservation} - onDelete={store.removeObservation} - onMoveUp={store.moveObservationUp} - onMoveDown={store.moveObservationDown} + onAdd={() => guarded(store.addObservation())} + onDelete={(i) => guarded(store.removeObservation(i))} + onMoveUp={(i) => guarded(store.moveObservationUp(i))} + onMoveDown={(i) => guarded(store.moveObservationDown(i))} sheet={index} onChange={store.updateObservation} onOpenVertebraPicker={(_i, zoneIndex) => - setVertebraTarget(zoneIndex) + openVertebraPicker(index, zoneIndex) } - onRemoveZone={(i, zoneIndex) => { - const obs = report.observations[i] - if (obs) store.updateObservation(i, removeZoneAt(obs, zoneIndex)) - }} + onRemoveZone={(i, zoneIndex) => removeZone(index, i, zoneIndex)} /> (null) const hydrateImport = useReportStore((s) => s.hydrateImport) - const sheet = useSheet(DEFAULT_SPECIES_ID) + // The page only needs to know a sheet exists; the core loads when a file is picked. + const sheet = useSheetAvailability(DEFAULT_SPECIES_ID) const [error, setError] = useState(null) const [busy, setBusy] = useState(false) const t = useT() /** Read, rebase onto the loaded sheet, open; the editor always works on that sheet. */ - async function importFile(file: File, index: SheetIndex) { + async function importFile(file: File) { // The engine refuses the same size; checking first keeps a huge file out of memory. if (file.size > MAX_PDF_BYTES) throw new ImportError('invalid_pdf') const bytes = new Uint8Array(await file.arrayBuffer()) - const outcome = await importReportFromPdf(bytes, index.sheet.migrationMap) - const rebase = rebaseReportOnSheet( - outcome.report, - index, - outcome.archive?.sheetSnapshot ?? null, - ) + const attachment = await readAttachment(bytes) + const index = await loadSheetIndex(DEFAULT_SPECIES_ID) + if (!index) throw new ImportError('core_unavailable') + const { read: outcome, rebase } = importAttachment(attachment, index) hydrateImport({ report: rebase.report, archive: outcome.archive }) const lines = importMessages(outcome, rebase, t) if (lines.length > 0) window.alert(lines.join('\n\n')) @@ -135,7 +141,7 @@ export default function HomeRoute() { setBusy(true) setError(null) try { - await importFile(file, sheet.index) + await importFile(file) } catch (err) { setError(importErrorMessage(err, t)) } finally { diff --git a/apps/app/src/app/routes/NewReportRoute.tsx b/apps/app/src/app/routes/NewReportRoute.tsx index e4dbdad1..eb43d37c 100644 --- a/apps/app/src/app/routes/NewReportRoute.tsx +++ b/apps/app/src/app/routes/NewReportRoute.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' -import type { Animal, Owner, Practitioner } from '@faunosteo/domain' +import type { Animal, Owner, Practitioner } from '@faunosteo/core-wasm/types' import PractitionerForm from '@/components/report/PractitionerForm' import AnimalForm from '@/components/report/AnimalForm' import AppHeader from '@/components/brand/AppHeader' @@ -13,7 +13,8 @@ import { writeCachedPractitioner, } from '@/state/practitionerCache' import { useReportStore } from '@/state/reportStore' -import { useSheet } from '@/sheets/useSheet' +import { useSheetAvailability } from '@/sheets/useSheet' +import { coreRuntime } from '@/core/runtime' import { useT } from '@/i18n/useT' /** The one species this build ships a sheet for. */ @@ -23,7 +24,8 @@ export default function NewReportRoute() { const navigate = useNavigate() const initReport = useReportStore((s) => s.initReport) const t = useT() - const sheet = useSheet(DEFAULT_SPECIES_ID) + // The form needs the sheet's reference and name only; the core loads on submit. + const sheet = useSheetAvailability(DEFAULT_SPECIES_ID) const [practitioner, setPractitioner] = useState({ name: '' }) const [animal, setAnimal] = useState({ @@ -44,10 +46,14 @@ export default function NewReportRoute() { owner.name.trim() && sheet.status === 'ready' - function submit() { + async function submit() { if (!canSubmit || sheet.status !== 'ready') return writeCachedPractitioner(practitioner) - initReport( + if (!(await coreRuntime().ready())) { + window.alert(t('sheet.core_unavailable')) + return + } + const created = initReport( { date, practitioner, @@ -57,9 +63,10 @@ export default function NewReportRoute() { conclusion: '', recommendations: '', }, - sheet.index.sheet.ref, + sheet.sheet.ref, ) - navigate('/editor') + if (created.ok) navigate('/editor') + else window.alert(t('core.action_failed')) } return ( @@ -91,8 +98,8 @@ export default function NewReportRoute() { sheet.status === 'ready' ? [ { - id: sheet.index.sheet.speciesId, - name: sheet.index.sheet.document.name, + id: sheet.sheet.speciesId, + name: sheet.sheet.name, }, ] : [ diff --git a/apps/app/src/components/observation/FindingsTreePicker.tsx b/apps/app/src/components/observation/FindingsTreePicker.tsx index d41013f8..03cf8fe7 100644 --- a/apps/app/src/components/observation/FindingsTreePicker.tsx +++ b/apps/app/src/components/observation/FindingsTreePicker.tsx @@ -7,9 +7,9 @@ import type { FindingZone, LateralSide, LocalizedOptionalText, -} from '@faunosteo/domain' +} from '@faunosteo/core-wasm/types' import Button from '@/components/ui/Button' -import { pickLabel } from '@/services/sheetIndex' +import { pickLabel } from '@/i18n/pickLocaleLabel' import { useT } from '@/i18n/useT' import { useLocaleStore } from '@/state/localeStore' import type { Locale } from '@/i18n/types' @@ -25,7 +25,11 @@ export interface FindingsTreePickerProps { zone: FindingZone side?: LateralSide selected: Finding[] - onChange: (next: Finding[]) => void + /** + * A leaf was ticked or unticked: its path and its position among the siblings shown. + * The parent has the core build or remove the finding (R2). + */ + onToggle: (leafPath: string[], leafPosition: number) => void } function isLeaf(node: TreeNode): boolean { @@ -69,13 +73,14 @@ function descriptionOf(node: TreeNode, locale: Locale): string | undefined { /** * Drill-down picker over one finding zone of the sheet. A finding is keyed - * by `(findingZoneId, path, side)`; labels are snapshotted at selection. + * by `(findingZoneId, path, side)`; the core snapshots its labels when it + * builds it. The selection predicates below only decide what is shown. */ export default function FindingsTreePicker({ zone, side, selected, - onChange, + onToggle, }: FindingsTreePickerProps) { const t = useT() const locale = useLocaleStore((s) => s.locale) @@ -125,25 +130,6 @@ export default function FindingsTreePicker({ selected.filter((f) => matches(f) && pathStartsWith(f.path, nodePath)) .length - function toggleLeaf(leafPath: string[], leaf: TreeNode) { - if (isLeafSelected(leafPath)) { - onChange( - selected.filter((f) => !(matches(f) && samePath(f.path, leafPath))), - ) - return - } - const next: Finding = { - findingZoneId: zone.id, - path: leafPath, - labelFrSnapshot: leaf.name.fr, - labelEnSnapshot: leaf.name.en, - } - if ('requires_vet_referral' in leaf && leaf.requires_vet_referral) - next.requiresVetReferral = true - if (side) next.side = side - onChange([...selected, next]) - } - const focusedDescription = focusedNode && descriptionOf(focusedNode, locale) return ( @@ -202,7 +188,7 @@ export default function FindingsTreePicker({ {t('findings.no_options')} ) : ( - currentNodes.map((node) => { + currentNodes.map((node, position) => { const nodePath = [...path, node.id] const nodeLabel = pickLabel(node.name, locale) const nodeDesc = descriptionOf(node, locale) @@ -215,7 +201,7 @@ export default function FindingsTreePicker({
{ + sheet: S + mainView: SheetView + view(id: string): SheetView | undefined + annotation(id: string): Annotation | undefined + annotationsOfView(viewId: string): Annotation[] + findingZone(id: string): FindingZone | undefined + /** The category or node at a path, undefined when absent from the sheet. */ + nodeAt( + zoneId: string, + path: readonly string[], + ): FindingCategory | FindingNode | undefined + regions(): VertebralRegion[] + region(code: string): VertebralRegion | undefined + /** The annotation that opens the vertebra picker for a region on a view. */ + spineAnnotation( + regionCode: string, + viewId: string, + ): ObservableAnnotation | undefined + /** Whether an annotation opens the vertebra picker. */ + isSpine(annotationId: string): boolean + name(annotation: Annotation): LocalizedText +} + +/** The label in a locale, the other locale as fallback, '' when none. */ +export function pickLabel( + text: LocalizedText | null | undefined, + locale: 'fr' | 'en', +): string { + if (!text) return '' + return locale === 'en' ? text.en || text.fr : text.fr || text.en +} + +export function isObservable( + a: Annotation | undefined, +): a is ObservableAnnotation { + return a !== undefined && a.kind !== 'detail_trigger' +} + +function nodeAtPath( + zone: FindingZone | undefined, + path: readonly string[], +): FindingCategory | FindingNode | undefined { + if (!zone || path.length === 0) return undefined + let node: FindingCategory | FindingNode | undefined = zone.categories.find( + (c) => c.id === path[0], + ) + for (const segment of path.slice(1)) { + if (!node) return undefined + node = node.children.find((n) => n.id === segment) + } + return node +} + +export function buildSheetIndex( + sheet: S, +): SheetIndex { + const { document } = sheet + const views = new Map(document.views.map((v) => [v.id, v])) + const annotations = new Map(document.annotations.map((a) => [a.id, a])) + const zones = new Map(document.finding_zones.map((z) => [z.id, z])) + const regions = new Map( + document.vertebral_config.regions.map((r) => [r.code, r]), + ) + const mainView = document.views.find((v) => v.kind === 'main') + if (!mainView) throw new Error('sheet has no main view') + + return { + sheet, + mainView, + view: (id) => views.get(id), + annotation: (id) => annotations.get(id), + annotationsOfView: (viewId) => + document.annotations.filter((a) => a.view_id === viewId), + findingZone: (id) => zones.get(id), + nodeAt: (zoneId, path) => nodeAtPath(zones.get(zoneId), path), + regions: () => document.vertebral_config.regions, + region: (code) => regions.get(code), + spineAnnotation: (code, viewId) => + document.annotations.find( + (a): a is ObservableAnnotation => + isObservable(a) && + a.view_id === viewId && + a.vertebral_region_code === code, + ), + isSpine: (id) => { + const a = annotations.get(id) + return isObservable(a) && a.vertebral_region_code !== null + }, + name: (a) => + a.kind === 'detail_trigger' + ? (a.name ?? views.get(a.opens_view_id)?.name ?? { fr: '', en: '' }) + : a.name, + } +} diff --git a/packages/core-wasm/tests/n-1/domain/anatomical-sheet/validate.ts b/packages/core-wasm/tests/n-1/domain/anatomical-sheet/validate.ts new file mode 100644 index 00000000..97aa6ead --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/anatomical-sheet/validate.ts @@ -0,0 +1,494 @@ +import type { + AnatomicalSheetDocument, + Annotation, + FindingNode, + SheetView, + VertebralRegion, +} from './schema' + +/** + * Integrity tier of the sheet model (ANATOMICAL_SHEET_MODEL.md §2.1). + * + * The shape tier (Zod) accepts dangling references so drafts can be saved + * mid-edit; this tier lists every inconsistency for the editor and gates + * publication. Each rule is one function; codes are part of the contract + * shared with the SQL re-check (private.sheet_document_issues). + */ + +export type SheetIssueSeverity = 'error' | 'warning' + +export interface SheetIssue { + code: string + severity: SheetIssueSeverity + path: string + message: string +} + +type Rule = (doc: AnatomicalSheetDocument) => SheetIssue[] + +type ObservableAnnotation = Exclude +type TriggerAnnotation = Extract +type DetailView = Extract + +/** A sibling level of the finding tree: categories or node children. */ +interface FindingLevelItem { + id: string + reference_ids: readonly string[] + children: readonly FindingNode[] +} + +function error(code: string, path: string, message: string): SheetIssue { + return { code, severity: 'error', path, message } +} + +function warning(code: string, path: string, message: string): SheetIssue { + return { code, severity: 'warning', path, message } +} + +/** Indexes of entries whose value already appeared earlier in the list. */ +function repeatedIndexes(values: readonly string[]): number[] { + const seen = new Set() + const repeated: number[] = [] + values.forEach((value, index) => { + if (seen.has(value)) repeated.push(index) + seen.add(value) + }) + return repeated +} + +function duplicateIssues( + values: readonly string[], + code: string, + pathOf: (index: number) => string, +): SheetIssue[] { + return repeatedIndexes(values).map((index) => + error(code, pathOf(index), `Duplicate id "${values[index]}"`), + ) +} + +function isObservable( + annotation: Annotation, +): annotation is ObservableAnnotation { + return annotation.kind !== 'detail_trigger' +} + +function isTrigger(annotation: Annotation): annotation is TriggerAnnotation { + return annotation.kind === 'detail_trigger' +} + +function viewsById(doc: AnatomicalSheetDocument): Map { + const byId = new Map() + for (const view of doc.views) if (!byId.has(view.id)) byId.set(view.id, view) + return byId +} + +/** Rendering starts from a single root drawing. */ +const checkMainViewCount: Rule = (doc) => { + const count = doc.views.filter((view) => view.kind === 'main').length + if (count === 1) return [] + return [ + error('view.main.count', 'views', `Expected 1 main view, found ${count}`), + ] +} + +const checkViewIdsUnique: Rule = (doc) => + duplicateIssues( + doc.views.map((view) => view.id), + 'view.id.duplicate', + (index) => `views[${index}].id`, + ) + +const checkViewParentsExist: Rule = (doc) => { + const byId = viewsById(doc) + return doc.views.flatMap((view, index) => + view.kind === 'detail' && !byId.has(view.parent_view_id) + ? [ + error( + 'view.parent.missing', + `views[${index}].parent_view_id`, + `Parent view "${view.parent_view_id}" does not exist`, + ), + ] + : [], + ) +} + +/** + * True when the parent chain loops before reaching the main view. A + * missing parent ends the walk: that case is view.parent.missing. + */ +function loopsBeforeMain(view: DetailView, byId: Map) { + const visited = new Set([view.id]) + let current: SheetView = view + while (current.kind === 'detail') { + const parent = byId.get(current.parent_view_id) + if (!parent) return false + if (visited.has(parent.id)) return true + visited.add(parent.id) + current = parent + } + return false +} + +const checkViewParentCycles: Rule = (doc) => { + const byId = viewsById(doc) + return doc.views.flatMap((view, index) => + view.kind === 'detail' && loopsBeforeMain(view, byId) + ? [ + error( + 'view.parent.cycle', + `views[${index}].parent_view_id`, + `Parent chain of "${view.id}" never reaches the main view`, + ), + ] + : [], + ) +} + +function isOpenedFromParent( + view: DetailView, + doc: AnatomicalSheetDocument, +): boolean { + return doc.annotations.some( + (annotation) => + isTrigger(annotation) && + annotation.opens_view_id === view.id && + annotation.view_id === view.parent_view_id, + ) +} + +/** A detail view nobody can open is dead content for the practitioner. */ +const checkViewsReachable: Rule = (doc) => { + const byId = viewsById(doc) + return doc.views.flatMap((view, index) => + view.kind === 'detail' && + byId.has(view.parent_view_id) && + !isOpenedFromParent(view, doc) + ? [ + error( + 'view.unreachable', + `views[${index}]`, + `No detail_trigger in "${view.parent_view_id}" opens "${view.id}"`, + ), + ] + : [], + ) +} + +/** Every view must have something to draw: its own asset or a crop. */ +function viewAssetIssue(view: SheetView, index: number): SheetIssue[] { + if (view.svg_asset_id !== null) return [] + if (view.kind === 'main') { + return [ + error( + 'view.asset.missing', + `views[${index}].svg_asset_id`, + `Main view "${view.id}" has no SVG asset`, + ), + ] + } + if (view.view_box !== null) return [] + return [ + error( + 'view.asset.missing', + `views[${index}].view_box`, + `Detail view "${view.id}" has neither an asset nor a view_box`, + ), + ] +} + +const checkViewAssets: Rule = (doc) => doc.views.flatMap(viewAssetIssue) + +/** Report points are keyed by annotation id across every view. */ +const checkAnnotationIdsUnique: Rule = (doc) => + duplicateIssues( + doc.annotations.map((annotation) => annotation.id), + 'annotation.id.duplicate', + (index) => `annotations[${index}].id`, + ) + +const checkAnnotationViews: Rule = (doc) => { + const byId = viewsById(doc) + return doc.annotations.flatMap((annotation, index) => + byId.has(annotation.view_id) + ? [] + : [ + error( + 'annotation.view.missing', + `annotations[${index}].view_id`, + `View "${annotation.view_id}" does not exist`, + ), + ], + ) +} + +const checkAnnotationCategories: Rule = (doc) => { + const ids = new Set(doc.categories.map((category) => category.id)) + return doc.annotations.flatMap((annotation, index) => + ids.has(annotation.category_id) + ? [] + : [ + error( + 'annotation.category.missing', + `annotations[${index}].category_id`, + `Category "${annotation.category_id}" does not exist`, + ), + ], + ) +} + +/** A trigger opens a direct child of the view it is drawn in. */ +function opensChildOfOwnView( + trigger: TriggerAnnotation, + byId: Map, +): boolean { + const target = byId.get(trigger.opens_view_id) + return target?.kind === 'detail' && target.parent_view_id === trigger.view_id +} + +const checkTriggerTargets: Rule = (doc) => { + const byId = viewsById(doc) + return doc.annotations.flatMap((annotation, index) => + isTrigger(annotation) && !opensChildOfOwnView(annotation, byId) + ? [ + error( + 'annotation.opens_view.invalid', + `annotations[${index}].opens_view_id`, + `"${annotation.opens_view_id}" is not a detail child of ` + + `"${annotation.view_id}"`, + ), + ] + : [], + ) +} + +const checkAnnotationFindingZones: Rule = (doc) => { + const ids = new Set(doc.finding_zones.map((zone) => zone.id)) + return doc.annotations.flatMap((annotation, index) => + isObservable(annotation) && + annotation.finding_zone_id !== null && + !ids.has(annotation.finding_zone_id) + ? [ + error( + 'annotation.finding_zone.missing', + `annotations[${index}].finding_zone_id`, + `Finding zone "${annotation.finding_zone_id}" does not exist`, + ), + ] + : [], + ) +} + +const checkAnnotationRegions: Rule = (doc) => { + const codes = new Set(doc.vertebral_config.regions.map((r) => r.code)) + return doc.annotations.flatMap((annotation, index) => + isObservable(annotation) && + annotation.vertebral_region_code !== null && + !codes.has(annotation.vertebral_region_code) + ? [ + error( + 'annotation.region.missing', + `annotations[${index}].vertebral_region_code`, + `Vertebral region "${annotation.vertebral_region_code}" ` + + 'is not configured', + ), + ] + : [], + ) +} + +/** Allowed in a draft, but a click on it would offer nothing to record. */ +const checkAnnotationsHaveFindings: Rule = (doc) => + doc.annotations.flatMap((annotation, index) => + isObservable(annotation) && annotation.finding_zone_id === null + ? [ + warning( + 'annotation.no_findings', + `annotations[${index}].finding_zone_id`, + `Annotation "${annotation.id}" is linked to no finding zone`, + ), + ] + : [], + ) + +const checkRegionCodesUnique: Rule = (doc) => + duplicateIssues( + doc.vertebral_config.regions.map((region) => region.code), + 'region.code.duplicate', + (index) => `vertebral_config.regions[${index}].code`, + ) + +const checkCategoryIdsUnique: Rule = (doc) => + duplicateIssues( + doc.categories.map((category) => category.id), + 'category.id.duplicate', + (index) => `categories[${index}].id`, + ) + +const checkFindingZoneIdsUnique: Rule = (doc) => + duplicateIssues( + doc.finding_zones.map((zone) => zone.id), + 'finding_zone.id.duplicate', + (index) => `finding_zones[${index}].id`, + ) + +/** + * Findings are addressed by (zone, path[]) as Finding.path does today, so + * ids only need to be unique among siblings, at every depth. + */ +function siblingIssues( + nodes: readonly FindingLevelItem[], + path: string, +): SheetIssue[] { + const own = duplicateIssues( + nodes.map((node) => node.id), + 'finding.id.duplicate', + (index) => `${path}[${index}].id`, + ) + const nested = nodes.flatMap((node, index) => + siblingIssues(node.children, `${path}[${index}].children`), + ) + return [...own, ...nested] +} + +const checkFindingSiblings: Rule = (doc) => + doc.finding_zones.flatMap((zone, index) => + siblingIssues(zone.categories, `finding_zones[${index}].categories`), + ) + +/** Allowed in a draft, but nothing on the drawing can reach this zone. */ +const checkFindingZonesReferenced: Rule = (doc) => { + const referenced = new Set( + doc.annotations.filter(isObservable).map((a) => a.finding_zone_id), + ) + return doc.finding_zones.flatMap((zone, index) => + referenced.has(zone.id) + ? [] + : [ + warning( + 'finding_zone.unreferenced', + `finding_zones[${index}]`, + `No annotation points to finding zone "${zone.id}"`, + ), + ], + ) +} + +const checkReferenceIdsUnique: Rule = (doc) => + duplicateIssues( + doc.references.map((reference) => reference.id), + 'reference.id.duplicate', + (index) => `references[${index}].id`, + ) + +/** A citation must point at a declared reference, at every depth. */ +function citationIssues( + nodes: readonly FindingLevelItem[], + path: string, + known: ReadonlySet, +): SheetIssue[] { + return nodes.flatMap((node, index) => { + const own = node.reference_ids.flatMap((id, refIndex) => + known.has(id) + ? [] + : [ + error( + 'finding.reference.missing', + `${path}[${index}].reference_ids[${refIndex}]`, + `Reference "${id}" is not declared in references`, + ), + ], + ) + const nested = citationIssues( + node.children, + `${path}[${index}].children`, + known, + ) + return [...own, ...nested] + }) +} + +const checkFindingReferences: Rule = (doc) => { + const known = new Set(doc.references.map((reference) => reference.id)) + return doc.finding_zones.flatMap((zone, index) => + citationIssues( + zone.categories, + `finding_zones[${index}].categories`, + known, + ), + ) +} + +/** The usual count must sit inside the documented variation. */ +function countRangeIssue(region: VertebralRegion, index: number): SheetIssue[] { + const range = region.count_range + if (range === null) return [] + if (range.min <= region.count && region.count <= range.max) return [] + return [ + error( + 'region.count_range.invalid', + `vertebral_config.regions[${index}].count_range`, + `Region "${region.code}": count ${region.count} outside ` + + `${range.min}–${range.max}`, + ), + ] +} + +const checkRegionCountRanges: Rule = (doc) => + doc.vertebral_config.regions.flatMap(countRangeIssue) + +const RULES: readonly Rule[] = [ + checkMainViewCount, + checkViewIdsUnique, + checkViewParentsExist, + checkViewParentCycles, + checkViewsReachable, + checkViewAssets, + checkAnnotationIdsUnique, + checkAnnotationViews, + checkAnnotationCategories, + checkTriggerTargets, + checkAnnotationFindingZones, + checkAnnotationRegions, + checkAnnotationsHaveFindings, + checkRegionCodesUnique, + checkCategoryIdsUnique, + checkFindingZoneIdsUnique, + checkFindingSiblings, + checkFindingZonesReferenced, + checkReferenceIdsUnique, + checkFindingReferences, + checkRegionCountRanges, +] + +/** Lists every integrity issue of a shape-valid document. */ +export function validateSheetDocument( + doc: AnatomicalSheetDocument, +): SheetIssue[] { + return RULES.flatMap((rule) => rule(doc)) +} + +/** Warnings never block publication; errors always do. */ +export function isPublishable(issues: readonly SheetIssue[]): boolean { + return !issues.some((issue) => issue.severity === 'error') +} + +export class SheetValidationError extends Error { + readonly issues: SheetIssue[] + + constructor(issues: SheetIssue[]) { + const errors = issues.filter((issue) => issue.severity === 'error') + super( + `Sheet document is not publishable: ${errors.length} error(s), ` + + `first: ${errors[0]?.code ?? 'none'}`, + ) + this.name = 'SheetValidationError' + this.issues = issues + } +} + +/** TypeScript-side publication gate, mirrored by SQL at publish time. */ +export function assertPublishable(doc: AnatomicalSheetDocument): void { + const issues = validateSheetDocument(doc) + if (!isPublishable(issues)) throw new SheetValidationError(issues) +} diff --git a/packages/core-wasm/tests/n-1/domain/archive/branding.ts b/packages/core-wasm/tests/n-1/domain/archive/branding.ts new file mode 100644 index 00000000..52b03f00 --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/archive/branding.ts @@ -0,0 +1,59 @@ +import { z } from 'zod' + +/** + * The visual identity a PDF archive embeds so a re-export needs no network + * and no `public/` folder (STEP6 §3.4): logos as PNG base64 or SVG text, + * credits with the URL and the text printed when the logo fails. Caps are + * STEP6 §15 (branding row). + */ + +const KIB = 1024 +const BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/ + +/** + * `http(s)://` then printable ASCII without `"`, `'`, `(`, `)`, `<`, `>` + * or `\`: the URL is written into PDF link actions and must never be able + * to close a string literal or carry a control character. Expressed as the + * allowed ranges of printable ASCII (0x21-0x7e) minus those seven. + */ +const HTTP_URL_PATTERN = /^https?:\/\/[!#-&*-;=?-[\]-~]+$/ + +const HttpUrlSchema = z + .string() + .max(2048) + .url() + .regex(HTTP_URL_PATTERN, 'http(s) URL expected') + +export const ImageAssetSchema = z.discriminatedUnion('kind', [ + z + .object({ + kind: z.literal('png'), + base64: z + .string() + .max(512 * KIB) + .regex(BASE64_PATTERN), + }) + .strict(), + z.object({ kind: z.literal('svg'), svg: z.string().max(256 * KIB) }).strict(), +]) +export type ImageAsset = z.infer + +export const CreditSchema = z + .object({ + logo: ImageAssetSchema.nullable(), + url: HttpUrlSchema, + fallbackText: z.string().max(128), + }) + .strict() +export type Credit = z.infer + +export const BrandingSchema = z + .object({ + siteUrl: HttpUrlSchema, + headerLogo: ImageAssetSchema.nullable(), + footerLogo: ImageAssetSchema.nullable(), + poweredBy: CreditSchema.nullable(), + partner: CreditSchema.nullable(), + }) + .strict() +export type Branding = z.infer diff --git a/packages/core-wasm/tests/n-1/domain/archive/envelope.ts b/packages/core-wasm/tests/n-1/domain/archive/envelope.ts new file mode 100644 index 00000000..d2265ddd --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/archive/envelope.ts @@ -0,0 +1,172 @@ +import { z } from 'zod' +import { readReportDocument } from '../report/migrate' +import type { ReportMigrationMap } from '../report/migration-map' +import { REPORT_VERSION, ReportSchema, type Report } from '../report/v3' +import { BrandingSchema, type Branding } from './branding' +import { PdfLabelSetSchema, type PdfLabelSet } from './labels' +import { + SheetSnapshotSchema, + SnapshotError, + assertSnapshot, + type SheetSnapshot, + type SnapshotRejection, +} from './snapshot' + +/** + * Attachment of a Step 6 PDF: the report (v3, unchanged) wrapped with the + * sheet snapshot, the branding and the PDF labels it was printed with + * (STEP6 §2.3). Reading is layered (§4, §14 "Read"): the report is located + * and parsed first so it is never lost because of its wrapper; the wrapper + * is then validated or dropped with a reason. + */ + +export const ENVELOPE_FORMAT = 'faunosteo-report-archive' +export const ENVELOPE_VERSION = 1 + +export interface ReportArchiveEnvelope { + format: typeof ENVELOPE_FORMAT + envelopeVersion: typeof ENVELOPE_VERSION + /** ISO timestamp of the export. */ + exportedAt: string + locale: 'fr' | 'en' + /** As exported, never rebased. */ + report: Report + sheetSnapshot: SheetSnapshot + branding: Branding + labels: PdfLabelSet +} + +/** Metadata is not strict: an additive v1 field never breaks an older reader. */ +const EnvelopeMetadataSchema = z.object({ + format: z.literal(ENVELOPE_FORMAT), + envelopeVersion: z.literal(ENVELOPE_VERSION), + exportedAt: z.string(), + locale: z.enum(['fr', 'en']), +}) + +/** Everything but the report and the snapshot, which the reader checks itself. */ +const EnvelopeWrapperSchema = EnvelopeMetadataSchema.extend({ + branding: BrandingSchema, + labels: PdfLabelSetSchema, +}) + +export const ReportArchiveEnvelopeSchema: z.ZodType< + ReportArchiveEnvelope, + z.ZodTypeDef, + unknown +> = EnvelopeWrapperSchema.extend({ + report: ReportSchema, + sheetSnapshot: SheetSnapshotSchema, +}) + +export type ArchiveOrigin = 'envelope_v1' | 'bare_v3' | 'v2' + +export interface ArchiveReadOutcome { + report: Report + origin: ArchiveOrigin + migrated: boolean + /** From the v2 migration; 0 for a v3 report. */ + unresolvedZones: number + unresolvedFindings: number + /** The validated envelope, when accepted. */ + archive: ReportArchiveEnvelope | null + /** Envelope present but its snapshot dropped. */ + snapshotRejected?: SnapshotRejection +} + +type Wrapped = + | { archive: ReportArchiveEnvelope } + | { snapshotRejected: SnapshotRejection } + +function isRecord(value: unknown): value is Record { + return typeof value === 'object' && value !== null && !Array.isArray(value) +} + +/** An envelope of any version is recognised by a numeric envelopeVersion. */ +function envelopeVersionOf(data: unknown): number | null { + if (!isRecord(data)) return null + const version = data.envelopeVersion + return typeof version === 'number' ? version : null +} + +function reportVersionOf(data: unknown): number | null { + if (!isRecord(data)) return null + return typeof data.version === 'number' ? data.version : null +} + +function snapshotMatches(snapshot: SheetSnapshot, report: Report): boolean { + return ( + snapshot.ref.sheetId === report.sheet.sheetId && + snapshot.ref.documentSha256 === report.sheet.documentSha256 + ) +} + +/** Step 3 for a v1 envelope: wrapper schema → snapshot gate → sheet invariant. */ +function readEnvelopeV1( + data: Record, + report: Report, +): Wrapped { + const wrapper = EnvelopeWrapperSchema.safeParse(data) + if (!wrapper.success) return { snapshotRejected: 'schema' } + let snapshot: SheetSnapshot + try { + snapshot = assertSnapshot(data.sheetSnapshot) + } catch (error) { + if (error instanceof SnapshotError) { + return { snapshotRejected: error.reason } + } + throw error + } + if (!snapshotMatches(snapshot, report)) { + return { snapshotRejected: 'sheet_mismatch' } + } + return { + archive: { + format: wrapper.data.format, + envelopeVersion: wrapper.data.envelopeVersion, + exportedAt: wrapper.data.exportedAt, + locale: wrapper.data.locale, + report, + sheetSnapshot: snapshot, + branding: wrapper.data.branding, + labels: wrapper.data.labels, + }, + } +} + +/** + * Reads the JSON of a PDF attachment of any supported shape: bare Report v2 + * or v3, or an archive envelope. The report is parsed first and always + * returned (`readReportDocument` throws UnsupportedReportVersionError for an + * unknown report version); the envelope is accepted whole or dropped with + * `snapshotRejected`. + */ +export function readArchiveDocument( + data: unknown, + map: ReportMigrationMap, +): ArchiveReadOutcome { + const envelopeVersion = envelopeVersionOf(data) + const reportData = + envelopeVersion !== null ? (data as Record).report : data + const outcome = readReportDocument(reportData, map) + const migrated = reportVersionOf(reportData) !== REPORT_VERSION + const base: ArchiveReadOutcome = { + report: outcome.report, + origin: migrated ? 'v2' : 'bare_v3', + migrated, + unresolvedZones: outcome.unresolvedZones, + unresolvedFindings: outcome.unresolvedFindings, + archive: null, + } + if (envelopeVersion === null) return base + if (envelopeVersion !== ENVELOPE_VERSION) { + return { ...base, snapshotRejected: 'unsupported_envelope' } + } + const wrapped = readEnvelopeV1( + data as Record, + outcome.report, + ) + return 'archive' in wrapped + ? { ...base, origin: 'envelope_v1', archive: wrapped.archive } + : { ...base, origin: 'envelope_v1', ...wrapped } +} diff --git a/packages/core-wasm/tests/n-1/domain/archive/index.ts b/packages/core-wasm/tests/n-1/domain/archive/index.ts new file mode 100644 index 00000000..6b2bd63b --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/archive/index.ts @@ -0,0 +1,4 @@ +export * from './snapshot' +export * from './branding' +export * from './labels' +export * from './envelope' diff --git a/packages/core-wasm/tests/n-1/domain/archive/labels.ts b/packages/core-wasm/tests/n-1/domain/archive/labels.ts new file mode 100644 index 00000000..217b856f --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/archive/labels.ts @@ -0,0 +1,57 @@ +import { z } from 'zod' + +/** + * The static strings the PDF engine prints (section headings, metadata, + * severities, sides, footer credits), in both locales, frozen into the + * archive so a re-export renders the wording of the day. Exactly the dict + * keys apps/app/src/pdf read when Step 6 started. + */ + +export const PDF_LABEL_KEYS = [ + 'pdf.empty', + 'pdf.eyebrow.observation', + 'pdf.eyebrow.synthesis', + 'pdf.owner_prefix', + 'pdf.section.comment', + 'pdf.section.conclusion', + 'pdf.section.findings_prefix', + 'pdf.section.free_findings', + 'pdf.section.next_appointment', + 'pdf.section.recommendations', + 'pdf.section.severity', + 'pdf.section.zones', + 'pdf.siret_prefix', + 'pdf.subject', + 'pdf.title.conclusion', + 'pdf.title.suffix.bilan', + 'pdf.view.detail_prefix', + 'pdf.view.general', + 'severity.mild', + 'severity.moderate', + 'severity.severe', + 'lateral.left', + 'lateral.right', + 'footer.powered_by', + 'footer.in_partnership', +] as const + +export type PdfLabelKey = (typeof PDF_LABEL_KEYS)[number] +export type PdfLabels = Record + +export interface PdfLabelSet { + fr: PdfLabels + en: PdfLabels +} + +const labelShape = Object.fromEntries( + PDF_LABEL_KEYS.map((key) => [key, z.string().max(256)]), +) as Record + +export const PdfLabelsSchema: z.ZodType = z + .object(labelShape) + .strict() + +/** Strict: every key present in both locales, no extra key. */ +export const PdfLabelSetSchema: z.ZodType = z + .object({ fr: PdfLabelsSchema, en: PdfLabelsSchema }) + .strict() diff --git a/packages/core-wasm/tests/n-1/domain/archive/snapshot.ts b/packages/core-wasm/tests/n-1/domain/archive/snapshot.ts new file mode 100644 index 00000000..11402a26 --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/archive/snapshot.ts @@ -0,0 +1,425 @@ +import { z } from 'zod' +import { + AnatomicalSheetDocumentSchema, + type AnatomicalSheetDocument, + type FindingCategory, + type FindingNode, + type FindingZone, + type SheetView, +} from '../anatomical-sheet/schema' +import { validateSheetDocument } from '../anatomical-sheet/validate' +import type { SheetIndexSource } from '../anatomical-sheet/sheet-index' +import { SheetRefSchema, type Report, type SheetRef } from '../report/v3' + +/** + * The sheet a report archive carries so an old bilan re-renders without the + * current catalog (STEP6 §2.2). The snapshot keeps the shape the renderer and + * the sheet index consume: a valid, lean `AnatomicalSheetDocument` (every + * view, annotation, category and region; finding trees pruned to the paths + * the report uses; bibliography emptied) plus the SVG text of every asset a + * view reaches. `assertSnapshot` is the single gate an imported snapshot + * passes (STEP6 §15 caps, integrity, reachable assets). + */ + +const SHA256_PATTERN = /^[0-9a-f]{64}$/ +const MIB = 1024 * 1024 + +/** Hard limits on an imported snapshot; every excess is a `caps` rejection. */ +export const SNAPSHOT_CAPS = { + views: 64, + annotations: 1024, + findingNodes: 8192, + findingDepth: 8, + labelChars: 512, + assets: 4, + assetBytes: 2 * MIB, + assetsTotalBytes: 6 * MIB, +} as const + +export type SheetSnapshotRef = SheetRef & { + schemaVersion: number + speciesId: string +} + +export interface SheetSnapshotAsset { + svgAssetId: string + /** Content address from the seed manifest; a provenance pointer, not a tamper check. */ + sha256: string | null + svg: string +} + +export interface SheetSnapshot { + status: 'draft' | 'published' + ref: SheetSnapshotRef + /** Lean, valid document (schema v2, strict). */ + document: AnatomicalSheetDocument + assets: SheetSnapshotAsset[] +} + +export const SheetSnapshotRefSchema: z.ZodType = + SheetRefSchema.extend({ + schemaVersion: z.number().int().positive(), + speciesId: z.string().min(1), + }).strict() + +const SheetSnapshotAssetSchema = z + .object({ + svgAssetId: z.string().uuid(), + sha256: z.string().regex(SHA256_PATTERN).nullable(), + svg: z.string().max(SNAPSHOT_CAPS.assetBytes), + }) + .strict() + +/** Shape tier only: caps beyond the schema and integrity live in assertSnapshot. */ +export const SheetSnapshotSchema: z.ZodType< + SheetSnapshot, + z.ZodTypeDef, + unknown +> = z + .object({ + status: z.enum(['draft', 'published']), + ref: SheetSnapshotRefSchema, + document: AnatomicalSheetDocumentSchema, + assets: z.array(SheetSnapshotAssetSchema).max(SNAPSHOT_CAPS.assets), + }) + .strict() + +/** What a loaded sheet provides to build a snapshot from. */ +export interface SnapshotSource { + status: 'draft' | 'published' + ref: SheetRef + speciesId: string + schemaVersion: number + document: AnatomicalSheetDocument + /** SVG text by `svg_asset_id`. */ + assets: Readonly> + /** sha256 by `svg_asset_id` (seed manifest); absent → null in the snapshot. */ + assetHashes?: Readonly> +} + +export type SnapshotRejection = + | 'unsupported_envelope' + | 'schema' + | 'caps' + | 'integrity' + | 'sheet_mismatch' + +/** Thrown by assertSnapshot; `reason` is what the import reports. */ +export class SnapshotError extends Error { + constructor( + public readonly reason: SnapshotRejection, + detail: string, + ) { + super(`snapshot rejected (${reason}): ${detail}`) + this.name = 'SnapshotError' + } +} + +/** Own-key lookup: ids come from documents (`__proto__` is not an entry). */ +function own( + record: Readonly>, + key: string, +): T | undefined { + return Object.hasOwn(record, key) ? record[key] : undefined +} + +/** The asset a view draws: its own, else the first one up its parent chain. */ +function assetOfView( + view: SheetView, + views: ReadonlyMap, +): string | null { + const visited = new Set() + let current: SheetView | undefined = view + while (current && !visited.has(current.id)) { + if (current.svg_asset_id !== null) return current.svg_asset_id + visited.add(current.id) + current = + current.kind === 'detail' ? views.get(current.parent_view_id) : undefined + } + return null +} + +/** Asset ids reachable from the views, in view order, each once. */ +function reachableAssetIds(document: AnatomicalSheetDocument): string[] { + const views = new Map(document.views.map((v) => [v.id, v])) + const ids: string[] = [] + for (const view of document.views) { + const id = assetOfView(view, views) + if (id !== null && !ids.includes(id)) ids.push(id) + } + return ids +} + +// --------------------------------------------------------------------------- +// Build + +/** Finding paths of the report grouped by zone, resolved and unresolved alike. */ +function pathsByZone(report: Report): Map { + const byZone = new Map() + for (const observation of report.observations) { + for (const finding of observation.findings) { + const paths = byZone.get(finding.findingZoneId) ?? [] + paths.push(finding.path) + byZone.set(finding.findingZoneId, paths) + } + } + return byZone +} + +/** Keeps, in document order, the nodes at `depth` of some path and their used descendants. */ +function pruneNodes( + nodes: readonly FindingNode[], + paths: readonly string[][], + depth: number, +): FindingNode[] { + return nodes + .filter((node) => paths.some((path) => path[depth] === node.id)) + .map((node) => ({ + id: node.id, + name: { ...node.name }, + description: {}, + requires_vet_referral: node.requires_vet_referral, + reference_ids: [], + review_status: node.review_status, + children: pruneNodes( + node.children, + paths.filter((path) => path[depth] === node.id), + depth + 1, + ), + })) +} + +function pruneCategories( + categories: readonly FindingCategory[], + paths: readonly string[][], +): FindingCategory[] { + return categories + .filter((category) => paths.some((path) => path[0] === category.id)) + .map((category) => ({ + id: category.id, + kind: category.kind, + name: { ...category.name }, + description: {}, + reference_ids: [], + review_status: category.review_status, + children: pruneNodes( + category.children, + paths.filter((path) => path[0] === category.id), + 1, + ), + })) +} + +function pruneZone(zone: FindingZone, paths: readonly string[][]): FindingZone { + return { + id: zone.id, + name: { ...zone.name }, + categories: pruneCategories(zone.categories, paths), + } +} + +function leanDocument( + document: AnatomicalSheetDocument, + report: Report, +): AnatomicalSheetDocument { + const used = pathsByZone(report) + return { + schema_version: document.schema_version, + species_id: document.species_id, + name: structuredClone(document.name), + description: structuredClone(document.description), + scope_disclaimer: structuredClone(document.scope_disclaimer), + attribution: structuredClone(document.attribution), + vertebral_config: structuredClone(document.vertebral_config), + references: [], + categories: structuredClone(document.categories), + views: structuredClone(document.views), + annotations: structuredClone(document.annotations), + finding_zones: document.finding_zones.map((zone) => + pruneZone(zone, used.get(zone.id) ?? []), + ), + } +} + +function snapshotAssets(sheet: SnapshotSource): SheetSnapshotAsset[] { + const assets: SheetSnapshotAsset[] = [] + for (const svgAssetId of reachableAssetIds(sheet.document)) { + const svg = own(sheet.assets, svgAssetId) + if (svg === undefined) continue + const sha256 = sheet.assetHashes + ? (own(sheet.assetHashes, svgAssetId) ?? null) + : null + assets.push({ svgAssetId, sha256, svg }) + } + return assets +} + +/** + * The snapshot of `sheet` a given report needs: pure, deterministic + * (document order everywhere), inputs untouched. Finding trees keep only the + * categories and nodes on a path some finding of the report names, as far as + * those nodes exist; a missing asset is left out and caught by assertSnapshot. + */ +export function buildSheetSnapshot( + sheet: SnapshotSource, + report: Report, +): SheetSnapshot { + return { + status: sheet.status, + ref: { + sheetId: sheet.ref.sheetId, + versionId: sheet.ref.versionId, + documentSha256: sheet.ref.documentSha256, + schemaVersion: sheet.schemaVersion, + speciesId: sheet.speciesId, + }, + document: leanDocument(sheet.document, report), + assets: snapshotAssets(sheet), + } +} + +// --------------------------------------------------------------------------- +// Assert + +function isRecord(value: unknown): value is Record { + return typeof value === 'object' && value !== null && !Array.isArray(value) +} + +function childrenOf(node: unknown): unknown[] { + if (!isRecord(node)) return [] + const children = node.children + return Array.isArray(children) ? children : [] +} + +/** + * Depth of the finding trees, checked on the raw input before Zod recurses + * into it (an attacker-sized tree must not drive the parser). Iterative: + * an explicit stack of (node, depth) pairs, categories at depth 1. + */ +function assertFindingDepth(input: unknown): void { + if (!isRecord(input) || !isRecord(input.document)) return + const zones = input.document.finding_zones + if (!Array.isArray(zones)) return + const stack: Array<[unknown, number]> = [] + for (const zone of zones) { + if (!isRecord(zone) || !Array.isArray(zone.categories)) continue + for (const category of zone.categories) stack.push([category, 1]) + } + while (stack.length > 0) { + const [node, depth] = stack.pop()! + if (depth > SNAPSHOT_CAPS.findingDepth) { + throw new SnapshotError( + 'caps', + `finding depth over ${SNAPSHOT_CAPS.findingDepth}`, + ) + } + for (const child of childrenOf(node)) stack.push([child, depth + 1]) + } +} + +function countFindingNodes(document: AnatomicalSheetDocument): number { + let count = 0 + const stack: Array = + document.finding_zones.flatMap((zone) => zone.categories) + while (stack.length > 0) { + count += 1 + stack.push(...stack.pop()!.children) + } + return count +} + +/** + * Longest `name` label (`fr` or `en`) anywhere in the document: sheet, views, + * annotations, categories, regions, finding zones and nodes. Free texts + * (`description`, `scope_disclaimer`) are not labels and carry no cap here. + */ +function longestName(document: AnatomicalSheetDocument): number { + let longest = 0 + const stack: unknown[] = [document] + while (stack.length > 0) { + const value = stack.pop() + if (Array.isArray(value)) stack.push(...value) + if (!isRecord(value)) continue + const name = value.name + if (isRecord(name)) { + for (const key of ['fr', 'en']) { + const text = name[key] + if (typeof text === 'string') longest = Math.max(longest, text.length) + } + } + stack.push(...Object.values(value)) + } + return longest +} + +function utf8Length(text: string): number { + return new TextEncoder().encode(text).byteLength +} + +function assertCaps(snapshot: SheetSnapshot): void { + const over = (what: string) => new SnapshotError('caps', `${what} over cap`) + const { document, assets } = snapshot + if (document.views.length > SNAPSHOT_CAPS.views) throw over('views') + if (document.annotations.length > SNAPSHOT_CAPS.annotations) { + throw over('annotations') + } + if (countFindingNodes(document) > SNAPSHOT_CAPS.findingNodes) { + throw over('finding nodes') + } + if (longestName(document) > SNAPSHOT_CAPS.labelChars) throw over('label') + if (assets.length > SNAPSHOT_CAPS.assets) throw over('assets') + const sizes = assets.map((asset) => utf8Length(asset.svg)) + if (sizes.some((size) => size > SNAPSHOT_CAPS.assetBytes)) throw over('asset') + const total = sizes.reduce((sum, size) => sum + size, 0) + if (total > SNAPSHOT_CAPS.assetsTotalBytes) throw over('assets total') +} + +function assertIntegrity(snapshot: SheetSnapshot): void { + const errors = validateSheetDocument(snapshot.document).filter( + (issue) => issue.severity === 'error', + ) + if (errors.length > 0) { + throw new SnapshotError('integrity', errors[0]!.code) + } + const present = new Set(snapshot.assets.map((asset) => asset.svgAssetId)) + const views = new Map(snapshot.document.views.map((v) => [v.id, v])) + for (const view of snapshot.document.views) { + const assetId = assetOfView(view, views) + if (assetId === null || !present.has(assetId)) { + throw new SnapshotError('integrity', `view "${view.id}" reaches no asset`) + } + } +} + +/** + * The single gate of an imported snapshot, in this order: finding depth on + * the raw input → shape (`schema`) → caps (§15) → sheet integrity rules and + * every view reaching an asset carried by the snapshot (`integrity`). + * Returns the parsed snapshot; throws SnapshotError with the reason. + */ +export function assertSnapshot(snapshot: unknown): SheetSnapshot { + assertFindingDepth(snapshot) + const parsed = SheetSnapshotSchema.safeParse(snapshot) + if (!parsed.success) { + throw new SnapshotError( + 'schema', + parsed.error.issues[0]?.message ?? 'invalid', + ) + } + assertCaps(parsed.data) + assertIntegrity(parsed.data) + return parsed.data +} + +/** Adapter: a snapshot as the sheet index reads it (assets array → record). */ +export function snapshotIndexSource( + snapshot: SheetSnapshot, +): SheetIndexSource & { ref: SheetSnapshotRef } { + return { + ref: snapshot.ref, + document: snapshot.document, + assets: Object.fromEntries( + snapshot.assets.map((asset) => [asset.svgAssetId, asset.svg]), + ), + } +} diff --git a/packages/core-wasm/tests/n-1/domain/index.ts b/packages/core-wasm/tests/n-1/domain/index.ts new file mode 100644 index 00000000..a0985a5c --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/index.ts @@ -0,0 +1,3 @@ +export * from './anatomical-sheet' +export * from './report' +export * from './archive' diff --git a/packages/core-wasm/tests/n-1/domain/report/identity.ts b/packages/core-wasm/tests/n-1/domain/report/identity.ts new file mode 100644 index 00000000..a472c925 --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/report/identity.ts @@ -0,0 +1,37 @@ +import { z } from 'zod' + +/** + * Identity snapshots carried by every report version: who wrote it, on + * which animal, for which owner. Copied into the report at creation so a + * report stays readable when the underlying records change (BDR-010). + */ + +export const PractitionerSchema = z.object({ + name: z.string().min(1), + cabinet: z.string().optional(), + contact: z.string().optional(), + /** SIRET, 14-digit French business identifier (not validated). */ + siret: z.string().optional(), +}) +export type Practitioner = z.infer + +export const AnimalSchema = z.object({ + /** Species of the animal; the sheet the report references matches it. */ + speciesId: z.string().min(1), + name: z.string().min(1), + breed: z.string().optional(), + age: z.string().optional(), +}) +export type Animal = z.infer + +export const OwnerSchema = z.object({ name: z.string().min(1) }) +export type Owner = z.infer + +export const NextAppointmentSchema = z.discriminatedUnion('kind', [ + z.object({ kind: z.literal('date'), date: z.string() }), + z.object({ kind: z.literal('period'), text: z.string() }), +]) +export type NextAppointment = z.infer + +export const LateralSideSchema = z.enum(['left', 'right']) +export type LateralSide = z.infer diff --git a/packages/core-wasm/tests/n-1/domain/report/index.ts b/packages/core-wasm/tests/n-1/domain/report/index.ts new file mode 100644 index 00000000..f54991a1 --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/report/index.ts @@ -0,0 +1,32 @@ +export * from './identity' +export * from './v3' +export { + FindingV2Schema, + ObservationV2Schema, + ObservationZoneV2Schema, + ReportV2Schema, + SeverityV2Schema, + VertebraV2Schema, + VertebralRegionV2Schema, + type FindingV2, + type ObservationV2, + type ObservationZoneV2, + type ReportV2, + type SeverityV2, +} from './v2' +export { + ReportMigrationMapSchema, + findingPathKey, + type ReportMigrationMap, +} from './migration-map' +export { + migrateReportV2ToV3, + readReportDocument, + UnsupportedReportVersionError, + type MigrationOutcome, +} from './migrate' +export { + rebaseReportOnSheet, + type RebaseIndex, + type RebaseOutcome, +} from './rebase' diff --git a/packages/core-wasm/tests/n-1/domain/report/migrate.ts b/packages/core-wasm/tests/n-1/domain/report/migrate.ts new file mode 100644 index 00000000..4274c410 --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/report/migrate.ts @@ -0,0 +1,167 @@ +import { findingPathKey, type ReportMigrationMap } from './migration-map' +import { + ReportV2Schema, + type FindingV2, + type ObservationV2, + type ObservationZoneV2, + type ReportV2, + type SeverityV2, +} from './v2' +import { + REPORT_VERSION, + ReportSchema, + type Finding, + type Observation, + type Report, + type ReportZone, + type Severity, +} from './v3' + +/** + * Lifts a Report v2 (PDF attachment or sessionStorage draft of the deployed + * application) to v3 against the migration map of the reference sheet. + * Never throws on content: a zone or finding the map cannot place is kept + * verbatim with its snapshots and flagged `unresolved`, so the practitioner's + * data survives any catalog change and stays identifiable. + */ + +/** Own-key lookup: ids come from untrusted documents (`__proto__` is not an entry). */ +function own(record: Record, key: string): T | undefined { + return Object.hasOwn(record, key) ? record[key] : undefined +} + +const SEVERITY: Record = { + légère: 'mild', + modérée: 'moderate', + sévère: 'severe', +} + +export interface MigrationOutcome { + report: Report + /** Zones whose legacy id has no annotation in the map. */ + unresolvedZones: number + /** Findings whose legacy path no longer exists in the sheet. */ + unresolvedFindings: number +} + +function migrateZone( + zone: ObservationZoneV2, + map: ReportMigrationMap, +): ReportZone { + const entry = own(map.annotations, zone.boneId) + const viewId = zone.detailSourceId + ? (own(map.views, zone.detailSourceId) ?? zone.detailSourceId) + : map.main_view_id + const out: ReportZone = { annotationId: entry?.id ?? zone.boneId, viewId } + if (zone.side) out.side = zone.side + if (zone.vertebrae) out.vertebrae = zone.vertebrae.map((v) => ({ ...v })) + if (entry) { + out.labelFrSnapshot = entry.name.fr + out.labelEnSnapshot = entry.name.en + } else { + out.unresolved = true + } + return out +} + +function migrateFinding(finding: FindingV2, map: ReportMigrationMap): Finding { + const mapped = own( + map.finding_paths, + findingPathKey(finding.zoneId, finding.path), + ) + const out: Finding = { + findingZoneId: finding.zoneId, + path: [...finding.path], + labelFrSnapshot: finding.labelFrSnapshot, + labelEnSnapshot: finding.labelEnSnapshot, + } + if (finding.requiresVetReferral) out.requiresVetReferral = true + if (finding.side) out.side = finding.side + if (typeof mapped === 'string') { + const [zoneId, ...path] = mapped.split('/') + out.findingZoneId = zoneId! + out.path = path + } else { + // null = removed by curation; undefined = never part of the legacy catalog. + out.unresolved = true + } + return out +} + +function migrateObservation( + obs: ObservationV2, + map: ReportMigrationMap, +): Observation { + const out: Observation = { + id: obs.id, + zones: obs.zones.map((z) => migrateZone(z, map)), + findings: obs.findings.map((f) => migrateFinding(f, map)), + freeTextFindings: [...obs.freeTextFindings], + comment: obs.comment, + } + if (obs.severity) out.severity = SEVERITY[obs.severity] + return out +} + +export function migrateReportV2ToV3( + report: ReportV2, + map: ReportMigrationMap, +): MigrationOutcome { + const observations = report.observations.map((o) => + migrateObservation(o, map), + ) + const migrated: Report = { + version: REPORT_VERSION, + id: report.id, + createdAt: report.createdAt, + date: report.date, + practitioner: report.practitioner, + animal: report.animal, + owner: report.owner, + sheet: { ...map.sheet }, + observations, + conclusion: report.conclusion, + recommendations: report.recommendations, + localAnnotations: [], + } + if (report.nextAppointment) migrated.nextAppointment = report.nextAppointment + const zones = observations.flatMap((o) => o.zones) + const findings = observations.flatMap((o) => o.findings) + return { + report: ReportSchema.parse(migrated), + unresolvedZones: zones.filter((z) => z.unresolved).length, + unresolvedFindings: findings.filter((f) => f.unresolved).length, + } +} + +/** Thrown for a report whose version this code cannot read. */ +export class UnsupportedReportVersionError extends Error { + constructor(public readonly foundVersion: number | null) { + super(`unsupported report version: ${foundVersion ?? 'unknown'}`) + this.name = 'UnsupportedReportVersionError' + } +} + +function versionOf(data: unknown): number | null { + if (data === null || typeof data !== 'object') return null + const v = (data as { version?: unknown }).version + return typeof v === 'number' ? v : null +} + +/** + * Reads a report document of any supported version (2 or 3) and returns it + * as v3. Zod errors propagate: a document of a known version that does not + * parse is corrupt, not old. + */ +export function readReportDocument( + data: unknown, + map: ReportMigrationMap, +): MigrationOutcome { + const version = versionOf(data) + if (version === REPORT_VERSION) { + const report = ReportSchema.parse(data) + return { report, unresolvedZones: 0, unresolvedFindings: 0 } + } + if (version === 2) return migrateReportV2ToV3(ReportV2Schema.parse(data), map) + throw new UnsupportedReportVersionError(version) +} diff --git a/packages/core-wasm/tests/n-1/domain/report/migration-map.ts b/packages/core-wasm/tests/n-1/domain/report/migration-map.ts new file mode 100644 index 00000000..65326590 --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/report/migration-map.ts @@ -0,0 +1,40 @@ +import { z } from 'zod' +import { SheetRefSchema } from './v3' + +/** + * Correspondence between the legacy identifiers a Report v2 carries and the + * canonical sheet a Report v3 references. Generated by the curation pipeline + * (`draft/report-migration-map.json`), never written by hand: annotations + * come from the legacy id map, finding paths from the applier's rename and + * removal records. A `null` finding path means "removed from the sheet": + * the migration keeps the finding with its snapshots and flags it. + */ + +const LocalizedNameSchema = z.object({ fr: z.string(), en: z.string() }) + +export const ReportMigrationMapSchema = z.object({ + schema_version: z.literal(1), + sheet: SheetRefSchema, + /** Id of the view a v2 zone without `detailSourceId` belongs to. */ + main_view_id: z.string().min(1), + /** Legacy detail popup key → view id. */ + views: z.record(z.string(), z.string().min(1)), + /** Legacy `data-anno-id` → annotation id and the legacy labels. */ + annotations: z.record( + z.string(), + z.object({ id: z.string().min(1), name: LocalizedNameSchema }), + ), + /** + * `/` of every legacy finding node → + * the same key in the sheet, or null when the node was removed. + */ + finding_paths: z.record(z.string(), z.string().nullable()), +}) +export type ReportMigrationMap = z.infer + +export function findingPathKey( + zoneId: string, + path: readonly string[], +): string { + return `${zoneId}/${path.join('/')}` +} diff --git a/packages/core-wasm/tests/n-1/domain/report/rebase.ts b/packages/core-wasm/tests/n-1/domain/report/rebase.ts new file mode 100644 index 00000000..626c2b65 --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/report/rebase.ts @@ -0,0 +1,137 @@ +import type { + SheetIndex, + SheetIndexSource, +} from '../anatomical-sheet/sheet-index' +import type { Annotation, LocalizedText } from '../anatomical-sheet/schema' +import type { SheetSnapshot } from '../archive/snapshot' +import { + ReportSchema, + type Finding, + type Observation, + type Report, + type ReportZone, + type SheetRef, +} from './v3' + +/** + * Moves an imported report onto the sheet the application has loaded + * (STEP6 §3.5). A report written on another revision of the sheet keeps + * every datum: a zone or finding the loaded sheet no longer holds is flagged + * `unresolved`, its labels taken from the archived snapshot when the report + * carries none, and the report now references the loaded sheet. Nothing + * happens when the report already sits on the loaded sheet. + */ + +/** An index whose source names its sheet (a loaded sheet or a snapshot). */ +export type RebaseIndex = SheetIndex + +export interface RebaseOutcome { + report: Report + /** Zones and findings newly flagged by this rebase. */ + unresolvedZones: number + unresolvedFindings: number + rebased: boolean +} + +interface Counters { + zones: number + findings: number +} + +/** The name the archived snapshot gives an annotation (a trigger: its view's). */ +function archivedName( + archived: SheetSnapshot | null, + annotationId: string, +): LocalizedText | undefined { + if (!archived) return undefined + const annotation: Annotation | undefined = archived.document.annotations.find( + (a) => a.id === annotationId, + ) + if (!annotation) return undefined + if (annotation.kind !== 'detail_trigger') return annotation.name + const view = archived.document.views.find( + (v) => v.id === annotation.opens_view_id, + ) + return annotation.name ?? view?.name +} + +function flagZone( + zone: ReportZone, + archived: SheetSnapshot | null, +): ReportZone { + const out: ReportZone = { ...zone, unresolved: true } + const name = archivedName(archived, zone.annotationId) + if (name) { + out.labelFrSnapshot ??= name.fr + out.labelEnSnapshot ??= name.en + } + return out +} + +function rebaseZone( + zone: ReportZone, + index: RebaseIndex, + archived: SheetSnapshot | null, + counters: Counters, +): ReportZone { + if (zone.unresolved) return { ...zone } + const known = + index.annotation(zone.annotationId) !== undefined && + index.view(zone.viewId) !== undefined + if (known) return { ...zone } + counters.zones += 1 + return flagZone(zone, archived) +} + +function rebaseFinding( + finding: Finding, + index: RebaseIndex, + counters: Counters, +): Finding { + if (finding.unresolved) return { ...finding } + if (index.nodeAt(finding.findingZoneId, finding.path)) return { ...finding } + counters.findings += 1 + return { ...finding, unresolved: true } +} + +function rebaseObservation( + observation: Observation, + index: RebaseIndex, + archived: SheetSnapshot | null, + counters: Counters, +): Observation { + return { + ...observation, + zones: observation.zones.map((z) => + rebaseZone(z, index, archived, counters), + ), + findings: observation.findings.map((f) => + rebaseFinding(f, index, counters), + ), + } +} + +export function rebaseReportOnSheet( + report: Report, + index: RebaseIndex, + archived: SheetSnapshot | null, +): RebaseOutcome { + if (report.sheet.documentSha256 === index.sheet.ref.documentSha256) { + return { report, unresolvedZones: 0, unresolvedFindings: 0, rebased: false } + } + const counters: Counters = { zones: 0, findings: 0 } + const { sheetId, versionId, documentSha256 } = index.sheet.ref + const rebased: Report = { + ...report, + sheet: { sheetId, versionId, documentSha256 }, + observations: report.observations.map((o) => + rebaseObservation(o, index, archived, counters), + ), + } + return { + report: ReportSchema.parse(rebased), + unresolvedZones: counters.zones, + unresolvedFindings: counters.findings, + rebased: true, + } +} diff --git a/packages/core-wasm/tests/n-1/domain/report/v2.ts b/packages/core-wasm/tests/n-1/domain/report/v2.ts new file mode 100644 index 00000000..9c6b958c --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/report/v2.ts @@ -0,0 +1,72 @@ +import { z } from 'zod' +import { + AnimalSchema, + LateralSideSchema, + NextAppointmentSchema, + OwnerSchema, + PractitionerSchema, +} from './identity' + +/** + * Report document version 2, exactly as the deployed application wrote it + * (PDF attachments of the practitioner's archive, sessionStorage drafts). + * Kept as an INPUT format only: nothing writes v2 any more, `migrate.ts` + * lifts it to v3. Field comments describe the legacy meaning. + */ + +export const SeverityV2Schema = z.enum(['légère', 'modérée', 'sévère']) +export type SeverityV2 = z.infer + +export const VertebralRegionV2Schema = z.enum(['C', 'T', 'L', 'S', 'Cd']) + +export const VertebraV2Schema = z.object({ + region: VertebralRegionV2Schema, + index: z.number().int().positive(), +}) + +export const ObservationZoneV2Schema = z.object({ + /** The legacy SVG `data-anno-id` (e.g. `point-mpbwtst0`). */ + boneId: z.string().min(1), + /** Legacy detail popup key (`head`) when the zone came from that view. */ + detailSourceId: z.string().optional(), + vertebrae: z.array(VertebraV2Schema).optional(), + side: LateralSideSchema.optional(), +}) +export type ObservationZoneV2 = z.infer + +export const FindingV2Schema = z.object({ + /** Legacy catalog zone key (equal to the canonical finding zone id). */ + zoneId: z.string().min(1), + /** Node ids from the zone's categories down to the leaf. */ + path: z.array(z.string().min(1)).min(1), + labelFrSnapshot: z.string().min(1), + labelEnSnapshot: z.string().min(1), + requiresVetReferral: z.boolean().optional(), + side: LateralSideSchema.optional(), +}) +export type FindingV2 = z.infer + +export const ObservationV2Schema = z.object({ + id: z.string().min(1), + zones: z.array(ObservationZoneV2Schema), + findings: z.array(FindingV2Schema), + freeTextFindings: z.array(z.string()), + severity: SeverityV2Schema.optional(), + comment: z.string(), +}) +export type ObservationV2 = z.infer + +export const ReportV2Schema = z.object({ + version: z.literal(2), + id: z.string().min(1), + createdAt: z.string(), + date: z.string(), + practitioner: PractitionerSchema, + animal: AnimalSchema, + owner: OwnerSchema, + observations: z.array(ObservationV2Schema), + conclusion: z.string(), + recommendations: z.string(), + nextAppointment: NextAppointmentSchema.optional(), +}) +export type ReportV2 = z.infer diff --git a/packages/core-wasm/tests/n-1/domain/report/v3.ts b/packages/core-wasm/tests/n-1/domain/report/v3.ts new file mode 100644 index 00000000..0609199e --- /dev/null +++ b/packages/core-wasm/tests/n-1/domain/report/v3.ts @@ -0,0 +1,97 @@ +import { z } from 'zod' +import { + AnimalSchema, + LateralSideSchema, + NextAppointmentSchema, + OwnerSchema, + PractitionerSchema, +} from './identity' + +/** + * Report document version 3: a report written on the canonical anatomical + * sheet. Zones name an annotation of a view of an exact sheet, findings a + * node path of a finding zone, both by stable ids; every label the report + * needs to stay readable without the sheet is snapshotted. Breaking change + * → version 4; additive optional fields keep the version. + */ + +export const REPORT_VERSION = 3 + +export const SeveritySchema = z.enum(['mild', 'moderate', 'severe']) +export type Severity = z.infer + +/** Region codes are the sheet's `vertebral_config` codes, checked at runtime. */ +export const VertebraSchema = z.object({ + region: z.string().min(1), + index: z.number().int().positive(), +}) +export type Vertebra = z.infer + +/** The sheet document a report was built on, by content. */ +export const SheetRefSchema = z.object({ + sheetId: z.string().min(1), + /** Database version id once the sheet lives in the database; null for a bundled draft. */ + versionId: z.string().min(1).nullable(), + /** sha256 of the document file the report was written against. */ + documentSha256: z.string().regex(/^[0-9a-f]{64}$/), +}) +export type SheetRef = z.infer + +export const ReportZoneSchema = z.object({ + annotationId: z.string().min(1), + viewId: z.string().min(1), + side: LateralSideSchema.optional(), + vertebrae: z.array(VertebraSchema).optional(), + /** Annotation name at selection time (or legacy name at migration). */ + labelFrSnapshot: z.string().optional(), + labelEnSnapshot: z.string().optional(), + /** Set by the migration when the legacy id has no canonical annotation. */ + unresolved: z.literal(true).optional(), +}) +export type ReportZone = z.infer + +export const FindingSchema = z.object({ + findingZoneId: z.string().min(1), + /** Node ids from the zone's categories down to the leaf. */ + path: z.array(z.string().min(1)).min(1), + labelFrSnapshot: z.string().min(1), + labelEnSnapshot: z.string().min(1), + requiresVetReferral: z.boolean().optional(), + side: LateralSideSchema.optional(), + /** Set by the migration when the path no longer exists in the sheet; data kept. */ + unresolved: z.literal(true).optional(), +}) +export type Finding = z.infer + +export const ObservationSchema = z.object({ + id: z.string().min(1), + zones: z.array(ReportZoneSchema), + findings: z.array(FindingSchema), + freeTextFindings: z.array(z.string()), + severity: SeveritySchema.optional(), + comment: z.string(), +}) +export type Observation = z.infer + +export const ReportSchema = z.object({ + version: z.literal(REPORT_VERSION), + id: z.string().min(1), + /** ISO timestamp of report creation. */ + createdAt: z.string(), + /** ISO date of the clinical encounter. */ + date: z.string(), + practitioner: PractitionerSchema, + animal: AnimalSchema, + owner: OwnerSchema, + sheet: SheetRefSchema, + observations: z.array(ObservationSchema), + conclusion: z.string(), + recommendations: z.string(), + nextAppointment: NextAppointmentSchema.optional(), + /** Reserved for report-only points (OPEN_QUESTIONS Q6); empty until defined. */ + localAnnotations: z.array(z.unknown()).max(0).default([]), +}) +export type Report = z.infer +export type ReportInput = z.input + +export type { LateralSide, NextAppointment } from './identity' diff --git a/packages/core-wasm/tests/n-1/index.ts b/packages/core-wasm/tests/n-1/index.ts new file mode 100644 index 00000000..c471ba3f --- /dev/null +++ b/packages/core-wasm/tests/n-1/index.ts @@ -0,0 +1,21 @@ +/** + * The N-1 reader (RUST_ARCHITECTURE_REVIEW III.3 rule 7, VI.3): the Zod schemas and readers + * the last TypeScript build shipped, copied verbatim from `packages/domain/src` at develop + * 1a7ee7d (the R2 starting point) into `./domain`. Never edited: a Rust-written report, draft, + * snapshot or envelope that these readers refuse would break a rollback to that build. + * Permanent, it outlives `packages/domain` (deleted at R5). + */ +export { + ReportSchema, + ReportArchiveEnvelopeSchema, + SheetSnapshotSchema, + AnatomicalSheetDocumentSchema, + BrandingSchema, + PdfLabelSetSchema, + readArchiveDocument, + readReportDocument, + assertSnapshot, + type Report, + type ReportArchiveEnvelope, + type ReportMigrationMap, +} from './domain' diff --git a/packages/core-wasm/tests/panic.test.ts b/packages/core-wasm/tests/panic.test.ts index 113fe2cc..af3e6132 100644 --- a/packages/core-wasm/tests/panic.test.ts +++ b/packages/core-wasm/tests/panic.test.ts @@ -10,10 +10,9 @@ * (`memory access out of bounds`), deterministically; * - a genuinely new instance (new module record, new memory) recovers in full. */ -import { loadCore } from '../src/index' -import { coreBuilt } from './helpers/core' +import { loadProofModule as loadCore } from '../src/node' -describe.skipIf(!coreBuilt)('panics and stack exhaustion (wasm)', () => { +describe('panics and stack exhaustion (wasm)', () => { it('turns a panic into a WebAssembly.RuntimeError', async () => { const core = await loadCore() expect(() => core.panic_for_test()).toThrow(WebAssembly.RuntimeError) diff --git a/packages/core-wasm/tests/runtime.test.ts b/packages/core-wasm/tests/runtime.test.ts new file mode 100644 index 00000000..5c22923e --- /dev/null +++ b/packages/core-wasm/tests/runtime.test.ts @@ -0,0 +1,147 @@ +/** + * The core runtime (R2 plan P9 rev 2) on the proofs build, whose trap exports make the + * failure paths real: lazy load, poison on a trap, re-instantiation from the kept compiled + * module and the pre-imported glue record (no network), handles rebuilt per instance and + * never called on a dropped one, the recovery cap, load failure and retry. + */ +import { readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' + +import { CoreRuntime, type CoreSource, type GlueModule } from '../src/index' +import { nodeCoreSource, type ProofModule } from '../src/node' + +const SEED = '../../../supabase/seed/anatomical-sheets/equine/draft/' + +function seedJson(name: string): unknown { + const path = fileURLToPath(new URL(`${SEED}${name}`, import.meta.url)) + return JSON.parse(readFileSync(path, 'utf8')) +} + +const BUNDLE = JSON.stringify({ + status: 'draft', + ref: { + sheet_id: 'sheet', + version_id: null, + document_sha256: '0'.repeat(64), + schema_version: 2, + species_id: 'equine', + }, + document: seedJson('document.json'), + migrationMap: seedJson('report-migration-map.json'), + assets: {}, + assetHashes: {}, +}) + +/** Counts glue imports; imports after `offlineAfter` fail like a lost network. */ +function countingSource(offlineAfter = Infinity) { + const inner = nodeCoreSource('pkg-proofs') + const source = { + imports: 0, + compile: () => inner.compile(), + importGlue: async (n: number): Promise => { + source.imports += 1 + if (source.imports > offlineAfter) throw new TypeError('offline') + return inner.importGlue(n) + }, + } + return source +} + +/** Traps the live instance through the proofs build (stack exhaustion). */ +function trap(runtime: CoreRuntime) { + return runtime.invoke((glue) => { + ;(glue as ProofModule).recurse_for_test(2_000_000) + return { ok: true, value: null } + }) +} + +describe('core runtime', () => { + it('loads on first need only', async () => { + const source = countingSource() + const runtime = new CoreRuntime(source) + expect(runtime.status).toBe('idle') + expect(runtime.call('core_version', '')).toMatchObject({ + ok: false, + kind: 'core_unavailable', + }) + expect(source.imports).toBe(0) + expect(await runtime.ready()).toBe(true) + expect(runtime.call('core_version', '')).toMatchObject({ ok: true }) + }) + + it('poisons on a trap and recovers offline from the spare glue record', async () => { + const source = countingSource(2) + const runtime = new CoreRuntime(source) + await runtime.ready() + expect(trap(runtime)).toMatchObject({ ok: false, kind: 'internal' }) + expect(runtime.status).toBe('recovering') + expect(runtime.call('core_version', '')).toMatchObject({ + kind: 'core_unavailable', + }) + expect(await runtime.ready()).toBe(true) + expect(runtime.generation).toBe(2) + expect(runtime.call('core_version', '')).toMatchObject({ ok: true }) + }) + + it('rebuilds a sheet handle on the new instance and never calls the dropped one', async () => { + const runtime = new CoreRuntime(countingSource()) + await runtime.ready() + const sheet = runtime.sheet(BUNDLE) + expect(sheet.call('index_data', '')).toMatchObject({ + ok: true, + value: { ref: { sheetId: 'sheet', versionId: null } }, + }) + trap(runtime) + expect(sheet.call('index_data', '')).toMatchObject({ + kind: 'core_unavailable', + }) + await runtime.ready() + // A call through the stack-trapped instance would fail in its allocator and poison + // again: one generation more and a ready runtime prove the handle was rebuilt. + expect(sheet.call('index_data', '')).toMatchObject({ ok: true }) + expect(runtime.generation).toBe(2) + expect(runtime.status).toBe('ready') + }) + + it('stops recovering after the cap', async () => { + const runtime = new CoreRuntime(countingSource(), { maxRecoveries: 1 }) + await runtime.ready() + trap(runtime) + expect(await runtime.ready()).toBe(true) + trap(runtime) + expect(runtime.status).toBe('unavailable') + expect(await runtime.retry()).toBe(false) + expect(runtime.call('core_version', '')).toMatchObject({ + kind: 'core_unavailable', + }) + }) + + it('reports a load failure and loads again on retry', async () => { + const inner = nodeCoreSource('pkg') + let failNext = true + const source: CoreSource = { + compile: () => { + if (failNext) { + failNext = false + return Promise.reject(new WebAssembly.CompileError('blocked')) + } + return inner.compile() + }, + importGlue: (n) => inner.importGlue(n), + } + const runtime = new CoreRuntime(source) + expect(await runtime.ready()).toBe(false) + expect(runtime.status).toBe('unavailable') + expect(await runtime.retry()).toBe(true) + expect(runtime.call('core_version', '')).toMatchObject({ ok: true }) + }) + + it('refuses an invalid sheet payload without poisoning the instance', async () => { + const runtime = new CoreRuntime(nodeCoreSource('pkg')) + await runtime.ready() + const outcome = runtime.sheet('{"status":"draft"}').open() + expect(outcome).toMatchObject({ ok: false, kind: 'invalid_sheet' }) + expect(runtime.status).toBe('ready') + expect(runtime.sheet(BUNDLE).open()).toEqual({ ok: true, value: null }) + }) +}) diff --git a/packages/core-wasm/tests/serialisation.test.ts b/packages/core-wasm/tests/serialisation.test.ts index d04d069d..387feff5 100644 --- a/packages/core-wasm/tests/serialisation.test.ts +++ b/packages/core-wasm/tests/serialisation.test.ts @@ -6,11 +6,11 @@ import { readFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' -import { ReportZoneSchema, SheetRefSchema } from '@faunosteo/domain' +import { ReportZoneSchema, SheetRefSchema } from './n-1/domain' import type { ReportZone, SheetRef } from '../types/index' -import { callCore, loadCore, type CoreModule } from '../src/index' -import { coreBuilt } from './helpers/core' +import type { CoreRuntime } from '../src/index' +import { nodeCoreRuntime } from '../src/node' const FIXTURES = [ 'apps/app/tests/fixtures/report-v3.demo.json', @@ -32,17 +32,17 @@ function repoFile(relative: string): string { ) } -function prettyByCore(core: CoreModule, text: string): string { - const outcome = callCore(core, 'pretty_json', text) +function prettyByCore(core: CoreRuntime, text: string): string { + const outcome = core.call('pretty_json', text) if (!outcome.ok) throw new Error(`${outcome.kind}: ${outcome.detail ?? ''}`) return outcome.value } -describe.skipIf(!coreBuilt)('serialisation contract (wasm)', () => { +describe('serialisation contract (wasm)', () => { it.each(FIXTURES)( '%s: core pretty output equals JSON.stringify(…, null, 2)', async (relative) => { - const core = await loadCore() + const core = await nodeCoreRuntime() const text = repoFile(relative) const expected = JSON.stringify(JSON.parse(text), null, 2) expect(prettyByCore(core, text)).toBe(expected) @@ -50,7 +50,7 @@ describe.skipIf(!coreBuilt)('serialisation contract (wasm)', () => { ) it('prints every number as JavaScript does', async () => { - const core = await loadCore() + const core = await nodeCoreRuntime() const text = JSON.stringify(NUMBER_CASES) expect(prettyByCore(core, text)).toBe( JSON.stringify(JSON.parse(text), null, 2), @@ -58,9 +58,8 @@ describe.skipIf(!coreBuilt)('serialisation contract (wasm)', () => { }) it('writes optional fields absent and nullable fields null, readable by the Zod schemas', async () => { - const core = await loadCore() - const bare = callCore( - core, + const core = await nodeCoreRuntime() + const bare = core.call( 'report_zone', JSON.stringify({ annotationId: 'hip', viewId: 'main' }), ) @@ -72,8 +71,7 @@ describe.skipIf(!coreBuilt)('serialisation contract (wasm)', () => { expect(Object.keys(bare.value)).toEqual(['annotationId', 'viewId']) expect(ReportZoneSchema.parse(bare.value)).toEqual(bare.value) - const full = callCore( - core, + const full = core.call( 'report_zone', JSON.stringify({ viewId: 'main', @@ -93,8 +91,7 @@ describe.skipIf(!coreBuilt)('serialisation contract (wasm)', () => { }, }) - const sheet = callCore( - core, + const sheet = core.call( 'sheet_ref', JSON.stringify({ sheetId: 'faunosteo-cheval', @@ -105,8 +102,7 @@ describe.skipIf(!coreBuilt)('serialisation contract (wasm)', () => { expect(sheet.ok && sheet.value.versionId).toBeNull() if (sheet.ok) expect(SheetRefSchema.parse(sheet.value)).toEqual(sheet.value) - const refused = callCore( - core, + const refused = core.call( 'report_zone', JSON.stringify({ annotationId: 'a', viewId: 'v', unresolved: false }), ) diff --git a/packages/core-wasm/tests/size.test.ts b/packages/core-wasm/tests/size.test.ts index 1dc8671a..982f06c1 100644 --- a/packages/core-wasm/tests/size.test.ts +++ b/packages/core-wasm/tests/size.test.ts @@ -1,25 +1,26 @@ /** - * R0 measurement: served size of the module and instantiate time (D-R13 budget, enforced - * from R2 on the real core; R0 records the skeleton's numbers). + * D-R13 budget: the served module (gzip) stays under 600 KB; the numbers are printed for + * RUST.md (raw and compressed size, compile + instantiate time on Node). */ import { readFileSync } from 'node:fs' import { gzipSync } from 'node:zlib' -import { coreWasmPath, loadCore } from '../src/index' -import { coreBuilt } from './helpers/core' +import { CoreRuntime } from '../src/index' +import { coreWasmPath, nodeCoreSource } from '../src/node' /** D-R13: the served module (compressed) stays under this many bytes. */ const COMPRESSED_BUDGET_BYTES = 600_000 -describe.skipIf(!coreBuilt)('module size and instantiate time (wasm)', () => { +describe('module size and instantiate time (shipped wasm build)', () => { it('stays under the compressed budget and reports its numbers', async () => { - const bytes = readFileSync(coreWasmPath()) + const bytes = readFileSync(coreWasmPath('pkg')) const gzip = gzipSync(bytes, { level: 9 }).length const started = performance.now() - await loadCore() - const instantiateMs = performance.now() - started + const runtime = new CoreRuntime(nodeCoreSource('pkg')) + expect(await runtime.ready()).toBe(true) + const readyMs = performance.now() - started console.info( - `[core-wasm] faunosteo_wasm_bg.wasm: ${bytes.length} bytes raw, ${gzip} bytes gzip-9, instantiate ${instantiateMs.toFixed(1)} ms`, + `[core-wasm] faunosteo_wasm_bg.wasm: ${bytes.length} bytes raw, ${gzip} bytes gzip-9, compile + instantiate ${readyMs.toFixed(1)} ms`, ) expect(gzip).toBeLessThanOrEqual(COMPRESSED_BUDGET_BYTES) }) diff --git a/packages/core-wasm/tests/types-index.test.ts b/packages/core-wasm/tests/types-index.test.ts new file mode 100644 index 00000000..4d110c0a --- /dev/null +++ b/packages/core-wasm/tests/types-index.test.ts @@ -0,0 +1,18 @@ +import { readdirSync, readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' + +/** The ts-rs output directory and its hand-kept index must list the same types. */ +describe('types/index.ts', () => { + it('re-exports every generated type file', () => { + const dir = fileURLToPath(new URL('../types/', import.meta.url)) + const generated = readdirSync(dir) + .filter((f) => f.endsWith('.ts') && f !== 'index.ts') + .map((f) => f.slice(0, -3)) + .sort() + const index = readFileSync(`${dir}index.ts`, 'utf8') + const exported = [...index.matchAll(/export type \{ (\w+) \}/g)] + .map((m) => m[1]) + .sort() + expect(exported).toEqual(generated) + }) +}) diff --git a/packages/core-wasm/tests/wasm-stamp.d.ts b/packages/core-wasm/tests/wasm-stamp.d.ts new file mode 100644 index 00000000..185ae3b6 --- /dev/null +++ b/packages/core-wasm/tests/wasm-stamp.d.ts @@ -0,0 +1,3 @@ +declare module '*/scripts/wasm-stamp.mjs' { + export function wasmStamp(): string +} diff --git a/packages/core-wasm/types/AddSidesInput.ts b/packages/core-wasm/types/AddSidesInput.ts new file mode 100644 index 00000000..e9ae59c6 --- /dev/null +++ b/packages/core-wasm/types/AddSidesInput.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LateralSide } from "./LateralSide"; +import type { Observation } from "./Observation"; + +export type AddSidesInput = { observation: Observation, annotationId: string, sides: Array, }; diff --git a/packages/core-wasm/types/AnatomicalSheetDocument.ts b/packages/core-wasm/types/AnatomicalSheetDocument.ts new file mode 100644 index 00000000..23125ab6 --- /dev/null +++ b/packages/core-wasm/types/AnatomicalSheetDocument.ts @@ -0,0 +1,15 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Annotation } from "./Annotation"; +import type { AnnotationCategory } from "./AnnotationCategory"; +import type { Attribution } from "./Attribution"; +import type { FindingZone } from "./FindingZone"; +import type { LocalizedOptionalText } from "./LocalizedOptionalText"; +import type { LocalizedText } from "./LocalizedText"; +import type { Reference } from "./Reference"; +import type { SheetView } from "./SheetView"; +import type { VertebralConfig } from "./VertebralConfig"; + +/** + * The canonical sheet document (schema_version 2). + */ +export type AnatomicalSheetDocument = { schema_version: 2, species_id: string, name: LocalizedText, description: LocalizedOptionalText, scope_disclaimer: LocalizedOptionalText, attribution: Attribution, vertebral_config: VertebralConfig, references: Array, categories: Array, views: Array, annotations: Array, finding_zones: Array, }; diff --git a/packages/core-wasm/types/Animal.ts b/packages/core-wasm/types/Animal.ts new file mode 100644 index 00000000..5f10e342 --- /dev/null +++ b/packages/core-wasm/types/Animal.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Animal = { +/** + * Species of the animal; the sheet the report references matches it. + */ +speciesId: string, name: string, breed?: string, age?: string, }; diff --git a/packages/core-wasm/types/Annotation.ts b/packages/core-wasm/types/Annotation.ts new file mode 100644 index 00000000..454eba8d --- /dev/null +++ b/packages/core-wasm/types/Annotation.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DetailTriggerAnnotation } from "./DetailTriggerAnnotation"; +import type { ObservableAnnotation } from "./ObservableAnnotation"; + +export type Annotation = ObservableAnnotation | DetailTriggerAnnotation; diff --git a/packages/core-wasm/types/AnnotationCategory.ts b/packages/core-wasm/types/AnnotationCategory.ts new file mode 100644 index 00000000..a45de4c3 --- /dev/null +++ b/packages/core-wasm/types/AnnotationCategory.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LocalizedText } from "./LocalizedText"; + +export type AnnotationCategory = { id: string, name: LocalizedText, color: string | null, }; diff --git a/packages/core-wasm/types/ArchiveImport.ts b/packages/core-wasm/types/ArchiveImport.ts new file mode 100644 index 00000000..b29e999d --- /dev/null +++ b/packages/core-wasm/types/ArchiveImport.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ArchiveReadOutcome } from "./ArchiveReadOutcome"; +import type { RebaseOutcome } from "./RebaseOutcome"; + +/** + * An imported attachment read and rebased onto the loaded sheet. + */ +export type ArchiveImport = { read: ArchiveReadOutcome, rebase: RebaseOutcome, }; diff --git a/packages/core-wasm/types/ArchiveOrigin.ts b/packages/core-wasm/types/ArchiveOrigin.ts new file mode 100644 index 00000000..1007a865 --- /dev/null +++ b/packages/core-wasm/types/ArchiveOrigin.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ArchiveOrigin = "envelope_v1" | "bare_v3" | "v2"; diff --git a/packages/core-wasm/types/ArchiveReadOutcome.ts b/packages/core-wasm/types/ArchiveReadOutcome.ts new file mode 100644 index 00000000..69dbdebb --- /dev/null +++ b/packages/core-wasm/types/ArchiveReadOutcome.ts @@ -0,0 +1,22 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ArchiveOrigin } from "./ArchiveOrigin"; +import type { Report } from "./Report"; +import type { ReportArchiveEnvelope } from "./ReportArchiveEnvelope"; +import type { SnapshotRejection } from "./SnapshotRejection"; + +/** + * What an attachment gave back: always the report, the envelope when accepted. + */ +export type ArchiveReadOutcome = { report: Report, origin: ArchiveOrigin, migrated: boolean, +/** + * From the v2 migration; 0 for a v3 report. + */ +unresolvedZones: number, unresolvedFindings: number, +/** + * The validated envelope, when accepted. + */ +archive: ReportArchiveEnvelope | null, +/** + * Envelope present but dropped, with the reason. + */ +snapshotRejected?: SnapshotRejection, }; diff --git a/packages/core-wasm/types/Attribution.ts b/packages/core-wasm/types/Attribution.ts new file mode 100644 index 00000000..85a0df54 --- /dev/null +++ b/packages/core-wasm/types/Attribution.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Attribution = { authors: Array, license: string | null, notes: string | null, }; diff --git a/packages/core-wasm/types/Branding.ts b/packages/core-wasm/types/Branding.ts new file mode 100644 index 00000000..f5871c1e --- /dev/null +++ b/packages/core-wasm/types/Branding.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Credit } from "./Credit"; +import type { ImageAsset } from "./ImageAsset"; + +export type Branding = { siteUrl: string, headerLogo: ImageAsset | null, footerLogo: ImageAsset | null, poweredBy: Credit | null, partner: Credit | null, }; diff --git a/packages/core-wasm/types/Circle.ts b/packages/core-wasm/types/Circle.ts new file mode 100644 index 00000000..1ef5ea91 --- /dev/null +++ b/packages/core-wasm/types/Circle.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Circle = { type: "circle", cx: number, cy: number, r: number, }; diff --git a/packages/core-wasm/types/CountRange.ts b/packages/core-wasm/types/CountRange.ts new file mode 100644 index 00000000..12d88a67 --- /dev/null +++ b/packages/core-wasm/types/CountRange.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type CountRange = { min: number, max: number, }; diff --git a/packages/core-wasm/types/Credit.ts b/packages/core-wasm/types/Credit.ts new file mode 100644 index 00000000..7c2b18a5 --- /dev/null +++ b/packages/core-wasm/types/Credit.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ImageAsset } from "./ImageAsset"; + +export type Credit = { logo: ImageAsset | null, url: string, fallbackText: string, }; diff --git a/packages/core-wasm/types/DetailTriggerAnnotation.ts b/packages/core-wasm/types/DetailTriggerAnnotation.ts new file mode 100644 index 00000000..64029c37 --- /dev/null +++ b/packages/core-wasm/types/DetailTriggerAnnotation.ts @@ -0,0 +1,10 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Geometry } from "./Geometry"; +import type { Laterality } from "./Laterality"; +import type { LocalizedText } from "./LocalizedText"; +import type { ReviewStatus } from "./ReviewStatus"; + +/** + * Navigation only: a trigger opens a detail view and never carries findings. + */ +export type DetailTriggerAnnotation = { id: string, view_id: string, category_id: string, laterality: Laterality, geometry: Geometry | null, review_status: ReviewStatus, color: string | null, kind: "detail_trigger", name: LocalizedText | null, opens_view_id: string, }; diff --git a/packages/core-wasm/types/DetailView.ts b/packages/core-wasm/types/DetailView.ts new file mode 100644 index 00000000..30d87ab1 --- /dev/null +++ b/packages/core-wasm/types/DetailView.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LocalizedText } from "./LocalizedText"; +import type { ViewBox } from "./ViewBox"; + +export type DetailView = { id: string, name: LocalizedText, svg_asset_id: string | null, view_box: ViewBox | null, kind: "detail", parent_view_id: string, }; diff --git a/packages/core-wasm/types/DraftRestore.ts b/packages/core-wasm/types/DraftRestore.ts new file mode 100644 index 00000000..c76f4933 --- /dev/null +++ b/packages/core-wasm/types/DraftRestore.ts @@ -0,0 +1,16 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { RebaseOutcome } from "./RebaseOutcome"; +import type { ReportArchiveEnvelope } from "./ReportArchiveEnvelope"; + +/** + * A restored draft: the rebase outcome carries the report the store opens. + */ +export type DraftRestore = { rebase: RebaseOutcome, +/** + * The session's archive envelope, when one was stored and still parses. + */ +archive: ReportArchiveEnvelope | null, +/** + * An archive text was stored but no longer parses (the caller sets it aside). + */ +archiveRejected: boolean, }; diff --git a/packages/core-wasm/types/DraftRestoreInput.ts b/packages/core-wasm/types/DraftRestoreInput.ts new file mode 100644 index 00000000..e079e634 --- /dev/null +++ b/packages/core-wasm/types/DraftRestoreInput.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type DraftRestoreInput = { +/** + * The raw text of the tab's draft. + */ +draft: string, +/** + * The raw text of the session's archive envelope, when one is stored. + */ +archive: string | null, }; diff --git a/packages/core-wasm/types/Finding.ts b/packages/core-wasm/types/Finding.ts new file mode 100644 index 00000000..2ee2bf56 --- /dev/null +++ b/packages/core-wasm/types/Finding.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LateralSide } from "./LateralSide"; + +export type Finding = { findingZoneId: string, +/** + * Node ids from the zone's categories down to the leaf. + */ +path: Array, labelFrSnapshot: string, labelEnSnapshot: string, requiresVetReferral?: boolean, side?: LateralSide, +/** + * Set by the migration when the path no longer exists in the sheet; data kept. + */ +unresolved?: true, }; diff --git a/packages/core-wasm/types/FindingCategory.ts b/packages/core-wasm/types/FindingCategory.ts new file mode 100644 index 00000000..7ccb2859 --- /dev/null +++ b/packages/core-wasm/types/FindingCategory.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { FindingCategoryKind } from "./FindingCategoryKind"; +import type { FindingNode } from "./FindingNode"; +import type { LocalizedOptionalText } from "./LocalizedOptionalText"; +import type { LocalizedText } from "./LocalizedText"; +import type { ReviewStatus } from "./ReviewStatus"; + +export type FindingCategory = { id: string, kind: FindingCategoryKind, name: LocalizedText, description: LocalizedOptionalText, reference_ids: Array, review_status: ReviewStatus, children: Array, }; diff --git a/packages/core-wasm/types/FindingCategoryKind.ts b/packages/core-wasm/types/FindingCategoryKind.ts new file mode 100644 index 00000000..dc819a0c --- /dev/null +++ b/packages/core-wasm/types/FindingCategoryKind.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type FindingCategoryKind = "dysfunction" | "consultation_reason" | "anamnesis" | "custom"; diff --git a/packages/core-wasm/types/FindingNode.ts b/packages/core-wasm/types/FindingNode.ts new file mode 100644 index 00000000..9b71a78c --- /dev/null +++ b/packages/core-wasm/types/FindingNode.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LocalizedOptionalText } from "./LocalizedOptionalText"; +import type { LocalizedText } from "./LocalizedText"; +import type { ReviewStatus } from "./ReviewStatus"; + +/** + * A finding node; every optional key of the authoring form is filled in when parsed. + */ +export type FindingNode = { id: string, name: LocalizedText, description: LocalizedOptionalText, requires_vet_referral: boolean, reference_ids: Array, review_status: ReviewStatus, children: Array, }; diff --git a/packages/core-wasm/types/FindingToggleInput.ts b/packages/core-wasm/types/FindingToggleInput.ts new file mode 100644 index 00000000..84c1fbcb --- /dev/null +++ b/packages/core-wasm/types/FindingToggleInput.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { JsIndex } from "./JsIndex"; +import type { LateralSide } from "./LateralSide"; +import type { Observation } from "./Observation"; + +export type FindingToggleInput = { observation: Observation, findingZoneId: string, path: Array, leafPosition: JsIndex, side?: LateralSide, }; diff --git a/packages/core-wasm/types/FindingZone.ts b/packages/core-wasm/types/FindingZone.ts new file mode 100644 index 00000000..99538c7c --- /dev/null +++ b/packages/core-wasm/types/FindingZone.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { FindingCategory } from "./FindingCategory"; +import type { LocalizedText } from "./LocalizedText"; + +export type FindingZone = { id: string, name: LocalizedText, categories: Array, }; diff --git a/packages/core-wasm/types/Geometry.ts b/packages/core-wasm/types/Geometry.ts new file mode 100644 index 00000000..3468ca76 --- /dev/null +++ b/packages/core-wasm/types/Geometry.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Circle } from "./Circle"; +import type { PathGeometry } from "./PathGeometry"; +import type { Polygon } from "./Polygon"; + +export type Geometry = Circle | Polygon | PathGeometry; diff --git a/packages/core-wasm/types/ImageAsset.ts b/packages/core-wasm/types/ImageAsset.ts new file mode 100644 index 00000000..fdae349d --- /dev/null +++ b/packages/core-wasm/types/ImageAsset.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PngAsset } from "./PngAsset"; +import type { SvgAsset } from "./SvgAsset"; + +export type ImageAsset = PngAsset | SvgAsset; diff --git a/packages/core-wasm/types/JsIndex.ts b/packages/core-wasm/types/JsIndex.ts new file mode 100644 index 00000000..992a1a76 --- /dev/null +++ b/packages/core-wasm/types/JsIndex.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * An index as JavaScript sent it: a number. Only a non-negative integer names a position. + */ +export type JsIndex = number; diff --git a/packages/core-wasm/types/Laterality.ts b/packages/core-wasm/types/Laterality.ts new file mode 100644 index 00000000..6e04ae2a --- /dev/null +++ b/packages/core-wasm/types/Laterality.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Explicit on every annotation: absence no longer carries meaning. + */ +export type Laterality = "unpaired" | "bilateral" | "left" | "right"; diff --git a/packages/core-wasm/types/Locale.ts b/packages/core-wasm/types/Locale.ts new file mode 100644 index 00000000..a7f6c6a0 --- /dev/null +++ b/packages/core-wasm/types/Locale.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Locale = "fr" | "en"; diff --git a/packages/core-wasm/types/LocalizedOptionalText.ts b/packages/core-wasm/types/LocalizedOptionalText.ts new file mode 100644 index 00000000..d5193e8a --- /dev/null +++ b/packages/core-wasm/types/LocalizedOptionalText.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type LocalizedOptionalText = { fr?: string, en?: string, }; diff --git a/packages/core-wasm/types/LocalizedText.ts b/packages/core-wasm/types/LocalizedText.ts new file mode 100644 index 00000000..6541db68 --- /dev/null +++ b/packages/core-wasm/types/LocalizedText.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type LocalizedText = { fr: string, en: string, }; diff --git a/packages/core-wasm/types/MainView.ts b/packages/core-wasm/types/MainView.ts new file mode 100644 index 00000000..87302584 --- /dev/null +++ b/packages/core-wasm/types/MainView.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LocalizedText } from "./LocalizedText"; +import type { ViewBox } from "./ViewBox"; + +export type MainView = { id: string, name: LocalizedText, svg_asset_id: string | null, view_box: ViewBox | null, kind: "main", }; diff --git a/packages/core-wasm/types/MigrationOutcome.ts b/packages/core-wasm/types/MigrationOutcome.ts new file mode 100644 index 00000000..12f07239 --- /dev/null +++ b/packages/core-wasm/types/MigrationOutcome.ts @@ -0,0 +1,15 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Report } from "./Report"; + +/** + * The report as v3 and what the migration could not place (0 for a v3 document). + */ +export type MigrationOutcome = { report: Report, +/** + * Zones whose legacy id has no annotation in the map. + */ +unresolvedZones: number, +/** + * Findings whose legacy path no longer exists in the sheet. + */ +unresolvedFindings: number, }; diff --git a/packages/core-wasm/types/MoveDirection.ts b/packages/core-wasm/types/MoveDirection.ts new file mode 100644 index 00000000..e039dcee --- /dev/null +++ b/packages/core-wasm/types/MoveDirection.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type MoveDirection = "up" | "down"; diff --git a/packages/core-wasm/types/MoveObservationInput.ts b/packages/core-wasm/types/MoveObservationInput.ts new file mode 100644 index 00000000..a3b4e1f2 --- /dev/null +++ b/packages/core-wasm/types/MoveObservationInput.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { JsIndex } from "./JsIndex"; +import type { MoveDirection } from "./MoveDirection"; +import type { Report } from "./Report"; + +export type MoveObservationInput = { report: Report, index: JsIndex, direction: MoveDirection, }; diff --git a/packages/core-wasm/types/NewReportDraft.ts b/packages/core-wasm/types/NewReportDraft.ts new file mode 100644 index 00000000..efad0909 --- /dev/null +++ b/packages/core-wasm/types/NewReportDraft.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Animal } from "./Animal"; +import type { NextAppointment } from "./NextAppointment"; +import type { Observation } from "./Observation"; +import type { Owner } from "./Owner"; +import type { Practitioner } from "./Practitioner"; + +/** + * What a new report needs before version, id, dates and the sheet are stamped + * (`Omit`). + */ +export type NewReportDraft = { date: string, practitioner: Practitioner, animal: Animal, owner: Owner, observations: Array, conclusion: string, recommendations: string, nextAppointment?: NextAppointment, }; diff --git a/packages/core-wasm/types/NewReportInput.ts b/packages/core-wasm/types/NewReportInput.ts new file mode 100644 index 00000000..4b1bed70 --- /dev/null +++ b/packages/core-wasm/types/NewReportInput.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NewReportDraft } from "./NewReportDraft"; +import type { SheetRef } from "./SheetRef"; + +export type NewReportInput = { draft: NewReportDraft, sheet: SheetRef, id: string, createdAt: string, observationId: string, }; diff --git a/packages/core-wasm/types/NextAppointment.ts b/packages/core-wasm/types/NextAppointment.ts new file mode 100644 index 00000000..61958a7c --- /dev/null +++ b/packages/core-wasm/types/NextAppointment.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NextAppointmentDate } from "./NextAppointmentDate"; +import type { NextAppointmentPeriod } from "./NextAppointmentPeriod"; + +export type NextAppointment = NextAppointmentDate | NextAppointmentPeriod; diff --git a/packages/core-wasm/types/NextAppointmentDate.ts b/packages/core-wasm/types/NextAppointmentDate.ts new file mode 100644 index 00000000..235395ef --- /dev/null +++ b/packages/core-wasm/types/NextAppointmentDate.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type NextAppointmentDate = { kind: "date", date: string, }; diff --git a/packages/core-wasm/types/NextAppointmentPeriod.ts b/packages/core-wasm/types/NextAppointmentPeriod.ts new file mode 100644 index 00000000..48841570 --- /dev/null +++ b/packages/core-wasm/types/NextAppointmentPeriod.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type NextAppointmentPeriod = { kind: "period", text: string, }; diff --git a/packages/core-wasm/types/ObservableAnnotation.ts b/packages/core-wasm/types/ObservableAnnotation.ts new file mode 100644 index 00000000..9f60d29e --- /dev/null +++ b/packages/core-wasm/types/ObservableAnnotation.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Geometry } from "./Geometry"; +import type { Laterality } from "./Laterality"; +import type { LocalizedText } from "./LocalizedText"; +import type { ObservableKind } from "./ObservableKind"; +import type { ReviewStatus } from "./ReviewStatus"; + +/** + * A point or zone annotation: observable, linked to findings by one explicit field. + */ +export type ObservableAnnotation = { id: string, view_id: string, category_id: string, laterality: Laterality, geometry: Geometry | null, review_status: ReviewStatus, color: string | null, name: LocalizedText, finding_zone_id: string | null, vertebral_region_code: string | null, kind: ObservableKind, }; diff --git a/packages/core-wasm/types/ObservableKind.ts b/packages/core-wasm/types/ObservableKind.ts new file mode 100644 index 00000000..01411436 --- /dev/null +++ b/packages/core-wasm/types/ObservableKind.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * The two observable annotation kinds share one shape. + */ +export type ObservableKind = "point" | "zone"; diff --git a/packages/core-wasm/types/Observation.ts b/packages/core-wasm/types/Observation.ts new file mode 100644 index 00000000..6cf3cee0 --- /dev/null +++ b/packages/core-wasm/types/Observation.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Finding } from "./Finding"; +import type { ReportZone } from "./ReportZone"; +import type { Severity } from "./Severity"; + +export type Observation = { id: string, zones: Array, findings: Array, freeTextFindings: Array, severity?: Severity, comment: string, }; diff --git a/packages/core-wasm/types/ObservationIndexInput.ts b/packages/core-wasm/types/ObservationIndexInput.ts new file mode 100644 index 00000000..0ad71bd6 --- /dev/null +++ b/packages/core-wasm/types/ObservationIndexInput.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { JsIndex } from "./JsIndex"; +import type { Observation } from "./Observation"; + +export type ObservationIndexInput = { observation: Observation, index: JsIndex, }; diff --git a/packages/core-wasm/types/Owner.ts b/packages/core-wasm/types/Owner.ts new file mode 100644 index 00000000..f4444e9d --- /dev/null +++ b/packages/core-wasm/types/Owner.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Owner = { name: string, }; diff --git a/packages/core-wasm/types/PathGeometry.ts b/packages/core-wasm/types/PathGeometry.ts new file mode 100644 index 00000000..f60f7c3e --- /dev/null +++ b/packages/core-wasm/types/PathGeometry.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type PathGeometry = { type: "path", d: string, }; diff --git a/packages/core-wasm/types/PdfLabelSet.ts b/packages/core-wasm/types/PdfLabelSet.ts new file mode 100644 index 00000000..60b25e12 --- /dev/null +++ b/packages/core-wasm/types/PdfLabelSet.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PdfLabels } from "./PdfLabels"; + +/** + * Strict: every key present in both locales, no extra key. + */ +export type PdfLabelSet = { fr: PdfLabels, en: PdfLabels, }; diff --git a/packages/core-wasm/types/PdfLabels.ts b/packages/core-wasm/types/PdfLabels.ts new file mode 100644 index 00000000..ee7c8f4e --- /dev/null +++ b/packages/core-wasm/types/PdfLabels.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Fields in the order of the engine dictionaries (`packages/pdf/src/i18n`), which is the + * order every shipped attachment carries. + */ +export type PdfLabels = { "pdf.eyebrow.observation": string, "pdf.eyebrow.synthesis": string, "pdf.title.conclusion": string, "pdf.section.zones": string, "pdf.section.findings_prefix": string, "pdf.section.free_findings": string, "pdf.section.severity": string, "pdf.section.comment": string, "pdf.section.conclusion": string, "pdf.section.recommendations": string, "pdf.section.next_appointment": string, "pdf.view.general": string, "pdf.view.detail_prefix": string, "pdf.empty": string, "pdf.owner_prefix": string, "pdf.siret_prefix": string, "pdf.title.suffix.bilan": string, "pdf.subject": string, "severity.mild": string, "severity.moderate": string, "severity.severe": string, "lateral.left": string, "lateral.right": string, "footer.powered_by": string, "footer.in_partnership": string, }; diff --git a/packages/core-wasm/types/PngAsset.ts b/packages/core-wasm/types/PngAsset.ts new file mode 100644 index 00000000..9f7503ec --- /dev/null +++ b/packages/core-wasm/types/PngAsset.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type PngAsset = { kind: "png", base64: string, }; diff --git a/packages/core-wasm/types/Point.ts b/packages/core-wasm/types/Point.ts new file mode 100644 index 00000000..5bba703b --- /dev/null +++ b/packages/core-wasm/types/Point.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * A polygon point: a pair of finite numbers. + */ +export type Point = [number, number]; diff --git a/packages/core-wasm/types/Polygon.ts b/packages/core-wasm/types/Polygon.ts new file mode 100644 index 00000000..9712b47d --- /dev/null +++ b/packages/core-wasm/types/Polygon.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Point } from "./Point"; + +export type Polygon = { type: "polygon", points: Array, }; diff --git a/packages/core-wasm/types/Practitioner.ts b/packages/core-wasm/types/Practitioner.ts new file mode 100644 index 00000000..59df1220 --- /dev/null +++ b/packages/core-wasm/types/Practitioner.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Practitioner = { name: string, cabinet?: string, contact?: string, +/** + * SIRET, 14-digit French business identifier (not validated). + */ +siret?: string, }; diff --git a/packages/core-wasm/types/RebaseOutcome.ts b/packages/core-wasm/types/RebaseOutcome.ts new file mode 100644 index 00000000..606f3036 --- /dev/null +++ b/packages/core-wasm/types/RebaseOutcome.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Report } from "./Report"; + +export type RebaseOutcome = { report: Report, +/** + * Zones and findings newly flagged by this rebase. + */ +unresolvedZones: number, unresolvedFindings: number, rebased: boolean, }; diff --git a/packages/core-wasm/types/Reference.ts b/packages/core-wasm/types/Reference.ts new file mode 100644 index 00000000..259da80d --- /dev/null +++ b/packages/core-wasm/types/Reference.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ReferenceType } from "./ReferenceType"; + +/** + * One bibliographic reference, declared once and cited by id. + */ +export type Reference = { id: string, type: ReferenceType, citation: string, url: string | null, doi: string | null, }; diff --git a/packages/core-wasm/types/ReferenceType.ts b/packages/core-wasm/types/ReferenceType.ts new file mode 100644 index 00000000..27ec76b1 --- /dev/null +++ b/packages/core-wasm/types/ReferenceType.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ReferenceType = "book" | "journal" | "standard" | "legal" | "web" | "manual"; diff --git a/packages/core-wasm/types/Report.ts b/packages/core-wasm/types/Report.ts new file mode 100644 index 00000000..16385fee --- /dev/null +++ b/packages/core-wasm/types/Report.ts @@ -0,0 +1,21 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Animal } from "./Animal"; +import type { NextAppointment } from "./NextAppointment"; +import type { Observation } from "./Observation"; +import type { Owner } from "./Owner"; +import type { Practitioner } from "./Practitioner"; +import type { SheetRef } from "./SheetRef"; + +export type Report = { version: 3, id: string, +/** + * ISO timestamp of report creation. + */ +createdAt: string, +/** + * ISO date of the clinical encounter. + */ +date: string, practitioner: Practitioner, animal: Animal, owner: Owner, sheet: SheetRef, observations: Array, conclusion: string, recommendations: string, nextAppointment?: NextAppointment, +/** + * Reserved for report-only points (OPEN_QUESTIONS Q6); empty until defined. + */ +localAnnotations: Array, }; diff --git a/packages/core-wasm/types/ReportArchiveEnvelope.ts b/packages/core-wasm/types/ReportArchiveEnvelope.ts new file mode 100644 index 00000000..95c14732 --- /dev/null +++ b/packages/core-wasm/types/ReportArchiveEnvelope.ts @@ -0,0 +1,19 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Branding } from "./Branding"; +import type { Locale } from "./Locale"; +import type { PdfLabelSet } from "./PdfLabelSet"; +import type { Report } from "./Report"; +import type { SheetSnapshot } from "./SheetSnapshot"; + +/** + * An archive envelope, in the order the engine writes it. + */ +export type ReportArchiveEnvelope = { format: "faunosteo-report-archive", envelopeVersion: 1, +/** + * ISO timestamp of the export. + */ +exportedAt: string, locale: Locale, +/** + * As exported, never rebased. + */ +report: Report, sheetSnapshot: SheetSnapshot, branding: Branding, labels: PdfLabelSet, }; diff --git a/packages/core-wasm/types/ReportIdInput.ts b/packages/core-wasm/types/ReportIdInput.ts new file mode 100644 index 00000000..8b4186a2 --- /dev/null +++ b/packages/core-wasm/types/ReportIdInput.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Report } from "./Report"; + +export type ReportIdInput = { report: Report, id: string, }; diff --git a/packages/core-wasm/types/ReportIndexInput.ts b/packages/core-wasm/types/ReportIndexInput.ts new file mode 100644 index 00000000..499844ae --- /dev/null +++ b/packages/core-wasm/types/ReportIndexInput.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { JsIndex } from "./JsIndex"; +import type { Report } from "./Report"; + +export type ReportIndexInput = { report: Report, index: JsIndex, }; diff --git a/packages/core-wasm/types/ReportZone.ts b/packages/core-wasm/types/ReportZone.ts index f0b42b7d..0b04baa8 100644 --- a/packages/core-wasm/types/ReportZone.ts +++ b/packages/core-wasm/types/ReportZone.ts @@ -3,8 +3,7 @@ import type { LateralSide } from "./LateralSide"; import type { Vertebra } from "./Vertebra"; /** - * A zone of an observation. Unknown keys are ignored on input, as the Zod schema strips - * them; optional fields are written only when set. + * A zone of an observation. */ export type ReportZone = { annotationId: string, viewId: string, side?: LateralSide, vertebrae?: Array, /** diff --git a/packages/core-wasm/types/ReviewStatus.ts b/packages/core-wasm/types/ReviewStatus.ts new file mode 100644 index 00000000..20c34ba2 --- /dev/null +++ b/packages/core-wasm/types/ReviewStatus.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * How far the content was checked against references. + */ +export type ReviewStatus = "inherited" | "reviewed" | "to_confirm"; diff --git a/packages/core-wasm/types/Severity.ts b/packages/core-wasm/types/Severity.ts new file mode 100644 index 00000000..e2691b3b --- /dev/null +++ b/packages/core-wasm/types/Severity.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Severity = "mild" | "moderate" | "severe"; diff --git a/packages/core-wasm/types/SheetCheck.ts b/packages/core-wasm/types/SheetCheck.ts new file mode 100644 index 00000000..33b075e1 --- /dev/null +++ b/packages/core-wasm/types/SheetCheck.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { SheetIssue } from "./SheetIssue"; + +/** + * The issues of a shape-valid document and whether they allow publication. + */ +export type SheetCheck = { issues: Array, publishable: boolean, }; diff --git a/packages/core-wasm/types/SheetIndexData.ts b/packages/core-wasm/types/SheetIndexData.ts new file mode 100644 index 00000000..96922974 --- /dev/null +++ b/packages/core-wasm/types/SheetIndexData.ts @@ -0,0 +1,39 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AnatomicalSheetDocument } from "./AnatomicalSheetDocument"; +import type { LocalizedText } from "./LocalizedText"; +import type { SheetRef } from "./SheetRef"; +import type { SheetStatus } from "./SheetStatus"; + +export type SheetIndexData = { status: SheetStatus, ref: SheetRef, speciesId: string, schemaVersion: number, +/** + * The first `main` view of the document. + */ +mainViewId: string, +/** + * The document as parsed (defaults filled in). + */ +document: AnatomicalSheetDocument, +/** + * Position in `document.views` by id; the last duplicate wins. + */ +viewById: { [key in string]: number }, +/** + * Position in `document.annotations` by id; the last duplicate wins. + */ +annotationById: { [key in string]: number }, +/** + * Position in `document.finding_zones` by id; the last duplicate wins. + */ +findingZoneById: { [key in string]: number }, +/** + * Display name of every annotation id (a trigger: its own, else its view's). + */ +names: { [key in string]: LocalizedText }, +/** + * Ids that open the vertebra picker, in document order, each once. + */ +spineIds: Array, +/** + * Every finding path the sheet holds, as the JSON text of `[zoneId, ...path]`. + */ +nodeKeys: Array, }; diff --git a/packages/core-wasm/types/SheetIssue.ts b/packages/core-wasm/types/SheetIssue.ts new file mode 100644 index 00000000..33ff1043 --- /dev/null +++ b/packages/core-wasm/types/SheetIssue.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { SheetIssueSeverity } from "./SheetIssueSeverity"; + +export type SheetIssue = { code: string, severity: SheetIssueSeverity, path: string, message: string, }; diff --git a/packages/core-wasm/types/SheetIssueSeverity.ts b/packages/core-wasm/types/SheetIssueSeverity.ts new file mode 100644 index 00000000..5e913d9d --- /dev/null +++ b/packages/core-wasm/types/SheetIssueSeverity.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SheetIssueSeverity = "error" | "warning"; diff --git a/packages/core-wasm/types/SheetRef.ts b/packages/core-wasm/types/SheetRef.ts index a1a95cd0..4f286e11 100644 --- a/packages/core-wasm/types/SheetRef.ts +++ b/packages/core-wasm/types/SheetRef.ts @@ -1,7 +1,7 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. /** - * Reference of the anatomical sheet a report was written against (`Report.sheet`). + * The sheet document a report was built on, by content. */ export type SheetRef = { sheetId: string, /** diff --git a/packages/core-wasm/types/SheetSnapshot.ts b/packages/core-wasm/types/SheetSnapshot.ts new file mode 100644 index 00000000..567d7b31 --- /dev/null +++ b/packages/core-wasm/types/SheetSnapshot.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AnatomicalSheetDocument } from "./AnatomicalSheetDocument"; +import type { SheetSnapshotAsset } from "./SheetSnapshotAsset"; +import type { SheetSnapshotRef } from "./SheetSnapshotRef"; +import type { SheetStatus } from "./SheetStatus"; + +export type SheetSnapshot = { status: SheetStatus, ref: SheetSnapshotRef, +/** + * Lean, valid document (schema v2, strict). + */ +document: AnatomicalSheetDocument, assets: Array, }; diff --git a/packages/core-wasm/types/SheetSnapshotAsset.ts b/packages/core-wasm/types/SheetSnapshotAsset.ts new file mode 100644 index 00000000..44f676e7 --- /dev/null +++ b/packages/core-wasm/types/SheetSnapshotAsset.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SheetSnapshotAsset = { svgAssetId: string, +/** + * Content address from the seed manifest; a provenance pointer, not a tamper check. + */ +sha256: string | null, svg: string, }; diff --git a/packages/core-wasm/types/SheetSnapshotRef.ts b/packages/core-wasm/types/SheetSnapshotRef.ts new file mode 100644 index 00000000..27730a8f --- /dev/null +++ b/packages/core-wasm/types/SheetSnapshotRef.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * `SheetRefSchema.extend({schemaVersion, speciesId}).strict()`. + */ +export type SheetSnapshotRef = { sheetId: string, versionId: string | null, documentSha256: string, schemaVersion: number, speciesId: string, }; diff --git a/packages/core-wasm/types/SheetStatus.ts b/packages/core-wasm/types/SheetStatus.ts new file mode 100644 index 00000000..be17250c --- /dev/null +++ b/packages/core-wasm/types/SheetStatus.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SheetStatus = "draft" | "published"; diff --git a/packages/core-wasm/types/SheetView.ts b/packages/core-wasm/types/SheetView.ts new file mode 100644 index 00000000..92f07721 --- /dev/null +++ b/packages/core-wasm/types/SheetView.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DetailView } from "./DetailView"; +import type { MainView } from "./MainView"; + +/** + * Views form a tree: a detail names its parent, any depth. + */ +export type SheetView = MainView | DetailView; diff --git a/packages/core-wasm/types/SnapshotInput.ts b/packages/core-wasm/types/SnapshotInput.ts new file mode 100644 index 00000000..0a895bdb --- /dev/null +++ b/packages/core-wasm/types/SnapshotInput.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Report } from "./Report"; + +export type SnapshotInput = { report: Report, }; diff --git a/packages/core-wasm/types/SnapshotRejection.ts b/packages/core-wasm/types/SnapshotRejection.ts new file mode 100644 index 00000000..81042866 --- /dev/null +++ b/packages/core-wasm/types/SnapshotRejection.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Why an imported snapshot (or its envelope) is dropped; the import reports it. + */ +export type SnapshotRejection = "unsupported_envelope" | "schema" | "caps" | "integrity" | "sheet_mismatch"; diff --git a/packages/core-wasm/types/SvgAsset.ts b/packages/core-wasm/types/SvgAsset.ts new file mode 100644 index 00000000..be0994d5 --- /dev/null +++ b/packages/core-wasm/types/SvgAsset.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SvgAsset = { kind: "svg", svg: string, }; diff --git a/packages/core-wasm/types/Vertebra.ts b/packages/core-wasm/types/Vertebra.ts index ee8f0693..d170adc8 100644 --- a/packages/core-wasm/types/Vertebra.ts +++ b/packages/core-wasm/types/Vertebra.ts @@ -1,6 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. /** - * One vertebra of a spine zone: the region code and the 1-based index in that region. + * One vertebra: the sheet's region code and the 1-based index in that region. */ export type Vertebra = { region: string, index: number, }; diff --git a/packages/core-wasm/types/VertebraAction.ts b/packages/core-wasm/types/VertebraAction.ts new file mode 100644 index 00000000..4d3c9922 --- /dev/null +++ b/packages/core-wasm/types/VertebraAction.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * One tap of the picker. + */ +export type VertebraAction = { "kind": "toggle", region: string, index: number, } | { "kind": "all", region: string, count: number, } | { "kind": "none", region: string, }; diff --git a/packages/core-wasm/types/VertebraSelectInput.ts b/packages/core-wasm/types/VertebraSelectInput.ts new file mode 100644 index 00000000..3822e154 --- /dev/null +++ b/packages/core-wasm/types/VertebraSelectInput.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Vertebra } from "./Vertebra"; +import type { VertebraAction } from "./VertebraAction"; + +export type VertebraSelectInput = { selection: Array, action: VertebraAction, }; diff --git a/packages/core-wasm/types/VertebraSyncInput.ts b/packages/core-wasm/types/VertebraSyncInput.ts new file mode 100644 index 00000000..594398d7 --- /dev/null +++ b/packages/core-wasm/types/VertebraSyncInput.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Observation } from "./Observation"; +import type { Vertebra } from "./Vertebra"; + +export type VertebraSyncInput = { observation: Observation, selection: Array, viewId: string, }; diff --git a/packages/core-wasm/types/VertebralConfig.ts b/packages/core-wasm/types/VertebralConfig.ts new file mode 100644 index 00000000..52c53571 --- /dev/null +++ b/packages/core-wasm/types/VertebralConfig.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { VertebralRegion } from "./VertebralRegion"; + +export type VertebralConfig = { regions: Array, }; diff --git a/packages/core-wasm/types/VertebralRegion.ts b/packages/core-wasm/types/VertebralRegion.ts new file mode 100644 index 00000000..4553f326 --- /dev/null +++ b/packages/core-wasm/types/VertebralRegion.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CountRange } from "./CountRange"; +import type { LocalizedText } from "./LocalizedText"; + +export type VertebralRegion = { code: string, name: LocalizedText, count: number, count_range: CountRange | null, }; diff --git a/packages/core-wasm/types/ViewBox.ts b/packages/core-wasm/types/ViewBox.ts new file mode 100644 index 00000000..162428a6 --- /dev/null +++ b/packages/core-wasm/types/ViewBox.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ViewBox = { min_x: number, min_y: number, width: number, height: number, }; diff --git a/packages/core-wasm/types/ZoneClick.ts b/packages/core-wasm/types/ZoneClick.ts new file mode 100644 index 00000000..049ab784 --- /dev/null +++ b/packages/core-wasm/types/ZoneClick.ts @@ -0,0 +1,30 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LateralSide } from "./LateralSide"; +import type { Observation } from "./Observation"; +import type { Vertebra } from "./Vertebra"; +import type { ZoneClickKind } from "./ZoneClickKind"; + +/** + * What a click on an annotation did, with what the editor needs to follow it up. + */ +export type ZoneClick = { kind: ZoneClickKind, +/** + * `open_view`: the detail view to open. + */ +viewId?: string, +/** + * The active observation after the click, when the click changed it. + */ +observation?: Observation, +/** + * `open_vertebra_picker`: the zone the picker edits. + */ +zoneIndex?: number, +/** + * `open_laterality_picker`: the sides already recorded. + */ +sidesPresent?: Array, +/** + * `open_vertebra_picker`: the picker's initial selection. + */ +vertebrae?: Array, }; diff --git a/packages/core-wasm/types/ZoneClickInput.ts b/packages/core-wasm/types/ZoneClickInput.ts new file mode 100644 index 00000000..27382027 --- /dev/null +++ b/packages/core-wasm/types/ZoneClickInput.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Observation } from "./Observation"; + +export type ZoneClickInput = { observation: Observation | null, annotationId: string, }; diff --git a/packages/core-wasm/types/ZoneClickKind.ts b/packages/core-wasm/types/ZoneClickKind.ts new file mode 100644 index 00000000..0997ea94 --- /dev/null +++ b/packages/core-wasm/types/ZoneClickKind.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * The kind of a click decision (`ZoneClickDecision.kind`). + */ +export type ZoneClickKind = "ignore" | "open_view" | "activate_fallback" | "open_vertebra_picker" | "open_laterality_picker" | "remove_both_sides" | "toggle"; diff --git a/packages/core-wasm/types/index.ts b/packages/core-wasm/types/index.ts index bcd07fa8..15ab92a9 100644 --- a/packages/core-wasm/types/index.ts +++ b/packages/core-wasm/types/index.ts @@ -1,6 +1,88 @@ // Types of the core contracts, generated by ts-rs from crates/core (`pnpm rust:check` -// regenerates them; CI fails when the committed files drift from the Rust structs). +// regenerates them; the drift gate fails when the committed files differ from the Rust structs). +// This index lists every generated file: tests/types-index.test.ts keeps it complete. +export type { AddSidesInput } from './AddSidesInput' +export type { AnatomicalSheetDocument } from './AnatomicalSheetDocument' +export type { Animal } from './Animal' +export type { AnnotationCategory } from './AnnotationCategory' +export type { Annotation } from './Annotation' +export type { ArchiveImport } from './ArchiveImport' +export type { ArchiveOrigin } from './ArchiveOrigin' +export type { ArchiveReadOutcome } from './ArchiveReadOutcome' +export type { Attribution } from './Attribution' +export type { Branding } from './Branding' +export type { Circle } from './Circle' +export type { CountRange } from './CountRange' +export type { Credit } from './Credit' +export type { DetailTriggerAnnotation } from './DetailTriggerAnnotation' +export type { DetailView } from './DetailView' +export type { DraftRestoreInput } from './DraftRestoreInput' +export type { DraftRestore } from './DraftRestore' +export type { FindingCategoryKind } from './FindingCategoryKind' +export type { FindingCategory } from './FindingCategory' +export type { FindingNode } from './FindingNode' +export type { FindingToggleInput } from './FindingToggleInput' +export type { Finding } from './Finding' +export type { FindingZone } from './FindingZone' +export type { Geometry } from './Geometry' +export type { ImageAsset } from './ImageAsset' +export type { JsIndex } from './JsIndex' +export type { Laterality } from './Laterality' export type { LateralSide } from './LateralSide' +export type { Locale } from './Locale' +export type { LocalizedOptionalText } from './LocalizedOptionalText' +export type { LocalizedText } from './LocalizedText' +export type { MainView } from './MainView' +export type { MigrationOutcome } from './MigrationOutcome' +export type { MoveDirection } from './MoveDirection' +export type { MoveObservationInput } from './MoveObservationInput' +export type { NewReportDraft } from './NewReportDraft' +export type { NewReportInput } from './NewReportInput' +export type { NextAppointmentDate } from './NextAppointmentDate' +export type { NextAppointmentPeriod } from './NextAppointmentPeriod' +export type { NextAppointment } from './NextAppointment' +export type { ObservableAnnotation } from './ObservableAnnotation' +export type { ObservableKind } from './ObservableKind' +export type { ObservationIndexInput } from './ObservationIndexInput' +export type { Observation } from './Observation' +export type { Owner } from './Owner' +export type { PathGeometry } from './PathGeometry' +export type { PdfLabelSet } from './PdfLabelSet' +export type { PdfLabels } from './PdfLabels' +export type { PngAsset } from './PngAsset' +export type { Point } from './Point' +export type { Polygon } from './Polygon' +export type { Practitioner } from './Practitioner' +export type { RebaseOutcome } from './RebaseOutcome' +export type { Reference } from './Reference' +export type { ReferenceType } from './ReferenceType' +export type { ReportArchiveEnvelope } from './ReportArchiveEnvelope' +export type { ReportIdInput } from './ReportIdInput' +export type { ReportIndexInput } from './ReportIndexInput' +export type { Report } from './Report' export type { ReportZone } from './ReportZone' +export type { ReviewStatus } from './ReviewStatus' +export type { Severity } from './Severity' +export type { SheetCheck } from './SheetCheck' +export type { SheetIndexData } from './SheetIndexData' +export type { SheetIssueSeverity } from './SheetIssueSeverity' +export type { SheetIssue } from './SheetIssue' export type { SheetRef } from './SheetRef' +export type { SheetSnapshotAsset } from './SheetSnapshotAsset' +export type { SheetSnapshotRef } from './SheetSnapshotRef' +export type { SheetSnapshot } from './SheetSnapshot' +export type { SheetStatus } from './SheetStatus' +export type { SheetView } from './SheetView' +export type { SnapshotInput } from './SnapshotInput' +export type { SnapshotRejection } from './SnapshotRejection' +export type { SvgAsset } from './SvgAsset' +export type { VertebraAction } from './VertebraAction' +export type { VertebralConfig } from './VertebralConfig' +export type { VertebralRegion } from './VertebralRegion' +export type { VertebraSelectInput } from './VertebraSelectInput' +export type { VertebraSyncInput } from './VertebraSyncInput' export type { Vertebra } from './Vertebra' +export type { ViewBox } from './ViewBox' +export type { ZoneClickInput } from './ZoneClickInput' +export type { ZoneClickKind } from './ZoneClickKind' +export type { ZoneClick } from './ZoneClick' diff --git a/packages/core-wasm/vitest.config.ts b/packages/core-wasm/vitest.config.ts index f6374039..cfd8f913 100644 --- a/packages/core-wasm/vitest.config.ts +++ b/packages/core-wasm/vitest.config.ts @@ -5,5 +5,6 @@ export default defineConfig({ environment: 'node', globals: true, include: ['tests/**/*.test.ts'], + globalSetup: ['tests/global-setup.ts'], }, }) diff --git a/packages/domain/tests/r2-characterisation.test.ts b/packages/domain/tests/r2-characterisation.test.ts new file mode 100644 index 00000000..aefbeef3 --- /dev/null +++ b/packages/domain/tests/r2-characterisation.test.ts @@ -0,0 +1,1302 @@ +/** + * R2 freeze, part b (R2 plan §5 "Oracles"): the behaviour of the TypeScript report and + * archive functions on the inputs no suite pins (JavaScript truthiness, numeric literals, + * prototype keys, lone surrogates, the envelope decision table, rebase labels, snapshot + * caps and depth), and the accept / refuse verdict of the Zod schemas on hostile inputs. + * `MAKE_R2_ORACLES=1` writes `crates/core/tests/oracles/{characterisation,verdicts}.json` + * from these functions; otherwise the committed files are asserted against them, so the Rust + * port is checked against what the TypeScript really did. + */ +import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' +import type { z } from 'zod' +import { + BrandingSchema, + ENVELOPE_FORMAT, + ENVELOPE_VERSION, + PdfLabelSetSchema, + ReferenceSchema, + ReportArchiveEnvelopeSchema, + ReportMigrationMapSchema, + ReportSchema, + ReportV2Schema, + SheetSnapshotSchema, + SnapshotError, + UnsupportedReportVersionError, + assertSnapshot, + buildSheetIndex, + buildSheetSnapshot, + createEmptySheetDocument, + readArchiveDocument, + readReportDocument, + rebaseReportOnSheet, + validateSheetDocument, + type AnatomicalSheetDocument, + type Report, + type SheetRef, + type SnapshotSource, +} from '../src' +import { sampleBranding, sampleLabels } from './archive.branding-labels.test' +import { HORSE_MAIN_ASSET_ID, horseSlice } from './fixtures/horse-slice' +import full from './fixtures/report-v2.full.json' +import minimal from './fixtures/report-v2.minimal.json' + +const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../../..') +const OUT = resolve(ROOT, 'crates/core/tests/oracles') +const MAKE = process.env.MAKE_R2_ORACLES === '1' +/** A backslash, so no escape sequence is typed literally in this file. */ +const BS = String.fromCharCode(92) +const LONE = `${BS}ud800` + +const SHA = 'a'.repeat(64) +const SHA_B = 'b'.repeat(64) +const REF_A: SheetRef = { + sheetId: 'sheet-1', + versionId: null, + documentSha256: SHA, +} +const REF_B: SheetRef = { + sheetId: 'sheet-1', + versionId: 'v2', + documentSha256: SHA_B, +} +const SVG = '' + +type Json = unknown +const text = (value: Json) => JSON.stringify(value) +const clone = (value: T): T => JSON.parse(JSON.stringify(value)) as T + +// --------------------------------------------------------------------------- +// Inputs shared with the Rust side (as texts, so both sides parse the same bytes) + +const TEST_MAP = { + schema_version: 1, + sheet: REF_A, + main_view_id: 'main', + views: { head: 'head' }, + annotations: { + 'point-mpbwyyc9': { + id: 'c7-t1', + name: { + fr: 'Charnière C7-T1 (cervico-thoracique)', + en: 'C7-T1 (Cervicothoracic)', + }, + }, + 'point-mpbwtst0': { + id: 'hip', + name: { fr: 'Hanche (coxo-fémorale)', en: 'Hip joint' }, + }, + 'zone-mpbx5hx2': { + id: 'cervical', + name: { fr: 'Vertèbres cervicales', en: '' }, + }, + 'point-mpbyo7zq': { id: 'atm', name: { fr: 'ATM', en: 'TMJ' } }, + }, + finding_paths: { + 'c7-t1/c7-t1-dysfunctions/segmental/fixation': + 'c7-t1/c7-t1-dysfunctions/segmental/fixation', + 'hip/hip-dysfunctions/articular/restriction-flexion': + 'hip/hip-dysfunctions/articular/restriction-flexion', + 'cervical/cervical-observations/stumbling-proprioceptive': + 'cervical/cervical-consultation-reasons/stumbling-proprioceptive', + 'atm/atm-observations/headshaking': null, + 'odd/no-slash': 'zone-only', + 'odd/empty': '', + 'odd/double': 'zone//leaf', + }, +} +const PROTO_MAP_TEXT = text(TEST_MAP) + .replace('"views":{', '"views":{"__proto__":"polluted-view",') + .replace( + '"annotations":{', + '"annotations":{"__proto__":{"id":"polluted","name":{"fr":"x","en":"x"}},', + ) +const MAPS: Record = { + test: text(TEST_MAP), + proto: PROTO_MAP_TEXT, +} + +function sliceB(): AnatomicalSheetDocument { + const doc = horseSlice() + doc.annotations = doc.annotations.filter( + (a) => a.id !== 'atm' && a.id !== 'head-trigger', + ) + const hip = doc.finding_zones.find((z) => z.id === 'hip')! + hip.categories[0]!.children = hip.categories[0]!.children.filter( + (n) => n.id !== 'articular', + ) + return doc +} + +const DOCUMENTS = { slice: horseSlice(), sliceB: sliceB() } +type SheetName = keyof typeof DOCUMENTS +const SHEET_REFS: Record = { slice: REF_A, sliceB: REF_B } + +/** A sheet as the Rust side loads it (the bundled payload shape) and as TS indexes it. */ +function bundle( + name: SheetName, + assets: Record, + hashes: Record, +) { + const ref = SHEET_REFS[name] + return { + status: 'draft', + ref: { + sheet_id: ref.sheetId, + version_id: ref.versionId, + document_sha256: ref.documentSha256, + schema_version: 2, + species_id: 'equine', + }, + document: DOCUMENTS[name], + migrationMap: TEST_MAP, + assets, + assetHashes: hashes, + } +} + +const SHEETS = { + slice: bundle( + 'slice', + { [HORSE_MAIN_ASSET_ID]: SVG }, + { [HORSE_MAIN_ASSET_ID]: 'c'.repeat(64) }, + ), + sliceB: bundle('sliceB', { [HORSE_MAIN_ASSET_ID]: SVG }, {}), + sliceNoHash: bundle('slice', { [HORSE_MAIN_ASSET_ID]: SVG }, {}), + sliceNoSvg: bundle('slice', {}, {}), +} +type LoadedName = keyof typeof SHEETS + +function source(name: LoadedName): SnapshotSource { + const b = SHEETS[name] + return { + status: 'draft', + ref: { + sheetId: b.ref.sheet_id, + versionId: b.ref.version_id, + documentSha256: b.ref.document_sha256, + }, + speciesId: b.ref.species_id, + schemaVersion: b.ref.schema_version, + document: b.document, + assets: b.assets, + assetHashes: b.assetHashes, + } +} + +function reportOn( + ref: SheetRef, + observations: Report['observations'] = [], +): Report { + return ReportSchema.parse({ + version: 3, + id: 'r1', + createdAt: '2026-10-10T10:00:00Z', + date: '2026-10-10', + practitioner: { name: 'Dr. Dupont' }, + animal: { speciesId: 'equine', name: 'Mistral' }, + owner: { name: 'Jean Martin' }, + sheet: ref, + observations, + conclusion: 'c', + recommendations: 'r', + }) +} + +/** The rebase suite's report on revision A, plus label cases for `??=`. */ +function rebaseReport(ref: SheetRef): Report { + return reportOn(ref, [ + { + id: 'obs-1', + zones: [ + { + annotationId: 'hip', + viewId: 'view-main', + side: 'left', + labelFrSnapshot: 'Hanche', + labelEnSnapshot: 'Hip', + }, + { annotationId: 'atm', viewId: 'view-head' }, + { annotationId: 'head-trigger', viewId: 'view-main' }, + { annotationId: 'hip', viewId: 'ghost-view', labelFrSnapshot: 'Gardé' }, + { + annotationId: 'atm', + viewId: 'view-head', + labelFrSnapshot: '', + side: 'right', + }, + { + annotationId: 'gone', + viewId: 'view-main', + labelFrSnapshot: 'Ancien', + unresolved: true, + }, + { annotationId: 'nowhere', viewId: 'view-main' }, + ], + findings: [ + { + findingZoneId: 'hip', + path: ['hip-dysfunctions', 'articular', 'restriction-flexion'], + labelFrSnapshot: 'Restriction en flexion', + labelEnSnapshot: 'Flexion restriction', + }, + { + findingZoneId: 'cervical', + path: ['cervical-observations', 'stumbling-proprioceptive'], + labelFrSnapshot: 'Trébuchements', + labelEnSnapshot: 'Stumbling', + requiresVetReferral: true, + }, + { + findingZoneId: 'atm', + path: ['atm-observations', 'headshaking'], + labelFrSnapshot: 'Headshaking', + labelEnSnapshot: 'Headshaking', + unresolved: true, + }, + ], + freeTextFindings: ['note'], + severity: 'moderate', + comment: '', + }, + ]) +} + +/** A report on the slice whose findings exercise the snapshot pruning. */ +function snapshotReport(): Report { + return reportOn(REF_A, [ + { + id: 'obs-1', + zones: [{ annotationId: 'hip', viewId: 'view-main' }], + findings: [ + { + findingZoneId: 'hip', + path: ['hip-dysfunctions', 'articular', 'restriction-flexion'], + labelFrSnapshot: 'R', + labelEnSnapshot: 'R', + }, + { + findingZoneId: 'hip', + path: ['hip-dysfunctions', 'articular', 'ghost-leaf'], + labelFrSnapshot: 'G', + labelEnSnapshot: 'G', + unresolved: true, + }, + { + findingZoneId: 'hip', + path: ['hip-dysfunctions'], + labelFrSnapshot: 'C', + labelEnSnapshot: 'C', + }, + { + findingZoneId: 'nowhere', + path: ['x'], + labelFrSnapshot: 'X', + labelEnSnapshot: 'X', + }, + ], + freeTextFindings: [], + comment: '', + }, + ]) +} + +// --------------------------------------------------------------------------- +// Characterisation cases + +interface Case { + name: string + fn: + | 'readReport' + | 'readArchive' + | 'rebase' + | 'assertSnapshot' + | 'buildSnapshot' + input: string + map?: string + sheet?: LoadedName + archived?: string | null + output?: Json + error?: { kind: string; found?: number | null } + /** The TS result keeps a lone surrogate; Rust refuses the text (`lone_surrogate`, L1). */ + l1?: true + /** The outcome depends on the sheet integrity rules (fork A's validate.rs). */ + needsRules?: true +} + +function errorOf(error: unknown): Case['error'] { + if (error instanceof UnsupportedReportVersionError) { + return { kind: 'unsupported_version', found: error.foundVersion } + } + if (error instanceof SnapshotError) return { kind: error.reason } + return { kind: 'invalid' } +} + +function run(c: Case): Case { + c = { ...c, name: `${c.fn}: ${c.name}` } + try { + const output = clone(compute(c)) + return { ...c, output } + } catch (error) { + return { ...c, error: errorOf(error) } + } +} + +function compute(c: Case): Json { + const map = ReportMigrationMapSchema.parse(JSON.parse(MAPS[c.map ?? 'test']!)) + const input: unknown = JSON.parse(c.input) + switch (c.fn) { + case 'readReport': + return readReportDocument(input, map) + case 'readArchive': + return readArchiveDocument(input, map) + case 'rebase': { + const archived = c.archived + ? assertSnapshot(JSON.parse(c.archived)) + : null + const index = buildSheetIndex(source(c.sheet!)) + return rebaseReportOnSheet(ReportSchema.parse(input), index, archived) + } + case 'assertSnapshot': + return assertSnapshot(input) + case 'buildSnapshot': + return buildSheetSnapshot(source(c.sheet!), ReportSchema.parse(input)) + } +} + +/** Whether a snapshot inside the input fails the integrity rules (Rust stub until merge). */ +function needsRules(c: Case): boolean { + const input = JSON.parse(c.input) as Record | null + const candidate = c.fn === 'readArchive' ? input?.sheetSnapshot : input + const parsed = SheetSnapshotSchema.safeParse(candidate) + return ( + parsed.success && + validateSheetDocument(parsed.data.document).some( + (i) => i.severity === 'error', + ) + ) +} + +const v2Minimal = () => ReportV2Schema.parse(minimal) +const v2With = (observations: unknown[]) => ({ + ...clone(minimal), + observations, +}) +const v2Obs = ( + zones: unknown[], + findings: unknown[] = [], + extra: object = {}, +) => ({ + id: 'o', + zones, + findings, + freeTextFindings: [], + comment: '', + ...extra, +}) +const v2Finding = (zoneId: string, path: string[], extra: object = {}) => ({ + zoneId, + path, + labelFrSnapshot: 'F', + labelEnSnapshot: 'F', + ...extra, +}) +const v3 = () => reportOn(REF_A) +const withVersion = (value: unknown, literal: string) => + text(value).replace(/"version":\d+/, `"version":${literal}`) + +function readReportCases(): Case[] { + const rr = (name: string, input: string, map?: string): Case => ({ + name, + fn: 'readReport', + input, + map, + }) + const zone = (z: object) => text(v2With([v2Obs([z])])) + return [ + rr('v2 full', text(full)), + rr('v2 minimal', text(minimal)), + rr( + 'detailSourceId empty string → main view', + zone({ boneId: 'point-mpbwtst0', detailSourceId: '' }), + ), + rr( + 'detailSourceId mapped', + zone({ boneId: 'point-mpbyo7zq', detailSourceId: 'head' }), + ), + rr( + 'detailSourceId unknown key kept as view id', + zone({ boneId: 'point-mpbyo7zq', detailSourceId: 'neck' }), + ), + rr( + 'prototype keys as legacy ids', + zone({ boneId: 'constructor', detailSourceId: '__proto__' }), + ), + rr( + '__proto__ entries of the map are dropped', + zone({ boneId: '__proto__', detailSourceId: '__proto__' }), + 'proto', + ), + rr( + 'empty legacy name kept as an empty snapshot', + zone({ boneId: 'zone-mpbx5hx2', vertebrae: [{ region: 'C', index: 3 }] }), + ), + rr('vertebrae [] kept', zone({ boneId: 'zone-mpbx5hx2', vertebrae: [] })), + rr('side copied', zone({ boneId: 'point-mpbwtst0', side: 'left' })), + rr('unknown legacy zone flagged', zone({ boneId: 'point-unknown' })), + rr( + 'requiresVetReferral false dropped, true kept, side kept', + text( + v2With([ + v2Obs( + [], + [ + v2Finding( + 'hip', + ['hip-dysfunctions', 'articular', 'restriction-flexion'], + { requiresVetReferral: false }, + ), + v2Finding( + 'c7-t1', + ['c7-t1-dysfunctions', 'segmental', 'fixation'], + { requiresVetReferral: true, side: 'right' }, + ), + v2Finding('atm', ['atm-observations', 'headshaking']), + v2Finding('nowhere', ['x']), + v2Finding('constructor', ['__proto__']), + ], + ), + ]), + ), + ), + rr( + 'mapped path without a slash fails the read', + text(v2With([v2Obs([], [v2Finding('odd', ['no-slash'])])])), + ), + rr( + 'mapped empty path fails the read', + text(v2With([v2Obs([], [v2Finding('odd', ['empty'])])])), + ), + rr( + 'mapped path with an empty segment fails the read', + text(v2With([v2Obs([], [v2Finding('odd', ['double'])])])), + ), + ...(['légère', 'modérée', 'sévère'] as const).map((severity) => + rr(`severity ${severity}`, text(v2With([v2Obs([], [], { severity })]))), + ), + rr( + 'next appointment date', + text({ + ...clone(minimal), + nextAppointment: { kind: 'date', date: '2026-11-01', extra: 1 }, + }), + ), + rr( + 'next appointment period', + text({ + ...clone(minimal), + nextAppointment: { kind: 'period', text: '3 sem.' }, + }), + ), + rr('v2 version written 2.0', withVersion(v2Minimal(), '2.0')), + rr('v3 version written 3.0', withVersion(v3(), '3.0')), + rr('v3 version written 3e0', withVersion(v3(), '3e0')), + rr('v3 version 3.5', withVersion(v3(), '3.5')), + rr('version as a string', text({ ...v3(), version: '3' })), + rr('version 4', text({ ...v3(), version: 4 })), + rr('version 1', text({ ...clone(minimal), version: 1 })), + rr('no version', text({ hello: 'world' })), + rr('an array', text([v3()])), + rr('null', 'null'), + rr('a number', '42'), + rr( + 'v3 unknown keys stripped', + text({ ...v3(), extra: 1, practitioner: { name: 'P', x: 2 } }), + ), + rr( + 'v3 optional field null refused', + text({ ...v3(), nextAppointment: null }), + ), + rr( + 'v3 vertebra index 2.0 and 1e20', + text( + reportOn(REF_A, [ + { + id: 'o', + zones: [ + { + annotationId: 'a', + viewId: 'v', + vertebrae: [ + { region: 'C', index: 2 }, + { region: 'T', index: 1e20 }, + ], + }, + ], + findings: [], + freeTextFindings: [], + comment: '', + }, + ]), + ).replace('"index":2', '"index":2.0'), + ), + rr( + 'v3 unresolved false refused', + text( + reportOn(REF_A, [ + { + id: 'o', + zones: [{ annotationId: 'a', viewId: 'v', unresolved: true }], + findings: [], + freeTextFindings: [], + comment: '', + }, + ]), + ).replace('"unresolved":true', '"unresolved":false'), + ), + rr( + 'v3 localAnnotations entry refused', + text({ ...v3(), localAnnotations: [{ x: 1 }] }), + ), + { + ...rr( + 'lone surrogate in a v3 conclusion', + text({ ...v3(), conclusion: 'a' }).replace( + '"conclusion":"a"', + `"conclusion":"a${LONE}b"`, + ), + ), + l1: true, + }, + { + ...rr( + 'lone surrogate in a v2 comment', + text(v2With([v2Obs([], [], { comment: 'x' })])).replace( + '"comment":"x"', + `"comment":"${LONE}"`, + ), + ), + l1: true, + }, + ] +} + +function envelopeOn( + report: unknown, + patch: Record = {}, +): Record { + return { + format: ENVELOPE_FORMAT, + envelopeVersion: ENVELOPE_VERSION, + exportedAt: '2026-10-11T10:00:00.000Z', + locale: 'fr', + report, + sheetSnapshot: clone(buildSheetSnapshot(source('slice'), snapshotReport())), + branding: sampleBranding(), + labels: { fr: sampleLabels(), en: sampleLabels() }, + ...patch, + } +} + +function readArchiveCases(): Case[] { + const ra = (name: string, input: string): Case => ({ + name, + fn: 'readArchive', + input, + }) + const report = snapshotReport() + const env = (patch: Record = {}) => envelopeOn(report, patch) + const snap = () => clone(buildSheetSnapshot(source('slice'), report)) + const brokenRule = snap() + brokenRule.document.finding_zones = brokenRule.document.finding_zones.filter( + (z) => z.id !== 'atm', + ) + const label513 = snap() + label513.document.name.fr = 'x'.repeat(513) + return [ + ra('bare v3', text(report)), + ra('bare v2', text(full)), + ra('envelope v1 accepted', text(env())), + ra( + 'envelopeVersion written 1.0', + text(env()).replace('"envelopeVersion":1', '"envelopeVersion":1.0'), + ), + ra( + 'unknown envelope version keeps the report origin', + text(env({ envelopeVersion: 2 })), + ), + ra( + 'envelopeVersion as a string is no envelope', + text(env({ envelopeVersion: '1' })), + ), + ra( + 'wrapper: javascript site URL', + text( + env({ + branding: { ...sampleBranding(), siteUrl: 'javascript:alert(1)' }, + }), + ), + ), + ra( + 'wrapper: labels without en', + text(env({ labels: { fr: sampleLabels() } })), + ), + ra('wrapper: locale de', text(env({ locale: 'de' }))), + ra('wrapper: other format', text(env({ format: 'other' }))), + ra( + 'wrapper: unknown metadata key ignored', + text(env({ futureField: { anything: true } })), + ), + ra( + 'wrapper: __proto__ metadata key ignored', + text(env()).replace('"format"', '"__proto__":{"polluted":true},"format"'), + ), + ra( + 'snapshot: unknown key', + text(env({ sheetSnapshot: { ...snap(), extra: 1 } })), + ), + ra('snapshot: missing', text(env({ sheetSnapshot: undefined }))), + ra('snapshot: label over the cap', text(env({ sheetSnapshot: label513 }))), + ra( + 'snapshot: no asset (integrity)', + text(env({ sheetSnapshot: { ...snap(), assets: [] } })), + ), + ra( + 'snapshot: a sheet rule fails (integrity)', + text(env({ sheetSnapshot: brokenRule })), + ), + ra( + 'snapshot: another document hash', + text( + env({ + sheetSnapshot: { + ...snap(), + ref: { ...snap().ref, documentSha256: 'f'.repeat(64) }, + }, + }), + ), + ), + ra( + 'snapshot: another sheet id', + text( + env({ + sheetSnapshot: { + ...snap(), + ref: { ...snap().ref, sheetId: 'other' }, + }, + }), + ), + ), + ra('v2 report inside an envelope', text(envelopeOn(full))), + ra( + 'unknown wrapped report version', + text(envelopeOn({ ...report, version: 4 })), + ), + ra('envelope without report', text(envelopeOn(undefined))), + ra('null', 'null'), + ra('a string', '"report"'), + ra('an array', text([report])), + ] +} + +function rebaseCases(): Case[] { + const archivedA = text( + buildSheetSnapshot(source('slice'), rebaseReport(REF_A)), + ) + const rb = ( + name: string, + report: Report, + archived: string | null, + sheet: LoadedName = 'sliceB', + ): Case => ({ + name, + fn: 'rebase', + input: text(report), + sheet, + archived, + }) + return [ + rb('same sheet: untouched', rebaseReport(REF_B), archivedA), + rb('other sheet with archived labels', rebaseReport(REF_A), archivedA), + rb('other sheet without archive', rebaseReport(REF_A), null), + rb( + 'other sheet onto the slice itself', + rebaseReport({ ...REF_A, documentSha256: 'e'.repeat(64) }), + archivedA, + 'slice', + ), + ] +} + +function snapshotDepth(depth: number) { + const snap = clone(buildSheetSnapshot(source('slice'), snapshotReport())) + let node: Record = { + id: 'leaf', + name: { fr: 'l', en: 'l' }, + description: {}, + requires_vet_referral: false, + reference_ids: [], + review_status: 'inherited', + children: [], + } + for (let level = depth - 2; level >= 1; level -= 1) { + node = { ...node, id: `n${level}`, children: [node] } + } + snap.document.finding_zones[0]!.categories[0]!.children = [node as never] + return snap +} + +function snapshotCases(): Case[] { + const as = (name: string, input: string): Case => ({ + name, + fn: 'assertSnapshot', + input, + }) + const bs = (name: string, sheet: LoadedName, report: Report): Case => ({ + name, + fn: 'buildSnapshot', + input: text(report), + sheet, + }) + const snap = () => + clone(buildSheetSnapshot(source('slice'), snapshotReport())) + const astral = snap() + astral.document.name.fr = '😀'.repeat(256) + const astralOver = snap() + astralOver.document.name.en = `x${'😀'.repeat(256)}` + const otherAsset = snap() + otherAsset.assets[0]!.svgAssetId = '00000000-0000-4000-8000-000000000009' + return [ + bs('pruned trees, unresolved and unknown paths', 'slice', snapshotReport()), + bs('no asset hash', 'sliceNoHash', snapshotReport()), + bs('no asset text', 'sliceNoSvg', snapshotReport()), + bs('no finding', 'slice', reportOn(REF_A)), + as('the slice snapshot', text(snap())), + as('depth 8 accepted', text(snapshotDepth(8))), + as('depth 9 refused before the shape', text(snapshotDepth(9))), + as( + 'garbage under a deep tree is caps first', + text({ + garbage: true, + document: { + finding_zones: [ + { + categories: [ + snapshotDepth(9).document.finding_zones[0]!.categories[0], + ], + }, + ], + }, + }), + ), + as( + 'a shallow garbage tree is schema', + text({ document: { finding_zones: [{ categories: [{ id: 'c' }] }] } }), + ), + as( + 'finding_zones not an array', + text({ document: { finding_zones: 'x' } }), + ), + as('unknown key', text({ ...snap(), extra: 1 })), + as( + '__proto__ key', + text(snap()).replace('"status"', '"__proto__":{"polluted":1},"status"'), + ), + as('null', 'null'), + as('labels of 256 astral characters (512 units)', text(astral)), + as('a label of 513 units', text(astralOver)), + as('no asset', text({ ...snap(), assets: [] })), + as('a view reaching another asset', text(otherAsset)), + as( + 'schemaVersion written 2.0', + text(snap()).replace('"schemaVersion":2', '"schemaVersion":2.0'), + ), + ] +} + +function characterisation(): Case[] { + return [ + ...readReportCases(), + ...readArchiveCases(), + ...rebaseCases(), + ...snapshotCases(), + ].map((c) => { + const done = run(c) + return needsRules(c) ? { ...done, needsRules: true } : done + }) +} + +// --------------------------------------------------------------------------- +// Verdicts of the Zod schemas + +interface Verdict { + schema: string + name: string + input: string + accepted: boolean +} + +const SCHEMAS: Record = { + Report: ReportSchema, + ReportV2: ReportV2Schema, + MigrationMap: ReportMigrationMapSchema, + Branding: BrandingSchema, + PdfLabelSet: PdfLabelSetSchema, + SheetSnapshot: SheetSnapshotSchema, + Envelope: ReportArchiveEnvelopeSchema, + Reference: ReferenceSchema, +} + +type Path = Array + +/** Every path to a value of `base`, skipping the subtrees `skip` names. */ +function paths( + value: unknown, + skip: (path: Path) => boolean, + prefix: Path = [], +): Path[] { + if (skip(prefix)) return [] + const own = prefix.length > 0 ? [prefix] : [] + if (Array.isArray(value)) { + return [ + ...own, + ...value.flatMap((item, i) => paths(item, skip, [...prefix, i])), + ] + } + if (value !== null && typeof value === 'object') { + return [ + ...own, + ...Object.entries(value).flatMap(([key, item]) => + paths(item, skip, [...prefix, key]), + ), + ] + } + return own +} + +function mutate( + base: unknown, + path: Path, + change: ( + parent: Record, + key: string | number, + ) => void, +) { + const copy = clone(base) as Record + let parent = copy + for (const key of path.slice(0, -1)) + parent = parent[key] as Record + change(parent, path.at(-1)!) + return copy +} + +function wrongType(value: unknown): unknown { + if (typeof value === 'string') return 1 + if (typeof value === 'number') return '1' + if (typeof value === 'boolean') return 'true' + if (Array.isArray(value)) return {} + return [] +} + +/** Generic mutations at every path: delete, null, wrong type, empty string, numeric edges, extra key. */ +function generic( + schema: string, + base: unknown, + skip: (path: Path) => boolean, +): Array> { + const out: Array> = [] + const add = (name: string, value: unknown) => + out.push({ schema, name, input: text(value) }) + add('base', base) + add('extra key at the root', { ...(base as object), zz: 1 }) + for (const path of paths(base, skip)) { + const at = path.join('.') + const value = path.reduce( + (v, k) => (v as Record)[k], + base, + ) + if (typeof path.at(-1) === 'string') + add( + `${at}: deleted`, + mutate(base, path, (p, k) => delete p[k]), + ) + add( + `${at}: null`, + mutate(base, path, (p, k) => (p[k] = null)), + ) + add( + `${at}: wrong type`, + mutate(base, path, (p, k) => (p[k] = wrongType(value))), + ) + if (typeof value === 'string') + add( + `${at}: empty`, + mutate(base, path, (p, k) => (p[k] = '')), + ) + if (typeof value === 'number') { + for (const n of [2.5, -1, 0, 1e20]) + add( + `${at}: ${n}`, + mutate(base, path, (p, k) => (p[k] = n)), + ) + } + if (value !== null && typeof value === 'object' && !Array.isArray(value)) { + add( + `${at}: extra key`, + mutate(base, path, (p, k) => (p[k] = { ...(value as object), zz: 1 })), + ) + } + } + return out +} + +function verdictBases() { + const report = reportOn(REF_A, [ + { + id: 'o', + zones: [ + { + annotationId: 'a', + viewId: 'v', + side: 'left', + vertebrae: [{ region: 'C', index: 2 }], + labelFrSnapshot: 'A', + labelEnSnapshot: 'A', + unresolved: true, + }, + ], + findings: [ + { + findingZoneId: 'z', + path: ['a', 'b'], + labelFrSnapshot: 'F', + labelEnSnapshot: 'F', + requiresVetReferral: true, + side: 'right', + unresolved: true, + }, + ], + freeTextFindings: ['t'], + severity: 'mild', + comment: 'c', + }, + ]) + const withAppointment = { + ...report, + nextAppointment: { kind: 'date', date: '2026-11-01' }, + } + const v2 = { + ...clone(minimal), + observations: [ + { + id: 'o', + zones: [ + { + boneId: 'b', + detailSourceId: 'head', + vertebrae: [{ region: 'Cd', index: 1 }], + side: 'left', + }, + ], + findings: [ + v2Finding('z', ['a'], { requiresVetReferral: true, side: 'left' }), + ], + freeTextFindings: [], + severity: 'modérée', + comment: '', + }, + ], + nextAppointment: { kind: 'period', text: 'x' }, + } + const document = createEmptySheetDocument({ + species_id: 'equine', + name: { fr: 'C', en: 'H' }, + }) + const snapshot = { + status: 'published', + ref: { ...REF_A, versionId: 'v1', schemaVersion: 2, speciesId: 'equine' }, + document, + assets: [ + { svgAssetId: HORSE_MAIN_ASSET_ID, sha256: 'c'.repeat(64), svg: SVG }, + ], + } + const envelope = { + format: ENVELOPE_FORMAT, + envelopeVersion: ENVELOPE_VERSION, + exportedAt: '2026-10-11T10:00:00.000Z', + locale: 'en', + report: reportOn(REF_A), + sheetSnapshot: snapshot, + branding: sampleBranding(), + labels: { fr: sampleLabels(), en: sampleLabels() }, + } + const reference = { + id: 'atlas', + type: 'book', + citation: 'Atlas', + url: 'https://example.org/a', + doi: '10.1/x', + } + return { report: withAppointment, v2, snapshot, envelope, reference } +} + +function verdictInputs(): Array> { + const b = verdictBases() + const none = () => false + return [ + ...generic('Report', b.report, none), + ...generic('ReportV2', b.v2, none), + ...generic('MigrationMap', TEST_MAP, none), + ...generic('Branding', sampleBranding(), none), + // Every key behaves the same: one label key per locale stands for the 25. + ...generic( + 'PdfLabelSet', + { fr: sampleLabels(), en: sampleLabels() }, + (path) => path.length === 2 && path[1] !== 'pdf.empty', + ), + // The document's own sites belong to the sheet contract (fork A's verdicts). + ...generic( + 'SheetSnapshot', + b.snapshot, + (path) => path[0] === 'document' && path.length > 1, + ), + ...generic('Envelope', b.envelope, (path) => path.length > 1), + ...generic('Reference', b.reference, none), + ...specific(b), + ] +} + +function specific( + b: ReturnType, +): Array> { + const out: Array> = [] + const add = (schema: string, name: string, input: string) => + out.push({ schema, name, input }) + const report = text(b.report) + add('Report', 'version 3.0', report.replace('"version":3', '"version":3.0')) + add('Report', 'version 3e0', report.replace('"version":3', '"version":3e0')) + add( + 'Report', + 'vertebra index 2.0', + report.replace('"index":2', '"index":2.0'), + ) + add( + 'Report', + 'vertebra index 2e0', + report.replace('"index":2', '"index":2e0'), + ) + add( + 'Report', + 'lone surrogate in a comment', + report.replace('"comment":"c"', `"comment":"${LONE}"`), + ) + add( + 'ReportV2', + 'version 2.0', + text(b.v2).replace('"version":2', '"version":2.0'), + ) + add( + 'ReportV2', + 'unknown legacy region', + text(b.v2).replace('"region":"Cd"', '"region":"X"'), + ) + add( + 'ReportV2', + 'English severity', + text(b.v2).replace('"modérée"', '"moderate"'), + ) + add( + 'SheetSnapshot', + 'schemaVersion 2.0', + text(b.snapshot).replace('"schemaVersion":2', '"schemaVersion":2.0'), + ) + add( + 'SheetSnapshot', + 'upper-case uuid', + text(b.snapshot).replace( + HORSE_MAIN_ASSET_ID, + HORSE_MAIN_ASSET_ID.toUpperCase(), + ), + ) + add( + 'SheetSnapshot', + 'upper-case sha256', + text(b.snapshot).replace('c'.repeat(64), 'C'.repeat(64)), + ) + add( + 'SheetSnapshot', + 'five assets', + text({ ...b.snapshot, assets: Array(5).fill(b.snapshot.assets[0]) }), + ) + add( + 'SheetSnapshot', + 'status other', + text({ ...b.snapshot, status: 'archived' }), + ) + add( + 'Envelope', + 'envelopeVersion 1.0', + text(b.envelope).replace('"envelopeVersion":1', '"envelopeVersion":1.0'), + ) + add( + 'Envelope', + 'envelopeVersion 2', + text({ ...b.envelope, envelopeVersion: 2 }), + ) + const labels = (value: string) => + text({ + fr: { ...sampleLabels(), 'pdf.subject': value }, + en: sampleLabels(), + }) + add('PdfLabelSet', '256 characters', labels('x'.repeat(256))) + add('PdfLabelSet', '257 characters', labels('x'.repeat(257))) + add( + 'PdfLabelSet', + '128 astral characters (256 units)', + labels('😀'.repeat(128)), + ) + add( + 'PdfLabelSet', + '128 astral characters and one more unit', + labels(`x${'😀'.repeat(128)}`), + ) + add( + 'PdfLabelSet', + 'extra locale', + text({ fr: sampleLabels(), en: sampleLabels(), de: sampleLabels() }), + ) + const credit = (fallbackText: string) => + text({ + ...sampleBranding(), + poweredBy: { ...sampleBranding().poweredBy!, fallbackText }, + }) + add('Branding', 'fallback 128', credit('x'.repeat(128))) + add('Branding', 'fallback 129', credit('x'.repeat(129))) + add('Branding', 'fallback 64 astral', credit('😀'.repeat(64))) + add('Branding', 'fallback 64 astral + 1', credit(`x${'😀'.repeat(64)}`)) + add( + 'Branding', + 'base64 with three =', + text({ + ...sampleBranding(), + headerLogo: { kind: 'png', base64: 'QUJD===' }, + }), + ) + add( + 'Branding', + 'empty base64', + text({ ...sampleBranding(), headerLogo: { kind: 'png', base64: '' } }), + ) + add( + 'Branding', + 'svg logo with extra key', + text({ ...sampleBranding(), footerLogo: { kind: 'svg', svg: SVG, zz: 1 } }), + ) + add( + 'Branding', + 'image kind gif', + text({ ...sampleBranding(), footerLogo: { kind: 'gif', svg: SVG } }), + ) + for (const url of [ + 'https://münchen.de/', + 'HTTP://a.example/', + 'https://a.example:99999/', + 'https://[::1]/', + 'https://%zz/', + 'http://a.example/%', + 'https://a.example/a?b=c&d=e#f', + 'https://', + 'http://a b/', + 'https://a.example/(x)', + 'https://xn--mnchen-3ya.de/', + 'https://user:pass@a.example/', + 'https://a..example/', + 'https://1.2.3.4/', + 'https://999.2.3.4/', + ]) { + add( + 'Branding', + `site URL ${url}`, + text({ ...sampleBranding(), siteUrl: url }), + ) + add('Reference', `url ${url}`, text({ ...b.reference, url })) + } + for (const url of [ + 'https://例え.テスト/', + 'Https://a.example/', + 'ftp://a.example/', + 'javascript:alert(1)', + 'mailto:a@b.c', + 'https:a.example', + 'https:/a.example', + ]) { + add('Reference', `url ${url}`, text({ ...b.reference, url })) + } + add('Reference', 'doi empty', text({ ...b.reference, doi: '' })) + add('Reference', 'type other', text({ ...b.reference, type: 'blog' })) + add( + 'Reference', + 'url and doi absent (defaults)', + text({ id: 'atlas', type: 'web', citation: 'C' }), + ) + add( + 'MigrationMap', + 'schema_version 1.0', + text(TEST_MAP).replace('"schema_version":1', '"schema_version":1.0'), + ) + add( + 'MigrationMap', + 'empty view id', + text({ ...TEST_MAP, views: { head: '' } }), + ) + add( + 'MigrationMap', + 'views as an array', + text({ ...TEST_MAP, views: ['head'] }), + ) + add('MigrationMap', '__proto__ entries', PROTO_MAP_TEXT) + return out +} + +function verdicts(): Verdict[] { + return verdictInputs().map((v) => { + const parsed = SCHEMAS[v.schema]!.safeParse(JSON.parse(v.input)) + return { ...v, accepted: parsed.success } + }) +} + +// --------------------------------------------------------------------------- + +/** One JSON line per entry: compact, still diffable case by case. */ +function lines(list: readonly unknown[]): string { + return `[\n${list.map((item) => JSON.stringify(item)).join(',\n')}\n]` +} + +function freeze(name: string, content: string) { + const file = resolve(OUT, name) + if (MAKE) { + mkdirSync(OUT, { recursive: true }) + writeFileSync(file, content) + } + expect(readFileSync(file, 'utf8')).toBe(content) +} + +describe('R2 characterisation oracles (frozen from the TypeScript domain)', () => { + it('characterisation.json: report, archive, rebase and snapshot functions', () => { + const cases = characterisation() + expect(new Set(cases.map((c) => c.name)).size).toBe(cases.length) + freeze( + 'characterisation.json', + `{"maps":${JSON.stringify(MAPS)},\n"sheets":${JSON.stringify(SHEETS)},\n"cases":${lines(cases)}}\n`, + ) + }) + + it('verdicts.json: accept / refuse of the Zod schemas on hostile inputs', () => { + const list = verdicts() + expect(list.some((v) => v.accepted)).toBe(true) + expect(list.some((v) => !v.accepted)).toBe(true) + freeze('verdicts.json', `${lines(list)}\n`) + }) +}) diff --git a/packages/domain/tests/r2-conformance.test.ts b/packages/domain/tests/r2-conformance.test.ts new file mode 100644 index 00000000..21d9dcdf --- /dev/null +++ b/packages/domain/tests/r2-conformance.test.ts @@ -0,0 +1,359 @@ +/** + * R2 conformance fixtures (RUST_ARCHITECTURE_REVIEW III.4): one mutated horse slice per + * rule family, with what the TypeScript rules report (code, severity, path, message) frozen + * from `validateSheetDocument`, and the codes the SQL re-check (`private.sheet_document_issues`) + * returns, sorted. Written under crates/core/tests/conformance with `MAKE_R2_ORACLES=1`, + * asserted otherwise; cargo checks the Rust rules against them and generates the pgTAP file + * supabase/tests/011_sheet_conformance.sql from them. + */ +import { readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' +import { + AnatomicalSheetDocumentSchema, + validateSheetDocument, + type AnatomicalSheetDocument, + type Annotation, + type SheetView, +} from '../src' +import { HORSE_MAIN_ASSET_ID, horseSlice } from './fixtures/horse-slice' + +const DIR = resolve( + dirname(fileURLToPath(import.meta.url)), + '../../../crates/core/tests/conformance', +) +const MAKE = process.env.MAKE_R2_ORACLES === '1' + +type Doc = AnatomicalSheetDocument +type Raw = Record + +interface Case { + name: string + description: string + /** Mutation of the parsed horse slice (shape-valid documents). */ + mutate?: (doc: Doc) => void + /** Mutation of the JSON form, for documents the shape tier refuses. */ + raw?: (doc: Raw) => void + /** Codes `private.sheet_document_issues` returns, sorted (collate "C"). */ + sql: string[] +} + +function point(id: string, fields: Partial = {}): Annotation { + return { + id, + kind: 'point', + view_id: 'view-main', + category_id: 'articulations', + laterality: 'bilateral', + geometry: null, + review_status: 'inherited', + color: null, + name: { fr: id, en: id }, + finding_zone_id: 'hip', + vertebral_region_code: null, + ...fields, + } as Annotation +} + +function trigger(id: string, viewId: string, opensViewId: string): Annotation { + return { + id, + kind: 'detail_trigger', + view_id: viewId, + category_id: 'cadrans-du-crane', + laterality: 'unpaired', + geometry: null, + review_status: 'inherited', + color: null, + name: null, + opens_view_id: opensViewId, + } +} + +function detailView(id: string, parentId: string): SheetView { + return { + id, + kind: 'detail', + name: { fr: id, en: id }, + parent_view_id: parentId, + svg_asset_id: HORSE_MAIN_ASSET_ID, + view_box: null, + } +} + +function observable(doc: Doc, index: number) { + const annotation = doc.annotations[index] + if (!annotation || annotation.kind === 'detail_trigger') + throw new Error('fixture') + return annotation +} + +const CASES: Case[] = [ + { name: 'clean', description: 'the horse slice: no issue', sql: [] }, + { + name: 'view-main-count', + description: 'two main views', + mutate: (d) => d.views.push({ ...d.views[0]!, id: 'view-alt' }), + sql: ['view.main.count'], + }, + { + name: 'view-id-duplicate', + description: 'a detail view listed twice', + mutate: (d) => d.views.push(structuredClone(d.views[1]!)), + sql: ['view.id.duplicate'], + }, + { + name: 'view-parent-missing', + description: 'a detail view whose parent does not exist', + mutate: (d) => d.views.push(detailView('view-orphan', 'view-ghost')), + sql: ['view.parent.missing'], + }, + { + name: 'view-parent-cycle', + description: + 'two detail views parent of each other (SQL has no cycle rule)', + mutate: (d) => { + d.views.push( + detailView('view-a', 'view-b'), + detailView('view-b', 'view-a'), + ) + d.annotations.push(trigger('open-a', 'view-b', 'view-a')) + d.annotations.push(trigger('open-b', 'view-a', 'view-b')) + }, + sql: [], + }, + { + name: 'view-unreachable', + description: 'the head view without its trigger', + mutate: (d) => { + d.annotations = d.annotations.filter((a) => a.id !== 'head-trigger') + }, + sql: ['view.unreachable'], + }, + { + name: 'view-asset-missing-main', + description: 'the main view without an SVG asset', + mutate: (d) => { + d.views[0]!.svg_asset_id = null + }, + sql: ['view.asset.missing'], + }, + { + name: 'view-asset-missing-detail', + description: 'a detail view with neither an asset nor a view_box', + mutate: (d) => { + d.views[1]!.svg_asset_id = null + d.views[1]!.view_box = null + }, + sql: ['view.asset.missing'], + }, + { + name: 'annotation-id-duplicate', + description: 'an annotation id repeated on another view', + mutate: (d) => { + d.annotations.push({ + ...structuredClone(d.annotations[4]!), + view_id: 'view-main', + }) + }, + sql: ['annotation.id.duplicate'], + }, + { + name: 'annotation-view-missing', + description: 'an annotation on a view that does not exist', + mutate: (d) => + d.annotations.push(point('ghost', { view_id: 'view-ghost' })), + sql: ['annotation.view.missing'], + }, + { + name: 'annotation-category-missing', + description: 'an annotation in an undeclared category', + mutate: (d) => { + d.annotations[0]!.category_id = 'os' + }, + sql: ['annotation.category.missing'], + }, + { + name: 'annotation-opens-view-invalid', + description: + 'triggers opening their own view, the main view and an absent view', + mutate: (d) => { + d.annotations.push(trigger('loop', 'view-head', 'view-head')) + d.annotations.push(trigger('to-main', 'view-main', 'view-main')) + d.annotations.push(trigger('to-ghost', 'view-main', 'view-ghost')) + }, + sql: ['annotation.opens_view.invalid'], + }, + { + name: 'annotation-finding-zone-missing', + description: 'an annotation linked to an undeclared finding zone', + mutate: (d) => + d.annotations.push(point('stifle', { finding_zone_id: 'stifle' })), + sql: ['annotation.finding_zone.missing'], + }, + { + name: 'annotation-region-missing', + description: 'a spine annotation on an unconfigured region', + mutate: (d) => { + observable(d, 1).vertebral_region_code = 'Q' + }, + sql: ['annotation.region.missing'], + }, + { + name: 'annotation-no-findings', + description: + 'an annotation linked to no finding zone (warning, not mirrored by SQL)', + mutate: (d) => + d.annotations.push(point('mandible', { finding_zone_id: null })), + sql: [], + }, + { + name: 'region-code-duplicate', + description: 'a vertebral region listed twice', + mutate: (d) => { + const regions = d.vertebral_config.regions + regions.push(structuredClone(regions[0]!)) + }, + sql: ['region.code.duplicate'], + }, + { + name: 'category-id-duplicate', + description: 'an annotation category listed twice', + mutate: (d) => d.categories.push(structuredClone(d.categories[0]!)), + sql: ['category.id.duplicate'], + }, + { + name: 'finding-zone-id-duplicate', + description: 'a finding zone listed twice', + mutate: (d) => d.finding_zones.push(structuredClone(d.finding_zones[0]!)), + sql: ['finding_zone.id.duplicate'], + }, + { + name: 'finding-id-duplicate', + description: + 'sibling finding ids repeated at two depths (not mirrored by SQL)', + mutate: (d) => { + const categories = d.finding_zones[0]!.categories + categories.push(structuredClone(categories[0]!)) + const articular = categories[0]!.children[0]! + articular.children.push(structuredClone(articular.children[0]!)) + }, + sql: [], + }, + { + name: 'reference-id-duplicate', + description: 'a reference declared twice', + mutate: (d) => d.references.push(structuredClone(d.references[0]!)), + sql: ['reference.id.duplicate'], + }, + { + name: 'finding-reference-missing', + description: 'undeclared citations on a category and on a nested node', + mutate: (d) => { + const hip = d.finding_zones[0]!.categories + hip[0]!.reference_ids = ['nav-2017'] + hip[0]!.children[0]!.children[0]!.reference_ids = ['legacy-catalog', 'x'] + }, + sql: ['finding.reference.missing'], + }, + { + name: 'region-count-range-invalid', + description: 'a usual vertebra count outside its documented range', + mutate: (d) => { + d.vertebral_config.regions[4]!.count_range = { min: 19, max: 21 } + }, + sql: ['region.count_range.invalid'], + }, + { + name: 'finding-zone-unreferenced', + description: + 'a finding zone no annotation points to (warning, not mirrored by SQL)', + mutate: (d) => + d.finding_zones.push({ + id: 'stifle', + name: { fr: 'Grasset', en: 'Stifle' }, + categories: [], + }), + sql: [], + }, + { + name: 'several-errors', + description: + 'errors of four families at once, duplicates of one code collapsed by SQL', + mutate: (d) => { + d.views[0]!.svg_asset_id = null + d.annotations[0]!.category_id = 'os' + d.annotations[2]!.category_id = 'os' + d.vertebral_config.regions[4]!.count_range = { min: 19, max: 21 } + }, + sql: [ + 'annotation.category.missing', + 'region.count_range.invalid', + 'view.asset.missing', + ], + }, + { + name: 'shape-references-not-array', + description: + 'a non-array references registry: the shape tier refuses it, SQL says document.shape', + raw: (d) => { + d.references = 'x' + }, + sql: ['document.shape'], + }, + { + name: 'shape-reference-url-scheme', + description: + 'a javascript: reference url: the shape tier refuses it, SQL says reference.url.scheme', + raw: (d) => { + const refs = d.references as Raw[] + refs[0]!.url = 'javascript:alert(1)' + }, + sql: ['reference.url.scheme'], + }, +] + +function fixtureOf(c: Case): unknown { + if (c.raw) { + const doc = structuredClone(horseSlice()) as unknown as Raw + c.raw(doc) + expect(AnatomicalSheetDocumentSchema.safeParse(doc).success).toBe(false) + return { + name: c.name, + description: c.description, + document: doc, + rust: { shape_error: true }, + sql: c.sql, + } + } + const doc = horseSlice() + c.mutate?.(doc) + expect(AnatomicalSheetDocumentSchema.safeParse(doc).success).toBe(true) + const issues = validateSheetDocument(doc) + return { + name: c.name, + description: c.description, + document: doc, + rust: { issues }, + sql: c.sql, + } +} + +describe('sheet conformance fixtures', () => { + it.each(CASES.map((c) => [c.name, c] as const))('%s', (name, c) => { + const file = resolve(DIR, `${name}.json`) + const text = `${JSON.stringify(fixtureOf(c))}\n` + if (MAKE) writeFileSync(file, text) + expect(readFileSync(file, 'utf8')).toBe(text) + }) + + it('has no stale fixture file', () => { + const names = new Set(CASES.map((c) => `${c.name}.json`)) + const stale = readdirSync(DIR).filter( + (f) => f.endsWith('.json') && !names.has(f), + ) + if (MAKE) for (const f of stale) rmSync(resolve(DIR, f)) + else expect(stale).toEqual([]) + }) +}) diff --git a/packages/domain/tests/r2-horse-slice.test.ts b/packages/domain/tests/r2-horse-slice.test.ts new file mode 100644 index 00000000..ef500ffb --- /dev/null +++ b/packages/domain/tests/r2-horse-slice.test.ts @@ -0,0 +1,26 @@ +/** + * R2: the horse slice fixture as JSON for the Rust suites (crates/core/tests/fixtures), + * written from the TypeScript fixture with `MAKE_R2_ORACLES=1`, asserted otherwise. + */ +import { readFileSync, writeFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' +import { HORSE_MAIN_ASSET_ID, horseSliceInput } from './fixtures/horse-slice' + +const FILE = resolve( + dirname(fileURLToPath(import.meta.url)), + '../../../crates/core/tests/fixtures/horse-slice.json', +) + +describe('horse slice JSON fixture', () => { + it('equals the TypeScript lean input', () => { + const fixture = { + mainAssetId: HORSE_MAIN_ASSET_ID, + input: horseSliceInput(), + } + const text = `${JSON.stringify(fixture, null, 2)}\n` + if (process.env.MAKE_R2_ORACLES === '1') writeFileSync(FILE, text) + expect(readFileSync(FILE, 'utf8')).toBe(text) + }) +}) diff --git a/packages/domain/tests/r2-oracles.test.ts b/packages/domain/tests/r2-oracles.test.ts new file mode 100644 index 00000000..e0593ef1 --- /dev/null +++ b/packages/domain/tests/r2-oracles.test.ts @@ -0,0 +1,46 @@ +/** + * R2 freeze (RUST_ARCHITECTURE_REVIEW VI.1): what the Zod schemas output for the reference + * documents, written once as `JSON.stringify(Schema.parse(x), null, 2)` under + * crates/core/tests/oracles so the Rust contracts are checked byte for byte against the + * TypeScript they replace. `MAKE_R2_ORACLES=1` writes them; otherwise they are asserted. + */ +import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' +import type { z } from 'zod' +import { + AnatomicalSheetDocumentSchema, + ReportMigrationMapSchema, + ReportSchema, + ReportV2Schema, +} from '../src' + +const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../../..') +const OUT = resolve(ROOT, 'crates/core/tests/oracles') +const MAKE = process.env.MAKE_R2_ORACLES === '1' +const SEED = 'supabase/seed/anatomical-sheets/equine' + +const CASES: Array<[string, string, z.ZodTypeAny]> = [ + ['sheet.draft.json', `${SEED}/draft/document.json`, AnatomicalSheetDocumentSchema], + ['sheet.legacy-import.json', `${SEED}/legacy-import/document.json`, AnatomicalSheetDocumentSchema], + ['migration-map.draft.json', `${SEED}/draft/report-migration-map.json`, ReportMigrationMapSchema], + ['report-v3.demo.json', 'apps/app/tests/fixtures/report-v3.demo.json', ReportSchema], + ['report-v2.full.json', 'apps/app/tests/fixtures/report-v2.full.json', ReportV2Schema], + ['report-v2.minimal.json', 'apps/app/tests/fixtures/report-v2.minimal.json', ReportV2Schema], +] + +describe('Zod output oracles of the R2 switch', () => { + it.each(CASES)('%s', (name, source, schema) => { + const input: unknown = JSON.parse(readFileSync(resolve(ROOT, source), 'utf8')) + const text = JSON.stringify(schema.parse(input), null, 2) + const file = resolve(OUT, name) + if (MAKE) { + mkdirSync(OUT, { recursive: true }) + writeFileSync(file, `${JSON.stringify({ source, output: JSON.parse(text) })}\n`) + } + const oracle = JSON.parse(readFileSync(file, 'utf8')) as { source: string; output: unknown } + expect(oracle.source).toBe(source) + expect(JSON.stringify(oracle.output, null, 2)).toBe(text) + }) +}) diff --git a/packages/supabase/package.json b/packages/supabase/package.json index ca830be9..38e69cd3 100644 --- a/packages/supabase/package.json +++ b/packages/supabase/package.json @@ -21,12 +21,12 @@ "assets:upload": "node scripts/upload-sheet-assets.ts" }, "dependencies": { - "@faunosteo/domain": "workspace:*", "@supabase/supabase-js": "^2.100.0", "zod": "^3.24.1" }, "devDependencies": { "@electric-sql/pglite": "^0.3.0", + "@faunosteo/core-wasm": "workspace:*", "@types/node": "^20.19.41", "eslint": "^9.17.0", "globals": "^15.14.0", diff --git a/packages/supabase/src/anatomical-sheets.ts b/packages/supabase/src/anatomical-sheets.ts index 373979c6..a516e808 100644 --- a/packages/supabase/src/anatomical-sheets.ts +++ b/packages/supabase/src/anatomical-sheets.ts @@ -1,18 +1,92 @@ -import { - AnatomicalSheetDocumentSchema, - assertPublishable, -} from '@faunosteo/domain' import type { FaunosteoClient } from './client' /** - * Publication gate on the client side: the full Zod shape and every - * integrity rule run before the RPC, so the editor gets the complete issue - * list. The database re-checks the referential rules on its own + * Publication gate on the client side: the full shape and every integrity + * rule run before the RPC, so the editor gets the complete issue list. The + * rules run in the Rust core (R2): the caller passes its `sheet.check` + * operation, so this package never loads the module itself. The gate fails + * closed: anything but a publishable verdict refuses publication. The + * database re-checks the referential rules on its own * (private.sheet_document_issues); this call never replaces that guard. */ + +export interface SheetIssue { + code: string + severity: 'error' | 'warning' + path: string + message: string +} + +/** The core's verdict on a document (`sheet.check`), or why it could not give one. */ +export type SheetCheckOutcome = + | { ok: true; value: { issues: SheetIssue[]; publishable: boolean } } + | { ok: false; kind: string; detail?: string } + +export type SheetValidator = (content: unknown) => SheetCheckOutcome + +export type SheetPublishErrorKind = + /** + * The document does not match the strict schema, or carries a text the core cannot read + * without altering it (`lone_surrogate`). + */ + | 'invalid_shape' + /** Integrity errors (warnings never block). */ + | 'not_publishable' + /** The validator could not run (core unavailable, trap): publication refused. */ + | 'validator_unavailable' + +export class SheetPublishError extends Error { + constructor( + readonly kind: SheetPublishErrorKind, + readonly issues: SheetIssue[] = [], + detail = '', + ) { + super(SheetPublishError.messageOf(kind, issues, detail)) + this.name = 'SheetPublishError' + } + + private static messageOf( + kind: SheetPublishErrorKind, + issues: SheetIssue[], + detail: string, + ): string { + if (kind === 'not_publishable') { + const errors = issues.filter((issue) => issue.severity === 'error') + return ( + `Sheet document is not publishable: ${errors.length} error(s), ` + + `first: ${errors[0]?.code ?? 'none'}` + ) + } + if (kind === 'invalid_shape') { + return `Sheet document does not match the schema${detail ? `: ${detail}` : ''}` + } + return `Sheet validator unavailable${detail ? ` (${detail})` : ''}` + } +} + +/** The validator's kinds that judge the document itself, not the validator's state. */ +const CONTENT_KINDS: ReadonlySet = new Set([ + 'invalid_shape', + 'lone_surrogate', +]) + +/** Throws unless the validator says the document is publishable. */ +function assertPublishable(validate: SheetValidator, content: unknown): void { + const check = validate(content) + if (!check.ok) { + throw CONTENT_KINDS.has(check.kind) + ? new SheetPublishError('invalid_shape', [], check.detail) + : new SheetPublishError('validator_unavailable', [], check.kind) + } + if (!check.value.publishable) { + throw new SheetPublishError('not_publishable', check.value.issues) + } +} + export async function publishSheetVersion( client: FaunosteoClient, versionId: string, + validate: SheetValidator, ): Promise { const draft = await client .from('anatomical_sheet_versions') @@ -21,7 +95,7 @@ export async function publishSheetVersion( .single() if (draft.error) throw draft.error - assertPublishable(AnatomicalSheetDocumentSchema.parse(draft.data.content)) + assertPublishable(validate, draft.data.content) const published = await client.rpc('publish_sheet_version', { version_id: versionId, diff --git a/packages/supabase/src/index.ts b/packages/supabase/src/index.ts index 0523ef9c..501f1149 100644 --- a/packages/supabase/src/index.ts +++ b/packages/supabase/src/index.ts @@ -43,7 +43,14 @@ export { } from './profiles' /** owner | admin | moderator | support. Not a professional status. */ export { fetchOwnPlatformRoles, type PlatformRole } from './platform-roles' -export { publishSheetVersion } from './anatomical-sheets' +export { + publishSheetVersion, + SheetPublishError, + type SheetCheckOutcome, + type SheetIssue, + type SheetPublishErrorKind, + type SheetValidator, +} from './anatomical-sheets' export { ASSET_FAILURE_KINDS, ASSET_OWNER_COLUMNS, diff --git a/packages/supabase/tests/anatomical-sheets.test.ts b/packages/supabase/tests/anatomical-sheets.test.ts index 413f9abb..5771280e 100644 --- a/packages/supabase/tests/anatomical-sheets.test.ts +++ b/packages/supabase/tests/anatomical-sheets.test.ts @@ -1,5 +1,15 @@ -import { publishSheetVersion } from '../src' -import type { FaunosteoClient } from '../src' +import { nodeCoreRuntime } from '@faunosteo/core-wasm/node' +import type { CoreRuntime } from '@faunosteo/core-wasm' +import { publishSheetVersion, SheetPublishError } from '../src' +import type { FaunosteoClient, SheetCheckOutcome, SheetValidator } from '../src' + +/** The real core's `sheet.check` (R2): the gate is never tested against a stub verdict. */ +let core: CoreRuntime +beforeAll(async () => { + core = await nodeCoreRuntime() +}) +const validate: SheetValidator = (content) => + core.call('sheet.check', JSON.stringify(content)) as SheetCheckOutcome /** * Stub of the two client calls publishSheetVersion makes. The real RPC is @@ -48,9 +58,21 @@ const publishable = { } describe('publishSheetVersion', () => { + it('refuses publication when the validator cannot run (fail closed)', async () => { + const { client, rpcCalls } = stubClient(publishable) + const unavailable: SheetValidator = () => ({ + ok: false, + kind: 'core_unavailable', + }) + await expect( + publishSheetVersion(client, 'v1', unavailable), + ).rejects.toMatchObject({ kind: 'validator_unavailable' }) + expect(rpcCalls).toEqual([]) + }) + it('calls the RPC once the document passes shape and integrity checks', async () => { const { client, rpcCalls } = stubClient(publishable) - await expect(publishSheetVersion(client, 'v1')).resolves.toBe( + await expect(publishSheetVersion(client, 'v1', validate)).resolves.toBe( 'published-id', ) expect(rpcCalls).toEqual([['publish_sheet_version', { version_id: 'v1' }]]) @@ -61,7 +83,7 @@ describe('publishSheetVersion', () => { ...publishable, views: [{ ...publishable.views[0], svg_asset_id: null }], }) - await expect(publishSheetVersion(client, 'v1')).rejects.toThrow( + await expect(publishSheetVersion(client, 'v1', validate)).rejects.toThrow( /view\.asset\.missing/, ) expect(rpcCalls).toEqual([]) @@ -69,7 +91,23 @@ describe('publishSheetVersion', () => { it('refuses a document that does not match the schema', async () => { const { client, rpcCalls } = stubClient({ schema_version: 1 }) - await expect(publishSheetVersion(client, 'v1')).rejects.toThrow() + await expect( + publishSheetVersion(client, 'v1', validate), + ).rejects.toBeInstanceOf(SheetPublishError) + await expect( + publishSheetVersion(client, 'v1', validate), + ).rejects.toMatchObject({ kind: 'invalid_shape' }) + expect(rpcCalls).toEqual([]) + }) + + it('refuses a document carrying a lone surrogate as content, before any RPC (L1)', async () => { + const { client, rpcCalls } = stubClient({ + ...publishable, + name: { fr: 'Vue \ud800', en: 'View' }, + }) + await expect( + publishSheetVersion(client, 'v1', validate), + ).rejects.toMatchObject({ kind: 'invalid_shape' }) expect(rpcCalls).toEqual([]) }) }) diff --git a/packages/supabase/vitest.config.ts b/packages/supabase/vitest.config.ts index 91ab39c3..c4b56b84 100644 --- a/packages/supabase/vitest.config.ts +++ b/packages/supabase/vitest.config.ts @@ -5,6 +5,8 @@ export default defineConfig({ environment: 'node', globals: true, include: ['tests/**/*.test.ts'], + // The publish gate runs on the real core: refuse a missing or stale module. + globalSetup: ['../core-wasm/tests/global-setup.ts'], // PGlite boots a WASM Postgres per file: give it room on slow CI runners. testTimeout: 60_000, hookTimeout: 120_000, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a06684e4..9b876b99 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: '@faunosteo/anatomy': specifier: workspace:* version: link:../../packages/anatomy + '@faunosteo/core-wasm': + specifier: workspace:* + version: link:../../packages/core-wasm '@faunosteo/domain': specifier: workspace:* version: link:../../packages/domain @@ -147,10 +150,11 @@ importers: version: 3.2.7(@types/node@20.19.41)(happy-dom@20.10.6)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.23.15) packages/core-wasm: + dependencies: + zod: + specifier: ^3.24.1 + version: 3.25.76 devDependencies: - '@faunosteo/domain': - specifier: workspace:* - version: link:../domain '@types/node': specifier: ^20.19.41 version: 20.19.41 @@ -240,9 +244,6 @@ importers: packages/supabase: dependencies: - '@faunosteo/domain': - specifier: workspace:* - version: link:../domain '@supabase/supabase-js': specifier: ^2.100.0 version: 2.117.3 @@ -253,6 +254,9 @@ importers: '@electric-sql/pglite': specifier: ^0.3.0 version: 0.3.16 + '@faunosteo/core-wasm': + specifier: workspace:* + version: link:../core-wasm '@types/node': specifier: ^20.19.41 version: 20.19.41 diff --git a/scripts/wasm-build.sh b/scripts/wasm-build.sh index 98e308b9..473e4fb7 100755 --- a/scripts/wasm-build.sh +++ b/scripts/wasm-build.sh @@ -21,14 +21,37 @@ if [ "$lock_version" != "$cli_version" ]; then exit 1 fi -# `proofs`: the R0 trap exports; dropped when R2 builds the module the application ships. -cargo build -p faunosteo-wasm --release --target wasm32-unknown-unknown --locked --features proofs +# Two modules from the same sources: pkg/ is the one the application ships (no trap export), +# pkg-proofs/ adds the R0 trap exports for the poison-and-reinstantiate tests only (R2 plan P10). +# The caller removes the previous output on its literal path first (never through a variable). +build_module() { + local out="$1" + shift + cargo build -p faunosteo-wasm --release --target wasm32-unknown-unknown --locked "$@" + wasm-bindgen --target web --out-dir "$out" --out-name faunosteo_wasm \ + target/wasm32-unknown-unknown/release/faunosteo_wasm.wasm +} -out=packages/core-wasm/pkg +# WASM_BUILD_SHIPPED_ONLY=1 (the application image) builds pkg/ alone; the stamp needs node, +# absent from that stage, and only the test suites read it. rm -rf packages/core-wasm/pkg -wasm-bindgen --target web --out-dir "$out" --out-name faunosteo_wasm \ - target/wasm32-unknown-unknown/release/faunosteo_wasm.wasm +if [ "${WASM_BUILD_SHIPPED_ONLY:-0}" = 1 ]; then + build_module packages/core-wasm/pkg +else + stamp="$(node scripts/wasm-stamp.mjs)" + rm -rf packages/core-wasm/pkg-proofs + build_module packages/core-wasm/pkg-proofs --features proofs + echo "$stamp" > packages/core-wasm/pkg-proofs/BUILD_STAMP + build_module packages/core-wasm/pkg + echo "$stamp" > packages/core-wasm/pkg/BUILD_STAMP +fi -raw=$(wc -c < "$out/faunosteo_wasm_bg.wasm") -gz=$(gzip -9 -c "$out/faunosteo_wasm_bg.wasm" | wc -c) -echo "faunosteo_wasm_bg.wasm: ${raw} bytes raw, ${gz} bytes gzip -9" +# The shipped module must not carry a proof export. +if grep -Eq 'panic_for_test|recurse_for_test' packages/core-wasm/pkg/faunosteo_wasm.d.ts; then + echo "packages/core-wasm/pkg exports a proof function: refusing to ship it" >&2 + exit 1 +fi + +raw=$(wc -c < packages/core-wasm/pkg/faunosteo_wasm_bg.wasm) +gz=$(gzip -9 -c packages/core-wasm/pkg/faunosteo_wasm_bg.wasm | wc -c) +echo "faunosteo_wasm_bg.wasm (shipped): ${raw} bytes raw, ${gz} bytes gzip -9" diff --git a/scripts/wasm-stamp.mjs b/scripts/wasm-stamp.mjs new file mode 100644 index 00000000..0cd52ace --- /dev/null +++ b/scripts/wasm-stamp.mjs @@ -0,0 +1,41 @@ +// Build stamp of the browser module: sha256 over the sources that compile into it (the core +// library, the wasm facade, the workspace manifests and lock, the cargo config). Written into +// pkg/ and pkg-proofs/ by scripts/wasm-build.sh; packages/core-wasm/tests/global-setup.ts +// recomputes it and refuses to run the suites on a missing or stale module. +// Usage: node scripts/wasm-stamp.mjs → prints the stamp. +import { createHash } from 'node:crypto' +import { readdirSync, readFileSync, statSync } from 'node:fs' +import { join, relative, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' + +const ROOT = resolve(fileURLToPath(new URL('..', import.meta.url))) +const INPUTS = [ + 'Cargo.toml', + 'Cargo.lock', + '.cargo/config.toml', + 'crates/core/Cargo.toml', + 'crates/core/src', + 'crates/wasm/Cargo.toml', + 'crates/wasm/src', +] + +function files(path) { + const absolute = join(ROOT, path) + if (!statSync(absolute).isDirectory()) return [path] + return readdirSync(absolute).flatMap((name) => files(join(path, name))) +} + +export function wasmStamp() { + const hash = createHash('sha256') + const all = INPUTS.flatMap(files).map((f) => relative(ROOT, join(ROOT, f))) + for (const file of all.sort()) { + hash.update(`${file}\0`) + hash.update(readFileSync(join(ROOT, file))) + hash.update('\0') + } + return hash.digest('hex') +} + +if (process.argv[1] === fileURLToPath(import.meta.url)) { + process.stdout.write(`${wasmStamp()}\n`) +} diff --git a/supabase/tests/011_sheet_conformance.sql b/supabase/tests/011_sheet_conformance.sql new file mode 100644 index 00000000..1a5db719 --- /dev/null +++ b/supabase/tests/011_sheet_conformance.sql @@ -0,0 +1,167 @@ +-- GENERATED from crates/core/tests/conformance/*.json by crates/core/tests/sheet_conformance.rs: +-- FAUNOSTEO_WRITE_CONFORMANCE=1 cargo test -p faunosteo-core --test sheet_conformance +-- Never edited by hand: cargo fails when this file differs from the fixtures. +-- The SQL publication re-check returns, for each fixture, the error codes the Rust +-- integrity rules report that SQL mirrors (codes only, sorted), plus its own +-- document.shape and reference.url.scheme on documents the shape tier refuses. +begin; +select plan(26); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"os","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{annotation.category.missing}'::text[], + 'conformance annotation-category-missing: an annotation in an undeclared category' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"},{"id":"stifle","kind":"point","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":null,"review_status":"inherited","color":null,"name":{"fr":"stifle","en":"stifle"},"finding_zone_id":"stifle","vertebral_region_code":null}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{annotation.finding_zone.missing}'::text[], + 'conformance annotation-finding-zone-missing: an annotation linked to an undeclared finding zone' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"},{"id":"atm","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{annotation.id.duplicate}'::text[], + 'conformance annotation-id-duplicate: an annotation id repeated on another view' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"},{"id":"mandible","kind":"point","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":null,"review_status":"inherited","color":null,"name":{"fr":"mandible","en":"mandible"},"finding_zone_id":null,"vertebral_region_code":null}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{}'::text[], + 'conformance annotation-no-findings: an annotation linked to no finding zone (warning, not mirrored by SQL)' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"},{"id":"loop","kind":"detail_trigger","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":null,"review_status":"inherited","color":null,"name":null,"opens_view_id":"view-head"},{"id":"to-main","kind":"detail_trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":null,"review_status":"inherited","color":null,"name":null,"opens_view_id":"view-main"},{"id":"to-ghost","kind":"detail_trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":null,"review_status":"inherited","color":null,"name":null,"opens_view_id":"view-ghost"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{annotation.opens_view.invalid}'::text[], + 'conformance annotation-opens-view-invalid: triggers opening their own view, the main view and an absent view' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"Q","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{annotation.region.missing}'::text[], + 'conformance annotation-region-missing: a spine annotation on an unconfigured region' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"},{"id":"ghost","kind":"point","view_id":"view-ghost","category_id":"articulations","laterality":"bilateral","geometry":null,"review_status":"inherited","color":null,"name":{"fr":"ghost","en":"ghost"},"finding_zone_id":"hip","vertebral_region_code":null}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{annotation.view.missing}'::text[], + 'conformance annotation-view-missing: an annotation on a view that does not exist' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"},{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{category.id.duplicate}'::text[], + 'conformance category-id-duplicate: an annotation category listed twice' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{}'::text[], + 'conformance clean: the horse slice: no issue' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]},{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{}'::text[], + 'conformance finding-id-duplicate: sibling finding ids repeated at two depths (not mirrored by SQL)' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":["nav-2017"],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog","x"],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{finding.reference.missing}'::text[], + 'conformance finding-reference-missing: undeclared citations on a category and on a nested node' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{finding_zone.id.duplicate}'::text[], + 'conformance finding-zone-id-duplicate: a finding zone listed twice' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"stifle","name":{"fr":"Grasset","en":"Stifle"},"categories":[]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{}'::text[], + 'conformance finding-zone-unreferenced: a finding zone no annotation points to (warning, not mirrored by SQL)' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null},{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{reference.id.duplicate}'::text[], + 'conformance reference-id-duplicate: a reference declared twice' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}},{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{region.code.duplicate}'::text[], + 'conformance region-code-duplicate: a vertebral region listed twice' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":19,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{region.count_range.invalid}'::text[], + 'conformance region-count-range-invalid: a usual vertebra count outside its documented range' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":19,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":null,"view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"os","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"os","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{annotation.category.missing,region.count_range.invalid,view.asset.missing}'::text[], + 'conformance several-errors: errors of four families at once, duplicates of one code collapsed by SQL' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":"javascript:alert(1)","doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{reference.url.scheme}'::text[], + 'conformance shape-reference-url-scheme: a javascript: reference url: the shape tier refuses it, SQL says reference.url.scheme' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":"x","categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{document.shape}'::text[], + 'conformance shape-references-not-array: a non-array references registry: the shape tier refuses it, SQL says document.shape' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":null,"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{view.asset.missing}'::text[], + 'conformance view-asset-missing-detail: a detail view with neither an asset nor a view_box' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":null,"view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{view.asset.missing}'::text[], + 'conformance view-asset-missing-main: the main view without an SVG asset' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{view.id.duplicate}'::text[], + 'conformance view-id-duplicate: a detail view listed twice' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"},{"id":"view-alt","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{view.main.count}'::text[], + 'conformance view-main-count: two main views' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"},{"id":"view-a","kind":"detail","name":{"fr":"view-a","en":"view-a"},"parent_view_id":"view-b","svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null},{"id":"view-b","kind":"detail","name":{"fr":"view-b","en":"view-b"},"parent_view_id":"view-a","svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"},{"id":"open-a","kind":"detail_trigger","view_id":"view-b","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":null,"review_status":"inherited","color":null,"name":null,"opens_view_id":"view-a"},{"id":"open-b","kind":"detail_trigger","view_id":"view-a","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":null,"review_status":"inherited","color":null,"name":null,"opens_view_id":"view-b"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{}'::text[], + 'conformance view-parent-cycle: two detail views parent of each other (SQL has no cycle rule)' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"},{"id":"view-orphan","kind":"detail","name":{"fr":"view-orphan","en":"view-orphan"},"parent_view_id":"view-ghost","svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"head-trigger","view_id":"view-main","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"polygon","points":[[454,332],[429,202],[349,154],[234,279],[164,384],[234,468]]},"review_status":"inherited","color":null,"kind":"detail_trigger","name":null,"opens_view_id":"view-head"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{view.parent.missing}'::text[], + 'conformance view-parent-missing: a detail view whose parent does not exist' +); + +select is( + array(select c from unnest(private.sheet_document_issues($fixture${"schema_version":2,"species_id":"equine","name":{"fr":"Cheval (extrait)","en":"Horse (slice)"},"description":{"fr":"Extrait de la fiche équine pour les tests du modèle","en":"Equine sheet slice for model tests"},"scope_disclaimer":{"fr":"Les éléments listés correspondent au périmètre légal de l'ostéopathie animale : dysfonctions ostéopathiques palpées, observations cliniques et motifs de consultation. Aucun diagnostic médical n'est posé. Toute pathologie organique relève du vétérinaire."},"attribution":{"authors":["Faunosteo"],"license":"MIT","notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7,"count_range":null},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18,"count_range":null},{"code":"L","name":{"fr":"Lombaires","en":"Lumbar"},"count":6,"count_range":null},{"code":"S","name":{"fr":"Sacrées","en":"Sacral"},"count":5,"count_range":null},{"code":"Cd","name":{"fr":"Caudales","en":"Caudal"},"count":18,"count_range":{"min":15,"max":21}}]},"references":[{"id":"legacy-catalog","type":"manual","citation":"Legacy equine catalog (pathologies.json, schema 2.0)","url":null,"doi":null}],"categories":[{"id":"articulations","name":{"fr":"Articulations","en":"Joints"},"color":"#ff9500"},{"id":"zone-colonne","name":{"fr":"Zone colonne","en":"Spine zone"},"color":"#e100ff"},{"id":"charnieres-vertebrales","name":{"fr":"Charnières vertébrales","en":"Vertebral junctions"},"color":"#ff0000"},{"id":"cadrans-du-crane","name":{"fr":"Cadrans du crâne","en":"Skull quadrants"},"color":"#1baa08"}],"views":[{"id":"view-main","name":{"fr":"Cheval entier","en":"Whole horse"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null,"kind":"main"},{"id":"view-head","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":60,"min_y":100,"width":500,"height":380},"kind":"detail","parent_view_id":"view-main"}],"annotations":[{"id":"hip","view_id":"view-main","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":1516,"cy":695,"r":34},"review_status":"inherited","color":null,"name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"finding_zone_id":"hip","vertebral_region_code":null,"kind":"point"},{"id":"cervical-vertebrae","view_id":"view-main","category_id":"zone-colonne","laterality":"unpaired","geometry":{"type":"polygon","points":[[468,276],[489,216],[558,248],[586,339],[552,461],[524,370]]},"review_status":"inherited","color":null,"name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"finding_zone_id":"cervical","vertebral_region_code":"C","kind":"zone"},{"id":"hinge-c7-t1","view_id":"view-main","category_id":"charnieres-vertebrales","laterality":"unpaired","geometry":{"type":"circle","cx":840.17,"cy":399.08,"r":30},"review_status":"inherited","color":null,"name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"finding_zone_id":"c7-t1","vertebral_region_code":null,"kind":"point"},{"id":"atm","view_id":"view-head","category_id":"articulations","laterality":"bilateral","geometry":{"type":"circle","cx":384.94,"cy":314.02,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"finding_zone_id":"atm","vertebral_region_code":null,"kind":"point"},{"id":"sphenoid","view_id":"view-head","category_id":"cadrans-du-crane","laterality":"unpaired","geometry":{"type":"circle","cx":299,"cy":298,"r":27},"review_status":"inherited","color":null,"name":{"fr":"Sphénoïde","en":"Sphenoid"},"finding_zone_id":"sphenoid","vertebral_region_code":null,"kind":"point"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche (coxo-fémorale)","en":"Hip joint"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"articular","name":{"fr":"Restrictions de mobilité articulaire","en":"Articular mobility restrictions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-flexion","name":{"fr":"Restriction en flexion","en":"Flexion restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"restriction-extension","name":{"fr":"Restriction en extension","en":"Extension restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"hip-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"limb-lameness","name":{"fr":"Boiterie rapportée (membre concerné)","en":"Reported lameness (affected limb)"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":["legacy-catalog"],"review_status":"inherited","children":[]}]}]},{"id":"cervical","name":{"fr":"Vertèbres cervicales","en":"Cervical Vertebrae"},"categories":[{"id":"cervical-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"muscular","name":{"fr":"Tensions musculaires paravertébrales","en":"Paravertebral muscle tensions"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"splenius-tension","name":{"fr":"Tension du splénius","en":"Splenius tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"cervical-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"stumbling-proprioceptive","name":{"fr":"Trébuchements / déficit proprioceptif rapporté","en":"Reported stumbling / proprioceptive deficit"},"description":{},"requires_vet_referral":true,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"c7-t1","name":{"fr":"Charnière C7-T1 (cervico-thoracique)","en":"C7-T1 (Cervicothoracic)"},"categories":[{"id":"c7-t1-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"restriction-rotation","name":{"fr":"Restriction en rotation","en":"Rotation restriction"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"c7-t1-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"base-neck-stiffness","name":{"fr":"Raideur de la base de l'encolure","en":"Base-of-neck stiffness"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"atm","name":{"fr":"Articulation Temporo-Mandibulaire (ATM)","en":"Temporomandibular Joint (TMJ)"},"categories":[{"id":"atm-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques de l'ATM","en":"Osteopathic TMJ dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"masseter-tension","name":{"fr":"Tension du masséter","en":"Masseter tension"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"atm-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"bit-defense","name":{"fr":"Réactions de défense au mors","en":"Defense reactions to bit"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"dental-context","name":{"fr":"Suite de soin dentaire récent","en":"Post recent dental care"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid","name":{"fr":"Sphénoïde","en":"Sphenoid"},"categories":[{"id":"ssb-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions ostéopathiques","en":"Osteopathic dysfunctions"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"physiological","name":{"fr":"Lésions physiologiques (SSB)","en":"Physiological lesions (SBS)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[{"id":"torsion-right","name":{"fr":"Torsion droite","en":"Right torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"torsion-left","name":{"fr":"Torsion gauche","en":"Left torsion"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]},{"id":"sphenoid-observations","kind":"consultation_reason","name":{"fr":"Observations / motifs de consultation","en":"Observations / consultation reasons"},"description":{},"reference_ids":[],"review_status":"inherited","children":[{"id":"post-trauma-head","name":{"fr":"Suite de traumatisme crânien","en":"Post head trauma"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse / facteurs rapportés","en":"Anamnesis / reported factors"},"description":{"fr":"Facteurs rapportés par le propriétaire lors de l'anamnèse"},"reference_ids":[],"review_status":"inherited","children":[{"id":"trauma-direct","name":{"fr":"Traumatisme rapporté (choc, chute)","en":"Reported trauma (blow, fall)"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]},{"id":"stress-context","name":{"fr":"Contexte de stress / changement","en":"Stress / change context"},"description":{},"requires_vet_referral":false,"reference_ids":[],"review_status":"inherited","children":[]}]}]}]}$fixture$::jsonb)) as c order by c collate "C"), + '{view.unreachable}'::text[], + 'conformance view-unreachable: the head view without its trigger' +); + +select * from finish(); +rollback;