pub struct RuntimeEvidence {
pub confirmations: u64,
pub contradictions: u64,
pub prior: f64,
pub last_trace_id: Option<String>,
pub last_observed_at: DateTime<Utc>,
}Expand description
Accumulated runtime-trace evidence for a symbol’s declared effects.
Each asd trace ingest classifies the run as either a confirmation
(every observed effect was already declared) or a positive contradiction
(an effect was observed at runtime that was NOT declared). A declared effect
that simply wasn’t exercised is not a contradiction — absence of
observation is not evidence of absence — so it never lowers confidence.
EffectDecl.confidence is then re-derived from these counts via
RuntimeEvidence::derive_confidence, seeded by the static prior so that
with zero runtime evidence the confidence equals the prior, each
confirmation pulls it toward 1.0, and each contradiction toward 0.0.
Fields§
§confirmations: u64Traces whose observed effects were all already declared.
contradictions: u64Traces that observed an effect not present in the declaration.
prior: f64Static/policy confidence captured at the first runtime observation. Used as the prior the runtime evidence updates, and frozen thereafter so the derivation stays reproducible from (prior, confirmations, contradictions).
last_trace_id: Option<String>§last_observed_at: DateTime<Utc>Implementations§
Source§impl RuntimeEvidence
impl RuntimeEvidence
Sourcepub const PRIOR_STRENGTH: f64 = 2.0
pub const PRIOR_STRENGTH: f64 = 2.0
Pseudo-count weight given to the static prior. With zero runtime
evidence the derived confidence equals the prior; each confirmation
pulls it toward 1.0 and each contradiction toward 0.0, with the prior
worth PRIOR_STRENGTH observations of resistance.
Sourcepub const NEUTRAL_PRIOR: f64 = 0.5
pub const NEUTRAL_PRIOR: f64 = 0.5
Neutral prior used when no static/policy confidence is available.
Sourcepub fn derive_confidence(
prior: f64,
confirmations: u64,
contradictions: u64,
) -> f64
pub fn derive_confidence( prior: f64, confirmations: u64, contradictions: u64, ) -> f64
Derive a confidence in [0, 1] from the static prior and accumulated
counts. This is a Laplace-smoothed success rate (equivalently the mean of
a Beta posterior) with the prior seeded as PRIOR_STRENGTH
pseudo-observations:
confidence = (prior*S + confirmations) / (S + confirmations + contradictions)With confirmations == contradictions == 0 this returns prior exactly.
Sourcepub fn confidence(&self) -> f64
pub fn confidence(&self) -> f64
Confidence derived from this evidence record.