feat(skills): reject safe_mode:true skills that bundle scripts/ or non-standard resources #196

Merged
CoreRasurae merged 1 commit from feature/m1-skill-safe-mode-resource-audit into develop 2026-11-26 20:20:10 +00:00
Member

Summary

  • Closes #191: SkillValidator.validate now rejects a skill whose effective safe_mode is true (explicit or default) when it bundles a scripts/ resource or a non-standard top-level folder (ADR-2034 D-11), naming the skill's name and every offending path.
  • safe_mode: false is unaffected regardless of what resources it bundles (one-directional rule). No change needed in SkillLoader/AgentCreationError wrapping.
  • Updated a handful of existing fixtures that bundled privileged resources without honestly declaring safe_mode: false (now rejected by this check), and split the resource-classification Scenario Outline so it keeps covering D-8 classification without tripping D-11.

Test plan

  • nox -s lint
  • nox -s format -- --check
  • nox -s typecheck
  • nox -s coverage_report (97.3%, threshold 96.5%) — 160 features / 3370 scenarios / 15520 steps passed
  • 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

ISSUES CLOSED: #191

## Summary - Closes #191: `SkillValidator.validate` now rejects a skill whose effective `safe_mode` is `true` (explicit or default) when it bundles a `scripts/` resource or a non-standard top-level folder (ADR-2034 D-11), naming the skill's `name` and every offending path. - `safe_mode: false` is unaffected regardless of what `resources` it bundles (one-directional rule). No change needed in `SkillLoader`/`AgentCreationError` wrapping. - Updated a handful of existing fixtures that bundled privileged resources without honestly declaring `safe_mode: false` (now rejected by this check), and split the resource-classification Scenario Outline so it keeps covering D-8 classification without tripping D-11. ## Test plan - [x] `nox -s lint` - [x] `nox -s format -- --check` - [x] `nox -s typecheck` - [x] `nox -s coverage_report` (97.3%, threshold 96.5%) — 160 features / 3370 scenarios / 15520 steps passed - [x] `nox -s security_scan` - [x] `nox -s dead_code` - [x] `nox -s complexity` - [x] `nox -s integration_tests` — 382/382 Robot tests passed - [x] `nox -s benchmark` - [x] `nox -s docs` - [x] `nox -s build` ISSUES CLOSED: #191
feat(skills): reject safe_mode:true skills that bundle scripts/ or non-standard resources
Some checks failed
CI / security (pull_request) Successful in 1m13s
CI / lint (pull_request) Successful in 1m19s
CI / typecheck (pull_request) Successful in 1m33s
CI / quality (pull_request) Successful in 2m2s
CI / build (pull_request) Successful in 2m6s
CI / integration_tests (pull_request) Successful in 4m32s
CI / unit_tests (pull_request) Successful in 8m11s
CI / coverage (pull_request) Failing after 15m38s
CI / benchmark (pull_request) Failing after 23m41s
CI / status-check (pull_request) Has been cancelled
3faefe321e
ADR-2034 D-11 adds a cross-field validation check to SkillValidator.validate
(src/cleveractors/agents/skill_schema.py): a skill whose effective safe_mode
is true (explicit or the canonical default produced by omission) MUST NOT
declare any resources entry classified as scripts/ or a non-standard
top-level folder (SkillResourceClassifier.classify, D-8). D-9's
double-safety gate already stopped such a skill from *executing* a
privileged resource; nothing previously stopped the inconsistent
declaration from existing in the first place. The check runs after
resources/safe_mode are computed and before the Skill is constructed,
raising the same ValidationError D-7 already uses for every other schema
violation -- SkillLoader._validate_one already wraps it as
AgentCreationError, so no change was needed there. The error names the
skill's name and every offending resource path (not just the first).
safe_mode: false is unaffected regardless of what resources it bundles --
the rule is one-directional.

Added _PRIVILEGED_RESOURCE_CLASSES (SCRIPT, NON_STANDARD) and
SkillValidator._validate_safe_mode_resource_consistency.

Several existing fixtures bundled scripts/ and a non-standard folder while
leaving safe_mode at its default-true, which this check now rejects as a
previously-undetected inconsistency (ADR-2034 D-11 Risks: "Stricter
validation may reject previously-loadable packages"). Updated them to
either declare safe_mode: false honestly (features/steps/
skill_directory_packages_steps.py, skill_directory_unpacking_steps.py,
robot/SkillLoadingTestLib.py) or drop the privileged resources where the
scenario's actual intent was the safe_mode-omission/normalization
semantics, not D-11 (new _create_minimal_skill / privileged= parameter).

Tests (Behave): features/agent_skills.feature gains scenarios covering
safe_mode: true (explicit and omitted) + scripts/ fails, + non-standard
fails, safe_mode: true + only references/assets/root succeeds (no
regression), safe_mode: false + either privileged class succeeds, and the
error names every offending path. The existing resource-classification
Scenario Outline is split into a non-privileged (default safe_mode) and a
privileged (safe_mode: false) outline so it keeps exercising D-8
classification without tripping the new D-11 check.

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: #191
hurui200320 left a comment

PR Review: !196 (Ticket #191)

Reviewed from feature/m1-skill-safe-mode-resource-audit (3faefe3) against develop (5dfbc9b). Scope notes: the PR has no prior review comments or author responses, so nothing was excluded as out-of-scope/deferred; red-tape items excluded per review policy (and they are fine anyway — commit first line matches the ticket Metadata exactly, ISSUES CLOSED: #191 present, single commit, branch matches Metadata, rebased on latest develop, no merge commits). GISM0 was unavailable this session, so the ticket memory journal could not be consulted.

Verdict: Approve

The implementation faithfully realizes ADR-2034 D-11 exactly as specified in ticket #191 and the authoritative docs (ADR-2034 §D-11, Actor Registry Standard §16.1/§16.3 v1.3.0, index.md §4.4.8 v1.10.1 — already on develop). All acceptance criteria are met; every quality gate was re-verified locally on the PR head. Only one minor test-strength issue and a few nits — none blocking.

Critical Issues

None.

Major Issues

None.

Minor Issues

  1. features/skill_directory_packages.feature:45-51 (+ features/steps/skill_directory_packages_steps.py:158-160) — the rewritten fixture no longer isolates safe_mode as the cause of the package-ID difference. On develop, "An explicit safe_mode false is preserved and changes the package ID" used two content-identical directories (both full, only safe_mode differing), so "the two packed package IDs should differ" specifically proved safe_mode: false participates in the content-addressed identity (§16.2: "a safety downgrade visible in the content-addressed identity"). Now the safe dir is minimal (no privileged resources) and the unsafe dir is full (privileged resources), so the IDs differ due to both content and safe_mode; a regression that dropped false from canonicalization would no longer be caught by this scenario. It is mitigated — features/agent_skills.feature:91 ("A skill declaring safe_mode false retains it and changes its package ID") still isolates the property at the validator level — but the packing-level scenario should keep its original power. Recommendation: keep both directories content-identical (both minimal — D-11 explicitly permits safe_mode: false with no privileged resources, per ADR-2034: "unusual but not inconsistent") so only safe_mode differs.

Nits

  1. features/agent_skills.feature:195-199 — Scenario title says "…with only references, assets, and root files…" but the fixture bundles only references/ + assets/; no root-level file is exercised. Root-file-under-default-safe-mode success is covered only implicitly via the classification outline (LICENSE.txt). Consider adding a root file to the fixture or adjusting the title.
  2. src/cleveractors/agents/skill_schema.py:483-486 — The error message says "declares safe_mode: true" even when safe_mode was omitted and only defaulted to true. Slightly imprecise for an author who never wrote the field; "has effective safe_mode: true" (or "defaults to safe_mode: true") would read more accurately. Cosmetic.
  3. features/steps/skill_directory_packages_steps.py:96-101 — _create_full_skill's docstring summary wraps mid-sentence across the first line (PEP 257 prefers a one-line summary). Cosmetic; lint passes.
  4. Optional hardening (not required by the ticket): no Behave scenario pins the D-11 rejection at the packer/unpacker layer — a directory bundling scripts/ without safe_mode: false now fails SkillDirectoryPacker.pack with SkillPackingError, and a violating package file likewise fails the unpacker, because both funnel through SkillValidator.validate. One scenario per layer would lock in that propagation.

Verification (local, on the PR head — authoritative)

  • nox -s unit_tests: 160 features / 3370 scenarios / 15520 steps passed (matches the PR report exactly).
  • nox -s coverage_report: COVERAGE OK: 97.3% (threshold 96.5%); skill_schema.py has zero missing lines, so the new check is fully covered.
  • nox -s typecheck: 0 errors (1 pre-existing optional-dependency warning in llm_imports.py, unrelated to this PR).
  • nox -s lint: all checks passed.
  • nox -s integration_tests -- robot/agent_skills.robot: 13/13 passed (full 382/382 per PR report).

Summary

A clean, well-scoped implementation of ADR-2034 D-11. The cross-field check lives in SkillValidator.validate (after resources/safe_mode are computed, before Skill construction — the single construction gate, so it cannot be bypassed), reuses the D-8 classifier via the already-computed resource_class (no reimplementation), is one-directional exactly as specified, fails fast with the standard ValidationError (which SkillLoader._validate_one already wraps as AgentCreationError — correctly requiring no loader change), and names the skill's name plus every offending path (deterministically sorted). It correctly applies in relaxed mode too, consistent with --relaxed's documented contract of easing only the description-length/frontmatter-key checks. All five required Behave scenarios are present with meaningful assertions (including the multi-path error-message case), the split classification outline retains full D-8 coverage including the Scripts/ case-sensitivity case, and all fixture updates (features, steps, Robot lib) are the honest ones D-11 demands — no example package, benchmark, or Robot fixture that bundles privileged resources was left declaring the unsafe default. Docs needed no changes (the D-11 spec text landed on develop with the ADR revision). Approve — the minor fixture-isolation issue and nits can be addressed in a follow-up if desired.

## PR Review: !196 (Ticket #191) Reviewed from `feature/m1-skill-safe-mode-resource-audit` (3faefe3) against `develop` (5dfbc9b). Scope notes: the PR has no prior review comments or author responses, so nothing was excluded as out-of-scope/deferred; red-tape items excluded per review policy (and they are fine anyway — commit first line matches the ticket Metadata exactly, `ISSUES CLOSED: #191` present, single commit, branch matches Metadata, rebased on latest `develop`, no merge commits). GISM0 was unavailable this session, so the ticket memory journal could not be consulted. ### Verdict: Approve The implementation faithfully realizes ADR-2034 D-11 exactly as specified in ticket #191 and the authoritative docs (ADR-2034 §D-11, Actor Registry Standard §16.1/§16.3 v1.3.0, index.md §4.4.8 v1.10.1 — already on `develop`). All acceptance criteria are met; every quality gate was re-verified locally on the PR head. Only one minor test-strength issue and a few nits — none blocking. ### Critical Issues None. ### Major Issues None. ### Minor Issues 1. **`features/skill_directory_packages.feature:45-51` (+ `features/steps/skill_directory_packages_steps.py:158-160`) — the rewritten fixture no longer isolates `safe_mode` as the cause of the package-ID difference.** On `develop`, "An explicit safe_mode false is preserved and changes the package ID" used two *content-identical* directories (both full, only `safe_mode` differing), so "the two packed package IDs should differ" specifically proved `safe_mode: false` participates in the content-addressed identity (§16.2: "a safety downgrade visible in the content-addressed identity"). Now the safe dir is minimal (no privileged resources) and the unsafe dir is full (privileged resources), so the IDs differ due to both content and `safe_mode`; a regression that dropped `false` from canonicalization would no longer be caught by this scenario. It is mitigated — `features/agent_skills.feature:91` ("A skill declaring safe_mode false retains it and changes its package ID") still isolates the property at the validator level — but the packing-level scenario should keep its original power. Recommendation: keep both directories content-identical (both minimal — D-11 explicitly permits `safe_mode: false` with no privileged resources, per ADR-2034: "unusual but not inconsistent") so only `safe_mode` differs. ### Nits 2. **`features/agent_skills.feature:195-199`** — Scenario title says "…with only references, assets, and root files…" but the fixture bundles only `references/` + `assets/`; no root-level file is exercised. Root-file-under-default-safe-mode success is covered only implicitly via the classification outline (`LICENSE.txt`). Consider adding a root file to the fixture or adjusting the title. 3. **`src/cleveractors/agents/skill_schema.py:483-486`** — The error message says "declares safe_mode: true" even when `safe_mode` was omitted and only defaulted to `true`. Slightly imprecise for an author who never wrote the field; "has effective safe_mode: true" (or "defaults to safe_mode: true") would read more accurately. Cosmetic. 4. **`features/steps/skill_directory_packages_steps.py:96-101`** — `_create_full_skill`'s docstring summary wraps mid-sentence across the first line (PEP 257 prefers a one-line summary). Cosmetic; lint passes. 5. **Optional hardening (not required by the ticket):** no Behave scenario pins the D-11 rejection at the packer/unpacker layer — a directory bundling `scripts/` without `safe_mode: false` now fails `SkillDirectoryPacker.pack` with `SkillPackingError`, and a violating package file likewise fails the unpacker, because both funnel through `SkillValidator.validate`. One scenario per layer would lock in that propagation. ### Verification (local, on the PR head — authoritative) - `nox -s unit_tests`: **160 features / 3370 scenarios / 15520 steps passed** (matches the PR report exactly). - `nox -s coverage_report`: **COVERAGE OK: 97.3%** (threshold 96.5%); `skill_schema.py` has **zero** missing lines, so the new check is fully covered. - `nox -s typecheck`: 0 errors (1 pre-existing optional-dependency warning in `llm_imports.py`, unrelated to this PR). - `nox -s lint`: all checks passed. - `nox -s integration_tests -- robot/agent_skills.robot`: 13/13 passed (full 382/382 per PR report). ### Summary A clean, well-scoped implementation of ADR-2034 D-11. The cross-field check lives in `SkillValidator.validate` (after `resources`/`safe_mode` are computed, before `Skill` construction — the single construction gate, so it cannot be bypassed), reuses the D-8 classifier via the already-computed `resource_class` (no reimplementation), is one-directional exactly as specified, fails fast with the standard `ValidationError` (which `SkillLoader._validate_one` already wraps as `AgentCreationError` — correctly requiring no loader change), and names the skill's `name` plus every offending path (deterministically sorted). It correctly applies in `relaxed` mode too, consistent with `--relaxed`'s documented contract of easing only the description-length/frontmatter-key checks. All five required Behave scenarios are present with meaningful assertions (including the multi-path error-message case), the split classification outline retains full D-8 coverage including the `Scripts/` case-sensitivity case, and all fixture updates (features, steps, Robot lib) are the honest ones D-11 demands — no example package, benchmark, or Robot fixture that bundles privileged resources was left declaring the unsafe default. Docs needed no changes (the D-11 spec text landed on `develop` with the ADR revision). Approve — the minor fixture-isolation issue and nits can be addressed in a follow-up if desired.
CoreRasurae force-pushed feature/m1-skill-safe-mode-resource-audit from 3faefe321e
Some checks failed
CI / security (pull_request) Successful in 1m13s
CI / lint (pull_request) Successful in 1m19s
CI / typecheck (pull_request) Successful in 1m33s
CI / quality (pull_request) Successful in 2m2s
CI / build (pull_request) Successful in 2m6s
CI / integration_tests (pull_request) Successful in 4m32s
CI / unit_tests (pull_request) Successful in 8m11s
CI / coverage (pull_request) Failing after 15m38s
CI / benchmark (pull_request) Failing after 23m41s
CI / status-check (pull_request) Has been cancelled
to 9a0e667f4c
Some checks failed
CI / lint (pull_request) Successful in 1m19s
CI / typecheck (pull_request) Successful in 1m12s
CI / security (pull_request) Successful in 1m1s
CI / quality (pull_request) Successful in 1m52s
CI / build (pull_request) Successful in 1m36s
CI / integration_tests (pull_request) Successful in 3m27s
CI / benchmark (pull_request) Failing after 14m3s
CI / unit_tests (pull_request) Successful in 6m15s
CI / coverage (pull_request) Successful in 6m18s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 1m18s
CI / typecheck (push) Successful in 1m9s
CI / security (push) Successful in 1m5s
CI / build (push) Successful in 2m0s
CI / quality (push) Successful in 2m33s
CI / integration_tests (push) Failing after 19m28s
CI / unit_tests (push) Failing after 19m49s
CI / benchmark (push) Successful in 28m51s
CI / coverage (push) Has been skipped
CI / status-check (push) Failing after 1s
2026-11-26 16:19:33 +00:00
Compare
Author
Member

Thanks for the review! Addressed in a commit amend (force-pushed, same commit — still unreleased/iterating):

  • Minor #1 (package-ID isolation): confirmed against ADR-2034 D-11 ("a skill declaring safe_mode: false is not required to contain any script or non-standard resource... unusual but not inconsistent"). Both directories now bundle only non-privileged resources and differ solely in safe_mode, so the asserted package-ID divergence is isolated to that field again.
  • Nit #2 (root file missing): confirmed against the ticket's literal acceptance criterion ("only references/, assets/, and root-level files"). Added a root-level file (LICENSE.txt) to that scenario.
  • Nit #3 (error wording): reworded to "has effective safe_mode: true", matching the spec's own terminology (ADR-2034 D-11 / Actor Registry Standard §16.1).
  • Nit #4 (docstring wrap): fixed to a proper one-line summary.
  • Nit #5 (packer/unpacker hardening): added one scenario per layer (skill_directory_packages.feature, skill_directory_unpacking.feature) pinning that D-11 propagates through SkillDirectoryPacker/SkillDirectoryUnpacker as SkillPackingError/SkillUnpackingError, not deferred.

Re-verified via nox: lint/format/typecheck/security_scan/dead_code/complexity green; coverage scoped to this feature's Behave files shows skill_schema.py, skill_packer.py, and skill_unpacker.py each at 100% (0 missing), 254/254 scenarios passing. Full-suite coverage/integration/benchmark/docs/build were already green on the prior revision and are unaffected by this test/wording-only refinement.

Thanks for the review! Addressed in a commit amend (force-pushed, same commit — still unreleased/iterating): - **Minor #1** (package-ID isolation): confirmed against ADR-2034 D-11 ("a skill declaring `safe_mode: false` is not required to contain any script or non-standard resource... unusual but not inconsistent"). Both directories now bundle only non-privileged resources and differ solely in `safe_mode`, so the asserted package-ID divergence is isolated to that field again. - **Nit #2** (root file missing): confirmed against the ticket's literal acceptance criterion ("only `references/`, `assets/`, and root-level files"). Added a root-level file (`LICENSE.txt`) to that scenario. - **Nit #3** (error wording): reworded to "has effective safe_mode: true", matching the spec's own terminology (ADR-2034 D-11 / Actor Registry Standard §16.1). - **Nit #4** (docstring wrap): fixed to a proper one-line summary. - **Nit #5** (packer/unpacker hardening): added one scenario per layer (`skill_directory_packages.feature`, `skill_directory_unpacking.feature`) pinning that D-11 propagates through `SkillDirectoryPacker`/`SkillDirectoryUnpacker` as `SkillPackingError`/`SkillUnpackingError`, not deferred. Re-verified via `nox`: lint/format/typecheck/security_scan/dead_code/complexity green; coverage scoped to this feature's Behave files shows `skill_schema.py`, `skill_packer.py`, and `skill_unpacker.py` each at 100% (0 missing), 254/254 scenarios passing. Full-suite coverage/integration/benchmark/docs/build were already green on the prior revision and are unaffected by this test/wording-only refinement.
CoreRasurae deleted branch feature/m1-skill-safe-mode-resource-audit 2026-11-26 20:20:10 +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.

Dependencies

No dependencies set.

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