Quality read of honker-core's watcher/transactional core cross-checked against the published crates.io artifact: the core itself is clean (Writer/Readers, polling-watcher failure handling, WatcherDeathGuard all verified), but published 0.5.0 predates upstream's unreleased fix train carrying the issue-#133 savepoint hardening (silent job loss in the dead-letter paths) and five .ok() error swallows — and ADR-010's queue depth requires engine-owned queue SQL in any posture. Resolution: fork honker-core at the reference revision, inherit the clean machinery and test suites, re-derive queue ops on contract v1, rename tables to __alkstore_*. - docs/research/quality-read-honker-core.md — full evidence - docs/architecture/decisions/011-sqlite-substrate-fork.md — decision - OQ-06 resolved in open-questions.md; ADR-003/005/008, engine-sqlite, queues, README annotated for consistency
7.3 KiB
status, last_updated
| status | last_updated |
|---|---|
| draft | 2026-10-05 |
SQLite engine
The alkstore-sqlite engine implements
core-contract.md on rusqlite over the
forked honker-core substrate.
This spec records WHAT the engine is internally (its
connection architecture, seam, and wake plumbing) — not code-level
HOW. Decisions live in ADRs; per-contract obligations live in the core
spec and are not restated here.
Identity and posture
- Single driver: rusqlite, riding the
forked honker-core substrate
(fork of published honker-core 0.5.0's lineage at the reference
revision),
bundled-sqlitefor hermetic builds. No.soruntime artifacts (ADR-003 for the driver decision; ownership resolved by ADR-011 — OQ-06's read fired ADR-005's fork trigger). - Sync machinery, async-facing trait: honker-core is sync (std
threads, blocking iterators); the engine bridges at the trait seam
per the family-standard posture (alktty REQ-TTY-01 precedent).
Every engine call runs in
spawn_blocking. - Single-host by nature: file-backed, one machine, NFS-two-writers unsupported (honker's honesty posture, inherited). See deployment.md.
Connection architecture
- Writer — one dedicated connection; the only one permitted to write. Serializes all mutations (WAL single-writer, modeled honestly, not fought).
- Readers — a small pool of read connections for lookups and claim/ack work.
- Watcher — honker-core's
SharedUpdateWatcher: a dedicated thread pollingPRAGMA data_versionat the default 1 ms cadence, fanning out to listeners, overtriggering on purpose (waking all subscribers per poll tick, even when several commits coalesced inside one tick — wake is a hint; consumers re-read indexed state, ADR-006). - Each connection runs honker's bootstrap at open: pragmas
(WAL,
synchronous=NORMAL, busy timeout),attach_notify,attach_honker_functions,bootstrap_honker_schema(the alknet-filesystem POC's wiring shape).
Mapping the contract
| Contract piece | Engine realization |
|---|---|
| notify / listen | honker's notify functions inside the caller's tx; listen() bridges the watcher's fanout into a tokio receiver (one spawn_blocking thread per subscription doing blocking_send) |
| streams | honker's stream machinery; explicit offset saves through the tx seam |
| queues | owned queue machinery (forked substrate re-derived on ADR-010 — stamps, no-stranded-rows sweep, dead-visible get_job); ADR-003's ride posture superseded on ownership by ADR-011 |
| named locks | honker's lock machinery |
| scheduler / outbox | collapse shape (ADR-009): owned scheduler storage (__alkstore_scheduler_tasks, forked substrate) carrying @every specs (cron machinery not ported); the leader loop pattern (TTL lock, heartbeat, exit-before-tick-on-loss); the leadership lock is __alkstore_scheduler; outbox = helper over queues with the derived backing-queue name (ADR-008 §4) |
| begin_tx | acquires the writer slot, opens BEGIN IMMEDIATE, returns the caller-held handle (ADR-007) |
| handle ops | each *_tx op round-trips spawn_blocking to the same connection (thread-affinity note in ADR-007) |
| commit/rollback | releases the writer slot |
Obligations and constraints
- A long transaction parks the writer (the slot lease is the honest model). Contract docs must surface this so consumers budget transactions (ADR-007 negative consequence).
- Watcher failure handling is inherited: on watcher death, every
subscriber's receiver closes (
WatcherDeathGuardbehavior) — consumers see the close, never a silent hang (ADR-006). - Wake coalescing: bursts inside one poll tick produce one wake; correctness is preserved by the re-read contract (POC-pinned: missed-wake stress with correct post-burst re-reads).
- Deployment note: the substrate's rusqlite generation (^0.40.1) has a rustc floor ≥ 1.99; binaries linking this engine carry that requirement (deployment.md matrix).
- The optimization path, if seam throughput ever demands it: a dedicated std-thread bridge (one thread owning the writer conn, ops over mpsc — measured ~2× the spawn_blocking shape at p50 in POC #1), or a raised watcher cadence for idle CPU. Neither is the default.
What the fork question resolved
The quality read (OQ-06) —
this engine's dependency gate — resolved 2026-10-05: ADR-005's fork
trigger fired (ADR-011).
The substrate is owned code forked from honker-core's lineage; the
watcher/connection architecture this spec describes is inherited
verbatim where kept (ADR-003
unchanged in architecture). The
evidence: published
0.5.0's unreleased-fix-train defect class, plus ADR-010's queue depth
requiring engine-owned queue SQL in any posture. The forked
substrate's table family is __alkstore_* (ADR-010 §8's naming
authorization).
Design Decisions
| ADR | Decision | Summary |
|---|---|---|
| 001 | Crate split | single-driver engine crate |
| 002 | Feature scope | which rows this engine serves |
| 003 | Driver | rusqlite + honker-core lineage, bridged seam, inherited watcher — ownership resolved by 011 |
| 005 | Ownership | published honker-core; fork trigger fired by OQ-06 (ADR-011) |
| 006 | Wake contract | data_version watcher, coalescing, death-closes-receivers |
| 007 | Tx seam | writer-slot lease, BEGIN IMMEDIATE, spawn_blocking round-trips |
| 008 | Contract v1 | pinned surface; outbox backing queue derived under the reserved prefix; wake payload transport unused (non-contract) |
| 009 | Scheduler collapse | @every specs; __alkstore_scheduler leadership; cron rejected |
| 010 | Queue depth | semantics pinned; §5/§3a realization resolved by ADR-011 (owned code) |
| 011 | Substrate fork | OQ-06's trigger fired; substrate owned, queue ops re-derived on contract v1 |
Open Questions
Open questions are tracked in open-questions.md. Key questions affecting this document:
- OQ-06: honker-core quality read — fork-trigger assessment — resolved (2026-10-05, ADR-011; trigger fired).
Resolved: OQ-09 (scheduler collapse — ADR-009) and OQ-05 (queue semantics depth — ADR-010), 2026-10-05.