bankai/vector_bridge

Vector retrieval over aarondb’s HNSW index.

Mnesia is Bankai’s source of truth. This module builds a short-lived index from Bankai documents for one command, keeping aarondb behind a Bankai-shaped result type and the embedding backend behind bankai/embed.

The index topology is deliberately deterministic. The managed projection is keyed by the committed Mnesia offset, so queries reuse a daemon-local HNSW graph until committed membership changes; direct search stays available for finite-corpus tests and one-shot callers.

Types

pub type Document {
  Document(kind: String, id: String, text: String)
}

Constructors

  • Document(kind: String, id: String, text: String)
pub type Match {
  Match(kind: String, id: String, score: Float)
}

Constructors

  • Match(kind: String, id: String, score: Float)
pub type ProjectionStatus {
  ProjectionStatus(
    last_applied_offset: Int,
    document_count: Int,
    health: projection_index.Health,
    generation: Int,
  )
}

Constructors

  • ProjectionStatus(
      last_applied_offset: Int,
      document_count: Int,
      health: projection_index.Health,
      generation: Int,
    )

Values

pub fn backend() -> String
pub fn exact_search(
  docs: List(Document),
  query: String,
  threshold: Float,
  limit: Int,
) -> List(Match)

Return the exact finite-corpus oracle for Bankai’s lexical vectors.

This exists for verification and benchmarks. The CLI intentionally keeps the HNSW path: exact search is exhaustive rather than an interactive retrieval strategy.

pub fn projected_exact_search(
  workspace: String,
  offset: Int,
  docs: List(Document),
  query: String,
  threshold: Float,
  limit: Int,
) -> Result(List(Match), String)

Exact oracle over the same managed projection corpus. It exists solely for verification and benchmark parity; user-facing commands use HNSW.

pub fn projected_search(
  workspace: String,
  offset: Int,
  docs: List(Document),
  query: String,
  threshold: Float,
  limit: Int,
) -> Result(List(Match), String)

Query the managed daemon-local HNSW projection at a committed source offset. Reusing an identical offset never rebuilds the graph; an offset advance produces a fresh deterministic generation before results are returned.

pub fn projection_status(
  workspace: String,
) -> Result(ProjectionStatus, String)
pub fn reset_projection_for_test(
  workspace: String,
) -> Result(Nil, String)
pub fn search(
  docs: List(Document),
  query: String,
  threshold: Float,
  limit: Int,
) -> List(Match)

Build an in-memory HNSW index and return ranked document matches.

threshold is cosine similarity because embed.embed returns normalized vectors. Empty queries and non-positive limits intentionally return no matches rather than making the index treat a zero vector as relevant.

Search Document