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:
1 parent
794dfd9d0b
commit
74fcb37564
65 files changed
+2227
-1678
No files matched your search
@@ -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<Comparison> {
|
||||
const st = statSync(path)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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<Record<string, string>>
|
||||
migrationMap: ReportMigrationMap
|
||||
}
|
||||
|
||||
export type CompareSheetIndex = SheetIndex<CompareSheet>
|
||||
|
||||
/** 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),
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user