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

+29 -9
View File
@@ -8,6 +8,9 @@
//! asset id) and copies them, and never re-cleans the legacy drawing. The review drawings and
//! the two Markdown reports are R5.4.
use crate::domain::sheet::fingerprint::{
FINGERPRINT_CONVENTION, TRUSTED_ALIASES, sheet_fingerprint,
};
use serde_json::{Map, Value, json};
use crate::json::to_js_compact;
@@ -165,14 +168,25 @@ pub fn build_equine_draft(input: &DraftInput<'_>) -> Result<DraftResult, Pipelin
})
}
/// What a report references: the sheet and the exact document bytes (the historical rule,
/// kept until the R5.6 switch).
fn sheet_ref(draft: &DraftResult, document_json: &str) -> SheetRef {
SheetRef {
/// What a report references: the sheet and its `sha256-rfc8785-validated-v1` fingerprint
/// (R5.6; the pre-switch rule hashed the formatted bytes, kept as a registered alias).
fn sheet_ref(draft: &DraftResult, document_json: &str) -> Result<SheetRef, PipelineError> {
let fingerprint = sheet_fingerprint(document_json)
.map_err(|error| fail(format!("document fingerprint: {error:?}")))?;
Ok(SheetRef {
sheet_id: draft.sheet_id.clone(),
version_id: None,
document_sha256: sha256_hex(document_json.as_bytes()),
}
document_sha256: fingerprint,
})
}
/// The registered aliases of this sheet's canonical value (descriptive in `sheet-ref.json`).
fn registered_aliases(reference: &SheetRef) -> Vec<&'static str> {
TRUSTED_ALIASES
.iter()
.filter(|e| e.sheet_id == reference.sheet_id && e.canonical == reference.document_sha256)
.map(|e| e.alias)
.collect()
}
/// The migration map (`report-migration-map.json` value) and its stats.
@@ -268,7 +282,7 @@ pub fn review_drawings_bytes(draft: &DraftResult) -> Result<usize, PipelineError
/// One review overlay per view (`review/annotations-<view>.svg`), then the application's
/// drawing of each view (`review/app-<view>.svg`).
fn review_drawings(draft: &DraftResult) -> Result<Vec<(String, String)>, PipelineError> {
pub fn review_drawings(draft: &DraftResult) -> Result<Vec<(String, String)>, PipelineError> {
let projected = review_drawings_bytes(draft)?;
if projected > MAX_REVIEW_DRAWINGS_BYTES {
return Err(fail(format!(
@@ -307,7 +321,9 @@ pub fn render_draft_artifacts(
legacy_anomalies: &[Anomaly],
) -> Result<Vec<(String, String)>, PipelineError> {
let document_json = format_json(&draft.document)?;
let reference = sheet_ref(draft, &document_json);
// The drawings' resource bound applies before the fingerprint validates the document.
let drawings = review_drawings(draft)?;
let reference = sheet_ref(draft, &document_json)?;
let (map, migration_stats) = draft_migration_map(draft, &reference)?;
let assets = serde_json::to_value(&draft.assets)
.map_err(|error| fail(format!("assets.json: {error}")))?;
@@ -317,6 +333,10 @@ pub fn render_draft_artifacts(
"document_sha256": reference.document_sha256,
"schema_version": draft.document.get("schema_version"),
"species_id": draft.document.get("species_id"),
"fingerprint": {
"convention": FINGERPRINT_CONVENTION,
"aliases": registered_aliases(&reference),
},
});
let changelog = render_changelog(
&draft.records,
@@ -343,7 +363,7 @@ pub fn render_draft_artifacts(
(SHEET_REF_FILE.to_owned(), format_json(&sheet_ref_json)?),
(MIGRATION_MAP_FILE.to_owned(), format_json(&map)?),
];
files.extend(review_drawings(draft)?);
files.extend(drawings);
files.push(("CHANGELOG.md".to_owned(), format_report(&changelog)?));
files.push(("REVIEW-REPORT.md".to_owned(), format_report(&review)?));
files.push((DRAFT_SEED_SQL_FILE.to_owned(), seed));