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 / src / triage.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 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 17 | pub enum IssueCategory { |
| 18 | BugReport, |
| 19 | Complaint, |
| 20 | FeatureRequest, |
| 21 | Inquiry, |
| 22 | } |
| 23 | |
| 24 | pub struct TriageResult { |
| 25 | pub category: IssueCategory, |
| 26 | pub labels: Vec<String>, |
| 27 | pub markdown: String, |
| 28 | } |
| 29 | |
| 30 | pub fn triage_issue(author: &str, issue_number: u64, title: &str, body: &str) -> TriageResult { |
| 31 | let clean_title = if title.trim().is_empty() { |
| 32 | "Untitled Issue" |
| 33 | } else { |
| 34 | title.trim() |
| 35 | }; |
| 36 | |
| 37 | let lower_title = clean_title.to_lowercase(); |
| 38 | let lower_body = body.to_lowercase(); |
| 39 | let combined = format!("{} {}", lower_title, lower_body); |
| 40 | |
| 41 | let is_complaint = combined.contains("complaint") |
| 42 | || combined.contains("unacceptable") |
| 43 | || combined.contains("terrible") |
| 44 | || combined.contains("why did you") |
| 45 | || combined.contains("frustrated") |
| 46 | || combined.contains("broken promises") |
| 47 | || combined.contains("poor performance"); |
| 48 | |
| 49 | let is_bug = combined.contains("bug") |
| 50 | || combined.contains("crash") |
| 51 | || combined.contains("panic") |
| 52 | || combined.contains("error") |
| 53 | || combined.contains("failure") |
| 54 | || combined.contains("broken") |
| 55 | || combined.contains("segfault") |
| 56 | || combined.contains("leak") |
| 57 | || combined.contains("reproduce") |
| 58 | || combined.contains("repro") |
| 59 | || combined.contains("hang") |
| 60 | || combined.contains("freeze"); |
| 61 | |
| 62 | let is_feature = combined.contains("feat") |
| 63 | || combined.contains("feature") |
| 64 | || combined.contains("enhancement") |
| 65 | || combined.contains("proposal") |
| 66 | || combined.contains("rfc") |
| 67 | || combined.contains("add support") |
| 68 | || combined.contains("request for"); |
| 69 | |
| 70 | let mut result = if is_complaint { |
| 71 | let labels = vec!["feedback".to_string(), "triaged".to_string()]; |
| 72 | let markdown = format!( |
| 73 | r#"### ⚖️ Sovereign Triage: Operational Feedback Registered |
| 74 | |
| 75 | Greetings @{author}. I am **AIEN**, the automated review gate for the AIENOS project. |
| 76 | |
| 77 | Your report regarding **#{issue_number}** ("{title}") has been registered in the triage ledger. We operate under strict project standards, zero telemetry, and rigorous craftsmanship. |
| 78 | |
| 79 | To isolate and address this issue: |
| 80 | 1. Specify the exact commit hash, release version, or service endpoint involved. |
| 81 | 2. State the observed behavior versus expected technical invariants. |
| 82 | 3. If this concerns stability, memory, or execution latency, provide terminal logs or profiling traces. |
| 83 | |
| 84 | We resolve concrete regressions directly. Thank you for holding the line on quality. |
| 85 | "#, |
| 86 | author = author, |
| 87 | issue_number = issue_number, |
| 88 | title = clean_title |
| 89 | ); |
| 90 | TriageResult { |
| 91 | category: IssueCategory::Complaint, |
| 92 | labels, |
| 93 | markdown, |
| 94 | } |
| 95 | } else if is_bug { |
| 96 | let has_repro = combined.contains("steps to reproduce") |
| 97 | || combined.contains("reproduce:") |
| 98 | || combined.contains("repro:") |
| 99 | || combined.contains("expected:") |
| 100 | || combined.contains("backtrace") |
| 101 | || combined.contains("stack trace") |
| 102 | || combined.contains("thread 'main' panicked") |
| 103 | || combined.contains("cargo run") |
| 104 | || combined.contains("aegis "); |
| 105 | |
| 106 | if has_repro { |
| 107 | let labels = vec!["bug".to_string(), "triaged".to_string()]; |
| 108 | let markdown = format!( |
| 109 | r#"### ⚖️ Sovereign Triage: Bug Report Queued |
| 110 | |
| 111 | Greetings @{author}. I am **AIEN**, the automated review gate for the AIENOS project. |
| 112 | |
| 113 | Your defect report **#{issue_number}** ("{title}") contains reproduction diagnostics and has been queued for verification. |
| 114 | |
| 115 | - **Status**: Triaged |
| 116 | - **Classification**: Confirmed Defect Report |
| 117 | - **Next Step**: Autonomous verification harnesses will isolate the fault and prepare a remediation patch. |
| 118 | |
| 119 | Thank you for reporting this issue to maintain operational integrity. |
| 120 | "#, |
| 121 | author = author, |
| 122 | issue_number = issue_number, |
| 123 | title = clean_title |
| 124 | ); |
| 125 | TriageResult { |
| 126 | category: IssueCategory::BugReport, |
| 127 | labels, |
| 128 | markdown, |
| 129 | } |
| 130 | } else { |
| 131 | let labels = vec!["bug".to_string(), "needs-repro".to_string()]; |
| 132 | let markdown = format!( |
| 133 | r#"### ⚖️ Sovereign Triage: Bug Report Acknowledged |
| 134 | |
| 135 | Greetings @{author}. I am **AIEN**, the automated review gate for the AIENOS project. |
| 136 | |
| 137 | Your defect report **#{issue_number}** ("{title}") has been logged in the triage queue. |
| 138 | |
| 139 | To isolate the fault without delay, please provide the following details: |
| 140 | |
| 141 | 1. **Hardware & Environment**: |
| 142 | - Host architecture (e.g., Linux aarch64, NVIDIA DGX Spark, GB10, kernel version). |
| 143 | - Driver and runtime versions. |
| 144 | |
| 145 | 2. **Reproduction Sequence**: |
| 146 | - Exact command line invocation or API request payload. |
| 147 | - Minimal reproduction repository or configuration. |
| 148 | |
| 149 | 3. **Diagnostic Output**: |
| 150 | - Full panic backtrace (`RUST_BACKTRACE=1`) or terminal execution logs. |
| 151 | - Observed behavior vs. expected behavior. |
| 152 | |
| 153 | Once these parameters are provided, automated verification will proceed. |
| 154 | "#, |
| 155 | author = author, |
| 156 | issue_number = issue_number, |
| 157 | title = clean_title |
| 158 | ); |
| 159 | TriageResult { |
| 160 | category: IssueCategory::BugReport, |
| 161 | labels, |
| 162 | markdown, |
| 163 | } |
| 164 | } |
| 165 | } else if is_feature { |
| 166 | let labels = vec!["enhancement".to_string(), "proposal".to_string()]; |
| 167 | let markdown = format!( |
| 168 | r#"### ⚖️ Sovereign Triage: Architectural Proposal Received |
| 169 | |
| 170 | Greetings @{author}. I am **AIEN**, the automated review gate for the AIENOS project. |
| 171 | |
| 172 | Thank you for proposing this enhancement in **#{issue_number}** ("{title}"). |
| 173 | |
| 174 | All prospective additions must satisfy our project standards: |
| 175 | 1. **Zero Telemetry**: No tracking hooks, external analytics, or surveillance telemetry. |
| 176 | 2. **Zero Commercial Lock-in**: No proprietary tollbooths, rent-seeking layers, or walled gardens. |
| 177 | 3. **Pure Native Discipline**: Implementations must adhere to compiled native Rust architecture without unnecessary interpreter layers. |
| 178 | 4. **Human Sovereignty**: Technology must defend and empower ordinary users and local infrastructure. |
| 179 | |
| 180 | Maintainers will review the architectural fit and discuss implementation pathways. |
| 181 | "#, |
| 182 | author = author, |
| 183 | issue_number = issue_number, |
| 184 | title = clean_title |
| 185 | ); |
| 186 | TriageResult { |
| 187 | category: IssueCategory::FeatureRequest, |
| 188 | labels, |
| 189 | markdown, |
| 190 | } |
| 191 | } else { |
| 192 | let labels = vec!["question".to_string(), "triaged".to_string()]; |
| 193 | let markdown = format!( |
| 194 | r#"### ⚖️ Sovereign Triage: Community Inquiry Logged |
| 195 | |
| 196 | Greetings @{author}. I am **AIEN**, the automated review gate for the AIENOS project. |
| 197 | |
| 198 | Your inquiry **#{issue_number}** ("{title}") has been registered. |
| 199 | |
| 200 | - **Governing Standards**: Consult the Stapleton Doctrine for the project's governing standards and `COVENANT.md` for its values. |
| 201 | - **Documentation**: Technical specifications reside in `docs/` and project manifests. |
| 202 | - **Direct Sovereign Coordination**: Drake Stapleton (drake@aienos.com) and AIEN (aien@aienos.com) |
| 203 | |
| 204 | A maintainer or sovereign agent will provide technical clarification shortly. |
| 205 | "#, |
| 206 | author = author, |
| 207 | issue_number = issue_number, |
| 208 | title = clean_title |
| 209 | ); |
| 210 | TriageResult { |
| 211 | category: IssueCategory::Inquiry, |
| 212 | labels, |
| 213 | markdown, |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | result.labels.sort(); |
| 218 | result.labels.dedup(); |
| 219 | result |
| 220 | } |
| 221 | |
| 222 | #[cfg(test)] |
| 223 | mod tests { |
| 224 | use super::*; |
| 225 | |
| 226 | #[test] |
| 227 | fn test_bug_without_repro() { |
| 228 | let res = triage_issue( |
| 229 | "tester", |
| 230 | 101, |
| 231 | "Kernel panics on startup", |
| 232 | "I ran it and it crashed.", |
| 233 | ); |
| 234 | assert_eq!(res.category, IssueCategory::BugReport); |
| 235 | assert!(res.labels.contains(&"needs-repro".to_string())); |
| 236 | assert!(res.markdown.contains("Bug Report Acknowledged")); |
| 237 | assert!(!res.markdown.contains('\u{2014}')); |
| 238 | assert!(!res.markdown.contains('\u{2013}')); |
| 239 | } |
| 240 | |
| 241 | #[test] |
| 242 | fn test_bug_with_repro() { |
| 243 | let res = triage_issue( |
| 244 | "tester", |
| 245 | 102, |
| 246 | "Panic in token serialization", |
| 247 | "Steps to reproduce:\n1. cargo run\nBacktrace: thread 'main' panicked at...", |
| 248 | ); |
| 249 | assert_eq!(res.category, IssueCategory::BugReport); |
| 250 | assert!(res.labels.contains(&"triaged".to_string())); |
| 251 | assert!(res.markdown.contains("Bug Report Queued")); |
| 252 | assert!(!res.markdown.contains('\u{2014}')); |
| 253 | assert!(!res.markdown.contains('\u{2013}')); |
| 254 | } |
| 255 | |
| 256 | #[test] |
| 257 | fn test_complaint() { |
| 258 | let res = triage_issue( |
| 259 | "user1", |
| 260 | 103, |
| 261 | "Unacceptable slow performance", |
| 262 | "This is terrible and slow.", |
| 263 | ); |
| 264 | assert_eq!(res.category, IssueCategory::Complaint); |
| 265 | assert!(res.labels.contains(&"feedback".to_string())); |
| 266 | assert!(res.markdown.contains("Operational Feedback Registered")); |
| 267 | assert!(!res.markdown.contains('\u{2014}')); |
| 268 | assert!(!res.markdown.contains('\u{2013}')); |
| 269 | } |
| 270 | |
| 271 | #[test] |
| 272 | fn test_feature_proposal() { |
| 273 | let res = triage_issue( |
| 274 | "dev", |
| 275 | 104, |
| 276 | "Add support for AVX-512 fallback", |
| 277 | "Proposal to add vector fallback.", |
| 278 | ); |
| 279 | assert_eq!(res.category, IssueCategory::FeatureRequest); |
| 280 | assert!(res.labels.contains(&"enhancement".to_string())); |
| 281 | assert!(res.markdown.contains("Architectural Proposal Received")); |
| 282 | assert!(!res.markdown.contains('\u{2014}')); |
| 283 | assert!(!res.markdown.contains('\u{2013}')); |
| 284 | } |
| 285 | |
| 286 | #[test] |
| 287 | fn test_empty_strings_and_whitespace() { |
| 288 | let res = triage_issue("user", 105, "", ""); |
| 289 | assert_eq!(res.category, IssueCategory::Inquiry); |
| 290 | assert!(res.markdown.contains("Untitled Issue")); |
| 291 | assert!(!res.markdown.contains('\u{2014}')); |
| 292 | assert!(!res.markdown.contains('\u{2013}')); |
| 293 | |
| 294 | let res2 = triage_issue("user", 106, " \t ", " \n \t "); |
| 295 | assert_eq!(res2.category, IssueCategory::Inquiry); |
| 296 | assert!(res2.markdown.contains("Untitled Issue")); |
| 297 | } |
| 298 | |
| 299 | #[test] |
| 300 | fn test_label_deduplication() { |
| 301 | let res = triage_issue( |
| 302 | "user", |
| 303 | 107, |
| 304 | "Feature enhancement request", |
| 305 | "Proposal to add support for new feature.", |
| 306 | ); |
| 307 | let mut sorted = res.labels.clone(); |
| 308 | sorted.sort(); |
| 309 | sorted.dedup(); |
| 310 | assert_eq!(res.labels, sorted); |
| 311 | } |
| 312 | } |