feat(storage): move runtime state to SQLite - #173
Merged
Conversation
owainlewis
force-pushed
the
codex/170-sqlite-state
branch
from
July 30, 2026 13:19
6dc8045 to
a58f546
Compare
owainlewis
force-pushed
the
codex/170-sqlite-state
branch
from
July 30, 2026 13:26
a58f546 to
80bd7b9
Compare
owainlewis
force-pushed
the
codex/170-sqlite-state
branch
from
July 30, 2026 13:39
80bd7b9 to
11fb11d
Compare
owainlewis
marked this pull request as ready for review
July 30, 2026 13:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves channel cursors and channel-qualified backend session mappings into the canonical
push.dbSQLite database. Existingstate.jsonfiles migrate once through an atomic, idempotent transaction, remain untouched as a recovery copy, and continue to honor explicitstate_path, legacylast_row_id, and unqualified iMessage session keys.The merged
PushPathsowner now supplies both the canonical database and legacy migration paths to the state store. Explicitstate_pathanddatabase_pathoverrides remain compatible. The Slack durable inbox remains separate onPushPaths.inboxbecause its acknowledgement-queue lifecycle differs from canonical runtime state. Database and migration errors fail closed before polling or pause processing with actionable context.Why
Whole-file JSON rewrites created a second mutable source of truth and could not provide database-level concurrency guarantees. SQLite now provides monotonic cursor upserts, transactional session rotation, and crash-safe migration markers under the repository's canonical runtime-path owner.
Test plan
Verified after rebasing onto current
main(795f326, including PRs #171, #172, and #175):cargo fmt --all -- --checkcargo clippy --locked --all-targets -- -D warningscargo build --lockedcargo test --locked(368 unit, 2 docs, 14 CLI integration, 3 crash tests)python -m mkdocs build --strict11fb11d: approved with no blocker or important findingRisks
The main risk is upgrade migration behavior. Tests cover legacy iMessage keys, explicit and fallback iMessage cursors, multiple channels and backends, empty session IDs, migration interruption and repetition, corrupt JSON, database-open failure, concurrent cursor writes, backend changes, exact channel-qualified
/clearrotation, and runtime path overrides. The retained legacy JSON is intentionally not deleted or rewritten after migration.Related issue
Closes #170