1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Memory bounded context for the CFA agent platform (Phase 26).
//!
//! Implements ADR-016 (memory architecture) and the
//! `feature_memory.yml` contracts (RUF-MEM-001..010 + RUF-MEM-INV-001..005).
//!
//! The bounded context owns the canonical record of CFA runtime activity at
//! the four runtime surfaces declared in ADR-015 — `Cli`, `Mcp`, `Skill`,
//! and `Plugin` — plus the indexing and retrieval substrate that makes
//! cross-session retrieval ("most similar past run") possible.
//!
//! ## Module layout
//!
//! - [`types`] — domain types (`RunSummary`, `Surface`, `EntityRef`,
//! `EntityKind`, `CfaSession`, `MemoryQuery`).
//! - [`hnsw_index`] — HNSW vector store wrapping [`hnsw_rs`] with a
//! side `HashMap<Uuid, RunSummary>` for record retrieval.
//! - [`bm25_index`] — BM25 keyword inverted index wrapping [`tantivy`].
//! - [`cfa_session`] — portable session archive (JSON + `flate2` gzip).
//!
//! Entity graph and tag-based entity extraction live in the multi-agent
//! coordination context at [`crate::multi_agent::entity_graph`] (Phase 27);
//! the Phase 26 placeholder stub that previously lived here was removed in
//! Phase 28 cleanup. Memory tests that exercise entity extraction now reach
//! into the multi-agent module directly under `cfg(feature = "multi_agent")`.
//!
//! ## On-disk persistence format (HNSW + summary side-store)
//!
//! `HnswMemoryIndex::save_to(path)` writes a single gzip-compressed JSON
//! envelope containing:
//!
//! - `version: u32` — currently `1`.
//! - `params: { m, ef_construction, embedding_dim }`.
//! - `summaries: Vec<RunSummary>` — one entry per ingested record.
//!
//! On `load_from(path)` the HNSW graph is rebuilt by re-inserting every
//! summary's embedding into a fresh in-memory index. The graph itself is
//! not serialised; the summary side-store is the ground truth and the
//! graph is treated as a derived view that can always be rebuilt — this
//! keeps the format crate-version-agnostic across `hnsw_rs` minor bumps.
//!
//! ## Feature gating
//!
//! The whole module is gated behind the `memory` cargo feature at the
//! crate root (`lib.rs`). Internal files do not repeat the gate.
pub use ;
pub use ;
pub use HnswMemoryIndex;
pub use ;