-
Notifications
You must be signed in to change notification settings - Fork 1
systems storage and search
Bryan edited this page Jun 13, 2026
·
1 revision
Active contributors: Bryan
SQLite is Lode's hot path. src/lode/storage.py defines the schema, writes parsed facts, supports FTS search, resolves symbols, returns graph neighbors, and stores embedding metadata.
src/lode/storage.py # schema, writes, queries, embedding persistence
src/lode/config.py # data directory and repository ID helpers
tests/test_lode.py # storage-backed CLI and indexing tests
| Name | File | Description |
|---|---|---|
connect() |
src/lode/storage.py |
Opens SQLite, sets WAL mode, enables foreign keys, and initializes schema. |
init_db() |
src/lode/storage.py |
Creates repos, files, nodes, edges, FTS, embedding queue, and embeddings tables. |
replace_file_index() |
src/lode/storage.py |
Atomically replaces all facts for one file. |
search_nodes() |
src/lode/storage.py |
Uses FTS5 with fallback matching. |
find_symbol() |
src/lode/storage.py |
Finds exact and partial qualified-name matches. |
get_neighbors() |
src/lode/storage.py |
Returns incoming and outgoing graph neighbors. |
| Table | Purpose |
|---|---|
repos |
Indexed repository roots and timestamps. |
files |
File metadata, language, size, hash, and indexed timestamp. |
nodes |
Symbols, files, routes, docs, config nodes, and external placeholders. |
edges |
Relationships between nodes. |
node_fts |
SQLite FTS5 index for names, signatures, docs, and paths. |
embedding_queue |
Nodes that should be embedded after indexing. |
embeddings |
Persisted vectors and model metadata. |
replace_file_index() deletes old facts for a file, upserts file metadata, inserts de-duplicated nodes, updates node_fts, queues embeddable nodes, and inserts de-duplicated edges. This keeps re-indexing cheap because unchanged files are skipped by src/lode/indexer.py.
graph LR
FileIndex[src/lode/model.py] --> Replace[replace_file_index]
Replace --> Files[(files)]
Replace --> Nodes[(nodes)]
Replace --> Edges[(edges)]
Replace --> FTS[(node_fts)]
Replace --> Queue[(embedding_queue)]
-
src/lode/context.pycallssearch_nodes()andget_neighbors(). -
src/lode/graph.pyreads nodes and edges, then writes resolved edges. -
src/lode/cli.pyandsrc/lode/daemon.pyuserepo_filter()to scope queries. -
src/lode/embeddings.pypairs withpending_embedding_nodes()andupsert_embedding().
Schema changes start in init_db() in src/lode/storage.py. Query behavior changes should be covered by tests/test_lode.py, and graph-neighbor behavior should be covered by tests/test_graph.py.
| File | Purpose |
|---|---|
src/lode/storage.py |
SQLite schema and query layer. |
src/lode/config.py |
Data paths and repository IDs. |
src/lode/model.py |
Stored fact shape. |
tests/test_lode.py |
Storage-backed behavior tests. |