-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.rs
More file actions
483 lines (463 loc) · 18.2 KB
/
Copy pathbot.rs
File metadata and controls
483 lines (463 loc) · 18.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
// SPDX-License-Identifier: MPL-2.0
//! Bot identification and metadata
use serde::{Deserialize, Serialize};
use std::fmt;
/// Unique identifier for each bot in the fleet
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum BotId {
/// RSR structural compliance validator
Rhodibot,
/// Mathematical/formal verification
Echidnabot,
/// Ecological/economic standards
Sustainabot,
/// Presentation quality (accessibility, SEO)
Glambot,
/// Integration testing
Seambot,
/// Release readiness validation
Finishbot,
/// Workflow cleanup and security executor
RobotRepoAutomaton,
/// Neurosymbolic CI/CD intelligence platform
Hypatia,
/// WCAG accessibility compliance validator
Accessibilitybot,
/// Cryptographic hygiene and post-quantum readiness specialist
Cipherbot,
/// Targeted audit bot wrapping panic-attack static analysis
Panicbot,
/// External ecological/economic code-analysis App (OikosBot,
/// `hyperpolymath/oikosbot`) that publishes findings via the optional
/// `oikosbot-fleet` bridge. NOT the reserved `Sustainabot` fleet slot and
/// NOT a fleet-managed roster bot — like `Custom`, it is deliberately
/// excluded from `all()` so the coordinator never dispatches it.
Oikosbot,
/// Custom/external bot
Custom(u32),
}
impl fmt::Display for BotId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
BotId::Rhodibot => write!(f, "rhodibot"),
BotId::Echidnabot => write!(f, "echidnabot"),
BotId::Sustainabot => write!(f, "sustainabot"),
BotId::Glambot => write!(f, "glambot"),
BotId::Seambot => write!(f, "seambot"),
BotId::Finishbot => write!(f, "finishbot"),
BotId::RobotRepoAutomaton => write!(f, "robot-repo-automaton"),
BotId::Hypatia => write!(f, "hypatia"),
BotId::Accessibilitybot => write!(f, "accessibilitybot"),
BotId::Cipherbot => write!(f, "cipherbot"),
BotId::Panicbot => write!(f, "panicbot"),
BotId::Oikosbot => write!(f, "oikosbot"),
BotId::Custom(id) => write!(f, "custom-{}", id),
}
}
}
impl BotId {
/// Get the tier this bot belongs to
pub fn tier(&self) -> Tier {
match self {
BotId::Rhodibot | BotId::Echidnabot | BotId::Sustainabot | BotId::Oikosbot | BotId::Panicbot => Tier::Verifier,
BotId::Glambot | BotId::Seambot | BotId::Finishbot | BotId::Accessibilitybot => Tier::Finisher,
BotId::Cipherbot => Tier::Specialist,
BotId::RobotRepoAutomaton => Tier::Executor,
BotId::Hypatia => Tier::Engine,
BotId::Custom(_) => Tier::Custom,
}
}
/// Get all standard bot IDs
pub fn all() -> Vec<BotId> {
vec![
BotId::Rhodibot,
BotId::Echidnabot,
BotId::Sustainabot,
BotId::Glambot,
BotId::Seambot,
BotId::Finishbot,
BotId::RobotRepoAutomaton,
BotId::Hypatia,
BotId::Accessibilitybot,
BotId::Cipherbot,
BotId::Panicbot,
]
}
/// Parse from string
// Returns `Option`, not `Result`, so the std `FromStr` trait does not fit; keep the name as part of the public API.
#[allow(clippy::should_implement_trait)]
pub fn from_str(s: &str) -> Option<BotId> {
match s.to_lowercase().as_str() {
"rhodibot" => Some(BotId::Rhodibot),
"echidnabot" => Some(BotId::Echidnabot),
"sustainabot" => Some(BotId::Sustainabot),
"glambot" => Some(BotId::Glambot),
"seambot" => Some(BotId::Seambot),
"finishbot" | "finishingbot" | "finishing-bot" => Some(BotId::Finishbot),
"robot-repo-automaton" | "robotrepoautomaton" => Some(BotId::RobotRepoAutomaton),
"hypatia" | "cicd-hyper-a" | "cicdhypera" => Some(BotId::Hypatia),
"accessibilitybot" | "accessibility-bot" => Some(BotId::Accessibilitybot),
"cipherbot" | "cipher-bot" => Some(BotId::Cipherbot),
"panicbot" | "panic-bot" => Some(BotId::Panicbot),
"oikosbot" | "oikos-bot" => Some(BotId::Oikosbot),
_ => None,
}
}
}
/// Bot execution tier
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Tier {
/// First tier - produces findings (rhodibot, echidnabot, sustainabot)
Verifier,
/// Second tier - consumes findings, produces results (glambot, seambot, finishbot)
Finisher,
/// Specialist - domain-specific deep analysis (cipherbot)
Specialist,
/// Third tier - executes actions based on findings (robot-repo-automaton)
Executor,
/// Central intelligence layer - coordinates all bots (hypatia)
Engine,
/// Custom/external bot
Custom,
}
impl Tier {
/// Get execution order (lower = earlier)
pub fn execution_order(&self) -> u8 {
match self {
Tier::Engine => 0, // Engine coordinates, runs first
Tier::Verifier => 1,
Tier::Finisher => 2,
Tier::Specialist => 3, // Specialist runs after verifiers/finishers
Tier::Executor => 4, // Executor runs after all analysis
Tier::Custom => 5,
}
}
/// Get all bots in this tier
pub fn bots(&self) -> Vec<BotId> {
BotId::all()
.into_iter()
.filter(|b| b.tier() == *self)
.collect()
}
}
/// Bot metadata and capabilities
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotInfo {
/// Unique identifier
pub id: BotId,
/// Human-readable name
pub name: String,
/// Description of purpose
pub description: String,
/// Version string
pub version: String,
/// Supported check categories
pub categories: Vec<String>,
/// Whether this bot can auto-fix issues
pub can_fix: bool,
/// Dependencies on other bots (must run first)
pub depends_on: Vec<BotId>,
}
impl BotInfo {
/// Create info for a standard bot
pub fn standard(id: BotId) -> Self {
match id {
BotId::Rhodibot => Self {
id,
name: "Rhodibot".to_string(),
description: "RSR (Rhodium Standard Repositories) compliance validation".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"structure".to_string(),
"files".to_string(),
"layout".to_string(),
"panel/structure".to_string(),
"panel/naming".to_string(),
"panel/spdx".to_string(),
],
can_fix: true,
depends_on: vec![],
},
BotId::Echidnabot => Self {
id,
name: "Echidnabot".to_string(),
description: "Tier 1 Verifier - formal verification, fuzzing, proof checking".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"verification".to_string(),
"fuzzing".to_string(),
"proofs".to_string(),
"proof-verification".to_string(),
"solver-integrity".to_string(),
"trust-bridge".to_string(),
"axiom-tracking".to_string(),
"panel/cmd-match".to_string(),
"panel/typell".to_string(),
"panel/boj-routing".to_string(),
],
can_fix: false,
depends_on: vec![],
},
BotId::Sustainabot => Self {
id,
name: "Sustainabot".to_string(),
description: "Ecological and economic code standards".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"sustainability".to_string(),
"efficiency".to_string(),
"debt".to_string(),
],
can_fix: false,
depends_on: vec![],
},
BotId::Glambot => Self {
id,
name: "Glambot".to_string(),
description: "Presentation quality - accessibility, SEO, machine-readability".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"accessibility".to_string(),
"seo".to_string(),
"html".to_string(),
"docs".to_string(),
"panel/aria".to_string(),
"panel/keyboard".to_string(),
"panel/clade".to_string(),
"panel/docs".to_string(),
],
can_fix: true,
depends_on: vec![BotId::Rhodibot],
},
BotId::Seambot => Self {
id,
name: "Seambot".to_string(),
description: "Architectural seam analysis - drift detection, hidden channels, forge integration".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"seam-analysis".to_string(),
"drift-detection".to_string(),
"hidden-channels".to_string(),
"forge-integration".to_string(),
"integration".to_string(),
"api".to_string(),
"contracts".to_string(),
"panel/wiring".to_string(),
"panel/msg-match".to_string(),
"panel/seam-integrity".to_string(),
],
can_fix: false,
depends_on: vec![BotId::Rhodibot, BotId::Echidnabot],
},
BotId::Finishbot => Self {
id,
name: "Finishing Bot".to_string(),
description: "Tier 2 Finisher - completeness analysis and release readiness".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"completeness/license".to_string(),
"completeness/placeholder".to_string(),
"completeness/claims".to_string(),
"completeness/release".to_string(),
"completeness/scm".to_string(),
"completeness/testing".to_string(),
"completeness/tooling".to_string(),
"completeness/v1-readiness".to_string(),
"panel/tests".to_string(),
"panel/clade-registered".to_string(),
"panel/todos".to_string(),
"panel/directives".to_string(),
"panel/release-gate".to_string(),
],
can_fix: true,
depends_on: vec![BotId::Rhodibot, BotId::Glambot],
},
BotId::RobotRepoAutomaton => Self {
id,
name: "Robot Repo Automaton".to_string(),
description: "Workflow cleanup and security executor for repository automation".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"security".to_string(),
"workflow".to_string(),
"structure".to_string(),
],
can_fix: true,
depends_on: vec![], // Executes based on rules from hypatia
},
BotId::Hypatia => Self {
id,
name: "Hypatia".to_string(),
description: "Neurosymbolic CI/CD intelligence platform - central rules engine".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"rules".to_string(),
"learning".to_string(),
"coordination".to_string(),
],
can_fix: false, // Engine provides rules, doesn't directly fix
depends_on: vec![], // Engine is the root, no dependencies
},
BotId::Accessibilitybot => Self {
id,
name: "Accessibilitybot".to_string(),
description: "WCAG 2.3 AAA accessibility compliance validator".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"accessibility/wcag-a".to_string(),
"accessibility/wcag-aa".to_string(),
"accessibility/wcag-aaa".to_string(),
"accessibility/aria".to_string(),
"accessibility/css".to_string(),
],
can_fix: true,
depends_on: vec![BotId::Rhodibot, BotId::Glambot],
},
BotId::Cipherbot => Self {
id,
name: "Cipherbot".to_string(),
description: "Cryptographic hygiene and post-quantum readiness specialist".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"crypto/hashing".to_string(),
"crypto/symmetric".to_string(),
"crypto/key-exchange".to_string(),
"crypto/signatures".to_string(),
"crypto/password".to_string(),
"crypto/pq-readiness".to_string(),
],
can_fix: true,
depends_on: vec![BotId::Rhodibot, BotId::Echidnabot],
},
BotId::Panicbot => Self {
id,
name: "Panicbot".to_string(),
description: "Targeted audit bot wrapping panic-attack static analysis".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"static-analysis/unsafe-code".to_string(),
"static-analysis/panic-path".to_string(),
"static-analysis/command-injection".to_string(),
"static-analysis/hardcoded-secret".to_string(),
"static-analysis/unsafe-ffi".to_string(),
"static-analysis/unsafe-deser".to_string(),
"static-analysis/race-condition".to_string(),
"static-analysis/resource-leak".to_string(),
"static-analysis/unchecked-error".to_string(),
"static-analysis/path-traversal".to_string(),
],
can_fix: false,
depends_on: vec![BotId::Rhodibot],
},
BotId::Oikosbot => Self {
id,
name: "OikosBot".to_string(),
description: "External ecological/economic code-analysis App (hyperpolymath/oikosbot) that publishes via the optional oikosbot-fleet bridge — distinct from the reserved Sustainabot slot".to_string(),
version: "0.1.0".to_string(),
categories: vec![
"sustainability".to_string(),
"ecological".to_string(),
"economic".to_string(),
],
can_fix: false,
depends_on: vec![],
},
BotId::Custom(_) => Self {
id,
name: "Custom Bot".to_string(),
description: "Custom/external bot".to_string(),
version: "0.0.0".to_string(),
categories: vec![],
can_fix: false,
depends_on: vec![],
},
}
}
}
/// Bot execution status
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum BotStatus {
/// Not yet started
Pending,
/// Currently running
Running,
/// Completed successfully
Completed,
/// Failed with errors
Failed,
/// Skipped (e.g., not applicable)
Skipped,
}
/// Record of a bot's execution
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BotExecution {
/// Which bot
pub bot: BotId,
/// Current status
pub status: BotStatus,
/// When started (if started)
pub started_at: Option<chrono::DateTime<chrono::Utc>>,
/// When completed (if completed)
pub completed_at: Option<chrono::DateTime<chrono::Utc>>,
/// Duration in milliseconds
pub duration_ms: Option<u64>,
/// Number of findings produced
pub findings_count: usize,
/// Number of errors
pub errors_count: usize,
/// Number of files analyzed
pub files_analyzed: usize,
/// Error message if failed
pub error_message: Option<String>,
}
impl BotExecution {
/// Create a new pending execution record
pub fn new(bot: BotId) -> Self {
Self {
bot,
status: BotStatus::Pending,
started_at: None,
completed_at: None,
duration_ms: None,
findings_count: 0,
errors_count: 0,
files_analyzed: 0,
error_message: None,
}
}
/// Mark as started
pub fn start(&mut self) {
self.status = BotStatus::Running;
self.started_at = Some(chrono::Utc::now());
}
/// Mark as completed
pub fn complete(&mut self, findings: usize, errors: usize, files: usize) {
let now = chrono::Utc::now();
// Completed regardless of whether errors were reported.
self.status = BotStatus::Completed;
self.completed_at = Some(now);
self.findings_count = findings;
self.errors_count = errors;
self.files_analyzed = files;
if let Some(started) = self.started_at {
self.duration_ms = Some((now - started).num_milliseconds() as u64);
}
}
/// Mark as failed
pub fn fail(&mut self, error: &str) {
self.status = BotStatus::Failed;
self.completed_at = Some(chrono::Utc::now());
self.error_message = Some(error.to_string());
if let Some(started) = self.started_at {
self.duration_ms = Some((chrono::Utc::now() - started).num_milliseconds() as u64);
}
}
/// Mark as skipped
pub fn skip(&mut self, reason: &str) {
self.status = BotStatus::Skipped;
self.error_message = Some(reason.to_string());
}
}