Skip to content

fix(gateway): resume durable outbound delivery retries - #118694

Merged
steipete merged 1 commit into
mainfrom
codex/qa0803-outbound-delivery-retry-lifecycle
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa0803-outbound-delivery-retry-lifecycle

Conversation

@steipete

@steipete steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Automatically retry persisted failed outbound messages instead of abandoning them until Gateway restart.
  • Preserve existing backoff, atomic delivery claims, current channel authorization, and Gateway suspension/shutdown ownership.

Root cause and canonical lifecycle owner

The generic Gateway called recoverPendingDeliveries exactly once at startup. A persisted row whose backoff had not elapsed—or any new Slack/Discord/Signal/etc. transport failure after startup—had no future generic drain, leaving the user's message stranded indefinitely; only a few channels implemented their own polling. The existing per-channel durable queue, coordinator, and retry policy already support correct recovery.

The Gateway runtime now owns a bounded unref timer matching the existing five-second first backoff. Startup legacy migration still executes exactly once; normal ticks use the existing atomic generic drain/coordinator, fresh getRuntimeConfig(), nonoverlapping work admission, and canonical backoff. No admitted root is retained between ticks, suspended Gateways are skipped, and the timer stops with the existing runtime lifecycle.

Actual durable operator proof

Real SQLite queue rows for Discord, Slack, and Signal fail once, are all deferred by the real startup owner, then the canonical retry owner delivers each exactly once after backoff; a repeat drain delivers none. A real revoked channel account is dead-lettered without invoking its send callback, proving current authorization replaces stale startup configuration.

  • Five actual Gateway lifecycle failures reproduced before repair.
  • Existing Gateway lifecycle + real SQLite delivery suites: 46/46 passing.
  • Covers initially empty startup then later failure, startup-deferred rows, hot channel disable, overlap, suspension/no idle admitted waiter, and shutdown cleanup.
  • Type-aware/type-check lint and formatting: clean.
  • Fresh independent structured Sol/high review: no findings, confidence 0.91.
  • Production delta: +43 lines for the previously missing lifecycle owner; no schema, configuration, or retry-policy changes.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 10:02 AM ET / 14:02 UTC.

ClawSweeper review

What this changes

The PR makes the Gateway periodically retry persisted outbound deliveries after startup so transient transport failures no longer remain queued until a restart.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this maintainer-labeled PR open for explicit owner review. Current main performs durable outbound recovery only once at Gateway activation, while the PR adds the missing lifecycle-owned recurring drain and preserves the queue’s existing backoff, atomic claim, authorization, and shutdown boundaries; no concrete patch defect was found in the reviewed change.

Priority: P1
Reviewed head: a97754b8fa1b1eca8063831052262b4c557e0b6a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned lifecycle repair with meaningful queue and Gateway coverage; remaining exact-head CI is the material merge check.
Proof confidence 🌊 off-meta tidepool Not applicable: This PR carries the protected maintainer label, so the external-contributor proof gate does not apply; its body nevertheless describes after-fix real SQLite queue behavior across three channel types.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This PR carries the protected maintainer label, so the external-contributor proof gate does not apply; its body nevertheless describes after-fix real SQLite queue behavior across three channel types.
Evidence reviewed 5 items Current-main gap: Current main invokes outbound recovery once during scheduled-service activation; the recovery helper only runs recoverPendingDeliveries and returns no lifecycle stop handle, so there is no generic future drain for rows deferred by backoff or created after startup.
PR owner-boundary repair: The proposed helper starts one unref interval at the canonical first-backoff cadence, performs startup migration/recovery once, drains thereafter with getRuntimeConfig(), prevents overlap, and returns a stop handle wired into the existing Gateway service shutdown path.
Queue contract: The existing generic drain rechecks retry eligibility, serializes claims through its coordinator, applies current admission rules, and only then drains a queued entry; the PR reuses that contract rather than adding a parallel retry path.
Findings None None.
Security None None.

How this fits together

Gateway startup activates background services after the runtime is ready. Persisted outbound deliveries first pass through startup recovery, then the proposed Gateway-owned timer invokes the existing durable queue drain using current channel configuration to deliver, defer, or dead-letter each row.

flowchart LR
  A[Persisted outbound delivery] --> B[Gateway startup recovery]
  B --> C[Durable retry backoff]
  C --> D[Gateway retry timer]
  D --> E[Atomic queue drain]
  F[Current channel configuration] --> E
  E --> G[Delivered, deferred, or dead-lettered]
Loading

Decision needed

Question Recommendation
Should this maintainer-labeled Gateway delivery lifecycle change be approved once its exact-head CI completes and the owner accepts the all-channel retry behavior? Approve after exact-head validation: Accept the canonical Gateway timer approach after the remaining checks complete successfully and the merge result still contains the queue-claim and current-config protections.

Why: The code path is focused and source-supported, but the protected maintainer label requires explicit human handling for a change that affects persisted message delivery across channels.

Before merge

  • Add real behavior proof - Not applicable: This PR carries the protected maintainer label, so the external-contributor proof gate does not apply; its body nevertheless describes after-fix real SQLite queue behavior across three channel types.
  • Resolve merge risk (P1) - This changes the retry trigger for every generic persisted outbound delivery. The existing queue coordinator and tests reduce duplicate-send risk, but the exact merge result should retain that claim/backoff behavior after the remaining Gateway, lint, build, and smoke checks finish.
  • Resolve merge risk (P1) - GitHub reports the branch as cleanly mergeable but behind current main; refresh the exact-head review and CI state before landing rather than inferring a regression from base drift.
  • Complete next step (P2) - The protected maintainer label requires explicit owner handling; no discrete code repair or contributor proof action is currently supported by the review.
Agent review details

Security

None.

PR surface

Source +43, Tests +245. Total +288 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 67 24 +43
Tests 2 246 1 +245
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 313 25 +288

Review metrics

Metric Value Why it matters
Production vs. test delta production +43, tests +245 The production growth is a named lifecycle owner for a previously one-shot recovery path; the larger test delta covers retry timing, shutdown, suspension, and multi-channel queue behavior.

Merge-risk options

Maintainer options:

  1. Complete exact-head delivery validation (recommended)
    Let the current Gateway, build, lint, and smoke checks finish on this head, then land only if the recurring drain still preserves the existing backoff and atomic-claim behavior.
  2. Pause for a fresh merged-base trace
    If maintainers want stronger operational assurance, pause and obtain a redacted after-fix queue trace on the current merge result before deciding.

Technical review

Best possible solution:

Keep one Gateway-owned recurring drain that delegates all retry eligibility, claims, authorization, and terminal handling to the existing durable queue, then merge only after an owner accepts the exact-head validation result.

Do we have a high-confidence way to reproduce the issue?

Yes—source provides a high-confidence reproduction shape: a row deferred by startup backoff, or a transient failure after an empty startup scan, has no later generic Gateway drain on current main. The PR’s focused lifecycle tests encode both cases, although this read-only review did not execute them.

Is this the best way to solve the issue?

Yes—the Gateway is the correct generic lifecycle owner because it already starts recovery and can schedule all channel rows without duplicating channel-specific polling. Changing startup recovery alone would not handle new post-start failures, while moving retry policy into the timer would duplicate the durable queue contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cad499d7ca06.

Labels

Label changes:

  • add P1: A transient outbound failure can leave a user message stranded indefinitely until Gateway restart across generic channel paths.
  • add merge-risk: 🚨 message-delivery: The new recurring Gateway drain changes when persisted delivery rows are retried across channels, so a regression could duplicate, prematurely retry, or suppress messages.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This PR carries the protected maintainer label, so the external-contributor proof gate does not apply; its body nevertheless describes after-fix real SQLite queue behavior across three channel types.

Label justifications:

  • P1: A transient outbound failure can leave a user message stranded indefinitely until Gateway restart across generic channel paths.
  • merge-risk: 🚨 message-delivery: The new recurring Gateway drain changes when persisted delivery rows are retried across channels, so a regression could duplicate, prematurely retry, or suppress messages.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This PR carries the protected maintainer label, so the external-contributor proof gate does not apply; its body nevertheless describes after-fix real SQLite queue behavior across three channel types.

Evidence

What I checked:

  • Current-main gap: Current main invokes outbound recovery once during scheduled-service activation; the recovery helper only runs recoverPendingDeliveries and returns no lifecycle stop handle, so there is no generic future drain for rows deferred by backoff or created after startup. (src/gateway/server-runtime-services.ts:181, cad499d7ca06)
  • PR owner-boundary repair: The proposed helper starts one unref interval at the canonical first-backoff cadence, performs startup migration/recovery once, drains thereafter with getRuntimeConfig(), prevents overlap, and returns a stop handle wired into the existing Gateway service shutdown path. (src/gateway/server-runtime-services.ts:185, a97754b8fa1b)
  • Queue contract: The existing generic drain rechecks retry eligibility, serializes claims through its coordinator, applies current admission rules, and only then drains a queued entry; the PR reuses that contract rather than adding a parallel retry path. (src/infra/outbound/delivery-queue-recovery.ts:1204, cad499d7ca06)
  • Lifecycle and sibling coverage: The PR adds Gateway timer tests for backoff-deferred and post-start failures, current-config use, overlap prevention, stop cleanup, and suspension; it also adds a real queue test spanning Discord, Slack, and Signal rows. (src/gateway/server-runtime-services.test.ts:425, a97754b8fa1b)
  • Feature-history provenance: The current startup-only recovery lines blame to Peter Steinberger’s current-main commit, and the proposed repair is a single commit by the same contributor; the shallow checkout does not expose older area history beyond that recent provenance. (src/gateway/server-runtime-services.ts:181, f6540b0a1f6c)

Likely related people:

  • steipete: Current-main blame attributes the startup-only recovery helper to Peter Steinberger’s recent Gateway services work, and the PR’s focused lifecycle repair is authored by the same contributor. (role: recent area contributor and proposed repair author; confidence: high; commits: f6540b0a1f6c, a97754b8fa1b; files: src/gateway/server-runtime-services.ts, src/gateway/server-runtime-services.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the in-progress exact-head checks, then refresh review if the merge result or head changes.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 25f174c into main Aug 3, 2026
134 of 140 checks passed
@steipete
steipete deleted the codex/qa0803-outbound-delivery-retry-lifecycle branch August 3, 2026 14:23
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
* origin/main:
  fix(onboard): keep referenced provider secrets out of plaintext (#118702)
  docs: show canonical agent roster configuration (#118722)
  fix(channels): generate catalog from package manifests (#118097)
  fix(zalouser): distinguish probe timeout from auth failure (#111336)
  improve(ui): cut E2E shard runtime by reusing the bundle (#118697)
  fix(cli): publish completion caches atomically (#118715)
  fix(whatsapp): honor disabled self-chat without widening group access (#118711)
  fix(voice-call): terminate carrier calls after realtime startup failures (#118699)
  fix(slack): isolate GovSlack media trust and delivery (#118695)
  fix(browser): wrap page-controlled action results (#118691)
  fix(security): sanitize JSON-escaped forged content boundaries (#118698)
  test(qa): prove real yielded-child completion and channel delivery (#118707)
  fix(doctor): honor explicit plugin-only migration authority (#118700)
  fix(security): detect child_process calls through aliases and computed members (#116304)
  test(gateway): avoid async facade mock race (#118708)
  fix(gateway): preserve final speech during transcription shutdown (#118693)
  fix(gateway): resume durable outbound delivery retries (#118694)
  fix(plugins): reject external public-artifact hardlinks (#118689)
vincentkoc added a commit that referenced this pull request Aug 3, 2026
* origin/main: (78 commits)
  fix(parallels): recover Windows poll transport failures (#118479)
  fix(channels): deny unauthorized Discord and Telegram binding access (#118704)
  fix(test): bound shared git inventory lookup (#111171)
  fix(onboard): keep referenced provider secrets out of plaintext (#118702)
  docs: show canonical agent roster configuration (#118722)
  fix(channels): generate catalog from package manifests (#118097)
  fix(zalouser): distinguish probe timeout from auth failure (#111336)
  improve(ui): cut E2E shard runtime by reusing the bundle (#118697)
  fix(cli): publish completion caches atomically (#118715)
  fix(whatsapp): honor disabled self-chat without widening group access (#118711)
  fix(voice-call): terminate carrier calls after realtime startup failures (#118699)
  fix(slack): isolate GovSlack media trust and delivery (#118695)
  fix(browser): wrap page-controlled action results (#118691)
  fix(security): sanitize JSON-escaped forged content boundaries (#118698)
  test(qa): prove real yielded-child completion and channel delivery (#118707)
  fix(doctor): honor explicit plugin-only migration authority (#118700)
  fix(security): detect child_process calls through aliases and computed members (#116304)
  test(gateway): avoid async facade mock race (#118708)
  fix(gateway): preserve final speech during transcription shutdown (#118693)
  fix(gateway): resume durable outbound delivery retries (#118694)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
* origin/main:
  fix(onboard): keep referenced provider secrets out of plaintext (openclaw#118702)
  docs: show canonical agent roster configuration (openclaw#118722)
  fix(channels): generate catalog from package manifests (openclaw#118097)
  fix(zalouser): distinguish probe timeout from auth failure (openclaw#111336)
  improve(ui): cut E2E shard runtime by reusing the bundle (openclaw#118697)
  fix(cli): publish completion caches atomically (openclaw#118715)
  fix(whatsapp): honor disabled self-chat without widening group access (openclaw#118711)
  fix(voice-call): terminate carrier calls after realtime startup failures (openclaw#118699)
  fix(slack): isolate GovSlack media trust and delivery (openclaw#118695)
  fix(browser): wrap page-controlled action results (openclaw#118691)
  fix(security): sanitize JSON-escaped forged content boundaries (openclaw#118698)
  test(qa): prove real yielded-child completion and channel delivery (openclaw#118707)
  fix(doctor): honor explicit plugin-only migration authority (openclaw#118700)
  fix(security): detect child_process calls through aliases and computed members (openclaw#116304)
  test(gateway): avoid async facade mock race (openclaw#118708)
  fix(gateway): preserve final speech during transcription shutdown (openclaw#118693)
  fix(gateway): resume durable outbound delivery retries (openclaw#118694)
  fix(plugins): reject external public-artifact hardlinks (openclaw#118689)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant