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:
1 parent
59521dc195
commit
9e87016399
31 files changed
+2331
-154
No files matched your search
@@ -32,22 +32,34 @@ const SEED: &str = "supabase/seed/anatomical-sheets/equine/draft";
|
||||
|
||||
/// The bundled draft sheet exactly as `apps/app/vite/sheet-bundle.ts` embeds it.
|
||||
fn draft_sheet() -> LoadedSheet {
|
||||
sheet_with(&repo_root().join(SEED))
|
||||
}
|
||||
|
||||
/// The sheet the R4 oracles were frozen against (before R5.6): the same document and drawing,
|
||||
/// with the pre-switch `sheet-ref.json` and migration map (`tests/fixtures/r5-6/pre-switch`,
|
||||
/// proven to be the TypeScript's files by `curation_draft`).
|
||||
fn historical_sheet() -> LoadedSheet {
|
||||
sheet_with(&repo_root().join("crates/core/tests/fixtures/r5-6/pre-switch"))
|
||||
}
|
||||
|
||||
/// The seed's document and drawings, with `sheet-ref.json` and the migration map from `refs`.
|
||||
fn sheet_with(refs: &std::path::Path) -> LoadedSheet {
|
||||
let seed = repo_root().join(SEED);
|
||||
let read = |name: &str| std::fs::read_to_string(seed.join(name)).unwrap();
|
||||
let manifest: Value = serde_json::from_str(&read("assets.json")).unwrap();
|
||||
let read = |dir: &std::path::Path, name: &str| std::fs::read_to_string(dir.join(name)).unwrap();
|
||||
let manifest: Value = serde_json::from_str(&read(&seed, "assets.json")).unwrap();
|
||||
let mut assets = serde_json::Map::new();
|
||||
let mut hashes = serde_json::Map::new();
|
||||
for asset in manifest.as_array().unwrap() {
|
||||
let id = asset["svg_asset_id"].as_str().unwrap().to_owned();
|
||||
let file = format!("assets/{}", asset["file"].as_str().unwrap());
|
||||
assets.insert(id.clone(), Value::String(read(&file)));
|
||||
assets.insert(id.clone(), Value::String(read(&seed, &file)));
|
||||
hashes.insert(id, asset["sha256"].clone());
|
||||
}
|
||||
let payload = json!({
|
||||
"status": "draft",
|
||||
"ref": parse_json(&read("sheet-ref.json")).unwrap(),
|
||||
"document": parse_json(&read("document.json")).unwrap(),
|
||||
"migrationMap": parse_json(&read("report-migration-map.json")).unwrap(),
|
||||
"ref": parse_json(&read(refs, "sheet-ref.json")).unwrap(),
|
||||
"document": parse_json(&read(&seed, "document.json")).unwrap(),
|
||||
"migrationMap": parse_json(&read(refs, "report-migration-map.json")).unwrap(),
|
||||
"assets": assets,
|
||||
"assetHashes": hashes,
|
||||
});
|
||||
@@ -126,7 +138,9 @@ fn archive_row(text: &str, sheet: &LoadedSheet) -> Value {
|
||||
#[test]
|
||||
fn o7_locate_and_read_match_the_typescript() {
|
||||
let oracle = r4_oracle("read.json");
|
||||
let sheet = draft_sheet();
|
||||
// In its original context: the oracle froze the reports a v2 migration stamps with the
|
||||
// pre-switch map (R5.6 leaves it untouched; the post-switch stamp has its own test below).
|
||||
let sheet = historical_sheet();
|
||||
let (mut inputs, mut located, mut archives, mut mismatches) = (0, 0, 0, Vec::new());
|
||||
for row in oracle["inputs"].as_array().unwrap() {
|
||||
if row["kind"] != "pdf" {
|
||||
@@ -179,6 +193,46 @@ fn o7_locate_and_read_match_the_typescript() {
|
||||
println!("O7: {inputs} inputs, {located} locate rows, {archives} archive rows");
|
||||
}
|
||||
|
||||
/// After R5.6 a v2 migration stamps the canonical value; everything else is what O7 froze.
|
||||
#[test]
|
||||
fn o7_after_r5_6_migrated_v2_reports_carry_the_canonical_stamp_and_nothing_else_moves() {
|
||||
let (now, then) = (draft_sheet(), historical_sheet());
|
||||
for file in ["scan.report-v2-full.pdf", "scan.report-v2-minimal.pdf"] {
|
||||
let bytes = r4_input("read", file);
|
||||
let text = read_attached_document(&bytes, ProbeLimits::UNBOUNDED)
|
||||
.unwrap()
|
||||
.text
|
||||
.into_owned();
|
||||
let data = parse_json(&text).unwrap();
|
||||
let after = read_archive_document(&data, &now.migration_map).unwrap();
|
||||
let before = read_archive_document(&data, &then.migration_map).unwrap();
|
||||
assert_eq!(
|
||||
after.report.sheet.document_sha256, now.reference.document_sha256,
|
||||
"{file}"
|
||||
);
|
||||
assert_eq!(
|
||||
before.report.sheet.document_sha256, then.reference.document_sha256,
|
||||
"{file}"
|
||||
);
|
||||
let mut aligned = after.report.clone();
|
||||
aligned.sheet.document_sha256 = before.report.sheet.document_sha256.clone();
|
||||
assert_eq!(aligned, before.report, "{file}");
|
||||
assert_eq!(
|
||||
(
|
||||
after.migrated,
|
||||
after.unresolved_zones,
|
||||
after.unresolved_findings
|
||||
),
|
||||
(
|
||||
before.migrated,
|
||||
before.unresolved_zones,
|
||||
before.unresolved_findings
|
||||
),
|
||||
"{file}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn compare(
|
||||
mismatches: &mut Vec<String>,
|
||||
file: &str,
|
||||
|
||||
Reference in new issue
Block a user