interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-allen / tests / refusal_rows_test.rs

83 lines · 2612 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//! The no-provision invariant (source scan, G5 analog) and the arch#150
17//! s4(6) row table. Rows that need approvals live outside this crate:
18//! DEPENDENCY sc#249, NOT_RUN.
19use std::path::PathBuf;
20
21fn src_files() -> Vec<(String, String)> {
22 let d = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src");
23 std::fs::read_dir(d)
24 .unwrap()
25 .map(|e| e.unwrap().path())
26 .map(|p| {
27 (
28 p.file_name().unwrap().to_string_lossy().into_owned(),
29 std::fs::read_to_string(&p).unwrap(),
30 )
31 })
32 .collect()
33}
34
35const BANNED: &[&str] = &[
36 "fn encode_subject",
37 "fn genesis",
38 "fn provision",
39 "fn mint",
40 "cs_provision",
41 "fn create_subject",
42 "thread::spawn",
43 "std::thread",
44 "tokio",
45];
46
47fn violations(text: &str) -> Vec<&'static str> {
48 BANNED
49 .iter()
50 .copied()
51 .filter(|b| text.contains(b))
52 .collect()
53}
54
55#[test]
56fn production_source_has_no_provision_or_encode_path() {
57 for (name, text) in src_files() {
58 assert!(
59 violations(&text).is_empty(),
60 "{name}: {:?}",
61 violations(&text)
62 );
63 }
64 // The subject module has a decoder and an id function only.
65 let s = src_files()
66 .into_iter()
67 .find(|(n, _)| n == "subject_v0.rs")
68 .unwrap()
69 .1;
70 assert!(!s.contains("pub fn encode"));
71 // Only the pin and deployment writers touch the filesystem for writing.
72 for (name, text) in src_files() {
73 let writes = text.contains("fs::write") || text.contains("File::create");
74 assert_eq!(writes, name == "binding.rs", "{name}: unexpected writer");
75 }
76}
77
78#[test]
79fn the_scan_would_catch_a_provision_function() {
80 // Negative control: the scan flags a provisioning function.
81 assert_eq!(violations("pub fn provision() {}"), vec!["fn provision"]);
82 assert!(violations("pub fn decode() {}").is_empty());
83}