pub struct CollusionDetector { /* private fields */ }Expand description
Multi-agent collusion detector.
Thread-safe via RwLock. All operations are fail-closed on lock poisoning.
Implementations§
Source§impl CollusionDetector
impl CollusionDetector
Sourcepub fn new(config: CollusionConfig) -> Result<Self, CollusionError>
pub fn new(config: CollusionConfig) -> Result<Self, CollusionError>
Create a new collusion detector with validated configuration.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the detector is enabled.
Sourcepub fn config(&self) -> &CollusionConfig
pub fn config(&self) -> &CollusionConfig
Get the current configuration.
Sourcepub fn compute_entropy(data: &[u8]) -> f64
pub fn compute_entropy(data: &[u8]) -> f64
Compute Shannon entropy (bits per byte) of raw data.
Returns a value in [0.0, 8.0]. Values above ~6.5 suggest compressed/encrypted/random data (potential steganographic channel).
Sourcepub fn analyze_parameters(
&self,
agent_id: &str,
param_data: &[u8],
) -> Result<Option<CollusionAlert>, CollusionError>
pub fn analyze_parameters( &self, agent_id: &str, param_data: &[u8], ) -> Result<Option<CollusionAlert>, CollusionError>
Analyze parameter data for steganographic channels.
Records the entropy observation and returns an alert if the agent has consistently high-entropy parameters.
Sourcepub fn record_resource_access(
&self,
agent_id: &str,
resource: &str,
tool: &str,
timestamp: u64,
) -> Result<Option<CollusionAlert>, CollusionError>
pub fn record_resource_access( &self, agent_id: &str, resource: &str, tool: &str, timestamp: u64, ) -> Result<Option<CollusionAlert>, CollusionError>
Record a resource access event and check for coordinated access patterns.
Returns an alert if min_coordinated_agents or more distinct agents
accessed the same resource within coordination_window_secs.
Sourcepub fn record_tool_timing(
&self,
agent_id: &str,
timestamp: u64,
) -> Result<Option<CollusionAlert>, CollusionError>
pub fn record_tool_timing( &self, agent_id: &str, timestamp: u64, ) -> Result<Option<CollusionAlert>, CollusionError>
Record a tool call timestamp for synchronization analysis.
Returns an alert if the agent’s timing is highly correlated with other tracked agents.
Sourcepub fn record_denial(
&self,
agent_id: &str,
tool: &str,
timestamp: u64,
) -> Result<Option<CollusionAlert>, CollusionError>
pub fn record_denial( &self, agent_id: &str, tool: &str, timestamp: u64, ) -> Result<Option<CollusionAlert>, CollusionError>
Record a policy denial event for an agent and check for reconnaissance probing patterns.
A reconnaissance probe is detected when an agent triggers
recon_denial_threshold or more distinct policy denials within
recon_window_secs. This indicates the agent is systematically
probing permission boundaries before launching an attack
(Promptware Kill Chain Stage 3 — Schneier/arXiv:2601.09625).
Returns an alert if the threshold is exceeded.
Sourcepub fn record_agent_action(
&self,
agent_id: &str,
denied: bool,
timestamp: u64,
) -> Result<Option<CollusionAlert>, CollusionError>
pub fn record_agent_action( &self, agent_id: &str, denied: bool, timestamp: u64, ) -> Result<Option<CollusionAlert>, CollusionError>
Record a tool call attempt and detect behavioral drift.
Tracks each agent’s action history (allowed vs denied) and compares the
denial rate in the first half of the time window (baseline) to the second
half (current). If the denial rate increases by more than drift_threshold,
an alert is raised indicating the agent may be gradually pushing boundaries.
(Straiker — “salami slicing” agent hijacking over multiple sessions)
Sourcepub fn recent_alerts(
&self,
limit: usize,
) -> Result<Vec<CollusionAlert>, CollusionError>
pub fn recent_alerts( &self, limit: usize, ) -> Result<Vec<CollusionAlert>, CollusionError>
Get recent alerts (up to limit).
Sourcepub fn alert_count(&self) -> Result<usize, CollusionError>
pub fn alert_count(&self) -> Result<usize, CollusionError>
Get total alert count.