Skip to content

fix(telegram): prevent durable ingress lane spins - #118357

Merged
vincentkoc merged 2 commits into
mainfrom
fix/beta8-ingress-lane-reconcile-20260803
Aug 3, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/beta8-ingress-lane-reconcile-20260803

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Related: #117861

What Problem This Solves

Fixes an issue where Telegram polling could stop making progress when a durable command was admitted before bot identity was available and replay later classified it into a different lane. The drain repeatedly reclaimed and released the same row, spinning SQLite and preventing polling shutdown.

Why This Change Was Made

The shared drain now applies the channel owner's stored-lane reconciliation policy consistently and attempts each row from a pending snapshot at most once per pass. Telegram preserves only the exact pre-identity control lane that the same payload derived before getMe(), so unrelated persisted-lane mismatches still fail closed.

This is the owner-boundary fix: generic drain scheduling owns bounded claim attempts, while Telegram owns the narrow pre/post-identity lane rule.

Current main was also red on check-lint after PR #116104 pushed chat-composer.ts over its max-lines budget. This PR carries the smallest behavior-neutral repair required by landing policy: the new mobile pointer-focus DOM policy now lives in the existing composer DOM helper.

User Impact

Telegram polling continues through durable control commands that arrive during startup, and shutdown no longer hangs on a tight ingress replay loop. Existing webhook lane-integrity checks remain enforced. The UI repair does not change pointer behavior.

Evidence

AI-assisted: yes. I reviewed the implementation, root cause, owner boundaries, red-main repair, and proof directly.

@vincentkoc vincentkoc self-assigned this Aug 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels Aug 3, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 3, 2026 01:42
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Aug 3, 2026
@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 9:53 PM ET / August 3, 2026, 01:53 UTC.

ClawSweeper review

What this changes

The PR prevents Telegram durable-ingress replay from repeatedly reclaiming a pre-identity control command whose later derived lane is busy, while preserving stored-lane integrity for unrelated mismatches.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer-owned PR open for normal merge review. The patch addresses a source-supported Telegram durable-ingress spin at the intended owner boundaries: the shared drain bounds one pass to one attempt per snapshot row, while Telegram retains only its tightly validated lane exception. No discrete correctness or security defect was found in the proposed patch; active current-head CI still needs to finish.

Priority: P1
Reviewed head: bc93ba8c72770104af96f62f9709abe2d47e990f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned reliability repair with direct regression coverage and reported Testbox evidence; remaining work is normal completion of the active merge checks.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports current-main reproduction, focused regressions, and exact-base Testbox evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports current-main reproduction, focused regressions, and exact-base Testbox evidence.
Evidence reviewed 6 items Current-main failure mechanism: Current main derives lane keys from current bot information for pending and claimed records, while the candidate list remains unchanged after a released claim; a rejected stored-lane reconciliation can therefore be selected again in the same pass.
Proposed owner-boundary repair: The branch turns snapshot candidate IDs into a set and removes each claimed ID before possible release; it applies the channel-owned reconciliation policy consistently when computing blocked lanes and the claimed lane.
Telegram exception remains narrow: The Telegram policy validates account/channel ownership and payload shape, then permits only defined legacy/canonical lane transitions; the claim-time inspection preserves a pre-identity control lane only when the same payload derived that lane before bot identity was available.
Findings None None.
Security None None.

How this fits together

Telegram polling first persists updates in the shared durable ingress queue, then a core drain claims and serializes them by lane before Telegram dispatches the update. Telegram owns how a stored lane may be reconciled once bot identity becomes available; the core drain owns bounded scheduling and claim lifecycle.

flowchart LR
  A[Telegram polling update] --> B[Durable ingress queue]
  B --> C[Core ingress drain]
  C --> D[Telegram lane policy]
  D --> E[Claimed update dispatch]
  E --> F[Polling progress and shutdown]
Loading

Before merge

  • Resolve merge risk (P1) - This changes queue scheduling and persisted Telegram lane reconciliation; an over-broad exception could serialize a valid update in the wrong lane, though the proposed Telegram predicate is deliberately narrow and existing rejection coverage reduces that risk.
  • Resolve merge risk (P1) - The current-head GitHub Actions run is still in progress, so merge should wait for its channel/runtime and type/lint gates rather than treating partial check results as final.
  • Complete next step (P2) - The PR is authored by a repository member and carries the protected maintainer label; it needs ordinary maintainer merge review and completion of active CI, not an automated repair branch.
Agent review details

Security

None.

PR surface

Source +49, Tests +49, Docs +1. Total +99 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 71 22 +49
Tests 1 49 0 +49
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 121 22 +99

Review metrics

Metric Value Why it matters
Production versus regression coverage 71 production-code lines added, 22 removed; 49 test lines added; 1 changelog line added The production growth is justified by a shared queue scheduling invariant and a narrowly owned Telegram lane rule, while the new regression test directly covers the same-pass spin bound.

Mantis proof suggestion

A proof-only Telegram transcript would directly demonstrate that a startup-time targeted control command drains without repeated replay and that polling remains responsive. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live proof: reproduce a startup-time targeted control command and verify it drains once while polling remains responsive.

Merge-risk options

Maintainer options:

  1. Finish current-head verification (recommended)
    Merge after the active channel/runtime and repository checks complete successfully on this exact head, with the shared drain and Telegram regressions retained.
  2. Request additional transport evidence
    If maintainers want stronger operator proof than the reported Testbox regressions, add a redacted restart-replay or live Telegram transcript showing the command drains and shutdown remains responsive.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Wait for the current-head required checks, including channel/runtime coverage, to complete successfully before merge.

Technical review

Best possible solution:

Merge the focused core scheduling bound and Telegram-specific reconciliation rule after current-head CI completes green; retain the existing fail-closed behavior for all lane changes outside the validated Telegram cases.

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

Yes. Current-main source shows the candidate snapshot is reused after a released claim while lane resolution can change after bot identity is available; the PR adds a focused regression for that scheduling pattern. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes. The best fix is to bound generic drain attempts in the shared owner while keeping Telegram’s exceptional stored-lane rule inside the Telegram plugin; a generic lane-bypass or Telegram-private claim loop would be a worse boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The defect can halt Telegram polling progress and block shutdown in an active channel workflow.
  • add merge-risk: 🚨 message-delivery: Persisted Telegram updates can be serialized by a different lane after identity becomes available, so this repair changes message-dispatch ordering behavior.
  • add merge-risk: 🚨 availability: The reported failure is a repeated SQLite claim/release loop that can prevent ingress draining and polling shutdown.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports current-main reproduction, focused regressions, and exact-base Testbox evidence.
  • add mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The repaired behavior affects Telegram command replay, polling progress, and shutdown responsiveness, which can be shown in a short redacted Telegram run.

Label justifications:

  • P1: The defect can halt Telegram polling progress and block shutdown in an active channel workflow.
  • merge-risk: 🚨 message-delivery: Persisted Telegram updates can be serialized by a different lane after identity becomes available, so this repair changes message-dispatch ordering behavior.
  • merge-risk: 🚨 availability: The reported failure is a repeated SQLite claim/release loop that can prevent ingress draining and polling shutdown.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports current-main reproduction, focused regressions, and exact-base Testbox evidence.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The repaired behavior affects Telegram command replay, polling progress, and shutdown responsiveness, which can be shown in a short redacted Telegram run.

Evidence

Acceptance criteria:

  • [P1] Confirm the current-head GitHub Actions run completes successfully.
  • [P1] Retain the focused shared-drain regression and Telegram persisted-lane security coverage.

What I checked:

  • Current-main failure mechanism: Current main derives lane keys from current bot information for pending and claimed records, while the candidate list remains unchanged after a released claim; a rejected stored-lane reconciliation can therefore be selected again in the same pass. (src/channels/message/ingress-drain.ts:751, f2af4e97b356)
  • Proposed owner-boundary repair: The branch turns snapshot candidate IDs into a set and removes each claimed ID before possible release; it applies the channel-owned reconciliation policy consistently when computing blocked lanes and the claimed lane. (src/channels/message/ingress-drain.ts:751, bc93ba8c7277)
  • Telegram exception remains narrow: The Telegram policy validates account/channel ownership and payload shape, then permits only defined legacy/canonical lane transitions; the claim-time inspection preserves a pre-identity control lane only when the same payload derived that lane before bot identity was available. (extensions/telegram/src/telegram-ingress-drain.ts:96, bc93ba8c7277)
  • Regression coverage: The added shared-drain test holds an active lane, admits a candidate with a rejected stored lane, and asserts exactly two claims total rather than a repeated same-pass reclaim; existing queue and Telegram webhook suites cover accepted and rejected lane reconciliation cases. (src/channels/message/ingress-drain-lanes.test.ts:8, bc93ba8c7277)
  • Feature-history provenance: The shared durable ingress monitor dates to the current-main refactor, while the earlier Telegram drain integration and durable engine were introduced in the same central area by the listed owners. (src/channels/message/ingress-drain.ts:1, ee0e3a4d478e)
  • Current-main and release check: The PR head is not contained in current main; the current main tip is after the latest release v2026.7.1, so this proposed repair is not already implemented or released. (extensions/telegram/src/telegram-ingress-drain.ts:65, f2af4e97b356)

Likely related people:

  • Peter Steinberger: Introduced the shared durable ingress monitor and has the most recent current-main history on the core drain and Telegram ingress area. (role: recent area contributor; confidence: high; commits: ee0e3a4d478e, 181da6f69c45; files: src/channels/message/ingress-drain.ts, extensions/telegram/src/telegram-ingress-drain.ts)
  • Ayaan Zaidi: Introduced the durable ingress drain engine and migrated Telegram ingress onto the shared core drain. (role: feature introducer; confidence: high; commits: fc6b9dad0b13, f7786a16cfe8; files: src/channels/message/ingress-drain.ts, extensions/telegram/src/telegram-ingress-drain.ts)

Rank-up moves

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

  • Wait for the current exact-head CI run to finish before merge.

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.

@vincentkoc
vincentkoc merged commit d93d07a into main Aug 3, 2026
139 of 150 checks passed
@vincentkoc
vincentkoc deleted the fix/beta8-ingress-lane-reconcile-20260803 branch August 3, 2026 01:58
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
* origin/main:
  refactor(agents): centralize terminal lifecycle outcomes (#118254)
  fix(scripts): warm gateway concurrency probes (#118364)
  test(discord): consolidate activity HTTP fixtures (#118314)
  fix(qa): restore prerelease validation (#118255)
  improve(tests): focus overflow compaction owner coverage (#118351)
  test(telegram): deduplicate dispatch fixtures (#118319)
  test(xai): consolidate realtime voice fixtures (#118318)
  fix(telegram): prevent durable ingress lane spins (#118357)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* fix(channels): prevent ingress lane reconciliation spins

* fix(ui): restore composer lint budget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui channel: telegram Channel integration: telegram maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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.

1 participant