Skip to content

feat(gateway): add deployment-scoped tool and action policy - #174547

Merged
stevenlee-oai merged 19 commits into
mainfrom
dev/stevenlee/gateway-tool-policy-p0
Oct 20, 2026
Merged

stevenlee-oai merged 19 commits into
mainfrom
dev/stevenlee/gateway-tool-policy-p0

Conversation

@stevenlee-oai

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

Copy link
Copy Markdown
Contributor

What Problem This Solves

Deployment owners need to limit which Gateway tools and actions model-directed work can use, including administrator-started conversations and plugin-provided tools. tools.gatewayPolicy applies a tool allowlist and explicit action lists after ordinary grants, then authorizes final arguments after preparation and hooks.

Tools capture the deployment policy when assembled. Adding, changing or removing it requires Gateway restart or replacement after affected old work ends. Ordinary tool-policy reloads, direct human administration, native Codex tools and deployments without this setting keep their existing behavior.

Tool Search, Code Mode, HTTP/MCP invocation and dedicated workers share the policy rules. Both turn and stable session catalogs are filtered. Children retain their parent's applicable whole-tool restrictions and apply the deployment's action policy themselves. Workspace-dependent delegation uses the shared publisher schema and existing policy evaluator without inserting a callable publisher into the parent's catalog.

This provides RFC-0021 items 1/2, caller-independent propagation for 3, and native execution coverage for 8. Automation restrictions, Codex adapter integration, OCE policy delivery and Harness-local protection remain separate work.

Evidence

  • Merged main at 92477a723819 in 8c9d271c2cc. Fresh correctness and maintainability review confirms the publication merge preserves sandbox-specific actions and fields, operator permissions, explicit publishing and omitted-action compatibility.
  • Scoped lint, formatting, generated-config and whitespace checks pass. The canonical generator exactly reproduced main's tracked baseline before adding the six policy entries; the PR still changes the same 52 paths.
  • CI for 8c9d271c2cc passed, including the final CI, dependency-review and security-sensitive-review gates. Local focused suites could not execute because the installed TypeScript package lacks the required typescript/ast export.
  • Native Auto Review was unavailable at helper startup (read-only filesystem; no report). The resolved publication changes received a fresh independent source review.

Real-Gateway runtime qualification remains pending. An isolated driver with fake credentials and a scripted local provider is prepared for allowed/denied tool effects, hook rewrites, human administration and activation after joined replacement. No current-head runtime qualification is claimed.

@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 clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels 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

This PR adds an optional deployment-wide allowlist for model-directed Gateway tools and actions.

Example: A deployment permits sessions with only the patch action.

  • Before: Ordinary grants determine the available tools without a separate deployment action ceiling.
  • After: The sessions schema advertises patch, and execution rejects other actions even after a hook rewrites the arguments.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source design is coherent with no confirmed introduced defect, but required authority evidence is absent and current-head typecheck failure remains unattributed.
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 cannot independently cap model-directed Gateway tools and actions after ordinary conversation and plugin grants.
Reason: The maintainer-authored direction addresses a concrete deployment requirement with one shared enforcement contract and explicitly bounded follow-up work.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep this PR open: it supplies a distinct, maintainer-sponsored deployment policy missing from main, and source review established no actionable introduced defect.

Priority: P2
Reviewed head: c60fafb88b2e0ea9a044d3972b9a6fc88a44f0c8

Before merge

  • Add real behavior proof - Authority-chain proof required: provide current-policy terminal output or redacted logs showing allowed effects and rejection before I/O of prohibited administrator-started model calls, post-hook action rewrites, and retained or queued worker calls after run/placement revocation, including inherited child restrictions. Demonstrate restart/replacement activation after affected old work ends and fresh-install/latest-stable upgrade behavior with existing settings intact. The body explicitly reports qualification pending; focused tests and the older publication screenshots do not establish these scenarios. Redact credentials, IPs, phone numbers, and non-public endpoints. 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 bypass was identified, but this new authorization boundary remains unqualified.
  • Resolve merge risk - The interaction between captured deployment restrictions and live run/worker authority remains unqualified for retained or queued calls after revocation.
  • Complete next step - Attribute the current-head check-prod-types failure from its compiler diagnostics, then repair any diff-caused errors or document an evidenced outside cause.
  • 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: Current-policy Gateway final-effect and revocation qualification is absent, latest-stable upgrade preservation is unshown, and the new regression tests have no supplied base-red/head-green demonstration.
Agent review details

How this fits together

Gateway tool assembly combines conversation permissions, plugins, and workspace capabilities; the new policy filters those tools and checks final arguments before execution across native, catalog, HTTP/MCP, and worker paths.

flowchart TD
  A[Deployment configuration] --> B[Tool assembly and ordinary grants]
  B --> C[Shared deployment policy]
  C --> D[Native and catalog tools]
  C --> E[HTTP MCP and workers]
  D --> F[Hooks and live authority checks]
  E --> F
  F --> G[Final action authorization]
  G --> H[Tool effect]
Loading

Technical review

Best possible solution:

Retain the shared policy owner and captured deployment contract, then qualify final effects and existing-install compatibility before merging.

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

This is a new capability rather than a reproducible bug report; current source establishes the missing deployment action ceiling, and no target execution was performed.

Is this the best way to solve the issue?

A shared evaluator at assembly and final argument authorization is a coherent first stage using existing execution and inheritance owners; the separate automation and Codex adapter work should remain separately scoped.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Qualify retained authority before merging (recommended)
    Supply current-policy final-effect traces showing allowed calls and rejection of prohibited or revoked calls before I/O.
  2. Hold the feature until qualification is available
    Keep the PR open without merging while its execution-authority contract remains unqualified.

Provenance checked

  • Hook rebuilding and execution authority keeps the original intent (fix(agents): preserve tool authority through hook rebuilds #159532: Preserve caller and lifetime wrappers during hook reconstruction so effects and results cannot escape admitted authority.)
  • Workspace-dependent child publication keeps the original intent (3cbbeb0: A child with its own managed worktree must retain policy-approved publication even when the parent lacks a publishable workspace.)
  • Tool Search action-dependent output validation changes intended behavior with a stated reason (feat(code-mode): infer results from the requested action #147291: Validate results against both executed and advertised action contracts, preserving represented failure outcomes; this PR explains why explicit worker error results must bypass successful-output validation.)
  • Structured worker error transport keeps the original intent (0606e31: Gateway-owned operations return structured errors across worker boundaries; the new isError marker preserves those failures through catalog validation.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete bypass was identified, but this new authorization boundary remains unqualified.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit bc60cd9 adds src/agents/agent-tools.before-tool-call.wrapper.ts:485 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc60cd94b485; files: src/agents/agent-tools.before-tool-call.wrapper.ts)
  • Shakker: Raw commit 3cbbeb0 adds src/gateway/worker-environments/worker-session-tool-executor.ts:178 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3cbbeb08d471; files: src/gateway/worker-environments/worker-session-tool-executor.ts)

PR surface

Source +323, Tests +632, Docs +25, Generated 0. Total +980 across 52 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 30 532 209 +323
Tests 19 728 96 +632
Docs 1 25 0 +25
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 52 1288 308 +980

Review metrics

Metric Value Why it matters
New configuration surface 1 optional namespace tools.gatewayPolicy introduces a required allow list and optional action map, with restart-required activation.
New SDK exports 2 policy helpers The existing agent-harness-tool-runtime entrypoint exposes shared filtering and final-argument assertions for harness adapters.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is an optional deployment-control feature with clear operator value and no established urgent production regression.
  • merge-risk: 🚨 compatibility: The PR expands the SDK and configuration contracts and deliberately rejects unsupported action schemas when enabled; its maintainer-authored restart contract explicitly accepts that activation model.
  • merge-risk: 🚨 security-boundary: The deployment ceiling controls model-directed effects across native, HTTP/MCP, and worker execution, including retained authority.
  • 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 final-effect proof for prohibited model calls and revoked worker authority, including queued execution and child inheritance.

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 (6 earlier review cycles)
  • reviewed 2026-10-16T19:49:13.422Z sha f624f92 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T17:58:49.743Z sha a929d8b :: needs real behavior proof before merge. :: [P2] Preserve the withheld publisher when projecting action schemas | [P2] Represent the publisher's default action before requiring it explicitly
  • reviewed 2026-10-19T18:41:42.096Z sha c3ce269 :: needs real behavior proof before merge. :: [P2] Preserve the withheld publisher when projecting action schemas | [P2] Represent the publisher's default action before requiring it explicitly
  • reviewed 2026-10-19T23:10:30.944Z sha 50c17bf :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T23:46:35.861Z sha 8fabeb6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-20T00:06:25.988Z sha ef3e8f4 :: needs real behavior proof before merge. :: none

Reviewed October 19, 2026, 9:05 PM ET / October 20, 2026, 01:05 UTC (Revision 7).

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 17, 2026
@stevenlee-oai

Copy link
Copy Markdown
Contributor Author

Codex: Clarified agent-tools.ts in ef3e8f44790 with a module overview, generic policy naming, and one section for restrictions captured for future children. Comments explain why a parent without a repository may pass publication permission to a child with its own worktree. Permissions and tool behavior are unchanged. The 10 parent/child tests, core typecheck, scoped lint/format and whitespace checks pass; independent source review found no material issues. The PR body separates this verification from the earlier broader test run.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 19, 2026
@stevenlee-oai
stevenlee-oai marked this pull request as ready for review October 20, 2026 00:45
@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: 8c9d271c2cc81f0ac3bb0bce154a7e1254f35457
  • Maintainer: @stevenlee-oai
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/gateway-tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/config/types.tools.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@stevenlee-oai

Copy link
Copy Markdown
Contributor Author

Codex: integrated current main and resolved the conflicts at 46ae92bf4ae8, preserving upstream stable session catalogs and brokered worker publication. Initial hosted CI passed production types and exposed one Workshop compatibility regression. c60fafb88b2e fixes the owning Tool Search success-output validation and restores the worker proxy's structured error results; the Workshop assertions remain unchanged. Scoped lint and fresh independent source review pass. Current-head CI is running; real-Gateway runtime qualification is still pending and is identified separately in the description.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 20, 2026
Preserve deployment-scoped policy enforcement alongside upstream tool metadata and worker fixture changes. Regenerate configuration baselines and remove the obsolete HTTP test port argument.
@stevenlee-oai
stevenlee-oai merged commit 1bd22b2 into main Oct 20, 2026
167 checks passed
@stevenlee-oai
stevenlee-oai deleted the dev/stevenlee/gateway-tool-policy-p0 branch October 20, 2026 22:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…#174547)

Add an optional deployment-wide Gateway tool and action policy after ordinary tool and plugin grants. Filter advertised tools and authorize final arguments before execution. Policy changes activate through restart or replacement.

Preserve existing behavior when no policy is configured, trusted human Gateway administration, and Codex native tools.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: XL 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