tt_retrieval/lib.rs
1//! `tt-retrieval` — RAG / context-compression engine.
2//!
3//! See `docs/superpowers/specs/2026-05-28-trackE-rag-context-compression-design.md`.
4
5#[cfg(feature = "postgres")]
6pub mod audit;
7pub mod chunking;
8pub mod embed;
9pub mod error;
10pub mod search;
11pub mod store;
12pub mod substitute;
13pub mod tags;
14pub mod types;
15
16pub use error::RetrievalError;
17pub use store::RetrievalStore;
18pub use substitute::{substitute_in_messages, SubstitutionReport, DEFAULT_MIN_SIMILARITY};
19pub use types::{Chunk, Corpus, Document, RetrievableTag, RetrievalResult};
20
21/// True if every component is finite (no NaN/Inf). A non-finite embedding makes
22/// cosine distance NaN and corrupts top-k ranking, so it is rejected at the
23/// embed chokepoint and at store insert (mirrors the L2 cache guard).
24///
25/// Note: an empty slice is vacuously finite (`true`). Emptiness is a separate
26/// concern — the pgvector `vector(1536)` column rejects a zero-dim insert with a
27/// `Store` error; this guard only screens NaN/Inf.
28pub(crate) fn embedding_is_finite(v: &[f32]) -> bool {
29 v.iter().all(|x| x.is_finite())
30}