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-inquisitor / tests / constitutional_rules.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 | use spark_inquisitor::audit::DiffAuditor; |
| 17 | |
| 18 | #[test] |
| 19 | fn test_em_dash_detected_in_code_comments() { |
| 20 | let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+// Important note \u{2014} do not delete this function\npub fn keep() {}"; |
| 21 | let report = DiffAuditor::audit_text(diff); |
| 22 | assert!(!report.clean); |
| 23 | assert!(report |
| 24 | .unslop_violations |
| 25 | .iter() |
| 26 | .any(|u| u.contains("Em/En dash detected"))); |
| 27 | } |
| 28 | |
| 29 | #[test] |
| 30 | fn test_em_dash_detected_in_string_literals() { |
| 31 | let diff = |
| 32 | "diff --git a/src/lib.rs b/src/lib.rs\n+pub const SLOGAN: &str = \"speed \u{2014} power\";"; |
| 33 | let report = DiffAuditor::audit_text(diff); |
| 34 | assert!(!report.clean); |
| 35 | assert!(report |
| 36 | .unslop_violations |
| 37 | .iter() |
| 38 | .any(|u| u.contains("Em/En dash detected"))); |
| 39 | } |
| 40 | |
| 41 | #[test] |
| 42 | fn test_em_dash_detected_in_markdown() { |
| 43 | let diff = |
| 44 | "diff --git a/README.md b/README.md\n+- Core Feature \u{2014} high throughput engine"; |
| 45 | let report = DiffAuditor::audit_text(diff); |
| 46 | assert!(!report.clean); |
| 47 | assert!(report |
| 48 | .unslop_violations |
| 49 | .iter() |
| 50 | .any(|u| u.contains("Em/En dash detected"))); |
| 51 | } |
| 52 | |
| 53 | #[test] |
| 54 | fn test_en_dash_detected_in_code_comments() { |
| 55 | let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+// Range 10\u{2013}20 items"; |
| 56 | let report = DiffAuditor::audit_text(diff); |
| 57 | assert!(!report.clean); |
| 58 | assert!(report |
| 59 | .unslop_violations |
| 60 | .iter() |
| 61 | .any(|u| u.contains("Em/En dash detected"))); |
| 62 | } |
| 63 | |
| 64 | #[test] |
| 65 | fn test_en_dash_detected_in_string_literals() { |
| 66 | let diff = "diff --git a/src/lib.rs b/src/lib.rs\n+let header = \"Version 1.0\u{2013}beta\";"; |
| 67 | let report = DiffAuditor::audit_text(diff); |
| 68 | assert!(!report.clean); |
| 69 | assert!(report |
| 70 | .unslop_violations |
| 71 | .iter() |
| 72 | .any(|u| u.contains("Em/En dash detected"))); |
| 73 | } |
| 74 | |
| 75 | #[test] |
| 76 | fn test_en_dash_detected_in_markdown() { |
| 77 | let diff = "diff --git a/DOCS.md b/DOCS.md\n+Pages 5\u{2013}10 contain benchmarks."; |
| 78 | let report = DiffAuditor::audit_text(diff); |
| 79 | assert!(!report.clean); |
| 80 | assert!(report |
| 81 | .unslop_violations |
| 82 | .iter() |
| 83 | .any(|u| u.contains("Em/En dash detected"))); |
| 84 | } |
| 85 | |
| 86 | #[test] |
| 87 | fn test_banned_buzzword_delve() { |
| 88 | let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Let us delve into the architecture"; |
| 89 | let report = DiffAuditor::audit_text(diff); |
| 90 | assert!(!report.clean); |
| 91 | assert!(report.unslop_violations.iter().any(|u| u.contains("delve"))); |
| 92 | } |
| 93 | |
| 94 | #[test] |
| 95 | fn test_banned_buzzword_tapestry() { |
| 96 | let diff = "diff --git a/src/main.rs b/src/main.rs\n+// A rich tapestry of microservices"; |
| 97 | let report = DiffAuditor::audit_text(diff); |
| 98 | assert!(!report.clean); |
| 99 | assert!(report |
| 100 | .unslop_violations |
| 101 | .iter() |
| 102 | .any(|u| u.contains("tapestry"))); |
| 103 | } |
| 104 | |
| 105 | #[test] |
| 106 | fn test_banned_buzzword_testament() { |
| 107 | let diff = |
| 108 | "diff --git a/src/main.rs b/src/main.rs\n+// This code is a testament to our engineering"; |
| 109 | let report = DiffAuditor::audit_text(diff); |
| 110 | assert!(!report.clean); |
| 111 | assert!(report |
| 112 | .unslop_violations |
| 113 | .iter() |
| 114 | .any(|u| u.contains("testament"))); |
| 115 | } |
| 116 | |
| 117 | #[test] |
| 118 | fn test_banned_buzzword_beacon_trope() { |
| 119 | let diff = |
| 120 | "diff --git a/src/main.rs b/src/main.rs\n+// Standing as a beacon of hope for open source"; |
| 121 | let report = DiffAuditor::audit_text(diff); |
| 122 | assert!(!report.clean); |
| 123 | assert!(report |
| 124 | .unslop_violations |
| 125 | .iter() |
| 126 | .any(|u| u.contains("beacon"))); |
| 127 | } |
| 128 | |
| 129 | #[test] |
| 130 | fn test_beacon_hardware_term_allowed() { |
| 131 | let diff = "diff --git a/src/net.rs b/src/net.rs\n+fn parse_ble_beacon_packet(frame: &[u8]) -> bool { true }"; |
| 132 | let report = DiffAuditor::audit_text(diff); |
| 133 | assert!(report.clean); |
| 134 | } |
| 135 | |
| 136 | #[test] |
| 137 | fn test_banned_buzzword_crucial() { |
| 138 | let diff = |
| 139 | "diff --git a/src/main.rs b/src/main.rs\n+// It is crucial to preserve cache coherence"; |
| 140 | let report = DiffAuditor::audit_text(diff); |
| 141 | assert!(!report.clean); |
| 142 | assert!(report |
| 143 | .unslop_violations |
| 144 | .iter() |
| 145 | .any(|u| u.contains("crucial"))); |
| 146 | } |
| 147 | |
| 148 | #[test] |
| 149 | fn test_banned_buzzword_pivotal() { |
| 150 | let diff = |
| 151 | "diff --git a/src/main.rs b/src/main.rs\n+// A pivotal refactor for the memory engine"; |
| 152 | let report = DiffAuditor::audit_text(diff); |
| 153 | assert!(!report.clean); |
| 154 | assert!(report |
| 155 | .unslop_violations |
| 156 | .iter() |
| 157 | .any(|u| u.contains("pivotal"))); |
| 158 | } |
| 159 | |
| 160 | #[test] |
| 161 | fn test_banned_buzzword_elevate() { |
| 162 | let diff = |
| 163 | "diff --git a/src/main.rs b/src/main.rs\n+// Designed to elevate the computing experience"; |
| 164 | let report = DiffAuditor::audit_text(diff); |
| 165 | assert!(!report.clean); |
| 166 | assert!(report |
| 167 | .unslop_violations |
| 168 | .iter() |
| 169 | .any(|u| u.contains("elevate"))); |
| 170 | } |
| 171 | |
| 172 | #[test] |
| 173 | fn test_elevate_flag_allowed() { |
| 174 | let diff = "diff --git a/src/cli.rs b/src/cli.rs\n+let flag = \"--elevate-privileges\";"; |
| 175 | let report = DiffAuditor::audit_text(diff); |
| 176 | assert!(report.clean); |
| 177 | } |
| 178 | |
| 179 | #[test] |
| 180 | fn test_banned_buzzword_game_changer() { |
| 181 | let diff = "diff --git a/src/main.rs b/src/main.rs\n+// The new allocator is a game-changer"; |
| 182 | let report = DiffAuditor::audit_text(diff); |
| 183 | assert!(!report.clean); |
| 184 | assert!(report |
| 185 | .unslop_violations |
| 186 | .iter() |
| 187 | .any(|u| u.contains("game-changer"))); |
| 188 | } |
| 189 | |
| 190 | #[test] |
| 191 | fn test_banned_buzzword_unleash() { |
| 192 | let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Unleash the power of local silicon"; |
| 193 | let report = DiffAuditor::audit_text(diff); |
| 194 | assert!(!report.clean); |
| 195 | assert!(report |
| 196 | .unslop_violations |
| 197 | .iter() |
| 198 | .any(|u| u.contains("unleash"))); |
| 199 | } |
| 200 | |
| 201 | #[test] |
| 202 | fn test_unleash_flag_allowed() { |
| 203 | let diff = "diff --git a/src/args.rs b/src/args.rs\n+if args.contains(&\"--unleash-features\".to_string()) {}"; |
| 204 | let report = DiffAuditor::audit_text(diff); |
| 205 | assert!(report.clean); |
| 206 | } |
| 207 | |
| 208 | #[test] |
| 209 | fn test_banned_buzzword_harness_verb() { |
| 210 | let diff = "diff --git a/src/main.rs b/src/main.rs\n+// We can harness the full throughput of GPU nodes"; |
| 211 | let report = DiffAuditor::audit_text(diff); |
| 212 | assert!(!report.clean); |
| 213 | assert!(report |
| 214 | .unslop_violations |
| 215 | .iter() |
| 216 | .any(|u| u.contains("harness"))); |
| 217 | } |
| 218 | |
| 219 | #[test] |
| 220 | fn test_harness_noun_and_test_harness_allowed() { |
| 221 | let diff = "diff --git a/src/harness.rs b/src/harness.rs\n+// Verification test harness runner\npub struct TestHarness;"; |
| 222 | let report = DiffAuditor::audit_text(diff); |
| 223 | assert!(report.clean); |
| 224 | } |
| 225 | |
| 226 | #[test] |
| 227 | fn test_allowed_word_seamlessly() { |
| 228 | let diff = |
| 229 | "diff --git a/src/main.rs b/src/main.rs\n+// Coordinates seamlessly across all instances"; |
| 230 | let report = DiffAuditor::audit_text(diff); |
| 231 | assert!(report.clean); |
| 232 | } |
| 233 | |
| 234 | #[test] |
| 235 | fn test_antithesis_trope_not_x_but_y() { |
| 236 | let diff = |
| 237 | "diff --git a/src/main.rs b/src/main.rs\n+// It is not speed, but correctness that matters"; |
| 238 | let report = DiffAuditor::audit_text(diff); |
| 239 | assert!(!report.clean); |
| 240 | assert!(report |
| 241 | .unslop_violations |
| 242 | .iter() |
| 243 | .any(|u| u.contains("antithesis trope"))); |
| 244 | } |
| 245 | |
| 246 | #[test] |
| 247 | fn test_antithesis_trope_not_only_x_but_y() { |
| 248 | let diff = "diff --git a/src/main.rs b/src/main.rs\n+// Not only fast, but completely reliable across all tests"; |
| 249 | let report = DiffAuditor::audit_text(diff); |
| 250 | assert!(!report.clean); |
| 251 | assert!(report |
| 252 | .unslop_violations |
| 253 | .iter() |
| 254 | .any(|u| u.contains("antithesis trope"))); |
| 255 | } |
| 256 | |
| 257 | #[test] |
| 258 | fn test_plaintext_secret_aws_access_key() { |
| 259 | let diff = "diff --git a/src/vault.rs b/src/vault.rs\n+let aws_key = \"AKIA1234567890ABCDEF\";"; |
| 260 | let report = DiffAuditor::audit_text(diff); |
| 261 | assert!(!report.clean); |
| 262 | assert!(report |
| 263 | .secret_violations |
| 264 | .iter() |
| 265 | .any(|s| s.contains("AWS Access Key"))); |
| 266 | } |
| 267 | |
| 268 | #[test] |
| 269 | fn test_plaintext_secret_github_pat() { |
| 270 | let diff = "diff --git a/src/auth.rs b/src/auth.rs\n+let token = \"ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";"; |
| 271 | let report = DiffAuditor::audit_text(diff); |
| 272 | assert!(!report.clean); |
| 273 | assert!(report |
| 274 | .secret_violations |
| 275 | .iter() |
| 276 | .any(|s| s.contains("GitHub Personal Access Token"))); |
| 277 | } |
| 278 | |
| 279 | #[test] |
| 280 | fn test_plaintext_secret_github_fine_grained_pat() { |
| 281 | let diff = "diff --git a/src/auth.rs b/src/auth.rs\n+let token = \"github_pat_11AAAAAAA01234567890abcdefghijklmnopqrstuvwxyz_01234567890abcdef\";"; |
| 282 | let report = DiffAuditor::audit_text(diff); |
| 283 | assert!(!report.clean); |
| 284 | assert!(report |
| 285 | .secret_violations |
| 286 | .iter() |
| 287 | .any(|s| s.contains("GitHub Personal Access Token"))); |
| 288 | } |
| 289 | |
| 290 | #[test] |
| 291 | fn test_plaintext_secret_rsa_private_key() { |
| 292 | let diff = "diff --git a/src/crypto.rs b/src/crypto.rs\n+const KEY: &str = \"-----BEGIN RSA PRIVATE KEY-----\\nMIIEowIBAAKCAQEA...\";"; |
| 293 | let report = DiffAuditor::audit_text(diff); |
| 294 | assert!(!report.clean); |
| 295 | assert!(report |
| 296 | .secret_violations |
| 297 | .iter() |
| 298 | .any(|s| s.contains("Private Key header"))); |
| 299 | } |
| 300 | |
| 301 | #[test] |
| 302 | fn test_plaintext_secret_generic_private_key() { |
| 303 | let diff = "diff --git a/src/crypto.rs b/src/crypto.rs\n+const KEY: &str = \"-----BEGIN PRIVATE KEY-----\\nMIIEowIBAAKCAQEA...\";"; |
| 304 | let report = DiffAuditor::audit_text(diff); |
| 305 | assert!(!report.clean); |
| 306 | assert!(report |
| 307 | .secret_violations |
| 308 | .iter() |
| 309 | .any(|s| s.contains("Private Key header"))); |
| 310 | } |
| 311 | |
| 312 | #[test] |
| 313 | fn test_env_file_addition_root() { |
| 314 | let diff = "diff --git a/.env b/.env\nnew file mode 100644\n--- /dev/null\n+++ b/.env\n@@ -0,0 +1,2 @@\n+PORT=8080\n+HOST=127.0.0.1"; |
| 315 | let report = DiffAuditor::audit_text(diff); |
| 316 | assert!(!report.clean); |
| 317 | assert!(report.violations.iter().any(|v| v.contains(".env"))); |
| 318 | } |
| 319 | |
| 320 | #[test] |
| 321 | fn test_env_file_addition_nested() { |
| 322 | let diff = "diff --git a/crates/backend/.env.production b/crates/backend/.env.production\nnew file mode 100644\n--- /dev/null\n+++ b/crates/backend/.env.production\n@@ -0,0 +1,1 @@\n+NODE_ENV=production"; |
| 323 | let report = DiffAuditor::audit_text(diff); |
| 324 | assert!(!report.clean); |
| 325 | assert!(report.violations.iter().any(|v| v.contains(".env"))); |
| 326 | } |
| 327 | |
| 328 | #[test] |
| 329 | fn test_false_positive_markdown_lists() { |
| 330 | let diff = "diff --git a/docs/README.md b/docs/README.md\n+- First item in checklist\n+- Second item in checklist\n+* Third item in checklist"; |
| 331 | let report = DiffAuditor::audit_text(diff); |
| 332 | assert!(report.clean); |
| 333 | } |
| 334 | |
| 335 | #[test] |
| 336 | fn test_false_positive_negative_numbers_and_subtraction() { |
| 337 | let diff = "diff --git a/src/calc.rs b/src/calc.rs\n+let delta = a - b;\n+let temp = -40;\n+let offset = x - y - z;"; |
| 338 | let report = DiffAuditor::audit_text(diff); |
| 339 | assert!(report.clean); |
| 340 | } |
| 341 | |
| 342 | #[test] |
| 343 | fn test_false_positive_standard_hyphenated_words() { |
| 344 | let diff = "diff --git a/src/arch.rs b/src/arch.rs\n+// Zero-telemetry multi-threaded aarch64-unknown-linux-gnu runtime\npub const TARGET: &str = \"aarch64-unknown-linux-gnu\";"; |
| 345 | let report = DiffAuditor::audit_text(diff); |
| 346 | assert!(report.clean); |
| 347 | } |