From c63f68f73f6d2152f9fb6f631cee2fc1fceaea89 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Thu, 5 Nov 2026 21:01:31 +0100 Subject: [PATCH] STRA-338 S5a: pin the identity digests with golden values before they are unified identity_digests_match_their_golden_values fixes the output of the twelve digest functions of backend.rs (optimized with and without profile, queued owners, streamed spill, retained scratch, resident owners, adaptive slots, original serve, kar expert, execution mode, mtp mode, kar mode) on fixed small inputs. The values were produced by the unmodified functions; the test lives in backend/digests_golden.rs, the first child module of the directory the split fills next. --- crates/leleka-runtime/src/backend.rs | 3 + .../src/backend/digests_golden.rs | 75 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 crates/leleka-runtime/src/backend/digests_golden.rs diff --git a/crates/leleka-runtime/src/backend.rs b/crates/leleka-runtime/src/backend.rs index 7ce98d88..1475cf13 100644 --- a/crates/leleka-runtime/src/backend.rs +++ b/crates/leleka-runtime/src/backend.rs @@ -3768,6 +3768,9 @@ mod native_down_public_pair; #[path = "gpu_proofs/native_down_candidate_only.rs"] mod native_down_candidate_only; +#[cfg(test)] +mod digests_golden; + #[cfg(test)] mod streamed_spill_policy_tests { use super::*; diff --git a/crates/leleka-runtime/src/backend/digests_golden.rs b/crates/leleka-runtime/src/backend/digests_golden.rs new file mode 100644 index 00000000..0476e190 --- /dev/null +++ b/crates/leleka-runtime/src/backend/digests_golden.rs @@ -0,0 +1,75 @@ +//! Golden values of every identity digest on fixed inputs, taken from the code as it was before the digest functions +//! were unified (STRA-338 S5a). A change here is a change of the `mode_identity_digest` a running service publishes. +use super::*; + +const BOUND: &str = "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + +#[test] +fn identity_digests_match_their_golden_values() { + let profile = RANKED_EXPERT_PROFILE_SHA; + let golden: [(&str, String, &str); 12] = [ + ( + "optimized without profile", + optimized_execution_digest(BOUND, None), + "sha256:4dc24ef3e7d280d4e5483fbb50d18fb9254e97e999ce7dfb2bd2be508db6a984", + ), + ( + "optimized with profile", + optimized_execution_digest(BOUND, Some(profile)), + "sha256:a8817a67f8f68bb0684a6651836cadc2cc36b5c8dd4828553996f709b8e8a04b", + ), + ( + "queued owners", + queued_owners_execution_digest(BOUND, profile), + "sha256:cc7d334b4eb726e8bac24ab5de32f3b3a9a23649a7f759014b72b8246aba6aba", + ), + ( + "streamed spill", + streamed_spill_execution_digest(BOUND, profile), + "sha256:713bf52214d58605db81c971266dae25b9e66495d52db1c76996665975d5c473", + ), + ( + "retained scratch", + retained_scratch_execution_digest(BOUND, profile), + "sha256:780249b732c71d4b95290fa10d26dd25a1d53761547cc6987ed86c32ce1a776a", + ), + ( + "resident owners", + resident_owners_execution_digest(BOUND, profile), + "sha256:c629d7629a0a3a3a9f57362eac601ef75598573da63b6afd2c0054d0cacca4da", + ), + ( + "adaptive slots", + adaptive_slots_execution_digest(BOUND, profile), + "sha256:b0668706ffe2095b700982849598f5980df78c039d367ab7dd9c54a085eab624", + ), + ( + "original serve", + original_serve_execution_digest(BOUND), + "sha256:5e712fad69be8561f847a294460b2583dd2ae37b81d4c818c4862f154d5ff130", + ), + ( + "kar expert mode", + kar_expert_mode_digest(BOUND, &[7u8; 32]), + "sha256:d23577e8eb2da7fdf18cf57ef71e05b5c22601cd0fff65c21134a75d06143453", + ), + ( + "execution mode", + execution_mode_digest(BOUND), + "sha256:929698db8cb37f5513b1f6e5e080baac7cd5301f820f2385331cbf699b64546c", + ), + ( + "mtp mode", + mtp_mode_digest(BOUND, KAR_MTP_PROFILE, ["pin-a", "pin-b", "pin-c"]), + "sha256:cfd01b767d66a015d9e29f77bee84d606ea759a13e06d50b80129c14f474c98f", + ), + ( + "kar mode", + kar_mode_digest(&[1u8; 32], &[2u8; 32]), + "sha256:8481f48e452c12ca1c2351f2079d29c1ee2459ab45e86c06f67b2fe6217530a3", + ), + ]; + for (name, got, want) in golden { + assert_eq!(got, want, "{name} digest changed"); + } +}