Expand description
FathomDB engine — the runtime core: storage, projections, ingest and query.
⚠ Most consumers should depend on the fathomdb facade crate instead.
fathomdb re-exports exactly the governed application surface and gates the
operator/recovery seam behind a cargo feature; this crate is the
implementation and exposes internals the facade deliberately withholds.
Depend on it directly only if you are building FathomDB tooling.
§What it does
One Engine owns an embedded SQLite database (FTS5 + sqlite-vec), the
single writer thread, a thread-affine reader pool serving DEFERRED-tx
snapshots, the background projection scheduler, and — optionally — an
in-process embedder. There is no server and no sidecar.
- Hybrid retrieval. A vector branch and an FTS5 branch, fused by Reciprocal Rank Fusion on ordinal rank (never on raw, non-comparable scores), with an optional CPU cross-encoder rerank and an optional graph-BFS third arm over temporal fact edges.
- Canonical rows + projections. Writes land as durable canonical rows; FTS, vector and attribute indexes are engine-maintained projections rebuildable from them.
- Record lifecycle. Transaction-time supersession keyed on
logical_id, an existence axis (transition/purge), and world-time validity windows on nodes plust_valid/t_invalidon edges. - Deletion on request.
Engine::erase_sourceerases every row carrying a provenance id — including anonymous rowsEngine::purgecannot reach — and finishes the erasure at rest.
§Provenance is mandatory
PreparedWrite::Node and PreparedWrite::Edge carry source_id: SourceId,
a newtype rather than an Option<String>. Engine::erase_source addresses
rows by source_id, so a row written without one could never be erased;
SourceId::new is the only public constructor and makes that state
inexpressible.
§Stability
Pre-1.0, so beta. SCHEMA_VERSION is the on-disk contract; migrations
run at open and only there. PreparedWrite, SearchFilter and
EngineError are #[non_exhaustive] or documented as additive.
Re-exports§
pub use lifecycle::Subscription;
Modules§
- lifecycle
- Lifecycle observability data types.
Structs§
- Bm25f
Field Weights - F5 (0.8.14 Slice 10) — per-field BM25F weights for the
search_index_v2multi-column FTS index. One weight per indexed field (kind/body/status), applied as the field’s contribution multiplier in the BM25F weighted-term-frequency accumulation. - Bm25f
Query Plan - F5 (0.8.14 Slice 10) — the compiled BM25F query plan for the fielded lexical
arm (
ADR-0.8.1§3.2BM25fQueryPlan). Carries the tunable per-fieldweightsand the tunable length-normalizationb(and the term-saturationk1). - Boundary
Crossing - 0.8.20 Slice 10b (R-20-NV) — one node that crossed a validity boundary
inside the interrogated interval, as reported by
Engine::crossed_boundary_since. - Check
Integrity Opts - Doctor
check-integrityinvocation flags.quickandround_tripare accepted in 0.6.0 but treated as default; onlyfullactivatesPRAGMA integrity_check. Perdev/design/recovery.md§ Doctor-only flags. - Consolidate
Axis - 0.8.12 Slice 15 (OPP-2, ADR-0.8.12) — one (subject-entity, relation) axis to
consolidate via
Engine::consolidate_with_provider. FathomDB assembles the competing fact-edge cluster for this axis DETERMINISTICALLY (CPU-only, no LLM) by querying activecanonical_edgeswherefrom_id = subject_logical_idANDkind = relation. - Consolidate
Candidate Edge - 0.8.12 Slice 15 (OPP-2, ADR-0.8.12) — one competing fact-edge in a candidate
cluster sent to the consolidation harness. Assembled deterministically from
canonical_edges; sent to the harness as the request payload; the harness’s verdict references edges back byedge_ref(the edge’s stablelogical_id). - Consolidate
Receipt - 0.8.12 Slice 15 (OPP-2, ADR-0.8.12) — receipt returned by
Engine::consolidate_with_provider. Consolidation records supersession / recency METADATA only (§2.1): edge bodies are never rewritten and no row is ever deleted, so these counts describe metadata transitions, not content changes. - Corruption
Detail - Stable corruption-on-open detail carried by
EngineOpenError::Corruption. - Counter
Snapshot - Snapshot of engine-internal counters returned by
Engine::counters. - Dump
Profile Report - Result of [
Engine::dump_profile]. Mirrors the open-time embedder posture + the per-kind vector configuration registered in_fathomdb_vector_kinds. - Dump
RowCounts Report - Result of [
Engine::dump_row_counts]. Canonical tables only; projection / FTS / vec0 shadow tables are excluded. Order matchesfathomdb_schema::CANONICAL_TABLES. - Dump
Schema Report - Result of [
Engine::dump_schema].user_versionis thePRAGMA user_versionsentinel. Canonical tables appear first perfathomdb_schema::CANONICAL_TABLES, then remaining non-sqlite_*tables alphabetically. Indexes follow the same alphabetical rule. - Engine
- Excise
Record Report - 0.8.20 Slice 5b (R-20-E7) — outcome of
[
Engine::excise_collection_record].records_excisedcounts the erasedoperational_mutationsversions (an append-only-log collection keeps every version of a key);state_rows_excisedcounts the erasedoperational_staterow (0 or 1). - Excise
Report - Phase 9 Pack B excise report (AC-028a/b/c). Counts are post-excise
totals;
projections_invalidatedreports the shadow-row invalidation total (FTS5 + vec0 + projection terminal) for the excised source. - Explanation
- 0.8.8 EXP-OBS (Slice 5) — the opt-in retrieval explanation payload returned
behind
search_explained(theexplain=truesurface). Built from the engine’s OWN fusion/rerank machinery (fuse_three_armsper-arm ranks,ce_rerankblend components) — no parallel machinery (R-OBS-3). Carries a query-levelQueryTraceplus a per-hit breakdown parallel to (and in the same order as)SearchResult.results. - Extract
Document - G11 (Slice 15) — a document sent to a BYO-LLM extraction harness via
Engine::ingest_with_extractor. - Filter
- 0.8.11 Slice 40 (#17) — the unified closed
Filtercontract. ONE superset type with implicit-ANDFilterTerms, dispatched to one of two internal compilation backends (Option A — the TYPE unifies, the COMPILATION dispatches): the vec0-metadata indexed pre-KNNWHEREforsearch_filtered, andjson_extractovercanonical_nodes.bodyforread.list. The shippedSearchFilter(G10) andPredicatelists (G4) re-express as sugar that lowers into this type (D4); thefilter=Nonebyte-identical-0.7.2-SQL pin is preserved because the vec0 lowering routes back through the shippedvector_filter_clausecompilation verbatim. - Finding
- Single doctor finding record. Stable report-shape per AC-043c. The
codeanddoc_anchorstrings are stable dispatch keys owned bydev/design/recovery.md§ Code-to-operator-action cross-reference. - Graph
Frontier Stats - G0 Phase-2 (E0a / BLOCK-1) — graph-arm frontier instrumentation. A
side-channel meter (deliberately NOT a
SearchResult/SearchHitfield — byte stability) that proves whether the graph arm seeds a non-empty frontier. Under the current doc-seeded path the frontier is empty (doc nodes carrylogical_id = NULL), soseeds_resolved == 0andresolved_seed_rate == 0.0— this meter is the measurement that proves it (and, post-C1, the 0→>0 flip). - IdSpace
- C-2 (0.8.19 / OPP-12 Phase-1, TC-8) — the typed, non-null, id-space-total
carrier for
SearchHit::id. Subsumes the interimwrite_cursorid AND the additive Cause-Astable_idfield of prior releases: thevalueis the BARE id (prefix stripped), andto_prefixedreproduces the pre-swapstable_idstring byte-for-byte (l:/h:unchanged) so cross-session real-gold keying continues onidas a true no-op. - Ingest
With Extractor Receipt - G11 (Slice 15) — receipt returned by
Engine::ingest_with_extractor. - Integrity
Report - Three-section integrity report. AC-043a pins exactly these three keys.
- Mean
Recompute Report - 0.7.2 PR-2b — result of [
Engine::recompute_mean] (the manualdoctor recompute-meanpath) and of the shared in-transaction recompute core.drift_cos_beforeis the cosine between the freshly derived corpus mean and the previously-pinned mean (1.0 when nothing was pinned yet, i.e. a first pin).mean_was_pinneddistinguishes a refresh of an existing mean from an initial pin. Seedev/design/embedder.md§0.3. - Node
Record - Slice 30 (G2) — an active canonical node row returned by
read.get/read.get_many. - OpStore
Row - Slice 30 (G3) — one
operational_mutationsrow returned byread.collection/read.mutations.idis the autoincrement PK (the after-id cursor key). - Open
Report - Opened
Engine - Orphan
Provenance Report - Result of [
Engine::orphan_provenance] — the per-source_idcensus behindfathomdb doctor orphan-provenance(design §4 item 11). - Orphan
Provenance Source - 0.8.20 Slice 5d (R-20-E8) — one
source_idbucket in anOrphanProvenanceReport.source_idisNonefor the NULL-provenance bucket, which after migration step 21 should contain ONLY governed NODES. - PerHit
Explain - 0.8.8 EXP-OBS (Slice 5) — per-hit provenance + score breakdown. One entry per
returned
SearchHit, same order.*_rankis the 0-based rank the hit’s body held in that arm’s pre-fusion list (None= absent from that arm). - Projection
Delta - 0.8.20 Slice 15d (R-20-PR) — the diff
Engine::configure_projectionsapplied. Idempotent re-registration yieldsunchanged == truewith all vecs empty (the “re-registration is a no-op” acceptance signal). A destructive change without an explicitdropis anErr, not a delta. - Projection
Fts - 0.8.20 Slice 15d (R-20-PR) — the
searchable→FTSsub-target selector. - Projection
Runtime Status - A pure, current view of projection-runtime facts for one open engine session.
- Projection
Runtime Status Entry - One declaration’s current dense status in
ProjectionRuntimeStatus. - Projection
Spec - 0.8.20 Slice 15d (R-20-PR / C-1) — a single declarative projection
declaration. HITL-ratified shape (
api-surface.md:85-89):{ name, roles: Set<ProjectionRole>, fts?, vector? }.rolescarries SET semantics (dedup + membership; an attribute can beFilterableANDSearchable) — encoded here as a sorted, de-duplicatedBTreeSet. Namedroles, notkind(kindis the node/edge type discriminator). - Projection
Vector - 0.8.20 Slice 15d (R-20-PR) — the
searchable→vectorsub-target selector. - Query
Trace - 0.8.8 EXP-OBS (Slice 5) — query-level retrieval trace. Reuses the existing
search_rerankedknobs + the active embedder identity; timings are coarse per-stage wall-clock (monotonic) captured only on the explain path. - Read
View - 0.8.20 Slice 10b (R-20-RV / R-20-NV) — the read view: the single knob
that decides which
canonical_nodesrows a read verb may see. - Rebuild
Report - Structured result of a rebuild operation.
rows_invalidatedis the total shadow-state rows truncated before re-derivation;rows_rebuiltis the count of rows the synchronous rebuild loop re-materialised (asynchronous re-enqueue work performed by the projection scheduler is not counted here).projection_cursor_afteris the post-rebuild value of the projection cursor. - Recovery
Hint - Recovery dispatch surface attached to a corruption detail.
- Safe
Export Artifact - Result of a successful [
Engine::safe_export] call. The returnedmanifest_sha256equals the SHA-256 of the export file bytes (per AC-039a) and matches thesha256field written into the manifest JSON. - Schema
Object - Single table or index entry emitted by [
Engine::dump_schema]. - Search
Expand Result - Slice 20 (G6) — result of
Engine::search_expand: initial search hits plus nodes reached by bounded BFS expansion that are not already in the search hit set. - Search
Filter - G10 — closed metadata filter for
Engine::search_filtered(Slice 10). - Search
Hit - Derives
Clone, Debug, PartialEqbut notEq—score: f64forbids total equality. - Search
Result - Hybrid
searchresult.resultscarries structuredSearchHits in vector-first, dedup-on-body order. DerivesClone, Debug, PartialEqbut notEq— each hit carries ascore: f64. - Soft
Fallback - Soft-fallback signal carried on hybrid
searchresults. - Source
Id - 0.8.20 Slice 5c (R-20-E3) — the provenance of a canonical row: which source
document it is attributable to, and therefore what
excise_sourcemust erase when that source is withdrawn. - Table
RowCount - Single canonical-table row count emitted by [
Engine::dump_row_counts]. - Trace
Event - Single canonical-row tracing record.
tableis one of"canonical_nodes"or"canonical_edges". - Trace
Report - Phase 9 Pack B trace report (AC-042). One event per canonical row
attributable to the requested
source_id, ordered bywrite_cursorascending. - Truncate
WalReport - Result of [
Engine::truncate_wal]. Carries the three counters returned byPRAGMA wal_checkpoint(TRUNCATE):busy,log_frames,checkpointed_frames. - Verify
Embedder Report - Result of [
Engine::verify_embedder].stored_identityis thename:revisionpair persisted in_fathomdb_embedder_profiles;supplied_identityechoes the operator’s input verbatim. - Write
Receipt
Enums§
- Comparison
Op - G4 (Slice 35) — comparison operator for
Predicate::JsonPathCompare. - Corruption
Kind - Open-path corruption category.
- Corruption
Locator - Locator pointing at the corrupted region of the database file.
- Dense
Readiness - 0.8.20 Slice 20 (R-20-DR) — the ENGINE-SET readiness of the
searchable→vectorprojection, perdev/design/record-lifecycle-protocol/projection-registry-and-async-embed.md§3. - Embedder
Choice - Caller-facing selector for the embedder used by an opened engine
(
dev/design/embedder.md§0). - Engine
Error - Engine
Open Error - Filter
Term - 0.8.11 Slice 40 (#17) — a single closed
FilterTermof the unified filter grammar (ADR-0.8.11-filter-grammar-unification, Option A; closes reserved-gap 37). Exactly five variants: the four G10 shorthand metadata fields (SourceType/Kind/CreatedAfter/Status) plus the general G4 json-pathPredicate(Json). The shorthand fields are dedicated typed variants — NOTJson(Predicate)over$.source_typeetc. — precisely so the vec0 search backend can lower them to the indexed pre-KNN metadata columns while typed-rejecting an arbitraryJsonterm (D3: no demotion to post-KNNjson_extract). - IdSpace
Kind - A single structured search hit (G1 / AC-057a-clean).
- Initial
State - OPP-12 Phase-1 (0.8.19 Slice 5) — the CREATE-TIME subset of
LifecycleState. - Lifecycle
State - OPP-12 record-lifecycle Phase-1 (0.8.19 Slice 5) — the existence axis.
- Open
Stage Engine.openstage at which corruption was detected.- Predicate
- G4 (Slice 35) — closed typed predicate for
Engine::read_listfilter. - Prepared
Write - Batch input shape for
Engine::write. - Projection
Role - 0.8.20 Slice 15d (R-20-PR, C-1) — one member of a
ProjectionSpec’s role set. Exactly three members (HITL-ratified S8,api-surface.md:87):searchable→FTSandsearchable→vectorare NOT roles — they are tier labels carried by thefts/vectorsub-objects of the spec, so an attribute isSearchableonce and the sub-objects select FTS-only / vector-only / both. - Projection
Runtime Unavailability Reason - The reason
ProjectionRuntimeStatus::runtime_embedder_availableis false. - Projection
Status Dense Readiness - The dense-readiness projection of
ProjectionRuntimeStatusEntry. - Rebuild
Kind - Which shadow-state surface a
RebuildReportdescribes.Projectionscovers the full FTS5 + vec0 + projection-terminal rebuild emitted by [Engine::rebuild_projections].Vec0covers the vec0-only path emitted by [Engine::rebuild_vec0]. - RowKind
- EXP-S (0.8.14 Slice 5, D1) — structural-role tag for a canonical row.
- Scalar
Value - G4 (Slice 35) — scalar value for
Predicatecomparisons. - Section
- One section of an
IntegrityReport. Either every check in the section was clean, or one or more typedFindings describe the detected issue. Per AC-043b. - Soft
Fallback Branch - Which retrieval branch produced a hit (or could not contribute).
- Traversal
Direction - Slice 20 (G5) — direction of graph traversal for
Engine::graph_neighbors/Engine::search_expand. - Truncate
WalStatus - Typed outcome of [
Engine::truncate_wal].Donematches SQLite’sbusy = 0return fromPRAGMA wal_checkpoint(TRUNCATE); any other value surfaces asBusy. - Verify
Embedder Status - Typed outcome of [
Engine::verify_embedder]. Mismatches do not raiseEngineError; the operator workflow needs to see the stored vs. supplied pair to decide on next action.
Constants§
- DEFAULT_
SEARCH_ RESULT_ LIMIT - Default number of ranked hits returned by public retrieval APIs.
- MAX_
SEARCH_ RESULT_ LIMIT - Largest ranked-hit count a public retrieval request may select.
- MEAN_
VEC_ PIN_ THRESHOLD - EU-5a2 — number of documents required before the workspace’s
_fathomdb_embedder_profiles.mean_vecis pinned for the default profile. Perdev/design/embedder.md§0.3 (compute-once-on-first- ingest lifecycle). Public-visible so the EU-5a2 machinery test can assert the value. - RECENCY_
WEIGHT - G12-recency — additive recency weight. Must satisfy two constraints:
- RRF_K
- G9 — Reciprocal Rank Fusion constant. IR-C (2026-06-10b,
performance-output-and-compare.md) found the standardk≈60slightly too high: the recall gain is concentrated at the top of the list, where a lowerksharpens rank-1/2 contributions.k=30is the validated operating point (k10 > k30 > k60 > k100on the sweep,30the conservative middle). Fusion is on rank, never raw score. - RRF_
WEIGHT_ GRAPH - R3 (Slice 30) — graph arm RRF weight. Conservative starting value (equal to
RRF_WEIGHT_VECTOR). Without R2 per-class delta data the graph arm weight cannot be calibrated; 1.0 is the minimum non-zero contribution. The graph arm surfaces newly-reachable nodes from BFS traversal; it is not meant to override the primary text/vector signals. Revisable after R2 data arrives. Seedev/design/slice-30-design.md§Q2. - RRF_
WEIGHT_ TEXT - RRF_
WEIGHT_ VECTOR - G9 / IR-C — per-branch RRF weights. The sweep’s optimum is strongly
text-dominant (
text:vector ≈ 3:1): the lexical (BM25) arm carries exact-fact recall and the dense arm, over-weighted, is a net drag on exploratory recall (performance-output-and-compare.md, 2026-06-10b/e). A branch contributesweight / (RRF_K + rank). - SEARCH_
RERANK_ LIMIT - Historical name for the public default ranked-result count (10).
- TOP_
K_ BIT_ CANDIDATES
Functions§
- apply_
importance_ reweight - 0.8.16 Slice 5 / F9 — OFF-by-default importance/confidence reweight, applied
to the fused hits AFTER bit-KNN + RRF (mirrors [
apply_recency_reweight]). - rerank_
passages - 0.8.2 Slice E2 — standalone CE rerank of a caller-supplied passage list.