Repository navigation
Conversation
This was referenced Oct 30, 2026
Open
li-xiu-qi
force-pushed
the
feat/327-tool-origin-trust-tiers
branch
from
October 30, 2026 09:06
024f356 to
f7386db
Compare
li-xiu-qi
marked this pull request as ready for review
October 30, 2026 09:37
li-xiu-qi
requested review from
MelodyVAR,
Uking-xxx,
ZouR-Ma and
liuedcson
as code owners
October 30, 2026 09:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #327.
Fixes #239.
Supersedes #317.
In
approve-for-me, the permission policy heuristically scanscommand,cmd, andscriptfields for every tool. This misclassifies shell-like text inside the built-inworkflowJavaScript sandbox as a host shell command. For example, a workflow source string containingrm -rfcan trigger shell confirmation or denial even though the workflow does not execute that text as a shell command.The root cause is that command analysis has no registration provenance: it cannot distinguish a first-party structured tool from an external tool whose parameters still require conservative inspection.
The closed, unmerged #317 addressed the immediate
workflow.scriptfalse positive with a name-basedNON_SHELL_SCRIPT_TOOLSexemption. It was closed in favor of the provenance-based approach proposed in #327. This PR implements that approach and also covers the original #239 report without adding an extension-name whitelist to the core permission policy.Changes
ToolOriginprovenance (core,builtin,extension, ormcp) to tool definitions andtool_callevents, and propagate the registered origin to permission evaluation.run_command,bash, andpowershell; other structured inputs are not reinterpreted as shell commands.customToolscannot self-assign a trusted tier. Host-injectedcreateStepToolProfiledefinitions retain core provenance through an object-identity marker without changing tool object identity.then_runverification unchanged. Add permission, registration, SDK, MCP, and real agent-loop workflow coverage, plus extension and SDK documentation.Behavior and compatibility
The public interface changes are additive and optional: existing tool definitions and event consumers require no migration, and no configuration or persisted-session format changes are introduced.
Existing extensions, ordinary SDK custom tools, MCP tools, and calls without provenance retain the previous conservative heuristic behavior. First-party workflow and other non-shell built-in capabilities no longer receive irrelevant shell analysis. Trusted shell tools and
then_runcommands still undergo command policy checks, and explicit tool overrides still take precedence.Validation
Windows, Node.js 24:
pnpm check— passed, including formatting, linting, type checking, and repository boundary checks.cd packages/coding-agent && pnpm exec vitest run --pool=forks test/tool-origin-permissions.test.ts— 17 passed.cd packages/coding-agent && pnpm exec vitest run --pool=forks test/step-then-run-command-parity.test.ts— 12 passed.cd packages/coding-agent && pnpm exec vitest run --pool=forks— compared with a pristineupstream/mainbaseline. This exposed threethen_runobject-identity regressions during development; those were fixed and the suite now passes independently. The remaining parallel-run failures were rerun separately where relevant../test.sh— the candidate and pristine baseline both stop at the same existing Windowsrelease-bundlefailure: 35 script tests passed and 1 failed (install.sh persists inherited PATH and preserves malformed user blocks). Consequently, this entrypoint did not complete the repository package-test phase locally.f7386db5—build-check-testandCheck commit attributionpassed (run 41030952095).Limitations
The local Windows full-suite result is not clean on either the candidate or pristine baseline. One unrelated CLI completion-check rerun also hit
spawnSync ETIMEDOUT; the affected origin, MCP, workflow, andthen_runsuites pass independently. No interactive terminal approval UI was manually exercised; the workflow regression is covered through the real agent-loop test harness.