Expand description
MoonStorage — StoragePort 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 method | Moon command(s) |
|---|---|
atomic_write | TXN.BEGIN + per-op (HSET / FT.UPSERT / GRAPH.QUERY MERGE) + TXN.COMMIT |
vector_search | FT.SEARCH (with TEMPORAL.SNAPSHOT_AT when as_of is Some) |
graph_traverse | GRAPH.QUERY (with TEMPORAL.SNAPSHOT_AT when as_of is Some) |
scan_range | SCAN ... MATCH <prefix>* then HGET per matched key |
read_as_of | TEMPORAL.SNAPSHOT_AT then HGET <key> v |
publish | MQ.PUSH |
subscribe | MQ.POP ... BLOCK polling stream |
capabilities | constant — Moon-native everything |
§Lazy per-scope init
On first write under a scope, ensure_scope creates:
FT.CREATE lunaris_{scope}_{kind}_idxfor each of chunks / entities / facts / communitiesGRAPH.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, ... }andWriteOp::GraphEdge { rel, ... }are interpolated into Cypher. Callers MUST validatelabel/relagainst^[A-Za-z_][A-Za-z0-9_]*$— seecrates/lunaris-storage-moon/src/atomic.rsrustdoc. Phase 4 (OPS-04audit) 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_write—TXN.BEGIN+ per-op fan-out +TXN.COMMIT(orTXN.ABORTon error).- client
MoonClient— typedmoon-clientv0.1.0 SDK wrapped in a Lunaris-shaped handle.- graph
graph_traverse— typedclient.graph().query_with_params(...)/query_rawfor latest reads, and rawGRAPH.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 viaFT.SEARCH.- kv
read_as_of— oneHMGETcall fetching both thevandbtfields in a single round trip (plan 260610-f91: replaces the prior two serial HGETs).scan_range— documented HSCAN escape hatch (the only raw RESPcmdsite allowed inlunaris-storage-moon/src/) then concurrent HGET fan-out viafutures::stream::buffered(plan 260610-f91).- queue
publishandsubscribefor Moon’sMQcommand family, via the typedmoondb::MqClient(ADD taskmq-typed-client, contract FROZEN @ v1).- scopes
list_scopes— enumerate known scopes via SCAN of thelunaris:*keyspace.- vector
vector_search— MoonFT.SEARCHKNN over per-scope vector indices.
Structs§
- Moon
Storage StoragePortbacked by a single Moon RESP connection manager.