feat(app): R2 switch — the application runs its domain rules in the Rust core

Consumers now fed by the core (crates/core through @faunosteo/core-wasm):
- the sheet: the bundled payload is parsed and indexed by the core
  (SheetHandle, SheetIndexData); SheetIndex reads precomputed tables only;
- the store: new report, add / remove / move observation, draft restore
  (v2 migration + rebase) through the core, actions answering { ok };
- the editor click chain (zone.click), laterality and vertebra pickers
  (zone.add_sides, vertebra.initial / sync / select), the findings picker
  (finding.toggle by clicked leaf position), zone removal;
- the import: engine byte scan (TypeScript until R4), then the core's
  layered reading and rebase in one call; the export: the core builds the
  sheet snapshot, the frozen TypeScript engine writes the PDF (R4).
Lazy core: Home and the new-report form read the sheet availability from
the bundle and load the module on import / submit only; the auth shell
never references it. Degraded states (core_unavailable, invalid_sheet)
show the validated notice with a retry and never redirect or touch the
draft; an unreadable draft or archive is set aside under
osteo:quarantine:* (only content kinds; a failed write keeps it in place
and the editor stays), a rebase that flags items keeps the raw pre-rebase
draft. Four strings, wording validated by the owner.
Deleted: services/zoneInteraction.ts and its suite (13 cases ported to
cargo), the TypeScript Finding builder and vertebra selection rules of the
pickers, store rules, persistence parsing, hydrateReport. ESLint forbids
@faunosteo/domain in apps/app/src; the report:compare CLI keeps the frozen
domain until R4 (scripts/compare/sheet.ts). App suite 313/313 on the real
core (24 new tests: quarantine, degraded editor, core failures, N-1
reader); step6 goldens and the frozen envelopes unchanged.
This commit is contained in:
bchanot committed 2026-10-14 00:41:34 +02:00
1 parent 794dfd9d0b
commit 74fcb37564
65 files changed
+2227 -1678

No files matched your search

+20 -6
View File
@@ -1,7 +1,9 @@
/**
* The archive check tool (scripts/compare-reports.ts) on the frozen v2 PDF,
* on a synthetic v2 report with removed and unknown items, on a v3 report
* and on a Step 6 envelope (archive header line).
* and on a Step 6 envelope (archive header line). The tool keeps its own
* reading on the frozen TypeScript domain until R4 (`compareSheetIndex`);
* the fixtures it compares are built through the application (the core).
*/
import { describe, it, expect, beforeAll } from 'vitest'
import { readFileSync } from 'node:fs'
@@ -14,6 +16,10 @@ import {
} from '@faunosteo/domain'
import { readAttachedDocument } from '@faunosteo/pdf'
import type { SheetIndex } from '@/services/sheetIndex'
import {
compareSheetIndex,
type CompareSheetIndex,
} from '../../scripts/compare/sheet'
import {
compareReport,
diffLines,
@@ -22,12 +28,19 @@ import {
renderSummary,
UNRESOLVED,
} from '../../scripts/compare/report'
import { archiveEnvelope, loadTestSheet, minimalReport } from '../helpers/sheet'
import {
archiveEnvelope,
bundledSheet,
loadTestSheet,
minimalReport,
} from '../helpers/sheet'
const HERE = dirname(fileURLToPath(import.meta.url))
const OPTS = { locale: 'fr' as const, full: false }
/** The application's sheet (fixture building) and the tool's own reading of it. */
let sheet: SheetIndex
let cli: CompareSheetIndex
function minimalV2(): ReportV2 {
return JSON.parse(
@@ -36,12 +49,13 @@ function minimalV2(): ReportV2 {
}
function compareRaw(raw: unknown, full = false) {
const outcome = readArchiveDocument(raw, sheet.sheet.migrationMap)
return compareReport(raw, outcome, sheet, { ...OPTS, full })
const outcome = readArchiveDocument(raw, cli.sheet.migrationMap)
return compareReport(raw, outcome, cli, { ...OPTS, full })
}
beforeAll(async () => {
sheet = await loadTestSheet()
cli = compareSheetIndex(await bundledSheet())
})
describe('compareReport on the frozen v2 archive PDF', () => {
@@ -210,7 +224,7 @@ describe('compareReport on unresolved items', () => {
describe('diff and arguments', () => {
it('diffs the v3 content of a migrated v2 report and its v3 re-reading', () => {
const v2 = minimalV2()
const migrated = readReportDocument(v2, sheet.sheet.migrationMap).report
const migrated = readReportDocument(v2, cli.sheet.migrationMap).report
const a = compareRaw(v2)
const b = compareRaw(migrated)
expect(diffLines(a.normalized, b.normalized)).toEqual([])
@@ -221,7 +235,7 @@ describe('diff and arguments', () => {
})
it('compares placeholders by default and real texts with --full', () => {
const base = readReportDocument(minimalV2(), sheet.sheet.migrationMap)
const base = readReportDocument(minimalV2(), cli.sheet.migrationMap)
const original = { ...base.report, conclusion: 'original' }
const edited = { ...base.report, conclusion: 'changed' }
expect(