Repository navigation
fix(exec): autoAllowSkills ignored for gateway-host exec - #158244
fede-kamel wants to merge 21 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesExtend 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.
Review scores
ProductKind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete 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 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherAgent 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +345, Tests +613, Docs +10, Other +5. Total +973 across 24 files. Added test files: 3. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (17 earlier review cycles; latest 8 shown)
Reviewed November 19, 2026, 6:13 PM ET / 23:13 UTC (Revision 18). |
436936e to
659b5e3
Compare
|
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.
a5478bb to
d1b97a6
Compare
… 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.
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.
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.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ow-skills # Conflicts: # src/agents/agent-tools.options.ts
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ow-skills # Conflicts: # src/gateway/server-methods/skills.ts
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ow-skills # Conflicts: # src/agents/agent-tools.options.ts
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Closes #158165
What Problem This Solves
Fixes: with exec approvals in
allowlistmode andautoAllowSkills: true, an agent whose commands run on the Gateway host is still denied (exec denied: allowlist miss) the binaries its own workspace skills declare inrequires.bins.autoAllowSkillsonly took effect on node hosts.User Impact
User impact: Gateway-hosted agents (containers, servers, most self-hosted setups) can use
allowlistmode withautoAllowSkillsand 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. WithautoAllowSkillsoff (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 enableautoAllowSkills, 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 samePATHthe command resolves on: the Gateway'sPATHplus operatortools.exec.pathPrepend. Host exec already rejects a requestedPATH(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(requiresskill-tool) anddisabled-skill(requiresdisabled-tool, withskills.entries.disabled-skill.enabled: false); the three executables on the Gateway'sPATH;openclaw gateway run; then oneopenclaw agentturn per command. The model is a scripted local OpenAI-compatible stub (deterministic, no keys) that asks theexectool to run one command and replies with the result.Eligibility is OpenClaw's own: when the executables sit only in a
tools.exec.pathPrependdirectory,openclaw skills checklistsskill-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
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 withautoAllowSkillson; denied with it off; a bin only a disabled skill declares stays denied; a bin no skill declares stays denied; a requestedPATHreaching 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 runover the gateway exec host, exec run, and exec allowlist test files: 7 files, 218 passed.pnpm tsgo:coreandpnpm tsgo:core:test: clean.pnpm check:changed: all steps pass (including the line-cap ratchet) exceptcore 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)A session-excluded skill's binary reached process launch and executed.
After (this revision)
Case [4] covers the revocation-before-launch request. The approvals file records
the
autoAllowSkillsflag but never the executable a skill authorized, so thecommitted-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 thegranting 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: sessionfilter 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 launchdrives
ask: "always"with a backgrounded approval, has the launch adapterinvoke
beforeSpawnas the real runtime does, and asserts the follow-up reportsthe denial and that spawn is never reached. Reverting only the
beforeSpawnchange flips it to the bypass, which is the reported defect:
pnpm tsgo:coreclean; 137 passed across the two gateway exec test files, 907across 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 grantinbash-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:
bash-tools.exec-host-gateway-revalidation.ts.infra/exec-approvals-skill-bins.ts, re-exported throughexec-approvals.Detached approval proof, without mocks. The revision-5 test
revalidates skill authority in the detached approval launchmocked the launch adapter. It is replaced bydetached approval launch …inbash-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.mdnow says the recheck covers every gateway launch path.Checks:
pnpm tsgo:coreand the changed test files typecheck clean. The autoAllowSkills suite, the gateway exec host tests, the cron-grant tests,exec-approvalsand 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 insrc/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
runExecProcesschecked 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.
verifyGatewaySkillBinAuthorityinbash-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.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 sameisSegmentAuthorizedBySkillBinscomparison as allowlist evaluation, so the single shared implementation is kept.createGatewaySkillBinAuthorityRecheck(inbash-tools.exec-host-gateway-revalidation.ts) exposes that check asassertSkillBinAuthorityCurrent. The gateway composes it into theassertCurrentit 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.
runExecProcesspasses thatassertCurrentto the supervisor asbeforeSpawn. It also wraps it intoinitiateSpawn(createExecLaunchLifecycle().wrap), which calls it synchronously right beforelaunch(). 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 throwsGatewaySkillBinAuthorityWithdrawnError, anExecProcessPreflightError. 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 oftouchthat 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 throughimportOriginal.launches the skill bin while skill trust holds through initiationis the allowed control. The marker is written.denies at native initiation when the authorizing skill is uninstalled after preflightdenies at native initiation when the trusted bin name is repointed after preflightdetached approval launch denies at native initiation when trust is withdrawn after preflight, inbash-tools.exec-host-gateway.auto-allow-skills.test.ts. The supervisor stand-in uninstalls the skill and then calls the realinitiateSpawnhook. 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):
Without the fix (the three source files reverted, tests kept), the withdrawn command launches and runs:
Checks:
pnpm tsgo:coreand the core test typecheck are clean. oxfmt and scoped core oxlint pass on the changed files.check:changedpasses 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, onextensions/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 promptingfails withservice 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
autoAllowSkillsscope.Executing-agent skill ownership and real Gateway traces (revision 8)
Head:
0a4297accba(one commit on top ofe0e151ea91b; no rebase, the branch merges cleanly with main).What was wrong. Tool assembly can borrow another agent's tool policy.
agent-tools.tsthen has two ids:agentId, the policy owner from the capability profile (options.policyAgentId, or the profile a caller passes in), andexecutionAgentId, the agent that actually runs (options.agentId, or the agent ofrunSessionKey). Exec defaults received onlyagentId, andresolveGatewaySkillBinsused it. So under a borrowed policy,autoAllowSkillsloaded 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.
ExecSkillScopegainsownerAgentId.agent-tools.tsnow always setsskillScope.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 fromskillScope.ownerAgentId. It falls back toagentIdonly for callers that don't separate the two. That one resolver feeds all three skill checks: allowlist evaluation, the async re-resolution inverifyGatewaySkillBinAuthority, and the authority it holds. The held authority records that agent'sworkspaceDirand skill source revision, so the synchronousfindStaleHeldGatewaySkillBinSegmentcheck at native initiation watches the executing agent's skills. No await was added before the spawn.agentId. That covers the approvals-file entry, theautoAllowSkillsflag, ask/security, and the cron standing-grant source match.skills.binsreturns 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.skillScopeinstead of as a new top-level exec option. This keepsbash-tools.exec-run.tsat the line cap: a top-level field would have taken it from 700 to 701 counted lines.Regression tests.
src/agents/bash-tools.exec-host-gateway.skill-owner.test.ts. It has no mocks. It assembles exec throughcreateOpenClawCodingToolswithagentId: "execution",policyAgentId: "main"andrunSessionKey: "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 formain. Each agent's workspace has one skill:maindeclarespolicy-tool,executiondeclaresexec-tool. Both bins are copies oftouch.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 asexecutionundermain's policy.denies at native initiation when the executing agent's skill is uninstalled under a borrowed policy after preflightuninstalls 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:
Without the fix (
agent-tools.ts,bash-tools.exec-host-gateway-allowlist.tsandbash-tools.exec-types.tsreverted, tests kept), the policy agent's bin runs and the executing agent's own bin is refused:The three non-borrowed
skill-initiationcases 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:
useCountis unchanged.occ3below.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 runon loopback with token auth, a scripted local OpenAI-compatible stub model (no keys), and one connected client with theapprovalscapability. Decisions are made withopenclaw approvals resolve. Bins are native copies oftouch, so a launch leaves a marker file. Nothing in the Gateway is mocked. The config now has two agents (agents.ownership: "explicit"):mainwith workspace skillskill-tool, andopswith its own workspace and skillops-tool.occ3is the "consumed, launched" case above. The operator's allow-always grant authorizes the exact command, so the occurrence runs and spends one use (uses1 → 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:
opsruns its own bin without a prompt, butmain's bin is an allowlist miss forops, whilemainitself 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 carriessandboxAgentId(RunEmbeddedAgentParams), or when a harness passespolicyAgentId(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 nativeskill-ownerandskill-initiationtests 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):bash-tools.exec-host-gateway.skill-owner.test.ts(new)bash-tools.exec-host-gateway.skill-initiation.test.tsbash-tools.exec-host-gateway.auto-allow-skills.test.tsbash-tools.exec-cron-grant.test.tsThe 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 (occ2above).Checks:
pnpm tsgo:corepasses, 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 invitest.database-worker-core-paths.mjsnext to the other two gateway skill suites.CLI-backend tool path (revision 9)
Head:
18936becef1(one commit on top of0a4297accba; 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 (resolveGatewayScopedToolsinsrc/gateway/tool-resolution.ts). That call passedagentId: policyAgentId, so inagent-tools.tsthe derivedexecutionAgentId, and with itskillScope.ownerAgentId, was the policy agent. The two agents really can differ there. The CLI runner (cli-runner/prepare.ts) resolvespolicyAgentIdfromruntimePolicySessionKeyseparately from the session's own agent, and passes both into the loopback grant (agentIdplusruntimePolicyAgentId).tool-resolution.tsalready had the executing agent assessionAgentId, but it used that value only for the workspace and the sandbox lookup.What changed. The fix is narrow.
OpenClawCodingToolsOptionsgainsskillOwnerAgentId, andagent-tools.tssetsskillScope.ownerAgentId = options.skillOwnerAgentId ?? executionAgentId. The loopback path passesskillOwnerAgentId: sessionAgentId.agentIdon 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 8skill-ownertest, but goes through the CLI-backend entry point. It callsresolveGatewayScopedToolswithsurface: "loopback",mediatedToolNames: ["exec"], sessionagent:execution:main(agentexecution) and runtime policy sessionagent:main:main(agentmain). Then it runs the resolved exec tool through the real gateway authorization, supervisor and native launch. The approvals entry exists only formain.main's workspace declarespolicy-toolandexecution's declaresexec-tool, both copies oftouch. The test is registered invitest.database-worker-core-paths.mjsnext to the other gateway skill suites.With the fix:
Without the fix (only the
skillOwnerAgentIdline intool-resolution.tsreverted, so the option plumbing and the test are kept), the policy agent's bin runs and the executing agent's own bin is refused:tool-resolution.skill-owner.test.ts(new)The existing
tool-resolution.exclude.test.ts(24 tests) and the revision 8bash-tools.exec-host-gateway.skill-owner.test.ts(2 tests) still pass.Checks:
pnpm tsgo:corepasses, 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.
buildCliMcpGrantContextcopied no skill state into the loopback grant, soresolveGatewayScopedToolsbuilt mediated exec without the session'sskillFilter/skillOverrides, and the gateway resolved the executing agent's full eligible set. A session withskillOverrides: { "exec-tool": false }(or a filter that leftexec-toolout) could still launchexec-toolwithout approval, and the final rechecks repeated the same widened scope.Fix (
e4f477f2022).buildCliMcpGrantContextcaptures the run'sskillFilterandskillOverridesfrom its skill snapshot asadmittedSkillScopeonMcpLoopbackRequestContext(host-captured, never read from MCP headers).tool-resolution.tspassesexecSkillScope: { ownerAgentId: sessionAgentId, ...admittedSkillScope }to mediated tool assembly. Evaluation and every spawn-boundary recheck read that same scope.skillOwnerAgentIdis removed from the publicOpenClawCodingToolsOptions;execSkillScopeis onInternalCodingToolsOptionsonly, and the publicPluginCodingToolsOptions.exectype omitsskillScope. 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 realbuildCliMcpGrantContextand is spread intoresolveGatewayScopedToolsthe waymcp-http.runtime.tsspreads it; the resolved exec tool runs through real gateway authorization, the supervisor and a native launch of atouchcopy.With only the
admittedSkillScopeline inbuildCliMcpGrantContextreverted, both exclusion cases launch the binary:Adapting to main.
collectSkillBinsinto theskills.binshandler (refactor: localize single-consumer preparation phases #179567). This PR is a second consumer, sosrc/skills/discovery/bins.tsis restored andskills.binsuses it again; no duplicate collection logic.resolveGatewayExecApprovalDrift,revalidateGatewayExecApprovalBindingandbuildGatewayExecApprovalDeniedToolResult; main moved them tobash-tools.exec-approval-binding.tsandbash-tools.exec-host-gateway.output.ts, and the gateway host imports them from there.exec-approvals-skill-bins.tsusesisPathScopedExecutableTokenfromexec-authorization-plan.tsinstead of a local copy.agent-tools.assembly.tson main;skillScopeis set there now.bumpSkillsSnapshotVersionno longer takeschangedPath; the gateway skill suites drop it.0e17db36d6c): main shrankbash-tools.exec-host-gateway.tsto 1171 counted lines, so the skill wiring would have grown it to 1198. The per-session consecutive auto-review denial streak moves tobash-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, withholdWithfor 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-ownerandbash-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) andcli-runner/mcp-grant-contextalso passed.--maxWorkers=1)tool-resolution.skill-owner.test.ts(3 cases added)Checks:
pnpm tsgo:coreandpnpm tsgo:core:testpass; 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 lackseslint-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: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).bash-tools.exec-host-gateway.auto-allow-skills.test.tsmocks the process supervisor and the approval RPCs) and the standing-grant recheck (bash-tools.exec-cron-grant.test.tssupplies 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 runwith the bundledclaude-clibackend (claude-cli/claude-opus-5). The only stand-in is the externalclaudebinary the backend launches: a keyless script onPATH, 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 callsexecon 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.execishost: gateway, security: allowlist, ask: off.mainautoAllowSkills: truewith an empty allowlist.agents.entries.main.skills: ["admitted-tool", "overridden-tool"].touch, so a launch leaves a marker file.The first three turns use
openclaw agent. The override turn first setstoolOverrides.skills: {"overridden-tool": false}on its session withsessions.patch, then sends throughchat.send.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 sameclaude-clisetup. 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"].What the upgrade changes.
autoAllowSkillsnow has its own admitted skills' bins trusted. Before the upgrade, those same approvals did nothing for Gateway-host exec.doctor --fixstep is not specific to this PR. Starting currentmaindirectly on 2026.11.3 state stops with "agent database uses schema version 27 … run openclaw doctor --fix to upgrade it to schema version 41", andopenclaw updateruns 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.
resolveExecutionTargetTrustPathand the skill-bin PATH lookup are now async, andsafeRealpathSyncis gone from exec resolution. That conflicted with this PR insrc/infra/exec-approvals-allowlist.tsandsrc/node-host/runtime-skill-bins.ts. The port:isSkillAutoAllowedSegmentandisSegmentAuthorizedBySkillBins(src/infra/exec-approvals-skill-bins.ts) and the exportedresolveSkillBinTrustEntriesnow use main's async resolution, and every Gateway caller awaits them.realpath/PATH work main just removed.assertCurrentchecks only in-memory authority (committed authorization, source, operator, sandbox), while filesystem identity (the approval cwd snapshot and mutable-file bindings) is rechecked in the asyncrevalidateBeforeExecution. 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").bash-tools.exec-host-gateway.skill-initiation.test.tswas 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:coreandpnpm tsgo:core:testare clean, and the import-cycle check reports 0 runtime value cycles.src/infra,src/node-hostand 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:
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.holdWithwrapper on the standing-grantassertCurrent;GatewaySkillBinAuthorityWithdrawnErrorand the detached path's handling of it;bash-tools.exec-host-gateway.skill-initiation.test.ts(with its vitest registration) and the detached native-initiation withdrawal case inbash-tools.exec-host-gateway.auto-allow-skills.test.ts.Checks at c8b326f:
pnpm tsgo:coreandpnpm tsgo:core:testare clean, and the import-cycle check reports 0 cycles.Live CLI-backend run, rerun at c8b326f. Same setup as revision 11:
Main merged in (revision 14, b896620)
Main had moved 377 commits and conflicted in
src/agents/agent-tools.options.ts: main addedtoolPolicyScopenext to this PR'sexecSkillScopeonInternalCodingToolsOptions. 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 instartup_failureor failed with 0 jobs), so CI has not run since revision 13. Thepull_requestworkflows for b896620 are waiting for a maintainer to approve them (action_required).Checks at b896620 (Node 24.19, which main now requires):
pnpm tsgo:coreandpnpm tsgo:core:testare clean, and the import-cycle check reports 0 cycles.Live CLI-backend run, rerun at b896620. Same setup as revision 11:
Review follow-up and main merged in again (revision 15, b4ca486)
rechecks skill authority before spending a standing grantinbash-tools.exec-cron-grant.test.ts. It forced askillsclassification whileautoAllowSkillswas 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.src/gateway/server-methods/skills.ts: main importsSkillApiKeyReferenceErrornext toupdateSkillConfigEntry, and this PR importscollectSkillBins. The resolution keeps both.Checks at b4ca486 (Node 24.19):
pnpm tsgo:coreandpnpm tsgo:core:testare clean, and the import-cycle check reports 0 cycles.Live CLI-backend run, rerun at b4ca486. Same setup as revision 11:
Main merged in again (revision 16, a04bb80)
Main removed the unused
authProfileStoreSourceoption (#201996). It sat next to this PR'sexecoverride in thePluginCodingToolsOptionsomit list insrc/agents/agent-tools.options.ts, which was the only conflict. The resolution takes main's list without that field and keeps this PR'sexecoverride, which dropsskillScopefrom caller-supplied exec options. No behavior in this PR changed.Checks at a04bb80 (Node 24.19):
pnpm tsgo:coreandpnpm tsgo:core:testare 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.