Skip to content

fix: channel messages fail after manual restart - #123885

Merged
joshavant merged 1 commit into
mainfrom
fix/channel-manager-admission-context
Aug 14, 2026
Merged

joshavant merged 1 commit into
mainfrom
fix/channel-manager-admission-context

Conversation

@joshavant

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an issue where messages could fail with GatewayDrainingError after an operator stopped and restarted a channel through Gateway RPC, even though the Gateway and channel both reported ready.

Why This Change Was Made

Channel account lifetimes are now detached once at the channel manager's canonical startup boundary. Provider work, approval handlers, cleanup, and automatic replacements therefore remain process-owned instead of inheriting the short-lived RPC or timer admission context that requested startup.

The existing lifecycle implementation remains unchanged behind that owner boundary. Production LOC: +7/-1 (net +6); tests: +132/-0.

User Impact

Operators can manually restart a channel and continue receiving messages immediately, without requiring a full Gateway restart to recover the channel.

Evidence

  • Real Telegram burner reproduction on current main: after successful channels.stop and channels.start, the first ordinary message failed with GatewayDrainingError and retried six times while /readyz and channels.status remained healthy.
  • Same real Telegram scenario on this branch: the channel reported running, connected, and ready; the first ordinary message produced exactly one inbound execution, one mock-model request, and one successful Telegram delivery, with zero draining errors and zero remaining spool files.
  • Three manager-level regressions cover provider lifetime, approval-bootstrap descendants, and automatic replacements. The exact tests fail on pre-fix code (true, true, [false, true]) and pass after the repair.
  • node scripts/run-vitest.mjs src/gateway/server-channels.test.ts — 99 passed.
  • node scripts/run-vitest.mjs src/process/gateway-work-admission.test.ts — 18 passed.
  • Remote pnpm check:changed on Blacksmith Testbox — passed.
  • Focused formatting, lint, diff checks, and final autoreview — clean.

@clawsweeper

clawsweeper Bot commented Aug 14, 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 gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 7:31 PM ET / 23:31 UTC.

ClawSweeper review

What this changes

Detaches channel startup from the short-lived Gateway request or timer admission so manually restarted channels can keep processing messages.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer landing: the focused owner-boundary repair appears correct, but this protected maintainer PR still needs its exact-head checks to finish.

Priority: P1
Reviewed head: 399081abd286155e37ef696b16f99a72b7deb5b6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with concrete before/after behavior evidence and boundary-level regression coverage.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless records a real Telegram before/after scenario.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless records a real Telegram before/after scenario.
Evidence reviewed 6 items Current failure boundary: Current main starts the channel account task from the same manager startup flow, so async descendants inherit the initiating Gateway admission context.
Canonical repair point: The branch wraps the single internal startup boundary with the existing process-owned admission helper, covering RPC starts, startup, and automatic restart callers without adding a channel-specific workaround.
Existing sibling pattern: Gateway reload channel restarts already clear the initiating admission context before calling the same channel-start contract, supporting this ownership boundary.
Findings None None.
Security None None.

How this fits together

Gateway RPC and timers ask the channel manager to start transport accounts. Those accounts spawn provider, approval, cleanup, and restart work that must outlive the initiating request.

flowchart LR
  A[Gateway RPC or timer] --> B[Channel manager]
  B --> C[Process-owned startup]
  C --> D[Channel account task]
  D --> E[Inbound execution]
  E --> F[Channel delivery]
Loading

Before merge

  • Resolve merge risk (P1) - Required exact-head checks are still in progress; merge only after they complete successfully.
  • Complete next step (P2) - No mechanical repair remains; await exact-head validation and maintainer landing review.
Agent review details

Security

None.

PR surface

Source +6, Tests +132. Total +138 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 1 +6
Tests 1 132 0 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 139 1 +138

Review metrics

Metric Value Why it matters
Production versus tests production +6 net, tests +132 The small ownership-boundary change is backed by three focused lifecycle regressions.

Merge-risk options

Maintainer options:

  1. Complete exact-head validation (recommended)
    Merge after the running required checks complete successfully on the reviewed head, preserving the process-owned startup boundary.

Technical review

Best possible solution:

Keep one process-owned wrapper at the channel manager’s canonical startup boundary, with the three lifecycle regressions retained as coverage.

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

Yes—current main starts the account task inside the RPC-owned async context, and the added released-root tests directly exercise the resulting admission failure.

Is this the best way to solve the issue?

Yes—the manager is the single owner of all channel-start callers, while a provider-only or RPC-only fix would miss approval bootstrap or automatic restart descendants.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A manually restarted channel can report ready while rejecting ordinary inbound work.
  • add merge-risk: 🚨 availability: The PR changes the admission ownership that determines whether a live channel can start follow-up work.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless records a real Telegram before/after scenario.

Label justifications:

  • P1: A manually restarted channel can report ready while rejecting ordinary inbound work.
  • merge-risk: 🚨 availability: The PR changes the admission ownership that determines whether a live channel can start follow-up work.
  • 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. Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless records a real Telegram before/after scenario.

Evidence

What I checked:

  • Current failure boundary: Current main starts the channel account task from the same manager startup flow, so async descendants inherit the initiating Gateway admission context. (src/gateway/server-channels.ts:499, 2ce443d9a46b)
  • Canonical repair point: The branch wraps the single internal startup boundary with the existing process-owned admission helper, covering RPC starts, startup, and automatic restart callers without adding a channel-specific workaround. (src/gateway/server-channels.ts:1072, 399081abd286)
  • Existing sibling pattern: Gateway reload channel restarts already clear the initiating admission context before calling the same channel-start contract, supporting this ownership boundary. (src/gateway/server-reload-channel-restart.ts:17, 2ce443d9a46b)
  • Admission contract: The existing helper exits the current AsyncLocalStorage root for process-lifetime work, while subordinate admission rejects a released inherited root. (src/process/gateway-work-admission.ts:355, 2ce443d9a46b)
  • Regression coverage: The added tests cover the released request root, approval-bootstrap descendants, and automatic replacements; these are behavior checks at the manager boundary rather than provider-specific assertions. (src/gateway/server-channels.test.ts:337, 399081abd286)
  • History and current-main status: The manager and admission implementation appear to date to the same recent main commit; the PR head is not contained in current main or any local release tag. (src/gateway/server-channels.ts:500, 36c440aa2b1e)

Likely related people:

  • Peter Steinberger: Blame attributes the startup boundary to the commit that added the current manager and Gateway admission modules. (role: introduced the current channel-manager and admission implementation; confidence: high; commits: 36c440aa2b1e; files: src/gateway/server-channels.ts, src/process/gateway-work-admission.ts)

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.

@joshavant
joshavant merged commit ed106bd into main Aug 14, 2026
190 checks passed
@joshavant
joshavant deleted the fix/channel-manager-admission-context branch August 14, 2026 23:37
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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