Repository navigation
fix: preserve queued messages during failed preparation and reload - #193564
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves queued-message custody through preparation failures and reloads while bounding pending replay backoff. Example: Discord message B waits behind RUNNER while its channel plugin reloads.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses queued-message loss and preparation hot loops still present on main; no concrete introduced defect was found, and current-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherChannel ingress claims durable messages and dispatches them into the session mailbox; lifecycle callbacks determine adoption, abandonment, deduplication, and durable retry settlement. flowchart TD
A[Channel ingress] --> B[Durable claim]
B --> C[Dispatch deduplication]
C --> D[Session mailbox]
D --> E[Preparation and execution]
E --> F[Custody lifecycle]
F --> G[Complete release or retain failure]
G --> B
Technical reviewBest possible solution: Retain this focused repair in the existing dispatch, mailbox custody, and ingress retry owners, then complete the required current-head checks. Do we have a high-confidence way to reproduce the issue? Current-main source retains the premature receipt completion and immediate preparation retry paths; the PR supplies matching Gateway observations and red/green regression results, but this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs receipt lifetime at dispatch, settlement at the existing custody owner, and backoff at the shared ingress policy without introducing another scheduler or persistent store. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a7c42ae41d3b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +78, Tests +194, Docs +2, Other +4. Total +278 across 15 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed November 5, 2026, 1:44 PM ET / 18:44 UTC (Revision 6). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Release pending dedupe refusals with bounded retry eligibility without spending failure attempts. Let the existing custody owner abandon lifecycle-backed inputs after a runner failure before adoption, preserving adopted and intentional consumption outcomes.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Use the existing preparation-failure receipt for single-input cases as well as grouped input. Preserve the watchdog-abort and dead-letter assertions; escaped generic runner failures have separate abandonment coverage.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Back off refused replays to the existing retry cap and resume ordinary attempt and age accounting after thirty minutes. Retain the pending start across counted retries so the lane cannot renew its free hold. Preserve the existing custody and execution fences.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
Closes #182246. Maintainer continuation of #182252, preserving the contributor commits. Thanks @emeric-dandelion-cult for the original repair. ## What Problem This Solves Messages intentionally discarded by the session queue's `old`/`new` cap policies could re-enter durable ingress, replay, and delay surviving messages. ## User Impact Policy-discarded messages receive a terminal queue-policy outcome without retry-failure notices or resend invitations. Surviving messages retain FIFO ordering. Protected-only capacity rejection remains retryable; surfaces without durable ingress keep visible queue-full feedback, and a refused `/followup` reports that it was not queued. Policy drops do not count as dead letters in health or Doctor. Retention bounds their replay guards separately from actual failures under the existing TTL. No config option, schema migration, dependency, or manual action is added. Old dropped content can still appear in Discord's independently recovered room history; it does not execute as a separate turn. ## Why This Change Was Made The existing queue, source-custody, and ingress owners carry a distinct dropped outcome through debounce and channel wrappers. The ingress monitor forwards it through its existing settlement wrapper. Failure reporting and bounded pruning remain with their existing owners. Feishu settles dropped session lanes independently, and summary eviction unbinds a source before awaiting its receipt. Reload and claim ownership come from merged main, including #193564. The monitor change only forwards `onDropped` through `settleLifecycle`; this PR adds no competing custody or fence mechanism. SDK docs describe forwarding and cleanup. Wrappers without durable terminal-drop custody retain their existing abandonment fallback. Redelivery while a drop callback's receipt is still pending receives the existing bounded pending refusal; this is accepted, and no eager commit or `onDropped` wrapper is added. ## Evidence Three dispatch/real-ingress/real-followup composition regressions cover old eviction, new rejection, and summarized eviction. Each verifies a terminal row with attempts 0 and its policy reason, then settled-source same-ID redelivery returns `skipped:duplicate`, makes no second resolver call, and sends no final reply. All three already passed on the merged head before this continuation; they protect composition with #193564 rather than establish a newly fixed post-settlement leak. Real local-model proof used an isolated Gateway through `pnpm openclaw`, synthetic Discord transport, real shared Ollama `qwen2.5:7b`, and the real queue, ingress ledger, model request and delivery path. These are macOS arm64 results, not live Discord-service or Linux/Windows proof. - Node 26.12.1 and pinned Bun 1.4.4 each passed reload plus old/new policy survival. Reload produced exactly RUNNER/B/C/D requests and replies in order; A ended `queue-cap-old` with attempts 0. Each surviving source completed with attempts 0. Each runtime logged one recovered unavailable-instance event; generation advanced 2 to 3, health/status answered, and no uncaught exception or unhandled rejection occurred. Old/new produced exactly RUNNER+B and RUNNER+A respectively, with the discarded source terminal at attempts 0 and no retry/resend notice. Combined command wall times: 114.03s Node, 69.73s Bun. - Both runtimes passed real Gateway non-durable overflow and refused `/followup`: each refusal produced exactly one neutral queue-full terminal outcome, while RUNNER and queued A each received a real model answer. Command wall times: 58.48s Node, 22.59s Bun. All eight scenarios passed; no input was lost, duplicated or left unanswered. All 22 retained runtime/launcher logs were scanned without an uncaught exception or unhandled rejection. `pnpm build` passed in 279.90s. The focused consumer set passed 895 tests across 37 files with one PostgreSQL-only capability skip in 508.51s. It covers queue/summary, ingress monitor/drain/claim ownership, channel wrappers, SDK fan-in/debounce, plugin replacement, Gateway outcomes, and prompt-prefix stability. All eight scoped production/test typechecks now pass; the first run caught a test-only lifecycle narrowing error. Scoped production/test/script lint and formatting pass after removing an unused import left by main integration. The corrected two-file Node rerun passed all 105 tests in 61.11s. The build, live runs and full consumer set preceded the final test-only type/import correction; production bytes are unchanged. No production wrapper or eager dedupe commit was added. All ten final-head baseline ratchets pass (53.79s), including assertion safety, line caps, timeout races, mock exports, test lines, database boundaries, configuration docs and plugin inventory. Current candidate: `7ddd944b651faf57bd935977235a69715768cb7c`. ClawSweeper completed its exact-head review at 2026-11-05 20:15 UTC with no findings, no security findings and no Before merge items. [Exact-head CI](https://github.com/openclaw/openclaw/actions/runs/42100431795) passed on attempt 2 at 2026-11-05 21:24 UTC. Attempt 1 failed only the Bun restart/resume test with `AgentDatabaseAdmissionError` during startup. The affected owner code is identical to main; ten full-file local runs passed on main and this head, and the separate restart/resume admission lane owns that race. Only the failed shard was rerun once. The maintainer lead accepted this evidence and authorized landing; the previously reported CI blocker is resolved. Local Codex branch autoreview from `54ed2bcc74b746085ddebe28ee59d268cd302fb6` to `7ddd944b651faf57bd935977235a69715768cb7c` through P2 is scoped-clean, with no accepted/actionable findings. The reviewer assessed source; runtime proof is reported separately. The earlier main comparison reproduced old/new discarded rows remaining claimed rather than reaching a terminal policy outcome, despite a real RUNNER answer; the candidate passed those invariants. That baseline reproduction is retained prior-lane evidence, not a new run here. Rename-aware delta against merged main `54ed2bcc74b746085ddebe28ee59d268cd302fb6`: production/scripts +527/-185 (net +342); tests/support +1362/-1196 (net +166); docs +40/-3 (net +37). This continuation adds 0 production lines and a net 108 test lines (109 composition lines minus one unused import). Production growth carries terminal outcomes through existing wrappers and separates bounded retention classes. A dedicated 166-line test allocation covers the 58 existing net regression lines after main integration plus this continuation’s net 108 test lines; the shared baseline is unchanged. The composition uses existing fixtures and no real timers or extra Gateway boot. Co-authored-by: Emeric Dandelion Cult <[email protected]>
…penclaw#193564) * fix: preserve queued messages while yielding failed preparation * test: advance fake clocks through preparation retries * fix: preserve pending ingress across custody refusals Release pending dedupe refusals with bounded retry eligibility without spending failure attempts. Let the existing custody owner abandon lifecycle-backed inputs after a runner failure before adoption, preserving adopted and intentional consumption outcomes. * test: expect abandonment before restart adoption * test: mark synthetic preparation retries Use the existing preparation-failure receipt for single-input cases as well as grouped input. Preserve the watchdog-abort and dead-letter assertions; escaped generic runner failures have separate abandonment coverage. * fix: bound pending ingress custody retries Back off refused replays to the existing retry cap and resume ordinary attempt and age accounting after thirty minutes. Retain the pending start across counted retries so the lane cannot renew its free hold. Preserve the existing custody and execution fences.
Closes openclaw#182246. Maintainer continuation of openclaw#182252, preserving the contributor commits. Thanks @emeric-dandelion-cult for the original repair. ## What Problem This Solves Messages intentionally discarded by the session queue's `old`/`new` cap policies could re-enter durable ingress, replay, and delay surviving messages. ## User Impact Policy-discarded messages receive a terminal queue-policy outcome without retry-failure notices or resend invitations. Surviving messages retain FIFO ordering. Protected-only capacity rejection remains retryable; surfaces without durable ingress keep visible queue-full feedback, and a refused `/followup` reports that it was not queued. Policy drops do not count as dead letters in health or Doctor. Retention bounds their replay guards separately from actual failures under the existing TTL. No config option, schema migration, dependency, or manual action is added. Old dropped content can still appear in Discord's independently recovered room history; it does not execute as a separate turn. ## Why This Change Was Made The existing queue, source-custody, and ingress owners carry a distinct dropped outcome through debounce and channel wrappers. The ingress monitor forwards it through its existing settlement wrapper. Failure reporting and bounded pruning remain with their existing owners. Feishu settles dropped session lanes independently, and summary eviction unbinds a source before awaiting its receipt. Reload and claim ownership come from merged main, including openclaw#193564. The monitor change only forwards `onDropped` through `settleLifecycle`; this PR adds no competing custody or fence mechanism. SDK docs describe forwarding and cleanup. Wrappers without durable terminal-drop custody retain their existing abandonment fallback. Redelivery while a drop callback's receipt is still pending receives the existing bounded pending refusal; this is accepted, and no eager commit or `onDropped` wrapper is added. ## Evidence Three dispatch/real-ingress/real-followup composition regressions cover old eviction, new rejection, and summarized eviction. Each verifies a terminal row with attempts 0 and its policy reason, then settled-source same-ID redelivery returns `skipped:duplicate`, makes no second resolver call, and sends no final reply. All three already passed on the merged head before this continuation; they protect composition with openclaw#193564 rather than establish a newly fixed post-settlement leak. Real local-model proof used an isolated Gateway through `pnpm openclaw`, synthetic Discord transport, real shared Ollama `qwen2.5:7b`, and the real queue, ingress ledger, model request and delivery path. These are macOS arm64 results, not live Discord-service or Linux/Windows proof. - Node 26.12.1 and pinned Bun 1.4.4 each passed reload plus old/new policy survival. Reload produced exactly RUNNER/B/C/D requests and replies in order; A ended `queue-cap-old` with attempts 0. Each surviving source completed with attempts 0. Each runtime logged one recovered unavailable-instance event; generation advanced 2 to 3, health/status answered, and no uncaught exception or unhandled rejection occurred. Old/new produced exactly RUNNER+B and RUNNER+A respectively, with the discarded source terminal at attempts 0 and no retry/resend notice. Combined command wall times: 114.03s Node, 69.73s Bun. - Both runtimes passed real Gateway non-durable overflow and refused `/followup`: each refusal produced exactly one neutral queue-full terminal outcome, while RUNNER and queued A each received a real model answer. Command wall times: 58.48s Node, 22.59s Bun. All eight scenarios passed; no input was lost, duplicated or left unanswered. All 22 retained runtime/launcher logs were scanned without an uncaught exception or unhandled rejection. `pnpm build` passed in 279.90s. The focused consumer set passed 895 tests across 37 files with one PostgreSQL-only capability skip in 508.51s. It covers queue/summary, ingress monitor/drain/claim ownership, channel wrappers, SDK fan-in/debounce, plugin replacement, Gateway outcomes, and prompt-prefix stability. All eight scoped production/test typechecks now pass; the first run caught a test-only lifecycle narrowing error. Scoped production/test/script lint and formatting pass after removing an unused import left by main integration. The corrected two-file Node rerun passed all 105 tests in 61.11s. The build, live runs and full consumer set preceded the final test-only type/import correction; production bytes are unchanged. No production wrapper or eager dedupe commit was added. All ten final-head baseline ratchets pass (53.79s), including assertion safety, line caps, timeout races, mock exports, test lines, database boundaries, configuration docs and plugin inventory. Current candidate: `7ddd944b651faf57bd935977235a69715768cb7c`. ClawSweeper completed its exact-head review at 2026-11-05 20:15 UTC with no findings, no security findings and no Before merge items. [Exact-head CI](https://github.com/openclaw/openclaw/actions/runs/42100431795) passed on attempt 2 at 2026-11-05 21:24 UTC. Attempt 1 failed only the Bun restart/resume test with `AgentDatabaseAdmissionError` during startup. The affected owner code is identical to main; ten full-file local runs passed on main and this head, and the separate restart/resume admission lane owns that race. Only the failed shard was rerun once. The maintainer lead accepted this evidence and authorized landing; the previously reported CI blocker is resolved. Local Codex branch autoreview from `bd8cac762efe00978ab5174974ff0f7bc146db2e` to `7ddd944b651faf57bd935977235a69715768cb7c` through P2 is scoped-clean, with no accepted/actionable findings. The reviewer assessed source; runtime proof is reported separately. The earlier main comparison reproduced old/new discarded rows remaining claimed rather than reaching a terminal policy outcome, despite a real RUNNER answer; the candidate passed those invariants. That baseline reproduction is retained prior-lane evidence, not a new run here. Rename-aware delta against merged main `bd8cac762efe00978ab5174974ff0f7bc146db2e`: production/scripts +527/-185 (net +342); tests/support +1362/-1196 (net +166); docs +40/-3 (net +37). This continuation adds 0 production lines and a net 108 test lines (109 composition lines minus one unused import). Production growth carries terminal outcomes through existing wrappers and separates bounded retention classes. A dedicated 166-line test allocation covers the 58 existing net regression lines after main integration plus this continuation’s net 108 test lines; the shared baseline is unchanged. The composition uses existing fixtures and no real timers or extra Gateway boot. Co-authored-by: Emeric Dandelion Cult <[email protected]>
…penclaw#193564) * fix: preserve queued messages while yielding failed preparation * test: advance fake clocks through preparation retries * fix: preserve pending ingress across custody refusals Release pending dedupe refusals with bounded retry eligibility without spending failure attempts. Let the existing custody owner abandon lifecycle-backed inputs after a runner failure before adoption, preserving adopted and intentional consumption outcomes. * test: expect abandonment before restart adoption * test: mark synthetic preparation retries Use the existing preparation-failure receipt for single-input cases as well as grouped input. Preserve the watchdog-abort and dead-letter assertions; escaped generic runner failures have separate abandonment coverage. * fix: bound pending ingress custody retries Back off refused replays to the existing retry cap and resume ordinary attempt and age accounting after thirty minutes. Retain the pending start across counted retries so the lane cannot renew its free hold. Preserve the existing custody and execution fences.
Closes openclaw#182246. Maintainer continuation of openclaw#182252, preserving the contributor commits. Thanks @emeric-dandelion-cult for the original repair. ## What Problem This Solves Messages intentionally discarded by the session queue's `old`/`new` cap policies could re-enter durable ingress, replay, and delay surviving messages. ## User Impact Policy-discarded messages receive a terminal queue-policy outcome without retry-failure notices or resend invitations. Surviving messages retain FIFO ordering. Protected-only capacity rejection remains retryable; surfaces without durable ingress keep visible queue-full feedback, and a refused `/followup` reports that it was not queued. Policy drops do not count as dead letters in health or Doctor. Retention bounds their replay guards separately from actual failures under the existing TTL. No config option, schema migration, dependency, or manual action is added. Old dropped content can still appear in Discord's independently recovered room history; it does not execute as a separate turn. ## Why This Change Was Made The existing queue, source-custody, and ingress owners carry a distinct dropped outcome through debounce and channel wrappers. The ingress monitor forwards it through its existing settlement wrapper. Failure reporting and bounded pruning remain with their existing owners. Feishu settles dropped session lanes independently, and summary eviction unbinds a source before awaiting its receipt. Reload and claim ownership come from merged main, including openclaw#193564. The monitor change only forwards `onDropped` through `settleLifecycle`; this PR adds no competing custody or fence mechanism. SDK docs describe forwarding and cleanup. Wrappers without durable terminal-drop custody retain their existing abandonment fallback. Redelivery while a drop callback's receipt is still pending receives the existing bounded pending refusal; this is accepted, and no eager commit or `onDropped` wrapper is added. ## Evidence Three dispatch/real-ingress/real-followup composition regressions cover old eviction, new rejection, and summarized eviction. Each verifies a terminal row with attempts 0 and its policy reason, then settled-source same-ID redelivery returns `skipped:duplicate`, makes no second resolver call, and sends no final reply. All three already passed on the merged head before this continuation; they protect composition with openclaw#193564 rather than establish a newly fixed post-settlement leak. Real local-model proof used an isolated Gateway through `pnpm openclaw`, synthetic Discord transport, real shared Ollama `qwen2.5:7b`, and the real queue, ingress ledger, model request and delivery path. These are macOS arm64 results, not live Discord-service or Linux/Windows proof. - Node 26.12.1 and pinned Bun 1.4.4 each passed reload plus old/new policy survival. Reload produced exactly RUNNER/B/C/D requests and replies in order; A ended `queue-cap-old` with attempts 0. Each surviving source completed with attempts 0. Each runtime logged one recovered unavailable-instance event; generation advanced 2 to 3, health/status answered, and no uncaught exception or unhandled rejection occurred. Old/new produced exactly RUNNER+B and RUNNER+A respectively, with the discarded source terminal at attempts 0 and no retry/resend notice. Combined command wall times: 114.03s Node, 69.73s Bun. - Both runtimes passed real Gateway non-durable overflow and refused `/followup`: each refusal produced exactly one neutral queue-full terminal outcome, while RUNNER and queued A each received a real model answer. Command wall times: 58.48s Node, 22.59s Bun. All eight scenarios passed; no input was lost, duplicated or left unanswered. All 22 retained runtime/launcher logs were scanned without an uncaught exception or unhandled rejection. `pnpm build` passed in 279.90s. The focused consumer set passed 895 tests across 37 files with one PostgreSQL-only capability skip in 508.51s. It covers queue/summary, ingress monitor/drain/claim ownership, channel wrappers, SDK fan-in/debounce, plugin replacement, Gateway outcomes, and prompt-prefix stability. All eight scoped production/test typechecks now pass; the first run caught a test-only lifecycle narrowing error. Scoped production/test/script lint and formatting pass after removing an unused import left by main integration. The corrected two-file Node rerun passed all 105 tests in 61.11s. The build, live runs and full consumer set preceded the final test-only type/import correction; production bytes are unchanged. No production wrapper or eager dedupe commit was added. All ten final-head baseline ratchets pass (53.79s), including assertion safety, line caps, timeout races, mock exports, test lines, database boundaries, configuration docs and plugin inventory. Current candidate: `7ddd944b651faf57bd935977235a69715768cb7c`. ClawSweeper completed its exact-head review at 2026-11-05 20:15 UTC with no findings, no security findings and no Before merge items. [Exact-head CI](https://github.com/openclaw/openclaw/actions/runs/42100431795) passed on attempt 2 at 2026-11-05 21:24 UTC. Attempt 1 failed only the Bun restart/resume test with `AgentDatabaseAdmissionError` during startup. The affected owner code is identical to main; ten full-file local runs passed on main and this head, and the separate restart/resume admission lane owns that race. Only the failed shard was rerun once. The maintainer lead accepted this evidence and authorized landing; the previously reported CI blocker is resolved. Local Codex branch autoreview from `54ed2bcc74b746085ddebe28ee59d268cd302fb6` to `7ddd944b651faf57bd935977235a69715768cb7c` through P2 is scoped-clean, with no accepted/actionable findings. The reviewer assessed source; runtime proof is reported separately. The earlier main comparison reproduced old/new discarded rows remaining claimed rather than reaching a terminal policy outcome, despite a real RUNNER answer; the candidate passed those invariants. That baseline reproduction is retained prior-lane evidence, not a new run here. Rename-aware delta against merged main `54ed2bcc74b746085ddebe28ee59d268cd302fb6`: production/scripts +527/-185 (net +342); tests/support +1362/-1196 (net +166); docs +40/-3 (net +37). This continuation adds 0 production lines and a net 108 test lines (109 composition lines minus one unused import). Production growth carries terminal outcomes through existing wrappers and separates bounded retention classes. A dedicated 166-line test allocation covers the 58 existing net regression lines after main integration plus this continuation’s net 108 test lines; the shared baseline is unchanged. The composition uses existing fixtures and no real timers or extra Gateway boot. Co-authored-by: Emeric Dandelion Cult <[email protected]>
The j14 rewrite of the ingress custody suite (openclaw#193564) carried the merge base's attempts: 1 for a queue clear before dispatch returns. The fleet openclaw#124337 graft settles that clear as cancellation by design: a committed abortSessionControllerInput notifies onCancelled, and the ingress drain releases the claim with recordAttempt: false. The fleet suite already asserts attempts: 0 for the identical scenario (abandon-before-commit), so the two cases contradicted each other on one production line. Adopt the fleet expectation in the j14 case and grant the nine added test lines in the #1564 allocation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upstream openclaw#193564 rewrote the two-case "dispatch retry after queued ingress abandonment" suite in place (watchdog-after-commit and abandon-before-commit became watchdog-after-deferral and abandon-before-dispatch-return). The fleet forward merge 7c4e1d7 kept the old block beside the rewrite because fleet's openclaw#124337 hunk sat inside it, leaving two describes with the same title. With fleet's queue-clear expectation ported onto the rewritten case, the old block asserts nothing the rewrite does not, so the file matches j14 plus that one adaptation. Return the 161 removed lines from the #1564 allocation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Backport 668744f (#193501), a required dependency of approved #193564. Preserve FIFO claim and live source checks while replacement settles; abandon unavailable owners. Co-authored-by: RomneyDa <[email protected]>
Backport d16f545 (#190804), a necessary dependency of approved #193564. Reclaiming a stale owner does not spend delivery attempts or alter the last real attempt time. Keep row equality, claim token, cutoff and corruption checks unchanged. Co-authored-by: RomneyDa <[email protected]>
Backport 5e4a575 (#193564). Keep exclusive queued dedupe custody until adoption or explicit consumption, bound pending-custody retries, and abandon unadopted runner failures. Retain no-replay-after-execution and exact adoption refusal semantics. Adapt existing consumer clocks for the source retry yield rather than import unrelated fixture refactoring. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes queued messages disappearing during channel recovery, Gateway hot loops when preparation repeatedly fails, and pending replay refusals holding an ingress lane indefinitely without failure accounting.
Related: #193501.
User Impact
Queued input remains recoverable until adoption or intentional consumption. Preparation retries yield to health, status, cancellation and reload work while preserving FIFO and existing authority checks. A replay waiting for its original source now backs off and has a bounded grace period before ordinary retry accounting resumes.
A source still alive after that grace period can finish later even if its replay row has reached the dead letter. The failed row remains visible and retained; expiry does not cancel the original source or relax its authority checks.
Why This Change Was Made
The dispatch owner retains exclusive queued input's deduplication receipt until adoption or intentional consumption; abandonment releases that exact receipt. Pre-execution retries yield for 250 ms, and restart releases replacement waits without weakening consumer or channel-stop fences. An escaped runner error before adoption abandons lifecycle-backed input through the existing custody owner. Adopted failures and sources without a lifecycle retain their behavior.
Pending-custody refusals share the existing in-memory ingress retry entry. Their delay doubles from one second up to the channel policy's existing
maxMs, without spending attempts for the first 30 minutes. That budget exceeds the five-minute stall timeout and normal queue waits. Afterward, ordinary attempts, non-retryable classification, age floor, dead-letter retention and pressure accounting apply. The original pending timestamp survives counted retries, so the grace period cannot restart on each refusal. Process restart clears this state along with the live claim; no persistent state or configuration is added. Runtime-recovery failure counting is preserved.Deferred follow-ups from independent review:
Production versus the PR merge base: +88/-10 lines (net +78); tests +634/-440 (net +194); docs +3/-1. This final repair adds 16 net production lines for two fields in the existing retry entry and the bounded backoff, plus 98 net regression-test lines with their own allocation record. The shared test ceiling is unchanged. No schema, dependency, prompt or public SDK change.
Evidence
Final candidate:
8dc73dca2be4d4c12de9098ac7f353e473ac7dbf.On
7e2cf957, all four new policy cases fail: backoff remains at one second and attempts stay zero past 30 minutes (17 controls pass; 32.77 s wall). Both new dispatch cases independently fail at the unchanged zero-attempt row (10 controls pass; 16.50 s wall).On the final candidate, all five focused suites pass: retry policy 21, dispatch/ACP 12, queue generation 20, queue restart 26, steering 13; 92 total, 56.81 s wall. Fake-time regressions prove doubling and both policy caps, ordinary accounting at the 30-minute boundary, zero-floor dead-letter retention and notice, and continued default retries until the 24-hour age floor. The existing in-budget source-release case still delivers exactly once without spending refused-replay attempts. Terminal coverage now runs through actual dispatch, deduplication and the durable ingress writer, alongside the preparation-only steering fixtures.
Scoped lint and core/messaging/infra types pass. All ten baseline ratchets pass (64.08 s wall), including line cap, assertion safety, timeout races, mock exports, test lines, database checks, config docs and plugin inventory. Isolated branch autoreview against merge base
5b6c991afcebb024b6eccb59dd024f2a6f984c49is scoped-clean through P2, with ingress drain/writer and custody-owner source context supplied; execution proof is separate.Full build passes (250.03 s wall, including artifact preparation; build phase 164.7 s). All six live cases pass on this exact head, reusing the same harness through real isolated
pnpm openclaw --profile fix-drain-floor gateway runprocesses and real Ollamaqwen2.5:7binference:Each reload delivers RUNNER/B/C/D in order, exactly once, with all four ingress rows completed, zero attempts, no failed reason/error and no notice. Every case has zero health/status probe failures and a clean shutdown without forced termination. Maximum health/status latency: 440.77 / 795.89 ms. This is macOS proof using synthetic Discord transport and real local-model inference; no real Discord/Signal-service, upgrade or cross-platform claim. Raw evidence remains in the maintainer's durable lane report.
The earlier pass observed 2,424 permanent-error dispatch attempts in 4.057 seconds, health/status timeouts and forced shutdown on its baseline; its reload baseline also reproduced silent replay completion. That is prior-pass evidence, not a new run on current main. Current main was inspected and does not contain this pending-refusal delta.
ClawSweeper reviewed exact head
8dc73dca2be4d4c12de9098ac7f353e473ac7dbf: Findings None; Before merge None; ready for maintainer review. Proof limitation: the 30-minute expiry is covered by fake-time policy and durable-dispatch regressions, not a shipped-entry-point 30-minute trace; raw live captures remain with the maintainer report.Current-head CI run 42086303021 remains pending: 77 jobs completed with no failures, while
checks-node-changed-compact-small-5,checks-node-changed-compact-small-15andchecks-node-changed-compact-large-18remain queued with no runner assigned. The requiredopenclaw/ci-gatestill reports Waiting for CI. The previous head’s green run is not current-head proof; hold landing until this gate passes.