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
@@ -27,24 +27,58 @@ use serde_json::{Value, json};
|
||||
const SEED: &str = "supabase/seed/anatomical-sheets/equine/draft";
|
||||
|
||||
/// The seed sheet as the binary loads it: document and map, no drawing.
|
||||
/// The sheet O10 was frozen against (before R5.6): the seed's document with the pre-switch
|
||||
/// `sheet-ref.json` and migration map (`tests/fixtures/r5-6/pre-switch`). O10 replays in that
|
||||
/// context; the switched seed has its own test under the declared rule below.
|
||||
fn draft_sheet() -> &'static LoadedSheet {
|
||||
static SHEET: OnceLock<LoadedSheet> = OnceLock::new();
|
||||
SHEET.get_or_init(|| {
|
||||
let seed = repo_root().join(SEED);
|
||||
let read = |name: &str| -> Value {
|
||||
serde_json::from_str(&std::fs::read_to_string(seed.join(name)).unwrap()).unwrap()
|
||||
};
|
||||
let payload = json!({
|
||||
"status": "draft",
|
||||
"ref": read("sheet-ref.json"),
|
||||
"document": read("document.json"),
|
||||
"migrationMap": read("report-migration-map.json"),
|
||||
"assets": {},
|
||||
"assetHashes": {},
|
||||
});
|
||||
let data: BundledSheetData = serde_json::from_value(payload).unwrap();
|
||||
LoadedSheet::from_bundle(data).unwrap()
|
||||
})
|
||||
SHEET
|
||||
.get_or_init(|| sheet_with(&repo_root().join("crates/core/tests/fixtures/r5-6/pre-switch")))
|
||||
}
|
||||
|
||||
/// The committed (switched) seed, as the `report-compare` binary reads it.
|
||||
fn switched_sheet() -> &'static LoadedSheet {
|
||||
static SHEET: OnceLock<LoadedSheet> = OnceLock::new();
|
||||
SHEET.get_or_init(|| sheet_with(&repo_root().join(SEED)))
|
||||
}
|
||||
|
||||
fn sheet_with(refs: &std::path::Path) -> LoadedSheet {
|
||||
let seed = repo_root().join(SEED);
|
||||
let read = |dir: &std::path::Path, name: &str| -> Value {
|
||||
serde_json::from_str(&std::fs::read_to_string(dir.join(name)).unwrap()).unwrap()
|
||||
};
|
||||
let payload = json!({
|
||||
"status": "draft",
|
||||
"ref": read(refs, "sheet-ref.json"),
|
||||
"document": read(&seed, "document.json"),
|
||||
"migrationMap": read(refs, "report-migration-map.json"),
|
||||
"assets": {},
|
||||
"assetHashes": {},
|
||||
});
|
||||
let data: BundledSheetData = serde_json::from_value(payload).unwrap();
|
||||
LoadedSheet::from_bundle(data).unwrap()
|
||||
}
|
||||
|
||||
/// The declared difference of the R5.6 switch for `report-compare` (`R5.6-fingerprint-v1`), per
|
||||
/// file block: a report read as is keeps its historical stamp and is the bundled sheet through
|
||||
/// the trusted alias, both raw values printed; a v2 report migrated on the switched map carries
|
||||
/// the canonical value and keeps the plain line. Only that one line changes; a report on
|
||||
/// another document still prints `!!`, so no content difference can hide behind the rule.
|
||||
fn r5_6_rule(text: &str) -> String {
|
||||
let plain = "(draft, matches the bundled sheet)";
|
||||
let alias = "(draft, matches the bundled sheet through the trusted alias: report sha 27c7383c445c…, sheet sha 12d788727c1e…)";
|
||||
let mut out = String::new();
|
||||
for (index, block) in text.split("== ").enumerate() {
|
||||
if index > 0 {
|
||||
out.push_str("== ");
|
||||
}
|
||||
if block.contains("(migrated)") {
|
||||
out.push_str(block);
|
||||
} else {
|
||||
out.push_str(&block.replace(plain, alias));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The repository as the TypeScript CLI saw it: arguments typed from the root.
|
||||
@@ -131,6 +165,10 @@ fn replay(row: &Row) -> Run {
|
||||
run(draft_sheet(), &row.args, &RepoFiles)
|
||||
}
|
||||
|
||||
fn replay_switched(row: &Row) -> Run {
|
||||
run(switched_sheet(), &row.args, &RepoFiles)
|
||||
}
|
||||
|
||||
fn assert_exact(row: &Row) {
|
||||
let got = replay(row);
|
||||
let args = row.args.join(" ");
|
||||
@@ -436,9 +474,14 @@ fn binary_prints_what_the_pure_run_prints_from_init_cwd() {
|
||||
let shapes = ["cli", "folder"];
|
||||
let mut spawned = 0;
|
||||
for row in rows.iter().filter(|r| shapes.contains(&r.group.as_str())) {
|
||||
// The binary reads the committed (switched) seed: the oracle under the declared rule.
|
||||
let got = spawn(&row.args);
|
||||
let args = row.args.join(" ");
|
||||
assert_eq!(got.stdout, row.stdout, "binary stdout of `{args}`");
|
||||
assert_eq!(
|
||||
got.stdout,
|
||||
r5_6_rule(&row.stdout),
|
||||
"binary stdout of `{args}`"
|
||||
);
|
||||
assert_eq!(got.stderr, row.stderr, "binary stderr of `{args}`");
|
||||
assert_eq!(got.exit_code, row.exit_code, "binary exit code of `{args}`");
|
||||
spawned += 1;
|
||||
@@ -449,10 +492,28 @@ fn binary_prints_what_the_pure_run_prints_from_init_cwd() {
|
||||
.iter()
|
||||
.find(|r| r.args.first().map(String::as_str) == Some("a.pdf"))
|
||||
.unwrap();
|
||||
assert_eq!(spawn(&scenario.args), replay(scenario));
|
||||
assert_eq!(spawn(&scenario.args), replay_switched(scenario));
|
||||
let full = rows
|
||||
.iter()
|
||||
.find(|r| r.args.first().map(String::as_str) == Some("--full") && r.args.len() == 2)
|
||||
.unwrap();
|
||||
assert_eq!(spawn(&full.args), replay(full));
|
||||
assert_eq!(spawn(&full.args), replay_switched(full));
|
||||
}
|
||||
|
||||
/// After R5.6, on the switched seed: every exact O10 row prints the oracle under the declared
|
||||
/// rule (the one sheet line), stderr and exit codes unchanged.
|
||||
#[test]
|
||||
fn o10_on_the_switched_seed_differs_only_by_the_declared_alias_line() {
|
||||
let mut aliased = 0;
|
||||
for row in rows().iter().filter(|r| r.declared.is_none()) {
|
||||
let got = replay_switched(row);
|
||||
let args = row.args.join(" ");
|
||||
let expected = r5_6_rule(&row.stdout);
|
||||
aliased += usize::from(expected != row.stdout);
|
||||
assert_eq!(got.stdout, expected, "stdout of `{args}`");
|
||||
assert_eq!(got.stderr, row.stderr, "stderr of `{args}`");
|
||||
assert_eq!(got.exit_code, row.exit_code, "exit code of `{args}`");
|
||||
}
|
||||
assert_eq!(aliased, 77, "rows through the alias");
|
||||
assert!(switched_sheet().is_fingerprint_verified() && !draft_sheet().is_fingerprint_verified());
|
||||
}
|
||||
Reference in new issue
Block a user