Files
openclaw/extensions/telegram
carlosjarenom c93652cbe4 fix(telegram): persist update offset only after durable spool write in isolated polling (#113368)
* fix(telegram): persist update offset only after durable spool write in isolated polling

Closes #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 #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 (#113368)

---------

Co-authored-by: Carlos <carlos@example.com>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-07-27 17:21:03 +09:00
..