agent-orchestrator/backend/internal/storage/sqlite
harshitsinghbhandari ad1c4dacec test(integration): LCM+SM live-fire against real SQLite store
Adds backend/internal/integration with five end-to-end tests that hydrate the
real lifecycle.Manager + session.Manager against a tmp SQLite store and
exercise the full pipeline through the DB triggers and the CDC poller:

- TestHappyPath_Spawn_PR_Kill — spawn -> SCM PR observation (open + CI
  passing) -> kill; asserts canonical row, pr row, and change_log event
  types (session_created/_updated, pr_created, pr_check_recorded).
- TestRestoreRoundTrip_PreservesMetadata — spawn, kill, close store, reopen
  same DB path, hydrate fresh LCM/SM, Restore(); asserts AgentSessionID and
  the rest of SessionMetadata survive across the daemon restart.
- TestCIFailureAndRecovery_NudgeThenClears — failing CI observation drives
  the CI-failed reaction nudge with the log tail injected; passing CI
  observation switches to approved-and-green human notify; pr_checks history
  reads back the failure (the brake's source of truth).
- TestDetectingPersistsAcrossRestart — failed probe parks the session in
  detecting with detecting_* columns populated, round-trips across a
  close/reopen, alive probe clears the quarantine memory.
- TestCDCPollerReceivesAllStages — drives the real cdc.Poller; asserts the
  trigger pipeline emits each expected event_type and seq is monotonic.

Wiring gap fixed (minimal): goose v3 keeps baseFS/logger/dialect as
package-level globals, so two concurrent sqlite.Open() calls — uncommon in
production but normal under -race with t.Parallel() — race on
goose.SetBaseFS/SetLogger/SetDialect inside migrate(). Added a process-level
sync.Mutex around the migrate() call. ~11 lines, no signature changes.

Scope notes (the task brief assumed a fancier architecture than what
actually shipped in PR #37):
- No outbox / consumer_offsets / janitor exist on main — the change_log
  table IS the durable, ordered source of truth (see cdc/event.go), so the
  brief's janitor-watermark step is skipped.
- No reaction_trackers table / ReactionStore port — trackers are in-memory
  per lifecycle/reactions.go; persistence-round-trip there is N/A.
- No revision column / Upsert(rec, eventType) — write-mutex serialises and
  change_log.seq orders, so the assertions land on event_type + seq, not on
  a per-row revision counter.

All 219 tests pass under -race across 18 packages. lifecycle/fakes_test.go
is untouched; existing unit tests still drive the in-memory fake.
2026-05-31 18:34:51 +05:30
..
gen feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
migrations feat(backend): atomic PR-observation write + CDC on check status updates 2026-05-31 17:02:47 +05:30
queries feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
changelog_store.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
db.go test(integration): LCM+SM live-fire against real SQLite store 2026-05-31 18:34:51 +05:30
mapping.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
pr_cdc_test.go feat(backend): atomic PR-observation write + CDC on check status updates 2026-05-31 17:02:47 +05:30
pr_store.go feat(backend): atomic PR-observation write + CDC on check status updates 2026-05-31 17:02:47 +05:30
project_store.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
store.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30
store_test.go feat(storage,cdc): minimal 6-table schema + trigger-driven CDC (storage layer) 2026-05-31 05:42:59 +05:30