agent-orchestrator/backend/internal/storage/sqlite/gen
prateek e5c4fd6ffd feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer)
Reworks the storage + CDC layer to the simplified design agreed in review:

Schema (one clean migration, 0001): projects, sessions, pr, pr_checks,
pr_comment, change_log. sessions.id is a single string key "{project}-{num}"
(mer-1); operational metadata folded into sessions; is_alive replaces the
runtime axis; no revision (the per-session write mutex serializes, change_log.seq
orders). pr keyed by URL (1 session : many PRs). pr_checks is CI run history
(one row per check per commit) — the CI-fix-loop brake is a LIMIT 3 query, no
counter stored. change_log carries a required project_id FK + nullable session_id.

CDC is DB-native: AFTER INSERT/UPDATE triggers on sessions/pr/pr_checks append
to change_log atomically with the change (json_object payloads). The old durable
outbox/JSONL/janitor pipeline is gone; the cdc package is now a Poller that reads
change_log and fans events out through the in-memory Broadcaster (hardened with
recover()). Clients catch up via the log from their own offset (SSE Last-Event-ID).

Storage uses a single writer connection + a reader pool (read-your-writes for the
triggers' subqueries; concurrent reads). sqlc-generated typed queries.

Tests (-race): CRUD, per-project id assignment, the loop-brake query, concurrent
creates, triggers populating change_log; CDC end-to-end through the real store,
concurrent goroutine delivery, broadcaster panic-isolation.

NOTE: scoped to storage + CDC. The lifecycle-engine consumers (decide, lifecycle,
session, reaper, main wiring) still reference the old domain axes and need a
follow-up integration pass to compile against the new model.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 05:42:59 +05:30
..
changelog.sql.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
db.go feat(backend): SQLite storage layer + CDC pipeline, LCM/reaper wiring 2026-05-30 16:02:07 +05:30
models.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
pr.sql.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
pr_checks.sql.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
pr_comment.sql.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
projects.sql.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
querier.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
sessions.sql.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30