Skip to content

webui-rs 7: Adopt Turso embedded as the local run store (Python writer ↔ Rust reader on one SQLite-format file) #32

Description

@GeorgePearse

Extends the Rust + Datastar webui rewrite (#26#31). Decision 2026-08-05: use Turso embedded (the in-process Rust SQLite rewrite, turso crate — not libSQL-the-fork, not Turso Cloud) as the local run store.

Why

  • ProgramDatabase (genesis/database/dbase.py) currently writes runs to ClickHouse via clickhouse_connect — a heavy external dependency for a single-user local research loop (docker-compose, URL env vars, connection health in the webui).
  • Turso embedded is in-process, SQLite-file-compatible, async, with native vector search — which maps directly onto the genotype/solution embeddings genesis stores for novelty (EmbeddingClient is already wired into dbase.py). Nearest-neighbour novelty checks become a DB query instead of numpy scans.
  • One file per experiment = trivially portable/archivable runs.

Shape

  • Writer (Python): ProgramDatabase gains a Turso backend via the official Python bindings (C FFI over the same engine). Schema: programs, generations, islands, lineage edges, embeddings (vector column).
  • Reader (Rust webui): the webui-rs 2/6: Port the read model — ClickHouse queries + typed rows in Rust, parity-tested against the FastAPI responses #27 read model queries the same file in-process with the turso crate — no server between the webui and the data at all.
  • ClickHouse demoted to optional: keep it as an opt-in sink for shared/long-term history, or drop it outright — decide here and record it. The webui's primary read path becomes Turso.

Risks to burn down first (spike before porting the schema)

  1. Multi-process access: evolution loop (Python) writing while the webui (Rust) reads the same file. SQLite solves this with WAL + file locks; verify Turso beta's cross-process story explicitly. Fallbacks if it's not there yet: webui opens read-only snapshots, or the file format's SQLite compatibility means the Rust side can read with rusqlite until Turso matures.
  2. Beta API drift: Turso Database is beta (v0.6.x as of May 2026, API still moving; libSQL is the production-ready sibling). Pin versions on both sides; keep the storage layer behind a trait/interface so a swap to libSQL is a contained change if beta bites.
  3. Vector search parity: confirm the vector type + ANN query path exists in both the Rust crate and Python bindings before committing the novelty path to it.

Sequencing

Slots in alongside #27: land the spike (risks above) first, then #27's read model targets Turso rather than ClickHouse. Resolves #27's open "legacy sqlite keep-or-drop" question — legacy sqlite mode is superseded by this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions