Skip to main content

safe_migrate/_internal/analysis/
outcome.rs

1use crate::_internal::analysis::evidence::EvidenceRecord;
2use crate::_internal::analysis::state::Confidence;
3
4/// Immutable result of an analysis run.
5#[derive(Debug, Clone)]
6pub struct AnalysisOutcome<T> {
7    pub findings: Vec<T>,
8    pub confidence: Confidence,
9    pub evidence: Vec<EvidenceRecord>,
10}
11
12impl<T> AnalysisOutcome<T> {
13    pub fn new(findings: Vec<T>, confidence: Confidence, evidence: Vec<EvidenceRecord>) -> Self {
14        Self {
15            findings,
16            confidence,
17            evidence,
18        }
19    }
20
21    /// Attach chain-level evidence after analysis without mutating the state
22    /// machine that produced the findings. This is used for invocation facts
23    /// such as a missing or stale baseline, which must taint the verdict but
24    /// must not downgrade the severity of the SQL being analyzed.
25    pub fn with_evidence(mut self, record: EvidenceRecord) -> Self {
26        if !self.evidence.contains(&record) {
27            self.evidence.push(record);
28            self.evidence.sort();
29        }
30        self.confidence = Confidence::Tainted;
31        self
32    }
33}