Bootstraps the dllb database schema for code intelligence use.
Provides functions that generate all DEFINE TABLE, DEFINE FIELD, and
DEFINE INDEX statements needed for the ast_node table and its indexes.
The bootstrap/1 function accepts a query execution function, decoupling
schema definition from the connection pool.
Summary
Functions
Returns all schema statements (table definitions + index definitions) in order.
Returns the list of query strings that define the secondary indexes on the
ast_node table.
Returns the list of query strings to define the ast_node table and its 15 fields.
Executes all schema DEFINE statements through the given query function.
Returns the list of query strings to define the _edge_idx table.
Functions
@spec all_statements() :: [String.t()]
Returns all schema statements (table definitions + index definitions) in order.
@spec ast_node_indexes() :: [String.t()]
Returns the list of query strings that define the secondary indexes on the
ast_node table.
These are persisted in the engine's index catalog and transparently
accelerate equality and range predicates in WHERE clauses:
idx_kindonkindidx_languageonlanguageidx_file_pathonfile_pathidx_moduleonmoduleidx_project_pathonproject_pathidx_file_kindcomposite onfile_path, kind(leftmost-prefix)
Vector (HNSW) and full-text indexes are intentionally omitted: the engine's
query protocol defines only plain secondary indexes, so those cannot be
created over the wire. The source_embedding, structure_embedding,
source_text, and docstring fields are still stored as ordinary document
fields.
@spec ast_node_table() :: [String.t()]
Returns the list of query strings to define the ast_node table and its 15 fields.
Fields:
kind(string, required) - the Metastatic node typename(string) - symbol/identifier namelanguage(string, required) - source languagefile_path(string, required) - absolute file pathmodule(string) - parent module/container namearity(int) - function arity (for function_def nodes)visibility(string) - "public" or "private"project_path(string) - project root path (multi-project support)line_start(int) - starting line numberline_end(int) - ending line numbersource_text(string) - raw source textsignature(string) - function/method signaturedocstring(string) - documentation stringsource_embedding(array) - 768-dim source code embeddingstructure_embedding(array) - 384-dim structural embedding
@spec bootstrap((String.t() -> {:ok, any()} | {:error, any()})) :: {:ok, :bootstrapped} | {:error, any()}
Executes all schema DEFINE statements through the given query function.
The query_fn must have the signature (String.t() -> {:ok, any()} | {:error, any()}).
Returns {:ok, :bootstrapped} on success or {:error, reason} on the first failure.
Examples
iex> Dllb.Schema.bootstrap(fn query -> send(self(), {:query, query}); {:ok, %{}} end)
{:ok, :bootstrapped}
@spec edge_idx_table() :: [String.t()]
Returns the list of query strings to define the _edge_idx table.
This schemaless table mirrors graph RELATE edges as queryable documents
so that SELECT * FROM _edge_idx WHERE edge_type = 'calls' works.