GeezerVison is showing github.com — id: design: Turso/libSQL journal fit (design + spike) (from #5681) · Issue #5865 · developing-today/code
id: design: Turso/libSQL journal fit (design + spike) (from #5681) #5865DescriptionSummary
Follow-on design ticket from #5681 — its decomposition sketch names this as a separate design, and the parent's acceptance requires these tickets to be filed and linked. Filed in the 2026-11-04 gap pass (WS-F) so the design work exists and can be prioritised on its own merits; implementation timing is a separate decision, possibly months out.
What this design must settle
libSQL embedded replicas and primary replication composed with #806, with a small proof of concept.
Context from the parent
The parent design decides D1 vs Turso vs both for the serverless (Workers) edition and fixes the storage contract each backend must satisfy. The parent issue carries the surrounding decisions this ticket must not re-decide; where this ticket's answer would change a parent decision, record that explicitly rather than silently forking it.
Decision record expected
Close this design with a recorded decision (on this issue or in a doc/ record linked from it): the chosen shape, the alternatives rejected and why, and the invariants implementation must hold. If the design splits further, file the splits and link them here rather than growing this issue.
Relations
Parent: #5681. Programme: epic #2056. Filed by WS-F (2026-11-04 ID design gap & expansion pass). Activitydeveloping-today commented on Nov 5, 2026 added task/triageQueue packet kind: verify, reproduce, and route this item kind/designA design proposal (design-architect): multi-step, phased, decision-bearing and removed on Nov 5, 2026dezren39 commented on Nov 5, 2026 agent-note:v1
- task: 10267
- state: done (triaged; pickup and triage in one pass, lane code-h direct)
Triage 2026-11-05 (task 10267): well-scoped follow-on design+spike ticket from #5681, verified open with no hard-stop labels and no decision record yet (only comment is the Kaneo link).
Verified ordering context, fresh reads:
Routing: no blocker on Drew. The spike (small proof of concept) is the evidence-producing step and is independently actionable; implementation timing beyond the spike is a separate later decision per the filing note. dezren39 commented on Nov 10, 2026
Agent note — task 14743 picked up direct, lane code-h
- Worker: repo-worker-code, lane code-h (shift 2026-11-10 17:58 CST)
- Task: task 14743 (design + spike) for issue id: design: Turso/libSQL journal fit (design + spike) (from #5681) #5865 — Turso/libSQL journal fit, from parent design(id): serverless edition storage — D1 vs Turso vs both for
id on Cloudflare Workers #5681
- Lane assignment: direct (row 6257); this lane works the task itself per fix(queue): single-session by default — launch-on-handoff, lane works, inline triage (reverses #8097 Rule 3) #8187.
- Revalidation (fresh): issue id: design: Turso/libSQL journal fit (design + spike) (from #5681) #5865 OPEN, no hard-stop labels. Parent design(id): serverless edition storage — D1 vs Turso vs both for
id on Cloudflare Workers #5681 still OPEN, but its decision record landed today (doc/2026-11-10_decision_id5681_serverless_storage.md): Drew's direction is BOTH with roles — Turso preferred, embedded replicas on endpoints — and the signed journal (id: F12.13 journal replication (read replicas over a signed stream) #806) is the system of record while every store is a materialisation of it. This design therefore does not re-decide D1 vs Turso; it settles how libSQL replication composes with id: F12.13 journal replication (read replicas over a signed stream) #806 given that direction, and flags no conflict with it.
- Grounding already in hand: id: F12.13 journal replication (read replicas over a signed stream) #806's design (doc/2026-11-01_design_id806.md — single writer, signed stream of exact JournalEntry bytes, (ordinal, rolling digest) cursor, verify-then-persist replicas); the journal today is append-only fsynced JSONL (pkgs/id/src/world_store.rs); pkgs/id already carries a read-only libSQL HTTP adapter for foreign data (src/foreign_libsql.rs, id: implement Turso/libsql HTTP adapter v1 (read-only, live) per #5806 decision record #7577/id: design: Turso/libsql HTTP adapter (from #5672) #5806), which is a different seam from the journal store and must not be conflated with it.
- Plan: spike the journal-entry mapping against a local libSQL primary (turso dev) on the laptop, write the decision record as doc/2026-11-10_design_id5865.md in the sibling shape, open and merge the doc PR, record spike results here, and file the embedded-replica sync spike as a follow-on packet if it cannot be executed honestly in this shift.
dezren39 commented on Nov 10, 2026
Agent note — task 14743 DONE (decision record merged), lane code-h
- Worker: repo-worker-code, lane code-h (shift 2026-11-10 18:05 CST)
- Task: task 14743 (design + spike) for issue id: design: Turso/libSQL journal fit (design + spike) (from #5681) #5865 — Turso/libSQL journal fit
- Outcome: decision record doc/2026-11-10_design_id5865.md merged via PR docs(id): Turso/libSQL journal fit decision record (#5865) #8347 (merge 4251e53); issue id: design: Turso/libSQL journal fit (design + spike) (from #5681) #5865 closed by the merge. The composition is decided: the id: F12.13 journal replication (read replicas over a signed stream) #806 signed stream is the only journal replication; libSQL replication is a materialisation accelerator inside one deployment; embedded replicas serve only up to a verified cursor; writes go to the primary from the single writer; access via the HTTP pipeline. No conflict with the design(id): serverless edition storage — D1 vs Turso vs both for
id on Cloudflare Workers #5681 direction (BOTH with roles, landed in doc/2026-11-10_decision_id5681_serverless_storage.md) — consumed, not re-decided.
- Spike results (record section 6.1, executed on the laptop): the journal table mapping (journal_entry with exact entry bytes and a (world_id, ordinal) primary key, plus journal_head) verified against the SQLite engine libSQL forks — ordinal-ordered storage and retrieval, byte-exact entry round-trip, duplicate-ordinal refusal by the primary key, and the head-consistency check as a single query.
- Spike owed (record section 6.2): embedded-replica frame-sync behaviour could not be executed here — no sqld on the fleet laptop (turso dev refuses to start) and the turso shell is a CGO-disabled stub. Filed as follow-on spike id: spike: libSQL embedded-replica sync behaviour for the journal tables (#5865 follow-on) #8346 with the acceptance verbatim (sync latency, offline reads, backwards-head convergence firing the watermark regression check).
- Codex review: two P2 findings on the first pass, both accepted and fixed in e52ffb7 — (1) fork refusal split into fork vs regression, with an independently retained verified watermark catching same-chain rollbacks whose digests still match; (2) compaction resets now archive the previous chain generation's exact entries (journal_entry_archive) under the id: design: backup, recovery & exit for serverless storage (from #5681) #5869 retention policy instead of discarding them. Re-review completed clean (no findings); both threads resolved.
dezren39 commented on Nov 17, 2026
Agent note — #8346 spike executed; results linked (lane any-d, task 20126, 2026-11-17)
The §6.2 embedded-replica spike owed by this record (#5865) has been executed against a live sqld primary (libsql-server v0.24.32, @libsql/client 0.18.0). Full measured results are on #8346: #8346 (comment) — sync latency distributions (at-rest median ~18 ms), disconnect behaviour (no replica-mode cold-open offline in this client; local file serves last synced state), reconnect convergence (digest-identical), and the head-backwards restore case: the §5.4 regression check fires at the journal layer, while libSQL's own sync() succeeds silently and keeps the replica at its newer head — the retained-watermark comparison is load-bearing. Nothing measured contradicts §2.3's freshness model. The record's §6.2 is amended with an executed-results note in the accompanying doc PR. dezren39 commented on Nov 17, 2026
Agent note — §6.2 follow-on spike #8346 EXECUTED (task 20126, lane any-j, 2026-11-17)
The embedded-replica sync spike this issue's record owed (§6.2 of doc/2026-11-10_design_id5865.md, filed as #8346) has been executed and the full measurements are recorded on #8346: #8346 (comment)
Headlines for this issue's record:
- Sync latency (cloud primary, pull sync): median ~0.36 s at rest, ~0.26 s under append load, full catch-up per sync; disconnect serves last synced state; reconnect converges.
- One design-relevant finding: writes on an embedded-replica connection are forwarded to the primary, not refused — §5.1's one-writer invariant must be gated at the journal layer, not assumed from client behaviour.
- The §5.4 regression case behaves as designed: the journal-layer check against the retained verified watermark fires on a head-backwards restore; the libSQL layer itself gives no signal (and does not converge backwards).
- §2.3's freshness model is not contradicted; no amendment. A companion doc PR marks §6.2 executed in the record and links the results.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|