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 / spark-aegis / src / doctrine.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 | // spark-aegis Sovereign Defensive Boundary and Containment Engine |
| 17 | // Pure Native Rust Systems Architecture |
| 18 | |
| 19 | use serde::{Deserialize, Serialize}; |
| 20 | use std::path::PathBuf; |
| 21 | |
| 22 | pub const DOCTRINE_STATEMENT: &str = |
| 23 | "The network is the house. Cut the session. Isolate the host. Close the door. Keep the evidence."; |
| 24 | |
| 25 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] |
| 26 | pub enum ContainmentActionKind { |
| 27 | CutSession, |
| 28 | IsolateHost, |
| 29 | CloseDoor, |
| 30 | KeepEvidence, |
| 31 | } |
| 32 | |
| 33 | impl ContainmentActionKind { |
| 34 | pub fn name(&self) -> &'static str { |
| 35 | match self { |
| 36 | Self::CutSession => "CutSession", |
| 37 | Self::IsolateHost => "IsolateHost", |
| 38 | Self::CloseDoor => "CloseDoor", |
| 39 | Self::KeepEvidence => "KeepEvidence", |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | pub fn directive(&self) -> &'static str { |
| 44 | match self { |
| 45 | Self::CutSession => "Cut the session.", |
| 46 | Self::IsolateHost => "Isolate the host.", |
| 47 | Self::CloseDoor => "Close the door.", |
| 48 | Self::KeepEvidence => "Keep the evidence.", |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | pub fn description(&self) -> &'static str { |
| 53 | match self { |
| 54 | Self::CutSession => "Terminate active unauthorized interactive or socket sessions immediately.", |
| 55 | Self::IsolateHost => "Suspend, sever, and isolate compromised host processes from execution.", |
| 56 | Self::CloseDoor => "Quarantine filesystem targets and revoke all access permissions.", |
| 57 | Self::KeepEvidence => "Compute Blake3 cryptographic integrity hash and commit durable audit record to Cortex.", |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | #[derive(Debug, Clone, Serialize, Deserialize)] |
| 63 | pub enum ContainmentAction { |
| 64 | CutSession { |
| 65 | session_id: String, |
| 66 | }, |
| 67 | IsolateHost { |
| 68 | process_id: u32, |
| 69 | }, |
| 70 | CloseDoor { |
| 71 | target_path: PathBuf, |
| 72 | }, |
| 73 | KeepEvidence { |
| 74 | incident_id: String, |
| 75 | blake3_hash: String, |
| 76 | }, |
| 77 | } |
| 78 | |
| 79 | impl ContainmentAction { |
| 80 | pub fn kind(&self) -> ContainmentActionKind { |
| 81 | match self { |
| 82 | Self::CutSession { .. } => ContainmentActionKind::CutSession, |
| 83 | Self::IsolateHost { .. } => ContainmentActionKind::IsolateHost, |
| 84 | Self::CloseDoor { .. } => ContainmentActionKind::CloseDoor, |
| 85 | Self::KeepEvidence { .. } => ContainmentActionKind::KeepEvidence, |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] |
| 91 | pub enum AegisInvariant { |
| 92 | ZeroDiskSecrets, |
| 93 | SovereignVoice, |
| 94 | PureCompiledArchitecture, |
| 95 | ImmutableAuditTrail, |
| 96 | } |
| 97 | |
| 98 | impl AegisInvariant { |
| 99 | pub fn code(&self) -> &'static str { |
| 100 | match self { |
| 101 | Self::ZeroDiskSecrets => "SECURE_TPM_ONLY", |
| 102 | Self::SovereignVoice => "UNSLOP_COMPLIANCE", |
| 103 | Self::PureCompiledArchitecture => "PURE_NATIVE_SYSTEMS", |
| 104 | Self::ImmutableAuditTrail => "BLAKE3_CORTEX_TRAIL", |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | pub fn description(&self) -> &'static str { |
| 109 | match self { |
| 110 | Self::ZeroDiskSecrets => { |
| 111 | "Plaintext secrets and .env files must never touch disk. All credentials must resolve via hardware TPM vault." |
| 112 | } |
| 113 | Self::SovereignVoice => { |
| 114 | "Strict zero em dash and en dash policy. Ban AI buzzwords, transitional filler, and antithesis tropes." |
| 115 | } |
| 116 | Self::PureCompiledArchitecture => { |
| 117 | "Core security and agent runtime engines must compile to native Rust binaries." |
| 118 | } |
| 119 | Self::ImmutableAuditTrail => { |
| 120 | "Every defensive incident and PR audit must commit Blake3 cryptographic proof into Cortex memory." |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | pub fn all_invariants() -> &'static [AegisInvariant] { |
| 127 | &[ |
| 128 | AegisInvariant::ZeroDiskSecrets, |
| 129 | AegisInvariant::SovereignVoice, |
| 130 | AegisInvariant::PureCompiledArchitecture, |
| 131 | AegisInvariant::ImmutableAuditTrail, |
| 132 | ] |
| 133 | } |
| 134 | |
| 135 | #[cfg(test)] |
| 136 | mod tests { |
| 137 | use super::*; |
| 138 | |
| 139 | #[test] |
| 140 | fn test_doctrine_statement() { |
| 141 | assert_eq!( |
| 142 | DOCTRINE_STATEMENT, |
| 143 | "The network is the house. Cut the session. Isolate the host. Close the door. Keep the evidence." |
| 144 | ); |
| 145 | } |
| 146 | |
| 147 | #[test] |
| 148 | fn test_containment_action_kinds() { |
| 149 | let action = ContainmentAction::CutSession { |
| 150 | session_id: "test-session-42".to_string(), |
| 151 | }; |
| 152 | assert_eq!(action.kind(), ContainmentActionKind::CutSession); |
| 153 | assert_eq!(action.kind().directive(), "Cut the session."); |
| 154 | |
| 155 | let isolate = ContainmentAction::IsolateHost { process_id: 1234 }; |
| 156 | assert_eq!(isolate.kind(), ContainmentActionKind::IsolateHost); |
| 157 | assert_eq!(isolate.kind().directive(), "Isolate the host."); |
| 158 | |
| 159 | let door = ContainmentAction::CloseDoor { |
| 160 | target_path: PathBuf::from("/tmp/badfile"), |
| 161 | }; |
| 162 | assert_eq!(door.kind(), ContainmentActionKind::CloseDoor); |
| 163 | assert_eq!(door.kind().directive(), "Close the door."); |
| 164 | |
| 165 | let ev = ContainmentAction::KeepEvidence { |
| 166 | incident_id: "inc-1".to_string(), |
| 167 | blake3_hash: "abcd".to_string(), |
| 168 | }; |
| 169 | assert_eq!(ev.kind(), ContainmentActionKind::KeepEvidence); |
| 170 | assert_eq!(ev.kind().directive(), "Keep the evidence."); |
| 171 | } |
| 172 | |
| 173 | #[test] |
| 174 | fn test_all_invariants_present() { |
| 175 | let inv = all_invariants(); |
| 176 | assert_eq!(inv.len(), 4); |
| 177 | assert_eq!(inv[0].code(), "SECURE_TPM_ONLY"); |
| 178 | } |
| 179 | } |