Skip to main content

Crate lunaris_storage_moon

Crate lunaris_storage_moon 

Source
Expand description

MoonStorageStoragePort impl backed by Moon (Redis-compatible RESP).

RFC 0001 Wave 1C: every StoragePort method now routes through per-scope keyspace helpers (keyspace::{scope_prefix, ft_index_name, graph_key, mq_topic}). Per-scope FT indices, graph keys, and MQ topics are created lazily on first write via ensure_scope.

Per blueprint §6, every method is a thin pass-through to a Moon native command:

trait methodMoon command(s)
atomic_writeTXN.BEGIN + per-op (HSET / FT.UPSERT / GRAPH.QUERY MERGE) + TXN.COMMIT
vector_searchFT.SEARCH (with TEMPORAL.SNAPSHOT_AT when as_of is Some)
graph_traverseGRAPH.QUERY (with TEMPORAL.SNAPSHOT_AT when as_of is Some)
scan_rangeSCAN ... MATCH <prefix>* then HGET per matched key
read_as_ofTEMPORAL.SNAPSHOT_AT then HGET <key> v
publishMQ.PUSH
subscribeMQ.POP ... BLOCK polling stream
capabilitiesconstant — Moon-native everything

§Lazy per-scope init

On first write under a scope, ensure_scope creates:

  • FT.CREATE lunaris_{scope}_{kind}_idx for each of chunks / entities / facts / communities
  • GRAPH.CREATE lunaris_{scope}_graph

Subsequent calls for an already-initialized scope skip the Moon round-trips via an in-memory initialized_scopes set (lock-free read path once initialized).

§Threat model snapshot (T-01-03-*)

  • WriteOp::GraphNode { label, ... } and WriteOp::GraphEdge { rel, ... } are interpolated into Cypher. Callers MUST validate label / rel against ^[A-Za-z_][A-Za-z0-9_]*$ — see crates/lunaris-storage-moon/src/atomic.rs rustdoc. Phase 4 (OPS-04 audit) will move the guard into the trait.
  • Connection is cleartext RESP over TCP — Moon is treated as trusted infra inside the same network boundary as the Lunaris process. TLS lands in Phase 5.

Re-exports§

pub use client::MoonClient;

Modules§

atomic
atomic_writeTXN.BEGIN + per-op fan-out + TXN.COMMIT (or TXN.ABORT on error).
client
MoonClient — typed moon-client v0.1.0 SDK wrapped in a Lunaris-shaped handle.
graph
graph_traverse — typed client.graph().query_with_params(...) / query_raw for latest reads, and raw GRAPH.QUERY ... VALID_AT <ms> for AS_OF reads.
keyspace
Moon keyspace conventions for Lunaris primitives — RFC 0001 §3.6 (Wave 1C).
keyword
keyword_search — Moon BM25 via FT.SEARCH.
kv
read_as_of — one HMGET call fetching both the v and bt fields in a single round trip (plan 260610-f91: replaces the prior two serial HGETs). scan_range — documented HSCAN escape hatch (the only raw RESP cmd site allowed in lunaris-storage-moon/src/) then concurrent HGET fan-out via futures::stream::buffered (plan 260610-f91).
queue
publish and subscribe for Moon’s MQ command family, via the typed moondb::MqClient (ADD task mq-typed-client, contract FROZEN @ v1).
scopes
list_scopes — enumerate known scopes via SCAN of the lunaris:* keyspace.
vector
vector_search — Moon FT.SEARCH KNN over per-scope vector indices.

Structs§

MoonStorage
StoragePort backed by a single Moon RESP connection manager.