Skip to main content

derive

Function derive 

Source
pub fn derive(
    _memory: &Memory,
    ctx: &DeriveContext,
) -> (f64, ConfidenceSignals, ConfidenceSource)
Expand description

Deterministically derive a confidence value from row signals.

Returns (confidence, signals, source_marker):

  • confidence — value in [0.0, 1.0]. The formula is:

    base = 0.5
         + 0.1 * is_atom
         + 0.05 * log10(1 + corroboration)
         - 0.02 * source_age_days * decay_rate
    value = clamp(base, 0.0, 1.0) * freshness_factor
          + (1 - freshness_factor) * baseline_per_source

    where decay_rate = ln(2) / half_life_days and freshness_factor = exp(-age / half_life). The blend with the per-source baseline lets a well-calibrated source survive aging without collapsing to the freshness floor.

  • signals — the ConfidenceSignals envelope that produced the value. Stored alongside the row on memories.confidence_signals so the derivation is reproducible.

  • source_marker — typed discriminator for the memories.confidence_source column. Always ConfidenceSource::AutoDerived here; the shadow and calibrate paths use the other variants.

§Audit honesty

This function is pure — it does not touch the substrate, fire a hook, or read environment variables. The caller is responsible for gating on auto_confidence_enabled and only persisting the returned value when the opt-in is active. Tests can call it directly with handcrafted DeriveContext values and get bit-identical outputs across runs.