Repository navigation
Description
Overview
The local store runs on the libsql crate (Cargo.toml: libsql = 0.6, core feature). Turso Database (formerly Limbo, the turso crate) is a from-scratch Rust rewrite of SQLite. It promises native async I/O, MVCC concurrent writes and built-in vector search, and it would remove the C libsql-ffi build and the libsql-sys rusqlite Windows-path workaround in packages/core/Cargo.toml.
This spike answers one question: can the turso crate run our schema and our heaviest queries, and how does it compare with libsql? The store leans on features a rewrite tends to support late, so a hard gap would end the idea.
Problem Statement
We don't know whether Turso supports what the store depends on. Usage in packages/core/src/db:
| Dependency | Usage |
|---|---|
WITH RECURSIVE |
about 20 queries, relationship and path walks |
json_extract / json_each |
about 60 call sites |
CREATE TRIGGER |
18 |
| FTS5 | node_title_fts (schema.rs) |
vec0 (sqlite-vec) |
vec_embeddings for KNN search (schema.rs, sqlite_store/embeddings.rs) |
journal_mode / busy_timeout |
WAL and writer-contention tuning on connections |
Proposed Solution
Time-boxed investigation in a disposable worktree. The spike code is discarded and nothing is merged.
- Add
tursoto a scratch crate or test, not to the workspace. - Run
create_schemaDDL against it and record each statement that fails: triggers, FTS5,vec0, indexes. - Run the relationship-path recursive CTEs against both engines on the same generated graph. Record support, result equality and timing.
- Run representative
json_extract/json_eachproperty queries on both engines. - Check vector search with Turso's native vector functions in place of
vec0. - Check concurrent-writer behavior (MVCC) against libsql under
busy_timeout. - Post the findings on this issue and delete the worktree.
Documentation
- ADR-069 - the transaction seam any engine swap must preserve
- write-atomicity-inventory - the atomic write paths the new engine would have to keep
- ADR-053 - one daemon owns several databases, so multi-database handling matters for an engine swap
- ADR-054 - the store's encryption stance
- data-layer.md - to be updated only if a migration is later decided
Architecture Impact
The docs mention libsql as the store but contain no ADR that selects it over alternatives. This spike changes no decision. If the findings favor switching, a new ADR is required before any migration issue is filed, and that is out of scope here.
Acceptance Criteria
- Each engine feature in the table above has a pass, partial or fail result with the failing statement or error recorded
- Recursive CTE results match libsql on the same graph, with timings for both engines
- A vector-search result: native Turso vectors against
vec0, on a small fixed data set - A concurrent-write result against libsql's single-writer behavior
- Findings posted as a comment on this issue with the pass/fail table and a go / no-go recommendation
- Spike worktree removed, nothing merged to
main, notursodependency left in the workspace
Technical Specifications
Reference Files
Cargo.toml- workspacelibsqlpinpackages/core/Cargo.toml-libsql-sysrusqliteworkaround to be removed if Turso is adoptedpackages/core/src/db/schema.rs- DDL, includingnode_title_ftsandvec_embeddingspackages/core/src/db/sqlite_store/relationship_paths.rs- recursive CTEspackages/core/src/db/sqlite_store/embeddings.rs- KNN search throughvec0packages/core/src/db/sqlite_store/connections.rs- connection pragmas
Notes
- The correlated-subquery form of the relationship-walk CTE is about 50x faster than the JOIN form on libsql and is plan-tested. Check that Turso doesn't lose that advantage.
- Don't touch the production code path. The spike lives in a scratch crate or an ignored test.
Non-Goals
- Migrating the store or writing any adapter layer
- Data migration, since the database can be reset
- Merging spike code
Activity
malibio commentedon Oct 27, 2026
Spike round 1: SQL feature support (
turso0.9.0-pre.1 vslibsql0.6)Scratch crate outside the repo, in-memory databases. The graph is 5000
has_childedges with fanout 2, and the recursive query is the production shape: a correlatedjson_group_arraysubquery feedingjson_each.WITH RECURSIVE(counter)WITH RECURSIVE+ correlated subquery +json_each(full walk, 5000 nodes)WITH RECURSIVEwalk from a leaf-ish nodeWITH RECURSIVEreverse walk (JOIN form)CREATE TRIGGERAFTER INSERT, and it firesjson_extractfilter and nested pathjson_eachaggregatevector_distance_cos/vector32fts5virtual tableno such module: fts5)CREATE INDEX ... USING ftsandfts_match()(needsexperimental_index_method(true))Recursive CTEs are supported and give the same results. That was the deal-breaker question.
Timing on the full walk was 6.6 ms on libsql and 14.0 ms on turso, with the same indexed access. That is one cold run on a micro-graph, so it shows no pathological blowup but is not a benchmark.
FTS is the real difference. There is no FTS5 virtual table. Turso has its own index-method FTS, behind an experimental flag.
node_title_ftsand its triggers/queries would have to be rewritten.Not yet covered:
busy_timeout, concurrent writers / MVCC)create_schemaDDLmalibio commentedon Nov 16, 2026
Closing as not planned for now. Recommendation: no-go at this time.
Round 1 (above) showed the hard question passes: recursive CTEs, triggers,
json_extract/json_eachand vector distance all run ontursoand match libsql. The blocker is full-text search. Turso has nofts5module (no such module: fts5); its own FTS is an index method behind an experimental flag, sonode_title_fts, its triggers and its queries would need a rewrite. The version tested, 0.9.0-pre.1, is also a pre-release.Not run: on-disk behaviour (WAL,
busy_timeout, concurrent writers/MVCC),vec0KNN against Turso's native vector index, the fullcreate_schemaDDL, and a warm-graph benchmark (the one cold run was 14.0 ms on turso vs 6.6 ms on libsql).Revisit when Turso ships FTS5 support or a stable release. No
tursodependency was added to the workspace; the scratch crate lived outside the repo.