fix(openshell): make the [openshell] extra enforce ACS policy again #4166
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4166"
general
weight: 0.35
prayagupa
Related Issue
None. Replaces #3728, which carried six weeks of CI history and follow-up comments on the same branch. The sections below are filled in because no issue is linked.
Problem & Solution
Problem.
pip install agent-governance-toolkit-integrations[openshell]installs anopenshell_agentmeshmodule that does nothing except emit a deprecation warning. The v5 migration removed the working adapter and never replaced it with an ACS one, so the extra we still advertise is empty.Solution.
GovernanceSkillandgoverned_shellare back, now backed by ACS. Everysubprocess.run,subprocess.Popen,os.systemandos.popeninside agoverned_shellscope goes throughsession.pre_tool_callasshell.executebefore the process starts. The policy-check CLI and the consolidated-package entry point come back with it.The policy target reports the program that will actually run:
executable=passed by keyword or positionally (Popen(["x", f], -1, "/bin/rm")) is what policy sees. Every positional afterargsis bound to its Popen name before the command is frozen, so a positionalshell=Trueis evaluated as a shell command too. A value given both positionally and by keyword raisesTypeErrorbefore evaluation, as Popen does.executable=is dropped, so the transformed argv[0] (or the default shell) runs.shell=True,os.systemandos.popen,executableis the shell. A rule keyed onexecutablealone does not see the program named in the string; policies must match oncommand. The README and the_policy_executabledocstring say so.Where to look (15 minutes)
About 480 lines of production code in
skill.pyandcli.py, about 940 lines of tests, the rest docs and CI wiring.skill.py:106: if policy evaluation throws, the command does not run. The broadexcept Exceptionis on purpose.skill.py:109: any verdict that does not permit (DENY, legacy ESCALATE) blocks before the subprocess starts.skill.py:111-117: a TRANSFORM with a malformed target raises instead of running the original command.skill.py:226-292: positional binding, freezing, and the transform rule forexecutable, shared by therunandPopenwrappers.skill.py:140-193: nested and concurrent scopes are tracked in aContextVar, and the four builtins are restored by reference even when the governed body raises.Out of scope: v4 policy objects still need migrating to ACS, and this does not add a Vertex provider.
Impact on Your Work
OpenShell sandboxes are where agents run shell commands, and the
[openshell]extra is how our docs tell users to govern them. Today that extra installs a no-op, so anyone following the docs gets no enforcement and no error telling them so. This puts enforcement back behind the same import path.Timeline
None.
Alternatives Considered
[openshell]extra instead. That breaks the documented install path and leaves OpenShell users with nothing to migrate to.subprocess.Popen.os.systemdoes not go through Popen, so it would run ungoverned.Type of Change
Package(s) Affected
Core & runtime:
Governance & security:
Platform & tooling:
CLI plugins:
Shared / other:
Testing
Unit Testing
agentmesh-integrations/openshell-skill/tests/test_skill.pycovers the verdict gate (ALLOW, WARN, DENY, ESCALATE, TRANSFORM), fail-closed evaluation, approval resolution, nested and concurrent scopes, restore on exception, argv freezing for any iterable, path-likecwdandexecutable, shell strings, and the CLI.Added for the latest review:
test_positional_executable_is_what_policy_sees[run|popen]: a policy denying executablermblocksPopen(["x", f], -1, "/bin/rm")and the same call throughrun, andfsurvives.test_executable_given_twice_raises_before_evaluation[run|popen]: positional plus keywordexecutableraisesTypeErrorwith no policy call.test_positional_shell_is_what_policy_sees: the ninth positionalshell=Trueis reported as a shell command.test_transform_drops_caller_executable(4 cases): keyword and positionalexecutable=pointing at a missing program, transformed to a Python argv that writes a marker. The marker is written, so the transformed argv ran.test_transform_to_echo_does_not_run_caller_rm[run|popen]:executable="/bin/rm"with a transform to["echo", f]leavesfin place. POSIX only.All nine new cases that run on Windows fail against the previous head and pass now.
Manual Testing
Locally on Windows with Python 3.12 and the ACS contract stub (
OPENSHELL_TEST_STUB_ACS=1): 55 passed, 3 skipped (the native ACS test and the two POSIX/bin/rmcases). The native OpenShell CI job builds ACS and runs the full file on Linux. On the previous head, 144 checks passed and 7 were skipped.ruff check . --select E,F,W --ignore E501is clean.Checklist
Attribution & Prior Art
Prior art / related projects (if any):
AI Assistance
If AI tools materially shaped this change, briefly note what was used:
Claude Code wrote most of the code and tests in this PR, which is why the commits carry a Claude co-author trailer. I reviewed every change and ran the tests before pushing.
IP, Patents, and Licensing