Skip to main content

Crate rig_memory_policy

Crate rig_memory_policy 

Source
Expand description

Backend-agnostic memory-policy primitives shared across Rig memory-store adapters (rig-memvid and future backends like SQLite, LanceDB, Qdrant, plain filesystem, etc.).

Public surface:

  • dedup — in-process content-hash dedup for hooks/compactors that must satisfy rig::memory::{DemotionHook, Compactor}’s idempotency contract.
  • metadata — typed envelope written into a backend’s per-entry metadata so downstream tools (evals, inspectors, RAG pipelines) can reason about the lifecycle that produced each entry.
  • inmem — a deterministic no-disk reference store for tests, examples, and offline modes.
  • scope — normalized exact and hierarchical scope matching helpers for backend isolation and provenance projection.
  • retention — deterministic keep/drop/defer policy evaluation over backend-provided frame metadata and optional timestamps/sequence numbers.
  • store — the minimal TextWriter + Committable capability traits backends impl so hooks and compactors can be generic over the storage engine.
  • error — neutral PolicyError for failures in the above helpers.

This crate has no dependency on memvid-core or any specific storage engine. Backends are expected to wrap these primitives in their own adapter (e.g. rig-memvid adds .mv2 framing on top).

See the store module docs for the audit-driven rationale behind the deliberately narrow trait surface.

Re-exports§

pub use error::PolicyError;
pub use inmem::Episode;
pub use inmem::InMemoryHit;
pub use inmem::InMemoryStore;
pub use metadata::FrameKind;
pub use metadata::FrameMetadata;
pub use retention::RetentionCandidate;
pub use retention::RetentionDecision;
pub use retention::RetentionPolicy;
pub use retention::RetentionRule;
pub use scope::Scope;
pub use scope::normalize_scope;
pub use scope::scope_matches;
pub use scope::scope_path;
pub use store::Committable;
pub use store::TextWriter;

Modules§

dedup
In-process content-hash dedup for memory-store hooks and compactors.
error
Neutral error type for rig-memory-policy helpers.
inmem
In-memory append-only episode store with lexical retrieval.
metadata
Typed metadata envelope for entries written by memory-lifecycle hooks.
retention
Deterministic retention decisions over backend-provided memory metadata.
scope
Backend-neutral helpers for matching and projecting memory scopes.
store
Backend-agnostic memory-store capability traits.