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
@@ -5,12 +5,13 @@
|
||||
//! every fixture PDF's attachment) under the comparison the five consumers will use.
|
||||
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
mod archive_support;
|
||||
mod common;
|
||||
|
||||
use faunosteo_core::domain::js::parse_json;
|
||||
use faunosteo_core::domain::sheet::fingerprint::{
|
||||
AliasRefusal, Equivalence, FINGERPRINT_CONVENTION, FingerprintError, TRUSTED_ALIASES,
|
||||
canonical_json, check_declared, equivalence, sheet_fingerprint,
|
||||
AliasRefusal, FINGERPRINT_CONVENTION, FingerprintError, TRUSTED_ALIASES, canonical_json,
|
||||
check_declared, sheet_fingerprint,
|
||||
};
|
||||
use faunosteo_core::pdf::read::probe::{ProbeLimits, read_attached_document};
|
||||
use serde_json::Value;
|
||||
@@ -120,34 +121,20 @@ fn an_invalid_or_malformed_document_has_no_fingerprint() {
|
||||
|
||||
#[test]
|
||||
fn the_registry_holds_one_pair_bound_to_the_equine_sheet() {
|
||||
// The comparison itself is crate-private (its unit test sits in `fingerprint.rs`); the
|
||||
// consumers reach it only through `LoadedSheet::recognises_historical_stamp`.
|
||||
assert_eq!(TRUSTED_ALIASES.len(), 1);
|
||||
assert_eq!(FINGERPRINT_CONVENTION, "sha256-rfc8785-validated-v1");
|
||||
let pair = &TRUSTED_ALIASES[0];
|
||||
assert_eq!(
|
||||
equivalence(SHEET, CANONICAL, CANONICAL),
|
||||
Equivalence::Identical
|
||||
);
|
||||
assert_eq!(
|
||||
equivalence(SHEET, CANONICAL, ALIAS),
|
||||
Equivalence::TrustedAlias
|
||||
);
|
||||
assert_eq!(
|
||||
equivalence(SHEET, ALIAS, CANONICAL),
|
||||
Equivalence::TrustedAlias
|
||||
);
|
||||
let other_sheet = "00000000-0000-0000-0000-000000000000";
|
||||
assert_eq!(
|
||||
equivalence(other_sheet, CANONICAL, ALIAS),
|
||||
Equivalence::Different
|
||||
);
|
||||
let other_content = "a".repeat(64);
|
||||
assert_eq!(
|
||||
equivalence(SHEET, &other_content, ALIAS),
|
||||
Equivalence::Different
|
||||
);
|
||||
assert_eq!(
|
||||
equivalence(SHEET, &other_content, CANONICAL),
|
||||
Equivalence::Different
|
||||
(pair.sheet_id, pair.alias, pair.canonical),
|
||||
(SHEET, ALIAS, CANONICAL)
|
||||
);
|
||||
let sheet = archive_support::draft_sheet();
|
||||
assert!(sheet.recognises_historical_stamp(SHEET, ALIAS));
|
||||
assert!(!sheet.recognises_historical_stamp(SHEET, CANONICAL));
|
||||
assert!(!sheet.recognises_historical_stamp(SHEET, &"a".repeat(64)));
|
||||
assert!(!sheet.recognises_historical_stamp("00000000-0000-0000-0000-000000000000", ALIAS));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -239,12 +226,17 @@ fn historical_archives_open_as_the_same_document_only_through_the_registered_pai
|
||||
stamps(&value, &mut found);
|
||||
}
|
||||
}
|
||||
assert!(pdfs > 50, "{pdfs} attachments read");
|
||||
assert_eq!(pdfs, 147, "attachments read");
|
||||
let loaded = archive_support::draft_sheet();
|
||||
assert_eq!(loaded.reference.document_sha256, CANONICAL);
|
||||
let mut same = 0;
|
||||
for (sheet, sha) in &found {
|
||||
let verdict = equivalence(sheet, sha, CANONICAL);
|
||||
// What the rebase decides: equal values, or the proven historical stamp of this sheet.
|
||||
let recognised = *sha == loaded.reference.document_sha256
|
||||
|| (*sheet == loaded.reference.sheet_id
|
||||
&& loaded.recognises_historical_stamp(sheet, sha));
|
||||
let expected = sheet == SHEET && sha == ALIAS;
|
||||
assert_eq!(verdict.same_document(), expected, "{sheet} {sha}");
|
||||
assert_eq!(recognised, expected, "{sheet} {sha}");
|
||||
same += usize::from(expected);
|
||||
}
|
||||
// Every authentic stamp of the equine draft is the alias; the synthetic ones stay different.
|
||||
@@ -252,7 +244,7 @@ fn historical_archives_open_as_the_same_document_only_through_the_registered_pai
|
||||
"census: {pdfs} PDF attachments, {} stamps, {same} alias",
|
||||
found.len()
|
||||
);
|
||||
assert!(same > 30, "{same} of {}", found.len());
|
||||
assert_eq!((found.len(), same), (124, 123), "stamps, aliases");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -268,3 +260,27 @@ fn v1_never_carries_the_historical_value_or_a_malformed_one() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn nested(depth: usize) -> Value {
|
||||
let mut value = Value::from(1);
|
||||
for _ in 0..depth {
|
||||
value = Value::Array(vec![value]);
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nesting_is_bounded_with_a_controlled_error() {
|
||||
use faunosteo_core::domain::sheet::fingerprint::{CanonicalError, MAX_CANONICAL_DEPTH};
|
||||
assert_eq!(MAX_CANONICAL_DEPTH, 128);
|
||||
assert!(canonical_json(&nested(MAX_CANONICAL_DEPTH)).is_ok());
|
||||
assert_eq!(
|
||||
canonical_json(&nested(MAX_CANONICAL_DEPTH + 1)),
|
||||
Err(CanonicalError::TooDeep)
|
||||
);
|
||||
let mut object = Value::from(1);
|
||||
for _ in 0..=MAX_CANONICAL_DEPTH {
|
||||
object = serde_json::json!({ "k": object });
|
||||
}
|
||||
assert_eq!(canonical_json(&object), Err(CanonicalError::TooDeep));
|
||||
}
|
||||
Reference in new issue
Block a user