interplane.Get Omega
Read in your language

spark-inquisitor

Ultra-fast compiled native Rust gatekeeper and automated code reviewer

Brought by drakestapleton

branch main Branches Tags History

spark-inquisitor / src / triage.rs

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