Expand description
Per-project registry of code-index database handles.
Code search is physically partitioned one SQLite file per project
(<memory_file>.code/<project>.code.db). This keeps each project’s FTS
index small and independent, makes dropping/re-indexing a project trivial,
and guarantees the regular knowledge-graph tools (which only ever touch the
main memory database) can never see or mutate code-symbol data.
init is called once at server startup; resolve lazily opens (and
caches) the handle for a given project. A project handle owns an in-memory
entity cache, so to keep cache coherence there must be at most one live
GraphHandle per project file in the process. That invariant is upheld
by tracking each handle with a Weak: as long as any caller (e.g. a running
watcher) holds a strong reference, resolve hands back that same instance.
A small LRU of strong references keeps recently-used, otherwise-idle handles
warm to avoid reopen churn.
Constants§
- DEFAULT_
PROJECT - Default project when a caller omits the
projectargument.
Functions§
- init
- Initialize the registry. Idempotent; safe to call once at startup.
baseis the directory under which per-project databases are created. - resolve
- Resolve the (lazily opened) database handle for
project, opening it if necessary. Returns the single canonical instance for that project so callers share one entity cache. - validate_
project - Validate a project identifier. It is used verbatim as a filename component, so restrict it to a safe, traversal-free character set.