Skip to content

fix: stop replaying messages discarded by queue caps - #193313

Merged
steipete merged 26 commits into
mainfrom
fix/182252-durable-ingress
Nov 5, 2026
Merged

steipete merged 26 commits into
mainfrom
fix/182252-durable-ingress

Conversation

@steipete

@steipete steipete commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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

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

@steipete
steipete marked this pull request as ready for review November 5, 2026 08:21
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: feishu Channel integration: feishu channel: sms Channel integration: sms labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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-05T20:12:03.000607Z 7ddd944 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 added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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 added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 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 merged commit 9435188 into main Nov 5, 2026
269 of 274 checks passed
@steipete
steipete deleted the fix/182252-durable-ingress branch November 5, 2026 21:32
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…openclaw#193423)

* fix(channels): preserve ingress custody across plugin reloads

Keep queue and maintenance work under monitor-owned plugin custody through
quiescence. Gate new delivery callbacks until resume, wake the existing
monitor after a failed reload, and preserve caller authority for permitted
late admissions and settlements.

Retire failed drains without exposing completed side effects to replay:
retain unresolved terminal claim identities in memory while allowing
never-adopted peer claims to recover. Stop reports failed writes and still
finishes disposal. Durable schemas and restart recovery remain unchanged.

This is the lifecycle prerequisite for openclaw#193313; queue policy and notice
changes remain with that draft.

* fix(channels): close ingress reload lifecycle gaps

Honor retained starts during quiescence, retire aborted monitors through their
joined stop path, retain failed dead-letter claims, and clear rejected pumps
for later wakes. Forward Discord account aborts to its ingress monitor.

Preserve claim-token fences, failed-completion protection, and the existing
split between admitted queue maintenance and fresh delivery authority.

* test(channels): simplify failed terminal write fixture
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
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]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
* fix: preserve user requests during ambient queue overflow

* fix: settle discarded ambient input without delivery scopes

* fix: keep ambient chatter from evicting user requests

OpenClaw-Publication: 4ccedf5d-d860-4b15-85e9-251f70601797

* fix: preserve bounded ambient context during queue overflow

* Publish openclaw/fast-shell

OpenClaw-Publication: 933231df-b944-4a6d-9e8d-becfd2191d99

---------

Co-authored-by: RomneyDa <[email protected]>

Source: 69d6eae

Release adaptation: Selected queue-only production and regressions applied cleanly atop baseline source custody. Required requests displace ambient only, previews bounded to same route and approved text, attach once. Terminal discard uses existing lifecycle adoption without executable backlog. Excluded QA transport/docs/allocation. Later openclaw#193313 broader ingress policy-drop work not imported; baseline unbound payload/custody retained. Formatting/diff checks pass; runtime unavailable due established setup blocker.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 88dc9f72f0e34b12944e155d90d5c884b7f2bbb7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: slack Channel integration: slack channel: sms Channel integration: sms channel: telegram Channel integration: telegram clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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.

[Bug]: Queue cap drops replay durable ingress until retries exhaust

1 participant