parlov-analysis 0.7.0

Analysis engine trait and signal detection for parlov.
Documentation
//! Coverage gate for the `NotPresent` verdict.
//!
//! Posterior alone is insufficient evidence. Even when the Bayesian aggregate falls
//! below the `NotPresent` threshold, the verdict should only be issued when the
//! endpoint has been meaningfully tested — multiple contradictory techniques across
//! enough independent strategies, with at least one technique that actually probes
//! the oracle-relevant boundary.

use crate::aggregation::reducer::{EvidenceEvent, EvidencePolarity};

/// Minimum number of distinct Contradictory technique firings required to claim `NotPresent`.
pub const MIN_CONTRADICTORY_TECHNIQUES: usize = 3;

/// Minimum weight for a Contradictory event to count as a "Strong" technique. Matches the
/// Strong bucket from the bucketed-prior calibration: `low_privilege` / `auth_strip` /
/// `scope_manipulation` all fire at 0.25.
pub const STRONG_THRESHOLD: f64 = 0.20;

/// Returns `true` iff the events satisfy the gate for `NotPresent`.
///
/// Three requirements:
/// 1. No `Positive` events. Any positive signal — at any weight — disqualifies `NotPresent`.
/// 2. At least `MIN_CONTRADICTORY_TECHNIQUES` distinct contradictory events fired.
/// 3. At least one contradictory event has `weight >= STRONG_THRESHOLD`.
#[must_use]
pub fn passes_not_present_gate(events: &[EvidenceEvent]) -> bool {
    let mut has_positive = false;
    let mut contradictory_count = 0usize;
    let mut has_strong = false;

    for event in events {
        match event.polarity {
            EvidencePolarity::Positive => {
                has_positive = true;
            }
            EvidencePolarity::Contradictory => {
                contradictory_count += 1;
                if event.weight >= STRONG_THRESHOLD {
                    has_strong = true;
                }
            }
        }
    }

    !has_positive && contradictory_count >= MIN_CONTRADICTORY_TECHNIQUES && has_strong
}

#[cfg(test)]
#[path = "coverage_gate_tests.rs"]
mod tests;