Repository navigation
fix(ingress): bound pre-adoption abandonment with the existing retry budget - #124337
karmafeast wants to merge 40 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherChannel 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
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +244, Tests +1998. Total +2242 across 48 files. Added test files: 4. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (26 earlier review cycles; latest 8 shown)
Reviewed October 25, 2026, 2:38 PM ET / 18:38 UTC (Revision 27). |
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]>
|
@clawsweeper re-review P1 addressed on 70d47be. Mixed fan-in cancel still calls Unit causal closure only. No live/fleet/treatment-composite claim. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
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]>
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]>
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]>
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]>
Make the exact-head drift diff pass its whitespace gate.\n\nRefs openclaw#124337\n\nCo-authored-by: Copilot <[email protected]>
Refs openclaw#124337 Co-authored-by: Copilot <[email protected]>
… 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]>
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]>
…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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp
|
@clawsweeper re-review The head is now The body's
What was not tested is stated plainly:
The receipts are linked in the body. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review The head is unchanged at
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review The head is unchanged at
The receipts are pinned at |
|
🦞👀 Re-review progress:
|
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
|
@clawsweeper re-review Merge conflict resolved without a rebase. The new head is |
|
🦞👀 Re-review progress:
|
|
Thanks @karmafeast for the detailed work on this. I confirmed the unbounded-abandonment defect still exists on main 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. |
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:attemptsclimbs pastmaxAttempts;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:TurnAdoptionLifecyclehas noonCancelled;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)makesonCancelledpart of the reply terminal contract:onCancelled.fix(ingress)settlesonAbandonedthroughapplyFailureDisposition. It records one attempt, respectsmaxAttemptsanddeadLetterMinAgeMs, and dead-letters asretry-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
main12b56e6492c, which was 797 commits ahead, into9fd80c6cdbd(merge3607dc4366c), 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=Ulist and the marker grep agreed.extensions/feishu/src/monitor.comment.test.ts: upstream folded the serialize and queued-claim-abort cases into oneit.each. Thatit.eachis 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 oneit.each. Thatit.eachis kept, and this PR's two cases follow it unchanged: cancellation cleanup ("cleans deferred MMS files before forwarding cancellation") and the cleanup-failure settlementit.each(onCancelled/onAbandoned).Follow-ups on top of the merge:
bb5da2e7098(test): upstream removed the SlackcreateReceiverEventWithBody/createChannelIdChangedEnvelopehelpers. This PR's routed-cancellation case now builds the samechannel_id_changedenvelope through upstream'screateReceiverEvent(id, ack, { event }). The assertions are unchanged.e3b5d3625cb(refactor): upstream grewsrc/channels/message/ingress-drain.tsto exactly the 700-line cap. ThesettleOncewrapper insettleUnadoptedis 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 bymaxAttempts). Cancellation still reopens the claim withrecordAttempt: false, so attempts andlast_errorare 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:testandtsgo:extensions:testexit 0.oxlintandoxfmt --check(on the 47 changed.tsfiles) andcheck-line-cap-ratchet --base 12b56e6492care clean.pnpm run checkpasses except its default line-cap run. That run compares against the fork'sorigin/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 ate3b5d3625cb.Since Revision 20 → Revision 21 (head
9fd80c6cdbd)Change: a merge of upstream
main93a9fa4562b, which was 631 commits ahead, intocd8a6e26fe. It had no conflicts (diff-filter=Uand 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:extensionsandtsgo:test:srcexit 0.telegram-ingress-coalescing.cancellation.e2e) passes 1/1.oxlint,oxfmt --checkandcheck-line-cap-ratchet --base 93a9fa4562bare clean.New: the shipped-Gateway proof that the last review asked for. It is the
## Evidencesection 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:
queue-caprejection) must go through the shared retry disposition, somaxAttemptsbounds it.Before evidence: shipped Gateway at upstream
main93a9fa4562b, same harness and steps as the after-fix runs (3/3 runs per scenario):/stop, the queued row that Stop relinquished has spent one attempt (attempts=1).pending attempts=1 last_error=turn-abandoned. A shutdown is charged as a failed attempt.queue-caprejection releases the row withattempts+1andlast_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:DISCORD_API_URLoverride. The mock was adapted from the fix(discord): keep stale ambient backlog from starving live mentions after gateway recovery #121204 proof corpus.agentRuntime.id: "codex"), pointed at a scripted Responses endpoint.MESSAGE_CREATEframes 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.HOLD-1message keeps one turn busy through repeatedsleeptool calls, so later messages queue behind it.Config:
messages.queue:followup,cap: 1,drop: old | new; one run usedcollect,cap: 2,drop: oldin a guild channel.messages.inbound.debounceMs: 0.maxAttempts: 8,deadLetterMinAgeMs: 0.Exact steps or command run after this patch:
9fd80c6cdbd, which is this PR'scd8a6e26fewith upstreammain93a9fa4562bmerged in. The merge was clean;tsgo:core,tsgo:extensionsandtsgo:test:srcall exit 0.scenario.sh <scenario> <side> <n> <tree>):HOLD-1;MSG-*while the turn is busy;channel_ingress_eventsfrom a copy of the state database (status, attempts,last_error,failed_reason)./stopwhileMSG-Ais queued.MSG-Ais queued, then start it again on the same state.drop:newwith the one slot held byMSG-A, thenMSG-B. Variants:drop:old, and a 12-message guild burst undercollect.Evidence after fix:
9fd80c6cdbdmain93a9fa4562bMSG-A(3 + 3)completed attempts=0, 3/3completed attempts=1, 3/3MSG-Aqueued (3 + 3)pending attempts=0, nolast_error, 3/3pending attempts=1 last_error=turn-abandoned, 3/3ack MSG-A,completed attempts=0, 3/3ack MSG-A,completed attempts=1, 3/3queue-caprejection (5 + 3)[discord] ingress: spooled update msg#04 failed; keeping for retry: turn-abandoned, thenattempts=1attempts=1 last_error=turn-abandonedcollectcap 2 (1 + 1)keeping for retry: turn-abandonedlines, all 14 rowscompleted, every message answeredcompleted, every message answeredObserved result after fix:
queue-capabandonment is now settled through the retry disposition, bounded bymaxAttempts.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.
7d8a1a91c6. It contains this PR at an earlier revision,51631e61a2, merged as3d05df8b5f5(verified withgit merge-base --is-ancestor).onCancelled/onAbandonedsettlement insrc/channels/message/ingress-drain.tsis semantically the same as this head9fd80c6cdbd, differing only in formatting:releaseClaim(…, { recordAttempt: false })andapplyFailureDisposition(…, 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):
[discord] ingress: spooled update <id> failed; keeping for retry: turn-abandoned.handler-timeoutlines 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.spooled update <id> failed with non-retryable retry-limit-exceeded: turn-abandoned; dead-letteredandspooled 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:
failed / retry-limit-exceeded;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 control93a9fa4562b)Setup:
channels.telegram.apiRoot.{ submitText }, the path this PR changed inbot-handlers.callback-router-controls.ts.loonly),env -i, a fake bot token and synthetic ids.HOLD-1turn keeps the session busy. The user presses an inline button (cbq-1), and the handler's submission is queued behind the busy turn (ingress rowclaimed attempts=0, not yet at the model). Then the owner cancels it before adoption. 3 runs per scenario per side:mainpending attempts=0, nolast_errorpending attempts=1 last_error=turn-abandonededitMessageReplyMarkup)cbq-1handler runs again;MSG-SUBMITreaches the model and is answered once; the button is then cleared; rowcompleted attempts=0completed attempts=1/stopwith the submission queued: rowcompleted attempts=0completed attempts=1/stopcbq-2) is answered once, then the button is clearedSo 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-1is 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 recordsHEADand 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:
handler-timeout), and that path applies the retry policy on head and base alike.spooled update msg#04 on lane channel:<dm-channel> reached retry limit after 8 attempts; dead-letteredwithin 0.3 s of each other, thenMSG-Cwas answered.maxAttempts) was not reached in this harness. The proof shows the disposition change, not a lane that main leaves blocked.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 fromqueue/lifecycle.test.ts, as the review at8da32c408esuggested. The wrapped-rejection cases keep the release-before-callback coverage.Upgrade / data-model compatibility. Corpus:
UPGRADE-v2026.10.6.openclaw doctor --fixmigrates the state schema from 20 to 31. This PR changes nothing insrc/state.7ab64536d3drains a migrated copy, all with the same retry policy.last_error, exactly as it does upstream.retry-limit-exceededwith 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.Checks at
cd8a6e26fe:queue/lifecycle.test.ts17/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 of7ab64536d3):queue/recent-message-ids.tsintoqueue/enqueue.ts(refactor: consolidate private single-consumer runtime frames #181498). The recent-source release there now goes throughreleaseBeforeTurnAdoptionRetry, so a cancelled queued turn also forgets its recent message id, as before.dispatch-from-config.prepare-context.ts: kept thereleaseBeforeTurnAdoptionRetryimport.waitForReplyDispatcherIdleis unused after fix: finish reply recording before resetting sessions #181105, so it is dropped.createTwitchIngress'spollIntervalMsoption (refactor(plugins): narrow private inputs and results #180700). The aged-cancelled Twitch test no longer passes it. That was thecheck-test-typesred at Revision 18, since CI type-checks the PR merged with main.Test added:
3fbec00bb7. WhenonCancelledstarts a Feishu flush's settlement andonAbandonedandonAdoptedoverlap it, the transport settles once throughonCancelled(no retry budget). The logical claim is released once, and nothing adopts or commits. As a mutation control, settingsettledafter 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:testandtsgo:extensions:testare clean. oxfmt and oxlint are clean on the PR's changed files.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:checkis stale at upstream main itself. A regen changes rows only for files this PR doesn't touch.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,15499d136aand1add83f4a1merge upstream9c87c4e826,646647245fand79ab1c4907.3cd32643c6merges upstream main827aae9c0b.Upstream rebuilt the follow-up queue on the session controller (#175837), so
1add83f4a1re-applies this PR's cancellation onto upstream's shapes rather than merging textually:queue/lifecycle.tsaddsreleaseBeforeTurnAdoptionRetry,cancelFollowupRunLifecycleand a"cancelled"disposition.session-controller.mailbox-source.tsroutes a cancelled disposition, or an aborted lifecycle signal, toonCancelled. A committedabortSessionControllerInputcounts as cancellation.onCancelledthrough upstream's shared bindings.Fix,
493d5bf21f: release unadopted sources when a drained run returns. This bug exists on upstream main as well.executeClaimmarks every source of a run that returns normally as consumed. A source that was never adopted is included, and consumed suppresses its terminal callbacks.handler-timeout(5 min). That charges an attempt even to a source whose owner aborted.79ab1c4907: both claims stay held, then are dead-lettered under a one-attempt policy.Tests added.
c7f27a7410drivesbindSessionControllerMailboxRestartDrainthrough the durable boundary. A waiting ingress claim is released on gateway restart with no attempt charged:onCancelledfires once,onAbandonednever fires, and nothing is dead-lettered.2407313ae0follows 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):
containSettlementis dropped. Upstream now awaits asynconAbandoned/onCancelledand records a rejection as that input's settlement failure.completeFollowupRunLifecycle).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:testandtsgo:extensions:testare clean.db:worker-inventory:checkis current. oxfmt and oxlint are clean on the PR's changed.tsfiles.src/auto-reply/reply,src/sessionsandsrc/channels/message, and the adapter suites the merges touched. 3 tests in 2 files failed, and both match upstream main827aae9c0bwhen 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-modelpasses alone in 3 of 3 runs on both sides (4/4 tests each); its two grouped reds are a load flake.3cd32643c6. The two test-seam files were committed mid-run as2407313ae0; they pass alone at this head, 10/10 and 1/1.493d5bf21fat that exact head and found no blockers.Still open:
ee2f6dfdf6(Revision 17).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. Inextensions/line/src/webhook-spool.ts, the stop branch for a delivery that returned withoutonAdoptedoronDeferrednow ends ownership throughfannedIn.cancel()instead offannedIn.abandon(). A row at the retry ceiling is no longer dead-lettered asretry-limit-exceededon 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. Everyvi.waitForthis PR added, across 10 test files, is gone. The tests now await one of three signals:observeChannelIngressQueueWrite, or the newobserveChannelIngressQueueWrites, which wraps each queue method once so several observers can't stack;claimNextcommit;These commits are test-only.
ee2f6dfdf6: two lint fixes in the Slack tests (a boundclaimNext, an unused import).Checks at
ee2f6dfdf6(Linux arm64):tsgo:core,tsgo:extensions,tsgo:core:testandtsgo:extensions:test: clean.pnpm checkfails only in its lint step. None of the reported files is in this PR's diff against042db1e706; the remaining errors (max-lines, ui) are in files this PR doesn't touch.Proof. The boundary harness was rerun at this exact head with the same bytes, against control
042db1e706. Every verdict and final SQLite row matches the0cb65da5f2corpus. The corpus is at https://github.com/karmaterminal/karmaterminal-openclaw-docs/tree/615595b9fcc318c8c6d45d4a4f0db2ad9069a7a9/PR-124337/PROOFS/ee2f6dfdf651a8bd4416edb435335c5393190c5eStill 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
042db1e706into51631e61a23(merge8853b1ae51c; 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:completeFollowupRunsforwards an optional disposition; stop, clear and aborted collect/summary sources settle ascancelledthrough it.consumeQueueSummaryDeliverykeeps its settlement argument; upstream's booleanfalsecalls are"retained".dropAbortedFollowupsstays inaborted-followups.ts(re-exported fromdrain.ts) and settles throughcompleteFollowupRuns(…, "cancelled").Feishu broadcast: a
cancelledlane state on upstream's pending/deferred/completed/failed model. Feishu flush and delivery, Slack and Telegram regainonCancelled; Telegram's abort-reason mapping now lives inabortedProcessingResult.c6cfd25c543: the ingress-cancellation test follows upstream's dispatch fixture move todispatch-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 oneifcondition inbot-handlers.callback-router-controls.tsonto one line, so behaviour is byte-equivalent to0cb65da5f2, where the checks and proof below ran.Checks at
0cb65da5f2(Linux arm64):tsgo:core,tsgo:extensions,tsgo:core:test,tsgo:extensions:testclean; 35/35 focused test files (this PR's suites plus the queue, drain, Feishu, Slack and Telegram suites the merge touched).pnpm checkfails three ratchets (line-cap growth, max-lines suppression, assertion SAFETY comment) that fail identically on main042db1e706and name no file in this PR. The boundary proof below was rerun at0cb65da5f2. CI note:src/plugin-sdk/channel-inbound.test.ts› "dispatches a published inbound event before automatic session maintenance" fails on mainb3c7dc2af7itself (3 of 3 local runs), but passes at this branch's tree (042db1e706base). It touches nothing in this PR.Since Revision 14 (head
51631e61a238de75ae0207af541b341e6edeac0e)The branch is rebased onto main
2983dfcfb3and merges cleanly into mainf986a7aaf1. The two original commits change only in rebase-conflict hunks: upstream's newreadLaneBacklogstays drain-only, the vitest path list keeps both entries, and Telegram uses upstream's participant heartbeat. On top of them:4dd7877d56aonCancelled. Feishu's pre-flush cleanup runs on cancellation too.06cd20afc87releaseClaims()andsettleTurn()run, then cancellation is forwarded budget-free.6ff545fd490784a1f1f4375f713b6bd7d3cd7de6f3d4d1c4823226ecompleteFollowupRunLifecyclecontains a rejected asynconCancelledoronAbandoned(logged via the runtime error log). The callback still starts synchronously, andonSettledstill runs right after it.bcbc2837f4efailed-retryable, which dead-lettered non-head members at the ceiling. A{ kind: "cancelled" }result now routes to each member's ownonCancelled, and the update tracker treats cancelled like retryable (not completed), so dedupe cannot swallow the redelivery.53cb34f058releaseBeforeTurnAdoptionRetrynow returnsonAbandoned's result, so core can contain its rejection on the wrapped path.cb1cd8a1d0fimportOriginal) and override onlybuildTelegramMessageContextanddispatchTelegramMessage.4a6c265fa80drain.tsline capdropAbortedFollowupsmoved verbatim into the sibling modulequeue/aborted-followups.ts; only the parameter type changed, to a named subset alias.drain.tsre-exports it, so existingdrain.jsmodule mocks still catch the call. The baseline is unchanged.51631e61a23telegram-ingress-coalescing.e2e.test.tsis restored to its upstream content. The aged-album cancellation regression moved unchanged intotelegram-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.
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).channel_id_changedrun. Before the fix,stop()waited on it indefinitely.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
onCancelled, but it does not update its local handoff state on cancellation. That would only matter for a cancellation beforeonDeferred, which the reply lane does not send.onAbandonedon 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 main042db1e7064930a08c534c4487864d7bfb8c5287(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 atb2d5e48e5b.attempts=0, nolastErrorattempts=1,lastError=turn-abandonedmaxAttempts=3retry-limit-exceeded/turn-abandonedon the 3rd delivery, and the next row in the lane completesattempts=6(2× the limit) when observation stopped, and the lane stayed blockedb2d5e48e5b: https://github.com/karmaterminal/karmaterminal-openclaw-docs/tree/a2cf9d60fabd7ddb5ee6a985365d60c16eb99bf1/PR-124337/PROOFS/b2d5e48e5b59da6d1d29b2bfb7b2af51aee58f0a)logs/{head,control}-{A1,A2,B}.login that directory.admitFollowupRunLifecycle.METHOD.mdlists every limit. The adapter fixes in this revision are covered by the real-queue tests above, not by this harness.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 commit53cb34f058changes onlylifecycle.tsand 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.--maxWorkers=1, 15 s).--maxWorkers=1, 70 s).drain.js: 247/247.check:import-cycles: 0.tsgo:core,tsgo:core:test,tsgo:extensionsandtsgo:extensions:test: clean.Typecheck:
tsgo:extensionsandtsgo:extensions:testare clean atbcbc2837f4e.tsgo:coreandtsgo:core:testare clean at53cb34f058.oxfmtis clean.