Skip to content

fix(gateway): owner turns after subagent work cannot edit automations - #157404

Merged
shakkernerd merged 1 commit into
mainfrom
fix/cron-management-grant
Sep 24, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix/cron-management-grant

Conversation

@obviyus

@obviyus obviyus commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: a configured channel owner cannot update, run or remove an automation from a turn that resumes after a subagent finishes; the automations tool fails with missing scope: operator.admin, although owner turns are documented to manage any Gateway automation.

User Impact

User impact: an owner's agent can edit its automations in follow-up turns after subagent work, instead of telling the owner it lacks permission and sending them to the Control UI.

Why This Change Was Made

A configured channel owner's turn gets automation management through a one-use cronManagementGrant, bound to one method and the admitted run. cron.update, cron.run and cron.remove are registered as operator.admin methods. A subagent-completion continuation turn reaches the Gateway through an in-process client with operator.write only, so the method-scope fence in authorizeGatewayMethod refused the call before the cron handler could redeem the grant. Reads (cron.list, cron.get) need only operator.read, so they worked and the failure looked like a missing permission on the owner's side.

The fence now asks the grant owner (holdsCronManagementGrant) whether the internal caller holds an unredeemed grant bound to this exact method and run, and admits the call if so. The cron handler still redeems the grant once and checks it is active, exactly as before. A grant bound to another method, an expired or revoked grant, or no grant still fails at the fence.

The existing requester-continuation integration tests called cronHandlers["cron.update"] directly, which skipped the fence. They now dispatch through handleGatewayRequest with a write-scoped client, so they cover the production path.

Evidence

Live Telegram (Test Server, real user in a forum group, fresh Gateway from built dist, token auth). The owner's message makes the agent spawn a subagent and yield; the subagent finishes; the resumed continuation turn lists automations and updates a seeded job through the automations tool.

Build Continuation turn's automations update
base 074198a634 missing scope: operator.admin (the production error)
this PR job updated

Turns the owner starts directly already had enough scope and passed on both builds; the failure is specific to continuation turns.

Tests (src/gateway/server-methods/requester-cron-authority.integration.test.ts):

  • The admitted-manager cases now run through the real request router with an operator.write client. On base, all routed management cases fail with missing scope: operator.admin; with this PR they pass. The no-grant case is refused at the fence, as in production.
  • New: a grant bound to cron.remove does not admit cron.update.
  • The revocation cases (fresh user turn, session reset, owner removal while the update awaits validation) still reject with the existing admin-grant error.
  • pnpm tsgo:core passes.

Test cost (--maxWorkers=1): pnpm test src/gateway/server-methods/requester-cron-authority.integration.test.ts --maxWorkers=1: 15 tests, 40.8 s wall (71% transform, 22% tests). One new case; the others changed dispatch only.

@clawsweeper

clawsweeper Bot commented Sep 24, 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 gateway Gateway runtime size: S labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The branch lets a resumed channel-owner turn use its one-use grant at the Gateway automation scope check and routes the regression test through Gateway request dispatch.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for merge consideration. Current main still blocks the documented owner-continuation workflow, and this review found no blocking patch defect.

Priority: P1
Reviewed head: af3eb4859245bddc8ab89b1c321a231c2afd18b7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused authorization repair has reported real-flow proof and routed tests covering the closest denied and revoked cases.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR reports a Telegram Test Server before/after run in which the resumed owner turn changed a seeded job, and its Gateway-routed integration test checks saved-job outcomes for allowed, ungranted, wrong-method, and revoked calls. 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 (live_output): The PR reports a Telegram Test Server before/after run in which the resumed owner turn changed a seeded job, and its Gateway-routed integration test checks saved-job outcomes for allowed, ungranted, wrong-method, and revoked calls. No stored-data contract changes.
Evidence reviewed 9 items Current main remains affected: Current main retains the scope denial without the proposed grant exception; its automation update, remove, and run methods require operator.admin.
Documented behavior: The documented contract grants configured channel owners management of existing automations and retains that authority through an admitted subagent continuation.
Introduced scope exception: The PR admits an otherwise denied method only when the internal runtime identity holds a grant bound to that method and run.
Findings None None.
Security None None.

How this fits together

The Gateway receives automation requests from an agent turn, checks the caller’s authority, and passes admitted requests to the automation handler. The handler checks authority again before changing a saved job.

flowchart LR
A[Owner chat] --> B[Resumed agent turn]
B --> C[Automation tool]
C --> D{Gateway scope check}
D -->|Matching grant| E[Live authority check]
D -->|No authority| F[Permission error]
E --> G[Saved automation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +35, Tests +8. Total +43 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 39 4 +35
Tests 1 45 37 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 84 41 +43

Review metrics

Metric Value Why it matters
Production and test delta production net +35 lines; tests net +8 lines The added production code factors grant matching into the Gateway authorization path, while the test changes exercise routed behavior.
Focused suite cost 15 tests, 40.8 s wall; 1 case added The PR records the cost of the routed authority suite, whose wall time is mostly transform work.

Technical review

Best possible solution:

Preserve owner continuation access through the exact-method grant while retaining one-use redemption and live authority checks at each automation effect.

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

Yes. A configured owner can resume after subagent work and request an automation update; current main still rejects that write-scoped call at the admin scope gate. The PR reports the same failure on its base build, though this review did not execute current main.

Is this the best way to solve the issue?

Yes. The grant owner supplies an exact-method check at the scope gate, while the automation handler retains one-use redemption and live precommit validation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A documented automation-management workflow fails for configured owners after a subagent turn resumes.
  • merge-risk: 🚨 security-boundary: The PR changes admission to admin-scoped automation methods, so the method-bound grant and final-effect checks are security-relevant.
  • 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 (live_output): The PR reports a Telegram Test Server before/after run in which the resumed owner turn changed a seeded job, and its Gateway-routed integration test checks saved-job outcomes for allowed, ungranted, wrong-method, and revoked calls. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a Telegram Test Server before/after run in which the resumed owner turn changed a seeded job, and its Gateway-routed integration test checks saved-job outcomes for allowed, ungranted, wrong-method, and revoked calls. No stored-data contract changes.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. A Telegram owner can observe whether the resumed agent updates an automation after subagent completion.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shakkernerd: 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 (1 earlier review cycle)
  • reviewed 2026-09-24T16:44:48.560Z sha af3eb48 :: needs maintainer review before merge. :: none

@shakkernerd shakkernerd self-assigned this Sep 24, 2026
@shakkernerd
shakkernerd marked this pull request as ready for review September 24, 2026 19:03
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: af3eb4859245bddc8ab89b1c321a231c2afd18b7
  • Maintainer: @obviyus
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/cron-creator-authority-grant.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/method-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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 24, 2026
@shakkernerd
shakkernerd merged commit 0a904fc into main Sep 24, 2026
274 checks passed
@shakkernerd
shakkernerd deleted the fix/cron-management-grant branch September 24, 2026 19:39
@shakkernerd

Copy link
Copy Markdown
Contributor

Fixed: resumed owner turns can manage automations using their existing method-bound grants.

With thanks to @obviyus.

@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…pe gate (openclaw#157404)

Allow automation management continuations to use their existing method- and run-bound grants at the Gateway scope check while preserving single-use redemption and live authority validation.

Reviewed-by: @shakkernerd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed 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.

2 participants