fix(agents): require both host unsafe mode and the agent's own safe_mode:false to open the skill gate's global safety #193

Merged
CoreRasurae merged 1 commit from bugfix/m1-skill-gate-global-safety-and into develop 2026-11-26 12:23:03 +00:00
Member

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 own safe_mode: false alone, or the invocation context's _unsafe_mode: true alone, 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.

  • Changed _is_global_unsafe from OR to AND. Both gate_open = global_unsafe and not skill_safe call sites already AND-composed correctly.
  • Updated every features/agent_skills.feature scenario that previously relied on the OR to open the gate via the invocation context alone, to also configure the ToolAgent's own safe_mode: false.
  • Removed @tdd_expected_fail from the merged #189 TDD regression scenario (bug now fixed) and added a new scenario proving the gate stays closed when only the agent's own safe_mode: false holds (without host-context unsafe mode).
  • docs/index.md, docs/adr/ADR-2034-skill-package-support.md, and docs/tools/safe-mode.md were already updated (uncommitted, pre-existing) documenting the D-9 correction and are not part of this PR's commit.

Note: traced the full LLMAgent → ephemeral ToolAgent dispatch path (_resolve_parent_unsafe/_build_ephemeral_tool_config/_build_tool_context in agents/llm.py, pre-dating ADR-2034 per issue #115) to confirm this fix's effect end-to-end. That path 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 fully independent when a skill is 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 explicit scope (ToolAgent._is_global_unsafe only) and is not addressed by this atomic fix.

Quality gates (all green locally)

  • nox -s lint, nox -s format -- --check, nox -s typecheck
  • nox -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 complexity
  • nox -s integration_tests (382/382 Robot tests passed)
  • nox -s benchmark, nox -s docs, nox -s build

Test plan

  • _is_global_unsafe returns False when only host unsafe mode holds (agent safe_mode still true)
  • _is_global_unsafe returns False when only the agent's own safe_mode: false holds (host context not unsafe)
  • _is_global_unsafe returns True only when both hold
  • Every gate_open call site reflects the corrected composition
  • No change to the skill-safety half or to unrelated checks (allow_shell, safe-mode shell blocklist)

Closes #189

## 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 own `safe_mode: false` alone, or the invocation context's `_unsafe_mode: true` alone, 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. - Changed `_is_global_unsafe` from OR to AND. Both `gate_open = global_unsafe and not skill_safe` call sites already AND-composed correctly. - Updated every `features/agent_skills.feature` scenario that previously relied on the OR to open the gate via the invocation context alone, to also configure the `ToolAgent`'s own `safe_mode: false`. - Removed `@tdd_expected_fail` from the merged #189 TDD regression scenario (bug now fixed) and added a new scenario proving the gate stays closed when only the agent's own `safe_mode: false` holds (without host-context unsafe mode). - `docs/index.md`, `docs/adr/ADR-2034-skill-package-support.md`, and `docs/tools/safe-mode.md` were already updated (uncommitted, pre-existing) documenting the D-9 correction and are not part of this PR's commit. Note: traced the full `LLMAgent` → ephemeral `ToolAgent` dispatch path (`_resolve_parent_unsafe`/`_build_ephemeral_tool_config`/`_build_tool_context` in `agents/llm.py`, pre-dating ADR-2034 per issue #115) to confirm this fix's effect end-to-end. That path 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 fully independent when a skill is 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 explicit scope (`ToolAgent._is_global_unsafe` only) and is not addressed by this atomic fix. ## Quality gates (all green locally) - `nox -s lint`, `nox -s format -- --check`, `nox -s typecheck` - `nox -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 complexity` - `nox -s integration_tests` (382/382 Robot tests passed) - `nox -s benchmark`, `nox -s docs`, `nox -s build` ## Test plan - [x] `_is_global_unsafe` returns `False` when only host unsafe mode holds (agent `safe_mode` still `true`) - [x] `_is_global_unsafe` returns `False` when only the agent's own `safe_mode: false` holds (host context not unsafe) - [x] `_is_global_unsafe` returns `True` only when both hold - [x] Every `gate_open` call site reflects the corrected composition - [x] No change to the skill-safety half or to unrelated checks (`allow_shell`, safe-mode shell blocklist) Closes #189
CoreRasurae added this to the v2.1.0 milestone 2026-11-25 13:57:12 +00:00
test(agents): add failing regression for the skill gate's OR-composed global safety (#189)
Some checks failed
CI / security (pull_request) Successful in 1m19s
CI / lint (pull_request) Successful in 1m24s
CI / typecheck (pull_request) Successful in 1m35s
CI / build (pull_request) Successful in 49s
CI / quality (pull_request) Successful in 3m15s
CI / integration_tests (pull_request) Successful in 4m49s
CI / unit_tests (pull_request) Successful in 6m50s
CI / coverage (pull_request) Successful in 6m30s
CI / benchmark (pull_request) Has been cancelled
CI / status-check (pull_request) Successful in 2s
f95e162697
Adds a failing-first Behave regression test proving issue #189:
ToolAgent._is_global_unsafe (src/cleveractors/agents/tool.py, ~line
1622) composes 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) -- so either the agent's own
safe_mode: false alone, or the invocation context's _unsafe_mode: true
alone, opens that half of the gate. The corrected D-9 text (amended
2026-11-25, see docs/adr/ADR-2034-skill-package-support.md and
docs/index.md Sec 4.4.8) requires both to hold at once, mirroring the
AND composition Sec 13 already uses for shell execution.

Extends features/agent_skills.feature (alongside the existing
double-safety-gate coverage, ~line 736) with a new scenario that
leaves the ToolAgent's own "safe_mode" at its default true, loads a
safe_mode: false "pdf-processing" skill bundling a non-standard
fixtures/sample.pdf resource (the existing "every D-8 class" fixture),
sets the invocation context globally unsafe, and asserts the
non-standard read is refused. No new step definitions were needed --
every Given/When/Then step already exists in
features/steps/agent_skills_steps.py and is reused as-is.

The scenario is tagged @tdd_issue @tdd_issue_189 @tdd_expected_fail.
Verified locally that removing @tdd_expected_fail makes the scenario's
assertion fail against current develop (the gate currently opens and
the read succeeds instead of being refused), confirming the bug is
genuinely reproduced; the failing step raises only AssertionError, so
the TDD CI hook inverts it correctly. With the tag restored, nox -s
unit_tests, nox -s coverage_report (97.3%), nox -s lint, nox -s format
-- --check, nox -s typecheck, nox -s security_scan, nox -s dead_code,
nox -s complexity, nox -s integration_tests, and nox -s build are all
green.

The actual fix (switching _is_global_unsafe to AND) lands separately
on bugfix/m1-skill-gate-global-safety-and per issue #189.

ISSUES CLOSED: #190
Refs: #189
fix(agents): require both host unsafe mode and the agent's own safe_mode:false to open the skill gate's global safety
Some checks failed
CI / lint (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 1m21s
CI / security (pull_request) Successful in 1m14s
CI / quality (pull_request) Successful in 2m13s
CI / build (pull_request) Successful in 1m54s
CI / integration_tests (pull_request) Successful in 3m8s
CI / unit_tests (pull_request) Successful in 7m11s
CI / benchmark (pull_request) Failing after 16m30s
CI / coverage (pull_request) Failing after 15m50s
CI / status-check (pull_request) Has been cancelled
4021ebb3fb
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: #189
hurui200320 requested changes 2026-11-25 16:23:17 +00:00
Dismissed
hurui200320 left a comment

PR Review: !193 (Ticket #189)

Verdict: Request Changes

The core fix is correct and well-tested: _is_global_unsafe now ANDs the host-context unsafe grant with the agent's own safe_mode: false, both gate_open call 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 in features/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

  1. 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, and docs/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 checked origin/develop, origin/master, and origin/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 parent type: llm agent's own safe_mode configuration is false" — 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 own safe_mode field ... is false, or the invocation context already carries _unsafe_mode: true" — still OR.
    • docs/tools/safe-mode.md "Bundled skill script execution" (~line 140): "global safety is false (that agent's own safe_mode is false, or the invocation context already carries _unsafe_mode: true)" — still OR.

    This matters for three reasons:

    • The PR's own CHANGELOG entry asserts "Docs: 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.
    • The project rule says that on code/spec discrepancy the specification is authoritative. A future reader applying that rule to the committed D-9 text would "fix" _is_global_unsafe back to OR — silently reintroducing the exact vulnerability this PR removes.
    • CONTRIBUTING requires each commit to be self-contained: code, tests, and documentation together. This is a behavior change whose justification rests on a spec amendment that exists nowhere in the repo.

    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 develop before this PR merges. Since the text is already written locally, this should be small.

Minor Issues

None

Nits

  1. Merge-order dependency with !192 (commit 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 to develop via its own PR") is sidestepped. No rebase needed; just the merge order.
  2. 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)

  • The LLMAgent → ephemeral ToolAgent dispatch path (_resolve_parent_unsafe/_build_ephemeral_tool_config/_build_tool_context in agents/llm.py) derives both D-9 conditions from one already-OR'd parent_unsafe signal, 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.
  • Robot-integration extension (ticket subtask) is not needed: on the real type: llm path 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 resolve pydantic — 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.
  • Audited both gate_open sites (tool.py:1357, tool.py:1444) and the whole module: _is_global_unsafe was the only OR path; file_read/file_write unsafe checks (tool.py:1063, tool.py:1262) are §13 semantics, correctly untouched.
  • Both commits' first lines match the issue Metadata Commit Message fields exactly; branch name matches Metadata; rebased linear history on latest develop, 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 develop first), merge !192 before this PR, and this is ready to approve.

## PR Review: !193 (Ticket #189) ### Verdict: Request Changes The core fix is correct and well-tested: `_is_global_unsafe` now ANDs the host-context unsafe grant with the agent's own `safe_mode: false`, both `gate_open` call 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 in `features/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 1. **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`, and `docs/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 checked `origin/develop`, `origin/master`, and `origin/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 parent `type: llm` agent's own `safe_mode` configuration is `false`"* — 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 own `safe_mode` field ... is `false`, **or** the invocation context already carries `_unsafe_mode: true`"* — still OR. - `docs/tools/safe-mode.md` "Bundled skill script execution" (~line 140): *"global safety is `false` (that agent's own `safe_mode` is `false`, or the invocation context already carries `_unsafe_mode: true`)"* — still OR. This matters for three reasons: - The PR's own CHANGELOG entry asserts *"Docs: `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. - The project rule says that on code/spec discrepancy the specification is authoritative. A future reader applying that rule to the committed D-9 text would "fix" `_is_global_unsafe` back to OR — silently reintroducing the exact vulnerability this PR removes. - CONTRIBUTING requires each commit to be self-contained: code, tests, and documentation together. This is a behavior change whose justification rests on a spec amendment that exists nowhere in the repo. **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 `develop` before this PR merges. Since the text is already written locally, this should be small. ### Minor Issues None ### Nits 1. **Merge-order dependency with !192** (commit `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 to `develop` via its own PR") is sidestepped. No rebase needed; just the merge order. 2. `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) - The **LLMAgent → ephemeral ToolAgent dispatch path** (`_resolve_parent_unsafe`/`_build_ephemeral_tool_config`/`_build_tool_context` in `agents/llm.py`) derives *both* D-9 conditions from one already-OR'd `parent_unsafe` signal, 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. - Robot-integration extension (ticket subtask) is not needed: on the real `type: llm` path 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 resolve `pydantic` — 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. - Audited both `gate_open` sites (`tool.py:1357`, `tool.py:1444`) and the whole module: `_is_global_unsafe` was the only OR path; file_read/file_write unsafe checks (`tool.py:1063`, `tool.py:1262`) are §13 semantics, correctly untouched. - Both commits' first lines match the issue Metadata `Commit Message` fields exactly; branch name matches Metadata; rebased linear history on latest `develop`, 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 `develop` first), merge !192 before this PR, and this is ready to approve.
CoreRasurae force-pushed bugfix/m1-skill-gate-global-safety-and from 4021ebb3fb
Some checks failed
CI / lint (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 1m21s
CI / security (pull_request) Successful in 1m14s
CI / quality (pull_request) Successful in 2m13s
CI / build (pull_request) Successful in 1m54s
CI / integration_tests (pull_request) Successful in 3m8s
CI / unit_tests (pull_request) Successful in 7m11s
CI / benchmark (pull_request) Failing after 16m30s
CI / coverage (pull_request) Failing after 15m50s
CI / status-check (pull_request) Has been cancelled
to d1ee3c0420
Some checks failed
CI / lint (pull_request) Successful in 1m10s
CI / quality (pull_request) Successful in 44s
CI / typecheck (pull_request) Successful in 2m25s
CI / security (pull_request) Successful in 3m0s
CI / build (pull_request) Successful in 1m26s
CI / integration_tests (pull_request) Successful in 3m28s
CI / unit_tests (pull_request) Successful in 6m21s
CI / coverage (pull_request) Failing after 13m13s
CI / benchmark (pull_request) Failing after 28m30s
CI / status-check (pull_request) Has been cancelled
2026-11-25 23:46:19 +00:00
Compare
hurui200320 left a comment

PR Review: !193 (Ticket #189)

Verdict: Approve

The fix commit (d1ee3c0) is correct, minimal, and fully verified: _is_global_unsafe now ANDs the host-context unsafe grant with the agent's own safe_mode: false, both gate_open call 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 commit d186c6e this 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 in tool.py are 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 via d186c6e, verified at head d1ee3c0. The CHANGELOG's docs citations are now true as committed.)

Minor Issues

None.

Nits

  1. Merge-order dependency with !192. This PR's first commit is !192's entire content (stacked branches). Merge !192 first: if !193 merges first, !192 becomes an empty diff and issue #190's Definition of Done ("scenario merged to develop via its own PR") is sidestepped. No rebase needed — the branches are already sha-identical (d186c6e); it is purely a merge-order instruction.
  2. 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.
  3. 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)

  • LLMAgent → ephemeral ToolAgent dispatch path (_resolve_parent_unsafe/_build_ephemeral_tool_config/_build_tool_context in agents/llm.py): both D-9 conditions there derive from one already-OR'd parent_unsafe signal (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.
  • Robot-integration extension subtask: conditional in the ticket ("if it exercises this gate end-to-end"); the existing robot suite already covers the gate open (Bundled Script Executes End To End Behind The Double Safety Gate, agent safe_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.
  • Coverage audit: _is_global_unsafe (lines 1622/1638/1639) fully exercised; tool.py's 23 uncovered lines are pre-existing error branches unrelated to the gate.
  • Audited the whole module and the codebase: _is_global_unsafe was the only OR composition of the global half; both gate_open = global_unsafe and not skill_safe sites AND-compose; the skill-safety half, allow_shell, and the safe-mode shell blocklist are untouched (the src diff is _is_global_unsafe plus its docstring only). The refusal-message semantics ('false' if global_unsafe else 'true') match both single-condition scenarios' assertions, and the @tdd_expected_fail tag was correctly dropped now that the regression passes for the right reason.
  • Commit hygiene (non-blocking checks only): first line matches the ticket Metadata Commit Message exactly, branch name matches Metadata, linear rebased history on the current develop tip, 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.

## PR Review: !193 (Ticket #189) ### Verdict: Approve The fix commit (`d1ee3c0`) is correct, minimal, and fully verified: `_is_global_unsafe` now ANDs the host-context unsafe grant with the agent's own `safe_mode: false`, both `gate_open` call 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 commit `d186c6e` this 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 in `tool.py` are 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 via `d186c6e`, verified at head `d1ee3c0`. The CHANGELOG's docs citations are now true as committed.) ### Minor Issues None. ### Nits 1. **Merge-order dependency with !192.** This PR's first commit is !192's entire content (stacked branches). Merge !192 first: if !193 merges first, !192 becomes an empty diff and issue #190's Definition of Done ("scenario merged to `develop` via its own PR") is sidestepped. No rebase needed — the branches are already sha-identical (`d186c6e`); it is purely a merge-order instruction. 2. `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. 3. `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) - **LLMAgent → ephemeral `ToolAgent` dispatch path** (`_resolve_parent_unsafe`/`_build_ephemeral_tool_config`/`_build_tool_context` in `agents/llm.py`): both D-9 conditions there derive from one already-OR'd `parent_unsafe` signal (`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. - **Robot-integration extension subtask**: conditional in the ticket ("if it exercises this gate end-to-end"); the existing robot suite already covers the gate open (`Bundled Script Executes End To End Behind The Double Safety Gate`, agent `safe_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**. - Coverage audit: `_is_global_unsafe` (lines 1622/1638/1639) fully exercised; `tool.py`'s 23 uncovered lines are pre-existing error branches unrelated to the gate. - Audited the whole module and the codebase: `_is_global_unsafe` was the only OR composition of the global half; both `gate_open = global_unsafe and not skill_safe` sites AND-compose; the skill-safety half, `allow_shell`, and the safe-mode shell blocklist are untouched (the src diff is `_is_global_unsafe` plus its docstring only). The refusal-message semantics (`'false' if global_unsafe else 'true'`) match both single-condition scenarios' assertions, and the `@tdd_expected_fail` tag was correctly dropped now that the regression passes for the right reason. - Commit hygiene (non-blocking checks only): first line matches the ticket Metadata `Commit Message` exactly, branch name matches Metadata, linear rebased history on the current `develop` tip, 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.
CoreRasurae force-pushed bugfix/m1-skill-gate-global-safety-and from d1ee3c0420
Some checks failed
CI / lint (pull_request) Successful in 1m10s
CI / quality (pull_request) Successful in 44s
CI / typecheck (pull_request) Successful in 2m25s
CI / security (pull_request) Successful in 3m0s
CI / build (pull_request) Successful in 1m26s
CI / integration_tests (pull_request) Successful in 3m28s
CI / unit_tests (pull_request) Successful in 6m21s
CI / coverage (pull_request) Failing after 13m13s
CI / benchmark (pull_request) Failing after 28m30s
CI / status-check (pull_request) Has been cancelled
to 5dfbc9b818
Some checks failed
CI / lint (pull_request) Successful in 1m13s
CI / quality (pull_request) Successful in 1m18s
CI / security (pull_request) Successful in 2m16s
CI / typecheck (pull_request) Successful in 2m24s
CI / build (pull_request) Successful in 1m46s
CI / integration_tests (pull_request) Successful in 3m38s
CI / unit_tests (pull_request) Successful in 6m51s
CI / benchmark (pull_request) Failing after 16m41s
CI / coverage (pull_request) Successful in 7m5s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 46s
CI / typecheck (push) Successful in 1m28s
CI / security (push) Successful in 1m16s
CI / benchmark (push) Failing after 11s
CI / quality (push) Successful in 1m40s
CI / build (push) Successful in 2m37s
CI / integration_tests (push) Successful in 4m44s
CI / unit_tests (push) Successful in 6m35s
CI / coverage (push) Failing after 15m29s
CI / status-check (push) Has been cancelled
2026-11-26 11:37:44 +00:00
Compare
CoreRasurae deleted branch bugfix/m1-skill-gate-global-safety-and 2026-11-26 12:23:04 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveractors-core!193
No description provided.