fix(telegram): back off, dead-letter, and tombstone spooled updates so poison messages cannot block or duplicate#98776
Conversation
|
ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed July 1, 2026, 6:27 PM ET / 22:27 UTC. Summary PR surface: Source +50, Tests +179. Total +229 across 6 files. Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Review metrics: none identified. Merge readiness This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict. Risk before merge
Maintainer options:
Next step before merge
Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against eb417fa206e6. Evidence reviewedPR surface: Source +50, Tests +179. Total +229 across 6 files. View PR surface stats
What I checked:
Likely related people:
How this review workflow works
|
9b36c21 to
9d7c633
Compare
|
Landed via rebase onto main.
|
Closes #98774
What Problem This Solves
Fixes an issue where a Telegram spooled update that keeps failing would retry every ~500ms forever with no backoff and no attempts cap — and because the spool drain claims the lowest update id per conversation lane, the poison row permanently blocked every later message in that chat/topic. Two directly associated spool defects are fixed with it: a transient store read error during restart replay silently deleted the spooled message (the same loss window #98076 closed for media, still open for store reads), and successfully processed rows were deleted instead of tombstoned, so a crash-window Telegram refetch could re-dispatch an already-processed update — including re-executing callback-query side effects.
Why This Change Was Made
Three commits, in dependency order. First, the one-off session-init-conflict backoff (from
13ecca5408c) is generalized: all retryable spooled failures now back off exponentially from the queue's persistedattempts/lastAttemptAt(1s base, 3m cap) and dead-letter to the existingfailedtombstones after 8 attempts, unblocking the lane. Second,TelegramPairingStoreReadErrorin the inbound handler now records afailed-retryableresult so spooled replays are requeued instead of deleted; the user-facing "please try again" apology is suppressed for replays (they retry durably) and kept for live updates (acked without retry). Third, the success path uses the ingress queue'scomplete()tombstones (30d/1000 retention, pruned on the existing enqueue-side prune) so enqueue-time duplicate detection absorbs refetches; a redrain-ordering fix ensures lane guards clear before a requested immediate redrain.User Impact
One malformed or persistently failing message can no longer silently freeze an entire Telegram chat or topic — it retries with backoff, then dead-letters with a warning log operators can find. Messages that hit transient store errors during a gateway restart are retried instead of lost, without apology spam. Buttons and commands no longer risk double-execution after a crash-window refetch.
Evidence
polling-session.test.ts, 72 pass); transient pairing-store error on spooled replay requeues instead of deleting, with no repeated apologies (bot.create-telegram-bot.test.ts, 113 pass); completed-then-refetched update is detected as duplicate and not re-dispatched, at both queue and drain level (telegram-ingress-spool.test.ts, 14 pass).pnpm tsgo:extensionspass;node scripts/run-oxlint.mjson touched files pass; repo autoreview (branch mode vsorigin/main) clean.codex/fix-telegram-cache-transport): conflict-free octopus merge,pnpm tsgo:extensionspass, 403/403 tests across all six touched test files.failedtombstone bounds).