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, secondary index, full-text/vector search index, and edge-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 that define the full-text and vector
search 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, secondary index, full-text/vector search index, and edge-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)
Full-text (BM25) and vector (HNSW) search indexes over the embedding and
text fields are defined separately by ast_node_search_indexes/0.
@spec ast_node_search_indexes() :: [String.t()]
Returns the list of query strings that define the full-text and vector
search indexes on the ast_node table.
Created over the wire via the engine's DEFINE FULLTEXT INDEX /
DEFINE VECTOR INDEX DDL. These require a dllb server with full-text/vector
services enabled (the default server build):
idx_source_text- full-text (BM25) onsource_textidx_docstring- full-text (BM25) ondocstringidx_source_embedding- vector (HNSW) onsource_embedding, 768-dim, cosineidx_structure_embedding- vector (HNSW) onstructure_embedding, 384-dim, cosine
@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.