ADR 0002 — Embedded DuckDB + DuckDB-Wasm Graph & Vector Projection Layer

Context

NEG-002 and INACC-002 documented that an external TypeDB server daemon (127.0.0.1:1729) cannot serve as a zero-daemon, offline-reproducible primary projection in sandboxed CI or static Quartz 5 browser builds. At the same time, INV-008 (“Markdown is canonical”) requires that every graph and vector projection be deterministically rebuildable from content/**/*.md alone.

Decision

  1. Primary Embedded Store (tools/garden/sync_duckdb.py):
    • Build .garden-scratch/garden.duckdb and public/static/garden.duckdb (plus portable Parquet/JSON tables notes, edges, sources, embeddings) directly from governed markdown notes.
    • Support SQL WITH RECURSIVE graph lineage / transitive impact queries (lineage, impact_of) and 384-dimensional vector cosine/HNSW similarity search (hybrid_search), with a deterministic local embedding pipeline that runs in <1s with zero network access.
  2. MCP Server Integration (tools/garden/mcp_server.py):
    • Expose garden_graph_query, garden_vector_search, garden_typeql_read, garden_capture_inbox, and garden_analyze over stdio JSON-RPC 2.0 backed by the embedded store.
  3. Optional TypeDB Exporter (tools/garden/sync_typedb.py):
    • Retain sync_typedb.py (with fixed tool_fingerprint(), indexed-by hyphen parsing, and inbox/source-materials exclusions) as an optional external exporter when a live TypeDB daemon is explicitly provisioned.

Consequences

  • bash scripts/verify_garden.sh rebuilds and tests the full graph + vector projection offline in <1s with zero external daemons (INV-008).
  • Static Quartz 5 builds (public/static/garden.duckdb and public/static/garden-meta.json) carry the complete Milner Bigraph and vector embeddings for client-side DuckDB-Wasm inspection.