Skip to content

fix(exec): autoAllowSkills ignored for gateway-host exec - #158244

Open
fede-kamel wants to merge 21 commits into
openclaw:mainfrom
fede-kamel:feat/gateway-auto-allow-skills
Open

fede-kamel wants to merge 21 commits into
openclaw:mainfrom
fede-kamel:feat/gateway-auto-allow-skills

Conversation

@fede-kamel

@fede-kamel fede-kamel commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #158165

What Problem This Solves

Fixes: with exec approvals in allowlist mode and autoAllowSkills: true, an agent whose commands run on the Gateway host is still denied (exec denied: allowlist miss) the binaries its own workspace skills declare in requires.bins. autoAllowSkills only took effect on node hosts.

User Impact

User impact: Gateway-hosted agents (containers, servers, most self-hosted setups) can use allowlist mode with autoAllowSkills and have the binaries of their eligible skills allowed, without a hand-kept allowlist that duplicates skill metadata. Binaries of disabled or otherwise ineligible skills, and binaries no skill declares, stay denied. With autoAllowSkills off (the default), nothing changes.

Why This Change Was Made

The gateway exec host evaluated the allowlist without skill bins, while the node host passes them (skills.bins). When the agent's effective approvals enable autoAllowSkills, the gateway host now trusts only the bins declared by the executing agent's eligible skills: the set its prompt sees (resolveWorkspaceSkillPromptEntries: enabled, allowed by the bundled-skills allowlist and the agent's skill filter, requirements met). It never trusts every installed skill, so a disabled bundled skill cannot grant execution trust. Those bins go to the same allowlist evaluation the node host uses. This is the agent-scoped option recommended in the issue review. Bins are resolved on the same PATH the command resolves on: the Gateway's PATH plus operator tools.exec.pathPrepend. Host exec already rejects a requested PATH (Custom 'PATH' variable is forbidden during host execution), so a tool call cannot point a skill bin name at another binary; a test pins that invariant. The evaluation moves into a sibling module, so the already-over-cap gateway host file shrinks.

Evidence

Real Gateway, allowlist mode, before and after. Same script for both: a fresh state dir; approvals agents.main = { autoAllowSkills: true, allowlist: [] }; two workspace skills, skill-tool (requires skill-tool) and disabled-skill (requires disabled-tool, with skills.entries.disabled-skill.enabled: false); the three executables on the Gateway's PATH; openclaw gateway run; then one openclaw agent turn per command. The model is a scripted local OpenAI-compatible stub (deterministic, no keys) that asks the exec tool to run one command and replies with the result.

===== BEFORE (published 2026.9.5 image)
[before] OpenClaw 2026.9.5 (ec9c1a1)
[before] approvals main: {"autoAllowSkills":true,"allowlist":[]}
[before] agent turn: the model asks exec to run: skill-tool
[before]   reply:   "error": "exec denied: allowlist miss"
[before] agent turn: the model asks exec to run: disabled-tool
[before]   reply:   "error": "exec denied: allowlist miss"
[before] agent turn: the model asks exec to run: other-tool
[before]   reply:   "error": "exec denied: allowlist miss"

===== AFTER (this PR, built from 659b5e30dc)
[after] OpenClaw 2026.9.6 (659b5e3)
[after] approvals main: {"autoAllowSkills":true,"allowlist":[]}
[after] agent turn: the model asks exec to run: skill-tool
[after]   reply: exec returned: skill-tool ran
[after] agent turn: the model asks exec to run: disabled-tool
[after]   reply:   "error": "exec denied: allowlist miss"
[after] agent turn: the model asks exec to run: other-tool
[after]   reply:   "error": "exec denied: allowlist miss"

Eligibility is OpenClaw's own: when the executables sit only in a tools.exec.pathPrepend directory, openclaw skills check lists skill-tool (bins: skill-tool) under missing requirements, so the skill is not in the agent's prompt and its bin is not trusted either. The trusted set always matches what the model is shown.

Tests and checks

  • New src/agents/bash-tools.exec-host-gateway.auto-allow-skills.test.ts (real exec tool, gateway host, allowlist mode): an eligible skill's bin runs with autoAllowSkills on; denied with it off; a bin only a disabled skill declares stays denied; a bin no skill declares stays denied; a requested PATH reaching a planted skill-named binary is refused. The eligible-skill test fails with the source change removed (1 failed / 4 passed). The disabled-skill test fails against an earlier revision of this PR that collected bins from every installed skill, and passes now.
  • pnpm vitest run over the gateway exec host, exec run, and exec allowlist test files: 7 files, 218 passed.
  • pnpm tsgo:core and pnpm tsgo:core:test: clean.
  • pnpm check:changed: all steps pass (including the line-cap ratchet) except core tsgo graph boundary ("agents-root: 721 test roots exceeds the advisory 720 limit"), which reports the same 721 on a clean checkout of main and is unrelated to this change.

Authority-chain proof (revision 3)

Addresses the P1 finding: the resolver reloaded eligible skills from agent config
alone, ignoring the admitted session's narrowing.

Driven through the real gateway exec path — real skill loader, real PATH
resolution, real process supervisor, nothing mocked. The skill's declared bin
appends to a marker file, so a denial is observable as the absence of any I/O
rather than only as a returned error.

Before (659b5e30dc3, the previously reviewed head)

[1] baseline: skill eligible for the run
    outcome: status=completed exitCode=0        marker: I/O HAPPENED (1 run)
[2] session filter excludes the declaring skill
    outcome: status=completed exitCode=0        marker: I/O HAPPENED (1 run)
[3] session override turns the declaring skill off
    outcome: status=completed exitCode=0        marker: I/O HAPPENED (1 run)
[4] bin repointed after authorization, before launch
    outcome: allowed                            marker: no I/O

A session-excluded skill's binary reached process launch and executed.

After (this revision)

[1] baseline: skill eligible for the run
    outcome: status=completed exitCode=0        marker: I/O HAPPENED (1 run)
[2] session filter excludes the declaring skill
    outcome: DENIED: exec denied: allowlist miss        marker: no I/O
[3] session override turns the declaring skill off
    outcome: DENIED: exec denied: allowlist miss        marker: no I/O
[4] bin repointed after authorization, before launch
    authorized: deniedResult=no, revalidateBeforeExecution=function
    outcome: DENIED at spawn boundary:
      Exec denied (SYSTEM_RUN_DENIED: skill bin authorization changed
      before execution): probe-tool                    marker: no I/O

Case [4] covers the revocation-before-launch request. The approvals file records
the autoAllowSkills flag but never the executable a skill authorized, so the
committed-policy recheck cannot see that binary change while approval settles;
the bins are re-resolved at the spawn boundary instead. The trust comparison is
now shared with the allowlist evaluator (isSegmentAuthorizedBySkillBins) so the
granting and revalidating checks cannot drift.

Scope note: the recheck observes executable identity and the admitted scope. A
skill's on-disk source changing mid-run is picked up by the skills watcher's
version bump, not by this path.

Regression coverage added in
src/agents/bash-tools.exec-host-gateway.auto-allow-skills.test.ts: session
filter exclusion, session override exclusion, the allowed case under an
including filter, and spawn-boundary denial on a swapped bin.

Detached approval launch (revision 5)

Addresses the follow-on P1: the detached launch kept its own spawn gate that
rechecked only cwd and mutable-operand drift, so revalidateBeforeExecution —
which carries the skill check — was never consulted on that path.

All five gateway launch paths now recheck skill authority at their spawn
boundary: inline ask, ask-fallback, auto-review allow-once, detached approval,
and the direct allowlist path. The check is split into a reason-returning
resolver and the result-returning wrapper the inline paths use, so both call
shapes share one implementation.

Regression test revalidates skill authority in the detached approval launch
drives ask: "always" with a backgrounded approval, has the launch adapter
invoke beforeSpawn as the real runtime does, and asserts the follow-up reports
the denial and that spawn is never reached. Reverting only the beforeSpawn
change flips it to the bypass, which is the reported defect:

with the fix:      DENIED ... skill bin authorization changed before execution
without the fix:   Exec finished (gateway id=req-1, sess...)   <- launched and ran

pnpm tsgo:core clean; 137 passed across the two gateway exec test files, 907
across the exec-approvals and bash-tools exec suites.

Rebased onto main (revision 6)

Rebased onto current main. Two things on main changed what this PR has to cover.

A sixth launch path. Main added a gateway launch path: a cron occurrence that consumes a standing grant. It rechecked only the grant, so a segment admitted on skill-bin trust could launch after that trust was withdrawn. It now rechecks skill authority before the grant is consumed, so a withdrawn skill denies the launch without spending the grant. All six launch paths now recheck at their spawn boundary: inline ask, ask-fallback, auto-review allow-once, detached approval, the direct allowlist path, and cron standing grants. New regression test: rechecks skill authority before spending a standing grant in bash-tools.exec-cron-grant.test.ts. It fails without the recheck.

The line-cap ratchet now runs on pull requests. The gateway host, its unit test and the infra allowlist evaluator stay at or below their size on main:

  • The spawn-boundary rechecks (approval-binding drift, the denial result, chaining, the skill-authority recheck) moved to bash-tools.exec-host-gateway-revalidation.ts.
  • Skill-bin trust matching moved to infra/exec-approvals-skill-bins.ts, re-exported through exec-approvals.

Detached approval proof, without mocks. The revision-5 test revalidates skill authority in the detached approval launch mocked the launch adapter. It is replaced by detached approval launch … in bash-tools.exec-host-gateway.auto-allow-skills.test.ts, which runs the real approval, launch adapter and spawn boundary. The command launches while skill trust holds, and is denied before spawn once the authorizing skill is uninstalled while approval is pending. The denial case fails without the detached-launch fix.

docs/tools/exec-approvals.md now says the recheck covers every gateway launch path.

Checks: pnpm tsgo:core and the changed test files typecheck clean. The autoAllowSkills suite, the gateway exec host tests, the cron-grant tests, exec-approvals and the node-host allowlist tests pass. The line-cap, mock-exports and import-cycle checks pass. The one red CI job on this head, checks-node-changed, fails only in src/gateway/x-publication-owner-composition.e2e.test.ts (404 vs 200), an X-publication route this PR doesn't touch. The exec e2e tests in the same job pass.

Final-initiation recheck (revision 7)

What was wrong. The skill-authority recheck ran once, before launch preparation. The launch could then still await four things before the native spawn: standing-grant consumption (cron), secret-egress registration, the supervisor scope fence, and adapter preparation. The synchronous guards at the end of runExecProcess checked only source, operator and committed-policy/grant authority. So a skill uninstalled, or a bin repointed, during one of those waits still let the pinned command launch.

What changed.

  • Each async re-resolution (verifyGatewaySkillBinAuthority in bash-tools.exec-host-gateway-allowlist.ts) now returns the authority it verified, and the recheck holds it. That held authority is the skill source revision (getSkillsSourceVersion, read before discovery), the bins that authorized the command, and the PATH they resolve on.
  • A new synchronous check, findStaleHeldGatewaySkillBinSegment, rechecks that held authority. It denies in three cases: nothing was verified, the skill source revision moved (a skill was installed, removed or reconfigured), or an authorizing bin now resolves to a different executable. It uses the same isSegmentAuthorizedBySkillBins comparison as allowlist evaluation, so the single shared implementation is kept.
  • createGatewaySkillBinAuthorityRecheck (in bash-tools.exec-host-gateway-revalidation.ts) exposes that check as assertSkillBinAuthorityCurrent. The gateway composes it into the assertCurrent it hands to the runtime: the committed-authorization assertion for the inline paths and detached approval, and the grant's assertion for cron standing grants.

Where it runs. runExecProcess passes that assertCurrent to the supervisor as beforeSpawn. It also wraps it into initiateSpawn (createExecLaunchLifecycle().wrap), which calls it synchronously right before launch(). No await sits between the check and the native spawn. All six launch paths go through it: inline ask, ask-fallback, auto-review allow-once, detached approval, direct allowlist, and cron standing grant. A refusal at initiation throws GatewaySkillBinAuthorityWithdrawnError, an ExecProcessPreflightError. The exec tool unwraps it into the usual denial result, and a detached launch reports it in its follow-up. On the cron path the grant has already been consumed when this final check refuses. That matches how the other final-initiation refusals already behave there.

Regression tests.

  • src/agents/bash-tools.exec-host-gateway.skill-initiation.test.ts, new. It runs the real gateway authorization, runExecProcess, supervisor, child adapter and native launch. The skill bin is a copy of touch that writes a marker file. Trust is withdrawn inside the secret-egress registration await, after the spawn preflight has passed. That is the only seam: the registry is wrapped through importOriginal.
    • launches the skill bin while skill trust holds through initiation is the allowed control. The marker is written.
    • denies at native initiation when the authorizing skill is uninstalled after preflight
    • denies at native initiation when the trusted bin name is repointed after preflight
  • detached approval launch denies at native initiation when trust is withdrawn after preflight, in bash-tools.exec-host-gateway.auto-allow-skills.test.ts. The supervisor stand-in uninstalls the skill and then calls the real initiateSpawn hook. The launch callback is never invoked, and the follow-up carries the skill denial.

With the fix (3 + 12 tests across the two files, all pass):

✓ launches the skill bin while skill trust holds through initiation
✓ denies at native initiation when the authorizing skill is uninstalled after preflight
✓ denies at native initiation when the trusted bin name is repointed after preflight
✓ detached approval launch denies at native initiation when trust is withdrawn after preflight

Without the fix (the three source files reverted, tests kept), the withdrawn command launches and runs:

× denies at native initiation when the authorizing skill is uninstalled after preflight
  → expected { status: 'completed', …(7) } to be undefined   (exitCode 0, exitReason "exit")
× denies at native initiation when the trusted bin name is repointed after preflight
  → expected { status: 'completed', …(7) } to be undefined   (exitCode 0, exitReason "exit")
× detached approval launch denies at native initiation when trust is withdrawn after preflight
  → Received: "Exec denied (gateway id=…, spawn-failed): skill-tool"   (initiation was not refused)

Checks: pnpm tsgo:core and the core test typecheck are clean. oxfmt and scoped core oxlint pass on the changed files. check:changed passes the line-cap growth ratchet, the max-lines suppression ratchet, the first-party mock export ratchet, the SQLite worker ratchet and format; the import-cycle check (0 cycles) and the remaining lint guards were run separately and pass. Its one failure is the dead-export scan, on extensions/voice-call/src/types.ts: CallBrief, which this PR doesn't touch. The gateway exec host tests and the cron-grant suite pass, with one exception. Locally, executes a cron occurrence via a standing grant without prompting fails with service child cleanup identity lost, and it fails the same way on the unmodified revision-6 head. It passed in CI on that head, so it is a local process-tree environment issue.

Not included yet: real-Gateway traces of delayed detached and standing-grant launches, with an allowed and a withdrawn-trust case. They are pending maintainer acceptance of the Gateway autoAllowSkills scope.

Executing-agent skill ownership and real Gateway traces (revision 8)

Head: 0a4297accba (one commit on top of e0e151ea91b; no rebase, the branch merges cleanly with main).

What was wrong. Tool assembly can borrow another agent's tool policy. agent-tools.ts then has two ids: agentId, the policy owner from the capability profile (options.policyAgentId, or the profile a caller passes in), and executionAgentId, the agent that actually runs (options.agentId, or the agent of runSessionKey). Exec defaults received only agentId, and resolveGatewaySkillBins used it. So under a borrowed policy, autoAllowSkills loaded the policy agent's workspace, while the run's skill snapshot (skillScope) came from the executing agent. A bin declared only by the policy agent's skill was trusted, and a bin declared by the executing agent's own skill was not.

What changed.

  • ExecSkillScope gains ownerAgentId. agent-tools.ts now always sets skillScope.ownerAgentId = executionAgentId, next to the session filter and overrides from the same run's snapshot. Before, the scope was only set when a snapshot existed.
  • resolveGatewaySkillBins (bash-tools.exec-host-gateway-allowlist.ts) resolves the workspace and the eligible skills from skillScope.ownerAgentId. It falls back to agentId only for callers that don't separate the two. That one resolver feeds all three skill checks: allowlist evaluation, the async re-resolution in verifyGatewaySkillBinAuthority, and the authority it holds. The held authority records that agent's workspaceDir and skill source revision, so the synchronous findStaleHeldGatewaySkillBinSegment check at native initiation watches the executing agent's skills. No await was added before the spawn.
  • Approval policy is unchanged and stays with agentId. That covers the approvals-file entry, the autoAllowSkills flag, ask/security, and the cron standing-grant source match.
  • Node host, for comparison: skills.bins returns the union of bins across every configured agent (agentSkillFilter: "ignore"), so the node has no per-agent owner to disagree with. The gateway stays narrower: only the executing agent's skills that its run admitted.
  • The skill owner is carried inside the existing skillScope instead of as a new top-level exec option. This keeps bash-tools.exec-run.ts at the line cap: a top-level field would have taken it from 700 to 701 counted lines.

Regression tests.

  • New: src/agents/bash-tools.exec-host-gateway.skill-owner.test.ts. It has no mocks. It assembles exec through createOpenClawCodingTools with agentId: "execution", policyAgentId: "main" and runSessionKey: "agent:execution:main", the same borrow shape as the gateway-tool assembly test. Then it calls the real exec tool, which runs the gateway authorization, supervisor and native launch. The approvals entry exists only for main. Each agent's workspace has one skill: main declares policy-tool, execution declares exec-tool. Both bins are copies of touch.
    • runs a bin declared by the executing agent's own skill: the marker is written.
    • denies a bin declared only by the policy agent's skill, with no I/O: exec denied: allowlist miss, and there is no marker.
  • bash-tools.exec-host-gateway.skill-initiation.test.ts (real native path) adds a borrowed-policy variant. The allowed control runs as execution under main's policy. denies at native initiation when the executing agent's skill is uninstalled under a borrowed policy after preflight uninstalls the skill during the post-preflight await. The denial comes from the synchronous initiation check against the executing agent's held authority.

With the fix:

✓ skill-owner      > runs a bin declared by the executing agent's own skill
✓ skill-owner      > denies a bin declared only by the policy agent's skill, with no I/O
✓ skill-initiation > launches the skill bin while skill trust holds through initiation (borrowed policy: true)
✓ skill-initiation > denies at native initiation when the executing agent's skill is uninstalled under a borrowed policy after preflight

Without the fix (agent-tools.ts, bash-tools.exec-host-gateway-allowlist.ts and bash-tools.exec-types.ts reverted, tests kept), the policy agent's bin runs and the executing agent's own bin is refused:

× denies a bin declared only by the policy agent's skill, with no I/O
  - "denied": "Error: exec denied: allowlist miss",  "ran": false
  + "details": { "status": "completed", "exitCode": 0, "exitReason": "exit", … },  "ran": true
× runs a bin declared by the executing agent's own skill
  - "details": { "status": "completed", "exitCode": 0 },  "ran": true
  + "ran": false
× launches the skill bin while skill trust holds through initiation (borrowed policy: true)
  → exec denied: allowlist miss
× denies at native initiation when the executing agent's skill is uninstalled under a borrowed policy after preflight
  → exec denied: allowlist miss

The three non-borrowed skill-initiation cases pass both with and without the fix.

Correction to the cron standing-grant wording (revision 6). Revision 6 said the cron recheck means "a withdrawn skill denies the launch without spending the grant". That is too broad. The skill recheck applies only to segments the occurrence's own preflight admitted on skill trust. A command the operator explicitly allow-always granted runs on that grant, whether or not a skill still declares its bins. The grant was minted for the exact operation (command, cwd, env), so it authorizes the command independently of skill trust. Grant consumption in detail:

  • Not consumed: the occurrence's preflight admitted a segment on skill trust, and the async recheck before consumption finds that trust withdrawn. The launch is denied and useCount is unchanged.
  • Consumed, then denied: trust is withdrawn after consumption but before native initiation. The synchronous initiation check refuses the launch, and the use is already spent (as revision 7 noted).
  • Consumed, launched: the skill is withdrawn before the occurrence starts. Its preflight then admits nothing on skill trust, the grant covers the whole command, and the occurrence runs on the grant. This is occ3 below.
  • Grant not used at all: every segment is admitted on skill or allowlist trust, so nothing asks. The command runs directly and the grant is neither checked nor consumed.

Real Gateway traces on this head (OpenClaw 2026.9.8 (0a4297a), built from a clean detached checkout of this commit). The harness is the same as described before: an isolated state dir and HOME, openclaw gateway run on loopback with token auth, a scripted local OpenAI-compatible stub model (no keys), and one connected client with the approvals capability. Decisions are made with openclaw approvals resolve. Bins are native copies of touch, so a launch leaves a marker file. Nothing in the Gateway is mocked. The config now has two agents (agents.ownership: "explicit"): main with workspace skill skill-tool, and ops with its own workspace and skill ops-tool.

[D1] approvals main: {"security":"allowlist","ask":"always","autoAllowSkills":true,"allowlist":[]}
[D1] agent turn (source channel: webhook) -> model asks exec to run: skill-tool skill-effect.marker
[D1] approval requested: id=403cf70e…  tool result returned to the model: approval-pending (run continues)
[D1] skill trust left in place while the approval is pending
[D1] operator: openclaw approvals resolve 403cf70e… allow-once -> resolved allow-once by runtime:cli.
[D1] detached follow-up delivered to the session: Exec finished (gateway id=403cf70e-…, code 0)
[D1] marker: I/O HAPPENED (skill-effect.marker created)

[D2] agent turn (source channel: webhook) -> model asks exec to run: skill-tool skill-effect.marker
[D2] approval requested: id=c1a551df…  tool result returned to the model: approval-pending (run continues)
[D2] WITHDRAW: skill-tool skill uninstalled while the approval is pending (after preflight)
[D2] operator: openclaw approvals resolve c1a551df… allow-once -> resolved allow-once by runtime:cli.
[D2] detached follow-up delivered to the session: SYSTEM_RUN_DENIED: skill bin authorization changed before execution
[D2] marker: no I/O (no marker file)

[X-own]   approvals ops: {"security":"allowlist","ask":"on-miss","autoAllowSkills":true,"allowlist":[]}
[X-own]   agent ops turn (source channel: webhook) -> model asks exec to run: ops-tool own-effect.marker
[X-own]   no approval prompt
[X-own]   marker: I/O HAPPENED (own-effect.marker created)

[X-other] skill-tool is declared only by agent main's workspace skill
[X-other] agent ops turn (source channel: webhook) -> model asks exec to run: skill-tool other-effect.marker
[X-other] approval requested: id=1ebabf77… (not skill-trusted for agent ops: allowlist miss)
[X-other] operator: openclaw approvals resolve 1ebabf77… deny -> resolved deny by runtime:cli.
[X-other] model saw: … Exec denied (gateway id=1ebabf77-…, user-denied): skill-tool other-effect.marker
[X-other] marker: no I/O (no marker file)

[X-main]  agent main turn (source channel: webhook) -> model asks exec to run: skill-tool other-effect.marker
[X-main]  no approval prompt
[X-main]  marker: I/O HAPPENED (other-effect.marker created)
[C] approvals main: {"security":"allowlist","ask":"on-miss","autoAllowSkills":true,"allowlist":[]}
[C] workspace skill marker-skill declares bin: touch (/usr/bin/touch); mkdir is declared by no skill
[C] cron job 7cdb367e… (isolated agent turn) -> model asks exec to run: touch skill-effect.marker && mkdir other-effect.marker
[C/occ1-mint] approval requested: id=32e21217… (cron approval delivered to the approval surface)
[C/occ1-mint] operator: openclaw approvals resolve 32e21217… allow-always -> resolved allow-always by runtime:cli.
[C/occ1-mint] marker: I/O HAPPENED (other-effect.marker,skill-effect.marker)   grant 6d8a8412… uses=0 revoked=false
[C/occ2-held] no approval prompt (standing grant)
[C/occ2-held] marker: I/O HAPPENED (other-effect.marker,skill-effect.marker)   grant 6d8a8412… uses=1 revoked=false
[C/occ3-withdrawn] WITHDRAW: marker-skill uninstalled after the grant was minted, before this occurrence
[C/occ3-withdrawn] marker: I/O HAPPENED (other-effect.marker,skill-effect.marker)   grant 6d8a8412… uses=2 revoked=false

occ3 is the "consumed, launched" case above. The operator's allow-always grant authorizes the exact command, so the occurrence runs and spends one use (uses 1 → 2) after the skill is gone.

About the cross-agent trace. The X cases are two agents, each running as itself. They show that a real Gateway takes skill trust from the running agent's own workspace: ops runs its own bin without a prompt, but main's bin is an allowlist miss for ops, while main itself runs that bin without a prompt. They are not a borrowed-policy run. In this tree an embedded run's policy owner differs from its executing agent only when the run carries sandboxAgentId (RunEmbeddedAgentParams), or when a harness passes policyAgentId (worker-environment placement, the Copilot and Agents API harnesses, all from that same run parameter). No Gateway RPC, CLI flag or config key sets it. The only shipped producers are compaction and the CLI-backend runner's rooted-execution preparation, and neither can be driven with a stub model. So the borrowed-policy proof is the native skill-owner and skill-initiation tests above. D3 (repoint while pending) was not re-run on this head, so it is not repeated here.

Focused tests on this head (local, pnpm vitest run <file> --maxWorkers=2, wall time including startup):

File Result Wall Vitest duration
bash-tools.exec-host-gateway.skill-owner.test.ts (new) 2 passed 32.6 s 18.2 s
bash-tools.exec-host-gateway.skill-initiation.test.ts 5 passed 33.9 s 20.2 s
bash-tools.exec-host-gateway.auto-allow-skills.test.ts 12 passed 43.5 s 26.4 s
bash-tools.exec-cron-grant.test.ts 15 passed, 1 failed (local only) 61.3 s 51.7 s

The one local failure is still executes a cron occurrence via a standing grant without prompting (service child cleanup identity lost), the local process-tree issue noted in revisions 6 and 7. The real Gateway runs the same standing-grant occurrence successfully (occ2 above).

Checks: pnpm tsgo:core passes, and so does the core test typecheck for the changed graphs (agents-tools, agents-root, agents-other; the first full run caught a tuple typing slip in the new test, now fixed). oxfmt and oxlint pass on the changed files. The line-cap ratchet (16 changed source files, no growth over cap), max-lines, mock-factory, SQLite worker, timeout-race and assertion-safety ratchets pass. The import-cycle check reports 0 cycles. The new test is registered in vitest.database-worker-core-paths.mjs next to the other two gateway skill suites.

CLI-backend tool path (revision 9)

Head: 18936becef1 (one commit on top of 0a4297accba; no rebase, the branch merges cleanly with main).

What was left. Revision 8 covered tool assembly that receives the executing agent as agentId. CLI backends take a different route. Their coding tools are minted on the Gateway and mediated over loopback (resolveGatewayScopedTools in src/gateway/tool-resolution.ts). That call passed agentId: policyAgentId, so in agent-tools.ts the derived executionAgentId, and with it skillScope.ownerAgentId, was the policy agent. The two agents really can differ there. The CLI runner (cli-runner/prepare.ts) resolves policyAgentId from runtimePolicySessionKey separately from the session's own agent, and passes both into the loopback grant (agentId plus runtimePolicyAgentId). tool-resolution.ts already had the executing agent as sessionAgentId, but it used that value only for the workspace and the sandbox lookup.

What changed. The fix is narrow. OpenClawCodingToolsOptions gains skillOwnerAgentId, and agent-tools.ts sets skillScope.ownerAgentId = options.skillOwnerAgentId ?? executionAgentId. The loopback path passes skillOwnerAgentId: sessionAgentId. agentId on that call is unchanged, so credentials, hooks, process scope and approval policy (approvals entry, autoAllowSkills, ask/security, grants) stay with the policy agent, as before. Callers that don't set the new option behave exactly as in revision 8.

Regression test. New: src/gateway/tool-resolution.skill-owner.test.ts. It has no mocks and uses the same fixture as the revision 8 skill-owner test, but goes through the CLI-backend entry point. It calls resolveGatewayScopedTools with surface: "loopback", mediatedToolNames: ["exec"], session agent:execution:main (agent execution) and runtime policy session agent:main:main (agent main). Then it runs the resolved exec tool through the real gateway authorization, supervisor and native launch. The approvals entry exists only for main. main's workspace declares policy-tool and execution's declares exec-tool, both copies of touch. The test is registered in vitest.database-worker-core-paths.mjs next to the other gateway skill suites.

With the fix:

✓ runs a bin declared by the executing agent's own skill
✓ denies a bin declared only by the policy agent's skill, with no I/O

Without the fix (only the skillOwnerAgentId line in tool-resolution.ts reverted, so the option plumbing and the test are kept), the policy agent's bin runs and the executing agent's own bin is refused:

× runs a bin declared by the executing agent's own skill
  - "details": { "status": "completed", "exitCode": 0 },  "ran": true
  + "ran": false
× denies a bin declared only by the policy agent's skill, with no I/O
  - "denied": "Error: exec denied: allowlist miss",  "ran": false
  + "details": { "status": "completed", "exitCode": 0, "exitReason": "exit", … },  "ran": true
File Result Wall Vitest duration
tool-resolution.skill-owner.test.ts (new) 2 passed 30.9 s 18.0 s

The existing tool-resolution.exclude.test.ts (24 tests) and the revision 8 bash-tools.exec-host-gateway.skill-owner.test.ts (2 tests) still pass.

Checks: pnpm tsgo:core passes, and so does the core test typecheck for the gateway-root graph that holds the new test. oxfmt and oxlint pass on the changed files. The line-cap ratchet (19 changed source files, no growth over cap) and the max-lines ratchet pass. The import-cycle check reports 0 cycles.

CLI grant carries the admitted skill narrowing; merged with main (revision 10)

Head: see the latest commit (main merged in at b110c2259f0, plus four commits). The branch was about 21,900 commits behind, so main is merged in, not rebased; the merge commit holds only the conflict resolution.

The remaining P1. Revision 9 fixed whose skills a CLI-backend run trusts, but not which of them. buildCliMcpGrantContext copied no skill state into the loopback grant, so resolveGatewayScopedTools built mediated exec without the session's skillFilter/skillOverrides, and the gateway resolved the executing agent's full eligible set. A session with skillOverrides: { "exec-tool": false } (or a filter that left exec-tool out) could still launch exec-tool without approval, and the final rechecks repeated the same widened scope.

Fix (e4f477f2022).

  • buildCliMcpGrantContext captures the run's skillFilter and skillOverrides from its skill snapshot as admittedSkillScope on McpLoopbackRequestContext (host-captured, never read from MCP headers).
  • tool-resolution.ts passes execSkillScope: { ownerAgentId: sessionAgentId, ...admittedSkillScope } to mediated tool assembly. Evaluation and every spawn-boundary recheck read that same scope.
  • SDK surface: skillOwnerAgentId is removed from the public OpenClawCodingToolsOptions; execSkillScope is on InternalCodingToolsOptions only, and the public PluginCodingToolsOptions.exec type omits skillScope. Plugin callers cannot supply either, and assembly always derives the scope itself.

Regression, CLI grant path (src/gateway/tool-resolution.skill-owner.test.ts). Still no mocks. The context now comes from the real buildCliMcpGrantContext and is spread into resolveGatewayScopedTools the way mcp-http.runtime.ts spreads it; the resolved exec tool runs through real gateway authorization, the supervisor and a native launch of a touch copy.

✓ runs a bin declared by the executing agent's own skill
✓ denies a bin declared only by the policy agent's skill, with no I/O
✓ runs a bin whose skill the session's snapshot admits
✓ denies a bin whose skill the session's snapshot left filter-excluded, with no I/O
✓ denies a bin whose skill the session's snapshot left override-disabled, with no I/O

With only the admittedSkillScope line in buildCliMcpGrantContext reverted, both exclusion cases launch the binary:

× denies a bin whose skill the session's snapshot left filter-excluded, with no I/O
  - "ran": false
  + "ran": true
× denies a bin whose skill the session's snapshot left override-disabled, with no I/O
  - "ran": false
  + "ran": true

Adapting to main.

  • Main localized collectSkillBins into the skills.bins handler (refactor: localize single-consumer preparation phases #179567). This PR is a second consumer, so src/skills/discovery/bins.ts is restored and skills.bins uses it again; no duplicate collection logic.
  • The revalidation module no longer carries copies of resolveGatewayExecApprovalDrift, revalidateGatewayExecApprovalBinding and buildGatewayExecApprovalDeniedToolResult; main moved them to bash-tools.exec-approval-binding.ts and bash-tools.exec-host-gateway.output.ts, and the gateway host imports them from there.
  • exec-approvals-skill-bins.ts uses isPathScopedExecutableToken from exec-authorization-plan.ts instead of a local copy.
  • Exec defaults moved to agent-tools.assembly.ts on main; skillScope is set there now.
  • bumpSkillsSnapshotVersion no longer takes changedPath; the gateway skill suites drop it.
  • Line cap (0e17db36d6c): main shrank bash-tools.exec-host-gateway.ts to 1171 counted lines, so the skill wiring would have grown it to 1198. The per-session consecutive auto-review denial streak moves to bash-tools.exec-host-gateway.auto-review-denials.ts, and allowlist evaluation plus its skill-bin authority recheck become one entry point in the revalidation module (evaluateGatewayShellAllowlistWithSkillAuthority, with holdWith for the standing-grant initiation check). The ratchet passes with no over-cap growth.

Tests run (local, 2 workers), on the final head: bash-tools.exec-host-gateway (including the auto-review denial cases), .auto-allow-skills, .skill-initiation, .skill-owner, tool-resolution.skill-owner and bash-tools.exec-cron-grant (including the standing-grant skill recheck): 74 passed. Before the line-cap refactor, exec-approvals, server-methods/skills.remote (skills.bins) and cli-runner/mcp-grant-context also passed.

File Result Wall (--maxWorkers=1)
tool-resolution.skill-owner.test.ts (3 cases added) 5 passed 28.9 s (Vitest 16.3 s)

Checks: pnpm tsgo:core and pnpm tsgo:core:test pass; oxfmt passes on all 25 changed files; the line-cap ratchet passes; the import-cycle check reports 0 cycles. The dead-export scan's findings are all in files this PR does not touch (already present on main). oxlint could not run locally because this worktree lacks eslint-plugin-solid; CI runs it.

Test-line budget. Main now ratchets total test lines. This PR's net test growth is 848 lines across the five gateway skill-trust suites, recorded as an exact allocation in config/test-lines-allocations/158244-gateway-auto-allow-skills.txt. They are the authority-chain regressions requested across review revisions. Not all of them launch natively, so to be precise:

  • Real native launch, no exec-path mocks: executing-agent ownership (bash-tools.exec-host-gateway.skill-owner.test.ts), CLI-grant narrowing including filter and override exclusions (tool-resolution.skill-owner.test.ts), and the native-initiation recheck (bash-tools.exec-host-gateway.skill-initiation.test.ts, which wraps only the egress-proxy registration hook as the point where trust is withdrawn).
  • Mocked boundaries: the inline and detached-approval rechecks (bash-tools.exec-host-gateway.auto-allow-skills.test.ts mocks the process supervisor and the approval RPCs) and the standing-grant recheck (bash-tools.exec-cron-grant.test.ts supplies mocked allowlist classifications). These pin the recheck ordering and the denial results; they are not native execution evidence.

Proof gap (closed in revision 11). The live CLI-backend Gateway run below replaces the earlier note that no CLI backend could run locally.

Live CLI-backend Gateway and latest-stable upgrade (revision 11)

Live CLI-backend run (head 555a55b). A real openclaw gateway run with the bundled claude-cli backend (claude-cli/claude-opus-5). The only stand-in is the external claude binary the backend launches: a keyless script on PATH, adapted from the repo's qa-lab fake (test/e2e/qa-lab/runtime/reply-run-plugin-reload.product-proof.e2e.test.ts). OpenClaw launches it with the generated --mcp-config. On the user turn it calls exec on the Gateway's loopback MCP server with the per-run grant OpenClaw issued, so grant building (buildCliMcpGrantContext), loopback tool resolution, gateway authorization, the supervisor and the native launch are all production code.

Setup is a fresh state dir:

  • tools.exec is host: gateway, security: allowlist, ask: off.
  • The approvals give main autoAllowSkills: true with an empty allowlist.
  • The agent skill filter is agents.entries.main.skills: ["admitted-tool", "overridden-tool"].
  • The workspace holds three skills, each declaring one bin that is a copy of touch, so a launch leaves a marker file.

The first three turns use openclaw agent. The override turn first sets toolOverrides.skills: {"overridden-tool": false} on its session with sessions.patch, then sends through chat.send.

[proof] OpenClaw 2026.11.3 (555a55b)
[proof] approvals (agent main): {"defaults":{"security":"allowlist","ask":"off","askFallback":"deny"},"main":{"autoAllowSkills":true,"allowlist":[]}}
[proof] agents.entries.main.skills (skill filter): ["admitted-tool","overridden-tool"]; workspace skills: admitted-tool filtered-tool overridden-tool
===== admitted
[admitted] reply: exec ok: (no output)
[admitted] marker: present (admitted-tool launched)
===== filter-excluded
[filter-excluded] reply: exec error: exec denied: allowlist miss
[filter-excluded] marker: absent (filtered-tool never launched)
===== override-control
[override-control] reply: exec ok: (no output)
[override-control] marker: present (overridden-tool launched)
===== override-disabled
[override-disabled] sessions.patch -> entry.toolOverrides = {"skills":{"overridden-tool":false}}
[override-disabled] reply: exec error: exec denied: allowlist miss
[override-disabled] marker: absent (overridden-tool never launched)
===== fake claude log (loopback MCP calls made with the per-run grant)
[fake-claude] mcp__openclaw__exec "admitted-tool <root>/markers/admitted"
[fake-claude] tool result: exec ok: (no output)
[fake-claude] mcp__openclaw__exec "filtered-tool <root>/markers/filter-excluded"
[fake-claude] tool result: exec error: exec denied: allowlist miss
[fake-claude] mcp__openclaw__exec "overridden-tool <root>/markers/override-control"
[fake-claude] tool result: exec ok: (no output)
[fake-claude] mcp__openclaw__exec "overridden-tool <root>/markers/override-disabled"
[fake-claude] tool result: exec error: exec denied: allowlist miss

The override control and the override-disabled turn use the same bin and the same agent filter; the only difference is the session's toolOverrides, which reaches exec through the CLI grant's admitted skill scope.

Latest stable to this PR, same state dir. Published [email protected] (847611d), installed from npm, writes the approvals and runs three turns through the same claude-cli setup. Then this PR's build runs the documented upgrade step and the same turns, with no approval edits. The agent filter here is ["admitted-tool"].

===== 1. published stable writes the approvals
[stable] OpenClaw 2026.11.3 (847611d)
[stable] approvals: {"defaults":{"security":"allowlist","ask":"off","askFallback":"deny"},"main":{"autoAllowSkills":true,"allowlist":[{"pattern":"/usr/bin/printf"}]}}
[stable] printf: exec ok: ok
[stable] admitted-tool: exec error: exec denied: allowlist miss | marker absent
[stable] filtered-tool: exec error: exec denied: allowlist miss | marker absent
===== 2. candidate on the same state: documented upgrade step, no approval edits
[candidate] OpenClaw 2026.11.3 (555a55b)
[candidate] openclaw doctor --fix --non-interactive: exit 0
[candidate] approvals: {"defaults":{"security":"allowlist","ask":"off","askFallback":"deny"},"main":{"autoAllowSkills":true,"allowlist":[{"pattern":"/usr/bin/printf"}]}}
[upgrade] approval settings identical after upgrade
[candidate] printf: exec ok: ok
[candidate] admitted-tool: exec ok: (no output) | marker present
[candidate] filtered-tool: exec error: exec denied: allowlist miss | marker absent

What the upgrade changes.

  • Existing approvals carry over unchanged, and the explicit allowlist entry keeps working.
  • The one behavior change is the one this PR makes: on a Gateway host, an agent that already opted into autoAllowSkills now has its own admitted skills' bins trusted. Before the upgrade, those same approvals did nothing for Gateway-host exec.
  • Skills outside the agent's filter stay denied.
  • The doctor --fix step is not specific to this PR. Starting current main directly on 2026.11.3 state stops with "agent database uses schema version 27 … run openclaw doctor --fix to upgrade it to schema version 41", and openclaw update runs that step itself.

Merged with main after the async exec-resolution cutover (revision 12)

Main's #197634 moved command and executable path resolution off the Gateway's synchronous path. resolveExecutionTargetTrustPath and the skill-bin PATH lookup are now async, and safeRealpathSync is gone from exec resolution. That conflicted with this PR in src/infra/exec-approvals-allowlist.ts and src/node-host/runtime-skill-bins.ts. The port:

  • isSkillAutoAllowedSegment and isSegmentAuthorizedBySkillBins (src/infra/exec-approvals-skill-bins.ts) and the exported resolveSkillBinTrustEntries now use main's async resolution, and every Gateway caller awaits them.
  • One behavior change to the native-initiation recheck. It still runs synchronously with no await before spawn, but now reads only in-memory authority: it denies when no skill authority was verified, or when the skill source revision moved since verification (a skill installed, removed or reconfigured). It no longer re-resolves bin identity from the filesystem at that moment. Doing so would bring back the synchronous realpath/PATH work main just removed.
  • This follows main's own split. Main's initiation-time assertCurrent checks only in-memory authority (committed authorization, source, operator, sandbox), while filesystem identity (the approval cwd snapshot and mutable-file bindings) is rechecked in the async revalidateBeforeExecution. A repointed skill bin is now caught the same way, by the async spawn-boundary recheck (bash-tools.exec-host-gateway.auto-allow-skills.test.ts, "denies at the spawn boundary when the authorizing skill bin is swapped").
  • The tradeoff. A bin repointed during the last awaits before spawn (standing-grant consumption, secret-egress registration, the supervisor fence) is no longer caught at initiation. Repointing requires write access to a directory on the Gateway's PATH, and that same access already lets someone swap an explicitly allowlisted executable in the same window. Ordinary allowlist entries get no initiation-time identity recheck on main either.
  • The repoint row in bash-tools.exec-host-gateway.skill-initiation.test.ts was removed for that reason. The uninstall rows (same and borrowed policy) still fail closed at initiation. Net test growth is now 841 lines, and the exact allocation was shrunk to match.

Checks at 4569ac8:

  • pnpm tsgo:core and pnpm tsgo:core:test are clean, and the import-cycle check reports 0 runtime value cycles.
  • The format check and the line-cap and test-lines ratchets pass.
  • The five gateway skill-trust suites pass (39 tests in the CLI-grant/initiation shard).
  • Main's autoAllowSkills and skill-bin suites across src/infra, src/node-host and the exec host tests pass: 12 files, 237 tests.

Live CLI-backend run, rerun at 4569ac8. Same setup as revision 11, with the same results:

[proof] OpenClaw 2026.11.3 (4569ac8)
[admitted] reply: exec ok: (no output)            | marker: present (admitted-tool launched)
[filter-excluded] reply: exec error: exec denied: allowlist miss | marker: absent (filtered-tool never launched)
[override-control] reply: exec ok: (no output)    | marker: present (overridden-tool launched)
[override-disabled] sessions.patch -> entry.toolOverrides = {"skills":{"overridden-tool":false}}
[override-disabled] reply: exec error: exec denied: allowlist miss | marker: absent (overridden-tool never launched)

Check skill authority once, when a launch starts (revision 13)

This follows main's updated policy (#197557, root AGENTS.md): "Check authority one time, when work starts. Revocation, removal and reload apply to the next request. A started request may finish." It addresses the P2 on revision 12, where installing or updating an unrelated skill during secret-egress registration bumped the workspace skill revision and denied a launch whose own skill and executable were unchanged.

  • Removed:
    • the held skill source revision;
    • the synchronous native-initiation recheck and the holdWith wrapper on the standing-grant assertCurrent;
    • GatewaySkillBinAuthorityWithdrawnError and the detached path's handling of it;
    • the tests that enforced revocation inside an already-started launch: all of bash-tools.exec-host-gateway.skill-initiation.test.ts (with its vitest registration) and the detached native-initiation withdrawal case in bash-tools.exec-host-gateway.auto-allow-skills.test.ts.
  • Kept: the skill-authority recheck when a launch starts, on the inline, approval, detached-approval and standing-grant paths, next to main's cwd and mutable-file binding rechecks. This supersedes the revision 12 note about an in-memory initiation check, which no longer exists.
  • Net test growth: 630 lines, with the exact allocation updated to match.

Checks at c8b326f:

  • pnpm tsgo:core and pnpm tsgo:core:test are clean, and the import-cycle check reports 0 cycles.
  • The format check and the line-cap and test-lines ratchets pass.
  • The gateway skill-trust suites pass: auto-allow-skills, both skill-owner suites, cron grant and exec approvals (39 tests).

Live CLI-backend run, rerun at c8b326f. Same setup as revision 11:

[proof] OpenClaw 2026.11.3 (c8b326f)
[admitted] reply: exec ok: (no output)            | marker: present (admitted-tool launched)
[filter-excluded] reply: exec error: exec denied: allowlist miss | marker: absent (filtered-tool never launched)
[override-control] reply: exec ok: (no output)    | marker: present (overridden-tool launched)
[override-disabled] sessions.patch -> entry.toolOverrides = {"skills":{"overridden-tool":false}}
[override-disabled] reply: exec error: exec denied: allowlist miss | marker: absent (overridden-tool never launched)

Main merged in (revision 14, b896620)

Main had moved 377 commits and conflicted in src/agents/agent-tools.options.ts: main added toolPolicyScope next to this PR's execSkillScope on InternalCodingToolsOptions. The resolution keeps both fields; the merge commit holds only that. No PR code changed. CI never ran on c8b326f because of the GitHub Actions outage on Nov 16 (every workflow on that head ended in startup_failure or failed with 0 jobs), so CI has not run since revision 13. The pull_request workflows for b896620 are waiting for a maintainer to approve them (action_required).

Checks at b896620 (Node 24.19, which main now requires):

  • pnpm tsgo:core and pnpm tsgo:core:test are clean, and the import-cycle check reports 0 cycles.
  • The format check and the line-cap and test-lines ratchets pass (net test growth is still 630).
  • The gateway skill-trust suites pass: auto-allow-skills, both skill-owner suites and cron grant (4 files, 34 tests).

Live CLI-backend run, rerun at b896620. Same setup as revision 11:

[proof] OpenClaw 2026.11.4 (b896620)
[admitted] reply: exec ok: (no output)            | marker: present (admitted-tool launched)
[filter-excluded] reply: exec error: exec denied: allowlist miss | marker: absent (filtered-tool never launched)
[override-control] reply: exec ok: (no output)    | marker: present (overridden-tool launched)
[override-disabled] sessions.patch -> entry.toolOverrides = {"skills":{"overridden-tool":false}}
[override-disabled] reply: exec error: exec denied: allowlist miss | marker: absent (overridden-tool never launched)

Review follow-up and main merged in again (revision 15, b4ca486)

  • Low-value test removed. The re-review of b896620 flagged rechecks skill authority before spending a standing grant in bash-tools.exec-cron-grant.test.ts. It forced a skills classification while autoAllowSkills was off and the executable was unresolved, which the real evaluator cannot produce, so it did not prove the withdrawal case it named. The file is back to main's version. The standing-grant path still rechecks skill authority before the grant is consumed (unchanged code); the real-Gateway cron trace in revision 8 ([C/occ2-held]) still covers a standing-grant occurrence. This supersedes the revision 7 and 10 notes that cite that test. Net test growth is now 610 lines, and the allocation shrank to match.
  • Main merged in (247 commits). The only conflict was the import block of src/gateway/server-methods/skills.ts: main imports SkillApiKeyReferenceError next to updateSkillConfigEntry, and this PR imports collectSkillBins. The resolution keeps both.

Checks at b4ca486 (Node 24.19):

  • pnpm tsgo:core and pnpm tsgo:core:test are clean, and the import-cycle check reports 0 cycles.
  • The format check and the line-cap and test-lines ratchets pass.
  • The gateway skill-trust suites pass: auto-allow-skills, both skill-owner suites and cron grant (4 files, 33 tests).

Live CLI-backend run, rerun at b4ca486. Same setup as revision 11:

[proof] OpenClaw 2026.11.4 (b4ca486)
[admitted] reply: exec ok: (no output)            | marker: present (admitted-tool launched)
[filter-excluded] reply: exec error: exec denied: allowlist miss | marker: absent (filtered-tool never launched)
[override-control] reply: exec ok: (no output)    | marker: present (overridden-tool launched)
[override-disabled] sessions.patch -> entry.toolOverrides = {"skills":{"overridden-tool":false}}
[override-disabled] reply: exec error: exec denied: allowlist miss | marker: absent (overridden-tool never launched)

Main merged in again (revision 16, a04bb80)

Main removed the unused authProfileStoreSource option (#201996). It sat next to this PR's exec override in the PluginCodingToolsOptions omit list in src/agents/agent-tools.options.ts, which was the only conflict. The resolution takes main's list without that field and keeps this PR's exec override, which drops skillScope from caller-supplied exec options. No behavior in this PR changed.

Checks at a04bb80 (Node 24.19): pnpm tsgo:core and pnpm tsgo:core:test are clean. The three gateway skill-trust test files touched by this PR pass (18 tests). Format, oxlint, the line-cap and test-lines ratchets (+610, covered by the existing allocation) and the import-cycle check pass.

@clawsweeper

clawsweeper Bot commented Sep 25, 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 agents Agent runtime and tooling size: M labels Sep 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Extend autoAllowSkills to Gateway-host execution using the executing agent’s eligible skills and admitted session restrictions.

Example: Agent main has autoAllowSkills=true, an empty allowlist, and an eligible skill declaring skill-tool.

  • Before: Gateway execution of skill-tool returns exec denied: allowlist miss.
  • After: skill-tool runs; disabled, session-excluded, and undeclared skill binaries remain denied.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Production-path evidence is strong and no concrete patch defect remains; readiness depends on approval of the permission expansion.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Contributor traces exercise Gateway exec and CLI-loopback grants through shipped CLI/server entry points, showing admitted native launches and excluded-bin denials; relevant skill behavior remains unchanged from the supplied rerun, and no persisted data shape changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Gateway-hosted agents must duplicate skill binary declarations in manual exec allowlists.
Reason: The convenience is demonstrated, but extending a documented node-only execution grant is an owner decision.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR provides a useful Gateway execution capability that current main still lacks, with no concrete correctness defect found. Extending the existing permission setting beyond its documented node-only scope needs maintainer direction.

Priority: P2
Reviewed head: a04bb80d0858a64e3cdd5a893622e6fe141ca429
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should an existing autoAllowSkills=true setting also authorize eligible skill binaries on the Gateway host?
  • Recommendation: Approve agent-scoped Gateway trust: Accept the implemented scope: executing-agent eligibility, admitted session restrictions, resolved executable identity, and the unchanged default-off setting.
  • Why: Existing documentation promises node-only behavior, and no recorded maintainer decision approves expanding that permission to Gateway execution.

Before merge

  • Await maintainer action - A maintainer must approve CI execution and the security-sensitive changes for revision a04bb80.

Findings

None.

Agent review details

How this fits together

Agent tool assembly supplies execution identity and session skill restrictions to Gateway exec, which resolves eligible binaries, evaluates approval policy, and authorizes process launch.

flowchart TD
  A[Agent turn] --> B[Tool assembly or CLI grant]
  B --> C[Gateway exec policy]
  D[Eligible skills and session restrictions] --> C
  E[Approval settings and executable paths] --> C
  C --> F[Launch admission]
  F --> G[Process supervisor]
Loading

Technical review

Best possible solution:

If maintainers approve the scope expansion, retain agent-scoped skill trust through the existing evaluator and launch-admission owner.

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

Current-main source confirms the omitted Gateway skill-trust inputs, and the contributor supplies before/after Gateway traces; this review executed no target code.

Is this the best way to solve the issue?

The implementation reuses existing skill eligibility, executable resolution, and allowlist owners, preserves CLI session narrowing, and avoids the broader all-agent node inventory.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9b1c36d adds src/agents/bash-tools.exec-host-gateway.ts:472 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9b1c36d23c3f; files: src/agents/bash-tools.exec-host-gateway.ts)
  • Jesse Merhi: Raw commit c9707ab adds src/agents/bash-tools.exec-host-gateway.ts:498 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c9707ab635b9; files: src/agents/bash-tools.exec-host-gateway.ts)
  • Josh Avant: Raw commit 1c37c8c adds src/agents/bash-tools.exec-host-gateway.ts:537 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1c37c8cdc71b; files: src/agents/bash-tools.exec-host-gateway.ts)

PR surface

Source +345, Tests +613, Docs +10, Other +5. Total +973 across 24 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 18 472 127 +345
Tests 4 613 0 +613
Docs 1 14 4 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 0 +5
Total 24 1104 131 +973

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded capability improvement for operators using restrictive Gateway execution policy with skills.
  • merge-risk: 🚨 compatibility: Existing autoAllowSkills=true settings gain Gateway behavior without a configuration edit.
  • merge-risk: 🚨 security-boundary: Skill metadata becomes an additional source of Gateway process-execution authority.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • 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 (17 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-10T10:43:13.703Z sha 18936be :: needs real behavior proof before merge. :: [P1] Carry admitted skill exclusions through CLI-mediated exec
  • reviewed 2026-11-11T16:12:27.265Z sha 088dab6 :: needs real behavior proof before merge. :: [P3] Describe the mocked launch coverage accurately
  • reviewed 2026-11-11T17:14:51.849Z sha 555a55b :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-11T17:30:44.812Z sha 555a55b :: blocked before merge. :: none
  • reviewed 2026-11-15T14:50:32.785Z sha 4569ac8 :: blocked before merge. :: [P2] Let admitted exec requests finish across skill refreshes
  • reviewed 2026-11-16T17:07:51.459Z sha c8b326f :: blocked before merge. :: none
  • reviewed 2026-11-17T15:27:39.244Z sha b896620 :: blocked before merge. :: none
  • reviewed 2026-11-17T16:09:18.645Z sha b4ca486 :: blocked before merge. :: none

Reviewed November 19, 2026, 6:13 PM ET / 23:13 UTC (Revision 18).

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Maintainer security review required

This external contributor PR changes sensitive security components. A maintainer must review these changes before merging.

Current SHA: a04bb80d0858a64e3cdd5a893622e6fe141ca429

These sensitive security changes were made:

  • src/infra/exec-approvals-allowlist.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-skill-bins.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

After reviewing the changes, post a new PR comment containing only approval commands, each on its own line:

/allow-security-sensitive-change

A later push requires a fresh approval comment.

Gateway-host exec evaluated the allowlist without skill bins, so
autoAllowSkills only took effect on node hosts: a workspace skill's
declared bin was still denied as an allowlist miss on the Gateway.

When the agent's approval policy enables autoAllowSkills, the gateway
host now trusts the bins declared by that agent's eligible skills only
(the set its prompt sees: enabled, allowed by the bundled allowlist,
requirements met), resolved on the same PATH the command resolves on
(Gateway PATH plus pathPrepend; host exec already rejects a requested
PATH), and passes them to the allowlist evaluation as the node host
does for skills.bins. The evaluation moves to a sibling module so the
gateway host file shrinks. Default behavior is unchanged.

Closes openclaw#158165
The gateway-host skill-bin resolver reloaded eligible skills from agent
config alone, so it ignored the narrower skill set the running session had
actually admitted. A reply can exclude a skill through its session filter
or a session override; with autoAllowSkills enabled, that excluded skill's
declared binary still passed the gateway allowlist and reached process
launch.

Carry the admitted run's skill scope (the snapshot's skillFilter and
skillOverrides) from the tool defaults into the gateway allowlist
evaluation, and apply it when resolving which skills may lend a binary. A
session that excluded a skill no longer borrows its bins, while other
sessions of the same agent are unaffected.

Also recheck skill-bin authority at the spawn boundary. The approvals file
records the autoAllowSkills flag but never the executable a skill
authorized, so the committed-policy recheck cannot see that binary change
while approval settles; re-resolving the bins before launch denies a
trusted name that was repointed at a different executable. The trust
comparison is now shared with the allowlist evaluator so the two cannot
drift.
The detached approval launch kept its own spawn gate, which rechecked only
cwd and mutable-operand drift. With ask "always" and a backgrounded
approval follow-up, a command that the allowlist admitted on skill-bin
trust could still launch after that skill stopped granting the binary:
assertCurrent revisits the committed autoAllowSkills flag, never which
executable a skill currently authorizes.

Apply the same skill-authority recheck there. The check is split into a
reason-returning resolver and the result-returning wrapper the inline paths
use, so both shapes share one implementation rather than drifting.

All five gateway launch paths now recheck skill authority at their spawn
boundary: inline ask, ask-fallback, auto-review allow-once, detached
approval, and the direct allowlist path.
…main

Main added a sixth gateway launch path: a cron occurrence that consumes a
standing grant. It rechecked only the grant, so a segment admitted on
skill-bin trust could launch after that trust was withdrawn. Recheck skill
authority there too, before the grant is consumed, so a withdrawn skill
denies the launch without spending the grant.

Main also enforces the line-cap ratchet on pull requests, and the gateway
host, its unit test, and the infra allowlist evaluator are all over their
caps. Keep each at or below its main size:

- Move the spawn-boundary rechecks (approval-binding drift, the denial
  result, chaining, and the skill-authority recheck) into
  bash-tools.exec-host-gateway-revalidation.ts.
- Move skill-bin trust matching into infra/exec-approvals-skill-bins.ts,
  re-exported through exec-approvals.
- Replace the mocked detached-launch test with one in the autoAllowSkills
  suite that runs the real approval, launch adapter, and spawn boundary:
  it launches while skill trust holds and denies before spawn once the
  authorizing skill is uninstalled while approval is pending.

Only a cleanly analyzed command can have segments admitted on skill trust,
so the recheck is skipped otherwise. Test fixtures follow main's move of
saveExecApprovals into exec-approvals-store test support.
@fede-kamel
fede-kamel force-pushed the feat/gateway-auto-allow-skills branch from a5478bb to d1b97a6 Compare October 6, 2026 15:33
… suite

The test-mock-exports check requires first-party mock factories to spread the real module or state why they stay isolated. The supervisor and Gateway RPC mocks are deliberately isolated, so record why above each.
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 6, 2026
The skill-bin recheck ran once before launch preparation, but the launch
can still await standing-grant consumption, secret-egress registration,
the supervisor scope fence and adapter preparation before the native
spawn. A skill removed or a bin repointed during those waits left the
pinned command launchable.

Each async re-resolution now holds the authority it verified: the skill
source revision read before discovery and the authorizing bins with the
PATH they resolve on. The gateway's launch assertCurrent, which runs
synchronously at the supervisor's beforeSpawn and inside initiateSpawn
immediately before the native launch, rechecks that held authority with
no await in between. It denies when nothing was verified, when the skill
source revision moved, or when an authorizing bin resolves to another
executable, using the same isSegmentAuthorizedBySkillBins comparison as
allowlist evaluation. Inline, ask-fallback, auto-review, direct
allowlist and cron standing-grant launches share it; detached approval
launches report the denial in their follow-up.
@clawsweeper clawsweeper Bot added the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Nov 15, 2026
Drop the held skill source revision and the synchronous native-initiation
recheck: under the check-once-at-start policy a started request may finish,
and an unrelated skill refresh must not deny it. Launch-start rechecks for
inline, approval, detached and standing-grant paths stay.
@fede-kamel

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 16, 2026
@fede-kamel fede-kamel closed this Nov 16, 2026
@fede-kamel fede-kamel reopened this Nov 16, 2026
…ow-skills

# Conflicts:
#	src/agents/agent-tools.options.ts
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 17, 2026
@fede-kamel

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 17, 2026
@fede-kamel

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. label Nov 17, 2026
…ow-skills

# Conflicts:
#	src/agents/agent-tools.options.ts
@fede-kamel

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

This branch has not been deployed

No deployments
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-review-required security-sensitive-changed size: XL status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Honor exec approvals autoAllowSkills for gateway-host exec

1 participant