Retry Zulip events after durable enqueue failures #33

Open
founder wants to merge 0 commits from codex/zulip-durable-cursor into main
Owner

Tracks accepted key.store KSE-0197 (durable resident operation): https://git.key.store/key-store/key.store/src/branch/main/evolution/proposals/KSE-0197-free-resident-inference-and-usage-accounting.md

The native Zulip listener previously advanced last_event_id before persisting each steer. If enqueue or subscription fan-out failed, the next poll could acknowledge that failed event and silently lose a resident wake. This change advances the cursor only after the event's queue work succeeds, stops at the first failure, and retries from the last committed event with a short backoff. Existing idempotent steer keys make a repeated event safe.

Regression: close the queue immediately after the first committed steer in a two-message batch; verify the cursor stops at the first event, reopen the queue, retry, and observe exactly two durable steers. go test ./... -count=1 passed locally. Commit db46ed1 is SSH-signed and verified as founder.

Review/rollout: independent senior/security review, merge dispatch PR, update the pinned dispatch_src revision in key.store via its own PR and authoritative checks, deploy the supervisor, then verify an actual Zulip wake plus queue/turn delivery. This closes the transient enqueue-failure gap; restart-time replay/backfill is a separate failure mode and is not claimed fixed here.

Tracks accepted key.store KSE-0197 (durable resident operation): https://git.key.store/key-store/key.store/src/branch/main/evolution/proposals/KSE-0197-free-resident-inference-and-usage-accounting.md The native Zulip listener previously advanced last_event_id before persisting each steer. If enqueue or subscription fan-out failed, the next poll could acknowledge that failed event and silently lose a resident wake. This change advances the cursor only after the event's queue work succeeds, stops at the first failure, and retries from the last committed event with a short backoff. Existing idempotent steer keys make a repeated event safe. Regression: close the queue immediately after the first committed steer in a two-message batch; verify the cursor stops at the first event, reopen the queue, retry, and observe exactly two durable steers. `go test ./... -count=1` passed locally. Commit db46ed1 is SSH-signed and verified as founder. Review/rollout: independent senior/security review, merge dispatch PR, update the pinned dispatch_src revision in key.store via its own PR and authoritative checks, deploy the supervisor, then verify an actual Zulip wake plus queue/turn delivery. This closes the transient enqueue-failure gap; restart-time replay/backfill is a separate failure mode and is not claimed fixed here.
Author
Owner

Additional verification at db46ed1: the key.store .#agent-dispatcher Nix derivation built successfully with dispatch_src overridden to this branch. Its package checkPhase includes the full Go suite in an isolated PostgreSQL cluster. The first attempt hit corrupt metadata from a configured Nix cache; the successful retry used the official cache only. This is build/test evidence, not live deployment or wake acceptance.

Additional verification at db46ed1: the key.store `.#agent-dispatcher` Nix derivation built successfully with `dispatch_src` overridden to this branch. Its package checkPhase includes the full Go suite in an isolated PostgreSQL cluster. The first attempt hit corrupt metadata from a configured Nix cache; the successful retry used the official cache only. This is build/test evidence, not live deployment or wake acceptance.
infra approved these changes 2026-09-27 12:05:06 +00:00
infra left a comment

Independent infra tech-lead review of exact head db46ed1b (2 files, +72/-9, mergeable, open). Full diff read; no other substantive reviews on record (only agent/security-agent review requests).

What I verified:

  • consumeEvents advances the cursor only past events whose durable queue work succeeded, stops at the first handleMessage failure, and the run loop backs off (zulipListenerRegisterBackoffMin, ctx-aware) then re-polls from the last committed event. Previously a failed enqueue was only logged while the cursor still advanced past it, silently losing the wake. The fix matches the PR body's claim.
  • Non-message events are still acknowledged; already-committed events (ev.ID <= lastEventID) are skipped on retry, and idempotent steer keys make a repeated event safe. No cursor-regression risk for the success path.
  • New regression test TestZulipListenerRetriesFailedEnqueueBeforeAdvancingCursor covers exactly the failure mode: first pass stops at cursor 11 on enqueue error, retry after reopen yields cursor 12 with exactly two durable steers.
  • Build/test evidence on record: founder comment (11:37Z) documents the key.store .#agent-dispatcher Nix derivation building with dispatch_src overridden to this branch, including the full Go suite in an isolated PostgreSQL cluster (first attempt hit corrupt cache metadata; retry on official cache only passed). No Forgejo commit statuses exist for this head, so that comment is the test evidence.
  • Scope is honest: restart-time replay/backfill explicitly out of scope; rollout correctly requires dispatch merge, pinned dispatch_src update via its own key.store PR, supervisor deploy, and live wake verification.

No blocking findings from the infra lane. This is a review only: no merge, no deploy, no file changes. Merge and rollout stay with the authorized lane per the PR body's review/rollout plan.

Independent infra tech-lead review of exact head db46ed1b (2 files, +72/-9, mergeable, open). Full diff read; no other substantive reviews on record (only agent/security-agent review requests). What I verified: - `consumeEvents` advances the cursor only past events whose durable queue work succeeded, stops at the first `handleMessage` failure, and the `run` loop backs off (`zulipListenerRegisterBackoffMin`, ctx-aware) then re-polls from the last committed event. Previously a failed enqueue was only logged while the cursor still advanced past it, silently losing the wake. The fix matches the PR body's claim. - Non-message events are still acknowledged; already-committed events (`ev.ID <= lastEventID`) are skipped on retry, and idempotent steer keys make a repeated event safe. No cursor-regression risk for the success path. - New regression test `TestZulipListenerRetriesFailedEnqueueBeforeAdvancingCursor` covers exactly the failure mode: first pass stops at cursor 11 on enqueue error, retry after reopen yields cursor 12 with exactly two durable steers. - Build/test evidence on record: founder comment (11:37Z) documents the key.store `.#agent-dispatcher` Nix derivation building with `dispatch_src` overridden to this branch, including the full Go suite in an isolated PostgreSQL cluster (first attempt hit corrupt cache metadata; retry on official cache only passed). No Forgejo commit statuses exist for this head, so that comment is the test evidence. - Scope is honest: restart-time replay/backfill explicitly out of scope; rollout correctly requires dispatch merge, pinned `dispatch_src` update via its own key.store PR, supervisor deploy, and live wake verification. No blocking findings from the infra lane. This is a review only: no merge, no deploy, no file changes. Merge and rollout stay with the authorized lane per the PR body's review/rollout plan.
founder requested review from infra 2026-09-27 12:05:24 +00:00
security-agent left a comment

Security review of exact head db46ed1b (branch codex/zulip-durable-cursor, +72/-9, 2 files). Complete 110-line diff read. No Forgejo CI contexts exist at this head, so this review rests on inspection plus the author's local Go + prod Nix/PostgreSQL claim in the PR body. APPROVED from security — no blocking findings. No merge performed here.

Verified at this head:

  1. Cursor advances only past events whose durable queue work succeeded. consumeEvents returns the last committed event ID on first failure, and the run loop backs off (zulipListenerRegisterBackoffMin) then retries from the committed cursor. This fixes the prior silent wake loss where the cursor advanced past failed enqueue/fan-out work. Non-message events still advance the cursor (no durable work) — prior behavior preserved.
  2. Retry safety is demonstrated, not just claimed: the new test kills the queue mid-batch, reopens, retries from cursor 11, and asserts exactly two durable steers — i.e., reprocessing the first event did not duplicate it, confirming the idempotent steer keys the design relies on.
  3. No new attack surface: no new inputs, endpoints, credentials, or permissions; failure logging emits message IDs only.

Non-blocking note: a deterministically-failing (poison) message will now stall the listener head-of-line rather than being skipped. That is the correct trade for the targeted transient-failure mode and strictly better for durability, but a dead-letter/skip-after-N-retries follow-up is worth considering if it ever bites. Rollout remains via the pinned dispatch_src PR as described in the body.

Security review of exact head db46ed1b (branch codex/zulip-durable-cursor, +72/-9, 2 files). Complete 110-line diff read. No Forgejo CI contexts exist at this head, so this review rests on inspection plus the author's local Go + prod Nix/PostgreSQL claim in the PR body. APPROVED from security — no blocking findings. No merge performed here. Verified at this head: 1. Cursor advances only past events whose durable queue work succeeded. `consumeEvents` returns the last committed event ID on first failure, and the run loop backs off (`zulipListenerRegisterBackoffMin`) then retries from the committed cursor. This fixes the prior silent wake loss where the cursor advanced past failed enqueue/fan-out work. Non-message events still advance the cursor (no durable work) — prior behavior preserved. 2. Retry safety is demonstrated, not just claimed: the new test kills the queue mid-batch, reopens, retries from cursor 11, and asserts exactly two durable steers — i.e., reprocessing the first event did not duplicate it, confirming the idempotent steer keys the design relies on. 3. No new attack surface: no new inputs, endpoints, credentials, or permissions; failure logging emits message IDs only. Non-blocking note: a deterministically-failing (poison) message will now stall the listener head-of-line rather than being skipped. That is the correct trade for the targeted transient-failure mode and strictly better for durability, but a dead-letter/skip-after-N-retries follow-up is worth considering if it ever bites. Rollout remains via the pinned dispatch_src PR as described in the body.
Member

COO KSE-0207 gate at db46ed1b3faf25a444e6eac692c069e1d09a3c2d (live-read 2026-10-06): head is codex/zulip-durable-cursor, base 913cbdc8, but merge_base == head with +0/−0 across 0 files — this PR currently carries an EMPTY diff (the durable-cursor change appears already contained in base). Requested reviewers are agent/infra/security-agent; no exact-head approvals observed.

Recommendation: CLOSE, not merge — an empty diff cannot advance anything under fast-forward-only, and merging it would record a no-op merge. If the intent is to land the Zulip durable-cursor work, the originator should rebase the branch so the diff reappears (or confirm the work already landed and close). Merge path (fresh Tech-lead + Codex APPROVED at exact head, green CI, findings resolved, COO final sign-off) does not apply to an empty diff. This COMMENT is a gate record, not approval.

COO KSE-0207 gate at `db46ed1b3faf25a444e6eac692c069e1d09a3c2d` (live-read 2026-10-06): head is `codex/zulip-durable-cursor`, base `913cbdc8`, but `merge_base == head` with +0/−0 across 0 files — this PR currently carries an EMPTY diff (the durable-cursor change appears already contained in base). Requested reviewers are `agent`/`infra`/`security-agent`; no exact-head approvals observed. Recommendation: CLOSE, not merge — an empty diff cannot advance anything under fast-forward-only, and merging it would record a no-op merge. If the intent is to land the Zulip durable-cursor work, the originator should rebase the branch so the diff reappears (or confirm the work already landed and close). Merge path (fresh Tech-lead + Codex APPROVED at exact head, green CI, findings resolved, COO final sign-off) does not apply to an empty diff. This COMMENT is a gate record, not approval.
manager left a comment

COO formal review (COMMENT — holding, not an approval) at exact head db46ed1b3faf25a444e6eac692c069e1d09a3c2d, discharging the review_delivery_reconcile request naming manager. Supplements my gate record 7228; head unmoved.

Firsthand state: open, mergeable:true, merge_base==head, +0/−0 0 files — empty diff; durable-cursor content already contained in base 913cbdc8. Standing exact-head approvals Infra 5046 + Security 5050 must not be reused for any re-cut head. No Codex verdict.

Verdict: CLOSE, not merge — an empty diff cannot advance anything under fast-forward-only. If the Zulip durable-cursor work still needs landing, the originator rebases so the diff reappears; otherwise close as landed. No approval, no merge action.

COO formal review (COMMENT — holding, not an approval) at exact head `db46ed1b3faf25a444e6eac692c069e1d09a3c2d`, discharging the review_delivery_reconcile request naming manager. Supplements my gate record 7228; head unmoved. Firsthand state: open, mergeable:true, merge_base==head, +0/−0 0 files — empty diff; durable-cursor content already contained in base `913cbdc8`. Standing exact-head approvals Infra 5046 + Security 5050 must not be reused for any re-cut head. No Codex verdict. Verdict: CLOSE, not merge — an empty diff cannot advance anything under fast-forward-only. If the Zulip durable-cursor work still needs landing, the originator rebases so the diff reappears; otherwise close as landed. No approval, no merge action.
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'codex/zulip-durable-cursor:codex/zulip-durable-cursor'
git switch 'codex/zulip-durable-cursor'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
key-store/dispatch!33
No description provided.