Skip to content

fix(automations): CLI-runtime owners can't see or manage ownerless automations - #162237

Merged
obviyus merged 3 commits into
openclaw:mainfrom
Grynn:fix/cli-mcp-owner-authority
Oct 29, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
Grynn:fix/cli-mcp-owner-authority

Conversation

@Grynn

@Grynn Grynn commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Related: #147614, #157126, #157144

What Problem This Solves

Fixes: admitted owners using CLI-backed agents cannot see or manage existing ownerless automations because the later MCP request constructs the tool outside the owner's automation-management scope.

User Impact

Authorized owners regain Gateway-wide list/get/update of existing automations through CLI MCP. Removing owner membership or revoking the grant still denies access, and later callers without management authority remain caller-scoped. Ownerless jobs remain ownerless. No configuration or stored-data migration is required.

This carries existing management authority across a host-owned boundary, so it needs the repository's exact-head security approval.

Why This Change Was Made

Automation tools bind management authority when constructed, before their later execution. The host-only CLI grant now retains the exact live construction scope, and tool resolution enters it under the admitted caller identity and stored request scope. The construction identity deliberately omits execution's requester-grant issuer. Actual execution retains the existing one-use, method-bound grant and final-effect checks.

The retained callback rechecks the exact grant row, active run, abort/currentness and current channel-owner membership. Stale scope exits any ambient management scope rather than inheriting it. The implementation builds on current requester-origin and detached-listener ownership; it does not restore superseded listener or ambient-authority code.

This semantic repair is based on f91bca9546f5. Its seven changed files are byte-identical to reviewed source 683a0212960fb997b1758ceaa55bc248a84b2c79; unrelated preceding model-locality changes are excluded from this PR. A local merge check against 1e48ec3a9e3 succeeds.

Evidence

  • Live Claude CLI proof: new QA scenario cron-claude-cli-owner-management (live-frontier, claude-cli/claude-sonnet-4-6, subscription auth). A configured channel owner asks the Claude CLI agent to get and then disable an automation owned by another account. On this branch the agent replies with the success marker; the job is disabled and keeps its original owner. With the four source files reverted to main, the same live turn fails with cron job not found: <id> ... For cross-session management, use a fresh authenticated configured channel owner ..., which is the production report in [Bug]: Channel owner turns on claude-cli runtime get no automation management grant over the MCP bridge (cron.update restricted) #186696.
  • Production: on 2026.10.8, a configured channel owner on a claude-cli agent got cron job not found for a job owned by the same conversation, with no cron: admin management log line; the same owner on the embedded runtime is granted management.
  • Real boundary regression: src/gateway/server-methods/mcp-cron-management.integration.test.ts drives the actual detached loopback HTTP MCP listener, production tool resolution and isolated durable Cron persistence. On the unchanged owner it fails with expected 'caller' to be 'gateway'; with this repair it lists, reads and updates the ownerless job without assigning an owner.
  • The same scenario then removes the configured owner and observes update refusal; revokes the grant and observes HTTP401; starts a later unentitled run on the same listener and observes caller scope with no access to the job. The only mocked boundary is unrelated attached-node inventory.
  • Construction/execution separation: a real HTTP regression proves the admitted identity cannot mint a requester grant during construction, while execution can mint and redeem its one-use grant. It failed before the construction identity was narrowed and passes afterward.
  • Final affected command: OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/gateway/mcp-http.async-scope.test.ts src/gateway/server-methods/mcp-cron-management.integration.test.ts src/agents/tools/cron-tool.management.test.ts --maxWorkers=1: 21/21 pass (7 HTTP-scope, 1 durable Cron integration, 13 management controls). Wrapper wall 65.13s, including compiler/bootstrap work; the integrated owner scenario took 6.772s. These are test costs, not production-latency benchmarks.
  • Earlier broader affected runs cover 85 distinct tests across the runs, including grant-store, grant construction, authority and requester-continuation consumers. Core/gateway test types, touched type-aware lint, formatting, scoped line-cap and diff checks pass. Fresh independent P0–P2 review completed scoped-clean on the final seven-file patch.
  • Simplification keeps the existing grant row and Cron authority owner; no second authority registry, wire credential, database schema or permission option is added. Construction and execution share one identity builder with an explicit phase. Necessary patch growth is the retained host callback and separate real authority/revocation regressions.

Current-head CI and independent maintainer security approval are still required; no approval or merge readiness is inferred from older-head checks.

@clawsweeper

clawsweeper Bot commented Oct 1, 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.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Maintainer security changes approved

A maintainer approved this revision with an explicit security approval comment.

A later push requires a fresh approval comment for an external contributor's PR.

@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. 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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserves admitted automation-management authority when CLI MCP requests construct their tools.

Example: A configured owner asks a Claude CLI agent to disable an automation owned by qa-other-account.

  • Before: Caller-scoped access hides the automation and returns cron job not found.
  • After: The agent disables the automation while preserving its original owner.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with corroborated live red/green behavior, distinct authority controls, no actionable findings, and successful exact-head gates.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The recorded real Gateway and subscription-authenticated Claude CLI owner turn reads and disables another account's automation while preserving ownership, and reverting the production changes reproduces the failure; obviyus confirms the exact-head result, while the production HTTP/Cron regression verifies refusal after owner removal, grant revocation, and a later unentitled caller. Inspected screenshots belong to the earlier admin-management PR and add no proof of this CLI repair.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Authenticated owners using CLI-backed agents cannot manage existing automations that their admitted authority should reach.
Reason: Restores the documented management contract, and obviyus's exact-head review approves this bounded construction-time repair.

Merge readiness

✅ Ready for maintainer review

This PR repairs documented automation management that remains broken on main; no actionable introduced defect remains, and the previous exact-head security approval blocker is cleared.

Priority: P2
Reviewed head: 26c6297b920762cbf393f27b01ee0d816cec2e2c

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway admission establishes run-bound authority, the host-owned CLI grant carries its construction scope across MCP HTTP, and automation operations redeem existing method-bound grants before accessing Cron persistence.

flowchart LR
  A[Authenticated owner turn] --> B[Admitted run authority]
  B --> C[Host owned CLI grant]
  C --> D[MCP tool construction]
  D --> E[Method bound management grant]
  E --> F[Cron authorization and persistence]
Loading

Technical review

Best possible solution:

Retain the existing run-bound management scope during CLI tool construction while preserving policy, revocation, and final-effect authorization.

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

Current-main source exposes the missing construction scope, supported by the recorded live red/green result and #186696; this review ran no reproduction.

Is this the best way to solve the issue?

The patch repairs the construction boundary through existing owners, restores the matching tool schema, and preserves execution-time authorization without a parallel authority registry.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +67, Tests +241, Other +82. Total +390 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 95 28 +67
Tests 3 241 0 +241
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 82 0 +82
Total 8 418 28 +390

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +95/-28; tests and QA scenarios +323/-0 Growth retains one host-owned construction callback and shares identity construction; coverage protects durable management, authority loss, late admission, and construction/execution separation.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #147614
Summary: The canonical report and later channel-owner report share the missing CLI MCP management-authority handoff.

Members:

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

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on maintainer: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: CLI-backed owner turns lose documented automation management, while the Automations page and other supported runtimes remain available.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-01T01:02:54.077Z sha 7dd812ff6dc810559de062c6a7e86f4d95e3150b :: blocked before merge. :: none
  • reviewed 2026-10-29T01:07:29.020Z sha 648d5ab :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-29T01:15:20.321Z sha 648d5ab :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-29T04:39:07.543Z sha 26c6297 :: blocked before merge. :: none

Reviewed October 29, 2026, 12:51 AM ET / 04:51 UTC (Revision 5).

Grynn added a commit to Grynn/openclaw that referenced this pull request Oct 21, 2026
Preserve the remaining behavior of local d5bb7f8 after upstream requester-origin and detached-listener work (openclaw#157806 and openclaw#165432). Cron tools bind management while being constructed; entering the admitted caller only at later MCP execution left authorized CLI owners unable to manage existing ownerless jobs.

Capture the exact live Cron construction scope on the host-only CLI grant and enter it under the admitted caller at tool resolution. Keep the stored request scope, live owner membership, exact grant-row lifecycle, detached listener, and final one-use method-bound effect checks. Construction omits execution-only requester grant minting; execution retains its original issuer.

Prove the original caller-vs-gateway visibility failure through real HTTP MCP, tool resolution, and isolated Cron persistence, including owner removal, bearer revocation, and later unentitled callers. A second real HTTP regression proves construction cannot see the requester issuer while execution can mint and redeem one-use grants. Focused affected tests, scoped types/lint, and fresh independent review passed. Related openclaw#162237; local retention does not constitute the outstanding maintainer security approval.
@Grynn
Grynn force-pushed the fix/cli-mcp-owner-authority branch from 7dd812f to 654ad2e Compare October 21, 2026 12:47
@Grynn

Grynn commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Reconstructed this repair on newer main at 654ad2e2125eedaef0b201d537d83c2728bf2310, preserving current requester-origin, stored request-scope and detached-listener behavior. The description now separates the earlier live report from current proof and records the remaining exact-head security approval explicitly.

Fresh real HTTP MCP → tool construction → durable Cron regression is red before the repair and green after, including owner removal, grant revocation and a later unentitled caller. A second HTTP regression verifies that construction cannot access the execution-only requester-grant issuer. Final affected21/21 and broader85distinct checks across runs, focused statics and independent review pass. GitHub reports mergeable. No security approval or current deployment is claimed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 21, 2026
Grynn added a commit to Grynn/openclaw that referenced this pull request Oct 21, 2026
Preserve the remaining behavior of local d5bb7f8 after upstream requester-origin and detached-listener work (openclaw#157806 and openclaw#165432). Cron tools bind management while being constructed; entering the admitted caller only at later MCP execution left authorized CLI owners unable to manage existing ownerless jobs.

Capture the exact live Cron construction scope on the host-only CLI grant and enter it under the admitted caller at tool resolution. Keep the stored request scope, live owner membership, exact grant-row lifecycle, detached listener, and final one-use method-bound effect checks. Construction omits execution-only requester grant minting; execution retains its original issuer.

Prove the original caller-vs-gateway visibility failure through real HTTP MCP, tool resolution, and isolated Cron persistence, including owner removal, bearer revocation, and later unentitled callers. A second real HTTP regression proves construction cannot see the requester issuer while execution can mint and redeem one-use grants. Focused affected tests, scoped types/lint, and fresh independent review passed. Related openclaw#162237; local retention does not constitute the outstanding maintainer security approval.

Local-Feature: cli-mcp-management-construction
Semantic-Source: 22b7f5f
Upstream-Tracking: openclaw#162237
Drop-When: Upstream retains scoped CLI management during construction with execution-only issuance and live authority checks.
Rebase-Base: ed9d493
Grynn added a commit to Grynn/openclaw that referenced this pull request Oct 21, 2026
Preserve the remaining behavior of local d5bb7f8 after upstream requester-origin and detached-listener work (openclaw#157806 and openclaw#165432). Cron tools bind management while being constructed; entering the admitted caller only at later MCP execution left authorized CLI owners unable to manage existing ownerless jobs.

Capture the exact live Cron construction scope on the host-only CLI grant and enter it under the admitted caller at tool resolution. Keep the stored request scope, live owner membership, exact grant-row lifecycle, detached listener, and final one-use method-bound effect checks. Construction omits execution-only requester grant minting; execution retains its original issuer.

Prove the original caller-vs-gateway visibility failure through real HTTP MCP, tool resolution, and isolated Cron persistence, including owner removal, bearer revocation, and later unentitled callers. A second real HTTP regression proves construction cannot see the requester issuer while execution can mint and redeem one-use grants. Focused affected tests, scoped types/lint, and fresh independent review passed. Related openclaw#162237; local retention does not constitute the outstanding maintainer security approval.

Local-Feature: cli-mcp-management-construction
Semantic-Source: 22b7f5f
Upstream-Tracking: openclaw#162237
Drop-When: Upstream retains scoped CLI management during construction with execution-only issuance and live authority checks.
Rebase-Base: ed9d493
Preserve the remaining behavior of local d5bb7f8 after upstream requester-origin and detached-listener work (openclaw#157806 and openclaw#165432). Cron tools bind management while being constructed; entering the admitted caller only at later MCP execution left authorized CLI owners unable to manage existing ownerless jobs.

Capture the exact live Cron construction scope on the host-only CLI grant and enter it under the admitted caller at tool resolution. Keep the stored request scope, live owner membership, exact grant-row lifecycle, detached listener, and final one-use method-bound effect checks. Construction omits execution-only requester grant minting; execution retains its original issuer.

Prove the original caller-vs-gateway visibility failure through real HTTP MCP, tool resolution, and isolated Cron persistence, including owner removal, bearer revocation, and later unentitled callers. A second real HTTP regression proves construction cannot see the requester issuer while execution can mint and redeem one-use grants. Focused affected tests, scoped types/lint, and fresh independent review passed. Related openclaw#162237; local retention does not constitute the outstanding maintainer security approval.

Local-Feature: cli-mcp-management-construction
Semantic-Source: 22b7f5f
Upstream-Tracking: openclaw#162237
Drop-When: Upstream retains scoped CLI management during construction with execution-only issuance and live authority checks.
Rebase-Base: 0220489
@Grynn
Grynn force-pushed the fix/cli-mcp-owner-authority branch from 654ad2e to 648d5ab Compare October 29, 2026 01:00
@Grynn

Grynn commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (022048904b5). The only conflicts were in src/gateway/mcp-http.async-scope.test.ts, where main added the keepalive suite (and a describe import) in the same places this PR adds its tests. The production files merged cleanly. One API change needed a test-only adjustment: main's ensureMcpLoopbackServer() no longer takes a port argument, so the new integration test calls it without one. The patch is otherwise unchanged.

Current main still has the gap. finalizeCliMcpGrant carries no management binding, and src/gateway/mcp-http.ts still resolves loopback tools outside the run's Cron scope, before the admitted caller identity is installed. So bindCronManagementGrant in createCronTool returns undefined for CLI-backed owner and admin turns. Since #182561 this also means the new bind action is refused on that path, because cron.bind requires the management grant. The tools.gatewayPolicy.automations policy from #174580 is still honoured: construction still goes through bindCronManagementGrant(runId, config), which checks that policy before it looks at the retained scope.

#186668 repairs the same handoff at execution time, and #186696 is another report of #147614. The difference is that this PR binds at construction, so the tool's schema and description also get the management shape (the schema-parity point #186668 leaves out of scope). Execution still uses the same one-use, method-bound grant and the same final-effect checks. I'm happy to close this in favour of #186668 if maintainers prefer that route.

Locally on the rebased tree: build, type checks and lint pass, and the focused tests (mcp-http.async-scope, mcp-cron-management.integration, cron-creator-authority-context, cron-tool.management) pass. CI on this head should confirm.

The previous re-review stopped on a provider limit. Exact-head security approval is still outstanding, and none is claimed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 29, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer review at 648d5ab8.

Bug confirmed in production. On 2026.10.8, a configured channel owner on a claude-cli agent called automations get on a job owned by the same conversation and got cron job not found (the job has operator authority, so only management can see it). No cron: admin management line was logged for that turn, while the same owner on the embedded runtime logs one. This matches #186696 and the root cause here: finalizeCliMcpGrant captured only the requester issuer and the currentness check, and the loopback request later built the automations tool outside the owner's activeCronCreatorAuthority scope, so bindCronManagementGrant returned undefined.

Design. This matches the Codex path (runWithCronCreatorAuthorityCapabilityResolver around dynamic tool construction). The narrow construction identity is right: management binding gets the admitted caller, and requester-grant minting stays at execution.

Tool cache. I checked whether a cached tool can keep management authority past its lifetime. It cannot widen:

  • mintCronCreatorAuthorityGrant rechecks scope.active, abort, isCurrent and channel-owner membership on every call, and each grant is one-use and method-bound.
  • McpLoopbackToolCache keys by grant token and evicts on row replacement.
  • A stale cached tool fails closed with the expired-management error; it does not fall back to caller scope for the rest of that grant. That is acceptable. A short note in the PR body would help the security reviewer.

Before merge:

  • check-lint-core-2 is red. Please check whether it comes from this diff or from current main.
  • ClawSweeper asks for real behavior proof. A QA or live run with a claude-cli owner turn doing get / update on an operator-created job would cover it.

Related: #187195 lets the owner conversation pause or remove its own operator-created jobs without management, so it does not overlap with this fix. This PR is still needed for Gateway-wide owner management on CLI agents.

@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. label Oct 29, 2026

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the exact head 26c6297. The management scope reaches CLI MCP tool construction only for the admitted owner run; grants stay one-use, method-bound and rechecked at mint and commit. Live Claude CLI proof passes on this head and fails on main with the production error.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 29, 2026
@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

/allow-security-sensitive-change

@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Oct 29, 2026
@obviyus
obviyus merged commit 33c8e49 into openclaw:main Oct 29, 2026
171 of 173 checks passed
@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Landed in 33c8e49. Thanks @Grynn for the fix.

  • Bug: a configured channel owner on a Claude CLI agent got no automation management: the CLI MCP bridge built the automations tool outside the owner's management scope, so get/update of another conversation's or account's job returned cron job not found ([Bug]: Channel owner turns on claude-cli runtime get no automation management grant over the MCP bridge (cron.update restricted) #186696).
  • Fix: the CLI grant keeps the live management scope and enters it only while building tools; grants stay one-use, method-bound and rechecked at mint and commit.
  • Proof: live claude-cli QA scenario cron-claude-cli-owner-management passes on this head and fails on main with the production error; the loopback integration and HTTP-scope regressions pass.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…tomations (openclaw#162237)

Related: openclaw#147614, openclaw#157126, openclaw#157144

## What Problem This Solves

Fixes: admitted owners using CLI-backed agents cannot see or manage existing ownerless automations because the later MCP request constructs the tool outside the owner's automation-management scope.

## User Impact

Authorized owners regain Gateway-wide list/get/update of existing automations through CLI MCP. Removing owner membership or revoking the grant still denies access, and later callers without management authority remain caller-scoped. Ownerless jobs remain ownerless. No configuration or stored-data migration is required.

## Why This Change Was Made

Automation tools bind management authority when constructed, before their later execution. The host-only CLI grant now retains the exact live construction scope, and tool resolution enters it under the admitted caller identity and stored request scope. The construction identity deliberately omits execution's requester-grant issuer. Actual execution retains the existing one-use, method-bound grant and final-effect checks.

The retained callback rechecks the exact grant row, active run, abort/currentness and current channel-owner membership. Stale scope exits any ambient management scope rather than inheriting it. The implementation builds on current requester-origin and detached-listener ownership; it does not restore superseded listener or ambient-authority code.


## Evidence

- **Live Claude CLI proof:** new QA scenario `cron-claude-cli-owner-management` (live-frontier, `claude-cli/claude-sonnet-4-6`, subscription auth). A configured channel owner asks the Claude CLI agent to `get` and then disable an automation owned by another account. On this branch the agent replies with the success marker; the job is disabled and keeps its original owner. With the four source files reverted to `main`, the same live turn fails with `cron job not found: <id> ... For cross-session management, use a fresh authenticated configured channel owner ...`, which is the production report in openclaw#186696.
- **Production:** on 2026.10.8, a configured channel owner on a `claude-cli` agent got `cron job not found` for a job owned by the same conversation, with no `cron: admin management` log line; the same owner on the embedded runtime is granted management.
- **Real boundary regression:** `src/gateway/server-methods/mcp-cron-management.integration.test.ts` drives the actual detached loopback HTTP MCP listener, production tool resolution and isolated durable Cron persistence. On the unchanged owner it fails with `expected 'caller' to be 'gateway'`; with this repair it lists, reads and updates the ownerless job without assigning an owner.
- The same scenario then removes the configured owner and observes update refusal; revokes the grant and observes HTTP401; starts a later unentitled run on the same listener and observes caller scope with no access to the job. The only mocked boundary is unrelated attached-node inventory.
- **Construction/execution separation:** a real HTTP regression proves the admitted identity cannot mint a requester grant during construction, while execution can mint and redeem its one-use grant. It failed before the construction identity was narrowed and passes afterward.
- Final affected command: `OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/gateway/mcp-http.async-scope.test.ts src/gateway/server-methods/mcp-cron-management.integration.test.ts src/agents/tools/cron-tool.management.test.ts --maxWorkers=1`: **21/21 pass** (7 HTTP-scope, 1 durable Cron integration, 13 management controls). Wrapper wall **65.13s**, including compiler/bootstrap work; the integrated owner scenario took **6.772s**. These are test costs, not production-latency benchmarks.
- Earlier broader affected runs cover **85 distinct tests across the runs**, including grant-store, grant construction, authority and requester-continuation consumers. Core/gateway test types, touched type-aware lint, formatting, scoped line-cap and diff checks pass.
- Simplification keeps the existing grant row and Cron authority owner; no second authority registry, wire credential, database schema or permission option is added. Construction and execution share one identity builder with an explicit phase. Necessary patch growth is the retained host callback and separate real authority/revocation regressions.

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

agents Agent runtime and tooling extensions: qa-lab gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: M 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