Skip to main content

Module index_format

Module index_format 

Source
Expand description

Binary segment codec for the persistent index store (ADR-104).

Byte-for-byte port of services/index_format.py per rust/spec/index-store-format.md §2. Fixed struct reads over a byte buffer — no code-bearing deserialisation; every read is bounds-checked and a segment’s declared payload length must match its file exactly, so truncation or trailing garbage fails closed on open (a cache miss).

Structs§

IndexFormatError
A segment is corrupt, truncated, wrong-magic, or wrong-version. The store treats this as a cache miss and rebuilds; it never escapes to a caller.
IndexedSegment
Reader over a write_indexed payload — random access by row index.
Reader
Writer

Constants§

SEGMENT_FORMAT_VERSION
The binary layout version (v4: tags tier, ADR-109).
SEGMENT_MAGIC
8 magic bytes opening every segment file.

Functions§

encode_segment
Frame a payload as a segment file’s bytes: magic, version, length, payload.
segment_payload
Validate a mapped segment and return its payload slice (fail-closed).
write_indexed
Encode row blobs with a docid-indexed offset table for O(1) point access: count(u32) | offsets(count × u64, relative to end of table) | rows.