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-abi-conformance / src / native.rs

128 lines · 4373 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//! Run-time view of what a binary linked (filled from the `build.rs` identity record).
17
18/// One native component as linked into this binary.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub struct NativeIdentity {
21 pub component: &'static str,
22 /// stub | pinned-source | dev-override | prebuilt
23 pub link: &'static str,
24 /// pass | symbols-only | unchecked | none
25 pub abi: &'static str,
26 /// locked | unrecorded | prebuilt-match | none
27 pub digest: &'static str,
28 pub archive_sha256: &'static str,
29 pub source_sha: &'static str,
30 pub aienos_lock: &'static str,
31 pub physics_lock: &'static str,
32 pub target: &'static str,
33 pub cc: &'static str,
34}
35
36impl NativeIdentity {
37 /// Release-grade: built from the pinned omega source, C ABI checked, digest recorded
38 /// and matched. A stub, a developer override or a prebuilt archive never qualifies.
39 pub fn qualifies(&self) -> bool {
40 self.link == "pinned-source" && self.abi == "pass" && self.digest == "locked"
41 }
42
43 /// Why [`Self::qualifies`] is false (empty when it is true).
44 pub fn gaps(&self) -> Vec<&'static str> {
45 let mut v = Vec::new();
46 if self.link != "pinned-source" {
47 v.push("not built from the pinned omega source");
48 }
49 if self.abi != "pass" {
50 v.push("C ABI not checked against the manifest");
51 }
52 if self.digest != "locked" {
53 v.push("archive digest not matched against native-artifacts.lock");
54 }
55 v
56 }
57
58 /// One JSON object (no dependencies; every value is a plain ASCII token).
59 pub fn to_json(&self) -> String {
60 let esc = |s: &str| s.replace('\\', "\\\\").replace('"', "\\\"");
61 format!(
62 "{{\"component\":\"{}\",\"link\":\"{}\",\"abi\":\"{}\",\"digest\":\"{}\",\"archive_sha256\":\"{}\",\"source_sha\":\"{}\",\"aienos_lock\":\"{}\",\"physics_lock\":\"{}\",\"target\":\"{}\",\"cc\":\"{}\",\"qualifies\":{}}}",
63 esc(self.component),
64 esc(self.link),
65 esc(self.abi),
66 esc(self.digest),
67 esc(self.archive_sha256),
68 esc(self.source_sha),
69 esc(self.aienos_lock),
70 esc(self.physics_lock),
71 esc(self.target),
72 esc(self.cc),
73 self.qualifies()
74 )
75 }
76}
77
78#[cfg(test)]
79mod tests {
80 use super::*;
81
82 #[test]
83 fn only_a_pinned_checked_locked_build_qualifies() {
84 let ok = NativeIdentity {
85 component: "x",
86 link: "pinned-source",
87 abi: "pass",
88 digest: "locked",
89 archive_sha256: "a",
90 source_sha: "b",
91 aienos_lock: "",
92 physics_lock: "",
93 target: "t",
94 cc: "cc \"q\"",
95 };
96 assert!(ok.qualifies() && ok.gaps().is_empty());
97 assert!(ok.to_json().contains("\"qualifies\":true"));
98 assert!(ok.to_json().contains("cc \\\"q\\\""));
99 for bad in [
100 NativeIdentity {
101 link: "stub",
102 abi: "none",
103 digest: "none",
104 ..ok
105 },
106 NativeIdentity {
107 link: "prebuilt",
108 abi: "symbols-only",
109 digest: "prebuilt-match",
110 ..ok
111 },
112 NativeIdentity {
113 link: "dev-override",
114 ..ok
115 },
116 NativeIdentity {
117 digest: "unrecorded",
118 ..ok
119 },
120 NativeIdentity {
121 abi: "unchecked",
122 ..ok
123 },
124 ] {
125 assert!(!bad.qualifies() && !bad.gaps().is_empty(), "{bad:?}");
126 }
127 }
128}