refactor: propagate context.Context through call chains #155
Reference in New Issue
Block a user
Delete Branch "refactor/context-propagation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes backlog item #19 — the last deferred security audit finding (context propagation, item 3.10).
Changes
Thread
context.Contextfrom callers instead of creatingcontext.Background()at every call site:Start()) fortriggerAlertgoroutines. Init methods (InitHistory,InitLogs,InitAlertHealth) accept ctx.GetStateChanges/GetStateChangesSince/TestAlertaccept ctx.apply,export,migrate-secrets) create root ctx and thread throughopenStore, seed functions.runServecreates one root ctx used for store init, engine lifecycle, and TUI.refresh/IsAllowedaccept ctx, threaded from SSH auth handler.Two intentional
context.Background()remain:Start(ctx)drainWrites— parent ctx already cancelled at shutdown timeTest plan
go build ./...— cleango test ./...— all passgolangci-lint run ./...— 0 issuescontext.Background()outside root entry points and the two documented exceptions