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
@@ -29,6 +29,9 @@ use faunosteo_core::curation::prettier_json::format_json;
|
||||
use faunosteo_core::domain::report::ReportMigrationMap;
|
||||
use faunosteo_core::domain::report::read::read_report_document;
|
||||
use faunosteo_core::domain::sheet::AnatomicalSheetDocument;
|
||||
use faunosteo_core::domain::sheet::fingerprint::{
|
||||
FINGERPRINT_CONVENTION, TRUSTED_ALIASES, sheet_fingerprint,
|
||||
};
|
||||
use faunosteo_core::json::to_js_compact;
|
||||
use serde_json::{Map, Value, json};
|
||||
|
||||
@@ -139,18 +142,85 @@ fn the_r5_3_files_of_the_committed_draft_folder_are_reproduced_byte_for_byte() {
|
||||
assert_eq!(frozen.len(), asset.byte_size);
|
||||
}
|
||||
|
||||
/// The declared difference of the R5.6 switch, `R5.6-fingerprint-v1` (owner 2026-10-24): from the
|
||||
/// pre-switch file the TypeScript wrote, only the fingerprint moves from the registered alias to
|
||||
/// its canonical value, and `sheet-ref.json` gains the descriptive block. Applied to a parsed
|
||||
/// value, then printed by the generator's own formatter: anything else that differs fails.
|
||||
fn r5_6_rule(name: &str, mut value: Value) -> Value {
|
||||
let pair = &TRUSTED_ALIASES[0];
|
||||
let stamp = match name {
|
||||
"sheet-ref.json" => &mut value["document_sha256"],
|
||||
"report-migration-map.json" => &mut value["sheet"]["documentSha256"],
|
||||
other => panic!("{other}: no declared rule"),
|
||||
};
|
||||
assert_eq!(
|
||||
*stamp, pair.alias,
|
||||
"{name}: the pre-switch value is the alias"
|
||||
);
|
||||
*stamp = Value::from(pair.canonical);
|
||||
if name == "sheet-ref.json" {
|
||||
value.as_object_mut().unwrap().insert(
|
||||
"fingerprint".into(),
|
||||
serde_json::json!({ "convention": FINGERPRINT_CONVENTION, "aliases": [pair.alias] }),
|
||||
);
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
fn pre_switch(name: &str) -> String {
|
||||
common::repo_file(&format!(
|
||||
"crates/core/tests/fixtures/r5-6/pre-switch/{name}"
|
||||
))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_document_fingerprint_is_the_historical_value() {
|
||||
fn the_pre_switch_copies_are_the_files_the_typescript_wrote() {
|
||||
let artifacts = oracle("pipeline.json")["artifacts"].clone();
|
||||
for name in ["sheet-ref.json", "report-migration-map.json"] {
|
||||
let row = artifacts
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.find(|a| a["file"] == name && a["folder"].as_str().unwrap().ends_with("draft"))
|
||||
.unwrap()
|
||||
.clone();
|
||||
let text = pre_switch(name);
|
||||
assert_eq!(row["sha256"], sha256_hex(text.as_bytes()), "{name}");
|
||||
assert_eq!(row["bytes"], text.len(), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_switch_changes_only_the_fingerprint_of_the_two_files() {
|
||||
for name in ["sheet-ref.json", "report-migration-map.json"] {
|
||||
let before: Value = serde_json::from_str(&pre_switch(name)).unwrap();
|
||||
let expected = format_json(&r5_6_rule(name, before)).unwrap();
|
||||
assert!(
|
||||
expected == common::repo_file(&format!("{DRAFT}/{name}")),
|
||||
"{name}: the committed file is not the pre-switch one under R5.6-fingerprint-v1"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_document_fingerprint_is_v1_and_its_bytes_keep_the_historical_alias() {
|
||||
let files = render_draft_artifacts(&equine_draft(), &[]).unwrap();
|
||||
let document = &files[0].1;
|
||||
let reference: Value = serde_json::from_str(&files[2].1).unwrap();
|
||||
let pair = &TRUSTED_ALIASES[0];
|
||||
assert_eq!(sha256_hex(document.as_bytes()), pair.alias);
|
||||
assert_eq!(
|
||||
reference["document_sha256"],
|
||||
sha256_hex(document.as_bytes())
|
||||
sheet_fingerprint(document).unwrap()
|
||||
);
|
||||
assert_eq!(reference["document_sha256"], pair.canonical);
|
||||
assert_eq!(
|
||||
reference["fingerprint"]["convention"],
|
||||
FINGERPRINT_CONVENTION
|
||||
);
|
||||
assert_eq!(
|
||||
reference["document_sha256"],
|
||||
"27c7383c445c73dc2001ebf4794a3ea63d416910bbbaa0d7848dd720de7c2660"
|
||||
reference["fingerprint"]["aliases"],
|
||||
serde_json::json!([pair.alias])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user