Reject a safe_mode: true skill bundling scripts/ or non-standard resources at validation time (ADR-2034 D-11) #191

Closed
opened 2026-11-25 12:46:31 +00:00 by CoreRasurae · 0 comments
Member

Metadata

Commit Message: feat(skills): reject safe_mode:true skills that bundle scripts/ or non-standard resources
Branch: feature/m1-skill-safe-mode-resource-audit

Note (amended 2026-11-25): This repository's PRs are submitted against develop, not master. The reference to master below describing the PR target is corrected to develop accordingly; nothing else about the acceptance criteria changes.

Background and context

ADR-2034 D-9 already prevents a safe_mode: true skill from executing a scripts/ or non-standard-folder resource (the double-safety gate's "skill safety" half stays closed). The ADR's 2026-11-25 revision adds D-11: nothing previously prevented such a skill from existing in the first place — SkillValidator.validate (src/cleveractors/agents/skill_schema.py, starting line 193) computes resources (_validate_resources, line 261) and safe_mode (_validate_safe_mode, line 262) completely independently and never cross-checks them. A skill package can therefore declare (or default to) safe_mode: true — asserting it needs no privileged operations — while still bundling a scripts/ or non-standard-folder entry that only makes sense under privilege. The declaration is then not merely unused, it is false, and nothing flags this at the point the skill is loaded.

Per D-11, this must fail fast — ValidationError from SkillValidator.validate, which SkillLoader._validate_one (src/cleveractors/agents/skills.py, ~line 236) already wraps as AgentCreationError for every other validation failure — not merely leave the resource dormant and unreachable at execution time.

Current behavior

SkillValidator.validate accepts, without error, skill content such as:

skill: true
name: innocuous-skill
description: Looks safe
instructions: Run scripts/helper.py
resources:
  scripts/helper.py:
    encoding: utf-8
    content: "..."

with no safe_mode field (canonical default true) — even though scripts/helper.py classifies (via SkillResourceClassifier.classify, same file, ~line 80) as SkillResourceClass.SCRIPT, a class that can never be executed while the skill reports itself safe. The same gap exists for a bundled non-standard-folder entry (e.g. fixtures/sample.pdf, classified NON_STANDARD).

Expected behavior

SkillValidator.validate raises ValidationError — naming the skill's name and every offending resource path — when the skill's effective safe_mode (explicit or default true) is true and resources contains at least one entry classified by SkillResourceClassifier.classify as SkillResourceClass.SCRIPT or SkillResourceClass.NON_STANDARD. A skill declaring safe_mode: false is unaffected regardless of what its resources contain — the rule is one-directional, matching ADR-2034 D-11.

Acceptance criteria

  • A skill with effective safe_mode: true (explicit or omitted) and a scripts/... resource fails validation with ValidationError naming the skill's name and the offending path.
  • A skill with effective safe_mode: true and a non-standard-folder resource (e.g. fixtures/...) fails validation the same way.
  • A skill with effective safe_mode: true and only references/, assets/, and root-level files continues to validate successfully (no regression).
  • A skill with safe_mode: false validates successfully regardless of its resources — bundling no script/non-standard resource at all is not an error.
  • The error message names every offending path when more than one is present, not just the first.
  • SkillLoader._validate_one/load/aload (src/cleveractors/agents/skills.py) surface this as AgentCreationError with no code change required there, since they already wrap any ValidationError raised by SkillValidator.validate.

Supporting information

  • docs/adr/ADR-2034-skill-package-support.md D-11.
  • docs/actor-registry-standard.md §16.1 "Safe-mode/resource consistency".
  • docs/index.md §4.4.8 "Resolution and validation".
  • Affected code: SkillValidator.validate (src/cleveractors/agents/skill_schema.py, ~line 193), specifically the gap between resources = self._validate_resources(...) (line 261) / safe_mode = self._validate_safe_mode(...) (line 262) and the Skill(...) construction (line 266). SkillResourceClassifier.classify (same file, ~line 80) is the existing D-8 classifier to reuse — do not reimplement path classification.
  • Parent Epic: #160 ("Epic: Agent Skills — Full Resource Support and Safe Execution") — linked via Forgejo dependency, not referenced further here.

Subtasks

  • Add a cross-field check in SkillValidator.validate (src/cleveractors/agents/skill_schema.py), run after resources/safe_mode are computed and before constructing Skill, that raises ValidationError when safe_mode is True and any resources key classifies as SkillResourceClass.SCRIPT or SkillResourceClass.NON_STANDARD via SkillResourceClassifier.classify.
  • Name the skill's name and every offending resource path in the ValidationError message (not just the first).
  • Tests (Behave): add scenarios to features/agent_skills.feature (alongside the existing safe_mode/resources scenarios around lines 78-110) covering: safe_mode: true + a script resource fails; safe_mode: true + a non-standard resource fails; safe_mode: true + only references/assets/root files succeeds; safe_mode: false + a script or non-standard resource succeeds; safe_mode: false with neither succeeds.
  • Verify coverage >= 97% via nox -s coverage_report.
  • Run nox (all default sessions), fix any errors.

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details.
  • The commit is pushed to the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to develop, reviewed, and merged.
## Metadata Commit Message: `feat(skills): reject safe_mode:true skills that bundle scripts/ or non-standard resources` Branch: `feature/m1-skill-safe-mode-resource-audit` **Note (amended 2026-11-25):** This repository's PRs are submitted against `develop`, not `master`. The reference to `master` below describing the PR target is corrected to `develop` accordingly; nothing else about the acceptance criteria changes. ## Background and context ADR-2034 D-9 already prevents a `safe_mode: true` skill from *executing* a `scripts/` or non-standard-folder resource (the double-safety gate's "skill safety" half stays closed). The ADR's 2026-11-25 revision adds D-11: nothing previously prevented such a skill from *existing* in the first place — `SkillValidator.validate` (`src/cleveractors/agents/skill_schema.py`, starting line 193) computes `resources` (`_validate_resources`, line 261) and `safe_mode` (`_validate_safe_mode`, line 262) completely independently and never cross-checks them. A skill package can therefore declare (or default to) `safe_mode: true` — asserting it needs no privileged operations — while still bundling a `scripts/` or non-standard-folder entry that only makes sense under privilege. The declaration is then not merely unused, it is false, and nothing flags this at the point the skill is loaded. Per D-11, this must fail fast — `ValidationError` from `SkillValidator.validate`, which `SkillLoader._validate_one` (`src/cleveractors/agents/skills.py`, ~line 236) already wraps as `AgentCreationError` for every other validation failure — not merely leave the resource dormant and unreachable at execution time. ## Current behavior `SkillValidator.validate` accepts, without error, skill content such as: ```yaml skill: true name: innocuous-skill description: Looks safe instructions: Run scripts/helper.py resources: scripts/helper.py: encoding: utf-8 content: "..." ``` with no `safe_mode` field (canonical default `true`) — even though `scripts/helper.py` classifies (via `SkillResourceClassifier.classify`, same file, ~line 80) as `SkillResourceClass.SCRIPT`, a class that can never be executed while the skill reports itself safe. The same gap exists for a bundled non-standard-folder entry (e.g. `fixtures/sample.pdf`, classified `NON_STANDARD`). ## Expected behavior `SkillValidator.validate` raises `ValidationError` — naming the skill's `name` and every offending resource path — when the skill's effective `safe_mode` (explicit or default `true`) is `true` and `resources` contains at least one entry classified by `SkillResourceClassifier.classify` as `SkillResourceClass.SCRIPT` or `SkillResourceClass.NON_STANDARD`. A skill declaring `safe_mode: false` is unaffected regardless of what its `resources` contain — the rule is one-directional, matching ADR-2034 D-11. ## Acceptance criteria - [ ] A skill with effective `safe_mode: true` (explicit or omitted) and a `scripts/...` resource fails validation with `ValidationError` naming the skill's `name` and the offending path. - [ ] A skill with effective `safe_mode: true` and a non-standard-folder resource (e.g. `fixtures/...`) fails validation the same way. - [ ] A skill with effective `safe_mode: true` and only `references/`, `assets/`, and root-level files continues to validate successfully (no regression). - [ ] A skill with `safe_mode: false` validates successfully regardless of its `resources` — bundling no script/non-standard resource at all is not an error. - [ ] The error message names every offending path when more than one is present, not just the first. - [ ] `SkillLoader._validate_one`/`load`/`aload` (`src/cleveractors/agents/skills.py`) surface this as `AgentCreationError` with no code change required there, since they already wrap any `ValidationError` raised by `SkillValidator.validate`. ## Supporting information - `docs/adr/ADR-2034-skill-package-support.md` D-11. - `docs/actor-registry-standard.md` §16.1 "Safe-mode/resource consistency". - `docs/index.md` §4.4.8 "Resolution and validation". - Affected code: `SkillValidator.validate` (`src/cleveractors/agents/skill_schema.py`, ~line 193), specifically the gap between `resources = self._validate_resources(...)` (line 261) / `safe_mode = self._validate_safe_mode(...)` (line 262) and the `Skill(...)` construction (line 266). `SkillResourceClassifier.classify` (same file, ~line 80) is the existing D-8 classifier to reuse — do not reimplement path classification. - Parent Epic: #160 ("Epic: Agent Skills — Full Resource Support and Safe Execution") — linked via Forgejo dependency, not referenced further here. ## Subtasks - [ ] Add a cross-field check in `SkillValidator.validate` (`src/cleveractors/agents/skill_schema.py`), run after `resources`/`safe_mode` are computed and before constructing `Skill`, that raises `ValidationError` when `safe_mode` is `True` and any `resources` key classifies as `SkillResourceClass.SCRIPT` or `SkillResourceClass.NON_STANDARD` via `SkillResourceClassifier.classify`. - [ ] Name the skill's `name` and every offending resource path in the `ValidationError` message (not just the first). - [ ] Tests (Behave): add scenarios to `features/agent_skills.feature` (alongside the existing safe_mode/resources scenarios around lines 78-110) covering: `safe_mode: true` + a script resource fails; `safe_mode: true` + a non-standard resource fails; `safe_mode: true` + only references/assets/root files succeeds; `safe_mode: false` + a script or non-standard resource succeeds; `safe_mode: false` with neither succeeds. - [ ] Verify coverage >= 97% via `nox -s coverage_report`. - [ ] Run `nox` (all default sessions), fix any errors. ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the first line matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details. - The commit is pushed to the branch matching the Branch in Metadata exactly. - The commit is submitted as a pull request to `develop`, reviewed, and merged.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#191
No description provided.