Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix: align hybrid authority candidate windows
AkitaOnRailsf55e32c07194
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 35fdf753..1b000e68 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -39,6 +39,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0including subdirectories and linked worktrees. (#259)### Fixed+- Hybrid search now gives its FTS, vector, and graph streams the same bounded+ candidate window used by authority-aware FTS search. Small result limits no+ longer exclude a canonical page before post-fusion authority ranking can+ promote it, and candidate-limit arithmetic is saturating throughout. (#276)- Forced workspace deletion now removes the immutable managed-workstreamsegment directories whose database rows are removed by the workspacecascade. Its admin report includes workstream/run counts and IDs, and rawdiff --git a/crates/ai-memory-store/src/lib.rs b/crates/ai-memory-store/src/lib.rsindex 5baa8095..7a4e9204 100644--- a/crates/ai-memory-store/src/lib.rs+++ b/crates/ai-memory-store/src/lib.rs@@ -2214,7 +2214,7 @@ mod tests {String::new(),String::new(),0,- 10,+ 1,).await.unwrap();diff --git a/crates/ai-memory-store/src/reader.rs b/crates/ai-memory-store/src/reader.rsindex d9ec7b3e..8ed08601 100644--- a/crates/ai-memory-store/src/reader.rs+++ b/crates/ai-memory-store/src/reader.rs@@ -2139,14 +2139,15 @@ impl ReaderPool {dim: u32,limit: usize,) -> StoreResult<Vec<PageHit>> {+ // Authority is applied after RRF, so every stream needs the same+ // bounded candidate window used by FTS-only search. A `limit * 2`+ // window was too narrow at small limits for a canonical page to enter+ // the fused pool and receive its bounded promotion.+ let candidate_limit = authority_candidate_limit(limit);+// Fetch FTS5 hits first.let fts_candidates = self- .search_page_candidates_for_project(- workspace_id,- project_id,- query,- limit.saturating_mul(2),- )+ .search_page_candidates_for_project(workspace_id, project_id, query, candidate_limit).await?;let mut authorities: std::collections::HashMap<PageId, PageAuthority> = fts_candidates.iter()@@ -2166,7 +2167,7 @@ impl ReaderPool {provider,model,dim,- limit * 2,+ candidate_limit,).await?;}@@ -2183,7 +2184,7 @@ impl ReaderPool {}}let graph_hits = self- .graph_neighbors_for_project(workspace_id, project_id, seed_ids, limit * 2)+ .graph_neighbors_for_project(workspace_id, project_id, seed_ids, candidate_limit).await?;// RRF fuse: score(d) = Σ 1/(k + rank_i(d)) over rankers.@@ -5436,6 +5437,17 @@ mod tests {AgentKind, Handoff, HandoffId, HandoffState, NewHandoff, ProjectId, SessionId, WorkspaceId,};+ #[test]+ fn authority_candidate_window_is_bounded_and_saturating() {+ use super::authority_candidate_limit;++ assert_eq!(authority_candidate_limit(0), 0);+ assert_eq!(authority_candidate_limit(1), 20);+ assert_eq!(authority_candidate_limit(10), 40);+ assert_eq!(authority_candidate_limit(1_000), 1_300);+ assert_eq!(authority_candidate_limit(usize::MAX), usize::MAX);+ }+/// Build an open handoff for the pure-selection tests. `manual` toggles/// the manual (`from_session_id == None`) vs auto distinction; `t` is the/// creation time in microseconds; `summary` doubles as a label to assertdiff --git a/docs/vector-backend-policy.md b/docs/vector-backend-policy.mdindex 868480d1..8a4c5297 100644--- a/docs/vector-backend-policy.md+++ b/docs/vector-backend-policy.md@@ -11,9 +11,10 @@ pages per project. At that size, brute-force cosine is simple,inspectable, and fast enough, especially because vector retrieval is onlyone signal in the query path. `memory_query` already combines FTS5,graph-neighbor expansion, optional vector RRF, and raw observation-fallback. A bounded page-authority adjustment runs after those candidate-streams, so semantic similarity cannot by itself declare a session page more-canonical than a maintained decision.+fallback. Each stream contributes through the same bounded candidate window,+then a page-authority adjustment runs after fusion, so semantic similarity+cannot by itself declare a session page more canonical than a maintained+decision.Adding `sqlite-vec` would add operational surface before it has provenvalue: