Skip to main content

Module sqlite

Module sqlite 

Source
Expand description

The sqlite registry twin — the family adapter pattern’s default engine assembly (ADR-019 §3, substrate.md §registry: “one trait pair, two implements — the sqlite adapter (sqlite feature, alkstore-sqlite + the co-tenant rusqlite connection)”).

  • SqliteRegistry — the durable write side (RegistryWrite) over the co-tenant git_repos rows. Every mutation bumps the durable registry_seq singleton inside the row-write transaction (transactionally exact — the watermark’s anchor, ADR-019 §5; failed mutations consume none, the tx rolls back whole), and the twins’ row commits also carry the refs-table legs the composition owes: put_repo seeds HEAD → refs/heads/main (substrate.md §refs — git parity: git init --bare creates the dangling HEAD at init, not at first push; git’s push grammar carries no HEAD. The dangling symref is exactly the unborn-HEAD shape ls-refs=unborn serves — the OQ-19 rider (a) fixture — and is CAS-unreachable from a push per git parity; the row is CAS-rewriteable, so the v1-pinned target is a two-way door, the constructor knob additive later) and remove_repo removes the registry row, the repo’s ref rows, and the repo’s mutation-marker rows together (backend.md — deletion is a GC consequence; objects stay for the sweep, no synchronous object deletion exists — the removal only touches co-tenant rows). Plus SqliteRegistry::record_mutation — the per-push mutation-marker write (ADR-019 §7, composition-internal: bumps the seq/watermark legs without touching the record; the receive-pack composition is the consumer).
  • SqliteRegistryAssembly — the adapter constructor: one fallible assembly call (loud failure — ADR-024 §1) that opens the co-tenant connection (CoTenantSqlite::open — WAL, the pinned busy_timeout 5000 ms, the migrations run at construction) beside the engine on one file, opens the alkstore-sqlite engine, loads the cached read provider’s initial snapshot, wires the reactive halves (Reactor) plus the announced write side (AnnouncingRegistry) and the refs twin, and hands back the pieces. The wave-8 single composition entry unifies construction; this is the per-piece constructor (the recorded interpretation). Post-commit announce (publish + notify + enqueue — each independent, fail-soft) is wired by default: mutations ride AnnouncingRegistry, never a non-reactive shipped path (ADR-019 §5).

§The sqlite asymmetry carried (substrate.md §the reactive halves)

The co-tenant file is itself the invalidation bus: the watcher’s file-wide data_version bump fans a wake to listeners on any commit to the file — including alkgit’s own registry writes on their own connection, including cross-process (~3.2 ms measured, POC-R; the probe is test-pinned here). A lost hint cannot exist while any write lands; the reconcile sweep is the correctness backstop, not a latency bound. The post-commit notify leg stays redundant but kept — for semantics and for postgres.

Concurrency model: rusqlite is blocking — the trait methods bridge their SQL off the async executor (spawn_blocking) under the co-tenant handle’s short-held lock, exactly the refs twin’s shape; the pinned busy timeout absorbs the cross-process write-lock waits.

Re-exports§

pub use crate::registry::HEAD_SEED_TARGET;

Structs§

SqliteRegistry
The durable write side of the family pair over the co-tenant git_repos rows (the pair’s sqlite implement). Reads ride the cached provider in the composed assemblies — the hot path never touches this side except the refresh reads.
SqliteRegistryAssembly
The sqlite twin assembly — the pieces one adapter constructor wires over the default engine assembly (single-host shape, substrate.md §assembly: alkstore-sqlite + the co-tenant twin on one file):