Expand description
Persistent recall context: the reader plus every mutable layer state.
A single recall() used to open_reader plus load_or_init about twenty
state objects on every call (~1.3 ms of file I/O inside a ~2.2 ms call).
This module holds them once and reuses them across calls.
§Safety contract
The context is behaviour-preserving for a single-writer process: every call saves its mutations back (same durability as before), so each call starts from the previously saved state — exactly as if it had re-read it.
Two staleness guards make long-lived use safe:
- Generation check.
SharedContextfingerprintsmeta.bin(byte length + mtime) plus the block count at open. Every access re-stats the file (~1 us); on mismatch the whole context is dropped and reopened. This catches rebuilds, which reassign block ids and would otherwise leave the mmap pointing at a replaced file. - Layer guards. The text index validates
block_count()on every use (full-scan fallback when stale); the append log validates its own (len, mtime) stamp per query. Seereader.rs.
If another process rewrites the state files without changing meta.bin
(in-place edits, which the build never does — it renames), the context
keeps serving in-memory copies. The CLI opens a fresh context per
invocation and is unaffected.
Structs§
- Recall
Context - All state one
recall()call needs, loaded once. - Shared
Context - A
RecallContextplus its layout fingerprint, with reopen-on-stale.
Functions§
- with_
shared - Run
fwith the process-global shared recall context forconfig.