Skip to content

feat: restrict model automation administration through Gateway policy - #174580

Merged
stevenlee-oai merged 30 commits into
mainfrom
dev/stevenlee/gateway-automation-policy-p0
Oct 21, 2026
Merged

stevenlee-oai merged 30 commits into
mainfrom
dev/stevenlee/gateway-automation-policy-p0

Conversation

@stevenlee-oai

@stevenlee-oai stevenlee-oai commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OCE needs caller-scoped scheduling without giving model turns an administrator’s authority over other automations or Gateway command jobs.

User Impact

Set tools.gatewayPolicy.automations to { scope: "caller", allowCommandJobs: false }. Administrator-started model conversations retain caller-owned scheduling. Model calls cannot create, convert, edit, enable or manually run command jobs or on-exit command watchers. Direct authorized human administration remains available.

The policy is optional and activates through Gateway restart or replacement after affected old work ends, matching merged #174547. Ordinary deployments and native Codex tools retain existing behavior. Stream schedules, scripts and triggers retain their separate controls.

Why This Change Was Made

Tool/action filtering cannot distinguish ordinary scheduling from administrative operations. Existing automation grants, ownership checks and commit guards now enforce the deployment policy. Live grant expiry/revocation and stream-approval safeguards remain intact.

The scheduling-authentication changes and their tests have moved to #179696. Neither PR depends on the other; either can merge first. This PR changes no inference-account selection or stored-job format.

Implements RFC-0021 items 3, 4 and the automation portion of 8 in the RFC.

Evidence

Current-head CI remains pending for 894421f4812.

  • Four affected Vitest suites pass after integrating main (208.44 seconds including preparation): Gateway policy, automation invocation, management and schema. They cover caller scoping, command restrictions, direct human administration and active/paced invocation actions.
  • Canonical config generation/check, targeted typed lint across changed TypeScript files, source formatting and whitespace checks pass. Core baseline count is 2567 → 2570 for exactly the three automation policy fields; channel/plugin baselines are unchanged.
  • The frozen workspace install passes after the package exceptions propagated; no lockfile changes were needed.
  • Independent Codex correctness and maintainability reviews found no issue. Native CLI autoreview remains blocked by read-only startup. ClawSweeper’s latest attempt returned provider_throttle without a review verdict.
  • Deployment upgrade qualification has not been run. Worker/provider execution qualification belongs to fix: unblock schedules using worker or native Harness authentication #179696 and is not claimed here.

@clawsweeper

clawsweeper Bot commented Oct 16, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 16, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Adds caller-scoped model automation policy, command-job restrictions, and worker-aware inference-account capture.

Example: An administrator-started model turn uses tools.gatewayPolicy.automations with scope "caller" and allowCommandJobs false.

  • Before: The turn can receive authority to manage other conversations’ automations and existing command jobs.
  • After: The turn retains caller-owned scheduling while foreign-job management and command-job changes or manual runs are denied.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source changes are coherent and the prior finding is resolved, but the required worker credential authority is not demonstrated through execution.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Deployment operators need ordinary model scheduling without lending administrator authority over unrelated jobs or requiring ambient Gateway credentials for worker-local inference.
Reason: The maintainer-authored direction addresses a concrete deployment boundary with optional restrictions and unchanged defaults.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-authored feature adds distinct policy controls absent from main, and the earlier RPC admission finding is fixed. No additional definite code defect was established.

Priority: P2
Reviewed head: 22a9c1b198b88fd4044034447e49fa18ae155983

Before merge

  • Add real behavior proof - Authority-chain proof required: supplied fixtures exercise real Gateway routing, live run-authority validation, and persistent cron mutations, including foreign-job and revoked-authority denials. The worker-account positives stop after saving disabled jobs; the body explicitly states that no worker or inference launches. Provide a real worker-path trace showing the intended account reaches provider I/O and revoked or reassigned authority cannot do so, with IPs, keys, and non-public endpoints redacted. No stable-release upgrade run is supplied. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete authorization bypass was established, but worker inference authority still needs final-effect qualification.
  • Resolve merge risk - Before merge, establish that an unbound required-worker schedule uses its intended worker account and rejects revoked or reassigned authority before provider I/O.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Show a persisted required-worker schedule executing with the intended account, including forbidden/revoked authority controls, and upgrade from v2026.10.4 with existing settings and jobs intact.
Agent review details

How this fits together

Model automation calls enter Gateway RPC admission, pass through cron ownership and live-authority checks, and reach persistent job mutations or run reservation; inference capture separately records the account needed for later execution.

flowchart TD
  A[Model automation tool] --> B[Gateway RPC admission]
  B --> C[Cron caller and policy checks]
  C --> D[Persistent cron owner]
  D --> E[Scheduled execution]
  F[Inference account capture] --> D
  G[Authorized human administration] --> B
Loading

Technical review

Best possible solution:

Keep policy enforcement in the existing grant and cron mutation owners, with worker execution retaining the intended credential boundary.

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

This is an intentional feature extension; source inspection confirms the existing administrator-management behavior and the new restriction paths, without executing target code.

Is this the best way to solve the issue?

The implementation uses the existing authority and persistence owners, checks stored job kinds, preserves human administration, and fixes the previously identified admission gap.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Qualify worker inference authority (recommended)
    Exercise creation, persistence, reload, and execution through the real worker path; record the selected account and show revoked or reassigned authority prevents provider I/O.

Provenance checked

  • Administrator automation management changes intended behavior with a stated reason (499ee4b: Authenticated administrator chat intentionally gained the same all-automation management scope as the Automations page.)
  • Write-scoped continuation admission keeps the original intent (0a904fc: Owner continuations needed a method-bound grant to pass the operator.admin fence while retaining handler-owned authorization.)
  • Inference-account capture changes intended behavior with a stated reason (d25a316: Persist an authorized account so scheduled runs do not switch identity or billing when interactive defaults change.)
  • Manual-run handler extraction keeps the original intent (9f330ef: Preserve enqueue semantics while optionally returning a finished run through the existing history-visibility boundary.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was established, but worker inference authority still needs final-effect qualification.

Evidence

What I checked:

  • Introduced changes and current-main distinction: The pinned introduction diff contains the automation policy fields and enforcement; fetched main lacks gatewayPolicy and allowCommandJobs in the corresponding configuration schema. (src/config/zod-schema.agent-runtime.ts:666, 22a9c1b198b8)
  • Previous finding addressed: The new admission exception permits managed write-scoped runtime identities to reach cron.update, cron.remove, and cron.run while preserving handler-owned authorization; comparison with the earlier reviewed head confirms this is a subsequent repair. (src/gateway/server-methods/method-authorization.ts:116, 22a9c1b198b8)
  • Policy checked against stored and requested job kinds: Command and on-exit checks inspect both the stored job and requested patch, and mutation guards repeat the policy check before committing. (src/gateway/server-methods/cron-caller-scope.ts:41, 22a9c1b198b8)
  • Production-owner authorization coverage: The integration fixture routes through handleGatewayRequest and the persistent CronService, covering own-job mutations, foreign-job rejection, revoked authority, command restrictions, and direct-human controls; execution callbacks remain mocked. (src/gateway/server-methods/cron.gateway-policy.integration.test.ts:123, 22a9c1b198b8)
  • Worker account capture and proof boundary: Required worker-local inference now skips ambient Gateway account capture when no explicit or compatible creator profile is selected; new positive tests persist disabled jobs without launching inference. (src/cron/inference-binding.runtime.ts:48, 22a9c1b198b8)
  • Contributor qualification limits: The complete PR body and contributor comments explicitly identify the evidence as local production-boundary fixtures, state that the account-binding suite launches no worker or inference, and leave deployed qualification pending. (22a9c1b198b8)

PR surface

Source +147, Tests +615, Docs +37, Generated 0. Total +799 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 11 310 163 +147
Tests 5 616 1 +615
Docs 2 38 1 +37
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 20 967 168 +799

Review metrics

Metric Value Why it matters
New configuration controls 2 optional leaf settings automations.scope and automations.allowCommandJobs independently restrict model calls; omission preserves existing administrator behavior.

Labels

Label changes:

  • add P2: This is a useful opt-in deployment policy improvement without an established urgent regression.
  • add merge-risk: 🚨 auth-provider: Required-worker schedules can now persist without a Gateway inference-account binding, changing later account-selection inputs.
  • add merge-risk: 🚨 security-boundary: The change controls model administration authority and modifies the credential boundary of scheduled worker inference.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a useful opt-in deployment policy improvement without an established urgent regression.
  • merge-risk: 🚨 security-boundary: The change controls model administration authority and modifies the credential boundary of scheduled worker inference.
  • merge-risk: 🚨 auth-provider: Required-worker schedules can now persist without a Gateway inference-account binding, changing later account-selection inputs.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add worker-path account and revocation proof through the final provider effect.
  • Show an upgrade from v2026.10.4 preserving existing automation definitions, settings, and account ownership.

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 (1 earlier review cycle)
  • reviewed 2026-10-16T19:34:41.649Z sha d2be50a :: needs real behavior proof before merge. :: [P2] Preserve caller-owned mutations through the RPC scope gate

Reviewed October 16, 2026, 10:40 PM ET / October 17, 2026, 02:40 UTC (Revision 2).

@stevenlee-oai

Copy link
Copy Markdown
Contributor Author

Codex: Addressed the caller-owned RPC admission finding in 2f1333a044b.

Under the managed caller policy, a server-owned runtime identity with write scope can reach cron.update, cron.run and cron.remove; the existing handlers still enforce job ownership and live authority before committing. This restores caller-owned operations without granting administrative model authority or changing ordinary human/no-policy permissions.

The existing integration fixture now routes through handleGatewayRequest. Its routed baseline reproduced missing scope: operator.admin for an own-job update; the fix passes all 17 cases, including own update/run/remove, foreign-job denial, revocation before commit, ordinary/read-only/no-policy negatives, command-policy checks and direct-human controls. Targeted types, lint and formatting pass. This is local production-routing and persistent-state proof, not deployed OCE qualification; the earlier 79-test result is recorded separately in the PR body.

@stevenlee-oai

Copy link
Copy Markdown
Contributor Author

Codex: The required-worker scheduling fix is published at 22a9c1b198b. It avoids capturing an ambient Gateway account while preserving selected-account validation and Gateway/optional-worker behavior. All 23 real-handler/SQLite cases and affected static checks pass; deployed qualification remains pending.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 17, 2026
@stevenlee-oai
stevenlee-oai marked this pull request as ready for review October 20, 2026 01:36
@stevenlee-oai

Copy link
Copy Markdown
Contributor Author

Codex update: pushed 5b1a3edc2e7, resolved conflicts with #174547, and aligned automation policy with its deployment/restart contract. Removed live-policy intersections and grant/catalog tightening expectations; existing run, grant and job-ownership checks remain. Fresh independent correctness and maintainability reviews found no remaining source issue. Formatting and whitespace checks pass.

Current-head CI is queued. Local runtime/type checks and config-baseline regeneration remain blocked by dependency downloads; the generated baseline still needs refreshing. The earlier ClawSweeper review had no code finding. Its required-worker account/revocation and old-version upgrade proof requests remain unqualified, rather than being treated as closed by source review. No merge or deployment was performed.

Base automatically changed from dev/stevenlee/gateway-tool-policy-p0 to main October 20, 2026 22:55
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 894421f4812609a1aa27da3b66eaa1ee45a196ea
  • Maintainer: @stevenlee-oai
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/cron-creator-authority-context.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • 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.

@stevenlee-oai

Copy link
Copy Markdown
Contributor Author

Codex: The scheduling-authentication changes and their tests have moved to #179696. This PR now contains only the deployment-scoped automation policy; either PR can merge first. Worker/provider execution qualification remains open in the auth PR.

Current head 894421f4812 resolves the main conflicts while preserving the new automation invocation actions, run guards and owner-delivery behavior. Canonical baselines and changed-file typed lint pass; a direct production-tool check covers inactive/active/paced discovery and result authorization. The PR body distinguishes the earlier 179 passing Gateway tests from post-integration CI, which is now running.

@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 the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 21, 2026
@stevenlee-oai
stevenlee-oai merged commit a4bc5c6 into main Oct 21, 2026
139 checks passed
@stevenlee-oai
stevenlee-oai deleted the dev/stevenlee/gateway-automation-policy-p0 branch October 21, 2026 17:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
…openclaw#174580)

* feat(gateway): enforce required model tool and action policy

* fix(gateway): accept unvalidated tool descriptors in policy helpers

* test(gateway): qualify tool policy fixtures and config schema

* test(gateway): type the action rewrite fixture

* refactor(agents): keep final tool policy assembly together

* feat: restrict model automation administration through Gateway policy

* fix(worker): retain prepared prompt report in turn results

* fix(gateway): admit caller-owned automation mutations

* fix(cron): avoid host auth capture for required workers

* fix(worker): preserve Gateway tool errors across proxy calls

* fix(cron): use selected Harness authentication for schedules

* refactor(gateway): scope tool policy to deployments

* refactor(gateway): simplify policy wrappers and coverage

* fix(agents): preserve publication scope under gateway tool policy

* refactor(agents): separate delegation policy from tool availability

* refactor(agents): clarify tool assembly and child policy capture

* fix(tools): preserve structured worker failures

* fix(agents): narrow explicit tool error results before validation

* test(cron): cover command-only deployment policy fallback

* fix: refresh automation baseline and simplify tool descriptions

* refactor: separate scheduling authentication from Gateway automation policy

---------

Co-authored-by: stevenlee-oai <[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 clawsweeper:intake:feature Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant