Skip to content

fix(channels): scope HTTP routes to account lifetimes - #133297

Merged
steipete merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:feat/issue-132886
Sep 1, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:feat/issue-132886

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #132886

What Problem This Solves

Channel recovery can repeatedly fail when a timed-out account task leaves its HTTP route behind. Account start tasks and bounded stop attempts now own separate revocable route leases. Recovery revokes abandoned ownership before admitting a replacement, so late callbacks cannot replace the new handler or restore withdrawn ingress.

The maintainer pass also fixes two gaps in the initial implementation: asynchronous stop hooks run in the correct Gateway registry, and dynamic callers borrowing a static api.registerHttpRoute entry cannot remove it during cleanup. Shared dynamic routes retain independent holders. Zalo now uses that central lifetime owner, removing its separate reference count and redundant cleanup state.

Evidence

  • Reproduced four Gateway failures and two static-route cleanup failures before the maintainer repair. The final owner/sibling suite passes 232 tests: Gateway 115, plugins 66, Zalo 51.
  • Real loopback HTTP requests through the production Gateway server cover late start and stop callbacks after both successful and failed replacement. The replacement response remains intact; a deliberately withdrawn route remains 404. Retained registry references and old unregister callbacks cannot reverse either result.
  • Final Gateway rerun passes 115/115. node scripts/check-changed.mjs -- <all nine changed files> passes formatting, production/test type checks, lint, SDK boundaries, import-cycle checks and repository guards. The full production build passes; all five production source hashes match the final candidate.
  • Fresh independent Codex review reports no actionable P0–P2 findings and verifies source integrity.

The first published-head CI run exposed a separate escaped-output test race: the fixture published readiness before finishing IPC, allowing timeout cleanup to kill its parent and cause an unhandled EPIPE. The fixture now publishes readiness from its disconnect event. The original full file passed 50 tests, and forcing the bad ordering reproduced the exact CI assertion failure. The repaired full file passes all 50 tests under both normal and forced ordering, with every original assertion and deadline preserved. All selected script/test gates and a fresh full-candidate managed review pass. This test-only correction adds three net lines and is published in df64c6993078b4c42c70af135d29d5b857d61b30; CI on this exact commit now passes. The September1 10:18UTC ClawSweeper review has no actionable findings; its remaining exact-head CI move is satisfied.

These runs use an isolated Linux worker and synthetic channel hooks. Gateway HTTP behavior is real; external Zalo account traffic is not exercised.

When replacement preflight fails, abandoned ingress stays withdrawn and the account records its stopped/error state. The plugin architecture documentation now explains this availability behavior and the distinction between registry-owned static routes and shared dynamic routes. Existing stop deadlines and recovery ordering are preserved.

Whole-PR production delta is +162/−137, net +25; tests/support +303/−58, docs +2. The shared 38-line capability primitive moves out of services so account callbacks and service lifetimes use the same revocation mechanism; a service-only scope cannot represent a settled start task and its later independent stop attempt. The maintainer repair itself adds three net production lines: independent shutdown ownership is offset by simpler registry state. Configuration, schemas, persistence and public API surfaces are unchanged.

Thanks @zhangguiping-xydt for the original repair.

@clawsweeper

clawsweeper Bot commented Aug 30, 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 channel: zalo Channel integration: zalo gateway Gateway runtime size: M labels Aug 30, 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. 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. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 6:29 AM ET / 10:29 UTC.

ClawSweeper review

What this changes

This PR binds dynamically registered Gateway HTTP routes to channel account start and stop attempts so abandoned callbacks cannot retain or replace recovered ingress.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open. Current main still lacks the channel-account route lease, and the introduced lifecycle and registry changes address that gap without a concrete correctness or security defect found; the stale test-merge snapshot means final integration should be refreshed against current main before landing.

Priority: P1
Reviewed head: df64c6993078b4c42c70af135d29d5b857d61b30

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused owner-boundary coverage and credible production-path HTTP evidence; current-main integration freshness is the remaining material confidence reducer.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The branch’s changed owner is the channel lifecycle manager, and the supplied evidence describes an isolated-worker run that sends real loopback HTTP requests through the Gateway server; the introduced test source verifies the observed recovered handler remains reachable and a withdrawn route remains 404 after late start or stop callbacks.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The branch’s changed owner is the channel lifecycle manager, and the supplied evidence describes an isolated-worker run that sends real loopback HTTP requests through the Gateway server; the introduced test source verifies the observed recovered handler remains reachable and a withdrawn route remains 404 after late start or stop callbacks.
Evidence reviewed 7 items Current-main gap: Current main starts channel accounts under a route-registry scope without a capability lease, so it does not contain this PR’s lifecycle-bound route ownership repair.
Introduced owner-boundary repair: The branch creates an account capability lease, revokes it before timed-out-task replacement, and supplies it to the route-registry scope around start callbacks.
Late-callback and shared-holder behavior: The route registry rejects registration from an expired async scope and retains independent dynamic holders until the final holder releases, while a static route has no dynamic holder and cannot be removed by a borrower.
Findings None None.
Security None None.

How this fits together

Channel plugins register HTTP ingress in the Gateway’s plugin route registry while account lifecycle code starts, stops, and recovers accounts. The lease makes route registration expire with the owning lifecycle attempt while preserving static plugin routes owned by the registry.

flowchart LR
  A[Channel account lifecycle] --> B[Start or stop attempt]
  B --> C[Capability lease]
  C --> D[Gateway route registry]
  D --> E[HTTP ingress handler]
  B --> F[Timed-out recovery]
  F --> C
  C --> G[Route cleanup or retained owner]
Loading

Before merge

  • Resolve merge risk (P1) - Current main has substantially changed the lifecycle surface after this branch’s base, while the supplied test merge is stale; refresh the merged-head lifecycle proof before landing to avoid an availability regression from integration drift.
  • Complete next step (P2) - No narrow mechanical repair is outstanding; a maintainer should refresh current-main integration evidence and complete normal merge review.
Agent review details

Security

None.

PR surface

Source +25, Tests +245, Docs +2. Total +272 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 162 137 +25
Tests 4 303 58 +245
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 467 195 +272

Review metrics

Metric Value Why it matters
Production versus test delta production +162/-137 (net +25); tests/support +303/-58; docs +2 The production growth introduces one shared lifecycle-lease primitive while removing the Zalo-specific reference-count cleanup; the branch body explains why a service-only lease cannot own independent account stop attempts.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #132886
Summary: This PR explicitly targets the open channel recovery route-conflict report and implements its proposed core lifecycle repair.

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 integration proof (recommended)
    Rebase or otherwise validate the clean merge against current main, then rerun the Gateway route-recovery and HTTP-registry coverage on that resulting head.
  2. Accept branch-only evidence
    Merge using the existing exact-branch evidence while accepting that later lifecycle changes were not exercised in the final merged shape.

Technical review

Best possible solution:

Land the generic lifecycle lease only after current-main integration confirms that start and stop routes cannot be resurrected by abandoned callbacks while registry-owned static routes remain intact.

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

Yes, source reproducibly identifies the timed-out account task retaining its route while recovery starts a replacement; the introduced test encodes start and stop variants through a real loopback Gateway HTTP server, though this review did not execute contributor code.

Is this the best way to solve the issue?

Yes, the shared lease at the channel lifecycle and route-registry boundary is preferable to restoring per-plugin route replacement because it revokes stale authority centrally and retains genuine cross-owner conflict checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: A timed-out channel teardown can leave recovery unavailable until manual intervention, interrupting channel message handling.
  • merge-risk: 🚨 availability: The patch changes timeout recovery and HTTP ingress cleanup for running channel accounts, so final current-main integration matters before merge.
  • 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 (linked_artifact): The branch’s changed owner is the channel lifecycle manager, and the supplied evidence describes an isolated-worker run that sends real loopback HTTP requests through the Gateway server; the introduced test source verifies the observed recovered handler remains reachable and a withdrawn route remains 404 after late start or stop callbacks.
  • proof: sufficient: Contributor real behavior proof is sufficient. The branch’s changed owner is the channel lifecycle manager, and the supplied evidence describes an isolated-worker run that sends real loopback HTTP requests through the Gateway server; the introduced test source verifies the observed recovered handler remains reachable and a withdrawn route remains 404 after late start or stop callbacks.

Evidence

What I checked:

  • Current-main gap: Current main starts channel accounts under a route-registry scope without a capability lease, so it does not contain this PR’s lifecycle-bound route ownership repair. (src/gateway/server-channels.ts:906, 90dba1a51877)
  • Introduced owner-boundary repair: The branch creates an account capability lease, revokes it before timed-out-task replacement, and supplies it to the route-registry scope around start callbacks. (src/gateway/server-channels.ts:628, df64c6993078)
  • Late-callback and shared-holder behavior: The route registry rejects registration from an expired async scope and retains independent dynamic holders until the final holder releases, while a static route has no dynamic holder and cannot be removed by a borrower. (src/plugins/http-registry.ts:31, df64c6993078)
  • Boundary-level coverage: The introduced Gateway test drives loopback fetch requests through the Gateway handler across abandoned start/stop callbacks, successful replacement, and failed replacement; registry tests cover last-holder cleanup, static-route borrowing, and expired nested scopes. (src/gateway/server-channels.test.ts:1929, df64c6993078)
  • Plugin API and documentation contract: The public webhook-ingress barrel exports dynamic route registration, and the updated architecture reference documents reuse, static-route ownership, and lifecycle expiry behavior. Public docs: docs/plugins/architecture-internals.md. (docs/plugins/architecture-internals.md:673, df64c6993078)
  • Feature history: Recent lifecycle work includes the maintainer-authored route-lifetime repair commit and earlier channel recovery maintenance, supporting routing to the current channel lifecycle area rather than the PR author alone. (src/gateway/server-channels.ts:623, 0b15ca83049a)

Likely related people:

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

Rank-up moves

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

  • Refresh the lifecycle proof on the clean current-main merge result before landing.

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-08-30T13:30:05.482Z sha 33903fd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T13:43:19.154Z sha 33903fd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T09:28:39.311Z sha 0b15ca8 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T09:35:15.303Z sha 0b15ca8 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T10:18:21.002Z sha df64c69 :: needs maintainer review before merge. :: none

Give each bounded channel stop attempt an independent route lease, preserve static API route ownership when borrowed by dynamic callers, and remove redundant shared-holder state. Exercise late callbacks through the real Gateway HTTP server after successful and failed replacement.

Co-authored-by: zhang-guiping <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L and removed size: M labels Sep 1, 2026
@steipete steipete changed the title fix: prevent channel recovery crash-loops after timed-out stops fix(channels): scope HTTP routes to account lifetimes Sep 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

The improved head adds an independent bounded lease for stop hooks and preserves registry-owned static routes when borrowed by dynamic callers. Six original-order failures were reproduced before repair; 232 owner/sibling tests, real Gateway HTTP recovery checks, all changed-file gates, the full build, and fresh independent review pass. The body records the remaining live-channel limitation and the documented failed-replacement behavior. Please review the current head.

@clawsweeper

clawsweeper Bot commented Sep 1, 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:

The escaped-output fixture previously announced readiness before its IPC handshake finished. A watchdog could kill the parent first, causing an unhandled EPIPE and invalidating the intended live-pipe cleanup scenario. Publish readiness from the disconnect event after the handshake.

The original whole-file run passed 50 tests; forcing that ordering reproduced the exact CI assertion failure. The repaired whole file passes 50 tests under normal scheduling and 50 with the same forced ordering. Deadlines, cleanup assertions and production code are unchanged.

Co-authored-by: zhang-guiping <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 1, 2026
@steipete
steipete merged commit b4385b8 into openclaw:main Sep 1, 2026
304 of 305 checks passed
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
* fix: prevent channel recovery crash-loops after timed-out stops

* fix(channels): bind shutdown routes to their lifetime

Give each bounded channel stop attempt an independent route lease, preserve static API route ownership when borrowed by dynamic callers, and remove redundant shared-holder state. Exercise late callbacks through the real Gateway HTTP server after successful and failed replacement.

Co-authored-by: zhang-guiping <[email protected]>

* test(scripts): publish escaped child readiness after IPC closes

The escaped-output fixture previously announced readiness before its IPC handshake finished. A watchdog could kill the parent first, causing an unhandled EPIPE and invalidating the intended live-pipe cleanup scenario. Publish readiness from the disconnect event after the handshake.

The original whole-file run passed 50 tests; forcing that ordering reproduced the exact CI assertion failure. The repaired whole file passes 50 tests under normal scheduling and 50 with the same forced ordering. Deadlines, cleanup assertions and production code are unchanged.

Co-authored-by: zhang-guiping <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: zhang-guiping <[email protected]>
obviyus added a commit that referenced this pull request Nov 22, 2026
## What Problem This Solves

Exec approvals were checked twice for one command. The worker commit (`execApprovals.commitAuthorizations`) checks the command against the current policy row. After that, `retainExecApprovalsCurrentRead` kept a per-database policy view that the launch guard read again right before spawn. A policy write that landed between the commit and the spawn refused a command that was already admitted ("Exec approval changed before execution", "Exec approval policy is unavailable or changing before execution"). Under the one-admission rule, a policy change applies to the next command; a command that has started finishes.

## Fix

- `src/infra/exec-approvals-store.ts`: delete `retainExecApprovalsCurrentRead`, the `currentPolicies` map and its publication/lifecycle bookkeeping.
  - `prepareExecApprovalsCurrentRead` returns the policy it read at preparation, through the existing prepared-snapshot cache, which a publication still clears for the next reader.
  - The launch guard from `commitExecAuthorizations` keeps Stop (`signal.throwIfAborted()`) and the caller's own `assertCurrent`, and returns the committed file.
- `src/infra/exec-approvals-authorization.ts`: `commitExecAuthorizationLocked` no longer runs `assertCurrentUsageAuthorization` again on the file it just committed. The worker already ran that check inside the commit transaction.
- `scripts/check-lifetime-check-ratchet.mts`: remove `retainExecApprovalsCurrentRead` (it is gone) and `createPluginRuntimeCapabilityLease` from `LIFETIME_CHECK_CALLS`.

### Classification

| Name | Class | Action |
|---|---|---|
| `retainExecApprovalsCurrentRead` (#169584) | authority. It re-read the exec policy, which is the permission for the command, after the worker commit had admitted it. It refused while a policy write was pending or after one committed. | deleted |
| `createPluginRuntimeCapabilityLease` (#133297, "scope HTTP routes to account lifetimes") | resource lifetime fence. Its only `revoke()` callers are channel account stop (`server-channels.ts`), plugin service stop (`services.ts`), plugin CLI scheduler close (`cli-service-scheduler.ts`) and shutdown drain. It never reads role, scopes, profile or grants. It retires HTTP routes, listeners and schedulers that a stopped account or service still holds. | code kept; name removed from the ratchet list |

Kept: Stop on the launch guard, the worker commit check against the current row (it protects the usage/grant write), and the DB-lifecycle fences inside the shared-state reads.

Not in scope (accepted for now): `plugin-node-host.ts` still compares the node exec **config** (`resolveNodeExecConfigPolicy`) at launch. The ratchet does not list it; it can go in a later PR.

## User Impact

- If you tighten exec approvals while a command is between approval and spawn, that command now runs. The next command uses the new policy. Before this change, the command failed with "Exec approval changed before execution".
- Stop still cancels the launch.
- A policy change made before the worker commit still refuses the command.

## Tests

Deleted or flipped. Each one asserted a refusal after the commit had admitted the command, which this change removes:
- `bash-tools.exec-authorization.integration.test.ts`: "revalidates … after asynchronous shell preparation" ×3, "rechecks policy after deferred supervisor admission", the PTY fallback `revoked=true` case. Added "finishes an admitted launch when policy is revoked during supervisor admission" (real exec tool → supervisor).
- `invoke-system-run.test.ts`, `invoke-agent-cli-claude.test.ts`: the revoke cases now expect the admitted launch to finish (real node `system.run` / Claude CLI entry points).
- `plugin-exec-policy.test.ts`: approvals tightened after the invocation started → the launch is allowed. A config change is still refused.
- `agent-tools.browser-loopback-current.e2e.test.ts`: deleted the approvals-revocation case. The abort (Stop) and config cases stay.
- `exec-approvals-store*.test.ts`, `operator-approval-store.worker.test.ts`: the pending-write / committed-change refusals are replaced by "the prepared read keeps its admitted policy; a fresh preparation sees the write".

## Evidence

Pre-push: one `ocx test` run of the 78 importer/touched files (continue-on-failure); the remaining reds there (`server-methods/exec-approvals.test.ts` ×4, `agents-mutate.test.ts`, `bash-tools.exec-gateway-approval.e2e.test.ts` hook-token reload) fail the same way on the merge base `1a0a24dcd2cf`. Touched tests rerun green (202 cases). `pnpm tsgo:core`, `pnpm tsgo:test`, oxfmt, oxlint, lifetime ratchet pass. Head E2E and CI follow in comments.

- Head E2E (Q/R/S pass): #203572 (comment)
- Local review rejected finding: #203572 (comment)

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 23, 2026
## What Problem This Solves

Exec approvals were checked twice for one command. The worker commit (`execApprovals.commitAuthorizations`) checks the command against the current policy row. After that, `retainExecApprovalsCurrentRead` kept a per-database policy view that the launch guard read again right before spawn. A policy write that landed between the commit and the spawn refused a command that was already admitted ("Exec approval changed before execution", "Exec approval policy is unavailable or changing before execution"). Under the one-admission rule, a policy change applies to the next command; a command that has started finishes.

## Fix

- `src/infra/exec-approvals-store.ts`: delete `retainExecApprovalsCurrentRead`, the `currentPolicies` map and its publication/lifecycle bookkeeping.
  - `prepareExecApprovalsCurrentRead` returns the policy it read at preparation, through the existing prepared-snapshot cache, which a publication still clears for the next reader.
  - The launch guard from `commitExecAuthorizations` keeps Stop (`signal.throwIfAborted()`) and the caller's own `assertCurrent`, and returns the committed file.
- `src/infra/exec-approvals-authorization.ts`: `commitExecAuthorizationLocked` no longer runs `assertCurrentUsageAuthorization` again on the file it just committed. The worker already ran that check inside the commit transaction.
- `scripts/check-lifetime-check-ratchet.mts`: remove `retainExecApprovalsCurrentRead` (it is gone) and `createPluginRuntimeCapabilityLease` from `LIFETIME_CHECK_CALLS`.

### Classification

| Name | Class | Action |
|---|---|---|
| `retainExecApprovalsCurrentRead` (openclaw#169584) | authority. It re-read the exec policy, which is the permission for the command, after the worker commit had admitted it. It refused while a policy write was pending or after one committed. | deleted |
| `createPluginRuntimeCapabilityLease` (openclaw#133297, "scope HTTP routes to account lifetimes") | resource lifetime fence. Its only `revoke()` callers are channel account stop (`server-channels.ts`), plugin service stop (`services.ts`), plugin CLI scheduler close (`cli-service-scheduler.ts`) and shutdown drain. It never reads role, scopes, profile or grants. It retires HTTP routes, listeners and schedulers that a stopped account or service still holds. | code kept; name removed from the ratchet list |

Kept: Stop on the launch guard, the worker commit check against the current row (it protects the usage/grant write), and the DB-lifecycle fences inside the shared-state reads.

Not in scope (accepted for now): `plugin-node-host.ts` still compares the node exec **config** (`resolveNodeExecConfigPolicy`) at launch. The ratchet does not list it; it can go in a later PR.

## User Impact

- If you tighten exec approvals while a command is between approval and spawn, that command now runs. The next command uses the new policy. Before this change, the command failed with "Exec approval changed before execution".
- Stop still cancels the launch.
- A policy change made before the worker commit still refuses the command.

## Tests

Deleted or flipped. Each one asserted a refusal after the commit had admitted the command, which this change removes:
- `bash-tools.exec-authorization.integration.test.ts`: "revalidates … after asynchronous shell preparation" ×3, "rechecks policy after deferred supervisor admission", the PTY fallback `revoked=true` case. Added "finishes an admitted launch when policy is revoked during supervisor admission" (real exec tool → supervisor).
- `invoke-system-run.test.ts`, `invoke-agent-cli-claude.test.ts`: the revoke cases now expect the admitted launch to finish (real node `system.run` / Claude CLI entry points).
- `plugin-exec-policy.test.ts`: approvals tightened after the invocation started → the launch is allowed. A config change is still refused.
- `agent-tools.browser-loopback-current.e2e.test.ts`: deleted the approvals-revocation case. The abort (Stop) and config cases stay.
- `exec-approvals-store*.test.ts`, `operator-approval-store.worker.test.ts`: the pending-write / committed-change refusals are replaced by "the prepared read keeps its admitted policy; a fresh preparation sees the write".

## Evidence

Pre-push: one `ocx test` run of the 78 importer/touched files (continue-on-failure); the remaining reds there (`server-methods/exec-approvals.test.ts` ×4, `agents-mutate.test.ts`, `bash-tools.exec-gateway-approval.e2e.test.ts` hook-token reload) fail the same way on the merge base `75564d96e6eb`. Touched tests rerun green (202 cases). `pnpm tsgo:core`, `pnpm tsgo:test`, oxfmt, oxlint, lifetime ratchet pass. Head E2E and CI follow in comments.

- Head E2E (Q/R/S pass): openclaw#203572 (comment)
- Local review rejected finding: openclaw#203572 (comment)

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: zalo Channel integration: zalo docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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: L 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.

[Bug]: Channel recovery crash-loops on the abandoned task's still-registered HTTP route

2 participants