Skip to content

fix(telegram): persist update offset only after durable spool write in isolated polling - #113368

Merged
obviyus merged 3 commits into
openclaw:mainfrom
carlosjarenom:fix/issue-113315-telegram-inbound-update-lost
Jul 27, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
carlosjarenom:fix/issue-113315-telegram-inbound-update-lost

Conversation

@carlosjarenom

@carlosjarenom carlosjarenom commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Refs #113315

What Problem This Solves

Isolated Telegram polling previously allowed the normal bot update tracker to persist an update offset before the ingress worker's durable spool write completed. A crash in that window could make Telegram stop redelivering an update that OpenClaw had not stored.

Changes

  • Persist isolated polling offsets only after writeTelegramSpooledUpdate commits.
  • Keep spool, offset persistence, and worker acknowledgement on the worker's existing one-update-at-a-time path.
  • Omit the post-dispatch onUpdateId callback in isolated mode so each offset has one owner.
  • Add diagnostics for polling, spool, and offset persistence stages.
  • Add regressions for non-consecutive Telegram update IDs, persistence failure after durable spool, and spool failure before acknowledgement.

Evidence

  • Current head 27de15889cb is rebased onto d4ed57bc884; git range-diff confirms the reviewed patch series is unchanged.
  • Exact-head full CI and required openclaw/ci-gate passed: https://github.com/openclaw/openclaw/actions/runs/30247109038
  • extensions/telegram/src/polling-session.test.ts proves spool → persist → ACK ordering and proves a spool failure produces no persisted offset or successful ACK.
  • extensions/telegram/src/telegram-ingress-worker.runtime.test.ts proves the worker waits for each parent ACK before advancing the next getUpdates offset.
  • Earlier live isolated-polling evidence established the spool-before-offset observable sequence. The current head removes unnecessary concurrency bookkeeping while retaining that single serialized boundary.

@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 24, 2026
@clawsweeper

clawsweeper Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 3:46 AM ET / 07:46 UTC.

ClawSweeper review

What this changes

The PR changes isolated Telegram polling so an update is durably written to the ingress spool before its polling offset is persisted and the worker is acknowledged, with regressions for ordering and failure paths.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for normal landing review: the current branch appears to correctly close the isolated polling spool-before-offset crash window, preserves the broader report as open work, and has no remaining code-level finding. It is behind current main, so the merge-result head still needs the focused ordering coverage and required checks before merge.

Priority: P1
Reviewed head: 27de15889cbe361dd17a3a878f6ab69aa87f2685

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, well-covered durability repair with accepted proof, pending only merge-result refresh and completion of exact-head checks.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): A recorded maintainer proof decision accepts exact-head failure-path tests because this internal durable-storage failure cannot be meaningfully injected through the available Telegram proof lanes; earlier live evidence covered the same serialized spool-before-offset contract.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): A recorded maintainer proof decision accepts exact-head failure-path tests because this internal durable-storage failure cannot be meaningfully injected through the available Telegram proof lanes; earlier live evidence covered the same serialized spool-before-offset contract.
Evidence reviewed 5 items Single offset owner in isolated mode: The branch removes the bot update tracker's post-dispatch offset callback when isolated ingress is enabled, leaving the parent spool handoff as the single owner of offset persistence.
Durable ordering regression coverage: The PR adds isolated-ingress coverage for spool → persist → acknowledgement ordering, non-consecutive update IDs, persistence failure after a successful spool, and spool failure without a successful acknowledgement.
Broader report remains correctly open: The final PR body uses a reference rather than a closing declaration for the broader inbound-loss report, and the maintainer proof decision explicitly says to keep that investigation open.
Findings None None.
Security None None.

How this fits together

Telegram's isolated polling worker receives updates from Telegram and asks the parent session to durably hand them to the ingress spool. The parent then records the polling offset and acknowledges the worker, determining whether Telegram may redeliver an update after a failure.

flowchart LR
  A[Telegram getUpdates] --> B[Isolated polling worker]
  B --> C[Parent spool handoff]
  C --> D{Durable spool succeeds?}
  D -->|yes| E[Persist polling offset]
  E --> F[Worker acknowledgment]
  D -->|no| G[Failure acknowledgment and redelivery]
Loading

Before merge

  • Resolve merge risk (P1) - This changes the acknowledgement boundary for live Telegram delivery; after rebasing, the focused spool-failure, persistence-failure, and serialized-worker tests must pass on the resulting head before merge.
  • Resolve merge risk (P1) - The PR deliberately fixes only the spool-before-offset signature. The broader no-ingress investigation remains tracked at [Bug]: Telegram inbound update is permanently lost after offset persistence with no ingress, spool, or dispatch #113315 and should not be implicitly closed by this branch.
  • Complete next step (P2) - No narrow repair remains; normal maintainer landing review should refresh the behind branch and confirm the exact merge-result checks before merging.
Agent review details

Security

None.

PR surface

Source +30, Tests +115. Total +145 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 43 13 +30
Tests 1 118 3 +115
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 161 16 +145

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #113315
Summary: This PR is a candidate fix for the specific offset-before-durable-spool failure mode reported by the canonical issue, while that issue retains broader unconfirmed inbound-loss investigation work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Refresh and prove the merge-result head (recommended)
    Rebase or update the merge result, then rerun the focused isolated polling ordering and failure-path coverage before merging the Telegram acknowledgement-boundary change.
  2. Pause if the refreshed head changes the serialized boundary
    If rebasing changes the parent-worker ordering or reintroduces concurrent delivery behavior, pause this branch and re-review the updated implementation rather than relying on prior proof.

Technical review

Best possible solution:

Rebase or refresh the merge result against current main, confirm the isolated polling ordering tests and required checks on that exact head, then merge this narrow durability fix while leaving the broader inbound-loss investigation open.

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

No independent live reproduction was performed in this read-only review; however, the prior failure window is high-confidence source-reproducible and is directly covered by the branch's ordered spool, persistence, and acknowledgement regressions.

Is this the best way to solve the issue?

Yes. Using the existing serialized parent-worker handoff to make durable spool success precede offset persistence is the narrowest maintainable repair, and removing the isolated-mode post-dispatch callback prevents split offset ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3c67fcc45d83.

Labels

Label justifications:

  • P1: The PR addresses a plausible permanent loss of inbound Telegram messages when an offset advances before durable handoff.
  • merge-risk: 🚨 message-delivery: Merging changes when a Telegram update becomes acknowledged, so a regression at this boundary could lose or replay inbound messages.
  • 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. Sufficient (live_output): A recorded maintainer proof decision accepts exact-head failure-path tests because this internal durable-storage failure cannot be meaningfully injected through the available Telegram proof lanes; earlier live evidence covered the same serialized spool-before-offset contract.
  • proof: sufficient: Contributor real behavior proof is sufficient. A recorded maintainer proof decision accepts exact-head failure-path tests because this internal durable-storage failure cannot be meaningfully injected through the available Telegram proof lanes; earlier live evidence covered the same serialized spool-before-offset contract.

Evidence

What I checked:

  • Single offset owner in isolated mode: The branch removes the bot update tracker's post-dispatch offset callback when isolated ingress is enabled, leaving the parent spool handoff as the single owner of offset persistence. (extensions/telegram/src/polling-session.ts:293, 27de15889cbe)
  • Durable ordering regression coverage: The PR adds isolated-ingress coverage for spool → persist → acknowledgement ordering, non-consecutive update IDs, persistence failure after a successful spool, and spool failure without a successful acknowledgement. (extensions/telegram/src/polling-session.test.ts:1083, 27de15889cbe)
  • Broader report remains correctly open: The final PR body uses a reference rather than a closing declaration for the broader inbound-loss report, and the maintainer proof decision explicitly says to keep that investigation open. (extensions/telegram/src/polling-session.ts:512, 27de15889cbe)
  • Review-cycle provenance: The final commit replaces the earlier concurrency/coalescing approach with a serialized durable-offset path, matching the worker's one-update-at-a-time contract described in the PR discussion. (extensions/telegram/src/polling-session.ts:512, 27de15889cbe)
  • Current merge state: GitHub reports the branch as cleanly mergeable but behind current main; several exact-head checks are still in progress, so landing evidence must be refreshed after the rebase or merge-result update. (3c67fcc45d83)

Likely related people:

  • obviyus: Assigned this PR, authored the final serialized-offset commit, and recorded the maintainer decision accepting exact-head failure-path test confidence. (role: recent area contributor and review decision owner; confidence: high; commits: 27de15889cbe; files: extensions/telegram/src/polling-session.ts, extensions/telegram/src/polling-session.test.ts)
  • marin19: Authored the initial durable-spool ordering implementation and its follow-up before the final serialized simplification. (role: initial implementation contributor; confidence: medium; commits: 68179531fdde, 3cb14bc7180d; files: extensions/telegram/src/polling-session.ts, extensions/telegram/src/polling-session.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase or refresh the merge result against current main and let the focused ordering coverage run on that exact head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-07-24T16:34:31.118Z sha 9143e2217fa7dd608cb0371b19bd87098c9bf136 :: needs real behavior proof before merge. :: [P1] Keep offset advancement ordered across concurrent spool writes
  • reviewed 2026-07-26T20:12:35.945Z sha 25f45cd2a76fdf2196173d8626a9323b57b2323e :: found issues before merge. :: [P1] Stop closing the still-unresolved Telegram loss report
  • reviewed 2026-07-27T07:04:57.678Z sha f7c0945d8918f6c8440061ceb904ba53bf88cd52 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T07:12:36.227Z sha f7c0945d8918f6c8440061ceb904ba53bf88cd52 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T07:36:25.496Z sha f7c0945d8918f6c8440061ceb904ba53bf88cd52 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 24, 2026
@carlosjarenom
carlosjarenom force-pushed the fix/issue-113315-telegram-inbound-update-lost branch from 9143e22 to 6c14f42 Compare July 24, 2026 16:55
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S size: M and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: S labels Jul 24, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up. The spool-before-offset ordering and the added poll/spool/offset diagnostics directly improve the original hazard reported in #113315.

One important scope note before this PR closes the issue: a new current-main reproduction now shows an additional, confirmed signature after the durable-spool boundary. On 2026.7.2 (8d67c40), across three recreations, early DMs at ~43–74s after polling startup produced a durable ingress row and advanced the canonical offset, but the row became completed in 32–34ms with no message received, no dispatchInboundMessage, no error/metadata, and no reply. Late controls on the same instances at >=10m52s delivered 4/4 with normal multi-second processing. Full redacted evidence: #113315 (comment)

This patch does not appear to change the claim/adoption → completion paths, so it may fix the first offset-before-spool failure mode without fixing the reproducible completed-without-dispatch startup mode. Could the PR either:

A mandatory completion reason (dispatched, skipped:<reason>, error:<detail>) would also make this second failure detectable.

JesusSerrano-Seimako commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Reviewing current head 25f45cd2: the new duplicate-coalescing failure path appears to report inconsistent results after a failed shared spool.

spoolAndAck() catches writeTelegramSpooledUpdate() errors internally, sends { ok: false } for the original request, but does not rethrow or return a failure result. Therefore its spoolPromise fulfills. A duplicate request that finds #pendingSpoolPromises.get(updateId) attaches this handler:

pending.then(
  () => ackSpooledUpdate(duplicateRequestId, { ok: true, updateId }),
  () => ackSpooledUpdate(duplicateRequestId, { ok: false, ... }),
)

If the shared spool fails, the original request receives ok:false but the duplicate receives ok:true.

Reachability update after reading telegram-ingress-worker.runtime.ts at this head: the current worker awaits each requestSpoolUpdate() serially before advancing lastUpdateId and before processing the next update. I could not find a producer that emits a concurrent duplicate while a request is pending, so this appears to be a latent correctness defect, not a confirmed production-reachable P1 today. The #pendingSpoolPromises branch looks defensive/future, and its comment about worker retries contradicts the current worker implementation. The ok:true → lastUpdateId advancement path is confirmed, so the loss risk would become reachable if an abort/restart or future retry path can re-emit an update while a prior request remains pending.

Suggested narrow fix: make the shared promise reject/rethrow after sending the original failure ACK, or have it resolve to an explicit success/failure result and map every coalesced request to that same result. Please add a regression that:

  1. starts one update spool and keeps it pending;
  2. emits a duplicate request for the same update_id;
  3. fails the shared spool;
  4. asserts both request IDs receive ok:false, no offset is persisted, and no drain is requested.

This is separate from the already-reported startup completed-without-dispatch signature.

JesusSerrano-Seimako commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Live after-fix validation on the exact current head 25f45cd2a76fdf2196173d8626a9323b57b2323e is complete. This was run after aggregate CI finished green, using an isolated image built from that SHA (sha256:c633b2ce8608d44d60924b700b7faedf26e57c2fc992cf1952ecace64f148e47). Production was untouched.

Each early sample used a clean container recreation and measured from the first isolated-worker poll-start:

sample update_id time after poll-start durable spool / offset downstream result Telegram outcome
C1 early 283876582 +52.642s both succeeded row completed in 43ms; no message received, no dispatchInboundMessage, no error/metadata no reply
C2 early 283876583 +55.901s both succeeded message received after 123ms; row completed in 1022ms; dispatch completed in 5080ms reply visible
C3 early 283876584 +75.169s both succeeded row completed in 44ms; no message received, no dispatchInboundMessage, no error/metadata no reply
C3 late control 283876585 +10m20.270s both succeeded message received after 133ms; row completed in 1019ms; dispatch completed in 5878ms reply visible

So the early result on the patched head is 2/3 silent losses, with a healthy late control on the same C3 instance. The pass between two losses also shows that this head has an intermittent startup race, not a uniformly fatal time window.

The patch clearly improves the original spool-before-offset hazard: every tested update crossed the durable boundary before offset persistence, and the remaining loss is now durable and inspectable. But it does not resolve the separately confirmed startup completed-without-dispatch path. The lost updates entered grammY ([telegram] update) and then returned before the message received diagnostic; the remaining candidates are the early exits around shouldSkipUpdate, authorization, or the message dispatch-dedupe claim. None currently records a completion reason.

Could the PR change Closes #113315 to Refs #113315 (or otherwise keep #113315 open) while this durability/ordering fix advances? The next focused regression/instrumentation should require every pre-dispatch early return to produce a durable reason such as skipped:update-dedupe, skipped:authorization, or skipped:dispatch-dedupe, and assert that an authorized fresh DM cannot be completed silently during startup.

Exact pre-dispatch completion map (source audit of this head)

  • bot-core.ts:182-211: the outer middleware calls finishUpdate(..., { completed: true }) whenever await next() returns, unless the processing frame reports failed-retryable. A handled skip and a real dispatch are therefore indistinguishable at this boundary.
  • bot-handlers.message-events.runtime.ts:128-180: a fresh message can return before processInboundMessage at exactly three gates: shouldSkipUpdate (128-130), gate.allowed === false (142-144), or claimMessageDispatchDedupe(...).process === false (177-180).
  • bot-handlers.authorization.runtime.ts:297-412: the denied gate is typed only as { allowed: false }, so its reason is discarded.
  • bot-handlers.message-lifecycle.runtime.ts:130-140: dispatch-dedupe emits only a verbose log before returning process: false.

A narrow diagnostic repair would make the handler return a mandatory discriminated outcome and persist it once at finishUpdate: dispatched, skipped:update-tracker:<reason>, skipped:authorization:<reason>, skipped:dispatch-dedupe, or failed-retryable. Reasons should be low-cardinality and contain no message text/PII. Focused replay tests can inject each branch (including two calls with the same semantic key) and assert that no durable row reaches completed without an explicit outcome. This map identifies the observable boundary; it does not yet claim which gate wins the startup race.

Copy link
Copy Markdown
Contributor

Correction to my post-PR reproduction analysis: the instrumented C2 loss was not a fresh-key startup race.

The dropped DM was message_id=77. Read-only inspection of the exact test database found an existing V1 dispatch-dedupe row for account=default, the same chat_id, and message_id=77, with seenAt/created_at=2026-07-20T09:59:49.132Z. The beta database from which this state was copied/migrated contains the same row and timestamp. That row predates the disposable bot. My earlier query appeared to show no row because it listed only the 25 newest entries; the older row fell outside that result.

The V1 dispatch key is account + chat_id + message_id and does not include Telegram bot identity. A legitimate message from a different bot therefore matched the inherited row and resolved as a persisted replay duplicate. Subsequent controls, message IDs 79 and 81, had no historical collision: their first raw claims were claimed in 3 ms, and both processed and replied normally.

Therefore the post-PR 2/3 "startup loss" table is confounded and should not be cited as evidence that #113368 leaves a downstream startup race. It does expose a separate product bug: rotating to another bot under the same account or copying state across bots can cause cross-bot dedupe collisions. Suggested V2 direction: scope the key by the stable numeric Telegram bot ID (account + bot_id + chat_id + message_id). V1 rows cannot be attributed safely to a bot and should not be automatically imported into a V2 bot namespace.

Scope: this explains the completed-without-dispatch signature in the state-reused test environment. It does not explain the original #113315 no-ingress/no-spool manifestations, which remain open.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Jul 26, 2026
@obviyus obviyus self-assigned this Jul 27, 2026
@obviyus
obviyus force-pushed the fix/issue-113315-telegram-inbound-update-lost branch from 25f45cd to f7c0945 Compare July 27, 2026 06:59
@obviyus

obviyus commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 27, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 27, 2026
@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 27, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared July 27, 2026 07:18 Inactive
@obviyus

obviyus commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Maintainer proof decision: accepting exact-head test confidence for the failure path, per ClawSweeper's documented option.

  • Exact-head full CI is green.
  • Focused regressions prove durable spool → actual offset persistence → worker ACK; forced spool failure proves no persistence and no successful ACK.
  • The worker runtime test proves only one update can be outstanding at this boundary.
  • The Telegram Desktop Mantis lane cannot inject this internal storage failure; the Telegram Live lane rejects secret-bearing execution of fork PR heads. A generic reply GIF would not prove the crash window.
  • Earlier live evidence showed spool-before-offset on the prior head. The current head only removes unreachable concurrency bookkeeping and keeps the same serialized contract.

Skipping new exact-head live failure injection with that limitation recorded. Keeping #113315 open for its broader no-ingress investigation.

@obviyus

obviyus commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jul 27, 2026
Carlos and others added 3 commits July 27, 2026 09:42
…n isolated polling

Closes openclaw#113315

In isolated polling ingress, the parent session now persists the Telegram
update offset only after the update has been durably written to the spool.
This prevents an update from being acknowledged (via the offset) before it
has been safely enqueued, which could lead to permanent data loss if the
process crashes between offset persistence and spool write.

Changes:
- Call persistUpdateId(updateId) after writeTelegramSpooledUpdate succeeds.
- Add structured logs for poll-start, update receipt, spool success/failure,
  and offset persistence success/failure.
- In isolated mode, stop passing onUpdateId to the bot so the offset is only
  persisted once, after the spool write.
- Add regression tests verifying spool-before-offset ordering and the
  failure path when spooling fails.
… spooled updates

Closes openclaw#113315

- Track successfully spooled update ids and advance the persisted offset only
  through a contiguous boundary. This prevents a later update_id from being
  persisted before an earlier one has finished spooling, which would make the
  earlier update unrecoverable after a restart.
- Serialize spooling while no durable offset floor exists, so the first
  successful spool becomes the persisted floor.
- Coalesce duplicate worker deliveries for the same update_id and ack both
  success and failure paths.
- Fix TypeScript cast errors in polling-session.test.ts.
@obviyus
obviyus force-pushed the fix/issue-113315-telegram-inbound-update-lost branch from f7c0945 to 27de158 Compare July 27, 2026 07:42
@obviyus
obviyus merged commit c93652c into openclaw:main Jul 27, 2026
126 of 128 checks passed
@obviyus

obviyus commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 28, 2026
…n isolated polling (openclaw#113368)

* fix(telegram): persist update offset only after durable spool write in isolated polling

Closes openclaw#113315

In isolated polling ingress, the parent session now persists the Telegram
update offset only after the update has been durably written to the spool.
This prevents an update from being acknowledged (via the offset) before it
has been safely enqueued, which could lead to permanent data loss if the
process crashes between offset persistence and spool write.

Changes:
- Call persistUpdateId(updateId) after writeTelegramSpooledUpdate succeeds.
- Add structured logs for poll-start, update receipt, spool success/failure,
  and offset persistence success/failure.
- In isolated mode, stop passing onUpdateId to the bot so the offset is only
  persisted once, after the spool write.
- Add regression tests verifying spool-before-offset ordering and the
  failure path when spooling fails.

* fix(telegram): persist isolated polling offset only across contiguous spooled updates

Closes openclaw#113315

- Track successfully spooled update ids and advance the persisted offset only
  through a contiguous boundary. This prevents a later update_id from being
  persisted before an earlier one has finished spooling, which would make the
  earlier update unrecoverable after a restart.
- Serialize spooling while no durable offset floor exists, so the first
  successful spool becomes the persisted floor.
- Coalesce duplicate worker deliveries for the same update_id and ack both
  success and failure paths.
- Fix TypeScript cast errors in polling-session.test.ts.

* fix(telegram): serialize durable polling offsets (openclaw#113368)

---------

Co-authored-by: Carlos <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

3 participants