Expand description
kevy-index — declarative secondary indexes over prefix domains (RFC 2026-07-04, LOCKED).
Pure logic crate: Catalog holds the index declarations and a
compiled prefix matcher; Segment holds one shard’s slice of one
index (entries follow the indexed key’s shard — index-follows-key).
The embedding runtime calls Segment::apply synchronously with
every write in the index’s domain (derived-by-construction: the
index can never drift from the data, and Segment::verify_entry
makes that falsifiable), and serves queries by fanning
Segment::range / Segment::eq across shards and merging.
No I/O, no threads, no runtime types — everything here is deterministic and unit-testable in isolation.
Structs§
- AggSegment
- One shard’s aggregate segment.
- AggStats
- Sizing counters (memory formula / IDX.LIST).
- AnnSpec
- v2.8 — HNSW declaration (immutable once created; RFC D2).
- Catalog
- The registry. The runtime holds one per process behind an RCU-style swap; shards read their clone lock-free.
- Cursor
- Opaque pagination cursor: the last
(value, key)served. Encoded by the runtime into the wire cursor;None= start. - Group
Stats - One group’s live statistics.
- Index
Spec - One declared index.
- Leaf
- One leaf: a declared index + the shape it contributes.
- Materialized
Set - One shard’s materialized result set: ordered
(order_value, key)members with the bounded top-K discipline (keepK + ΔwhereΔ = K/4; underflow requests a local rebuild from the base indexes — RFC §2). - Segment
- One shard’s slice of one index.
- Segment
Stats - Sizing + health counters (
IDX.LIST/ memory formula). - View
Catalog - The view registry (mirrors
crate::Catalog): named specs + sidecar text round-trip. Cap 64. - View
Spec - A declared view.
Enums§
- AggBy
- Ranking metric for
AggSegment::top_groups. - Index
Kind - Index kind (
KIND range|unique). - Index
State - Lifecycle state (RFC D5).
- Index
Value - One indexed scalar. Ordering is total within a type; the catalog guarantees a segment only ever holds one variant.
- Tree
- The composition tree. Depth ≤ 3, leaves ≤ 4 (declarative caps, enforced at CREATE).
- ValType
- Declared scalar type of an index (
TYPE i64|f64|str). - View
Mode - View mode.
Constants§
- MAX_
TREE_ DEPTH - Declarative caps (RFC §1).
- MAX_
TREE_ LEAVES - Max leaves per tree.
- MAX_
VIEWS - Hard cap on declared views.
Functions§
- eval_
tree - Evaluate
treeagainst one shard’s segments:segresolves an index name to itsSegment(None = unknown index → empty leaf — the runtime validates names at CREATE, so this is defensive). Returns the member keys (unordered set semantics). - key_
in_ tree - Re-evaluate ONE key’s membership (the materialized write hook): every leaf is a point probe via the segment’s reverse map.
- key_
in_ tree_ vals key_in_treevariant over PRE-FETCHED per-index values — the write hook probes each referenced index ONCE per key and evaluates every view against the same small table (bounds compares only; no per-view re-hashing).- merge_
group - Merge shard partials for one group (reduce side): counts/sums add, min/max take extremes.
- sort_
groups - Shared ranking order (per-shard AND at the reduce after merging shard partials — one definition, no drift).