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 to define all indexes on the ast_node table.
Returns the list of query strings to define the ast_node table and its 11 fields.
Executes all schema DEFINE statements through the given query function.
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 to define all indexes on the ast_node table.
Indexes:
idx_kind- btree onkindidx_language- btree onlanguageidx_file_path- btree onfile_pathidx_source_embedding- HNSW 768-dim COSINE onsource_embeddingidx_structure_embedding- HNSW 384-dim COSINE onstructure_embeddingidx_source_text- fulltext onsource_textidx_docstring- fulltext ondocstring
@spec ast_node_table() :: [String.t()]
Returns the list of query strings to define the ast_node table and its 11 fields.
Fields:
kind(string, required) - the Metastatic node typename(string) - symbol/identifier namelanguage(string, required) - source languagefile_path(string, required) - absolute file pathline_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}