Skip to content

fix(delivery): record ambiguous final loss as durable notice debt - #121833

Merged
obviyus merged 1 commit into
mainfrom
investigate/issue-80362
Aug 11, 2026
Merged

obviyus merged 1 commit into
mainfrom
investigate/issue-80362

Conversation

@obviyus

@obviyus obviyus commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes #80362: a Telegram (or any channel) final reply whose platform send was accepted but whose response was lost ended in silence — the user got nothing, and nothing explained why. grammY wraps pre-connect failures and accepted-response-loss in the same outer error, so the original regex-based classification could not distinguish them safely.

Why This Change Was Made

This PR is rebuilt on top of #121908 (dispatcher-owned pending-final custody) and adds only what that change does not cover:

  • Durable uncertainty notice debt (pendingDeliveryNotice): custody that stays unknown after a claimed send records owed debt in the session entry. The next same-route turn delivers one "could not confirm delivery" notice and acknowledges it into the transcript. Restart recovery completes ambiguous sessions with the same debt instead of a fire-and-forget notice that is lost during the very outage that caused the ambiguity. The debt survives session reset and daily/idle rollover. Residual records without notice identity keep the visible fail path instead of completing silently.
  • Typed no-send settlement: a permanent PlatformMessageNotDispatchedError (retryable: false) settles as terminal suppressed — a proven no-send must not replay or owe a false notice. A retryable typed rejection restores prepared custody so recovery replays it (the pre-I/O claim writes unknown; leaving it would fake ambiguity).
  • Google Chat: the media-only service-account rejection uses the typed no-send contract, and PATCH 404 on a typing placeholder is distinguished from response loss (POST fallback only for the confirmed-missing placeholder).
  • Telegram: native-command replies are bound into pending-final custody, and a cleanup crash on an already-accepted preview no longer manufactures a delivery failure.

Superseded parts of the earlier revision (cross-channel adapter adoption, queue publication ordering, dispatcher rewrites) were dropped in favor of the landed #121908 design.

Recorded review rebuttal (notice replacement): a newer owed notice may replace an older unresolved one. The notice text is generic same-route uncertainty, so one owed notice covers both losses and is strictly more actionable than retaining a terminal failed-delivery record; keeping both would grow the model into a notice list for a double-failure edge case. Accepted tradeoff.

Maintainer decision (recorded): resolve #80362 with durable visible recovery (no blind resend + owed uncertainty notice) rather than adding a retry contract on grammY's opaque outer error. Decided by the repo owner during this rework; a safe-retry path can be revisited if grammY ever exposes trustworthy pre-connect evidence.

User Impact

An ambiguous delivery loss now always ends in a visible outcome: the reply is never blindly resent, and the user is told once, on their next contact, that the previous reply may not have arrived. Known no-send failures (for example Google Chat media-only replies) fail visibly without a false "may not have arrived" notice.

Evidence

  • Focused suites green on the exact head: channel-turn custody/delivery, delivery-completion (notice debt, suppressed/prepared settlement), main-session restart recovery (notice completion, identity-less fail path, rollover survival), Google Chat reply delivery, Telegram lane delivery + native commands.
  • Regression proofs: rollover-survival and failed-send custody tests fail on pre-fix code for the intended reason.
  • tsgo:test:src, tsgo:extensions:test, plugin-sdk API baseline regenerated, format/lint clean.
  • Real-behavior proof: Telegram E2E userbot run on the final head (one real DM turn, single final, zero edits/deletes, one provider request) — rerun after the rebuild, see PR comments/body updates.

@clawsweeper

clawsweeper Bot commented Aug 11, 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 docs Improvements or additions to documentation channel: discord Channel integration: discord channel: telegram Channel integration: telegram gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 11, 2026
@obviyus
obviyus force-pushed the investigate/issue-80362 branch 2 times, most recently from bba590f to b1cd4d9 Compare August 11, 2026 03:38
@obviyus
obviyus force-pushed the investigate/issue-80362 branch 2 times, most recently from ec5c4b9 to 9ef31b9 Compare August 11, 2026 04:07
@openclaw-barnacle openclaw-barnacle Bot added channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: tlon Channel integration: tlon channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser channel: feishu Channel integration: feishu channel: twitch Channel integration: twitch channel: irc labels Aug 11, 2026
@obviyus
obviyus enabled auto-merge (squash) August 11, 2026 05:35
@obviyus
obviyus disabled auto-merge August 11, 2026 05:43
@obviyus
obviyus force-pushed the investigate/issue-80362 branch 2 times, most recently from c4af4da to 3ff8211 Compare August 11, 2026 06:06
@obviyus
obviyus enabled auto-merge (squash) August 11, 2026 06:09
@obviyus
obviyus disabled auto-merge August 11, 2026 06:10
@obviyus
obviyus force-pushed the investigate/issue-80362 branch 2 times, most recently from 1538b80 to 5fbcfe4 Compare August 11, 2026 06:22
@obviyus
obviyus enabled auto-merge (squash) August 11, 2026 06:23
@obviyus
obviyus force-pushed the investigate/issue-80362 branch from 5fbcfe4 to 4037014 Compare August 11, 2026 06:39
@obviyus
obviyus disabled auto-merge August 11, 2026 06:44
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 11, 2026
@obviyus
obviyus force-pushed the investigate/issue-80362 branch from 5653464 to 88cd674 Compare August 11, 2026 07:33
@obviyus
obviyus enabled auto-merge (squash) August 11, 2026 07:39
@obviyus
obviyus force-pushed the investigate/issue-80362 branch from 88cd674 to 481892f Compare August 11, 2026 07:45
@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 11, 2026
A final whose platform send outcome stays unknown now records owed
pendingDeliveryNotice debt in the session entry; the next same-route turn
delivers one "could not confirm delivery" notice and acknowledges it into
the transcript. Restart recovery completes ambiguous sessions with the
same debt instead of failing them with a fire-and-forget notice that is
lost during the outage that caused the ambiguity.

Permanent typed PlatformMessageNotDispatchedError rejections settle as
terminal suppression (proven no-send: no replay, no false notice); Google
Chat's media-only service-account rejection uses the typed contract and
distinguishes PATCH 404 from response loss. Telegram binds native-command
replies into pending-final custody and no longer converts a cleanup crash
on an already-accepted preview into a delivery failure.

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

Labels

agents Agent runtime and tooling channel: googlechat Channel integration: googlechat channel: telegram Channel integration: telegram docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. 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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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

1 participant