Skip to content

fix: preserve queued messages during failed preparation and reload - #193564

Merged
steipete merged 6 commits into
mainfrom
fix/drain-retry-floor
Nov 5, 2026
Merged

steipete merged 6 commits into
mainfrom
fix/drain-retry-floor

Conversation

@steipete

@steipete steipete commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Persistent failures before adoption can repeatedly abandon without reaching the retry policy's terminal decision; a probe saw 13 attempts over 20 minutes, but no routine trigger was established.
  • Refused replay can still display cosmetic channel error reactions, status or progress presentation.
  • Feishu's aggregate containing one pending refusal and one real failure can receive a no-attempt release; this path remains untraced.
  • The accepted Signal post-dispatch no-send failure can stall its FIFO lane until its live source adopts or abandons. Pending replay is now bounded by the same grace period above.

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 5b6c991afcebb024b6eccb59dd024f2a6f984c49 is 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 run processes and real Ollama qwen2.5:7b inference:

Gateway runtime Reload success Failed reload, 10 s debounce Permanent preparation error
Node 26.12.1 64.35 s 53.98 s 12 attempts / 3.002 s; 28.79 s wall
Pinned Bun 1.4.4 37.04 s 62.24 s 13 attempts / 3.001 s; 28.50 s wall

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-15 and checks-node-changed-compact-large-18 remain queued with no runner assigned. The required openclaw/ci-gate still reports Waiting for CI. The previous head’s green run is not current-head proof; hold landing until this gate passes.

@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L labels Nov 5, 2026
@steipete
steipete marked this pull request as ready for review November 5, 2026 15:38
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T18:41:55.090490Z 8dc73dc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: A replay can be completed as a duplicate without delivering B, or repeated preparation failures can starve Gateway requests.
  • After: B retains its pending receipt until adoption or consumption, preparation retries yield for 250 ms, and refused replays begin ordinary failure accounting after 30 minutes.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused ownership repair with credible reported Gateway results and distinct regression coverage; raw live artifacts were not independently inspected.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its public body reports exact-head isolated Gateway runs on Node and pinned Bun with real Ollama inference, synthetic Discord transport, ordered delivery, responsive probes, and clean shutdown, while the new expiry boundary has integration-test evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Accepted queued messages can disappear during recovery, and repeated preparation failures can leave the Gateway unresponsive.
Reason: The maintainer-authored direction restores recoverability and responsiveness while explicitly documenting delayed-source completion and retained failure behavior.

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
Reviewed head: 8dc73dca2be4d4c12de9098ac7f353e473ac7dbf

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The reported Gateway runs cover reload and preparation yielding; the 30-minute custody expiry is demonstrated by red/green policy and durable-dispatch tests rather than a shipped-entry-point expiry trace.
Agent review details

How this fits together

Channel 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
Loading

Technical review

Best 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

  • Inbound deduplication and abandonment keeps the original intent (d872690: Preserve safely abandoned messages while preventing stale cleanup from removing newer claims.)
  • Generic runner-error settlement changes intended behavior with a stated reason (36e277d: Only producer receipts permitted mailbox replay; generic runner failures were consumed.)
  • Plugin replacement wait keeps the original intent (668744f: Hold FIFO custody while replacement settles without starving reload progress or disposing unfinished work.)
  • Queue-owned recovery retry state keeps the original intent (765c2f1: Keep bounded recovery facts with the live queue and preserve durable error text and ordinary retry accounting.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +78, Tests +194, Docs +2, Other +4. Total +278 across 15 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 88 10 +78
Tests 8 634 440 +194
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 2 4 0 +4
Total 15 729 451 +278

Preflight source

Source 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

Metric Value Why it matters
Production versus regression code Production +88/-10; tests +634/-440 Production growth extends existing lifecycle and retry owners; regression coverage distinguishes pending replay, terminal accounting, adoption, cancellation, and reload outcomes.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The repaired paths can silently lose accepted queued messages or starve Gateway health, status, and shutdown work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster. Replaced prior rating: 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (5 earlier review cycles)
  • reviewed 2026-11-05T15:44:53.471Z sha 7b694f0 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-05T16:04:18.608Z sha 679180b :: needs maintainer review before merge. :: none
  • reviewed 2026-11-05T17:04:29.810Z sha 29691f4 :: needs changes before merge. :: [P2] Update the restart regression for pre-adoption abandonment
  • reviewed 2026-11-05T17:23:59.911Z sha ec9817a :: needs maintainer review before merge. :: none
  • reviewed 2026-11-05T17:48:07.701Z sha 7e2cf95 :: needs maintainer review before merge. :: none

Reviewed November 5, 2026, 1:44 PM ET / 18:44 UTC (Revision 6).

@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
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.
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 5, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Nov 5, 2026
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.
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
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.
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 5e4a575 into main Nov 5, 2026
148 of 151 checks passed
@steipete
steipete deleted the fix/drain-retry-floor branch November 5, 2026 19:49
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Nov 5, 2026
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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
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]>
wangmiao0668000666 pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Nov 6, 2026
…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.
wangmiao0668000666 pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Nov 6, 2026
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]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Nov 13, 2026
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]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Nov 13, 2026
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]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
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]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
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]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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