Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
feat(store): B1 belief-strength confidence into ranking authority (default-OFF)
AkitaOnRailse9b9d9cfe27b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6f76c879..09df7138 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Added+- Belief-strength confidence over the `page_evidence` substrate+ (design-memory-aging.md bucket B1 / design-hindsight-borrowings.md §3): a+ read-time, **zero-LLM** `confidence` derived per page version from its+ evidence — distinct supporting sessions (breadth, not raw count), recency of+ the newest sighting, and live `contradicts` count — bounded to+ `[0.0, 0.95]`. It is **exposed inertly** everywhere it helps diagnosis:+ `memory_query(explain=true)` now reports `confidence` and `evidence_count`+ per hit (and `belief_factor` when folding is on), and `memory_status` reports+ the project's `evidence_rows` count — none of which changes ranking. It can+ optionally be **folded into ranking authority** as one more bounded factor+ inside the existing `[0.55, 1.50]` clamp (never a new multiplier tower) via+ the new `[retrieval] belief_authority_weight` config key, which **defaults to+ `0.0` (OFF)** so upgrades rank byte-identically. The anti-entrenchment guards+ are baked in: breadth weighting by distinct sessions, recency shading, a+ hard confidence cap, and — the caller-side guard for invariant #16 — **a+ supersession always wins regardless of evidence** (a superseded version's+ stale evidence never boosts it, and confidence never gates whether a write or+ correction takes). Turning the authority factor on is **gated on a positive+ R2 delta** (retrieval-triple / QA), not yet performed (#815).- Zero-LLM contradiction detection surfaced through `memory_lint`(design-memory-aging.md bucket A5): the lint pass now flags likely-conflictingpages by cosine-similarity band. Cold knowledge pages (semantic / procedural)diff --git a/crates/ai-memory-cli/src/config.rs b/crates/ai-memory-cli/src/config.rsindex 2869cb1e..d44c958f 100644--- a/crates/ai-memory-cli/src/config.rs+++ b/crates/ai-memory-cli/src/config.rs@@ -1144,6 +1144,12 @@ pub struct RetrievalSettings {/// the RRF fusion. Pages gain an abstract vector when their frontmatter/// carries `abstract:` and the embedding backfill runs.pub abstract_vectors: bool,+ /// Weight of the belief-strength confidence factor folded into page+ /// authority (P2). `0.0` (the default) is inert — ranking is byte-identical+ /// and no belief query runs. Positive folds a page's evidence-derived+ /// `confidence` into its authority factor, inside the existing bounds.+ /// OFF by default: enabling it is gated on a positive R2 delta.+ pub belief_authority_weight: f64,}impl Default for RetrievalSettings {@@ -1153,6 +1159,7 @@ impl Default for RetrievalSettings {query_intent: base.session_recall_routing,session_recall_bonus: base.session_recall_bonus,abstract_vectors: base.abstract_vectors,+ belief_authority_weight: base.belief_authority_weight,}}}@@ -1165,6 +1172,10 @@ impl RetrievalSettings {session_recall_routing: self.query_intent,session_recall_bonus: self.session_recall_bonus.max(0.0),abstract_vectors: self.abstract_vectors,+ // A negative weight would flip the boost into a penalty on+ // supported pages; clamp it out so misconfiguration is inert, not+ // inverted.+ belief_authority_weight: self.belief_authority_weight.max(0.0),}}}diff --git a/crates/ai-memory-mcp/src/server.rs b/crates/ai-memory-mcp/src/server.rsindex a6dca955..3c0311b4 100644--- a/crates/ai-memory-mcp/src/server.rs+++ b/crates/ai-memory-mcp/src/server.rs@@ -10207,6 +10207,9 @@ mod tests {.map(|t| t.text.clone()).unwrap();assert!(text.contains("\"pages_latest\": 1"));+ // The belief-strength substrate footprint (P2) is surfaced in status;+ // this fresh project has consolidated nothing, so it reads 0.+ assert!(text.contains("\"evidence_rows\": 0"));}/// A scope that does not resolve is caller input, not a server fault: thediff --git a/crates/ai-memory-store/src/belief.rs b/crates/ai-memory-store/src/belief.rsnew file mode 100644index 00000000..5c2f2527--- /dev/null+++ b/crates/ai-memory-store/src/belief.rs@@ -0,0 +1,255 @@+//! Read-time belief-strength confidence (P2,+//! `docs/design-hindsight-borrowings.md` §3).+//!+//! Pure, deterministic, zero-LLM math — mirroring [`crate::decay`] — so the+//! monotonicity and anti-entrenchment guarantees are unit-testable without a+//! database. Given the evidence a page *version* has accrued (`page_evidence`,+//! V63) plus its count of live contradictions, it derives a bounded+//! `confidence` in `[0.0, CONFIDENCE_CAP]`.+//!+//! Confidence is derived at *read time* rather than stored: there is no mutable+//! scalar to write on every access and no second source of truth to keep in+//! sync — the append-only evidence rows are the only truth, and the number is+//! recomputed from them each query.+//!+//! # Anti-entrenchment (Hindsight's documented failure mode)+//! A popular-but-wrong belief must not pin itself at the top forever+//! (`research-hindsight.md` §5). Three guards are baked into [`confidence`]:+//!+//! * **Distinct sessions, not raw count.** Breadth is driven by the number of+//! *distinct* supporting sessions; a page cited 50 times by one session is+//! worth far less than one cited by 50 sessions, so a single loud operator+//! cannot manufacture confidence.+//! * **Recency weighting.** The age of the *newest* sighting shades the score+//! down toward a floor, so an old belief nobody has reaffirmed loses standing+//! to a freshly reinforced one.+//! * **A hard cap below 1.0.** The support curve saturates and the result is+//! clamped to [`CONFIDENCE_CAP`], so evidence *alone* can never pin a page's+//! confidence — and thus its ranking authority — at the ceiling.+//!+//! A fourth guard lives in the caller, not here: a supersession always wins+//! regardless of count (invariant #16). Confidence only shades *ranking*; it+//! never gates whether a correction is written or returned, and the ranker+//! declines to apply the boost to superseded (stale) versions at all.++/// Distinct supporting sessions at which the support curve reaches ~63% of its+/// ceiling. Deliberately small: a belief backed by a handful of independent+/// sessions is already strongly supported, and the saturating shape means+/// each further session adds less — the diminishing-returns half of the+/// anti-entrenchment guard.+const SUPPORT_SATURATION: f64 = 3.0;++/// Credit a non-session evidence row (a directly-cited observation or a+/// reaffirming feedback row) contributes to breadth, relative to a distinct+/// session. Heavily discounted because those rows carry no independent-session+/// guarantee, so they cannot substitute for genuine cross-session breadth.+const NON_SESSION_CREDIT: f64 = 0.2;++/// Ceiling on the breadth non-session evidence can add, in distinct-session+/// equivalents. The anti-entrenchment core: a page cited by one session and a+/// hundred observations must not reach the confidence of one backed by many+/// independent sessions — raw non-session volume is capped so distinct breadth+/// always dominates.+const RESIDUAL_BREADTH_CAP: f64 = 1.0;++/// Recency time-constant: evidence this many seconds old has decayed most of+/// the way to [`RECENCY_FLOOR`]. 30 days — long enough that steady work keeps a+/// belief "fresh", short enough that a belief abandoned for a month visibly+/// loses standing.+const RECENCY_TAU_SECS: f64 = 60.0 * 60.0 * 24.0 * 30.0;++/// Floor of the recency multiplier: even the oldest evidence keeps this share+/// of its support. Recency *shades* standing; it never erases a real belief+/// (that is supersession's job, not aging's).+const RECENCY_FLOOR: f64 = 0.5;++/// Hard ceiling on derived confidence. Below 1.0 by construction so that+/// evidence can never pin a page at maximum authority — the confidence cap of+/// the anti-entrenchment guard.+pub const CONFIDENCE_CAP: f64 = 0.95;++/// The evidence a single page version has accrued, as read from the store for+/// one candidate page. All fields default to zero / `None`, which+/// [`confidence`] reads as "no evidence" → confidence `0.0` (neutral, i.e. no+/// ranking effect), never "unsupported".+#[derive(Debug, Clone, Copy, Default, PartialEq)]+pub struct BeliefInputs {+ /// Total `page_evidence` rows citing this page version.+ pub evidence_count: u32,+ /// Distinct supporting sessions — `COUNT(DISTINCT source_id)` over the+ /// `session` and `reconsolidation` evidence kinds. The breadth signal.+ pub distinct_sessions: u32,+ /// `MAX(created_at)` over the page's evidence rows, in Unix microseconds;+ /// `None` when the page has no evidence.+ pub newest_evidence_us: Option<i64>,+ /// Number of live (`contradicts` → latest page) contradictions this page+ /// declares. Each one weakens the belief.+ pub unresolved_contradictions: u32,+}++/// Derive a page version's belief-strength confidence in `[0.0, CONFIDENCE_CAP]`+/// from its evidence and contradictions, evaluated against `now_us`.+///+/// Monotone by construction: strictly increasing in distinct sessions and in+/// evidence count, strictly decreasing in the age of the newest evidence and in+/// the contradiction count. A page with no evidence returns `0.0`.+#[must_use]+pub fn confidence(inputs: &BeliefInputs, now_us: i64) -> f64 {+ // Breadth is driven by distinct sessions; non-session rows beyond that add+ // only a discounted residual. `saturating_sub` guards the (normal) case+ // where distinct sessions is a subset of the total row count, and the+ // (pathological) case where a caller reports more distinct sessions than+ // rows — the residual is then simply zero, never negative.+ let residual = f64::from(+ inputs+ .evidence_count+ .saturating_sub(inputs.distinct_sessions),+ );+ let residual_breadth = (NON_SESSION_CREDIT * residual).min(RESIDUAL_BREADTH_CAP);+ let breadth = f64::from(inputs.distinct_sessions) + residual_breadth;+ if breadth <= 0.0 {+ // No evidence at all: neutral, no ranking effect. Returning here also+ // keeps a page whose only "evidence" is an unresolved contradiction+ // from going negative.+ return 0.0;+ }++ // Saturating support: 1 - e^(-breadth/k) ∈ [0, 1), diminishing returns per+ // additional session — evidence alone cannot reach the ceiling.+ let support = 1.0 - (-breadth / SUPPORT_SATURATION).exp();++ // Recency: newest sighting shades the score toward RECENCY_FLOOR. `None`+ // is unreachable once breadth > 0 (a row implies a timestamp), but we treat+ // it as "unknown, not old" (multiplier 1.0) rather than penalizing.+ let recency = match inputs.newest_evidence_us {+ Some(ts) => {+ let age_secs = (now_us.saturating_sub(ts)).max(0) as f64 / 1_000_000.0;+ RECENCY_FLOOR + (1.0 - RECENCY_FLOOR) * (-age_secs / RECENCY_TAU_SECS).exp()+ }+ None => 1.0,+ };++ // Each live contradiction weakens the belief. 1/(1+n) is monotone+ // decreasing and bottoms out toward 0 without ever driving the whole score+ // negative.+ let contradiction = 1.0 / (1.0 + f64::from(inputs.unresolved_contradictions));++ (support * recency * contradiction).clamp(0.0, CONFIDENCE_CAP)+}++#[cfg(test)]+mod tests {+ use super::*;++ /// A fixed "now" so age-based terms are deterministic.+ const NOW: i64 = 1_900_000_000_000_000;+ const DAY_US: i64 = 60 * 60 * 24 * 1_000_000;++ fn inputs(distinct: u32, count: u32, age_days: i64, contradictions: u32) -> BeliefInputs {+ BeliefInputs {+ evidence_count: count,+ distinct_sessions: distinct,+ newest_evidence_us: Some(NOW - age_days * DAY_US),+ unresolved_contradictions: contradictions,+ }+ }++ #[test]+ fn no_evidence_is_zero_and_thus_neutral() {+ assert_eq!(confidence(&BeliefInputs::default(), NOW), 0.0);+ // An unresolved contradiction with no supporting evidence stays 0.0,+ // never negative.+ let only_contradiction = BeliefInputs {+ unresolved_contradictions: 3,+ ..BeliefInputs::default()+ };+ assert_eq!(confidence(&only_contradiction, NOW), 0.0);+ }++ #[test]+ fn more_distinct_sessions_is_strictly_higher() {+ // Stay in the unsaturated region; the cap is asserted separately.+ let mut prev = confidence(&inputs(1, 1, 0, 0), NOW);+ for n in 2..=8 {+ let c = confidence(&inputs(n, n, 0, 0), NOW);+ assert!(c > prev, "distinct={n}: {c} !> {prev}");+ prev = c;+ }+ }++ #[test]+ fn raw_count_matters_far_less_than_distinct_sessions() {+ // 50 sightings from ONE session must be worth much less than 50 from+ // 50 sessions — the core anti-entrenchment property.+ let one_loud = confidence(&inputs(1, 50, 0, 0), NOW);+ let many_distinct = confidence(&inputs(50, 50, 0, 0), NOW);+ assert!(+ many_distinct > one_loud,+ "distinct breadth {many_distinct} must beat one loud session {one_loud}"+ );+ }++ #[test]+ fn older_newest_evidence_is_strictly_lower() {+ let mut prev = confidence(&inputs(4, 4, 0, 0), NOW);+ for age in [1_i64, 7, 30, 90, 365, 3650] {+ let c = confidence(&inputs(4, 4, age, 0), NOW);+ assert!(c < prev, "age={age}d: {c} !< {prev}");+ prev = c;+ }+ }++ #[test]+ fn more_contradictions_is_strictly_lower() {+ let mut prev = confidence(&inputs(4, 4, 0, 0), NOW);+ for n in 1..=5 {+ let c = confidence(&inputs(4, 4, 0, n), NOW);+ assert!(c < prev, "contradictions={n}: {c} !< {prev}");+ prev = c;+ }+ }++ #[test]+ fn confidence_cap_is_respected_even_with_overwhelming_evidence() {+ let overwhelming = confidence(&inputs(100_000, 1_000_000, 0, 0), NOW);+ assert!(overwhelming <= CONFIDENCE_CAP, "{overwhelming} exceeds cap");+ assert!(overwhelming < 1.0, "confidence must never reach 1.0");+ }++ #[test]+ fn always_bounded() {+ for &distinct in &[0_u32, 1, 5, 100] {+ for &count in &[distinct, distinct + 10, distinct.saturating_mul(3)] {+ for &age in &[0_i64, 30, 1000] {+ for &contra in &[0_u32, 1, 10] {+ let c = confidence(&inputs(distinct, count, age, contra), NOW);+ assert!((0.0..=CONFIDENCE_CAP).contains(&c), "out of range: {c}");+ }+ }+ }+ }+ }++ #[test]+ fn recency_floor_keeps_ancient_evidence_supported() {+ // Even 100 years old, a broadly-supported belief keeps at least the+ // floor share of its support (aging shades; it does not erase).+ let ancient = confidence(&inputs(50, 50, 365 * 100, 0), NOW);+ let fresh = confidence(&inputs(50, 50, 0, 0), NOW);+ assert!(ancient > 0.0);+ assert!(ancient < fresh);+ assert!(ancient >= fresh * RECENCY_FLOOR * 0.99);+ }++ #[test]+ fn missing_timestamp_is_treated_as_unknown_not_old() {+ let no_ts = BeliefInputs {+ evidence_count: 4,+ distinct_sessions: 4,+ newest_evidence_us: None,+ unresolved_contradictions: 0,+ };+ // Same as a brand-new sighting: recency multiplier 1.0.+ assert!((confidence(&no_ts, NOW) - confidence(&inputs(4, 4, 0, 0), NOW)).abs() < 1e-12);+ }+}diff --git a/crates/ai-memory-store/src/lib.rs b/crates/ai-memory-store/src/lib.rsindex 8566d38a..4111f9cb 100644--- a/crates/ai-memory-store/src/lib.rs+++ b/crates/ai-memory-store/src/lib.rs@@ -16,6 +16,7 @@ use rusqlite::Connection;mod api_credentials;mod auto_improve;+pub mod belief;pub mod decay;mod error;mod fts_query;@@ -43,6 +44,7 @@ pub use auto_improve::{OwnedAutoImproveProposalDetail, RejectAutoImproveProposal, SkippedProposal,StageAutoImproveRun, StagedAutoImproveRun, StagedAutoImproveRunReport, artifact_path_for,};+pub use belief::{BeliefInputs, CONFIDENCE_CAP, confidence};pub use decay::{DecayParams, SALIENCE_MAX, SALIENCE_MIN, SALIENCE_STEP, TierLambdas,lambda_from_half_life_days, retention_score, retention_score_with_breadth,diff --git a/crates/ai-memory-store/src/reader.rs b/crates/ai-memory-store/src/reader.rsindex 258b8528..541b1798 100644--- a/crates/ai-memory-store/src/reader.rs+++ b/crates/ai-memory-store/src/reader.rs@@ -642,10 +642,28 @@ pub struct SearchExplain {/// sessions/observations/feedback/reconsolidation passes produced or/// reaffirmed it. Populated only on the explained path/// ([`Reader::hybrid_search_explained`]), batch-fetched after fusion;- /// `None` on the default (non-explained) path. Inert this release: it- /// never feeds `fused`/`authority` or changes ranking.+ /// `None` on the default (non-explained) path. Populated on every+ /// explained query and, additionally, whenever the belief-authority weight+ /// is on (it is an input to the factor then). Exposing the count is inert:+ /// the count itself never feeds `fused`/`authority`.#[serde(skip_serializing_if = "Option::is_none")]pub evidence_count: Option<u32>,+ /// Belief-strength confidence in `[0.0, `[`crate::belief::CONFIDENCE_CAP`]`]`+ /// derived from this page version's evidence (P2,+ /// docs/design-hindsight-borrowings.md §3): distinct supporting sessions,+ /// recency of the newest sighting, and live contradiction count. Populated+ /// alongside `evidence_count`. Informational unless+ /// `[retrieval] belief_authority_weight` is positive; see `belief_factor`.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub confidence: Option<f64>,+ /// The belief contribution actually folded into `authority` for this hit:+ /// `belief_authority_weight * confidence`, or `0.0` when the confidence+ /// applied but was zero. `None` when the belief-authority weight is off+ /// (the default) or the hit was skipped (a superseded version — a+ /// supersession always wins, so stale evidence never boosts it). Inert+ /// exposure of `confidence`/`evidence_count` does not set this.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub belief_factor: Option<f64>,}/// One hit returned by [`ReaderPool::search_pages`].@@ -898,6 +916,12 @@ pub struct StatusCounts {pub sessions: u64,/// Total observations across all sessions.pub observations: u64,+ /// Total `page_evidence` rows in the project (P2,+ /// docs/design-hindsight-borrowings.md §3): the belief-strength substrate's+ /// footprint — how many session/observation/feedback/reconsolidation+ /// citations back this project's pages. `0` on a store that predates the+ /// evidence write path or has consolidated nothing yet.+ pub evidence_rows: u64,}/// One likely cross-project contamination finding from@@ -4116,22 +4140,30 @@ impl ReaderPool {.await}- /// Number of `page_evidence` rows for each of `page_ids` (P2,- /// docs/design-hindsight-borrowings.md §3): what produced or- /// reaffirmed that page version. One batch query for the whole- /// result page — never one per hit — so- /// [`Self::hybrid_search_explained`] can attach- /// `SearchExplain::evidence_count` without touching the hot,- /// non-explained default path. A page id with zero evidence rows is- /// simply absent from the map; callers read that as count 0- /// ("unknown", not "unsupported").+ /// Batched belief-strength inputs for each of `page_ids` (P2,+ /// docs/design-hindsight-borrowings.md §3): the evidence aggregate and the+ /// live-contradiction count that [`crate::belief::confidence`] needs.+ ///+ /// Two fixed batch queries for the whole result page — never one per hit+ /// (invariant #2). Only called when the belief signal is needed (an+ /// explained query, or the belief-authority weight is on), so the hot,+ /// non-explained default path pays nothing. A page id with no evidence rows+ /// is absent from the map; the caller reads that as+ /// [`BeliefInputs::default`] (confidence 0, i.e. no ranking effect).+ ///+ /// `distinct_sessions` counts distinct `source_id`s over the `session` and+ /// `reconsolidation` kinds — the breadth signal — and `newest_evidence_us`+ /// is `MAX(created_at)`. The contradiction count is the number of+ /// `contradicts` edges the page declares whose target resolves to a *live*+ /// (latest) page; a stale (dangling) contradiction does not weaken the+ /// belief, matching the lint's resolved/stale split.////// # Errors/// Propagates any SQL or pool error.- pub async fn page_evidence_counts(+ pub async fn page_belief_inputs(&self,page_ids: &[PageId],- ) -> StoreResult<std::collections::HashMap<PageId, u32>> {+ ) -> StoreResult<std::collections::HashMap<PageId, crate::belief::BeliefInputs>> {if page_ids.is_empty() {return Ok(std::collections::HashMap::new());}@@ -4143,21 +4175,63 @@ impl ReaderPool {let placeholders = std::iter::repeat_n("?", page_id_blobs.len()).collect::<Vec<_>>().join(", ");- let sql = format!(- "SELECT page_id, COUNT(*) FROM page_evidence \+ let mut out: std::collections::HashMap<PageId, crate::belief::BeliefInputs> =+ std::collections::HashMap::new();++ // Evidence aggregate: total rows, distinct supporting sessions, and+ // the newest sighting, in one grouped pass.+ let evidence_sql = format!(+ "SELECT page_id, COUNT(*), \+ COUNT(DISTINCT CASE WHEN source_kind IN ('session','reconsolidation') \+ THEN source_id END), \+ MAX(created_at) \+ FROM page_evidence \WHERE page_id IN ({placeholders}) GROUP BY page_id");- let mut stmt = conn.prepare(&sql)?;+ let mut stmt = conn.prepare(&evidence_sql)?;+ let rows = stmt.query_map(params_from_iter(page_id_blobs.iter()), |row| {+ let id: Vec<u8> = row.get(0)?;+ let count: i64 = row.get(1)?;+ let distinct: i64 = row.get(2)?;+ let newest: Option<i64> = row.get(3)?;+ Ok((id, count, distinct, newest))+ })?;+ for r in rows {+ let (id, count, distinct, newest) = r?;+ out.insert(+ PageId::from_slice(&id)?,+ crate::belief::BeliefInputs {+ evidence_count: u32::try_from(count).unwrap_or(u32::MAX),+ distinct_sessions: u32::try_from(distinct).unwrap_or(u32::MAX),+ newest_evidence_us: newest,+ unresolved_contradictions: 0,+ },+ );+ }++ // Live contradictions each page declares. Only edges whose target+ // resolves to a latest page count — a dangling `contradicts` is+ // stale, not an active disagreement (mirrors the lint split).+ let contradiction_sql = format!(+ "SELECT l.from_page_id, COUNT(*) \+ FROM links l \+ JOIN pages tp ON tp.id = l.to_page_id AND tp.is_latest = 1 \+ WHERE l.link_type = 'contradicts' \+ AND l.from_page_id IN ({placeholders}) \+ GROUP BY l.from_page_id"+ );+ let mut stmt = conn.prepare(&contradiction_sql)?;let rows = stmt.query_map(params_from_iter(page_id_blobs.iter()), |row| {let id: Vec<u8> = row.get(0)?;let n: i64 = row.get(1)?;- Ok((id, u32::try_from(n).unwrap_or(u32::MAX)))+ Ok((id, n))})?;- let mut out = std::collections::HashMap::new();for r in rows {let (id, n) = r?;- out.insert(PageId::from_slice(&id)?, n);+ let entry = out.entry(PageId::from_slice(&id)?).or_default();+ entry.unresolved_contradictions = u32::try_from(n).unwrap_or(u32::MAX);}+Ok(out)}).await@@ -4867,18 +4941,13 @@ impl ReaderPool {include_superseded,).await?;- // Evidence counts (P2, docs/design-hindsight-borrowings.md §3) are- // explain-only: one batch query over the already-fused result page- // ids, never a per-hit query on the hot default path.- let page_ids: Vec<PageId> = hits.iter().map(|(hit, _)| hit.id).collect();- let counts = self.page_evidence_counts(&page_ids).await?;+ // Belief-strength fields (`evidence_count`, `confidence`,+ // `belief_factor`; P2, docs/design-hindsight-borrowings.md §3) are+ // populated inside the explained path of `hybrid_search_inner` from one+ // batched query — never per-hit — so no second pass is needed here.Ok(hits.into_iter()- .map(|(hit, explain)| {- let mut explain = explain.unwrap_or_default();- explain.evidence_count = Some(counts.get(&hit.id).copied().unwrap_or(0));- (hit, explain)- })+ .map(|(hit, explain)| (hit, explain.unwrap_or_default())).collect())}@@ -5181,18 +5250,69 @@ impl ReaderPool {.await?};authorities.extend(extra_authorities);++ // Belief-strength (P2, docs/design-hindsight-borrowings.md §3).+ // Fetched only when needed: an explained query exposes+ // `confidence`/`evidence_count` inertly, and a positive weight folds+ // confidence into the authority factor. The default, non-explained,+ // weight-off path skips the query entirely and ranks byte-identically.+ let belief_weight = tuning.belief_authority_weight;+ let need_belief = explain || belief_weight > 0.0;+ let belief_inputs = if need_belief {+ let ids: Vec<PageId> = out.iter().map(|(hit, _)| hit.id).collect();+ self.page_belief_inputs(&ids).await?+ } else {+ std::collections::HashMap::new()+ };+ // Anti-entrenchment: a supersession always wins regardless of count+ // (invariant #16). A superseded version's stale evidence must not boost+ // it, so the fold skips those ids. Only needed on the opt-in+ // include_superseded path — the default path returns latest only.+ let boost_skip = if belief_weight > 0.0 && include_superseded {+ let ids: Vec<PageId> = out.iter().map(|(hit, _)| hit.id).collect();+ self.superseded_page_ids(workspace_id, project_id, ids)+ .await?+ } else {+ std::collections::HashSet::new()+ };+ let belief_now = now_us();for (hit, explain) in &mut out {if let Some(authority) = authorities.get(&hit.id) {- let factor = authority.factor_for(session_recall, tuning.session_recall_bonus);+ let base = authority.factor_for(session_recall, tuning.session_recall_bonus);+ // Belief confidence is one more bounded factor folded *inside*+ // the existing authority clamp — never a new multiplier tower.+ let (confidence, belief_add) = if need_belief {+ let inputs = belief_inputs.get(&hit.id).copied().unwrap_or_default();+ let confidence = crate::belief::confidence(&inputs, belief_now);+ let add = if belief_weight > 0.0 && !boost_skip.contains(&hit.id) {+ Some(belief_weight * confidence)+ } else {+ None+ };+ (Some((inputs, confidence)), add)+ } else {+ (None, None)+ };+ let factor = match belief_add {+ Some(add) => (base + add).clamp(0.55, 1.50),+ None => base,+ };hit.rank = apply_rank_multiplier(hit.rank, factor);// `fused` stays the raw RRF sum; without the multiplier// beside it the explain could not account for the rank it// returns, which is the whole point of the surface.if let Some(details) = explain {details.authority = Some(factor);+ if let Some((inputs, confidence)) = confidence {+ details.evidence_count = Some(inputs.evidence_count);+ details.confidence = Some(confidence);+ details.belief_factor = belief_add;+ }if session_recall {details.intent = Some("session_recall");- details.intent_boost = Some(factor / authority.factor);+ // Report the routing lift over the pre-belief base so+ // the two factors stay separable in explain.+ details.intent_boost = Some(base / authority.factor);}}}@@ -5569,6 +5689,7 @@ impl ReaderPool {pages_all: count(conn, "SELECT COUNT(*) FROM pages")?,sessions: count(conn, "SELECT COUNT(*) FROM sessions")?,observations: count(conn, "SELECT COUNT(*) FROM observations")?,+ evidence_rows: count(conn, "SELECT COUNT(*) FROM page_evidence")?,};let activity_7d = window_activity(conn, 7, cutoff_7d)?;@@ -5747,6 +5868,14 @@ impl ReaderPool {workspace_id,project_id,)?,+ evidence_rows: count_project(+ conn,+ "SELECT COUNT(*) FROM page_evidence pe \+ JOIN pages p ON p.id = pe.page_id \+ WHERE p.workspace_id = ?1 AND p.project_id = ?2",+ workspace_id,+ project_id,+ )?,};let activity_7d = window_activity_project(conn, 7, cutoff_7d, workspace_id, project_id)?;@@ -6223,6 +6352,13 @@ impl ReaderPool {"SELECT COUNT(*) FROM observations WHERE workspace_id = ?1",workspace_id,)?,+ evidence_rows: count_workspace(+ conn,+ "SELECT COUNT(*) FROM page_evidence pe \+ JOIN pages p ON p.id = pe.page_id \+ WHERE p.workspace_id = ?1",+ workspace_id,+ )?,};let activity_7d = window_activity_workspace(conn, 7, cutoff_7d, workspace_id)?;@@ -8313,11 +8449,13 @@ impl ReaderPool {let pages_all: u64 = count(conn, "SELECT COUNT(*) FROM pages")?;let sessions: u64 = count(conn, "SELECT COUNT(*) FROM sessions")?;let observations: u64 = count(conn, "SELECT COUNT(*) FROM observations")?;+ let evidence_rows: u64 = count(conn, "SELECT COUNT(*) FROM page_evidence")?;Ok(StatusCounts {pages_latest,pages_all,sessions,observations,+ evidence_rows,})}).await@@ -8523,11 +8661,22 @@ impl ReaderPool {workspace_id,project_id,)?;+ // page_evidence carries no scope columns of its own; join through+ // pages to keep the count per-project (3-tuple identity, #4).+ let evidence_rows = count_project(+ conn,+ "SELECT COUNT(*) FROM page_evidence pe \+ JOIN pages p ON p.id = pe.page_id \+ WHERE p.workspace_id = ?1 AND p.project_id = ?2",+ workspace_id,+ project_id,+ )?;Ok(StatusCounts {pages_latest,pages_all,sessions,observations,+ evidence_rows,})}).awaitdiff --git a/crates/ai-memory-store/src/retrieval_tuning.rs b/crates/ai-memory-store/src/retrieval_tuning.rsindex 8a859b1e..41ec5d74 100644--- a/crates/ai-memory-store/src/retrieval_tuning.rs+++ b/crates/ai-memory-store/src/retrieval_tuning.rs@@ -36,6 +36,19 @@ pub struct RetrievalTuning {/// Add the L0 abstract-embedding stream to the RRF fusion. Reads/// `page_abstract_embeddings`; contributes nothing while it is empty.pub abstract_vectors: bool,+ /// Weight of the belief-strength confidence factor folded into+ /// [`crate::belief`] page authority (P2,+ /// `docs/design-hindsight-borrowings.md` §3). `0.0` (the default) leaves+ /// ranking byte-identical to a store that never heard of belief strength:+ /// no belief query runs and the authority factor is untouched. When+ /// positive, a page's derived `confidence` adds up to `weight * confidence`+ /// to its authority factor, still clamped inside the existing `[0.55,+ /// 1.50]` bounds — one more bounded factor, never a new multiplier tower.+ ///+ /// Ships OFF: this changes retrieval ranking, so per the design it must not+ /// default on without a positive R2 delta (retrieval-triple / QA), not yet+ /// performed.+ pub belief_authority_weight: f64,}impl Default for RetrievalTuning {@@ -50,6 +63,9 @@ impl Default for RetrievalTuning {// matters more than session recall.session_recall_bonus: 0.25,abstract_vectors: false,+ // OFF by default: folding belief confidence into ranking is+ // R2-gated (see the field doc).+ belief_authority_weight: 0.0,}}}@@ -140,6 +156,7 @@ mod tests {let t = RetrievalTuning::default();assert!(!t.session_recall_routing);assert!(!t.abstract_vectors);+ assert_eq!(t.belief_authority_weight, 0.0);}#[test]diff --git a/crates/ai-memory-store/tests/suite/belief_authority.rs b/crates/ai-memory-store/tests/suite/belief_authority.rsnew file mode 100644index 00000000..3a6b8049--- /dev/null+++ b/crates/ai-memory-store/tests/suite/belief_authority.rs@@ -0,0 +1,467 @@+//! Belief-strength confidence in ranking (P2,+//! docs/design-hindsight-borrowings.md §3).+//!+//! The evidence-derived `confidence` is exposed in `SearchExplain` inertly+//! (always), and folded into `PageAuthority` only behind the default-OFF+//! `belief_authority_weight`. These tests pin: (1) with the weight off, ranking+//! is unaffected while explain still exposes the fields; (2) with it on, a+//! high-distinct-session page outranks an equally-relevant low-evidence one;+//! (3) a supersession always wins regardless of the prior version's evidence —+//! a superseded version's stale evidence never boosts it (invariant #16 /+//! anti-entrenchment).++use ai_memory_core::{+ LinkTarget, NewPage, PageEvidence, PageEvidenceKind, PagePath, Relation, Tier,+};+use ai_memory_store::{RetrievalTuning, Store};++#[allow(clippy::too_many_arguments)]+fn page(+ ws: ai_memory_core::WorkspaceId,+ proj: ai_memory_core::ProjectId,+ path: &str,+ body: &str,+ evidence: Vec<PageEvidence>,+ links: Vec<LinkTarget>,+) -> NewPage {+ NewPage {+ workspace_id: ws,+ project_id: proj,+ path: PagePath::new(path).unwrap(),+ title: path.into(),+ body: body.into(),+ tier: Tier::Semantic,+ frontmatter_json: serde_json::json!({}),+ pinned: false,+ links,+ author_id: None,+ expires_at: None,+ entities: Vec::new(),+ evidence,+ }+}++/// `n` distinct supporting sessions.+fn sessions(n: usize) -> Vec<PageEvidence> {+ (0..n)+ .map(|i| PageEvidence {+ kind: PageEvidenceKind::Session,+ source_id: format!("session-{i}"),+ })+ .collect()+}++fn belief_tuning(weight: f64) -> RetrievalTuning {+ RetrievalTuning {+ belief_authority_weight: weight,+ ..RetrievalTuning::default()+ }+}++async fn store_with_scope() -> (+ tempfile::TempDir,+ Store,+ ai_memory_core::WorkspaceId,+ ai_memory_core::ProjectId,+) {+ let tmp = tempfile::tempdir().unwrap();+ let store = Store::open(tmp.path()).unwrap();+ let ws = store+ .writer+ .get_or_create_workspace("default".to_string())+ .await+ .unwrap();+ let proj = store+ .writer+ .get_or_create_project(ws, "app".to_string(), None)+ .await+ .unwrap();+ (tmp, store, ws, proj)+}++/// With the belief weight OFF (the default), ranking must be byte-identical to+/// a store that never accrued any evidence — evidence never touches authority —+/// yet an explained query still exposes the inert `confidence` and+/// `evidence_count`. This is the no-surprise-on-upgrade proof.+#[tokio::test]+async fn belief_off_is_byte_identical_but_explain_exposes_confidence() {+ // Byte-identity: the same two pages, one store where a.md carries heavy+ // evidence and one where it carries none. With the weight off, both must+ // produce the exact same ranks — a grid over the two pages.+ async fn ranks(a_evidence: usize) -> Vec<(String, f64)> {+ let (_tmp, store, ws, proj) = store_with_scope().await;+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/a.md",+ "widgetquux shared",+ sessions(a_evidence),+ vec![],+ ))+ .await+ .unwrap();+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/b.md",+ "widgetquux shared",+ vec![],+ vec![],+ ))+ .await+ .unwrap();+ assert_eq!(store.reader.retrieval_tuning().belief_authority_weight, 0.0);+ store+ .reader+ .hybrid_search(+ ws,+ proj,+ "widgetquux".to_string(),+ None,+ String::new(),+ String::new(),+ 0,+ 10,+ None,+ false,+ )+ .await+ .unwrap()+ .into_iter()+ .map(|h| (h.path.as_str().to_string(), h.rank))+ .collect()+ }+ let with_evidence = ranks(6).await;+ let without = ranks(0).await;+ assert_eq!(+ with_evidence, without,+ "evidence must not change any rank while the belief weight is off"+ );++ // Exposure is on regardless: an explained query surfaces the count and a+ // positive confidence for the supported page, and 0 for the bare one —+ // without folding anything into the rank (belief_factor stays None).+ let (_tmp, store, ws, proj) = store_with_scope().await;+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/a.md",+ "widgetquux shared",+ sessions(6),+ vec![],+ ))+ .await+ .unwrap();+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/b.md",+ "widgetquux shared",+ vec![],+ vec![],+ ))+ .await+ .unwrap();+ let hits = store+ .reader+ .hybrid_search_explained(+ ws,+ proj,+ "widgetquux".to_string(),+ None,+ String::new(),+ String::new(),+ 0,+ 10,+ None,+ false,+ )+ .await+ .unwrap();+ let a = hits+ .iter()+ .find(|(h, _)| h.path.as_str() == "notes/a.md")+ .unwrap();+ let b = hits+ .iter()+ .find(|(h, _)| h.path.as_str() == "notes/b.md")+ .unwrap();+ assert_eq!(+ a.1.authority, b.1.authority,+ "evidence must not change authority when off"+ );+ assert_eq!(a.1.belief_factor, None);+ assert_eq!(b.1.belief_factor, None);+ assert_eq!(a.1.evidence_count, Some(6));+ assert!(a.1.confidence.unwrap() > 0.0);+ assert_eq!(b.1.evidence_count, Some(0));+ assert_eq!(b.1.confidence, Some(0.0));+}++/// With the weight ON, the well-supported page (more distinct sessions) must+/// outrank an equally-relevant page with no evidence, and explain must account+/// for it via `belief_factor`.+#[tokio::test]+async fn belief_on_boosts_the_higher_evidence_page() {+ let (_tmp, mut store, ws, proj) = store_with_scope().await;+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/a.md",+ "widgetquux shared",+ sessions(8),+ vec![],+ ))+ .await+ .unwrap();+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/b.md",+ "widgetquux shared",+ vec![],+ vec![],+ ))+ .await+ .unwrap();++ store.reader.set_retrieval_tuning(belief_tuning(0.5));+ let hits = store+ .reader+ .hybrid_search_explained(+ ws,+ proj,+ "widgetquux".to_string(),+ None,+ String::new(),+ String::new(),+ 0,+ 10,+ None,+ false,+ )+ .await+ .unwrap();+ assert_eq!(+ hits[0].0.path.as_str(),+ "notes/a.md",+ "the supported page must lead"+ );+ let a = hits+ .iter()+ .find(|(h, _)| h.path.as_str() == "notes/a.md")+ .unwrap();+ let b = hits+ .iter()+ .find(|(h, _)| h.path.as_str() == "notes/b.md")+ .unwrap();+ assert!(a.0.rank < b.0.rank);+ assert!(a.1.belief_factor.unwrap() > 0.0);+ assert!(a.1.authority.unwrap() > b.1.authority.unwrap());+ // The bare page's confidence is 0, so its applied belief factor is 0.+ assert_eq!(b.1.belief_factor, Some(0.0));+}++/// A live contradiction must lower a page's confidence relative to an+/// otherwise-identical page — the "weaken" half of strengthen/weaken/extend.+#[tokio::test]+async fn a_live_contradiction_lowers_confidence() {+ let (_tmp, mut store, ws, proj) = store_with_scope().await;+ // Target the contradiction points at must exist as a latest page for the+ // edge to count as live.+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/target.md",+ "target body",+ vec![],+ vec![],+ ))+ .await+ .unwrap();+ // Two equally-supported pages; one declares it contradicts the target.+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/clean.md",+ "widgetquux shared",+ sessions(5),+ vec![],+ ))+ .await+ .unwrap();+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "notes/disputed.md",+ "widgetquux shared",+ sessions(5),+ vec![LinkTarget {+ workspace: None,+ project: None,+ path: PagePath::new("notes/target.md").unwrap(),+ relation: Some(Relation::Contradicts),+ }],+ ))+ .await+ .unwrap();++ store.reader.set_retrieval_tuning(belief_tuning(0.5));+ let hits = store+ .reader+ .hybrid_search_explained(+ ws,+ proj,+ "widgetquux".to_string(),+ None,+ String::new(),+ String::new(),+ 0,+ 10,+ None,+ false,+ )+ .await+ .unwrap();+ let clean = hits+ .iter()+ .find(|(h, _)| h.path.as_str() == "notes/clean.md")+ .unwrap();+ let disputed = hits+ .iter()+ .find(|(h, _)| h.path.as_str() == "notes/disputed.md")+ .unwrap();+ assert!(+ disputed.1.confidence.unwrap() < clean.1.confidence.unwrap(),+ "a live contradiction must weaken the belief"+ );+ // Same evidence count; only the contradiction differs.+ assert_eq!(disputed.1.evidence_count, clean.1.evidence_count);+}++/// The anti-entrenchment guarantee: a superseding correction always takes and+/// is the returned answer, no matter how much evidence the prior version had —+/// and a superseded version's stale evidence never boosts it in ranking, even+/// with the belief weight cranked up (invariant #16).+#[tokio::test]+async fn supersession_always_wins_regardless_of_prior_evidence() {+ let (_tmp, mut store, ws, proj) = store_with_scope().await;+ // v1: a heavily-supported prior belief.+ store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "decisions/queue.md",+ "queue zzentry against",+ sessions(8),+ vec![],+ ))+ .await+ .unwrap();+ // A human/agent correction supersedes it. Different body → a new version;+ // it starts its own (small) evidence trail.+ let latest_id = store+ .writer+ .upsert_page(page(+ ws,+ proj,+ "decisions/queue.md",+ "queue zzentry adopt",+ sessions(1),+ vec![],+ ))+ .await+ .unwrap();++ // Even with the belief weight high, the correction is what a normal query+ // returns — evidence never gates whether the write took.+ store.reader.set_retrieval_tuning(belief_tuning(0.8));+ let hits = store+ .reader+ .hybrid_search(+ ws,+ proj,+ "queue zzentry".to_string(),+ None,+ String::new(),+ String::new(),+ 0,+ 10,+ None,+ false,+ )+ .await+ .unwrap();+ assert_eq!(+ hits.len(),+ 1,+ "default search returns the latest version only"+ );+ assert_eq!(+ hits[0].id, latest_id,+ "the correction, not the high-evidence prior, is returned"+ );+ assert!(!hits[0].superseded);++ // With superseded versions surfaced, the stale high-evidence prior must NOT+ // be boosted past the correction: its belief factor is withheld.+ let explained = store+ .reader+ .hybrid_search_explained(+ ws,+ proj,+ "queue zzentry".to_string(),+ None,+ String::new(),+ String::new(),+ 0,+ 10,+ None,+ true,+ )+ .await+ .unwrap();+ let latest = explained.iter().find(|(h, _)| h.id == latest_id).unwrap();+ let prior = explained+ .iter()+ .find(|(h, _)| h.path.as_str() == "decisions/queue.md" && h.id != latest_id)+ .expect("the superseded prior version should surface with include_superseded");++ assert!(prior.0.superseded);+ assert_eq!(+ prior.1.evidence_count,+ Some(8),+ "the prior kept its evidence trail"+ );+ assert_eq!(+ prior.1.belief_factor, None,+ "a superseded version's stale evidence must never boost it"+ );+ assert!(+ latest.1.belief_factor.is_some(),+ "the live correction is the one belief may shade"+ );+ assert!(+ latest.0.rank <= prior.0.rank,+ "the correction must not rank below its own superseded, higher-evidence prior"+ );+}diff --git a/crates/ai-memory-store/tests/suite/mod.rs b/crates/ai-memory-store/tests/suite/mod.rsindex ea791faa..f2529030 100644--- a/crates/ai-memory-store/tests/suite/mod.rs+++ b/crates/ai-memory-store/tests/suite/mod.rs@@ -7,6 +7,7 @@ mod agent_messages;mod audit_contamination;mod audit_log;mod auto_improve_staging;+mod belief_authority;mod client_activity;mod fts_drift_status;mod handoff_ownership;diff --git a/crates/ai-memory-store/tests/suite/retrieval_tuning_streams.rs b/crates/ai-memory-store/tests/suite/retrieval_tuning_streams.rsindex 1d1e4454..c16563a4 100644--- a/crates/ai-memory-store/tests/suite/retrieval_tuning_streams.rs+++ b/crates/ai-memory-store/tests/suite/retrieval_tuning_streams.rs@@ -35,6 +35,7 @@ fn tuning(session_recall: bool, bonus: f64, abstract_vectors: bool) -> Retrievalsession_recall_routing: session_recall,session_recall_bonus: bonus,abstract_vectors,+ belief_authority_weight: 0.0,}}diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 5de6e7df..907f49ac 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -291,7 +291,7 @@ separately gated Claude Code assistant/Stop excerpt remains capped at 2 KB.| `page_embeddings` | Optional vector rows for latest pages, with `(provider, model, dim)` denormalised so hybrid search can ignore stale vectors after an embedding config change and report missing-embedding diagnostics. || `page_feedback` | Append-only `memory_feedback` signals (`helpful` / `not_helpful` / `stale` / `wrong`) keyed by page *version*, with an optional sanitized reason and `salience_after`. Source of truth for the derived `pages.salience`; the lint pass reads unresolved stale/wrong rows joined against `is_latest = 1`, so a rewrite retires the finding. || `page_access` | One row per latest page and qualified operator identity. Supplies the optional access-breadth retention term without changing the existing shared access counter. |-| `page_evidence` | V63 append-only record of what produced or reaffirmed each page version — consolidation cites the `session` it ran on, written in the page-upsert transaction and cascaded on purge. Surfaced as `evidence_count` in `memory_query(explain=true)` and used to order the opt-in `settled_first` briefing. Ranking-inert: the confidence→authority factor is deferred behind the eval harness (`docs/design-hindsight-borrowings.md` P2). |+| `page_evidence` | V63 append-only record of what produced or reaffirmed each page version — consolidation cites the `session` it ran on, written in the page-upsert transaction and cascaded on purge. Feeds a read-time, zero-LLM **belief-strength `confidence`** (`ai_memory_store::belief`, B1 / `docs/design-hindsight-borrowings.md` P2): a bounded `[0.0, 0.95]` function of distinct supporting sessions (breadth, not raw count), recency of the newest sighting, and live `contradicts` count. Exposed as `confidence` + `evidence_count` in `memory_query(explain=true)`, as `evidence_rows` in `memory_status`, and used to order the opt-in `settled_first` briefing — all **ranking-inert**. It folds into `PageAuthority` only behind `[retrieval] belief_authority_weight` (**default `0.0`/OFF, R2-gated**), as one bounded factor inside the `[0.55, 1.50]` clamp; a supersession always wins regardless of evidence (a superseded version is never boosted). || `agent_messages` | V64 cross-project message inbox/queue (`docs/agent-messaging.md`). Directed, claim-once mail from a sender coordinate to a recipient coordinate; `pending`→`claimed` (popped exactly once, the handoff compare-and-set) or `pending`→`cancelled` (sender retracts). The one table that crosses per-project isolation, so reads are keyed by the recipient coordinate (inbox) or sender coordinate (outbox); `from_owner_user`/`claimed_by_user` are attribution only, never a read filter. Recipient inbox depth is capped. `ON DELETE CASCADE` on both coordinate pairs. || `pages.compacted_at` | V65 nullable A2 tier-down marker (`docs/design-memory-aging.md` §A2). Set when the forget-sweep extractively compacts a cold episodic page (opt-in `[decay] compact_cold_episodic`) instead of evicting it; derived at the single page-upsert choke point from a `compacted: true` frontmatter mirror, so the marker and compacted body land in one transaction. Additive `ADD COLUMN`, no backfill — populated lazily by the sweep. The sweep and curator skip a marked page so it is never re-compacted, re-evicted, or re-reported as cold. Reversible: the full pre-compaction body stays in git + the supersession chain. || `client_activity` | Server-wide MCP tool-call counters split into reads/writes and bucketed by UTC day. The MCP request choke point flushes buffered calls on a one-minute background interval; failed batches retry from bounded memory. Each day stores at most 128 sanitized client labels plus `other`, so an untrusted `clientInfo.name` cannot create traffic-proportional rows. |@@ -685,6 +685,12 @@ session_recall_bonus = 0.25 # extra authority on top of the cancelled penaabstract_vectors = false # fifth RRF stream over page_abstract_embeddings# (L0: each page's frontmatter `abstract:` line, embedded# by the same backfill as the body)+belief_authority_weight = 0.0 # fold read-time belief-strength confidence (P2) into page+ # authority as ONE bounded factor inside the [0.55, 1.50]+ # clamp. 0.0 = OFF (default): ranking is byte-identical and+ # no belief query runs. confidence/evidence_count are still+ # exposed in explain regardless (inert). DEFAULT OFF,+ # R2-gated: do not default on without a positive R2 delta.```**LLM provider env** (opt-in):