aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / crates / aien-proof / src / store_assert.rs
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | //! Stable Store qualification assertion IDs for evidence receipts. |
| 17 | //! |
| 18 | //! This module records the test that happened; it never defines Store |
| 19 | //! wire format rules. Each constant is the stable `Assertion.id` value |
| 20 | //! written into an `EvidenceReceiptV1`. |
| 21 | |
| 22 | /// Records that the observed store layout parsed as the expected format. |
| 23 | pub const STORE_FORMAT_VALID: &str = "store_format_valid"; |
| 24 | /// Records that observed object identifiers matched the expected shape. |
| 25 | pub const STORE_OBJECT_IDS_VALID: &str = "store_object_ids_valid"; |
| 26 | /// Records that the observed catalog listing matched the expected entries. |
| 27 | pub const STORE_CATALOG_VALID: &str = "store_catalog_valid"; |
| 28 | /// Records that the observed commit reference matched the expected value. |
| 29 | pub const STORE_COMMIT_VALID: &str = "store_commit_valid"; |
| 30 | /// Records that the observed full history graph traversal matched the expected result. |
| 31 | pub const STORE_FULL_GRAPH_VALID: &str = "store_full_graph_valid"; |
| 32 | /// Records that a conflicting write attempt was rejected without mutating state. |
| 33 | pub const STORE_CONFLICT_FAIL_CLOSED: &str = "store_conflict_fail_closed"; |
| 34 | /// Records that an inconsistent history input was rejected without mutating state. |
| 35 | pub const STORE_INCONSISTENT_HISTORY_FAIL_CLOSED: &str = "store_inconsistent_history_fail_closed"; |
| 36 | /// Records that an I/O error was reported instead of silent fallback content. |
| 37 | pub const STORE_IO_ERROR_NOT_FALLBACK: &str = "store_io_error_not_fallback"; |
| 38 | /// Records that a no-space condition left zero partial writes visible. |
| 39 | pub const STORE_NOSPACE_ZERO_WRITES: &str = "store_nospace_zero_writes"; |
| 40 | /// Records that after a write attempt only the previous or the new content was visible. |
| 41 | pub const STORE_PREVIOUS_OR_NEW_ONLY: &str = "store_previous_or_new_only"; |
| 42 | /// Records that opening the store produced no observable side effects. |
| 43 | pub const STORE_OPEN_SIDE_EFFECT_FREE: &str = "store_open_side_effect_free"; |
| 44 | /// Records that the store state observed after a QEMU reboot matched the expected committed state. |
| 45 | pub const STORE_QEMU_REBOOT_RECOVERED: &str = "store_qemu_reboot_recovered"; |
| 46 | |
| 47 | /// All 12 stable Store assertion IDs in canonical order. |
| 48 | pub fn store_assertion_ids() -> &'static [&'static str] { |
| 49 | &[ |
| 50 | STORE_FORMAT_VALID, |
| 51 | STORE_OBJECT_IDS_VALID, |
| 52 | STORE_CATALOG_VALID, |
| 53 | STORE_COMMIT_VALID, |
| 54 | STORE_FULL_GRAPH_VALID, |
| 55 | STORE_CONFLICT_FAIL_CLOSED, |
| 56 | STORE_INCONSISTENT_HISTORY_FAIL_CLOSED, |
| 57 | STORE_IO_ERROR_NOT_FALLBACK, |
| 58 | STORE_NOSPACE_ZERO_WRITES, |
| 59 | STORE_PREVIOUS_OR_NEW_ONLY, |
| 60 | STORE_OPEN_SIDE_EFFECT_FREE, |
| 61 | STORE_QEMU_REBOOT_RECOVERED, |
| 62 | ] |
| 63 | } |
| 64 | |
| 65 | /// Returns true when `id` is one of the 12 stable Store assertion IDs. |
| 66 | pub fn is_store_assertion(id: &str) -> bool { |
| 67 | store_assertion_ids().contains(&id) |
| 68 | } |
| 69 | |
| 70 | #[cfg(test)] |
| 71 | mod tests { |
| 72 | use super::*; |
| 73 | use std::collections::BTreeSet; |
| 74 | |
| 75 | #[test] |
| 76 | fn ids_are_non_empty_unique_and_stable() { |
| 77 | let ids = store_assertion_ids(); |
| 78 | assert_eq!(ids.len(), 12); |
| 79 | let mut seen = BTreeSet::new(); |
| 80 | for id in ids { |
| 81 | assert!(!id.is_empty(), "store assertion id must not be empty"); |
| 82 | assert!(seen.insert(*id), "duplicate store assertion id {id:?}"); |
| 83 | assert!( |
| 84 | is_store_assertion(id), |
| 85 | "is_store_assertion must accept {id:?}" |
| 86 | ); |
| 87 | } |
| 88 | assert_eq!(seen.len(), 12); |
| 89 | } |
| 90 | |
| 91 | #[test] |
| 92 | fn rejects_non_store_ids() { |
| 93 | assert!(!is_store_assertion("artifact_signature_valid")); |
| 94 | assert!(!is_store_assertion("")); |
| 95 | } |
| 96 | } |