Skip to main content

deepstrike_core/context/
fault.rs

1use serde::{Deserialize, Serialize};
2
3/// Errors/Faults that can occur during Context VM execution or replay.
4#[derive(Debug, Clone, thiserror::Error, Serialize, Deserialize)]
5pub enum ContextFault {
6    #[error("Prompt exceeds maximum token limit: budget={budget}, actual={actual}")]
7    PromptTooLong { budget: u32, actual: u32 },
8    #[error("Missing archive chunk {seq} for session {session_id}")]
9    MissingArchive { session_id: String, seq: u64 },
10    #[error("Invalid replay at turn {turn}: {reason}")]
11    InvalidReplay { turn: u32, reason: String },
12}
13
14/// FNV-1a 64-bit — the render layer's cache-stability test fingerprint dialect.
15#[cfg(test)]
16pub(crate) fn stable_hash(bytes: &[u8]) -> u64 {
17    let mut hash = 0xcbf29ce484222325u64;
18    for byte in bytes {
19        hash ^= u64::from(*byte);
20        hash = hash.wrapping_mul(0x100000001b3);
21    }
22    hash
23}