Expand description
Code index host capability.
Ports the deterministic trigram/word index that lived in
Sources/BurinCodeIndex/ on the Swift side. Exposes five host builtins
whose surfaces are locked by schemas/code_index/<method>.json:
| Builtin | What it does |
|---|---|
hostlib_code_index_query | Trigram-accelerated literal substring search. |
hostlib_code_index_rebuild | Walk a workspace and (re)build the in-memory index. |
hostlib_code_index_stats | Count files/trigrams/words + last rebuild timestamp. |
hostlib_code_index_imports_for | Imports declared by a single file (with resolutions). |
hostlib_code_index_importers_of | Reverse lookup: who imports the given module/path? |
The capability owns one SharedIndex cell per instance — there is at
most one live workspace per VM at a time. The schema for the read
builtins (query, stats, imports_for, importers_of) does not
carry a workspace argument, so multi-workspace embedders are expected
to drive separate CodeIndexCapability handles. The internal layout
still keeps everything keyed on FileId, so a future schema bump can
add a root parameter without refactoring the data model.
Structs§
- Build
Outcome - Summary returned from
IndexState::build_from_root. - Code
Index Capability - Code-index capability handle.
- DepGraph
- Forward + reverse import graph plus the side-table of unresolved import strings (raw text we couldn’t map back to a known file).
- Index
State - In-memory index for one workspace. Composed from the per-file table, the trigram + word sub-indexes, and the dep graph.
- Indexed
File - Per-file metadata persisted in the index.
- Indexed
Symbol - Outline-style symbol entry. Reserved for AST integration; the code-index
importer leaves
IndexedFile::symbolsempty, but the shape is kept stable so storage upgrades won’t have to re-key. - Trigram
Index - Trigram posting list:
trigram -> set of file ids that contain it, plus a per-file reverse map for cheap re-indexing. - WordHit
- Single occurrence of an identifier-shaped token: which file it landed in and on which 1-based line number.
- Word
Index - Inverted word index keyed on identifier-shaped tokens.
Type Aliases§
- FileId
- Monotonically-assigned identifier for a file in the index. Stable
across re-indexes of the same path so sub-indexes can key on
FileIdwithout invalidating string keys. - Shared
Index - Shared, mutable cell carrying the (at most one) live workspace index.
Mutexrather thanRwLockbecause rebuilds flip the slot wholesale — fine-grained concurrency between rebuild + reads is intentionally not supported (the Swift side serialised through a single actor too).