feat(domain): R5.6 fingerprint switch to sha256-rfc8785-validated-v1

The Rust pipeline is the official seed writer (pnpm import:equine); sheet-ref.json
and report-migration-map.json carry 12d78872...74e2 and the v1 block, the only two
seed files changed. 27c7383c...2660 stays a registered alias, honoured only through
LoadedSheet::recognises_historical_stamp (verified v1, recomputed document). M1: the
snapshot of an old report keeps its stamp; export, archive reader strict. Historical
oracles run in their pre-switch context; equivalence is crate-private.
This commit is contained in:
bchanot committed 2026-10-25 02:02:42 +01:00
1 parent 59521dc195
commit 9e87016399
31 files changed
+2331 -154

No files matched your search

+73 -9
View File
@@ -22,25 +22,89 @@ 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],
[
'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,
],
]
/**
* Since R5.6 the committed migration map carries the `v1` fingerprint; the oracle was frozen on
* the pre-switch file, read here in that original context (`tests/fixtures/r5-6/pre-switch`,
* proven the same TypeScript output by the Rust suite `curation_draft`).
*/
const PRE_SWITCH: Record<string, string> = {
[`${SEED}/draft/report-migration-map.json`]:
'crates/core/tests/fixtures/r5-6/pre-switch/report-migration-map.json',
}
const ALIAS = '27c7383c445c73dc2001ebf4794a3ea63d416910bbbaa0d7848dd720de7c2660'
const CANONICAL =
'12d788727c1e532641bd5b3a7ecf39dbdd25e70350f8a76be5ca917b262874e2'
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 read = PRE_SWITCH[source] ?? source
const input: unknown = JSON.parse(readFileSync(resolve(ROOT, read), '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`)
writeFileSync(
file,
`${JSON.stringify({ source, output: JSON.parse(text) })}\n`,
)
}
const oracle = JSON.parse(readFileSync(file, 'utf8')) as {
source: string
output: unknown
}
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)
})
})
describe('the committed migration map after R5.6', () => {
it('is the oracle with only the fingerprint moved to the canonical value', () => {
const source = `${SEED}/draft/report-migration-map.json`
const committed = ReportMigrationMapSchema.parse(
JSON.parse(readFileSync(resolve(ROOT, source), 'utf8')),
)
const oracle = JSON.parse(
readFileSync(resolve(OUT, 'migration-map.draft.json'), 'utf8'),
) as { output: { sheet: { documentSha256: string } } }
expect(oracle.output.sheet.documentSha256).toBe(ALIAS)
const expected = {
...oracle.output,
sheet: { ...oracle.output.sheet, documentSha256: CANONICAL },
}
expect(JSON.stringify(committed, null, 2)).toBe(
JSON.stringify(expected, null, 2),
)
})
})