fix(agents): require both host unsafe mode and the agent's own safe_mode:false to open the skill gate's global safety #193
No reviewers
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Reference
cleveragents/cleveractors-core!193
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bugfix/m1-skill-gate-global-safety-and"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
ToolAgent._is_global_unsafe(src/cleveractors/agents/tool.py) composed the ADR-2034 D-9 "global safety" half of the skill double-safety gate with OR instead of AND, so either the agent's ownsafe_mode: falsealone, or the invocation context's_unsafe_mode: truealone, opened that half of the gate. The corrected D-9 text (amended 2026-11-25) requires both at once, mirroring the AND composition §13 already uses for shell execution._is_global_unsafefrom OR to AND. Bothgate_open = global_unsafe and not skill_safecall sites already AND-composed correctly.features/agent_skills.featurescenario that previously relied on the OR to open the gate via the invocation context alone, to also configure theToolAgent's ownsafe_mode: false.@tdd_expected_failfrom the merged #189 TDD regression scenario (bug now fixed) and added a new scenario proving the gate stays closed when only the agent's ownsafe_mode: falseholds (without host-context unsafe mode).docs/index.md,docs/adr/ADR-2034-skill-package-support.md, anddocs/tools/safe-mode.mdwere already updated (uncommitted, pre-existing) documenting the D-9 correction and are not part of this PR's commit.Note: traced the full
LLMAgent→ ephemeralToolAgentdispatch path (_resolve_parent_unsafe/_build_ephemeral_tool_config/_build_tool_contextinagents/llm.py, pre-dating ADR-2034 per issue #115) to confirm this fix's effect end-to-end. That path derives the ephemeralToolAgent's ownsafe_modeand its context's_unsafe_modefrom one already-OR'dparent_unsafesignal, so the two conditions_is_global_unsafechecks are not fully independent when a skill is invoked through a realtype: llmagent's tool loop (only directToolAgentconstruction, as used by this project's Behave suite, exercises them independently). That is a separate, pre-existing architectural question outside this issue's explicit scope (ToolAgent._is_global_unsafeonly) and is not addressed by this atomic fix.Quality gates (all green locally)
nox -s lint,nox -s format -- --check,nox -s typechecknox -s unit_tests(3363 scenarios passed)nox -s coverage_report(97.3%, threshold 96.5%)nox -s security_scan,nox -s dead_code,nox -s complexitynox -s integration_tests(382/382 Robot tests passed)nox -s benchmark,nox -s docs,nox -s buildTest plan
_is_global_unsafereturnsFalsewhen only host unsafe mode holds (agentsafe_modestilltrue)_is_global_unsafereturnsFalsewhen only the agent's ownsafe_mode: falseholds (host context not unsafe)_is_global_unsafereturnsTrueonly when both holdgate_opencall site reflects the corrected compositionallow_shell, safe-mode shell blocklist)Closes #189
ToolAgent._is_global_unsafe (src/cleveractors/agents/tool.py) composed the ADR-2034 D-9 "global safety" half of the skill double-safety gate with OR: (not self.safe_mode) or context.get("_unsafe_mode", False). Either the agent's own safe_mode: false alone, or the invocation context's _unsafe_mode: true alone, was therefore enough to open that half of the gate -- letting an agent author's own safe_mode: false unlock every safe_mode: false skill's privileged resources even while the host/actor stayed safely configured, and letting a host/actor placed in unsafe mode for an unrelated reason silently authorize every loaded skill. The corrected D-9 text (amended 2026-11-25) requires both conditions to hold at once, mirroring the AND composition Sec 13 already uses for shell execution (allow_shell: true and host unsafe mode). Changed the composition to AND. Both gate_open = global_unsafe and not skill_safe call sites (~lines 1357, 1444) already AND-compose correctly and needed no change -- _is_global_unsafe was the only OR path. Every features/agent_skills.feature scenario that previously relied on the OR to open the gate via the invocation context alone (without also configuring the ToolAgent's own safe_mode: false) now sets that field too, so each continues to exercise a genuinely-open gate under the corrected composition. Two new scenarios prove the gate stays closed when only one of the two global conditions holds: host unsafe alone (the merged #189 TDD regression, @tdd_expected_fail removed now that the fix is in place) and the agent's own safe_mode: false alone. Traced the full LLMAgent -> ephemeral ToolAgent dispatch path (_resolve_parent_unsafe/_build_ephemeral_tool_config/_build_tool_context in agents/llm.py) to confirm this fix's effect end to end: that path pre-dates ADR-2034 (issue #115) and derives the ephemeral ToolAgent's own safe_mode and its context's _unsafe_mode from one already-OR'd parent_unsafe signal, so the two conditions _is_global_unsafe checks are not independent when skills are invoked through a real type: llm agent's tool loop -- only direct ToolAgent construction (as used by this project's Behave suite) exercises them independently. That is a separate, pre-existing architectural question outside this issue's scope (ToolAgent._is_global_unsafe only); flagged separately rather than folded into this atomic fix. nox (lint, format --check, typecheck, unit_tests, coverage_report 97.3%, security_scan, dead_code, complexity, integration_tests 382/382, benchmark, docs, build) all green. ISSUES CLOSED: #189PR Review: !193 (Ticket #189)
Verdict: Request Changes
The core fix is correct and well-tested:
_is_global_unsafenow ANDs the host-context unsafe grant with the agent's ownsafe_mode: false, bothgate_opencall sites already AND-composed, every gate-open Behave scenario was updated, and the two new single-condition regression scenarios prove the gate stays closed when only one condition holds. I verified the full unit suite locally (3363/3363 scenarios pass, 153/153 infeatures/agent_skills.feature), plus lint and typecheck (0 errors). One major issue blocks approval: the spec documents that this fix implements — the corrected D-9 text the commit message and CHANGELOG both cite — are not actually committed anywhere in the repository, so the PR as submitted leaves the authoritative spec contradicting the merged code.Critical Issues
None
Major Issues
Docs amendment is missing from the PR — committed spec still specifies the OR composition the code just stopped using. The PR description says
docs/index.md,docs/adr/ADR-2034-skill-package-support.md, anddocs/tools/safe-mode.md"were already updated (uncommitted, pre-existing) ... and are not part of this PR's commit". But no branch contains that update — I checkedorigin/develop,origin/master, andorigin/feature/skill-package-support:docs/adr/ADR-2034-skill-package-support.md, D-9 "The double-safety gate" point 1 (~line 400): "host/actor unsafe mode ..., or the parenttype: llmagent's ownsafe_modeconfiguration isfalse" — still OR. The Revision History's last row is still 2026-11-09; there is no 2026-11-25 amendment row.docs/index.md§4.4.8 (~line 606): "Global safety — either this agent's ownsafe_modefield ... isfalse, or the invocation context already carries_unsafe_mode: true" — still OR.docs/tools/safe-mode.md"Bundled skill script execution" (~line 140): "global safety isfalse(that agent's ownsafe_modeisfalse, or the invocation context already carries_unsafe_mode: true)" — still OR.This matters for three reasons:
docs/adr/ADR-2034-skill-package-support.md(D-9, corrected 2026-11-25),docs/index.md§4.4.8" — false as committed; it points readers at docs that state the opposite rule._is_global_unsafeback to OR — silently reintroducing the exact vulnerability this PR removes.Recommendation: commit the already-drafted docs amendment in this PR (D-9 point 1, the 2026-11-25 Revision History row, §4.4.8, and safe-mode.md), or land the docs amendment on
developbefore this PR merges. Since the text is already written locally, this should be small.Minor Issues
None
Nits
f95e162): this PR contains the TDD commit that is !192's entire content (stacked branches). Please merge !192 first — if !193 merges first, !192 becomes an empty diff and issue #190's Definition of Done ("scenario merged todevelopvia its own PR") is sidestepped. No rebase needed; just the merge order.src/cleveractors/agents/tool.py:1629— the new docstring says "Sec 13"; the codebase convention is "§13" (e.g. "§13.2.1", "§13.3" elsewhere in this same file).Scope notes (per the author's decisions — not re-raised)
_resolve_parent_unsafe/_build_ephemeral_tool_config/_build_tool_contextinagents/llm.py) derives both D-9 conditions from one already-OR'dparent_unsafesignal, so the two conditions are not independent there and the AND fix is behavior-neutral on that path. The author explicitly flagged this as a separate, pre-existing architectural question (issue #115 era) outside this issue's scope; I verified the analysis in code and agree it is not a regression of this PR — excluded from this review as decided.type: llmpath the two conditions flip together, so a single-condition end-to-end scenario cannot be constructed without the architectural change above; the existing robot suite already covers the gate open ("Bundled Script Executes End To End Behind The Double Safety Gate") and closed ("Non Standard Read Is Refused While The Gate Is Inactive") end to end.Verified locally
nox -s unit_tests: 3363/3363 scenarios pass (160 features) — matches the PR's reported run.nox -s unit_tests -- features/agent_skills.feature: 153/153 pass.nox -s lint: pass.nox -s typecheck: 0 errors (1 pre-existing optional-import warning, unrelated).nox -s coverage_report: could not run in this sandbox (pip could not resolvepydantic— network issue, not code); relying on the PR's reported 97.3% ≥ 96.5 threshold, which is plausible given the change is one boolean operator fully covered by the new scenarios.gate_opensites (tool.py:1357,tool.py:1444) and the whole module:_is_global_unsafewas the only OR path; file_read/file_write unsafe checks (tool.py:1063,tool.py:1262) are §13 semantics, correctly untouched.Commit Messagefields exactly; branch name matches Metadata; rebased linear history on latestdevelop, no merge commits; CHANGELOG entry correctly placed under Unreleased → Fixed (docs claim aside).Summary
A precise, well-scoped security fix with genuinely good test discipline — the updated scenarios and the two new single-condition regressions cover exactly the acceptance criteria, and the commit/TDD workflow was followed properly. The single blocking item is documentation packaging: the corrected D-9 spec text that this fix implements (and that the CHANGELOG cites) must be committed to the repository with this change, otherwise the authoritative spec keeps prescribing the insecure OR composition and the fix can be legitimately "reverted" by anyone trusting the spec. Include the docs amendment (or land it on
developfirst), merge !192 before this PR, and this is ready to approve.4021ebb3fbd1ee3c0420PR Review: !193 (Ticket #189)
Verdict: Approve
The fix commit (
d1ee3c0) is correct, minimal, and fully verified:_is_global_unsafenow ANDs the host-context unsafe grant with the agent's ownsafe_mode: false, bothgate_opencall sites already AND-compose, and the behavior matches the corrected ADR-2034 D-9 text that is now actually committed in the repository (via the amended TDD commitd186c6ethis PR is stacked on — the major issue from the earlier, stale review is resolved). I independently re-ran the full quality gates locally on exactly this head: lint, format --check, typecheck (0 errors), full unit suite 3363/3363 scenarios, and coverage_report 97.3% (threshold 96.5%) — this time including coverage, which the earlier review could not run. The changed lines are fully covered; the remaining uncovered lines intool.pyare pre-existing exception branches (UTF-8 decode errors, missing interpreter, POSIX-only paths) untouched by this PR. No critical or major issues remain — only three nits below, none blocking.Critical Issues
None.
Major Issues
None. (The previously raised "spec amendment missing from the repository" issue is resolved: the corrected D-9 text, the 2026-11-25 ADR Revision History row,
docs/index.md§4.4.8,docs/tools/safe-mode.md, A-14/A-15, and the Registry Standard 1.3.0 §16.1/D-11 revision are all present on this branch viad186c6e, verified at headd1ee3c0. The CHANGELOG's docs citations are now true as committed.)Minor Issues
None.
Nits
developvia its own PR") is sidestepped. No rebase needed — the branches are already sha-identical (d186c6e); it is purely a merge-order instruction.src/cleveractors/agents/tool.py:1629— the new docstring says "Sec 13"; the same file uses the "§" convention everywhere else (9 occurrences, e.g. "§13.2.1" line 41, "§13.3" line 1115). Cosmetic follow-up opportunity.features/agent_skills.feature:784— the new scenario ("...refused when the agent's own safe_mode is false but the context is not globally unsafe") pins only the"global safety is true"half of the refusal signature; its siblings (including the TDD scenario, which was strengthened for exactly this reason during the !192 review) also assert"skill safety is false". Adding that one line would match the established assertion pattern.Scope exclusions (per the author's decisions — not re-raised)
ToolAgentdispatch path (_resolve_parent_unsafe/_build_ephemeral_tool_config/_build_tool_contextinagents/llm.py): both D-9 conditions there derive from one already-OR'dparent_unsafesignal (safe_mode = not parent_unsafe,_unsafe_mode = parent_unsafe), so AND and OR coincide and the fix is behavior-neutral on that path. The author explicitly declared this a separate, pre-existing architectural question (issue #115 era) outside this issue's scope in both the PR description and the commit message; I re-verified the analysis in code at this head and agree. Excluded.Bundled Script Executes End To End Behind The Double Safety Gate, agentsafe_mode: False→ gate opens) and closed (Non Standard Read Is Refused While The Gate Is Inactive) end to end, and single-condition end-to-end scenarios are impossible on the LLMAgent path without the deferred architectural change above. Excluded as decided; this also explains why no robot changes were needed for 382/382 to stay green.Verified locally (authoritative, on head
d1ee3c0)nox -s unit_tests: 3363/3363 scenarios, 15482/15482 steps, 0 failed — matches the PR's reported run.nox -s unit_tests -- features/agent_skills.feature: 697 steps passed, 0 failed.nox -s lint: pass.nox -s format -- --check: 298 files already formatted.nox -s typecheck: 0 errors (1 pre-existing optional-import warning, unrelated).nox -s coverage_report: 97.3% (threshold 96.5%) — COVERAGE OK._is_global_unsafe(lines 1622/1638/1639) fully exercised;tool.py's 23 uncovered lines are pre-existing error branches unrelated to the gate._is_global_unsafewas the only OR composition of the global half; bothgate_open = global_unsafe and not skill_safesites AND-compose; the skill-safety half,allow_shell, and the safe-mode shell blocklist are untouched (the src diff is_is_global_unsafeplus its docstring only). The refusal-message semantics ('false' if global_unsafe else 'true') match both single-condition scenarios' assertions, and the@tdd_expected_failtag was correctly dropped now that the regression passes for the right reason.Commit Messageexactly, branch name matches Metadata, linear rebased history on the currentdeveloptip, no merge commits; CHANGELOG entry correctly placed under Unreleased → Fixed with accurate docs citations.Summary
A precise, well-scoped security fix with strong test discipline: the updated scenarios and the two single-condition regressions cover the corrected D-9 semantics exactly, the spec text the fix implements is now genuinely in the repository, and every gate I could run locally is green on the exact head under review. Merge !192 before this PR, optionally sweep the three nits in a follow-up, and this is ready to merge. Approving.
d1ee3c04205dfbc9b818