Skip to content

fix(ingress): bound pre-adoption abandonment with the existing retry budget - #124337

Closed
karmafeast wants to merge 40 commits into
openclaw:mainfrom
karmaterminal:codeagent/ward-1255-m1-intervention
Closed

karmafeast wants to merge 40 commits into
openclaw:mainfrom
karmaterminal:codeagent/ward-1255-m1-intervention

Conversation

@karmafeast

@karmafeast karmafeast commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An ingress row can defer its turn to the reply queue and then end without ever being admitted. When that happens, the row is released with lastError: "turn-abandoned" and an attempt recorded, but the retry policy is never consulted. Such a row can therefore retry forever:

  • attempts climbs past maxAttempts;
  • the row never dead-letters;
  • it holds the head of its lane, so the messages behind it never run.

Sending abandonment through the shared retry disposition takes a single hunk, but that is only safe once intentional cancellation stops arriving as abandonment. On main, the reply queue settles every unadmitted turn through onAbandoned:

  • TurnAdoptionLifecycle has no onCancelled;
  • the ingress binding omits it;
  • the inbound debounce flush drops it.

Bounding abandonment on its own would therefore charge these as failures: queue clears, Stop cleanup, drops of aborted followups, collect-group aborts and gateway shutdown. That was the P1 on the earlier head of this PR.

This PR lands both halves:

  • fix(reply) makes onCancelled part of the reply terminal contract:
    • every intentional relinquish site uses it;
    • both dedupe owners release on either terminal callback;
    • fan-in always offers onCancelled.
  • fix(ingress) settles onAbandoned through applyFailureDisposition. It records one attempt, respects maxAttempts and deadLetterMinAgeMs, and dead-letters as retry-limit-exceeded.

There is no AsyncLocalStorage compatibility flag. Every lifecycle that reaches a fan-in carries onCancelled, so the consumer makes the flag unnecessary.

Since Revision 21 → back-merge (head e3b5d3625cb)

Change: a merge of upstream main 12b56e6492c, which was 797 commits ahead, into 9fd80c6cdbd (merge 3607dc4366c), then two small follow-ups. The history is kept: a merge commit, then a fast-forward. Nothing was rebased.

Conflicts, both test-only. The full diff-filter=U list and the marker grep agreed.

  • extensions/feishu/src/monitor.comment.test.ts: upstream folded the serialize and queued-claim-abort cases into one it.each. That it.each is kept, and this PR's budget-free cancellation case ("cancels a queued durable comment after its claim aborts without spending retry budget") follows it unchanged.
  • extensions/sms/src/inbound.test.ts: upstream folded the deferred, adopted and failure MMS cases into one it.each. That it.each is kept, and this PR's two cases follow it unchanged: cancellation cleanup ("cleans deferred MMS files before forwarding cancellation") and the cleanup-failure settlement it.each (onCancelled / onAbandoned).

Follow-ups on top of the merge:

  • bb5da2e7098 (test): upstream removed the Slack createReceiverEventWithBody / createChannelIdChangedEnvelope helpers. This PR's routed-cancellation case now builds the same channel_id_changed envelope through upstream's createReceiverEvent(id, ack, { event }). The assertions are unchanged.
  • e3b5d3625cb (refactor): upstream grew src/channels/message/ingress-drain.ts to exactly the 700-line cap. The settleOnce wrapper in settleUnadopted is folded onto one line, and the behaviour is unchanged.

Every source change merged cleanly, and this PR's per-file source deltas are the same size against the new base as against the old one. Abandonment still settles through applyFailureDisposition (one attempt, bounded by maxAttempts). Cancellation still reopens the claim with recordAttempt: false, so attempts and last_error are preserved.

Gate at exact head e3b5d3625cb (Linux x86-64, Node 26.12.1; the tree was clean at the start and at the end):

  • tsgo:core, tsgo:extensions, tsgo:core:test and tsgo:extensions:test exit 0.
  • Vitest: 67 files and 871 tests pass. The set is the changed tests, plus same-directory tests importing a changed module, plus the two conflict files.
  • The Telegram cancellation e2e passes 1/1.
  • oxlint and oxfmt --check (on the 47 changed .ts files) and check-line-cap-ratchet --base 12b56e6492c are clean.
  • pnpm run check passes except its default line-cap run. That run compares against the fork's origin/main, not upstream, and flags 8 files this PR does not touch.

Receipts: https://github.com/karmaterminal/karmaterminal-openclaw-docs/tree/6922cbf6e219e0d5fb4820dd1bb9869cb3c2ae4e/PR-124337/PROOFS/e3b5d3625cb02a09c73e81b4f11b3c33cda194e3/GATE

Proofs below (shipped-Gateway Discord and Telegram) ran at 9fd80c6cdbd. The merge brings in upstream changes under the paths they exercise (src/channels/message, src/auto-reply/reply/queue, extensions/discord, extensions/telegram, src/plugins/interactive.ts). This PR's own deltas are unchanged, but those proofs have not been re-run at e3b5d3625cb.

Since Revision 20 → Revision 21 (head 9fd80c6cdbd)

Change: a merge of upstream main 93a9fa4562b, which was 631 commits ahead, into cd8a6e26fe. It had no conflicts (diff-filter=U and a marker grep were both empty), and nothing in this PR's own diff changed. The history is kept: a merge commit, then a fast-forward. Nothing was rebased.

Gate at exact head 9fd80c6cdbd (Linux x86-64, Node 26.12.1):

  • tsgo:core, tsgo:extensions and tsgo:test:src exit 0.
  • Vitest: 67 files and 884 tests pass. The set is this PR's changed tests plus every test that imports a changed module from the same directory.
  • The Telegram cancellation e2e (telegram-ingress-coalescing.cancellation.e2e) passes 1/1.
  • oxlint, oxfmt --check and check-line-cap-ratchet --base 93a9fa4562b are clean.
  • The tree was clean at the start and at the end.

New: the shipped-Gateway proof that the last review asked for. It is the ## Evidence section below. The earlier boundary-harness evidence stays, under "Earlier evidence".

Evidence

Behavior or issue addressed: an ingress row that defers to the reply queue and is then released without being admitted. Two halves:

  • Intentional relinquish (Stop / queue clear, Gateway shutdown) must release the row without spending retry budget.
  • Genuine abandonment (for example a queue-cap rejection) must go through the shared retry disposition, so maxAttempts bounds it.

Before evidence: shipped Gateway at upstream main 93a9fa4562b, same harness and steps as the after-fix runs (3/3 runs per scenario):

  • After /stop, the queued row that Stop relinquished has spent one attempt (attempts=1).
  • After a clean Gateway shutdown, the queued row is pending attempts=1 last_error=turn-abandoned. A shutdown is charged as a failed attempt.
  • A queue-cap rejection releases the row with attempts+1 and last_error=turn-abandoned, and logs no retry-disposition line.

Real environment tested: the shipped Gateway (node scripts/run-node.mjs gateway) on Linux x86-64 with Node 26.12.1, from a clean worktree at the head and one at the base. Everything else was loopback-only:

  • Channel: the production Discord plugin, reaching a loopback mock of Discord REST plus WebSocket Gateway through the production DISCORD_API_URL override. The mock was adapted from the fix(discord): keep stale ambient backlog from starving live mentions after gateway recovery #121204 proof corpus.
  • Agent: the bundled Codex 0.162.1 app-server as agent runtime (agentRuntime.id: "codex"), pointed at a scripted Responses endpoint.
  • Isolation: its own state directory, config and ports. No real Discord, model provider, credential or host Gateway was involved.
  • Message flow: messages enter as MESSAGE_CREATE frames and pass through the production listener, ingress monitor, SQLite ingress queue, drain, reply queue and agent turn. Replies leave as REST sends, recorded by the mock with their text.
  • Busy turn: a HOLD-1 message keeps one turn busy through repeated sleep tool calls, so later messages queue behind it.

Config:

  • messages.queue: followup, cap: 1, drop: old | new; one run used collect, cap: 2, drop: old in a guild channel.
  • messages.inbound.debounceMs: 0.
  • Discord DM allowlist plus one open guild.
  • Discord's production ingress policy: maxAttempts: 8, deadLetterMinAgeMs: 0.

Exact steps or command run after this patch:

  • Head: 9fd80c6cdbd, which is this PR's cd8a6e26fe with upstream main 93a9fa4562b merged in. The merge was clean; tsgo:core, tsgo:extensions and tsgo:test:src all exit 0.
  • Each run (scenario.sh <scenario> <side> <n> <tree>):
    1. starts the mock, the scripted provider and the Gateway;
    2. sends HOLD-1;
    3. sends one or more MSG-* while the turn is busy;
    4. does the scenario action (below);
    5. snapshots channel_ingress_events from a copy of the state database (status, attempts, last_error, failed_reason).
  • Scenario actions:
    • cancel: /stop while MSG-A is queued.
    • restart: SIGTERM the Gateway while MSG-A is queued, then start it again on the same state.
    • abandon: drop:new with the one slot held by MSG-A, then MSG-B. Variants: drop:old, and a 12-message guild burst under collect.

Evidence after fix:

Scenario (runs) Head 9fd80c6cdbd Base main 93a9fa4562b
Stop clears the queued MSG-A (3 + 3) completed attempts=0, 3/3 completed attempts=1, 3/3
Shutdown with MSG-A queued (3 + 3) pending attempts=0, no last_error, 3/3 pending attempts=1 last_error=turn-abandoned, 3/3
Restart redelivery of that row (3 + 3) delivered once, one ack MSG-A, completed attempts=0, 3/3 delivered once, one ack MSG-A, completed attempts=1, 3/3
First queue-cap rejection (5 + 3) [discord] ingress: spooled update msg#04 failed; keeping for retry: turn-abandoned, then attempts=1 silent release, attempts=1 last_error=turn-abandoned
Guild burst, collect cap 2 (1 + 1) 5 keeping for retry: turn-abandoned lines, all 14 rows completed, every message answered 0 such lines, all 14 rows completed, every message answered

Observed result after fix:

  • Stop and Gateway shutdown now release the row without spending an attempt, and the restart still redelivers it exactly once.
  • A genuine queue-cap abandonment is now settled through the retry disposition, bounded by maxAttempts.

Additional real-environment observation (production seat, fork build; not this exact head). This was observed on a long-running production Gateway, not run by the harness above.

  • Setup: real Discord, a real native-Codex agent, and real room traffic. No production state was changed to collect this.
  • Build: the fork build 7d8a1a91c6. It contains this PR at an earlier revision, 51631e61a2, merged as 3d05df8b5f5 (verified with git merge-base --is-ancestor).
  • Same settlement: its onCancelled / onAbandoned settlement in src/channels/message/ingress-drain.ts is semantically the same as this head 9fd80c6cdbd, differing only in formatting: releaseClaim(…, { recordAttempt: false }) and applyFailureDisposition(…, new Error("turn-abandoned")). The surrounding files differ by later upstream merges. This is therefore evidence about the settlement path, not a receipt for this SHA.

What happened: on 2026-10-24 a burst of room messages overflowed the seat's reply-queue cap (drop: "old"). The queue-cap drop then re-dispatched ingress, which is a separate defect (#182252). That produced quick, repeated pre-adoption abandonment, the shape the loopback harness above could not reproduce.

Gateway journal, one process lifetime from 20:07:31Z to about 22:03Z (redacted):

  • 1,006 events: [discord] ingress: spooled update <id> failed; keeping for retry: turn-abandoned.
  • 0 handler-timeout lines observed in that window. This means none was observed in that window; it is not a claim that the watchdog can never take this path.
  • 254 lines of the shapes spooled update <id> failed with non-retryable retry-limit-exceeded: turn-abandoned; dead-lettered and spooled update <id> on lane channel:<id> reached retry limit after 8 attempts; dead-lettered (maxAttempts: 8).

State DB, read from a consistent copy at about 22:03Z, counting rows (not events) received from 19:30Z on that lane:

  • 119 rows ended failed / retry-limit-exceeded;
  • 121 rows completed after the first dead-letter at 20:09:41Z, so the lane kept making progress.

What this supports: abandonment retries were bounded at maxAttempts, and later messages on the same lane went on to complete.

What this does not prove: that each abandoned attempt settled correctly, or that this PR alone caused the recovery.

Telegram interactive-submission cancellation (shipped Gateway, exact head 9fd80c6cdbd, base control 93a9fa4562b)

Setup:

  • Channel: the production Telegram plugin, using long polling and the durable spool. It reaches a loopback Bot API mock through channels.telegram.apiRoot.
  • Handler: one local plugin's Telegram interactive handler that returns { submitText }, the path this PR changed in bot-handlers.callback-router-controls.ts.
  • Agent: Codex 0.162.1 against a scripted Responses endpoint.
  • Isolation: a netless namespace (lo only), env -i, a fake bot token and synthetic ids.
  • Steps: a HOLD-1 turn keeps the session busy. The user presses an inline button (cbq-1), and the handler's submission is queued behind the busy turn (ingress row claimed attempts=0, not yet at the model). Then the owner cancels it before adoption. 3 runs per scenario per side:
Head Base main
Gateway shutdown with the submission queued: row pending attempts=0, no last_error pending attempts=1 last_error=turn-abandoned
Buttons after that shutdown retained (no editMessageReplyMarkup) retained
Restart redelivery the same cbq-1 handler runs again; MSG-SUBMIT reaches the model and is answered once; the button is then cleared; row completed attempts=0 answered once; row completed attempts=1
/stop with the submission queued: row completed attempts=0 completed attempts=1
Buttons after /stop retained; a re-press (cbq-2) is answered once, then the button is cleared cleared by the replayed callback; the submission is never answered and no button is left to press

So a cancelled Telegram submission keeps its retry facts and its buttons, and the shipped spool redelivers it after restart. Stop does not resubmit the stopped text by itself; the user re-presses, as with Discord Stop. After Stop the replayed cbq-1 is absorbed by the plugin interactive dedupe, so the handler does not run twice. That is inferred from source (src/plugins/interactive.ts) and the invocation counts.

Not covered: real Telegram, webhook mode, and a real model.

Receipts: https://github.com/karmaterminal/karmaterminal-openclaw-docs/tree/31fb7e642c8f8a74fd06972671443d736819312d/PR-124337/PROOFS/9fd80c6cdbd8d67ea6b27ac1b1bf19471eef225f/GATEWAY-TELEGRAM (EVIDENCE.md, harness/, 12 sanitized runs with raw Gateway logs). Each run records HEAD and clean status at start and end.

Redaction: no message, channel or session IDs; no host name, content or credentials; no raw journal or DB attachment.

What was not tested:

  • Dead-letter through abandonment. In every Discord shape above, the redelivered row waits behind the busy turn on its channel. After the first abandonment, each further attempt is therefore settled by the 300 s claim→adoption watchdog (handler-timeout), and that path applies the retry policy on head and base alike.
    • A 42-minute run on each side ended identically: spooled update msg#04 on lane channel:<dm-channel> reached retry limit after 8 attempts; dead-lettered within 0.3 s of each other, then MSG-C was answered.
    • So the base defect (abandonment re-dispatching past maxAttempts) was not reached in this harness. The proof shows the disposition change, not a lane that main leaves blocked.
    • The production observation above shows the bounded path and lane progress on a fork build that carries this settlement. It is not a base-side contrast: every observed seat already carried the fix.
  • Telegram against the real Bot API, webhook mode, and a real model (the interactive-submission cancellation above ran against a loopback Bot API mock).
  • Other channels (Slack, SMS, LINE, Twitch, Feishu) and native Discord commands.
  • A real model and real Discord.

Redacted receipts (21 runs, the harness, the gate): https://github.com/karmaterminal/karmaterminal-openclaw-docs/tree/fe333eff401c78b165b06e7ad77af99bcc654baf/PR-124337/PROOFS/9fd80c6cdbd8d67ea6b27ac1b1bf19471eef225f/GATEWAY-DISCORD. Each run has meta.txt, rows.txt, mock Discord and provider JSONL, and Gateway logs. They use synthetic snowflakes only, with the home path and host name removed.

Since Revision 20 (head cd8a6e26fe)

Change cd8a6e26fe (test only): drops the helper-only "pre-retry release ahead of both terminal callbacks" case from queue/lifecycle.test.ts, as the review at 8da32c408e suggested. The wrapped-rejection cases keep the release-before-callback coverage.

Upgrade / data-model compatibility. Corpus: UPGRADE-v2026.10.6.

  • Seeding: the latest stable release, v2026.10.6, writes seven ingress rows into a fresh state: pending, released with 2 attempts and a last error, abandoned under the limit, over the limit (6 attempts, limit 3), a cancel case, dead-lettered, and a dead-owner claim.
  • Migration: upstream's openclaw doctor --fix migrates the state schema from 20 to 31. This PR changes nothing in src/state.
  • Drain: this head drains the migrated state. As controls, stable drains an unmigrated copy and upstream 7ab64536d3 drains a migrated copy, all with the same retry policy.
  • What carries over: the retry facts stable wrote. The head reads attempts and the last error as stored and counts attempts on from there, without resetting them. A later successful completion clears last_error, exactly as it does upstream.
  • Cancellation and settled rows: the cancelled row spends no attempt, the dead-lettered row is never dispatched, and the dead-owner claim is recovered as stale.
  • The one difference from both controls is the over-limit row. At this head it is dispatched once, then dead-lettered as retry-limit-exceeded with its attempts and last error kept. Both controls keep re-dispatching it (still pending at 18 attempts after 12 passes). That is the defect this PR fixes.
  • Schema: the ingress table schema and index are identical across stable, this head and upstream.

Checks at cd8a6e26fe: queue/lifecycle.test.ts 17/17, oxfmt and oxlint clean. Everything else is as at Revision 19 (8da32c408e); the only difference is this one test file.

Still open: shipped-Gateway / real-transport cancellation, restart and abandonment, and the Telegram Test Server interactive-submission case.

Since Revision 19 (head 8da32c408e)

This revision brings the branch up to upstream main 7ab64536d3 (2026-10-23). History is kept: merges and fast-forwards only.

Back-merge 8da32c408e (merge of 7ab64536d3):

Test added: 3fbec00bb7. When onCancelled starts a Feishu flush's settlement and onAbandoned and onAdopted overlap it, the transport settles once through onCancelled (no retry budget). The logical claim is released once, and nothing adopts or commits. As a mutation control, setting settled after the await makes it fail on the intended assertion.

Checks at 8da32c408e (Linux x86_64, Node 26.12.1):

  • tsgo:core, tsgo:extensions, tsgo:core:test and tsgo:extensions:test are clean. oxfmt and oxlint are clean on the PR's changed files.
  • One grouped run of 619 test files: 30 tests in 3 files failed. Run alone 3 times a side, each matches upstream main 7ab64536d3:
    • dispatch-from-config.delivery: 27 fail on both sides, with identical test names ("Physical session already has a different controller owner").
    • dispatch-from-config.lifecycle: 1 fails on both sides, the same test as at Revision 18.
    • progress-narrator-model: passes 4/4 on both sides, a grouped-load flake.
  • db:worker-inventory:check is stale at upstream main itself. A regen changes rows only for files this PR doesn't touch.
  • The Telegram cancellation e2e passed.

Since Revision 18 (head 2407313ae0)

This revision brings the branch up to upstream main 827aae9c0b (2026-10-22). It adds one fix that upstream needs as well. History is kept: these are merges and fast-forwards only, no rebase.

Back-merges.

  • e7ef059e18, 15499d136a and 1add83f4a1 merge upstream 9c87c4e826, 646647245f and 79ab1c4907.
  • 3cd32643c6 merges upstream main 827aae9c0b.

Upstream rebuilt the follow-up queue on the session controller (#175837), so 1add83f4a1 re-applies this PR's cancellation onto upstream's shapes rather than merging textually:

  • queue/lifecycle.ts adds releaseBeforeTurnAdoptionRetry, cancelFollowupRunLifecycle and a "cancelled" disposition.
  • session-controller.mailbox-source.ts routes a cancelled disposition, or an aborted lifecycle signal, to onCancelled. A committed abortSessionControllerInput counts as cancellation.
  • Queue clear, Stop cleanup and restart-cleared waiting inputs settle as cancelled.
  • The adapters (Feishu, LINE, MS Teams, Telegram, Twitch, inbound debounce) carry onCancelled through upstream's shared bindings.

Fix, 493d5bf21f: release unadopted sources when a drained run returns. This bug exists on upstream main as well.

  • Upstream's executeClaim marks every source of a run that returns normally as consumed. A source that was never adopted is included, and consumed suppresses its terminal callbacks.
  • Its durable ingress claim is then held until the adoption-stall watchdog fails it as handler-timeout (5 min). That charges an attempt even to a source whose owner aborted.
  • Reproduced at 79ab1c4907: both claims stay held, then are dead-lettered under a one-attempt policy.
  • Now a normal return completes an unadopted source without the consumed disposition. An aborted owner cancels (no attempt); a live one abandons (one attempt). Adopted sources stay consumed. Throws keep upstream's no-replay rule unless the producer refused before execution.
  • The collect-group cancellation test is restored on upstream's fixtures.

Tests added.

  • c7f27a7410 drives bindSessionControllerMailboxRestartDrain through the durable boundary. A waiting ingress claim is released on gateway restart with no attempt charged: onCancelled fires once, onAbandoned never fires, and nothing is dead-lettered.
  • 2407313ae0 follows upstream's narrowed test seams (refactor: narrow private plugin adapter inputs #180003): the Slack duplicate-wait test stubs the replay guard by module mock, and the Twitch test-message helper takes the id as a string.

Not carried 1:1 (the reviewers' rulings are in the thread):

  1. containSettlement is dropped. Upstream now awaits async onAbandoned/onCancelled and records a rejection as that input's settlement failure.
  2. A run whose own abort signal fired and that completes unconsumed counts as cancellation (completeFollowupRunLifecycle).
  3. Twitch shutdown/handedOff: upstream's adapter no longer has this handling, and upstream's choice is kept.

Checks at 2407313ae0 (Linux x86_64, Node 26.12.1):

  • tsgo:core, tsgo:extensions, tsgo:core:test and tsgo:extensions:test are clean.
  • db:worker-inventory:check is current. oxfmt and oxlint are clean on the PR's changed .ts files.
  • One grouped run of 619 test files: this PR's suites plus everything under src/auto-reply/reply, src/sessions and src/channels/message, and the adapter suites the merges touched. 3 tests in 2 files failed, and both match upstream main 827aae9c0b when run alone (3 runs per side):
    • dispatch-from-config.lifecycle › "audits an aborted prepared-runtime wait as a skipped reply operation" fails 3/3 alone on both sides with the same test.
    • progress-narrator-model passes alone in 3 of 3 runs on both sides (4/4 tests each); its two grouped reds are a load flake.
    • The run started at the merge 3cd32643c6. The two test-seam files were committed mid-run as 2407313ae0; they pass alone at this head, 10/10 and 1/1.
  • The Telegram cancellation e2e: passed (1/1).
  • Three fork reviewers re-reviewed 493d5bf21f at that exact head and found no blockers.

Still open:

  • The boundary harness has not been rerun at this head. The last proof corpus is at ee2f6dfdf6 (Revision 17).
  • ClawSweeper's request for shipped-Gateway / real-transport cancellation and restart evidence, and for Telegram Test Server proof, is still outstanding.

Since Revision 17 (head ee2f6dfdf651a8bd4416edb435335c5393190c5e)

This revision addresses ClawSweeper's review of e682f7cc17 (fast-forward; no rebase):

  • 7cab4e61eb, [P1] cancel LINE's unhanded delivery when shutdown returns ownership. In extensions/line/src/webhook-spool.ts, the stop branch for a delivery that returned without onAdopted or onDeferred now ends ownership through fannedIn.cancel() instead of fannedIn.abandon(). A row at the retry ceiling is no longer dead-lettered as retry-limit-exceeded on stop. The new test "keeps an aged row at the retry ceiling recoverable when shutdown ends an unhanded delivery" covers the active-delivery-return case. It passes (16/16) and fails with only this fix reverted (15/16).

  • 2b67393ddd, 5c214fa2a4, cd45f79821, [P3] await owned settlement signals instead of polling. Every vi.waitFor this PR added, across 10 test files, is gone. The tests now await one of three signals:

    • the queue's committed write, through observeChannelIngressQueueWrite, or the new observeChannelIngressQueueWrites, which wraps each queue method once so several observers can't stack;
    • the drain's own claimNext commit;
    • deferreds that the owned turns resolve.

    These commits are test-only.

  • ee2f6dfdf6: two lint fixes in the Slack tests (a bound claimNext, an unused import).

Checks at ee2f6dfdf6 (Linux arm64):

  • tsgo:core, tsgo:extensions, tsgo:core:test and tsgo:extensions:test: clean.
  • 35/35 focused test files pass.
  • pnpm check fails only in its lint step. None of the reported files is in this PR's diff against 042db1e706; the remaining errors (max-lines, ui) are in files this PR doesn't touch.
  • The Telegram cancellation e2e passed 3 of 3 repeated runs.

Proof. The boundary harness was rerun at this exact head with the same bytes, against control 042db1e706. Every verdict and final SQLite row matches the 0cb65da5f2 corpus. The corpus is at https://github.com/karmaterminal/karmaterminal-openclaw-docs/tree/615595b9fcc318c8c6d45d4a4f0db2ad9069a7a9/PR-124337/PROOFS/ee2f6dfdf651a8bd4416edb435335c5393190c5e

Still open: ClawSweeper's request for shipped-Gateway / real-transport cancellation and restart evidence, plus Telegram Test Server proof for cancelled interactive submissions. That needs a Telegram test bot and account, and is not covered by the harness above.

Since Revision 16 (head e682f7cc17fdbc34f299b6703e11aa23d90c120c)

Revision 16 had no findings; the branch had since gone conflicting with main. This head merges upstream main 042db1e706 into 51631e61a23 (merge 8853b1ae51c; no rebase) and adds two test-only commits. Upstream had refactored the follow-up queue and Feishu settlement, so the cancellation half is re-applied onto upstream's shapes rather than merged textually:

  • completeFollowupRuns forwards an optional disposition; stop, clear and aborted collect/summary sources settle as cancelled through it.

  • consumeQueueSummaryDelivery keeps its settlement argument; upstream's boolean false calls are "retained".

  • dropAbortedFollowups stays in aborted-followups.ts (re-exported from drain.ts) and settles through completeFollowupRuns(…, "cancelled").

  • Feishu broadcast: a cancelled lane state on upstream's pending/deferred/completed/failed model. Feishu flush and delivery, Slack and Telegram regain onCancelled; Telegram's abort-reason mapping now lives in abortedProcessingResult.

  • c6cfd25c543: the ingress-cancellation test follows upstream's dispatch fixture move to dispatch-from-config.test-support.ts. 0cb65da5f22: the Slack cancellation test's mocks spread the real modules (first-party mock export ratchet).

  • e682f7cc17f: oxfmt only. It folds one if condition in bot-handlers.callback-router-controls.ts onto one line, so behaviour is byte-equivalent to 0cb65da5f2, where the checks and proof below ran.

Checks at 0cb65da5f2 (Linux arm64): tsgo:core, tsgo:extensions, tsgo:core:test, tsgo:extensions:test clean; 35/35 focused test files (this PR's suites plus the queue, drain, Feishu, Slack and Telegram suites the merge touched). pnpm check fails three ratchets (line-cap growth, max-lines suppression, assertion SAFETY comment) that fail identically on main 042db1e706 and name no file in this PR. The boundary proof below was rerun at 0cb65da5f2. CI note: src/plugin-sdk/channel-inbound.test.ts › "dispatches a published inbound event before automatic session maintenance" fails on main b3c7dc2af7 itself (3 of 3 local runs), but passes at this branch's tree (042db1e706 base). It touches nothing in this PR.

Since Revision 14 (head 51631e61a238de75ae0207af541b341e6edeac0e)

The branch is rebased onto main 2983dfcfb3 and merges cleanly into main f986a7aaf1. The two original commits change only in rebase-conflict hunks: upstream's new readLaneBacklog stays drain-only, the vitest path list keeps both entries, and Telegram uses upstream's participant heartbeat. On top of them:

commit addresses change
4dd7877d56a [P1] carry cancellation through custom channel lifecycle adapters Telegram, Twitch, and Feishu's merged and broadcast lifecycles forward onCancelled. Feishu's pre-flush cleanup runs on cancellation too.
06cd20afc87 [P1] preserve Slack replay and migration cleanup on cancellation Both Slack owners wrap cancellation: releaseClaims() and settleTurn() run, then cancellation is forwarded budget-free.
6ff545fd490 [P2] clean up deferred MMS attachments on cancellation The MMS lifecycle has its own cancellation wrapper that cleans up before forwarding.
784a1f1f437 same class LINE ends shutdown-rejected ownership by cancellation, not abandonment, because the core types define shutdown as cancellation.
5f713b6bd7d same class Feishu message and comment paths whose abort already fired cancel instead of abandoning. Real dispatch failures still abandon.
3cd7de6f3d4 found in review SMS: a rejected MMS unlink no longer skips settlement. Cleanup failure is logged, and the owner settles once, for both cancel and abandon.
d1c4823226e found in review Core completeFollowupRunLifecycle contains a rejected async onCancelled or onAbandoned (logged via the runtime error log). The callback still starts synchronously, and onSettled still runs right after it.
bcbc2837f4e found in review Telegram albums: cancelling a coalesced turn settled every participant as failed-retryable, which dead-lettered non-head members at the ceiling. A { kind: "cancelled" } result now routes to each member's own onCancelled, and the update tracker treats cancelled like retryable (not completed), so dedupe cannot swallow the redelivery.
53cb34f058 found in review The dedupe wrapper releaseBeforeTurnAdoptionRetry now returns onAbandoned's result, so core can contain its rejection on the wrapped path.
cb1cd8a1d0f Revision 15 [P3] mock isolation The two new Telegram dispatch mocks spread the real module (importOriginal) and override only buildTelegramMessageContext and dispatchTelegramMessage.
4a6c265fa80 Revision 15 [P3] drain.ts line cap dropAbortedFollowups moved verbatim into the sibling module queue/aborted-followups.ts; only the parameter type changed, to a named subset alias. drain.ts re-exports it, so existing drain.js module mocks still catch the call. The baseline is unchanged.
51631e61a23 Revision 15 [P3] e2e line cap telegram-ingress-coalescing.e2e.test.ts is restored to its upstream content. The aged-album cancellation regression moved unchanged into telegram-ingress-coalescing.cancellation.e2e.test.ts, which uses the shared fixtures; the bundled-plugin e2e glob includes it.

New tests. Each new test failed before its fix and passes after it.

  • The aged-row tests seed a row at 7/8 attempts with lastError "prior failure". They cancel the deferred turn, then assert that nothing is dead-lettered and that the row returns with attempts and error intact. These run on the real durable SQLite queue for Telegram (single update and a two-member album), Twitch, Feishu (merged turn and handler-entry abort) and LINE (late deferral at shutdown).
  • Slack migration fence: a cancelled deferred turn lets a queued channel_id_changed run. Before the fix, stop() waited on it indefinitely.
  • Rejection tests run the failing callback directly and behind the dedupe wrapper. They assert the order release → callback → onSettled, that there is no unhandled rejection, and that the error is logged. They check the error text, not a count of log calls.

Known boundary

  • Reply-queue cap evictions still settle as genuine abandonment, which is one bounded attempt. That is intended.
  • IRC forwards onCancelled, but it does not update its local handoff state on cancellation. That would only matter for a cancellation before onDeferred, which the reply lane does not send.
  • Channels that call onAbandoned on real dispatch failures (Mattermost, MS Teams, Signal) are unchanged. Those failures are charged attempts, as intended.

Earlier evidence (boundary harness, head 0cb65da5f2)

Real behavior (central fix). I ran a production-module boundary harness at this exact head 0cb65da5f2283965905abe1c55aca505e8139550, with main 042db1e7064930a08c534c4487864d7bfb8c5287 (the merge's second parent) as the control. The chain is the channel ingress monitor → the durable SQLite ingress queue → the drain → the bound reply/followup queue. There is no vitest and nothing in the chain under test is mocked. Each scenario ends with a projection of the SQLite row. Every verdict matches the earlier run at b2d5e48e5b.

scenario this PR main (control)
queued message, then gateway stop (restart-drain clears the followup queue) budget-free: attempts=0, no lastError charged: attempts=1, lastError=turn-abandoned
restart in a fresh process redelivered, adopted, completed redelivered, completed
genuine pre-adoption abandonment (reply queue at cap), maxAttempts=3 dead-lettered retry-limit-exceeded / turn-abandoned on the 3rd delivery, and the next row in the lane completes not dead-lettered at attempts=6 (2× the limit) when observation stopped, and the lane stayed blocked

Failing control (unit). At the earlier head, with the production files reverted to main and the tests kept at head, 11 assertions across 6 files fail. They pass at head.

Tests (focused, Linux): at bcbc2837f4e, 335/335 across 30 files. The set covers the adapter suites above, telegram-ingress-coalescing.e2e, the reply lifecycle, the ingress drain and lifecycle, and the ingress-cancellation dispatch suite. The final commit 53cb34f058 changes only lifecycle.ts and its test, which were re-run at that head: lifecycle 14/14, cancellation 4/4.

Revision 15 policy checks at 51631e61a23:

  • pnpm check:line-cap-ratchet --base 2983dfcfb3: OK.
  • pnpm check:test-mock-exports --base 2983dfcfb3: OK.
  • lifecycle + ingress-cancellation: 18/18 (--maxWorkers=1, 15 s).
  • telegram-ingress-drain + coalescing e2e: 57/57 (--maxWorkers=1, 70 s).
  • the new cancellation e2e suite on its own: 1/1. Vitest itself took 35 s; the first run's plugin-SDK rebuild is the rest of the wall time.
  • queue suites and the gateway tests that mock drain.js: 247/247.
  • check:import-cycles: 0.
  • tsgo:core, tsgo:core:test, tsgo:extensions and tsgo:extensions:test: clean.

Typecheck: tsgo:extensions and tsgo:extensions:test are clean at bcbc2837f4e. tsgo:core and tsgo:core:test are clean at 53cb34f058. oxfmt is clean.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: feishu Channel integration: feishu labels Aug 16, 2026
@karmafeast
karmafeast marked this pull request as ready for review August 16, 2026 01:49
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR bounds pre-adoption abandonment through the existing retry policy and carries budget-free cancellation through reply queues and channel adapters.

Example: A deferred ingress row repeatedly abandons before adoption with maxAttempts=3 and deadLetterMinAgeMs=0.

  • Before: The row remains pending beyond three attempts and can block later messages in its lane.
  • After: The third abandonment dead-letters the row as retry-limit-exceeded, allowing the next message to run.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful shared-owner repair with sufficient production-path evidence and no introduced findings; terminal lane-progress observations come from a disclosed fork build rather than an exact-head controlled transport contrast.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Shipped-Gateway Discord and Telegram runs at 9fd80c6 exercise production transport clients against loopback servers and show budget-free cancellation, restart redelivery, and retained interactive buttons. Production fork observations support bounded abandonment and lane progress, with their different build and absent base contrast disclosed. Exact-head integration receipts cover the subsequent merge resolution; the prepared images are unrelated continuation diagrams and were not counted as behavioral proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Messages can repeatedly retry before agent adoption and delay later messages, while intentional queue cleanup can incorrectly spend retry budget.
Reason: The change restores the documented shared retry invariant and preserves cancellation semantics without adding configuration or a new persistence format.

Merge readiness

✅ Ready for maintainer review

Keep this PR: it fixes a remaining retry-budget defect on current main, preserves intentional cancellation, and has no actionable introduced findings. The previous merge conflict is resolved; exact-head CI remains pending.

Priority: P1
Reviewed head: e3b5d3625cb02a09c73e81b4f11b3c33cda194e3

Before merge

None.

Findings

None.

Agent review details

How this fits together

Channel plugins persist incoming events in durable ingress queues; the shared drain transfers them to reply queues and settles each claim through adoption, cancellation, or retry disposition.

flowchart TD
  A[Channel event] --> B[Durable ingress queue]
  B --> C[Shared ingress drain]
  C --> D[Reply queue and channel adapters]
  D --> E[Terminal lifecycle callback]
  E --> F[Existing retry policy]
  F --> B
  E --> B
Loading

Technical review

Best possible solution:

Use the existing ingress retry policy for genuine abandonment and the existing cancellation settlement for intentional relinquishment.

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

Current-main source shows abandonment bypassing retry disposition, and supplied controlled durable-queue runs demonstrate attempts exceeding the limit; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch repairs the shared settlement owner and propagates the existing cancellation contract through affected consumers, avoiding a second retry policy or compatibility mode.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 231f108dd068.

Provenance checked

  • Abandonment retry accounting keeps the original intent (4151625: Restore genuine pre-adoption failure accounting and backoff while retaining budget-free cancellation.)
  • Aggregate cancellation availability changes intended behavior with a stated reason (fix(discord): unblock ingress after retry exhaustion #122878: Expose aggregate cancellation only when every constituent supports it, preserving legacy settlement fallback.)
  • Reply-source completion changes intended behavior with a stated reason (36e277d: Give session-controller custody one owner for queued source execution and asynchronous settlement.)
  • Channel replay and attachment cleanup keeps the original intent (fix(feishu): wait for accepted replay work during shutdown #150094: Retain accepted replay work through shutdown settlement; channel adapters remain responsible for their logical claims and cleanup.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 433b3ce adds src/channels/message/ingress-drain.ts:520 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 433b3ce86d71; files: src/channels/message/ingress-drain.ts)
  • joshavant: Raw commit 06600e2 adds src/channels/message/ingress-drain.ts:550 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 06600e2ca09f; files: src/channels/message/ingress-drain.ts)
  • Ayaan Zaidi: Raw commit fc6b9da adds src/channels/message/ingress-drain.ts:556 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: fc6b9dad0b13; files: src/channels/message/ingress-drain.ts)

PR surface

Source +244, Tests +1998. Total +2242 across 48 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 28 335 91 +244
Tests 20 2014 16 +1998
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 48 2349 107 +2242

Review metrics

Metric Value Why it matters
Production versus tests and support Production +331/-90; tests and support +2018/-17 Growth covers distinct cancellation, restart, dedupe, attachment-cleanup, migration-fence, and coalesced-participant failures while retaining the existing settlement owners.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Repeated pre-adoption abandonment can keep a channel lane occupied beyond its configured retry budget and delay subsequent messages.
  • merge-risk: 🚨 compatibility: The narrow repair changes shared Plugin SDK lifecycle behavior by forwarding cancellation and always exposing aggregate cancellation; optional legacy callbacks retain their abandonment fallback.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (26 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-12T01:02:02.935Z sha e682f7c :: needs real behavior proof before merge. :: [P1] Cancel LINE's unhanded delivery when shutdown returns ownership | [P3] Await owned settlement signals instead of polling claim state
  • reviewed 2026-10-13T15:53:16.117Z sha ee2f6df :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T16:08:59.459Z sha ee2f6df :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-23T17:43:22.372Z sha 8da32c4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-23T20:46:41.808Z sha cd8a6e2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-24T17:51:21.984Z sha 9fd80c6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-24T22:26:32.118Z sha 9fd80c6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-25T04:04:09.882Z sha 9fd80c6 :: needs changes before merge. :: none

Reviewed October 25, 2026, 2:38 PM ET / 18:38 UTC (Revision 27).

karmafeast pushed a commit to karmaterminal/karmaterminal-openclaw-docs that referenced this pull request Aug 16, 2026
Document that staged 07 is a condensed shard summary and that
only the pre-retarget MS Teams FAIL exists as a raw log.
Classify the known validate-corpus manifest-schema red
(320/319/1 docs harness).

Refs openclaw/openclaw#124337

Co-authored-by: Copilot <[email protected]>
@karmafeast

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

P1 addressed on 70d47be.

Mixed fan-in cancel still calls onCancelled when present and falls back to onAbandoned for a legacy source. That fallback now runs under cancel-compat so it stays budget-free. bindIngressLifecycleToReplyOptions forwards onCancelled. Genuine onAbandoned still terminalizes. Fossil assertions are unchanged. Product PR no longer carries lane receipts.

Unit causal closure only. No live/fleet/treatment-composite claim.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

karmafeast pushed a commit to karmaterminal/karmaterminal-openclaw-docs that referenced this pull request Aug 16, 2026
Replace obsolete 0a77fdcf sidecar with fresh exact-head receipts
for mixed capable+legacy fan-in cancel, genuine abandon budget,
MS Teams aged sibling, and production-only reverse/reapply.

Does not edit PROOFS/INDEX.json. Isolated Gateway smoke pending
on pure continuation assembly tip + 70d47bec.

Refs openclaw/openclaw#124337

Co-authored-by: Copilot <[email protected]>
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 20, 2026
Safe-branch merge of frozen upstream 923e972 onto PR head 70d47be.
Owner suites and Gate 2/2.5/2.7 are recorded. Full-suite tally is still
running on 8a7c7a4. Composite live proof is specified, not executed.

Refs openclaw#124337
Refs #1255

Co-authored-by: Copilot <[email protected]>
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 20, 2026
Owner ingress suites stayed green. Full test-projects.mts on merge head
8a7c7a4 failed after shared node_modules collapsed; 143 assertion
files, none on the PR surface. Composite live proof remains specified
not executed.

Refs openclaw#124337
Refs #1255

Co-authored-by: Copilot <[email protected]>
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 20, 2026
Preserve cancellation-vs-abandonment behavior while making the outcome and legacy fan-in paths explicit.\n\nRefs openclaw#124337\n\nCo-authored-by: Copilot <[email protected]>
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 20, 2026
Make the exact-head drift diff pass its whitespace gate.\n\nRefs openclaw#124337\n\nCo-authored-by: Copilot <[email protected]>
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 20, 2026
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 22, 2026
… and budget-free cancel

Replays the treatment-only openclaw#124337 head
4ff99f7 onto the composite.

Genuine pre-adoption onAbandoned previously released the claim without
entering the retry disposition owner, so an unadoptable lane head could retry
forever and hold its FIFO lane. releaseUnadopted becomes settleUnadopted with
a closed cancelled | abandoned outcome: cancellation releases budget-free and
preserves attempts, last-attempt time, and last error; genuine abandonment
takes the same bounded disposition onFailed uses. Mixed capable/legacy fan-in
cancel is scoped with AsyncLocalStorage so a source predating onCancelled is
still treated as cancellation rather than reclassified as abandonment.

Composite interaction audit for the both-sides file
src/channels/message/ingress-drain.ts:

- the base already routes the claim-to-adoption stall watchdog through
  applyFailureDisposition; this change routes genuine abandonment through the
  same function, so there is exactly one disposition owner and one retry
  budget rather than two parallel ones;
- the watchdog and settleUnadopted both settle through the same per-state
  settleOnce owner, so a stalled-then-abandoned claim cannot be charged twice;
- applyFailureDisposition still releases GatewayDrainingError budget-free
  ahead of the bounded path, so the continuation's restart-drain behavior is
  unchanged by the new abandonment routing;
- openclaw#121204's pending-disposition and lane-state hunks in drainOnce and the
  continuation's gateway root work-admission retention around
  dispatchClaimedEvent are preserved verbatim and are disjoint from these
  hunks.

ingress-drain.test.ts's abandonment case is retargeted rather than weakened:
it previously asserted the row stayed pending past maxAttempts, which is the
defect. It now asserts per-pass attempt accounting and terminal
retry-limit-exceeded with the producer's turn-abandoned message preserved.

This remains treatment-composite input, not independently accepted live
behavior.

Provenance (openclaw#124337 authored commits): 401dc7a a01d78a f991826
0a77fdc b900d1d

Co-authored-by: Copilot <[email protected]>
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 22, 2026
Evidence artifacts from the treatment-only openclaw#124337 head, carried so the
composite's openclaw#124337 provenance stays auditable without reopening that lane.

Provenance (openclaw#124337 authored commits): 5e7e090 0b79a2c 02bc3fb
4ff99f7

Co-authored-by: Copilot <[email protected]>
karmafeast pushed a commit to karmaterminal/openclaw that referenced this pull request Aug 22, 2026
…e drain

Composite consequence, not cosmetics. The base's stall-watchdog reroute,
openclaw#121204's pending-disposition block, and openclaw#124337's settleUnadopted all landed
in src/channels/message/ingress-drain.ts, pushing it to 703 counted lines and
reding eslint(max-lines) at 700. Suppressions are forbidden, so the file is
split along the boundary the composite itself exposed.

ingress-drain-claim-settlement.ts now owns every terminal write for a held
claim — tombstone, release, dead-letter — plus the single
applyFailureDisposition decision. That is exactly the invariant this composite
had to protect: the stall watchdog, genuine pre-adoption abandonment, and
dispatch failure must share one retry budget, and openclaw#124337's defect was a call
site that bypassed it. Making the owner a module makes bypassing it a visible
import rather than a local edit.

failClaim is intentionally not exported: only applyFailureDisposition needs
it, so the module surface stays the four operations the drain actually calls,
minus that one. commitClaimWriteWithRetry's redundant double return is
collapsed and the duplicated displayId computation is hoisted; the fenced
false/throw semantics, retry bound, log strings, and abortable backoff are
unchanged.

Net production LOC is negative: ingress-drain.ts drops 825 to 699 lines while
the new module is 186, and no behavior moved.

Co-authored-by: Copilot <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 23, 2026
@karmafeast

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The head is now 9fd80c6cdbd. It is a merge of upstream main 93a9fa4562b into cd8a6e26fe, with no conflicts, and it was gated at that exact SHA: 67 files / 884 tests, plus the Telegram cancellation e2e, oxlint, oxfmt and line-cap.

The body's ## Evidence now has the shipped-Gateway proof you asked for. The production Discord plugin talks to a loopback mock Discord through DISCORD_API_URL, the agent is native Codex 0.162.1 against a scripted provider, and each run has isolated state. Head and base each ran 3 times:

  • Stop releases the row budget-free.
  • Gateway shutdown releases it budget-free.
  • Restart redelivers it exactly once.
  • A genuine queue-cap rejection is settled through the retry disposition.

What was not tested is stated plainly:

  • Dead-letter through abandonment. The 300 s adoption watchdog applies the retry policy on base as well, so in this harness main never blocked the lane.
  • Telegram interactive submission.

The receipts are linked in the body.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@karmafeast

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The head is unchanged at 9fd80c6cdbd. ## Evidence gains one section: Additional real-environment observation (production seat, fork build; not this exact head). It addresses the open item about bounded abandonment freeing a lane.

  • A production Gateway (real Discord and a real native-Codex agent) runs a fork build carrying this PR's settlement at 51631e61a2, which is semantically the same as this head.
  • That Gateway logged 1,006 turn-abandoned retry events with 0 handler-timeout observed in the window. 119 rows ended retry-limit-exceeded after 8 attempts, and 121 later rows on the same lane completed.
  • The limits are stated in the section: it is not this exact SHA, it is not a base-side contrast, and it is not proof that each attempt settled correctly. Telegram remains untested.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@karmafeast

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The head is unchanged at 9fd80c6cdbd. The PR body now adds the requested proof of Telegram interactive-submission cancellation, run on the shipped Gateway. The production Telegram plugin ran against a loopback Bot API mock, on the head and on the base control 93a9fa4562b, 3 runs per scenario per side. The runs show:

  • the submission is cancelled before adoption;
  • the retry facts are kept (attempts=0, no last_error; base charges attempts=1);
  • the buttons are retained;
  • the submission is redelivered once after a restart, and a re-press after /stop is answered once.

The receipts are pinned at 31fb7e64. Not covered: real Telegram, webhook mode, and a real model.

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

gloss-dandelion-cult and others added 3 commits October 25, 2026 10:41
Back-merge for openclaw#124337 (no rebase). Two test-only conflicts:
- extensions/feishu/src/monitor.comment.test.ts: upstream folded the
  serialize and queued-claim-abort cases into one it.each; kept it and
  re-added this PR's budget-free cancellation case after it.
- extensions/sms/src/inbound.test.ts: upstream folded the deferred,
  adopted and failure MMS cases into one it.each; kept it and re-added
  this PR's cancellation-cleanup and cleanup-failure settlement cases.
Source changes merged cleanly and keep the PR's deltas unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp
… helper

The back-merge auto-merged cleanly, but upstream removed
createReceiverEventWithBody and createChannelIdChangedEnvelope from
ingress.test.ts and now builds the channel_id_changed event through
createReceiverEvent(id, ack, { event }). This PR's routed-cancellation
case still called the removed helpers (tsgo:extensions:test TS2552/TS2304).
Build the same envelope through upstream's helper; assertions unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp
… line cap

Upstream grew ingress-drain.ts to exactly the 700-line cap, so this PR's
settleUnadopted (+1 counted line) tipped it to 701 (oxlint max-lines and
the line-cap ratchet). Collapse the settleOnce wrapper onto one line;
behaviour is unchanged: settle runs once, its result is discarded, and
errors are swallowed as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp
@karmafeast

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Merge conflict resolved without a rebase. The new head is e3b5d3625cb: upstream main 12b56e6492c merged in, then a Slack test port to upstream's helper and a one-line line-cap fold in ingress-drain.ts.
Both conflicts were test-only (Feishu comment, SMS inbound). Upstream's folded it.each cases are kept, and this PR's cancellation cases are re-added after them. The abandonment and cancellation split is unchanged in source.
At the exact head: tsgo ×4, 67 files and 871 tests plus the Telegram cancellation e2e, oxlint, oxfmt, and the line-cap ratchet against upstream main are all green. Receipts are linked in the PR body.

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @karmafeast for the detailed work on this. I confirmed the unbounded-abandonment defect still exists on main a79002c971e2.

The minimal shared-owner replacement, #189393, fixed exhaustion but introduced a verified cancellation regression: clearing a real queued follow-up dead-lettered a threshold message, while main left it replayable. Cancellation still reaches abandonment through the reply binding and lifecycle wrappers; the review records the evidence.

A safe repair requires the broader cancellation cutover, beyond this scoped maintenance pass. I’m closing this oversized takeover and withdrawing the replacement without merging. The shared retry-policy handoff and exhaustion regression remain useful together with that prerequisite. The underlying bug remains unfixed. Thank you for investigating it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu channel: line Channel integration: line channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: sms Channel integration: sms channel: telegram Channel integration: telegram channel: twitch Channel integration: twitch 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. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

5 participants