Skip to main content

qualia_core_db/tensor/
quantum.rs

1//! Quantum context (q) for epistemic superposition and wavefunction collapse
2
3use serde::{Deserialize, Serialize};
4
5/// Quantum context state
6#[repr(C)]
7#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
8pub enum QuantumState {
9    /// Collapsed Ground Truth (q = 0)
10    GroundTruth = 0,
11    /// Parallel epistemic context (q > 0)
12    ParallelContext = 1,
13    /// Pending GSR resolution ("In Escrow")
14    InEscrow = 2,
15    /// Sandbox evaluation (e.g., isolated q=999)
16    Sandbox = 3,
17}
18
19impl Default for QuantumState {
20    fn default() -> Self {
21        QuantumState::GroundTruth
22    }
23}
24
25impl QuantumState {
26    pub fn from_q_value(q: f32) -> Self {
27        if q == 0.0 {
28            QuantumState::GroundTruth
29        } else if q >= 999.0 {
30            QuantumState::Sandbox
31        } else {
32            QuantumState::ParallelContext
33        }
34    }
35
36    pub fn to_q_value(&self) -> f32 {
37        match self {
38            QuantumState::GroundTruth => 0.0,
39            QuantumState::ParallelContext => 1.0,
40            QuantumState::InEscrow => 2.0,
41            QuantumState::Sandbox => 999.0,
42        }
43    }
44}