fix: commit run notification intents with state transitions

This commit is contained in:
2026-10-20 15:55:01 +01:00
parent a08789e071
commit 90cd43bdd7
7 changed files with 509 additions and 10 deletions
+13 -3
View File
@@ -6,6 +6,16 @@ notification hook. `off` suppresses stage, run-level system and browser tray
notifications. Needs you remains a status/action surface, not a delivery channel.
Summaries and pushed events carry the mode; the browser seeds and folds it.
`FinishRun` and `MarkWaiting` enqueue the notification intent in the same SQLite
transaction as the run/step state change. Enqueue failure rolls back the state;
after commit, the worker can recover the intent without any runner callback.
The store derives the mode, name, stage and sequence from stored rows. A failed
FinishRun does not emit a terminal-success event or run alert. Terminal stage
hooks run only after FinishRun commits. Waiting/terminal hooks and the worker
share an atomic sending lease to avoid racing publications. Declared hooks get
a one-minute initial opportunity to publish their artifacts; if a restart loses
the callback, the generic outbox alert becomes eligible after that delay.
`run_notifications` is an additive, idempotent SQLite migration. Each
run/sequence/event/channel has one durable outbox row. Its status is `pending`,
`sending`, `sent`, `failed`, or `covered` (a stage already published this event).
@@ -22,9 +32,9 @@ publication does not swallow the run-level fallback/retry. Stage artifact
publications themselves are not made retryable by this change.
Publisher acknowledgement is **not device reception**. A crash after publish
but before the acknowledgement is saved can duplicate a notification. The
transition and enqueue are separate writes: a crash between them can miss an
alert; this is bounded retry of enqueued alerts, not guaranteed delivery.
but before the acknowledgement is saved can duplicate a notification. State and
intent commit together, closing the transition-to-enqueue crash window; this is
still bounded retry, not guaranteed delivery.
Browser delivery remains page-session best effort and requires permission plus
HTTPS/localhost; successful runs do not become Needs you entries. The older L5
parity description is attention-only for auto; on now adds success.