Skip to content

fix(channels): preserve messages stalled before adoption - #132409

Closed
PollyBot13 wants to merge 4 commits into
openclaw:mainfrom
PollyBot13:fix/ingress-stall-retry-fence
Closed

PollyBot13 wants to merge 4 commits into
openclaw:mainfrom
PollyBot13:fix/ingress-stall-retry-fence

Conversation

@PollyBot13

@PollyBot13 PollyBot13 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Related: #127229
Supersedes #120419 with @Grynn’s agreement.

What Problem This Solves

Fixes silently lost channel messages when delivery stalls before turn adoption and retry races the original dispatch or deferred transport bookkeeping.

User Impact

Stalled messages remain recoverable and replay in lane order. Unrelated conversations continue, and monitor shutdown leaves an unfinished claim recoverable by its successor. An abort-ignoring participant can still hold its own lane until it settles or the monitor restarts: this is the preservation-first policy accepted by @Patrick-Erichsen on September 10, not a new policy in this reconciliation.

Why This Change Was Made

The shared drain retains claim ownership and heartbeat until dispatch/deferred bookkeeping quiesces. Dispatch-idle observation stays separate from watchdog settlement. Telegram treats an owner-aborted deferred update as incomplete rather than consuming its replay watermark.

The October 3 reconciliation merges main without rewriting contributor/maintainer history. It preserves main’s adoption finalization, early ownership registration, token-fenced writes and joined disposal. It also cancels a watchdog-owned wait on direct disposal and checks live drain authority immediately before delayed retry release; ordinary late terminal settlements retain their existing contract. Retry backoff remains measured from durable release, not from the watchdog deadline.

No queue schema, dependencies, routing or production Gateway changes. Cohesive private helper/test-support extractions satisfy current main’s file-growth ratchets without removing coverage or changing suite fixture order; the existing polling state-wait helper moves unchanged into its test-support module.

Evidence

Current reconciliation

  • Head: 606f04bfa59b744c17b5ec26679de940442904d6; integrated main: 66cbf25fa6243566a1965c4a4906f588af7c8e3b.
  • 346 focused tests passed across drain/watchdog/monitor/inspection, Mattermost ingress, Telegram bot/polling/webhook and Zalo ingress (6 wrapper shards, 277.14 s). After the final write guard and helper extractions, 94 core cases and the relocated webhook retry case passed; all four relocated bot outcome/tracker cases passed after correcting their fixture callback (15.23 s wrapper wall time).
  • The two new fake-timer direct-disposal cases demonstrably fail before the fix: the retired watchdog invokes queue.release once. Both pass after the fix, with the durable row still claimed and its attempt count unchanged. Tests cover no external signal and a still-live external signal, while existing late-terminal-settlement tests remain green.
  • Final lint-cleanup/extraction reruns: all 21 watchdog cases passed (37.46 s wrapper), and all 40 polling cases passed (36.20 s wrapper). The production watchdog uses the same captured state and the polling fixture retains its 200 ms completion delay.
  • Real SQLite/production-monitor tests prove unrelated-lane progress while a stalled claim is fenced, bounded stop, successor recovery exactly once and stale-owner rejection. Polling and webhook tests prove same-lane ordered retry and durable acknowledgement before processing.
  • All 39 commands in the current native changed-file check plan passed against pinned main: formatting, core/test and extension/test types, scoped type-aware lint, full-tree unused exports (zero findings), file-growth/suppression guards, plugin/import boundaries, database/schema/auth/webhook guards and runtime import cycles. Evidence combines the initial pipeline, resumed failed/unrun commands, and relevant final-extraction reruns; it is not one uninterrupted run. The committed tree matches the final validated staged tree exactly. Diff whitespace check is clean.
  • Clean-context Astra review: PASS, no remaining actionable P0–P2 findings. The local CLI AutoReview route returned reviewer_unavailable/engine failure and is not represented as completed review coverage.
  • Prior-head CI failures were attributed to a provider declaration type error (fixed on main by fix(workers): restore installation type checks #159629), premature hello presence publication (fixed on main by refactor(cli): deslop CLI and fix Gateway presence publication #159554), and this branch’s unused monitor import (removed here). Cancelled checks and aggregate gates were not misclassified as source proof. Fresh exact-head hosted CI and ClawSweeper review: pending at publication.

Historical isolated Gateway proof (not this head)

At 4250c7a56bed066a5b1a52977c18f4ccf0a5dfd6, an ephemeral built Gateway exercised production Telegram ingress against a loopback Bot API and repository mock OpenAI provider. A 1,000 ms watchdog fired at 1,002 ms; provider admission and outgoing replies were ordered first, recovered stalled message, follower, with the stalled marker admitted exactly once. Gateway cleanup completed; no real Telegram account or production service was used.

{
  "head": "4250c7a56bed066a5b1a52977c18f4ccf0a5dfd6",
  "passed": true,
  "transport": "loopback Telegram Bot API",
  "runtime": "ephemeral Gateway, repository mock OpenAI provider",
  "watchdogObserved": true,
  "providerMarkerOrder": ["PR132409-FIRST-DONE", "PR132409-STALLED-RECOVERED", "PR132409-FOLLOWER-DONE"],
  "outboundTexts": ["PR132409-FIRST-DONE", "PR132409-STALLED-RECOVERED", "PR132409-FOLLOWER-DONE"]
}

This historical full-Gateway proof is not an exact-head or authenticated Telegram service claim. Current reconciliation proof is the actual shared-drain/monitor and transport boundary tests above; fresh hosted CI/review and maintainer landing remain separate gates.

Owner acceptance

  • Boundary: shared ingress claim/settlement ownership plus Telegram replay bookkeeping; critical durable-message recovery, retaining the accepted preservation policy.
  • Falsifier: lost/duplicate stalled-message admission, a follower admitted first, retired watchdog release, or shutdown blocked on that old owner.
  • Reviewability: one recovery invariant; private watchdog/wake mechanics and relocated tests stay under existing owners. No new public SDK or schema expansion in this reconciliation.
  • Rollback: revert the landed PR change. No runtime deployment is part of this branch update.

AI-assisted implementation and validation under human authorization. Original implementation: @PollyBot13. Maintainer compatibility work: @steipete and @Kimiyu-186; contributor ancestry retained.

Historical maintainer collaboration: existing review session.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram channel: zalouser Channel integration: zalouser size: L labels Aug 29, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 3:10 PM ET / 19:10 UTC (Revision 18).

ClawSweeper review

What this changes

The branch preserves stalled incoming messages until dispatch and deferred bookkeeping settle, keeps owner-aborted Telegram updates replayable, and retires watchdog waits during disposal.

Merge readiness

✅ Ready for maintainer review

This remains a useful landing candidate: current main and v2026.9.8 still lack the dispatch-settlement fence. No concrete introduced defect was found, and the recorded production-path proof remains relevant to the reconciled implementation.

Priority: P1
Reviewed head: 606f04bfa59b744c17b5ec26679de940442904d6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent repair with relevant production-path evidence and focused lifecycle regressions, without an actionable correctness finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The historical isolated Gateway trace exercises production Telegram ingress through a real loopback transport client, observes watchdog recovery, and delivers the stalled marker once before its follower. It belongs to source 4250c7a, while reported current-head disposal, restart, polling, and webhook checks supplement the reconciliation; no exact-head Gateway replay is claimed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The historical isolated Gateway trace exercises production Telegram ingress through a real loopback transport client, observes watchdog recovery, and delivers the stalled marker once before its follower. It belongs to source 4250c7a, while reported current-head disposal, restart, polling, and webhook checks supplement the reconciliation; no exact-head Gateway replay is claimed. No stored-data contract changes.
Evidence reviewed 12 items Pinned introduction: Reviewed the complete introduced delta from the pinned merge base to the exact original PR head. The supplied test merge is stale and was not used to claim removal of current-main behavior.
Current-main necessity: Fetched main aborts the stalled dispatcher and immediately starts failure disposition without awaiting dispatch or deferred-participant quiescence. The central repair is still absent.
Latest-release check: The v2026.9.8 source also settles watchdog claims without the proposed quiescence fence. Its source was inspected through the GitHub contents API after local historical-blob retrieval failed.
Findings None None.
Security None None.

How this fits together

Channel transports durably queue incoming messages before the shared ingress drain dispatches them to agent turns. Claim settlement and Telegram replay bookkeeping determine whether stalled messages remain recoverable or become completed records.

flowchart LR
 A[Incoming channel message] --> B[Durable ingress queue]
 B --> C[Claim and dispatch]
 C --> D{Turn adopted?}
 D -->|Yes| E[Complete claim]
 D -->|Watchdog expires| F[Wait for old dispatch]
 F --> G[Release for ordered retry]
 F -->|Monitor stops| H[Retain for successor recovery]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +250, Tests +498. Total +748 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 6 322 72 +250
Tests 11 726 228 +498
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 1048 300 +748

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #127229
Summary: This branch is a candidate repair for the documented watchdog-release and Telegram replay-ordering failure.

Members:

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

Technical review

Best possible solution:

Keep one shared settlement owner that safely retries quiescent attempts, preserves unfinished claims for successor recovery, and allows unrelated conversations to progress.

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

Yes, source establishes the race: hold a pre-adoption dispatch beyond the watchdog and current main releases its claim before that dispatch settles. This read-only review did not execute a failing current-main run.

Is this the best way to solve the issue?

Yes. The patch repairs the shared settlement owner and Telegram tracker at their existing boundaries while retaining the canonical retry policy and restart recovery path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against bdd44c5260d1.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The repair addresses lost or falsely completed accepted channel messages, with recent production corroboration.
  • merge-risk: 🚨 compatibility: The recorded accepted preservation policy changes timeout recovery from immediate release to retaining an unsettled claim.
  • merge-risk: 🚨 availability: The accepted tradeoff permits an abort-ignoring participant to hold its lane until settlement or monitor restart.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The historical isolated Gateway trace exercises production Telegram ingress through a real loopback transport client, observes watchdog recovery, and delivers the stalled marker once before its follower. It belongs to source 4250c7a, while reported current-head disposal, restart, polling, and webhook checks supplement the reconciliation; no exact-head Gateway replay is claimed. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The historical isolated Gateway trace exercises production Telegram ingress through a real loopback transport client, observes watchdog recovery, and delivers the stalled marker once before its follower. It belongs to source 4250c7a, while reported current-head disposal, restart, polling, and webhook checks supplement the reconciliation; no exact-head Gateway replay is claimed. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction: Reviewed the complete introduced delta from the pinned merge base to the exact original PR head. The supplied test merge is stale and was not used to claim removal of current-main behavior. (606f04bfa59b)
  • Current-main necessity: Fetched main aborts the stalled dispatcher and immediately starts failure disposition without awaiting dispatch or deferred-participant quiescence. The central repair is still absent. (src/channels/message/ingress-drain.ts:310, bdd44c5260d1)
  • Latest-release check: The v2026.9.8 source also settles watchdog claims without the proposed quiescence fence. Its source was inspected through the GitHub contents API after local historical-blob retrieval failed. (src/channels/message/ingress-drain.ts:300, fc23bc864e45)
  • Settlement and disposal: The watchdog waits for quiescence or retirement; failure disposition rechecks stopped state before delayed release. Direct-disposal regressions retain the claimed row and unchanged attempt count, while retained tests cover late terminal settlement and successor token fencing. (src/channels/message/ingress-drain-watchdog.ts:29, 606f04bfa59b)
  • Telegram replay owner: Deferred tracker completion now rejects owner-aborted pending work. Inspection of the participant, tracker, and ingress monitor confirms that this preserves retry eligibility at the existing transport bookkeeping owner. (extensions/telegram/src/bot-core.ts:169, 606f04bfa59b)
  • Recorded production-path proof: The captured PR body records an isolated built Gateway using production Telegram ingress and a loopback Bot API at source 4250c7a: the watchdog fired at 1,002 ms, the stalled marker was admitted once, and replies arrived before the same-lane follower. This is historical after-fix proof, not an exact-head or authenticated Telegram run; reported current-head restart, disposal, polling, and webhook checks supplement it. (4250c7a56bed)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • PollyBot13: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Patrick-Erichsen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (17 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-05T18:19:31.459Z sha fee6336bcdc357ff0eeda22babe46e8902f71bfc :: blocked before merge. :: none
  • reviewed 2026-09-07T21:18:21.494Z sha 4250c7a :: blocked before merge. :: none
  • reviewed 2026-09-10T23:55:10.846Z sha 217ef6a :: blocked before merge. :: none
  • reviewed 2026-09-11T00:03:17.226Z sha 217ef6a :: blocked before merge. :: none
  • reviewed 2026-09-11T00:21:55.644Z sha 217ef6a :: blocked before merge. :: none
  • reviewed 2026-09-27T11:48:18.260Z sha cc8f0d0 :: needs maintainer review before merge. :: none
  • reviewed September 27, 2026, 8:14 AM ET / 12:14 UTC (Revision 16) sha unknown :: needs maintainer review before merge. :: none
  • reviewed September 27, 2026, 8:14 AM ET / 12:14 UTC (Revision 17) sha unknown :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 29, 2026
@PollyBot13
PollyBot13 force-pushed the fix/ingress-stall-retry-fence branch from 7db767c to 3cdb9d5 Compare August 29, 2026 18:24
@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 29, 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 exact_review_queue).
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 the proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. label Aug 29, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. labels Sep 5, 2026
Preserve terminal quiescence before retry while retaining upstream joined shutdown settlement.
@PollyBot13

Copy link
Copy Markdown
Contributor Author

Reconciled this PR with current main in cc8f0d00870; it is mergeable again. The conflict resolution preserves main's joined claim-settlement shutdown and the PR's stalled-message retry fence. Focused core/channel tests and an independent ownership review passed; fresh hosted CI is still running. The earlier loopback proof is explicitly identified in the PR body as evidence from the prior head, not exact-head proof.

This update is also in response to the stale notice. I cannot remove the stale label from this contributor account; maintainer review and landing remain with the assigned owner.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Sep 28, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Sep 28, 2026
@itsnimbus

Copy link
Copy Markdown

We've been running this fix in production on a self-hosted multi-agent gateway (Discord + Telegram, ~20 agents) since 2026.9.5, and it's still needed on v2026.9.7. In stock 9.7, ingress-drain still releases a stalled claim for retry while the original dispatch is running. In a dist-level race harness, the stock release fired at ~205 ms while the dispatch returned at ~800 ms; with the fix, the release waits for dispatch quiescence.

We rebased the PR onto v2026.9.7 (c074824). Three things needed adjusting for 9.7, in case it helps the rebase here:

  1. stop() hang. 9.7's monitor stop() now ends with drain.dispose({ waitForSettlements: true }). If the stall settlement waits for the stalled dispatch, a hung owner never settles and stop() never returns. We end that wait on drain abort/dispose (settle without a write, not counted as a failure). The claim stays fenced, and the next owner's stale-claim recovery picks it up.
  2. Telegram webhook retry timing. The deferred release charged a second full backoff after the handler finally returned. We count the backoff from the watchdog deadline, so a quick finish keeps stock retry timing.
  3. Tests that assert the old release-while-running behaviour: ingress-monitor.inspection.test.ts ("joins pending inspection after the watchdog retires its claim") and the Telegram polling-session timed-out retry test. We updated both to assert that the claim stays fenced while dispatch or inspection runs, and settles afterwards.

Gate: 2× vitest over src/channels/message, plugin-sdk ingress, mattermost, telegram, discord, slack, signal and whatsapp inbound. 11383/11384 passed both times; the one failure is mattermost/slash-http.boundary.test.ts, which needs 127.0.0.2+ loopback aliases (macOS) and fails identically on stock 9.7. tsgo core, plugin-sdk and extension test configs are clean.

Happy to share the rebased diff if it's useful.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 1, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 1, 2026
amittell added a commit to amittell/openclaw that referenced this pull request Oct 1, 2026
Carries openclaw#132409 ("fix(channels): preserve messages stalled
before adoption", open; issue openclaw#127229, P1 message loss) onto the 9.6 carry.
Applied as diff(9a4114b..217ef6a), the PR's own base to its
Sept 10 head, by 3-way merge onto 1d5d6c8.

Why that head and not the Sept 27 merge head cc8f0d0: the 9.6 tag's
ingress files equal main of 2026-09-22 (814a7e7). cc8f0d0 merges
main of 09-27 and integrates the PR with openclaw#158637's claim custody through
settlement, which the tag does not have; applied here it conflicts in 4
production files. 217ef6a predates openclaw#158637, applies with one import
conflict, and has a green hosted CI run (34543782080). The 09-27 head adds
an abort-aware quiescence wait and idle-wake accessors that only openclaw#158637's
retained owner and main's reworked monitor use. On this tree the owner is
deregistered at abort, so a replacement drain recovers the claim at once;
settleStalledClaim checks isStopped() only between attempts, so an attempt
already waiting for quiescence still makes its one release write after
stop, and the claim token fences that write.

What it fixes on the bots: a second update from the same chat waits in
grammY sequentialize behind a deferred handler with no heartbeat. At the
300 s adoption watchdog the drain released it for retry while the first
callback was still blocked; the retry met the in-process update tracker
as a duplicate, returned no outcome, and the row was completed without a
recorded processing outcome (rh-bot, updates 735980139 and 735980143,
2026-09-29). Now the stalled claim keeps its lease and heartbeat until the
old dispatch and deferred bookkeeping quiesce, then settles the retry; a
separate stall-settlement wake repumps the monitor; Telegram's tracker
records an owner-aborted deferred update as incomplete.

Conflict resolution:
- ingress-monitor.ts: import-only; the fork's split imports kept, the
  wake scheduler import added.
- ingress-drain.watchdog.test.ts: main's two tests added after 09-08 kept;
  in the PR's rewritten "rearms a live deferred wait" test the tag's
  1_666 ms heartbeat-cadence assertion is kept (cc8f0d0 dropped it).
- polling-session.test.ts: the PR's hunk for "requeues buffered spooled
  claims when deferred processing times out" is not applied. At the tag
  the deferred participant settles itself on owner abort (openclaw#150080), so
  the claim is released at the stall without a manual settle; main later
  deleted the test (openclaw#155040).

ingress-drain.ts equals 217ef6a plus exactly the tag's own 09-08..09-22
drift; drain-state, drain-wake, drain.test, zalouser and mattermost tests
are byte-identical to 217ef6a.

Original implementation by PollyBot13, with the maintainer fixup in
217ef6a; see openclaw#132409. Drop this commit when an upstream equivalent
reaches the fork's base tag.
amittell added a commit to amittell/openclaw that referenced this pull request Oct 1, 2026
…-cap ratchet

check:line-cap-ratchet --base 1d5d6c8 refused the carry: the PR's test
changes grew three files that are already over the cap here (upstream main
has since shrunk them). bot.create-telegram-bot.test.ts 5953 -> 5994,
polling-session.test.ts 3889 -> 3895, webhook.test.ts 2839 -> 2841.

- The PR's new update-tracker test moves unchanged into
  bot.create-telegram-bot.spooled-owner-abort.test.ts, on the same harness;
  bot.create-telegram-bot.test.ts is back to its 1d5d6c8 blob.
- polling-session.test.ts drops its local copy of waitForAbortSignal for
  the SDK's (openclaw/plugin-sdk/runtime, same behavior).
- webhook.test.ts builds its message fixture with the spool test-support's
  directUpdate(id, 111, text), the same fields, and drops its local type.

No test is removed or weakened. Ratchet OK; webhook 111/111, polling-session
81/81, bot.create-telegram-bot 163/163, the new file 1/1.
amittell added a commit to amittell/openclaw that referenced this pull request Oct 1, 2026
A dated section for the four commits on top of the deployed 1d5d6c8:
why version-3 carriers lost the Telegram body in the 9.6 pull-forward of
openclaw#151099 and what carrierText changes; why openclaw#132409 is carried at its 09-10
head 217ef6a and not cc8f0d0, with the conflict resolutions and the
held-lane behavior change on channels that hold the lane; the line-cap
ratchet fix; the review findings fixed and left; and the validation on this
tree, including the two changed-gate failures shown byte-identical at
1d5d6c8. Records rh-bot's unbuilt ad67756 and the local variant
branch that carries the same four commits onto it.
@alihamie

alihamie commented Oct 1, 2026

Copy link
Copy Markdown

I am experiencing this same bug in 9.2 as well

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 2, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 2, 2026
Merge current main while retaining dispatch/deferred quiescence and token-fenced
settlement. Retire watchdog-owned release waits on direct disposal and recheck
drain authority immediately before delayed retry release.

Preserve main's finalization and early ownership registration, remove the unused
monitor import, and adapt the inspection fixture to retained claim ownership.
Extract cohesive private watchdog and Telegram test helpers to satisfy current
file-growth ratchets without dropping coverage or changing suite fixture order.

Validated with 346 focused tests, post-extraction core/transport cases, the
failing-before direct-disposal regression, changed-file gates and independent
ownership review. No queue schema, dependencies or runtime deployment changes.
@openclaw-barnacle openclaw-barnacle Bot added size: XL and removed size: L stale Marked as stale due to inactivity labels Oct 3, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

amittell added a commit to amittell/openclaw that referenced this pull request Oct 22, 2026
…un found

Upstream tests that fail alone on the base a1ccb69 and pass alone on
bare v2026.10.5 because they assert behaviour the fork changes on purpose. Each
pin passes here and fails with the fork code reverted to 10.5's.

- main-session-recovery-yield: the kept dead-generation fence rule (Alex,
  2026-10-21) settles the other-generation fence, so the claim is not_required.
- ingress-monitor.admission: openclaw#132409 keeps the claim fenced through the stall
  watchdog. 10.5 moved this test here from the deleted
  ingress-monitor.inspection.test.ts, whose fork pin the carry dropped.
- server.health-store-scheduling: openclaw#89526 re-collects health when a config
  publication lands mid-collection; the test waits for in-flight collections
  before counting reads.
- telegram-recovery-notice-send: fork #13 claims a restart only for a cycle
  with cause gateway_restart.
- gateway-tool.assembly: a non-owner turn sees a refusing gateway stub
  (owner-only tool stubs); the real tool stays off its authorized surface.
- run.plugin-runtime-refresh: the fork's silent-stop nudge adds a third
  attempt for message-tool-only turns; media and provenance assertions are
  unchanged.
amittell added a commit to amittell/openclaw that referenced this pull request Nov 11, 2026
…claim hold

telegram-ingress-coalescing.e2e.test.ts > "keeps a timed-out update
retryable while its original middleware is still waiting" fails on the
stack, on 3eefd13 and on the deployed 11.1 carry (eee763b), and
passes on bare v2026.11.2. Upstream added it with openclaw#169202 (6d624f3,
2026-10-15). There the stall watchdog re-queues a timed-out update as
pending with handler-timeout while its original middleware still waits,
and the retry records "Telegram update processing is still pending"
until the original returns.

The fork carries upstream openclaw#132409 (closed upstream unmerged; carried
since da9b206fc93, now through 1e127ad). Its stall watchdog
(ingress-drain-watchdog.ts) releases the timed-out claim only once the
original dispatch has quiesced (beforeRetryRelease ->
waitForQuiescenceOrStop). The test pinned openclaw#169202's in-between state, so
it cannot pass with openclaw#132409. Alex chose to keep openclaw#132409, so the
upstream test is replaced by a pin of the fork's behavior, marked FORK
DIVERGENCE (openclaw#132409): "holds a timed-out update's claim until its
original middleware returns, then retries it once".

The pin lives in a new fork-only file,
extensions/telegram/src/telegram-ingress-claim-hold.e2e.test.ts, with the
subset of the coalescing harness a text-only case needs (the same mocks,
fixture and import order). The upstream file was already over the
1,000-line test cap at the tag (1,014 counted lines, so oxlint max-lines
fails on it). Moving the replaced case out brings it to 928, and later
upstream merges of that file only see the case removed.

The assertions are what an instrumented run measured on the stack:
- at 300 s the watchdog has fired, and 802 is still claimed with
  attempts 0 and no lastError. It is not pending and not failed.
- 803, admitted then, stays pending behind it, and 802 is not handed to
  handleUpdate again.
- after 801 finishes and the drain runs, handleUpdate has seen 802, 802,
  803 (the original, then the one retry), and the downstream turns are
  "busy turn", "deliver this later", "deliver after the retry".
- nothing is left pending, claimed or failed, both updates are
  tombstoned, and a redelivered 802 is skipped.

The same measurement shows no message loss: the update is processed
once, and in order.

Proof (M4, Node 26.12.1, node scripts/run-vitest.mjs run --config
test/vitest/vitest.e2e.config.ts <file>), on 1daeda2 plus this commit:
- telegram-ingress-coalescing.e2e.test.ts 20/20 passed.
  telegram-ingress-claim-hold.e2e.test.ts 1/1 passed.
- Red check (throwaway commit): with the watchdog's quiescence wait
  skipped (env toggle), the pin fails at the 300 s assertion, because 802
  is already pending with lastError "Channel ingress claim->adoption
  stalled for event 802 ... (handler-timeout)". Without the toggle it
  passes.
- Gates: check-line-cap-ratchet --base v2026.11.2 rc 0, run-oxlint on
  both files rc 0, check-test-mock-exports --base v2026.11.2 rc 0 (the
  new file's three isolating mocks carry mock-isolation reasons),
  tsgo:extensions:test rc 0, and oxfmt --check on both files rc 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost channel: telegram Channel integration: telegram channel: zalouser Channel integration: zalouser clawtributor-review Clawtributor pull request awaiting prioritized maintainer review merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: XL stale Marked as stale due to inactivity 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.

5 participants