Revert "feat: add notifier delivery runtime"#63
Conversation
Greptile SummaryThis PR reverts #58 ("feat: add notifier delivery runtime"), removing the full notification dispatch runtime — the delivery scheduler, routing engine, retry policy, desktop delivery wiring, and the associated SQLite schema migration (
Confidence Score: 3/5Safe to merge only if migration 0003 has never been applied to any live environment; any deployment that ran #58 will have orphaned schema objects and a potential Goose startup failure on next deploy. The revert is internally consistent — all generated code, domain types, config types, and wiring are updated together. The two concerns that hold back full confidence: (1) deleting the migration file instead of adding a new forward migration means that databases carrying version 3 in goose_db_version cannot cleanly start with this binary, and (2) the error-path shutdown sequence in daemon.go that PR #58 had fixed (cdcPipe.Stop not called before store.Close on httpd.New/startLifecycle failures) is reintroduced. If #58 was never deployed, only concern (2) is active, which is a latent race in an error path. If #58 reached any deployed environment, concern (1) is an operational blocker. backend/internal/storage/sqlite/migrations/ — the deleted 0003 file is the most operationally sensitive part of this revert; backend/internal/daemon/daemon.go — the error-path shutdown ordering for httpd.New and startLifecycle failures should be revisited. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Before["Before Revert (PR #58)"]
A1[daemon.Run] --> B1[startCDC]
A1 --> C1[startNotifier\nManager+Dispatcher]
A1 --> D1[httpd.New]
A1 --> E1[startLifecycle]
D1 -- error --> F1[stop + notifier.Stop\n+ cdcPipe.Stop]
E1 -- error --> F1
C1 --> G1[RoutePending\nrouted_at tracking]
G1 --> H1[notification_deliveries\ntable]
H1 --> I1[Electron / AO-app\ndesktop toast claim]
end
subgraph After["After Revert (this PR)"]
A2[daemon.Run] --> B2[startCDC]
A2 --> D2[httpd.New]
A2 --> E2[startLifecycle]
D2 -- error --> F2[return err\ncdcPipe NOT stopped]
E2 -- error --> F2
A2 --> G2[Enqueuer only\nenqueue to notifications table]
end
subgraph Schema["DB Schema risk"]
S1[0003 migration applied\nin existing DB] --> S2[routed_at column\norphaned]
S1 --> S3[notification_deliveries\norphaned tables]
S1 --> S4[Goose v3.27.1\napplied-but-missing\nmigration risk]
end
|
| @@ -86,11 +79,6 @@ func Run() error { | |||
| // trigger -> change_log -> poller -> broadcaster. | |||
| lcStack, err := startLifecycle(ctx, store, log) | |||
| if err != nil { | |||
| stop() | |||
| notifier.Stop() | |||
| if cdcErr := cdcPipe.Stop(); cdcErr != nil { | |||
| log.Error("cdc pipeline shutdown", "err", cdcErr) | |||
| } | |||
| return err | |||
| } | |||
There was a problem hiding this comment.
cdcPipe not drained before store.Close on early-return error paths
PR #58 had added stop() + cdcPipe.Stop() to both the httpd.New() and startLifecycle() error paths. The revert removes those calls, restoring the pre-#58 state where, if either call fails, return err fires and the deferred sequence runs as: termMgr.Close() → stop() → store.Close(). Cancelling the context causes the CDC poller goroutines to start winding down, but store.Close() fires immediately after stop() with no drain wait. Any CDC goroutine that is mid-query at that instant will attempt to use a closed DB. The fix that was added in #58 — calling stop() and cdcPipe.Stop() before returning — was correct independently of the notifier, and should be retained (without notifier.Stop()) to preserve the safe shutdown ordering.
Reverts #58