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
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// The 7 distinct Agent Domains as defined in the MAS architecture.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum AgentDomain {
Kinematics, // KinematicsAgent
Executor, // ExecutorAgent
Security, // SecurityAgent
QoS, // QoSAgent
Lifecycle, // LifecycleAgent
BuildSystem, // BuildSystemAgent
Semantic, // SemanticAgent
}
/// The core task payload posted to the Blackboard by the Rust CLI.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentTask {
/// A unique identifier for the task.
pub task_id: String,
/// Which expert domain this task falls under.
pub target_domain: AgentDomain,
/// The absolute path to the file containing the violation.
pub file_path: String,
/// The specific text snippet or AST block causing the issue.
pub violation_context: String,
/// The diagnostic error message generated by the static analysis.
pub diagnostic_message: String,
/// Start byte of the violation range.
pub start_byte: usize,
/// End byte of the violation range.
pub end_byte: usize,
/// Any semantic metadata gathered (e.g., node name, topic, QoS).
pub semantic_metadata: HashMap<String, String>,
}
/// A simulated event bus where the Rust CLI posts tasks and Agents read from it.
/// In a real distributed system, this could be backed by Redis, MQTT, or a JSON file.
pub struct BlackboardEventBus {
tasks: Vec<AgentTask>,
}
impl BlackboardEventBus {
pub fn new() -> Self {
Self { tasks: Vec::new() }
}
/// The Rust CLI frontend calls this to broadcast an issue to the agents.
pub fn post_task(&mut self, task: AgentTask) {
// In production, this would serialize the task to JSON and post to a broker.
self.tasks.push(task);
}
/// Autonomous Agents call this to see if there are any tasks in their domain.
pub fn poll_tasks(&mut self, domain: &AgentDomain) -> Vec<AgentTask> {
let matched_tasks: Vec<AgentTask> = self.tasks
.iter()
.filter(|t| &t.target_domain == domain)
.cloned()
.collect();
// Remove polled tasks from the blackboard (claim them)
self.tasks.retain(|t| &t.target_domain != domain);
matched_tasks
}
}