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-closure / src / error.rs

112 lines · 3453 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 nine finding codes and their exit codes.
17
18use std::fmt;
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
21pub enum Code {
22 UnverifiedDependency,
23 MissingReceipt,
24 ReceiptHashMismatch,
25 DependencyNotPinned,
26 DependencyCycle,
27 StaleReceipt,
28 UndeclaredImport,
29 TaintedArtifact,
30 UnknownVerifierProfile,
31}
32
33pub const ALL: [Code; 9] = [
34 Code::UnverifiedDependency,
35 Code::MissingReceipt,
36 Code::ReceiptHashMismatch,
37 Code::DependencyNotPinned,
38 Code::DependencyCycle,
39 Code::StaleReceipt,
40 Code::UndeclaredImport,
41 Code::TaintedArtifact,
42 Code::UnknownVerifierProfile,
43];
44
45impl Code {
46 pub fn as_str(self) -> &'static str {
47 match self {
48 Code::UnverifiedDependency => "UNVERIFIED_DEPENDENCY",
49 Code::MissingReceipt => "MISSING_RECEIPT",
50 Code::ReceiptHashMismatch => "RECEIPT_HASH_MISMATCH",
51 Code::DependencyNotPinned => "DEPENDENCY_NOT_PINNED",
52 Code::DependencyCycle => "DEPENDENCY_CYCLE",
53 Code::StaleReceipt => "STALE_RECEIPT",
54 Code::UndeclaredImport => "UNDECLARED_IMPORT",
55 Code::TaintedArtifact => "TAINTED_ARTIFACT",
56 Code::UnknownVerifierProfile => "UNKNOWN_VERIFIER_PROFILE",
57 }
58 }
59
60 /// Process exit code. 0 is PASS, 1 is an internal error, 2 is a usage
61 /// error, so findings start at 10.
62 pub fn exit_code(self) -> i32 {
63 match self {
64 Code::UnverifiedDependency => 10,
65 Code::MissingReceipt => 11,
66 Code::ReceiptHashMismatch => 12,
67 Code::DependencyNotPinned => 13,
68 Code::DependencyCycle => 14,
69 Code::StaleReceipt => 15,
70 Code::UndeclaredImport => 16,
71 Code::TaintedArtifact => 17,
72 Code::UnknownVerifierProfile => 18,
73 }
74 }
75}
76
77impl fmt::Display for Code {
78 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
79 f.write_str(self.as_str())
80 }
81}
82
83/// One machine-readable finding.
84#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
85pub struct Finding {
86 pub code: Code,
87 pub component: String,
88 pub detail: String,
89}
90
91impl Finding {
92 pub fn new(code: Code, component: &str, detail: impl Into<String>) -> Self {
93 Finding {
94 code,
95 component: component.to_string(),
96 detail: detail.into(),
97 }
98 }
99
100 /// `FINDING <CODE> component=<name> detail=<one line text>`
101 pub fn line(&self) -> String {
102 let detail: String = self
103 .detail
104 .chars()
105 .map(|c| if c.is_control() { ' ' } else { c })
106 .collect();
107 format!(
108 "FINDING {} component={} detail={}",
109 self.code, self.component, detail
110 )
111 }
112}