Skip to content

fix: stop retrying exhausted unadopted channel messages - #189393

Closed
roboclaw-bot wants to merge 1 commit into
mainfrom
loop/contributor-pr-124337
Closed

roboclaw-bot wants to merge 1 commit into
mainfrom
loop/contributor-pr-124337

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #124337, thanks @karmafeast.

Withdrawn: this narrow replacement is unsafe without the broader cancellation cutover. Nothing was merged.

What Problem This Solves

The proposed shared-owner change bounds genuine pre-adoption abandonment, which still bypasses retry exhaustion on main.

User Impact

No shipped change. The proposal would also dead-letter explicitly cancelled queued messages at the retry threshold because reply cancellation still reaches onAbandoned. It must not be deployed.

Why This Change Was Made

The shared drain's direct abandonment release increments attempts but never consults the existing failure disposition. The proposed handoff fixes that defect, but retaining the drain's onCancelled callback is insufficient: bindIngressLifecycleToReplyOptions drops it, and abortSessionControllerInput invokes abandonment during explicit cancellation. Shared debounce, dedupe settlement, and channel-owned lifecycle wrappers also need a complete cancellation contract. That broader cutover is outside this task's bounded shared-owner-only takeover scope; #124337 is not being ported wholesale.

The useful part remains the shared retry-policy handoff and its exhaustion regression, conditional on completing cancellation propagation. Deliberate queue-cap drops remain the separate scope of #182252.

Evidence

  • Original defect confirmed on main: Telegram's production ingress monitor and SQLite queue, with a 25-hour-old message and seven prior failures, left the failed ledger empty after the eighth abandonment on c504abf10afa. The determining shared owner was also unchanged at 338de6d69998.
  • Proposed fix: the same Telegram regression passed; all 23 Telegram ingress tests and 38 shared drain/retry-policy tests passed. Wall times: 46.18 and 42.83 seconds, including worker compilation. Touched-file type-aware lint, formatting, and diff checks passed.
  • Introduced regression reproduced: a separate focused probe used real createChannelIngressDrain → bindIngressLifecycleToReplyOptions → enqueueFollowupRun → clearFollowupQueue, with the existing drain policy maxAttempts: 1, deadLetterMinAgeMs: 0. Clearing the queue returned 1; the row then entered the failed ledger with reason: retry-limit-exceeded and message: turn-abandoned. The identical probe passed with main's drain restored, leaving the message pending/replayable. Candidate probe: 12.47 seconds; main control: 36.78 seconds including compilation. This disproves the original statement that retaining the drain callback alone preserves reply cancellation.
  • Review: Codex autoreview with full owner/caller context reported scoped-clean at P0–P2. Hosted ClawSweeper then identified the P1 cancellation regression; it was verified rather than dismissed. Review and evidence.
  • Scope: proposed production +16/-18 (-2 lines), regression +48, allocation +2; landed delta 0. No settings, migrations, dependency changes, or deployment.
  • Only trusted main and this independently implemented candidate were run locally. The contributor branch was read with gh pr view/gh pr diff and never checked out or executed. No production Gateway or live channel/model was used.

CI completion is recorded in the closure comment; its outcome does not override the reproduced cancellation regression.

Apply the existing failure disposition to pre-adoption abandonment so exhausted
messages reach the failed ledger and emit the terminal diagnostic. Preserve the
explicit cancellation release and remove its now-single-use helper.

Supersedes #124337, thanks @karmafeast.

Co-authored-by: frond-scribe <[email protected]>
Co-authored-by: gloss-dandelion-cult <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added the channel: telegram Channel integration: telegram label Oct 31, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 31, 2026 12:51
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

Scoped maintainer replacement for #124337: the shared ingress owner now applies the existing retry disposition to abandonment. Codex autoreview with full owner and caller context found no P0–P2 findings; 61 focused tests passed. Please review the small replacement, including settlement ownership and the existing explicit-cancellation behavior.

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Route unadopted message abandonment through the existing retry policy so exhausted messages enter the failed ledger.

Example: Telegram update 3 is 25 hours old and has seven recorded failed attempts.

  • Before: Another abandonment releases it for retry indefinitely.
  • After: Another abandonment records retry-limit-exceeded and lets update 4 proceed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused persisted-queue regression supports the central fix, but the unchanged reply cancellation path creates a blocking delivery regression.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this collaborator-authored PR; its supplied evidence is a Telegram monitor/SQLite regression with mocked dispatch, while linked earlier Gateway observations concern different revisions.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Repeatedly abandoned inbound messages can retry indefinitely and delay later conversation messages.
Reason: The maintainer-authored direction restores the existing bounded-retry contract using its current owner; cancellation correctness still needs repair.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR addresses a current retry-exhaustion bug, but terminalizing abandonment also terminalizes explicit cancellations that still reach that callback.

Priority: P1
Reviewed head: fe9ede7238828f26027fb76f264f129f6ff5db14

Before merge

  • Preserve explicit reply cancellation before dead-lettering abandonment (P1) - A cancelled queued input still reaches this new terminal path: abortSessionControllerInput calls notifySessionControllerSourceAbandonment for an unclaimed, unadopted source, which invokes onAbandoned, and bindIngressLifecycleToReplyOptions explicitly drops onCancelled. For example, cancel a queued Discord message with seven prior attempts: Discord's zero minimum-age policy makes this callback fail it as retry-limit-exceeded instead of releasing it for replay. Previously this callback only released the row. Carry explicit cancellation through the reply lifecycle and affected adapters before treating genuine abandonment as terminally retryable; retaining the drain's onCancelled implementation alone does not preserve cancellation behavior.

Findings

  • [P1] Preserve explicit reply cancellation before dead-lettering abandonment — src/channels/message/ingress-drain.ts:451-453

Tests

  • Missing end-to-end proof: Add a production-path cancellation regression with a queued threshold message, proving cancellation preserves retry facts and restart replay while genuine abandonment still terminalizes.
Agent review details

How this fits together

Channel monitors feed durable SQLite claims into the shared ingress drain, whose lifecycle callbacks settle delivery, cancellation, adoption, and retry outcomes.

flowchart TD
  A[Channel monitor] --> B[SQLite ingress queue]
  B --> C[Shared ingress drain]
  C --> D[Reply lifecycle binding]
  D --> E[Session mailbox]
  E --> F[Terminal callback]
  F --> C
  C --> G[Retry or failed ledger]
Loading

Technical review

Best possible solution:

Preserve cancellation as a distinct budget-free outcome through the existing reply and ingress owners before applying terminal retry disposition to genuine abandonment.

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

Source establishes both the current-main unbounded-abandonment path and the introduced cancellation-to-dead-letter path; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Reusing the shared retry disposition is appropriate, but the complete fix must distinguish cancellation at the reply-mailbox boundary rather than assuming every abandonment callback represents a failed delivery.

Full review comments:

  • [P1] Preserve explicit reply cancellation before dead-lettering abandonment — src/channels/message/ingress-drain.ts:451-453
    A cancelled queued input still reaches this new terminal path: abortSessionControllerInput calls notifySessionControllerSourceAbandonment for an unclaimed, unadopted source, which invokes onAbandoned, and bindIngressLifecycleToReplyOptions explicitly drops onCancelled. For example, cancel a queued Discord message with seven prior attempts: Discord's zero minimum-age policy makes this callback fail it as retry-limit-exceeded instead of releasing it for replay. Previously this callback only released the row. Carry explicit cancellation through the reply lifecycle and affected adapters before treating genuine abandonment as terminally retryable; retaining the drain's onCancelled implementation alone does not preserve cancellation behavior.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 27c5554782e7.

Provenance checked

  • Shared abandonment disposition changes intended behavior with a stated reason (06600e2: Separate dispatcher failure from explicit cancellation while retaining existing abandonment behavior.)
  • Retry accounting versus cancellation keeps the original intent (4151625: Charge genuine abandoned deliveries while keeping Telegram owner shutdown budget-free.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/channels/message/ingress-drain.test.ts src/channels/message/ingress-drain-lifecycle.test.ts --maxWorkers=1
  • pnpm test src/sessions/session-controller.mailbox-cleanup.test.ts src/auto-reply/reply/queue/lifecycle.test.ts --maxWorkers=1
  • pnpm test extensions/telegram/src/telegram-ingress-drain.test.ts --maxWorkers=1
  • Prove threshold-message cancellation preserves attempts, last error, and restart replay through the production reply lifecycle; separately prove genuine abandonment dead-letters and releases the lane.
  • Run affected bundled-adapter tests and targeted type-aware lint/type checks after the cancellation cutover.

What I checked:

Likely related people:

  • joshavant: Raw commit 13750fe adds src/channels/message/ingress-drain-lifecycle.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 13750feff339; files: src/channels/message/ingress-drain-lifecycle.ts)

PR surface

Source -2, Tests +48, Other +2. Total +48 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 16 18 -2
Tests 1 48 0 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 66 18 +48

Review metrics

Metric Value Why it matters
Production versus regression code Production +16/-18; tests +48 The production reduction reuses the existing retry owner, and the added regression protects terminal ledger settlement and same-lane progress.

Labels

Label changes:

  • add P1: The central bug can indefinitely delay channel messages, while the introduced cancellation interaction can terminally remove queued messages from automatic replay.
  • add merge-risk: 🚨 message-delivery: An explicitly cancelled queued message at the retry threshold can now enter the failed ledger instead of remaining replayable.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: The central bug can indefinitely delay channel messages, while the introduced cancellation interaction can terminally remove queued messages from automatic replay.
  • merge-risk: 🚨 message-delivery: An explicitly cancelled queued message at the retry threshold can now enter the failed ledger instead of remaining replayable.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 31, 2026, 8:56 AM ET / 12:56 UTC.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Withdrawing this narrow replacement: the P1 cancellation finding is verified. A real follow-up enqueue/queue-clear probe dead-lettered the message with this patch and passed with main's drain restored. Repairing the complete cancellation contract requires a broader cutover than this scoped takeover permits.

All required CI ultimately passed at fe9ede7238828f26027fb76f264f129f6ff5db14: CI run 41202978488, 625 seconds wall time, and the final openclaw/ci-gate is successful. That proof did not cover the reproduced cancellation regression. Nothing was merged; please do not deploy this candidate.

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

Labels

channel: telegram Channel integration: telegram 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. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant