Composable indexed code search: index lifecycle, candidate planning, and grep-style matching.
Indexes::open (lifecycle) / Indexes::load → Option (search)
Plan::new (pure) → Plan::resolve (query I/O) → Searcher::execute
Indexes— builds, publishes, queries, and hydrates one store (loadisNonewhen absent)Files— sharedFileId → Filetable for the current committed snapshotPlan— pure discovery decision;resolveowns index query I/OSearcher— match execution over resolved candidates and streamsQuery— patterns + options; owns narrowing policyFile/Origin— path identity (Origin::{File, Stream { label }})
Today the default catalog record is N-gram width 3. record.rs privately opens
kinds through its Opened enum.
Search (re-exported from lib.rs):
Query,Searcher,Report,Origin,SearchModeStoreMeta,IndexRecord,Indexes,SnapshotId,Files,CorpusKindngram::Index,GramWidth,GramNormCandidates,Plan,Scan,ScanScope,SnapshotFreshness,Coverage
| Module | Responsibility |
|---|---|
index/indexes.rs |
Indexes open/load/build + query/hydrate |
index/record.rs |
IndexRecord, private Opened dispatch |
index/files.rs |
Snapshot-owned Files |
index/disk.rs |
Snapshot persistence |
index/ngram/ |
N-gram implementation (artifact names live here) |
index/mmap.rs |
Sole unsafe in the crate (mmap_open) |
search/ |
Query, Searcher, Report, events |
candidates/plan.rs |
Plan (plan + resolve) |
candidates/candidates.rs |
Candidates collection |
corpus/ |
File, FileFilter, FileOrder, walk |
Searcher::execute
1. coverage ← caller maps SearchMode → Coverage
2. plan ← Plan::new(source, query, coverage)
3. candidates ← plan.resolve(source)
4. search ← Searcher::execute(...)
Planning is pure; Plan::resolve is the only candidate I/O boundary.
- Conservative narrowing: indexes may over-return, never under-return.
- Multi-kind intersection happens in
Indexes::query, not per-caller. - No free helper functions — logic lives on the owning type.
- No callback/
FnOnceAPIs. - No
unsafeoutsideindex/mmap.rs.
cargo test -p sift-core- Break public API without updating CLI.
- Add
unsafeoutsideindex/mmap.rs. - Put stdout formatting in core.
- Expose
Indexes::candidatesor test-only constructors. - Mix planning with I/O.
- Reintroduce
Grep,IndexStore, oropen_or_create.