Expand description
lunaris — umbrella crate. Re-exports lunaris_core types, exposes the
open(url) URL-scheme dispatcher AND the higher-level Lunaris handle
that drives the Phase 2 ingest hot path.
§Two construction paths
open()— returnsArc<dyn StoragePort>for callers that just want raw storage access (Plan 5 conformance harness, low-level tests).Lunaris::open— returns a high-level handle wired with a defaultEmbedder+HlcClockso callers can calllunaris.ingest(episode).await?without manually plumbing the Phase 2 pipeline. This is what Helios uses.
§Prelude
For day-to-day use, glob-import the curated common surface:
use lunaris::prelude::*;See prelude for the exact list — it intentionally stays small
(handle, scope, episode builder, retrieval DSL, the pluggable
trait + Noop* pairs, and the umbrella error type).
Re-exports§
pub use consolidator_pipeline::ConsolidatorPipelineHandle;pub use consolidator_pipeline::ENABLED_ENV_VAR as CONSOLIDATE_ENABLED_ENV_VAR;pub use digest::recent_by_source;pub use episode_builder::EpisodeBuilder;pub use forget::ForgetConfirmation;pub use forget::ForgetReceipt;pub use forget::ForgetTarget;pub use forget::IndexKind;pub use forget::ScopeSpec;pub use graph_pipeline::ENABLED_ENV_VAR as GRAPH_ENABLED_ENV_VAR;pub use graph_pipeline::GraphPipelineHandle;pub use handle::DegradationNotice;pub use handle::EmbedderBackend;pub use handle::IngestKind;pub use handle::Lunaris;pub use handle::SUPPRESS_DEGRADED_WARNING_ENV;pub use handle::ScopedLunaris;pub use handle::VerifyAgendaEntry;pub use handle::degradation_notice;pub use handle::lazy_default_embedder;pub use handle::resolve_default_embedder;pub use handle::resolve_default_reranker;pub use handle::resolved_embedder_backend;pub use recall_rerank::RECALL_RERANK_ENV_VAR;pub use recall_rerank::RECALL_RERANK_TOP_IN_ENV_VAR;pub use recall_rerank::RecallRerankConfig;pub use structured_ingest::EntityInput;pub use structured_ingest::FactInput;pub use structured_ingest::RelationInput;pub use structured_ingest::StructuredIngest;pub use primitives::WorkingMemory;pub use logging::init as init_logging;pub use open::open;pub use recipes::HeliosScratchpad;Deprecated pub use recipes::AsOfScratchpad;pub use recipes::CodingSessionMemory;pub use verify_pipeline::ENABLED_ENV_VAR as VERIFY_ENABLED_ENV_VAR;pub use verify_pipeline::VerifierPipelineHandle;
Modules§
- activation
- ADD task activation-ledger — the persistent per-memory activation ledger.
- audit
- Plan 13-01 — re-export shim for the canonical audit types that now live in
lunaris-core::audit. This file preserves the olduse crate::audit::*import surface socrates/lunaris/src/forget.rsand every downstream test keeps compiling without modification. - bitemporal
- Bi-temporal validity stamp per blueprint §3.3.
- circuit_
breaker - RFC 0007 — per-provider circuit breaker for
Fallback*combinators. - consolidator_
pipeline - Plan 04-04: Runtime toggle for the ACT-R Consolidator worker.
- digest
- Recency-ordered, source-filtered episode recall for the SessionStart digest.
- embedder
- Embedder trait + a deterministic stub impl returning 768-dim vectors.
- episode_
builder EpisodeBuilder— scope-less payload builder forlunaris_core::Episode.- error
- Error taxonomy — one umbrella enum, one sub-enum per subsystem.
- forget
- Plan 04-05 —
Lunaris::forget(target) -> ForgetReceipt. - graph_
pipeline - Plan 03-03: Runtime toggle for the graph extraction pipeline.
- handle
Lunaris— the high-level memory-engine handle (Phase 2 surface).- hlc
- Hybrid Logical Clock — wall-time millis + monotonic counter + node id.
- ingest
Lunaris::ingest— Phase 3 dispatcher.- json_
repair - Repair JSON numbers that lost their integer-ness in transit.
- keyspace
- Storage-agnostic primitive KV key helpers — RFC 0001 §3.6 (Wave 2.5B).
- logging
- Plan 05-05 OPS-08 — structured logging defaults to JSON in production, pretty in dev (CONTEXT.md D-26 verbatim).
- models
- The GGUF model catalogue — one place that names the artifacts.
- open
lunaris::open(url)— single entry point for the storage backend.- prelude
- Glob-import the common surface:
use lunaris::prelude::*;. - primitives
- Phase 10/11/12 Option-A relocation — primitives that must live in the
umbrella
lunariscrate because Phase 12CodingSessionMemory(also inlunaris) composes over them. Previously these lived inlunaris-recipes, butlunaris-recipes → lunarisdependency direction made the reverse import impossible. Moving them down (crate-wise) breaks the cycle without touching the public Phase 9 fluent API — the recipes crate re-exports these names souse lunaris_recipes::WorkingMemory;keeps compiling. - recall
Lunaris::recall— the public Phase 2 retrieve entry point.- recall_
rerank - GA-1 — opt-in cross-encoder rerank stage on the production recall root.
- recipes
- Plan 05-04 — opinionated v0 recipes (helios-rfc §5.3 surface).
- reconcile
- Cross-episode memory-convergence reconciliation — the pure decision core.
- retention
- W4.6 / D6.4 — enforcing a scope’s
RetentionPolicy. - scope
Scopenewtype — the primary partition key for multi-agent / multi-tenant isolation in Lunaris v0.2 (RFC 0001).- scope_
resolver - Scope derivation — shared between
lunaris-mcpandlunaris-hook. - snapshot
- Plan 08-00 —
Lunaris::snapshot()monotonic LSN marker. - snippet
- LLM-optimized snippet rendering for stored episode content.
- storage
- Storage abstraction — the trait, supporting types, and capability reporting.
- store_
discovery - Contextd store discovery — shared by
lunaris-hookandlunaris-mcp. - structured_
ingest - Phase 23 — agent-facing structured ingest.
- verify_
pipeline - Plan 04-04: Runtime toggle for the slow-path Verifier worker.
Structs§
- ActR
Consolidator - Production ACT-R consolidator — composes
ActRScorerinto a concreteimpl Consolidatorthat the worker can iterate against. - AndRetriever
.and(A, B)— concurrent fan-out, concatenated output (with per-source tag preserved).- BiTemporal
- Chunk
- Circuit
Breaker - Per-provider circuit breaker (RFC 0007 §3.2).
- Circuit
Config - Cloud
ApiExtractor - Cloud-API extractor — wraps
lunaris_llm::CloudBackendper chunk and emits the D-21 sentinel on retry exhaust. - Cloud
ApiExtractor Opts - Construction options for
CloudApiExtractor. - Cloud
ApiVerifier - Cloud-API verifier (Anthropic / OpenAI / Gemini). Phase 12b wraps
CloudBackend(lunaris-llm) +LlmVerifier. - Cloud
ApiVerifier Opts - Construction options for
CloudApiVerifier. - Community
- Cypher
Query - Degraded
Fallback Retriever degraded_fallback(primary, fallback)operator.- Dream
Agenda - Output of one
build_dream_agendacall. - Dream
Cluster - One candidate distillation cluster.
- Dream
Config - Tunables for one
build_dream_agendacall. - Entity
- Entity
Id - Deterministic 16-byte content-hash identifier per D-06.
- Episode
- Fact
- Failing
Embedder - Always-failing
Embedderfor use in unit tests that must verify error propagation. Everyembed_batchcall returnsLunarisError::Storage(StorageError::Backend(...)). - Floored
TopRetriever TopRetrieverwith a reserved per-leg floor — seefloored_topfor the selection contract and the displacement regression it closes.- Fuse
RrfRetriever - Reciprocal Rank Fusion operator.
- Graph
- Graph-anchored retrieval operator.
- Graph
Decay - Recency-decay parameters for graph traversal (ADD task
graph-decay-recency, contract v1). Maps to Moon’sGRAPH.QUERY ... --decay <λ> [--time-weight <w>]read-path clause: effective edge cost =|weight| + λ·w·age_seconds. - Graph
Result - Dynamic header-keyed result table returned by
StoragePort::graph_traverse. - Hit
- Final hydrated retrieval hit returned to the caller.
- Hlc
- HlcClock
- HotKey
- One entry from a backend’s hot-key sketch (
StoragePort::hot_keys). - Keyword
- Keyword (BM25) retrieval operator.
- Keyword
Hit - One keyword search hit.
- LlmReflect
Supervisor - LLM-backed reflect supervisor. Wraps any
Arc<dyn LlmBackend>— same trait the extract + verify pipelines consume — so a single candle Gemma-3 4B handle can serve all three when the unified config wires it that way. - Lsn
- Log sequence number returned by
atomic_write. - Moon
Storage StoragePortbacked by a single Moon RESP connection manager.- Navigate
- Graph-expanded vector retrieval operator.
- Navigate
Hit - A single hit returned by
StoragePort::vector_navigate. - Navigate
Spec - Parameters for graph-expanded vector retrieval (ADD task
ft-navigate-recall, contract v1). Maps to Moon’sFT.NAVIGATE ... HOPS <n> [HOP_PENALTY <p>] [DECAY <λ>]. - Noop
Consolidator - Default consolidator when the pipeline is OFF (Plan 04-04) or when the
caller has not installed a real consolidator via
with_consolidator. - Noop
Embedder - Zero-vector
Embedderof caller-configureddim. Used when no real embedder backend is wired (air-gapped builds, metadata-only ingest, tests that need a workingArc<dyn Embedder>without similarity semantics). - Noop
Extractor - Default extractor when graph pipeline is OFF (Plan 03-03) or when no remote
backend cache is missing. Returns one empty
RawExtractionper input chunk so the per-chunk index alignment downstream still holds. - Noop
Reflect Supervisor - Noop reflect supervisor — always returns an empty
ReflectOutput. Default forLunaris::with_reflectwhen the umbrella ships reflect-OFF (mirrors blueprint §5.1 default-OFF for verify). - Noop
Reranker - NO-OP reranker. Used as the default fallback when
crate::BgeRerankerV2M3weights are missing. Production code wires this viaLunaris::open(url)automatically when the cache is empty. - Noop
Verifier - Default verifier when the pipeline is OFF (Plan 04-04) or when no remote
backend cache is missing. Returns a
VerifyDecision::deferredso the worker treats the item as “abstain — leave the underlying primitive row untouched”. - Ollama
Extractor - Ollama-backed extractor — thin wrapper over
LlmExtractor. - Ollama
Extractor Opts - Construction options for
OllamaExtractor. - Ollama
Verifier - Ollama-backed verifier. Phase 12b wraps
OllamaBackend+LlmVerifier. - Ollama
Verifier Opts - Construction options for
OllamaVerifier. - Page
- One page of
scan_pageresults. - Query
- One retrieval query.
- Queue
Msg - A single message yielded by
subscribe.offsetis the broker-assigned monotonic offset within(topic, partition). - RawHit
- One pre-hydration retrieval hit. Operators flow these around between
each other; the final stage hydrates them into
Hits. - Reflect
Input - Input snapshot the reflection LLM sees. Caller assembles this from the just-finished turn’s ingest + recall state. The fields are intentionally minimal — wider context (full chunk text, full recall hits) belongs in the prompt the reflection wrapper builds.
- Reflect
Opts - Construction options.
- Reflect
Output - Output the reflection LLM emits. All three fields are advisory — nothing in this commit applies them. Wire-up to the storage layer is a follow-up.
- Relation
- Rerank
Candidate - One pre-rerank candidate. The operator hydrates the chunk text BEFORE
calling the reranker (see
lunaris_retrieve::hydrate::partial_hydrate_text) so the cross-encoder can pair-encode(query, doc.text)for scoring. - Rerank
Retriever rerank(model)operator — wraps an upstream retriever with a cross-encoder rerank pass. See module-level rustdoc for the partial-hydration + hit-count contracts.- Retrieval
Builder - Builder returned by
Lunaris::recall(). - Retrieval
Service tower::Serviceadapter wrapping a built operator tree.- Row
- A single MVCC row returned by
read_as_of.btcarries the bi-temporal stamp the row was visible under at the snapshot time. - Scope
- A partition key for multi-agent / multi-tenant isolation.
- Scope
Page - One page of scope identifiers returned by
StoragePort::list_scopes. - Storage
Capabilities - Stub
Embedder - TopRetriever
- Cap the result list to
nhits after the upstream operator resolves. - Tree
- RAPTOR tree retrieval operator.
- Validated
Extraction - What
validateproduces. Theentities/relations/factslists hold items that passed validation and are safe to write to storage; theneeds_reviewlist holds items that failed with a structured reason so the ingest fan-out can publish them to the verify queue (D-19). - Vector
- Vector retrieval operator.
- Vector
Hit - A single
vector_searchresult. - Verify
Decision - One verifier arbitration decision.
winner_id/loser_idareOptionbecause a “deferred” decision (NoopVerifier short-circuit, or cloud-api D-21 transient-after-retry) carries no arbitration pair — the worker treats such decisions as “skip this item”.
Enums§
- Audit
Event - Canonical typed audit event. Externally-tagged so the JSON wire shape
carries
"kind": "<variant-name>"for grep-friendly ops triage. - Circuit
State - State machine for the circuit breaker. Encoded as
u8so the state fits in an atomic without aMutex<State>outer layer; the failure-window counter still lives behind aMutexbecause it needs the wall-clock to age entries out. - Cloud
Provider - Selectable provider per D-01. Reads from
LUNARIS_EXTRACT_PROVIDERenv (case-insensitive) atCloudApiExtractorOpts::defaulttime. - Consol
Error - Cypher
Dialect - Cypher dialect tier the backend’s graph executor accepts.
- Extract
Error - Filter
- Filter expression passed to
vector_search. v0 supports a small algebra; the backend translates it to its native filter language (FT.SEARCH ... FILTER ...on Moon). - List
Error - Failure modes of
scan_page.ListError::codeis the stable wire string. - Lunaris
Error - Top-level error type returned by every public
lunarisAPI. - Memory
Level - The canonical memory-partition levels, composed UNDER the JWT base scope
in this fixed order (
User→Agent→Session). Each carries a one-char disambiguating tag so the composed scope is self-describing and collision-resistant:{base}.u-{user}.a-{agent}.s-{session}, including only the levels whose id is present. - Needs
Review Item - One failed extraction with the reason it was demoted. Preserves the raw item so the Phase 4 Verifier (Plan 04-XX) can re-extract / arbitrate.
- Needs
Review Reason - Structured reason explaining why an extraction was routed to
ValidatedExtraction::needs_review. Each variant maps onto a blueprint §5.2 / D-08 / D-21 NeedsReview class. - Plan
- Retrieval plan picked by the v0 query planner.
- Plan
Error - Why a JSON plan could not be turned into a retriever.
- Retrieve
Error - RrfFusion
- RRF (Reciprocal Rank Fusion) mode for the retrieval DSL.
- Scope
Error - Error returned when constructing an invalid
Scope. - Source
Op - What kind of operator produced a
RawHit. RRF fusion groups raw hits by this tag so per-branch rankings stay isolated when computing1 / (k + rank_i). - Storage
Error - Subsystem
- Coarse subsystem tag for a
LunarisError— one classifying match, inside the crate that owns the enum. - Validate
Error - Verifier
Backend - Provider tag for audit records. Serialized with default enum tagging
(externally tagged →
"Ollama"/"CloudAnthropic"/ etc.) so the audit schema is grep-friendly in ops tooling. - Verify
Needs Review Item - One failed extraction with the reason it was demoted. Preserves the raw item so the Phase 4 Verifier (Plan 04-XX) can re-extract / arbitrate.
- WriteOp
- One operation in an
atomic_writebatch.
Constants§
- AUDIT_
TOPIC - Unified audit topic. Every publisher in the workspace emits here.
- DEFAULT_
GRAPH_ HOPS - Default hops per ROADMAP Phase 3 success criterion #3.
- DEFAULT_
GRAPH_ K - Default candidate count for graph traversal (matches Vector/Keyword default of 30).
- LUNARIS_
GRAPH_ NAME - Graph name Lunaris traverses — the
<graph>argument of Moon’sGRAPH.QUERY <graph> "...". Held as a constant (rather than inlined at each call site) so a future backend can be pointed at the same graph identifier and keep the Cypher template portable;with_graph()overrides it per tenant. - MAX_
GRAPH_ HOPS - Hard cap on hops to prevent runaway BFS (D-14). Caller-supplied
hops greater than 5clamps to 5;hops == 0clamps up to 1 so the BFS always runs at least one edge step (zero-hop traversal would only return the anchor entities themselves, which the caller already has). - MAX_
PAGE - Hard upper bound on a single page (contract v1). A
limitabove this is rejected. - NOOP_
DEFAULT_ DIM - Default dim for
NoopEmbedderwhen no override is supplied. Matches the historical EmbeddingGemma 300M / granite-r2 output width (768) so an operator who flips to the noop backend doesn’t have to re-create theirFT.CREATEHNSW index.
Traits§
- Consolidator
- Object-safe async consolidator.
- Embedder
- Extractor
- Object-safe async extractor.
- Key
- User-defined typed key. Implementors define how to serialize the key to bytes
for
KvPut/KvDeletewrite ops; trait is object-safe-by-design (no generic methods). - Keyword
Port - BM25 keyword search extension trait.
- Reflect
Supervisor - Object-safe async reflection supervisor.
- Reranker
- Async cross-encoder reranker.
- Retriever
- Object-safe async retriever.
- Storage
Port - The storage abstraction for Lunaris.
- Verifier
- Object-safe async verifier.
Functions§
- compose_
levels - Compose the JWT-bound
basescope with optional user/agent/session ids, in the canonicalMemoryLevelorder, into the bound partition. - degraded_
fallback - Builder-friendly factory:
degraded_fallback(primary, fallback). - det_vec
- Deterministic stand-in for a real embedding: unit-norm and clustered.
- filter_
str - Parse the v0 string DSL into a
FilterAST. - floored_
top - Chunk-superset floored top-k selection (pure function; the policy behind
FlooredTopRetriever). - hybrid_
root - The fused hybrid root:
(Vector ∧ BM25)("chunks") ∧ (Navigate ∧ BM25)("facts") → fuse_rrf(60). - plan_
query - Run the v0 planner heuristic.
- publish_
audit_ event - Fire-and-forget audit publish. Mirrors the pre-refactor helper at
crates/lunaris/src/audit.rs:99-117verbatim: - rerank
- Builder-friendly factory:
rerank(upstream, reranker). Mirrors thefuse_rrf(inner, k)shape fromoperators/fuse.rsso callers can chain via either method-style or function-style composition. - retriever_
from_ json - Build a retriever tree from a JSON plan node. See the module docs for the accepted shape.
- sanitize_
graph_ ident - Sanitize free-form text into a Cypher-safe identifier for
WriteOp::GraphNode::label/WriteOp::GraphEdge::rel. - scan_
page - Read one page of primitives of type
Tunderprefix, scope-bound, ULID-ascending.