Skip to content

feat(agentsapi): configure hosted network access - #161004

Merged
sjf-oa merged 1 commit into
mainfrom
sjf/agentsapi-host-network-public
Sep 29, 2026
Merged

sjf-oa merged 1 commit into
mainfrom
sjf/agentsapi-host-network-public

Conversation

@sjf-oa

@sjf-oa sjf-oa commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Operators need to restrict which network destinations an Agents API hosted VM can reach from OpenClaw.

User Impact

Operators can configure plugins.entries.agentsapi.config.openai_host.network with the API's access and allowed_domains fields. Adding, changing, or removing a configured policy requires an explicit session reset. Omitted or null policy preserves existing hosted sessions and the API default; self-hosted sessions are unchanged.

Why This Change Was Made

Forward the native network policy during hosted-session creation and include configured policy in saved-session identity. This prevents an existing VM from silently continuing under an old policy. Domain semantics remain validated by the API. The generated plugin configuration budget increases by five entries for this requested API-shaped configuration; core and channel configuration budgets are unchanged.

"openai_host": {
  "network": {
    "access": "restricted",
    "allowed_domains": [
      "api.github.com",
      "pypi.org",
      "files.pythonhosted.org"
    ]
  }
}

Evidence

A real ARM64 Docker Gateway run on 2026-09-28 PDT exercised the same network-policy implementation through the Gateway agent endpoint and the hosted VM. Native command records, completed turns, and released binding leases were inspected. These were real service calls, with no mocks or fakes. The existing run is reused by maintainer direction; it preceded this public port and is not an exact build of the public commit or its newer SDK dependency set. Slack transport was not tested.

Policy Destination Observed result
restricted api.github.com HTTP 200, curl exit 0
restricted pypi.org HTTP 200, curl exit 0
restricted files.pythonhosted.org HTTP 404 from origin, curl exit 0
restricted example.com proxy CONNECT 403, curl exit 56
disabled, after reset api.github.com proxy CONNECT 403, curl exit 56

Changing the policy to disabled hot-reloaded the plugin. Continuing the existing session returned the reset-required error. Native session snapshots before and after that rejected continuation were identical, with one completed turn and five items. After explicitly resetting only the test session, its replacement reported network.access=disabled and blocked the previously reachable destination. Both probe turns completed and their binding leases cleared. The requested restricted policy was restored; final Gateway health reported no plugin errors.

Captured native hosted-VM output

Restricted policy:

HOST=api.github.com
http=200
exit=0
HOST=pypi.org
http=200
exit=0
HOST=files.pythonhosted.org
http=404
exit=0
HOST=example.com
curl: (56) CONNECT tunnel failed, response 403
http=000
exit=56

Disabled policy, after reset:

HOST=api.github.com
curl: (56) CONNECT tunnel failed, response 403
http=000
exit=56

The prior environment suite passed 23 tests in 4.96 seconds wall time, with 0.24 seconds test execution. Formatting, scoped lint, and package type checking also passed on that implementation. On the public commit, pnpm test extensions/agentsapi/agentsapi-environment.test.ts --maxWorkers=1 passed all 23 tests in 5.24 seconds wall time. Formatting, scoped TypeScript lint, package type checking, and git diff --check passed. Initial CI exposed missing generated configuration records; those records were regenerated and pnpm config:docs:check now passes. GitHub CI is being rerun for that documentation-only correction. The existing Docker proof remains the live behavior evidence for this change; no additional live run is planned.

@clawsweeper

clawsweeper Bot commented Sep 29, 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.

@sjf-oa

sjf-oa commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@sjf-oa sjf-oa self-assigned this Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-host-network-public branch from e4faad9 to 1703969 Compare September 29, 2026 05:59
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 29, 2026
@sjf-oa

sjf-oa commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

Validation for 1703969dcae75cc5f0274f30f781c66204e30d5b: GitHub CI passed, and the combined CI/security gate is green.

The environment test file passed all 23 cases: 5.24 seconds wall time for the focused command on the unchanged source before the generated-doc amendment, and 0.191 seconds summed case execution in CI. Its shared CI shard passed 114 tests across nine files in 22.00 seconds. Formatting, scoped lint, package type checking, generated configuration records, and whitespace checks also passed.

The real Docker/hosted-VM network proof remains attached in the PR description. It is being reused as requested, with its public-port and SDK-version limitation stated explicitly; no additional live run was performed.

@clawsweeper

clawsweeper Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 2:08 AM ET / 06:08 UTC.

ClawSweeper review

What this changes

The Agents API plugin adds hosted VM network settings, forwards them when creating sessions, and requires a session reset when a configured policy changes.

Merge readiness

✅ Ready for maintainer review

Keep open: current main lacks hosted VM network configuration, and this PR presents a focused plugin-level implementation with credible real-VM evidence.

Priority: P2
Reviewed head: 1703969dcae75cc5f0274f30f781c66204e30d5b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused implementation, meaningful transition tests, and real hosted-VM evidence support a normal good PR rating, with the live run’s earlier build limiting certainty.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body ties plugin configuration and SDK session creation to a real ARM64 Gateway and hosted-VM run, with observed allowed and denied egress and reset-required rejection before continuation. That run predates this public commit and SDK set, while focused current-head tests cover forwarding and identity; unconfigured saved bindings retain their prior fingerprint, so existing-state compatibility is supported.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body ties plugin configuration and SDK session creation to a real ARM64 Gateway and hosted-VM run, with observed allowed and denied egress and reset-required rejection before continuation. That run predates this public commit and SDK set, while focused current-head tests cover forwarding and identity; unconfigured saved bindings retain their prior fingerprint, so existing-state compatibility is supported.
Evidence reviewed 10 items Current-main gap: Current main resolves the hosted environment to its type alone; its plugin manifest has no network setting. The requested capability remains absent.
Hosted policy path: The introduced resolver constructs the hosted network setting; the attempt includes a configured policy in the saved-session fingerprint before the existing SDK session-create call.
SDK dependency signal: The plugin types its environment against the official openai SDK and calls its session-create method, so that SDK contract is relevant to this review.
Findings None None.
Security None None.

How this fits together

The Agents API plugin turns OpenClaw agent requests into OpenAI-hosted sessions. It reads operator configuration and saved session bindings before creating or continuing a session through the official SDK.

flowchart LR
A[Operator network setting] --> B[Agents API plugin]
B --> C{Saved session policy matches?}
C -->|Yes or new session| D[Official Agents API SDK]
C -->|No| E[Reset required]
D --> F[Hosted VM network access]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +44, Tests +97, Docs +38, Generated 0. Total +179 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 48 4 +44
Tests 1 101 4 +97
Docs 1 39 1 +38
Config 0 0 0 0
Generated 2 3 3 0
Other 0 0 0 0
Total 7 191 12 +179

Review metrics

Metric Value Why it matters
Hosted policy configuration 1 new policy object; 2 fields; 3 access modes Operators gain a plugin setting whose values follow the native API contract.
Production and test growth production +44 net lines, tests +97 net lines The production growth is scoped to config metadata, forwarding, and session identity; the tests cover policy transitions.

Technical review

Best possible solution:

Keep hosted egress policy in the Agents API plugin, preserve unconfigured saved sessions, and reject continuation under a changed policy until the operator resets the session.

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

Not applicable: this adds an opt-in capability; current main has no hosted network setting to exercise as an existing-behavior bug.

Is this the best way to solve the issue?

Yes: the plugin already owns hosted environment selection and saved-session identity, so forwarding the native policy there is a narrow fit.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4d8c9bddda7f.

Labels

Label changes:

  • add P2: This is a bounded, opt-in hosted-session improvement with no demonstrated urgent regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body ties plugin configuration and SDK session creation to a real ARM64 Gateway and hosted-VM run, with observed allowed and denied egress and reset-required rejection before continuation. That run predates this public commit and SDK set, while focused current-head tests cover forwarding and identity; unconfigured saved bindings retain their prior fingerprint, so existing-state compatibility is supported.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This is a bounded, opt-in hosted-session improvement with no demonstrated urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body ties plugin configuration and SDK session creation to a real ARM64 Gateway and hosted-VM run, with observed allowed and denied egress and reset-required rejection before continuation. That run predates this public commit and SDK set, while focused current-head tests cover forwarding and identity; unconfigured saved bindings retain their prior fingerprint, so existing-state compatibility is supported.

Evidence

What I checked:

Likely related people:

  • sjf-oa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: 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.

@sjf-oa
sjf-oa merged commit d812797 into main Sep 29, 2026
115 checks passed
@sjf-oa
sjf-oa deleted the sjf/agentsapi-host-network-public branch September 29, 2026 06:11
@sjf-oa

sjf-oa commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

MarMarLabs added a commit to MarMarLabs/openclaw that referenced this pull request Sep 29, 2026
94 upstream commits, including the Telegram, Matrix and Feishu cleanup
(openclaw#160970), the removal of unused Feishu send test fixtures (openclaw#160913) and
hosted network access for the agentsapi plugin (openclaw#161004).

Four conflicts. Two are in Feishu code. In extensions/feishu/src/send.ts,
openclaw#160970 has sendMessageFeishu resolve its target from params and pass the
whole target to sendReplyOrFallbackDirect. That shape is kept. The target still
carries accountId from this branch's send-target.ts, so the table mode
keeps following the delivering account. In
extensions/feishu/src/reply-dispatcher.ts, openclaw#160970 inlined
markVisibleReplySent at six call sites. This branch moved those senders
into reply-senders.ts, which marks a visible reply through that callback,
so the helper and the createFeishuReplySenders call are kept. The inlined
assignments that merged cleanly elsewhere in the file behave the same.

The other two are generated, docs/.generated/config-baseline.counts.json
and docs/.generated/config-baseline.sha256. openclaw#161004 takes plugin from 4431
to 4436. This branch keeps channel at 3788 and core stays at 2475. Both
files came from upstream and were regenerated. build:docker ran in a
separate detached checkout of this commit outside the nested node_modules
install. Regenerating there changed those two files and nothing else,
giving the predicted counts, the upstream core and plugin hashes, this
branch's channel hash and a new combined hash. The three generated-file
checks pass there.

Upstream deleted 28 test files in this range. None of them were added or
changed by this branch.

Feishu: 107 files and 1858 tests in the extension project, 17 files and
311 tests in the database-workers project. Each is one lower than the
previous merge because openclaw#160913 removed a card edit test from send.test.ts
and openclaw#160970 removed a botName test from monitor.reaction.test.ts, neither
touched by this branch. The forwarder test and the routing guards pass,
431 tests. tsgo:core, tsgo:extensions, tsgo:extensions:test,
tsgo:test:root, the line-cap, max-lines and assertion-safety ratchets
against upstream/main, oxlint and oxfmt on the 43 changed code files all
pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
obviyus added a commit that referenced this pull request Nov 1, 2026
…olicies (#190036)

## Summary

- **Problem:** `modelPolicy.allow` had two grammars under one name. Operator roles accepted a model-name prefix such as `openai/gpt-*`; agent policies rejected it. Role matching used a separate glob matcher, and five other callers detected wildcards by hand (`endsWith("/*")`, `slice(0, -2)`, `startsWith`). The copies agreed today but could drift, for example on padded refs like `"openai / *"`.
- **Fix:** `src/config/model-policy-ref.ts` now owns one parser (`parseModelPolicyWildcardRef`: `provider/*`, `provider/namespace/*`, `provider/family-*`) and one matcher (`modelPolicyWildcardMatches`). Role policy matching, config validation, `isModelKeyAllowedBySet`, configured model entries, alias candidates, `models status` and the legacy Codex wildcard migration use them. The role-only parser, the role glob matcher and the role-only validation branch are deleted.
- **User impact:** agent policies now also accept model-name prefixes such as `openai/gpt-*`. Existing agent and role configs keep their meaning; no config is invalidated.

## Evidence

**Live Gateway, real operator-role identity.** Setup:
- Candidate Gateway (`openclaw.mjs gateway run` from this branch) on an isolated HOME, state and loopback port.
- `gateway.auth.mode: "trusted-proxy"` with a loopback proxy that sets `x-forwarded-user: [email protected]`.
- `gateway.roles.default: "limited"`, with `modelPolicy: { allow: ["fixture/echo-*"], deny: ["fixture/echo-restricted*"] }`.
- A loopback fake OpenAI-completions provider that logs every request.
- The client is the real `GatewayClient` (webchat mode, device identity, no token), so the proxy-verified user is its only credential.

```text
(1)+(2) sessions.patch fixture/echo-restricted       -> FORBIDDEN "Your operator role cannot use this model…"
        sessions.patch fixture/echo-restricted-mini  -> FORBIDDEN
        sessions.patch fixture/other-x               -> FORBIDDEN (outside allow)
        sessions.patch fixture/echo-main             -> ok
        agent run on that session                    -> status ok
        provider log: POST /v1/chat/completions model=echo-main   (only request; no echo-restricted* or other-x call)
(3)     live reload narrows the role: deny += "fixture/echo-main*"
        [reload] config change detected; evaluating reload (gateway.roles.definitions.limited.modelPolicy.deny)
        next agent run on the pinned echo-main session -> status error "Your operator role cannot use this model…"
        provider requests before=2 after=2 (no new provider call)
(4)     upgrade cell, same state directory:
        published [email protected] Gateway writes and serves the role config:
          echo-restricted / echo-restricted-mini / other-x -> FORBIDDEN, echo-main -> ok, provider called with echo-main
        stop; candidate `doctor --fix` (agent DB schema 25 -> 39, role config untouched); candidate Gateway on that state:
          identical sessions.patch decisions (diff: IDENTICAL), provider called only with echo-main
```

**Role policy compatibility (main vs this PR, real owner code).** One script prepared role policies through `prepareOperatorModelPolicy` on an `origin/main` checkout and on this branch. It evaluated `allows()` for 12 models under 5 policies (family deny `vendor/restricted-v1*`, family allow `vendor/gpt-*`, nested `router/anthropic/*`, padded ` VENDOR / gpt-* ` with deny `vendor/gpt-5.5*`, inherited-source deny `vendor/restricted-*`). It also captured the `main` snapshots with `captureOperatorModelPolicySnapshot` and restored them on this branch with `restoreOperatorModelPolicySnapshot`.

```text
prepared decisions, main vs PR:           0 differences / 60
main snapshots restored on PR vs main:    0 differences / 60
familyDeny on PR: vendor/restricted-v1 false, vendor/restricted-v1-mini false, vendor/restricted-v2 true, vendor/primary true
```

**Admission proof.** New case in `src/gateway/sessions-patch.operator-model-policy.test.ts` drives `projectSessionsPatchEntry` (the `sessions.patch` owner that admits a model before any run or provider request) with role policy `allow: ["fixture/*"]`, `deny: ["fixture/restricted-v1*"]`, once with the freshly prepared policy and once with a policy restored from its captured snapshot:

```text
fixture/restricted-v1       -> FORBIDDEN "operator role cannot use this model"
fixture/restricted-v1-mini  -> FORBIDDEN
fixture/allowed             -> ok; after the operator source is revoked, its commit guard -> FORBIDDEN
```

It fails with this PR's first matcher (strict length check) and passes now. Rebased onto #190019; `pnpm check:changed` and the auth-model-policy suites pass on the rebased head.

Role admission suites that consume this predicate before provider calls also pass on this branch: model fallback, CLI runner, isolated completion and image fallback operator-policy suites, plus `operator-model-policy.test.ts` (65 tests).

- New regression in `model-visibility-policy.test.ts` (agent policy `openai/gpt-5.6-*` allows `gpt-5.6-sol`, not `gpt-5.5`) fails on `origin/main` and passes here.
- Validation table adds `openai/gpt-*` (valid for agents) and rejects `openai/gpt *` and `*`.
- Focused suites pass: model visibility, config model-ref validation, operator model policy, role mutation authority, `models status`, legacy Codex model migration, configured model entries, model selection.
- Role compatibility: `modelPolicyWildcardMatches` is a plain prefix test, the same set the old role glob (`^prefix.*$`) accepted, because the parser forbids any other `*`. A new operator-policy regression (`allow: ["vendor/*"]`, `deny: ["vendor/restricted-v1*"]` must deny `vendor/restricted-v1` itself) fails on the first head of this PR and passes now. Stored role snapshots keep the same canonical wildcard keys, so restored policies match as before.
- `pnpm check:changed` (dead-code step skipped) passes; config docs baseline regenerated.

## Merge danger

Two-way door: no stored state or migration; a revert restores the narrower agent grammar. Blast radius: model policy matching for agents and operator roles. Role semantics are unchanged (same prefix rule, same normalized `provider/model` key).

Pash/Sarah check: Sarah's commits on these files (#161609, #162335, #161048, #161004, #159363, #158307, #158703, #151176, #123875) touch Agents API, Codex and Slack config help/validation entries. This PR edits only model-policy wildcard parsing, matching and help text, so their behavior is unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…olicies (openclaw#190036)

## Summary

- **Problem:** `modelPolicy.allow` had two grammars under one name. Operator roles accepted a model-name prefix such as `openai/gpt-*`; agent policies rejected it. Role matching used a separate glob matcher, and five other callers detected wildcards by hand (`endsWith("/*")`, `slice(0, -2)`, `startsWith`). The copies agreed today but could drift, for example on padded refs like `"openai / *"`.
- **Fix:** `src/config/model-policy-ref.ts` now owns one parser (`parseModelPolicyWildcardRef`: `provider/*`, `provider/namespace/*`, `provider/family-*`) and one matcher (`modelPolicyWildcardMatches`). Role policy matching, config validation, `isModelKeyAllowedBySet`, configured model entries, alias candidates, `models status` and the legacy Codex wildcard migration use them. The role-only parser, the role glob matcher and the role-only validation branch are deleted.
- **User impact:** agent policies now also accept model-name prefixes such as `openai/gpt-*`. Existing agent and role configs keep their meaning; no config is invalidated.

## Evidence

**Live Gateway, real operator-role identity.** Setup:
- Candidate Gateway (`openclaw.mjs gateway run` from this branch) on an isolated HOME, state and loopback port.
- `gateway.auth.mode: "trusted-proxy"` with a loopback proxy that sets `x-forwarded-user: [email protected]`.
- `gateway.roles.default: "limited"`, with `modelPolicy: { allow: ["fixture/echo-*"], deny: ["fixture/echo-restricted*"] }`.
- A loopback fake OpenAI-completions provider that logs every request.
- The client is the real `GatewayClient` (webchat mode, device identity, no token), so the proxy-verified user is its only credential.

```text
(1)+(2) sessions.patch fixture/echo-restricted       -> FORBIDDEN "Your operator role cannot use this model…"
        sessions.patch fixture/echo-restricted-mini  -> FORBIDDEN
        sessions.patch fixture/other-x               -> FORBIDDEN (outside allow)
        sessions.patch fixture/echo-main             -> ok
        agent run on that session                    -> status ok
        provider log: POST /v1/chat/completions model=echo-main   (only request; no echo-restricted* or other-x call)
(3)     live reload narrows the role: deny += "fixture/echo-main*"
        [reload] config change detected; evaluating reload (gateway.roles.definitions.limited.modelPolicy.deny)
        next agent run on the pinned echo-main session -> status error "Your operator role cannot use this model…"
        provider requests before=2 after=2 (no new provider call)
(4)     upgrade cell, same state directory:
        published [email protected] Gateway writes and serves the role config:
          echo-restricted / echo-restricted-mini / other-x -> FORBIDDEN, echo-main -> ok, provider called with echo-main
        stop; candidate `doctor --fix` (agent DB schema 25 -> 39, role config untouched); candidate Gateway on that state:
          identical sessions.patch decisions (diff: IDENTICAL), provider called only with echo-main
```

**Role policy compatibility (main vs this PR, real owner code).** One script prepared role policies through `prepareOperatorModelPolicy` on an `origin/main` checkout and on this branch. It evaluated `allows()` for 12 models under 5 policies (family deny `vendor/restricted-v1*`, family allow `vendor/gpt-*`, nested `router/anthropic/*`, padded ` VENDOR / gpt-* ` with deny `vendor/gpt-5.5*`, inherited-source deny `vendor/restricted-*`). It also captured the `main` snapshots with `captureOperatorModelPolicySnapshot` and restored them on this branch with `restoreOperatorModelPolicySnapshot`.

```text
prepared decisions, main vs PR:           0 differences / 60
main snapshots restored on PR vs main:    0 differences / 60
familyDeny on PR: vendor/restricted-v1 false, vendor/restricted-v1-mini false, vendor/restricted-v2 true, vendor/primary true
```

**Admission proof.** New case in `src/gateway/sessions-patch.operator-model-policy.test.ts` drives `projectSessionsPatchEntry` (the `sessions.patch` owner that admits a model before any run or provider request) with role policy `allow: ["fixture/*"]`, `deny: ["fixture/restricted-v1*"]`, once with the freshly prepared policy and once with a policy restored from its captured snapshot:

```text
fixture/restricted-v1       -> FORBIDDEN "operator role cannot use this model"
fixture/restricted-v1-mini  -> FORBIDDEN
fixture/allowed             -> ok; after the operator source is revoked, its commit guard -> FORBIDDEN
```

It fails with this PR's first matcher (strict length check) and passes now. Rebased onto openclaw#190019; `pnpm check:changed` and the auth-model-policy suites pass on the rebased head.

Role admission suites that consume this predicate before provider calls also pass on this branch: model fallback, CLI runner, isolated completion and image fallback operator-policy suites, plus `operator-model-policy.test.ts` (65 tests).

- New regression in `model-visibility-policy.test.ts` (agent policy `openai/gpt-5.6-*` allows `gpt-5.6-sol`, not `gpt-5.5`) fails on `origin/main` and passes here.
- Validation table adds `openai/gpt-*` (valid for agents) and rejects `openai/gpt *` and `*`.
- Focused suites pass: model visibility, config model-ref validation, operator model policy, role mutation authority, `models status`, legacy Codex model migration, configured model entries, model selection.
- Role compatibility: `modelPolicyWildcardMatches` is a plain prefix test, the same set the old role glob (`^prefix.*$`) accepted, because the parser forbids any other `*`. A new operator-policy regression (`allow: ["vendor/*"]`, `deny: ["vendor/restricted-v1*"]` must deny `vendor/restricted-v1` itself) fails on the first head of this PR and passes now. Stored role snapshots keep the same canonical wildcard keys, so restored policies match as before.
- `pnpm check:changed` (dead-code step skipped) passes; config docs baseline regenerated.

## Merge danger

Two-way door: no stored state or migration; a revert restores the narrower agent grammar. Blast radius: model policy matching for agents and operator roles. Role semantics are unchanged (same prefix rule, same normalized `provider/model` key).

Pash/Sarah check: Sarah's commits on these files (openclaw#161609, openclaw#162335, openclaw#161048, openclaw#161004, openclaw#159363, openclaw#158307, openclaw#158703, openclaw#151176, openclaw#123875) touch Agents API, Codex and Slack config help/validation entries. This PR edits only model-policy wildcard parsing, matching and help text, so their behavior is unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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

docs Improvements or additions to documentation extensions: agentsapi size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants