feat(skills): execute skill scripts behind the double-safety gate #168

Merged
CoreRasurae merged 1 commit from feature/m1-skill-script-execution into develop 2026-11-12 13:53:02 +00:00
Member

Summary

Implements ADR-2034 D-10: bundled skill scripts can now be executed through the synthesized skill tool, behind the D-9 double-safety gate.

  • Adds execute, args, and timeout to the synthesized skill tool schema.
  • execute: true requires resource; only scripts/ and non-standard entries may run. references/, assets/, and root-level files are never executable.
  • Execution requires global safety false, the skill's safe_mode: false, and the agent's existing allow_shell: true; the skill gate never bypasses the command-execution capability.
  • Materializes the complete skill resource tree into a fresh isolated workspace contained by the sandbox root, uses the skill root as the working directory, selects the interpreter from the extension or shebang, applies the existing shell timeout policy and safe-mode blocklist, and removes the workspace on every path.
  • Success returns stdout/stderr in a [SKILL_SCRIPT_EXECUTED] envelope; denial, missing interpreter, non-zero exit, and timeout raise actionable ExecutionErrors. Script output joins the tool-call loop and remains subject to ADR-2031 budget/pruning.

Tests

  • Behave: new gate-matrix and execution-outcome scenarios in features/agent_skills.feature; internal selector/materializer/executor scenarios in features/skill_script_execution.feature.
  • Robot: bundled script executes end to end with positional args and relative references/ / assets/ reads in robot/agent_skills.robot.
  • nox -s unit_tests: 157 features, 3248 scenarios passed.
  • nox -s coverage_report: COVERAGE OK 97.2% (threshold 96.5%).
  • nox -s integration_tests: 380 tests passed.
  • nox -s lint, nox -s format -- --check, nox -s typecheck, nox -s security_scan, nox -s dead_code, nox -s complexity, nox -s docs, nox -s build, and nox -s benchmark all pass.

Docs

Updated docs/guides/skill-packages.md, docs/tools/built-in-tools.md, docs/tools/safe-mode.md, and CHANGELOG.md.

Closes #163

## Summary Implements ADR-2034 D-10: bundled skill scripts can now be executed through the synthesized `skill` tool, behind the D-9 double-safety gate. - Adds `execute`, `args`, and `timeout` to the synthesized `skill` tool schema. - `execute: true` requires `resource`; only `scripts/` and non-standard entries may run. `references/`, `assets/`, and root-level files are never executable. - Execution requires global safety `false`, the skill's `safe_mode: false`, and the agent's existing `allow_shell: true`; the skill gate never bypasses the command-execution capability. - Materializes the complete skill resource tree into a fresh isolated workspace contained by the sandbox root, uses the skill root as the working directory, selects the interpreter from the extension or shebang, applies the existing shell timeout policy and safe-mode blocklist, and removes the workspace on every path. - Success returns stdout/stderr in a `[SKILL_SCRIPT_EXECUTED]` envelope; denial, missing interpreter, non-zero exit, and timeout raise actionable `ExecutionError`s. Script output joins the tool-call loop and remains subject to ADR-2031 budget/pruning. ## Tests - Behave: new gate-matrix and execution-outcome scenarios in `features/agent_skills.feature`; internal selector/materializer/executor scenarios in `features/skill_script_execution.feature`. - Robot: bundled script executes end to end with positional args and relative `references/` / `assets/` reads in `robot/agent_skills.robot`. - `nox -s unit_tests`: 157 features, 3248 scenarios passed. - `nox -s coverage_report`: COVERAGE OK 97.2% (threshold 96.5%). - `nox -s integration_tests`: 380 tests passed. - `nox -s lint`, `nox -s format -- --check`, `nox -s typecheck`, `nox -s security_scan`, `nox -s dead_code`, `nox -s complexity`, `nox -s docs`, `nox -s build`, and `nox -s benchmark` all pass. ## Docs Updated `docs/guides/skill-packages.md`, `docs/tools/built-in-tools.md`, `docs/tools/safe-mode.md`, and `CHANGELOG.md`. Closes #163
Adds an optional `backends` list (>= 2 entries) and `strategy` field
(default and currently only supported value: `round_robin`) to `type: llm`
agent configuration, so a single logical agent can pool several backend
credential sets -- e.g. multiple OAuth subscriptions for the same provider
-- and forward each invocation to exactly one of them. This solves the
"single provider/model/credential-set per agent" limitation of the shared,
provider-keyed credentials dict, which cannot hold two distinct credential
sets for the same provider name.

Design is recorded in ADR-2038. Key decisions carried into this
implementation:
- `VirtualChatModel` is a genuine `BaseChatModel` subclass (same precedent
  as `ReasoningChatModel`, ADR-2036), overriding only
  `_generate`/`_agenerate`/`_stream`/`_astream`/`_llm_type` so it is
  Liskov-substitutable for any other chat model this project constructs.
- Each backend is built via the existing, unmodified per-provider
  construction/credential-validation logic
  (`llm_client._build_from_credentials`) -- no parallel validation path.
- Backend selection happens exactly once per external invocation; retries
  (ADR-2032) and the first-chunk-only streaming retry are performed
  internally against that same selected backend, never re-selecting
  mid-retry or mid-stream -- otherwise a retry would silently bounce
  between backends, which the issue explicitly calls out as must-not-happen.
  `LLMAgent._retry_ainvoke`/`_run_pruning_pass`/`stream_message` needed no
  changes; their own outer retry wrapping becomes a harmless no-op for a
  virtual provider since `VirtualChatModel` already exhausts retries
  internally before raising.
- `reasoning_feedback` is read once at the virtual-provider level and
  applied identically to every backend, so a reasoning-aware backend
  switch still round-trips `reasoning_content` correctly.

Also fixes a pre-existing Behave test-isolation bug surfaced while adding
these scenarios: `reasoning_provider_routing_steps.py`'s
`_reasoning_unavailable` context flag wasn't reset in `before_scenario`, so
it silently leaked into any later scenario reusing the shared "the chat
model is constructed" step, breaking unrelated native-provider construction.

Module: src/cleveractors/agents/llm_virtual_provider.py (new),
src/cleveractors/agents/llm_client.py, src/cleveractors/agents/llm.py,
src/cleveractors/validation/_agents.py, src/cleveractors/validation/_vocabulary.py.
BDD: features/virtual_provider.feature. Robot: robot/virtual_provider_routing.robot.
Benchmark: benchmarks/virtual_provider_benchmark.py.
Example: examples/packages/virtual-provider-pooled-agent.yaml.

ISSUES CLOSED: #155
docs: Document virtual providers for load balancing
Some checks failed
CI / lint (pull_request) Successful in 35s
CI / quality (pull_request) Successful in 1m10s
CI / typecheck (pull_request) Successful in 2m10s
CI / security (pull_request) Successful in 2m23s
CI / build (pull_request) Successful in 1m49s
CI / integration_tests (pull_request) Successful in 3m45s
CI / unit_tests (pull_request) Successful in 4m59s
CI / benchmark (pull_request) Has been cancelled
CI / coverage (pull_request) Successful in 4m36s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 1m11s
CI / build (push) Successful in 1m11s
CI / quality (push) Successful in 1m44s
CI / security (push) Successful in 2m4s
CI / integration_tests (push) Successful in 4m42s
CI / unit_tests (push) Successful in 6m43s
CI / typecheck (push) Failing after 11m15s
CI / benchmark (push) Failing after 23m33s
CI / coverage (push) Has been skipped
CI / status-check (push) Failing after 4s
9631ee670a
Refs: #155
feat(executor): let provably zero-cost invocations pass the budget pre-flight
Some checks failed
CI / lint (pull_request) Successful in 1m5s
CI / typecheck (pull_request) Successful in 1m32s
CI / quality (pull_request) Successful in 1m32s
CI / build (pull_request) Successful in 2m19s
CI / security (pull_request) Successful in 3m3s
CI / integration_tests (pull_request) Successful in 3m39s
CI / benchmark (pull_request) Failing after 19m14s
CI / unit_tests (pull_request) Failing after 19m28s
CI / lint (push) Successful in 32s
CI / typecheck (push) Successful in 1m6s
CI / security (push) Successful in 55s
CI / quality (push) Successful in 1m5s
CI / build (push) Successful in 36s
CI / integration_tests (push) Failing after 3m42s
CI / unit_tests (push) Successful in 5m35s
CI / benchmark (push) Failing after 13m33s
CI / coverage (push) Failing after 13m19s
CI / coverage (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled
CI / status-check (push) Has been cancelled
4a9818cbdf
The max_cost_usd pre-flight gate raises budget_exhausted when
accumulated >= limit before an invocation (issue #76, PR #80). A fresh
execution starts at accumulated = 0, so a 0.0 limit (the embedding-
platform case max_cost_usd = min(platform_cap, wallet.available_balance)
on an empty wallet) tripped the gate before the first node for every
run, blocking runs whose every LLM invocation is provably free — a real,
growing class of catalogued 0/0-rate models (big-pickle, glm-5-free).
Consumers had to ship a platform-side static zero-cost estimator purely
to work around it (cleveragents/cleveragents-webapp#531).

The gate now resolves the upcoming invocation's (provider, model) rates
through the exact ladder the gate charges by — lifted from _compute_cost
into core.exceptions._resolve_pricing_rates with a conservative
_is_zero_rated_invocation predicate — and lets the invocation pass the
tripped gate only when both resolved rates are exactly 0.0. Anything
unresolvable still blocks: missing/incomplete/invalid entries, half-zero
entries, non-AGENT nodes, non-LLM agents, unresolved agent names, empty
pricing tables (issue #150 AC5, the same conservative default the
platform-side estimator applies). PR #80 semantics are preserved: post-
node/post-invocation checks stay >, so an exactly-at-limit node still
completes and only the next payable node/invocation is refused.

Applied at all three pre-flight enforcement points:
- PureLangGraph._check_budget_pre_flight (per node, execute and stream
  share it via _node_budget_context), with the conservative taxonomy
  helper _upcoming_node_invocation_is_zero_rated;
- LLMAgent._check_budget_before_invoke (tool-loop pre-invoke, correct
  for all five call sites since each precedes self.chat_model);
  purely-suppressant _should_skip_pruning is deliberately unchanged
  (ADR-2038 D-3: a free invocation does not resurrect pruning);
- new shared runtime_dispatch._check_single_llm_budget_pre_flight for
  both single-type:llm dispatch functions (AC4). In _execute_llm_stream
  it raises inside the early-validation wrapper so the billing-integrity
  executor.last_result placeholder is still populated.

Owner-approved full alignment also closes a discovered enforcement gap:
the non-stream _execute_llm path had no max_cost_usd enforcement at all
(neither pre-flight nor post-invocation). It now mirrors the stream and
graph shapes with the post-invocation > cost check, the bool/non-numeric
limit ladder, and the ADR-2029 non-empty-pricing-table entry validation,
so the same config no longer succeeds or fails depending on which
executor shape it lands in.

Docs: new ADR-2038 (docs/adr/ADR-2038-budget-gate-zero-cost-carveout.md,
continuing the ADR-2029/PR-80 budget lineage) and a CHANGELOG.md
[Unreleased] entry; no pyproject version bump since v2.1.0 is still
unreleased (no tags; every prior milestone feature also landed under
[Unreleased]) and the release process is tag-driven.

Tests: 21 new Behave scenarios (features/execution_limits.feature graph
path incl. the payable-then-free-then-payable chain, features/
llm_agent_tool_loop.feature tool-loop path incl. pruning-skip and
no-pricing-table locks, new features/budget_gate_single_llm.feature
single-LLM execute/stream with invocation-counting mock models) plus 7
new Robot integration tests (robot/budget_gate_zero_cost.robot) driving
real create_executor actors end to end. The two single-LLM stream
scenarios whose enforcement point moved from post-stream to pre-flight
were updated to cover both gates separately. Gates: nox format, lint,
typecheck, security_scan, dead_code, unit_tests (3136 scenarios),
integration_tests (373 tests), coverage_report all pass; coverage
improved from 96.90% (origin/master, measured) to 97.11%, above the
97% standard, with every new line covered.

ISSUES CLOSED: #150
feat(agents): add random backend-selection strategy for virtual provider LLM agents
Some checks failed
CI / lint (pull_request) Successful in 1m13s
CI / security (pull_request) Successful in 2m12s
CI / build (pull_request) Successful in 2m9s
CI / typecheck (pull_request) Successful in 2m50s
CI / quality (pull_request) Successful in 2m56s
CI / integration_tests (pull_request) Successful in 4m1s
CI / unit_tests (pull_request) Successful in 6m49s
CI / coverage (pull_request) Successful in 6m11s
CI / status-check (pull_request) Successful in 2s
CI / benchmark (pull_request) Failing after 17m14s
CI / lint (push) Successful in 40s
CI / typecheck (push) Successful in 2m2s
CI / quality (push) Successful in 2m8s
CI / security (push) Successful in 2m37s
CI / build (push) Successful in 1m26s
CI / integration_tests (push) Successful in 4m12s
CI / unit_tests (push) Successful in 6m26s
CI / coverage (push) Successful in 5m33s
CI / status-check (push) Successful in 6s
CI / benchmark (push) Failing after 24m16s
4b98ce0067
Extends the backends/strategy virtual-provider routing (#155, ADR-2038)
with the second required selection strategy: strategy: random selects a
backend uniformly at random, via Python's random module, with identical
selection-and-forward semantics to round_robin -- only how the backend
index is chosen differs.

RandomStrategy needs no concurrency guard (unlike RoundRobinStrategy's
position counter): random.randrange has no shared mutable state to
protect. The non-cryptographic random source is deliberate -- this is a
capacity-distribution concern, not a security boundary -- documented with
a `# nosec B311` justification comment for the expected low-severity
bandit finding.

Two existing scenarios used "random" as an example of an *unsupported*
strategy value; both now use "weighted" instead, since random is no
longer unsupported.

The num_backends <= 0 guard is hoisted into a shared
SelectionStrategy._validate_num_backends helper instead of being
duplicated in both RoundRobinStrategy and RandomStrategy. Behave and
Robot coverage for the random path now assert the selected backend's
response is forwarded unmodified, not just that it was called. The ASV
benchmark helper's strategy parameter is typed as the SelectionStrategy
ABC instead of the concrete union, and the Robot suite's docstrings now
mention RandomStrategy alongside RoundRobinStrategy.

ISSUES CLOSED: #156
feat(skills): add skill-local safe_mode and resource classification
Some checks failed
CI / lint (pull_request) Successful in 2m16s
CI / typecheck (pull_request) Successful in 1m52s
CI / build (pull_request) Successful in 1m29s
CI / quality (pull_request) Successful in 2m37s
CI / security (pull_request) Successful in 3m4s
CI / integration_tests (pull_request) Successful in 3m8s
CI / unit_tests (pull_request) Successful in 5m12s
CI / coverage (pull_request) Successful in 6m0s
CI / status-check (pull_request) Successful in 2s
CI / lint (push) Successful in 1m28s
CI / typecheck (push) Successful in 2m1s
CI / build (push) Successful in 1m40s
CI / quality (push) Successful in 2m8s
CI / security (push) Successful in 2m39s
CI / integration_tests (push) Successful in 3m44s
CI / benchmark (pull_request) Failing after 18m10s
CI / unit_tests (push) Successful in 6m14s
CI / coverage (push) Successful in 5m31s
CI / status-check (push) Successful in 2s
CI / benchmark (push) Failing after 19m3s
c97ffe7b6b
Add the ADR-2034 D-8/D-9 foundation to the Skill Package Schema. A skill
may declare an optional boolean safe_mode (default true); non-boolean
values fail with the existing registry ValidationError, absence remains
canonical so existing Package IDs are unchanged, and safe_mode: false is
retained and participates in the content-addressed identity.

Classify every bundled resource path by its first POSIX segment into
references/, assets/, scripts/, non-standard, or root-file classes and
carry the class plus effective safe_mode through Skill, SkillResource,
and the loaded skill catalogue.

Document the authoring rules in a new guide, add an example skill package,
and add ASV benchmarks for classification and schema validation. No
script execution or privileged access is introduced by this change.

ISSUES CLOSED: #161
feat(skills): expose assets and gated non-standard resources through the skill tool
Some checks failed
CI / lint (pull_request) Successful in 58s
CI / typecheck (pull_request) Successful in 1m55s
CI / security (pull_request) Successful in 2m12s
CI / quality (pull_request) Successful in 2m15s
CI / build (pull_request) Successful in 2m4s
CI / benchmark (pull_request) Failing after 22m10s
CI / unit_tests (pull_request) Successful in 5m58s
CI / integration_tests (pull_request) Successful in 4m28s
CI / coverage (pull_request) Successful in 5m52s
CI / status-check (pull_request) Successful in 2s
CI / lint (push) Successful in 1m43s
CI / quality (push) Successful in 1m13s
CI / security (push) Successful in 2m27s
CI / typecheck (push) Successful in 2m36s
CI / build (push) Successful in 2m7s
CI / integration_tests (push) Successful in 4m15s
CI / unit_tests (push) Successful in 6m31s
CI / coverage (push) Successful in 4m58s
CI / status-check (push) Successful in 3s
CI / benchmark (push) Failing after 16m51s
1aa02bd4df
Return a class-grouped bundled-resource manifest when a skill activates and gate non-standard folder reads behind the ADR-2034 D-9 double-safety check. Assets become readable like references, with text decoded and binary content returned as base64. The skill tool schema and authoring docs describe the manifest and gating rules; Behave and Robot coverage exercise the manifest, asset reads, and the non-standard read matrix.

ISSUES CLOSED: #162
feat(skills): execute skill scripts behind the double-safety gate
Some checks failed
CI / lint (pull_request) Successful in 1m5s
CI / typecheck (pull_request) Successful in 1m37s
CI / security (pull_request) Successful in 1m42s
CI / quality (pull_request) Successful in 2m25s
CI / build (pull_request) Successful in 2m52s
CI / unit_tests (pull_request) Successful in 6m20s
CI / coverage (pull_request) Successful in 5m55s
CI / benchmark (pull_request) Failing after 18m59s
CI / integration_tests (pull_request) Successful in 2m38s
CI / status-check (pull_request) Successful in 1s
a1ead0b0e6
Add execute/args/timeout to the synthesized skill tool and run bundled scripts only when scripts/ or a non-standard path is requested, the ADR-2034 D-9 double-safety gate is open (global safety false and the skill declares safe_mode: false), and the agent has allow_shell enabled.

Materialize the complete skill resource tree into a fresh isolated workspace under the sandbox root, select the interpreter from the extension or shebang, apply the existing shell timeout policy and safe-mode blocklist, and remove the workspace on every path. Success returns stdout/stderr in a [SKILL_SCRIPT_EXECUTED] envelope; denial, missing interpreter, non-zero exit, and timeout raise actionable ExecutionErrors.

ISSUES CLOSED: #163
CoreRasurae added this to the v2.1.0 milestone 2026-11-10 19:18:44 +00:00
CoreRasurae changed target branch from master to develop 2026-11-10 20:17:49 +00:00
hurui200320 left a comment

PR Review: !168 (Ticket #163)

Verdict: Request Changes

The implementation itself is faithful to ADR-2034 D-10 and the ticket: the D-9 double-safety gate is correctly composed and fails closed, allow_shell is never bypassed, the workspace is verifiably contained and cleaned up on every path, and the read-path refactor into _SkillToolRequest/_read_skill_resource is behavior-preserving (verified line-by-line against the base commit, plus runtime probes of containment, interpreter selection, and end-to-end execution). However, the required integration_tests CI job fails on the PR head commit, contradicting the PR description's claim that nox -s integration_tests passes (380 tests). The merge gate (status-check) was cancelled as a result, so the PR cannot merge until this is resolved.

Per reviewer instructions, the following were excluded from this review: red-tape items (commit footer/label conventions — verified anyway: commit message matches the issue Metadata exactly, single atomic commit, rebase-clean, branch matches Metadata), and the benchmark CI failure, which is pre-existing on develop (run 540, commit 1aa02bd4) and is a non-required job in status-check. No prior review comments or author responses exist on this PR or ticket, so no items were dropped as out-of-scope/deferred.

Critical Issues

None.

Major Issues

  1. CI integration_tests fails on the PR head — merge blocked (CI run 541, job integration_tests #394333, commit a1ead0b).
    • Problem: The required integration_tests job failed after ~19m (vs. the ~3–4.5m baseline of successful runs; develop passes the same job on run 540). The status-check gate job was consequently cancelled, so the PR is not mergeable. This contradicts the PR description's "nox -s integration_tests: 380 tests passed". The failure duration pattern suggests a hang/retry loop rather than a clean assertion failure; the new Robot scenario Bundled Script Executes End To End Behind The Double Safety Gate (robot/agent_skills.robot:116) is the most likely new code involved, though run 539 shows the suite has a pre-existing flaky mode (failed once at 235s, passed on rerun).
    • Recommendation: Reproduce locally with nox -s integration_tests in a CI-like environment, fetch the ci-logs-integration-tests artifact, and fix the root cause — or, if it is the pre-existing flakiness, re-run the job until green and note that in the PR. Do not merge with a red required check.

Minor Issues

  1. Timeout error does not name the skill or resource path — src/cleveractors/agents/tool.py:1456-1460.
    • Problem: Skill script timed out after N seconds... omits the skill name and resource path, while every other execution error (denial, missing interpreter, non-zero exit) names them, the shell tool's equivalent message names the command, and the ticket requires "an actionable message naming the states and path".
    • Recommendation: Include the skill name and resource (not the workspace path) in the timeout message, e.g. Skill '<skill>' script '<resource>' timed out after N seconds.... Note the Behave assertion only checks "timed out" and the duration, so this can be strengthened without breaking tests.

Nits

  1. env assignments in shebangs are silently dropped — src/cleveractors/agents/skill_execution.py:145-165. #!/usr/bin/env -S MODE=test python3 -u resolves to python3 -u but MODE=test is never applied to the subprocess environment (verified by probe). Either apply the assignment to the child env or document the limitation in the selector docstring.
  2. docs/tools/safe-mode.md:136 states "The shell safe-mode blocklist above also applies to script execution" without noting the deliberate exclusion of the script-path component (documented only in the code comment at tool.py:1427-1432). A one-line clarification would help operators auditing safe-mode behavior.
  3. Fourth gate combination has no dedicated scenario — features/agent_skills.feature:896-1145 covers (safe,unsafe), (unsafe,safe), and (unsafe,unsafe) execution refusals/success, but not (safe,safe). Branch coverage is achieved via the other two refusal scenarios, so this only affects the ticket's "cover every gate combination" wording; a cheap Scenario Outline row would close it.
  4. Unreachable fallback — src/cleveractors/agents/tool.py:1433: [argv[0], *argv[2:]] if len(argv) > 1 else list(argv) — argv always contains the interpreter and script path, so the else branch is dead; an assertion would state the invariant.
  5. Duplicate computation — src/cleveractors/agents/skill_execution.py:103: content.splitlines() is evaluated twice; bind it once.

Summary

A high-quality, well-tested implementation of ADR-2034 D-10. Spec compliance is exact: execute/args/timeout schema additions, scripts/non-standard-only executability, the D-9 gate checked before any I/O with both states named in errors, allow_shell composition, full-tree materialization into a fresh 0700 workspace under the sandbox root with skill-root cwd, extension/shebang interpreter selection with actionable missing-interpreter errors, shell timeout-policy reuse, create_subprocess_exec (no shell injection surface), workspace cleanup on every path (verified: success, non-zero exit, timeout, selection failure, and tampered-catalogue rejection of ../absolute escapes), and the [SKILL_SCRIPT_EXECUTED] envelope feeding ADR-2031 budget/pruning. Tests cover the gate matrix, all execution outcomes, cleanup assertions, and a real end-to-end Robot scenario; docs, ADR, and CHANGELOG are consistent; commit hygiene is correct. The single blocker is the red required integration_tests CI job on the head commit, which must be reproduced/fixed or shown flaky and re-run to green before merge.

## PR Review: !168 (Ticket #163) ### Verdict: Request Changes The implementation itself is faithful to ADR-2034 D-10 and the ticket: the D-9 double-safety gate is correctly composed and fails closed, `allow_shell` is never bypassed, the workspace is verifiably contained and cleaned up on every path, and the read-path refactor into `_SkillToolRequest`/`_read_skill_resource` is behavior-preserving (verified line-by-line against the base commit, plus runtime probes of containment, interpreter selection, and end-to-end execution). However, **the required `integration_tests` CI job fails on the PR head commit**, contradicting the PR description's claim that `nox -s integration_tests` passes (380 tests). The merge gate (`status-check`) was cancelled as a result, so the PR cannot merge until this is resolved. Per reviewer instructions, the following were excluded from this review: red-tape items (commit footer/label conventions — verified anyway: commit message matches the issue Metadata exactly, single atomic commit, rebase-clean, branch matches Metadata), and the `benchmark` CI failure, which is pre-existing on `develop` (run 540, commit 1aa02bd4) and is a non-required job in `status-check`. No prior review comments or author responses exist on this PR or ticket, so no items were dropped as out-of-scope/deferred. ### Critical Issues None. ### Major Issues 1. **CI `integration_tests` fails on the PR head — merge blocked** (CI run 541, job `integration_tests` #394333, commit a1ead0b). - Problem: The required `integration_tests` job failed after ~19m (vs. the ~3–4.5m baseline of successful runs; `develop` passes the same job on run 540). The `status-check` gate job was consequently cancelled, so the PR is not mergeable. This contradicts the PR description's "nox -s integration_tests: 380 tests passed". The failure duration pattern suggests a hang/retry loop rather than a clean assertion failure; the new Robot scenario `Bundled Script Executes End To End Behind The Double Safety Gate` (robot/agent_skills.robot:116) is the most likely new code involved, though run 539 shows the suite has a pre-existing flaky mode (failed once at 235s, passed on rerun). - Recommendation: Reproduce locally with `nox -s integration_tests` in a CI-like environment, fetch the `ci-logs-integration-tests` artifact, and fix the root cause — or, if it is the pre-existing flakiness, re-run the job until green and note that in the PR. Do not merge with a red required check. ### Minor Issues 1. **Timeout error does not name the skill or resource path** — src/cleveractors/agents/tool.py:1456-1460. - Problem: `Skill script timed out after N seconds...` omits the skill name and resource path, while every other execution error (denial, missing interpreter, non-zero exit) names them, the `shell` tool's equivalent message names the command, and the ticket requires "an actionable message naming the states and path". - Recommendation: Include the skill name and resource (not the workspace path) in the timeout message, e.g. `Skill '<skill>' script '<resource>' timed out after N seconds...`. Note the Behave assertion only checks "timed out" and the duration, so this can be strengthened without breaking tests. ### Nits 1. **`env` assignments in shebangs are silently dropped** — src/cleveractors/agents/skill_execution.py:145-165. `#!/usr/bin/env -S MODE=test python3 -u` resolves to `python3 -u` but `MODE=test` is never applied to the subprocess environment (verified by probe). Either apply the assignment to the child env or document the limitation in the selector docstring. 2. **docs/tools/safe-mode.md:136** states "The shell safe-mode blocklist above also applies to script execution" without noting the deliberate exclusion of the script-path component (documented only in the code comment at tool.py:1427-1432). A one-line clarification would help operators auditing safe-mode behavior. 3. **Fourth gate combination has no dedicated scenario** — features/agent_skills.feature:896-1145 covers (safe,unsafe), (unsafe,safe), and (unsafe,unsafe) execution refusals/success, but not (safe,safe). Branch coverage is achieved via the other two refusal scenarios, so this only affects the ticket's "cover every gate combination" wording; a cheap Scenario Outline row would close it. 4. **Unreachable fallback** — src/cleveractors/agents/tool.py:1433: `[argv[0], *argv[2:]] if len(argv) > 1 else list(argv)` — `argv` always contains the interpreter and script path, so the `else` branch is dead; an assertion would state the invariant. 5. **Duplicate computation** — src/cleveractors/agents/skill_execution.py:103: `content.splitlines()` is evaluated twice; bind it once. ### Summary A high-quality, well-tested implementation of ADR-2034 D-10. Spec compliance is exact: execute/args/timeout schema additions, scripts/non-standard-only executability, the D-9 gate checked before any I/O with both states named in errors, `allow_shell` composition, full-tree materialization into a fresh 0700 workspace under the sandbox root with skill-root cwd, extension/shebang interpreter selection with actionable missing-interpreter errors, shell timeout-policy reuse, `create_subprocess_exec` (no shell injection surface), workspace cleanup on every path (verified: success, non-zero exit, timeout, selection failure, and tampered-catalogue rejection of `..`/absolute escapes), and the `[SKILL_SCRIPT_EXECUTED]` envelope feeding ADR-2031 budget/pruning. Tests cover the gate matrix, all execution outcomes, cleanup assertions, and a real end-to-end Robot scenario; docs, ADR, and CHANGELOG are consistent; commit hygiene is correct. The single blocker is the red required `integration_tests` CI job on the head commit, which must be reproduced/fixed or shown flaky and re-run to green before merge.
hurui200320 left a comment

Review complete — see the full report in the review body. Verdict: Request Changes. One major blocker: the required CI integration_tests job fails on the head commit (run 541), so the PR cannot merge until it is reproduced/fixed or shown flaky and re-run to green.

Review complete — see the full report in the review body. Verdict: Request Changes. One major blocker: the required CI integration_tests job fails on the head commit (run 541), so the PR cannot merge until it is reproduced/fixed or shown flaky and re-run to green.
CoreRasurae force-pushed feature/m1-skill-script-execution from a1ead0b0e6
Some checks failed
CI / lint (pull_request) Successful in 1m5s
CI / typecheck (pull_request) Successful in 1m37s
CI / security (pull_request) Successful in 1m42s
CI / quality (pull_request) Successful in 2m25s
CI / build (pull_request) Successful in 2m52s
CI / unit_tests (pull_request) Successful in 6m20s
CI / coverage (pull_request) Successful in 5m55s
CI / benchmark (pull_request) Failing after 18m59s
CI / integration_tests (pull_request) Successful in 2m38s
CI / status-check (pull_request) Successful in 1s
to 8bb4c7c830
Some checks failed
CI / lint (pull_request) Successful in 1m9s
CI / typecheck (pull_request) Successful in 1m10s
CI / security (pull_request) Successful in 1m31s
CI / quality (pull_request) Successful in 2m24s
CI / integration_tests (pull_request) Successful in 2m34s
CI / build (pull_request) Successful in 2m17s
CI / benchmark (pull_request) Failing after 21m41s
CI / unit_tests (pull_request) Successful in 4m48s
CI / coverage (pull_request) Successful in 4m39s
CI / status-check (pull_request) Successful in 1s
2026-11-11 15:44:43 +00:00
Compare
hurui200320 left a comment

Review body (submitted separately).

Review body (submitted separately).
hurui200320 left a comment

PR Review: !168 (Ticket #163)

Verdict: Approve

Re-review of head 8bb4c7c8 (single atomic commit, clean fast-forward on top of develop, no merge commits). The one major blocker from the previous review (required CI integration_tests job failing on run 541) is resolved: run 542 passes integration_tests plus every other required job (lint, typecheck, security, quality, unit_tests, coverage, build, status-check). Coverage passed at 97.2% (repo threshold 96.5%, project standard ≥ 97%). No unresolved discussion threads exist and nothing was declared out-of-scope or deferred, so no prior items were carried forward or struck.

All ADR-2034 D-10 execute-behaviour requirements and every ticket #163 acceptance criterion are implemented and covered by passing scenarios:

  • execute: true without resource fails before any lookup; non-boolean execute and non-string args are rejected.
  • Class gate: only scripts/ and non-standard entries are executable; references/, assets/, and root files are refused (Scenario Outline covers all three).
  • D-9 double-safety gate: all four combinations tested (refusal messages name both switch states and the resource path); allow_shell: false refusal confirms the skill gate never bypasses the command-execution capability.
  • Execution: Python script runs with positional args, relative references/ and assets/ reads resolve from the materialized skill root; .sh extension and non-standard shebang paths covered; non-zero exit, missing interpreter, and timeout each raise actionable ExecutionError with workspace cleanup asserted (no skill script workspaces should remain).
  • Internals: interpreter selection (shebang/extension/env handling), materializer containment (../base64/encoding/missing-root failures), and executor request validation all have focused Behave scenarios; the Robot scenario proves the end-to-end path against a real on-disk skill package.

Security posture is sound: spawning uses create_subprocess_exec (no shell, so args are never shell-interpreted), workspace writes go through SandboxRootPolicy (repels ../~ and containment escapes), base64 is validated, malformed catalogues fail closed, the success envelope never leaks the workspace path, and the shared safe-mode blocklist/timeout-ceiling behaviour of the shell tool is preserved by the refactor to _enforce_safe_mode_blocklist. Docs (skill-packages.md, built-in-tools.md, safe-mode.md) and the CHANGELOG entry accurately describe the implemented behaviour.

Critical Issues

None.

Major Issues

None. (The previous major blocker — failing required integration_tests on run 541 — now passes on run 542 for head 8bb4c7c8.)

Minor Issues

None.

Nits

  1. src/cleveractors/agents/tool.py (_run_skill_script_command, ~line 1463): the safe-mode blocklist check drops argv[1] (the workspace script path) to avoid false positives from the random mkdtemp suffix. Deliberate and documented in code and docs/tools/safe-mode.md; the residual gap (a skill-bundled file whose name contains a blocklisted substring escapes the substring filter) is skill-author-controlled rather than model-controlled and already requires the double gate, so no action needed — noted for the record.
  2. src/cleveractors/agents/tool.py (_run_skill_script_command, timeout path ~line 1483): on timeout only the direct child is killed (process.kill()), not the process group, so grandchildren spawned by a script may outlive the deadline. This is strictly better than the shell tool (which kills nothing on timeout) and not a regression — consider a start_new_session=True + group kill in a future hardening pass for both paths.
  3. features/agent_skills.feature: no skill-tool-specific scenario for a per-invocation timeout exceeding the shell_max_timeout/tools_max_timeout ceiling, nor a success-path execution with an explicit timeout override. The shared TimeoutPolicy mechanism is already tested via the shell tool, so this is optional coverage polish.
  4. Informational (non-blocking): the non-required CI / benchmark job is red on run 542, but it is also red on develop itself (run 540) and on PR !167 (runs 538/539) — pre-existing and excluded from status-check's required jobs, so it does not gate this merge. Suggest tracking the ASV baseline regression separately.

Summary

A well-scoped, atomic implementation of ADR-2034 D-10. The design keeps a single controlled execution path (timeout policy, blocklist, and spawning stay in ToolAgent) while delegating interpreter selection, workspace materialization, and orchestration to a new, cleanly separated skill_execution module with dependency injection that keeps the code independently testable. The gate matrix, failure paths, and cleanup guarantees are thoroughly tested at both the unit (Behave) and integration (Robot) levels, and documentation and changelog were updated in the same commit. The previous CI blocker is fixed and all required checks are green on the current head. Approving; the nits above are optional follow-ups and none block the merge.

## PR Review: !168 (Ticket #163) ### Verdict: Approve Re-review of head `8bb4c7c8` (single atomic commit, clean fast-forward on top of `develop`, no merge commits). The one major blocker from the previous review (required CI `integration_tests` job failing on run 541) is **resolved**: run 542 passes `integration_tests` plus every other required job (lint, typecheck, security, quality, unit_tests, coverage, build, status-check). Coverage passed at 97.2% (repo threshold 96.5%, project standard ≥ 97%). No unresolved discussion threads exist and nothing was declared out-of-scope or deferred, so no prior items were carried forward or struck. All ADR-2034 D-10 execute-behaviour requirements and every ticket #163 acceptance criterion are implemented and covered by passing scenarios: - `execute: true` without `resource` fails before any lookup; non-boolean `execute` and non-string `args` are rejected. - Class gate: only `scripts/` and non-standard entries are executable; `references/`, `assets/`, and root files are refused (Scenario Outline covers all three). - D-9 double-safety gate: all four combinations tested (refusal messages name both switch states and the resource path); `allow_shell: false` refusal confirms the skill gate never bypasses the command-execution capability. - Execution: Python script runs with positional `args`, relative `references/` and `assets/` reads resolve from the materialized skill root; `.sh` extension and non-standard shebang paths covered; non-zero exit, missing interpreter, and timeout each raise actionable `ExecutionError` with workspace cleanup asserted (`no skill script workspaces should remain`). - Internals: interpreter selection (shebang/extension/`env` handling), materializer containment (`..`/base64/encoding/missing-root failures), and executor request validation all have focused Behave scenarios; the Robot scenario proves the end-to-end path against a real on-disk skill package. Security posture is sound: spawning uses `create_subprocess_exec` (no shell, so `args` are never shell-interpreted), workspace writes go through `SandboxRootPolicy` (repels `..`/`~` and containment escapes), base64 is validated, malformed catalogues fail closed, the success envelope never leaks the workspace path, and the shared safe-mode blocklist/timeout-ceiling behaviour of the `shell` tool is preserved by the refactor to `_enforce_safe_mode_blocklist`. Docs (`skill-packages.md`, `built-in-tools.md`, `safe-mode.md`) and the CHANGELOG entry accurately describe the implemented behaviour. ### Critical Issues None. ### Major Issues None. (The previous major blocker — failing required `integration_tests` on run 541 — now passes on run 542 for head `8bb4c7c8`.) ### Minor Issues None. ### Nits 1. `src/cleveractors/agents/tool.py` (`_run_skill_script_command`, ~line 1463): the safe-mode blocklist check drops `argv[1]` (the workspace script path) to avoid false positives from the random `mkdtemp` suffix. Deliberate and documented in code and `docs/tools/safe-mode.md`; the residual gap (a skill-bundled file whose *name* contains a blocklisted substring escapes the substring filter) is skill-author-controlled rather than model-controlled and already requires the double gate, so no action needed — noted for the record. 2. `src/cleveractors/agents/tool.py` (`_run_skill_script_command`, timeout path ~line 1483): on timeout only the direct child is killed (`process.kill()`), not the process group, so grandchildren spawned by a script may outlive the deadline. This is strictly better than the `shell` tool (which kills nothing on timeout) and not a regression — consider a `start_new_session=True` + group kill in a future hardening pass for both paths. 3. `features/agent_skills.feature`: no skill-tool-specific scenario for a per-invocation `timeout` exceeding the `shell_max_timeout`/`tools_max_timeout` ceiling, nor a success-path execution with an explicit `timeout` override. The shared `TimeoutPolicy` mechanism is already tested via the `shell` tool, so this is optional coverage polish. 4. Informational (non-blocking): the non-required `CI / benchmark` job is red on run 542, but it is also red on `develop` itself (run 540) and on PR !167 (runs 538/539) — pre-existing and excluded from `status-check`'s required jobs, so it does not gate this merge. Suggest tracking the ASV baseline regression separately. ### Summary A well-scoped, atomic implementation of ADR-2034 D-10. The design keeps a single controlled execution path (timeout policy, blocklist, and spawning stay in `ToolAgent`) while delegating interpreter selection, workspace materialization, and orchestration to a new, cleanly separated `skill_execution` module with dependency injection that keeps the code independently testable. The gate matrix, failure paths, and cleanup guarantees are thoroughly tested at both the unit (Behave) and integration (Robot) levels, and documentation and changelog were updated in the same commit. The previous CI blocker is fixed and all required checks are green on the current head. Approving; the nits above are optional follow-ups and none block the merge.
CoreRasurae force-pushed feature/m1-skill-script-execution from 8bb4c7c830
Some checks failed
CI / lint (pull_request) Successful in 1m9s
CI / typecheck (pull_request) Successful in 1m10s
CI / security (pull_request) Successful in 1m31s
CI / quality (pull_request) Successful in 2m24s
CI / integration_tests (pull_request) Successful in 2m34s
CI / build (pull_request) Successful in 2m17s
CI / benchmark (pull_request) Failing after 21m41s
CI / unit_tests (pull_request) Successful in 4m48s
CI / coverage (pull_request) Successful in 4m39s
CI / status-check (pull_request) Successful in 1s
to 83d62347fd
Some checks failed
CI / lint (pull_request) Successful in 47s
CI / typecheck (pull_request) Successful in 1m29s
CI / security (pull_request) Successful in 1m11s
CI / unit_tests (pull_request) Has started running
CI / benchmark (pull_request) Has started running
CI / quality (pull_request) Successful in 49s
CI / build (pull_request) Successful in 1m47s
CI / integration_tests (pull_request) Failing after 4m32s
CI / coverage (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled
2026-11-12 12:48:44 +00:00
Compare
CoreRasurae force-pushed feature/m1-skill-script-execution from 83d62347fd
Some checks failed
CI / lint (pull_request) Successful in 47s
CI / typecheck (pull_request) Successful in 1m29s
CI / security (pull_request) Successful in 1m11s
CI / unit_tests (pull_request) Has started running
CI / benchmark (pull_request) Has started running
CI / quality (pull_request) Successful in 49s
CI / build (pull_request) Successful in 1m47s
CI / integration_tests (pull_request) Failing after 4m32s
CI / coverage (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled
to 7532768dd8
Some checks failed
CI / lint (pull_request) Successful in 47s
CI / security (pull_request) Successful in 1m24s
CI / typecheck (pull_request) Successful in 1m57s
CI / quality (pull_request) Successful in 1m52s
CI / build (pull_request) Successful in 51s
CI / integration_tests (pull_request) Successful in 3m39s
CI / unit_tests (pull_request) Successful in 5m40s
CI / coverage (pull_request) Successful in 5m32s
CI / benchmark (pull_request) Has been cancelled
CI / status-check (pull_request) Successful in 2s
CI / lint (push) Successful in 46s
CI / typecheck (push) Successful in 1m53s
CI / security (push) Successful in 1m32s
CI / quality (push) Successful in 1m50s
CI / build (push) Successful in 2m27s
CI / unit_tests (push) Successful in 6m4s
CI / integration_tests (push) Failing after 14m41s
CI / coverage (push) Failing after 13m46s
CI / benchmark (push) Failing after 38m52s
CI / status-check (push) Has been cancelled
2026-11-12 13:08:58 +00:00
Compare
CoreRasurae deleted branch feature/m1-skill-script-execution 2026-11-12 13:53:02 +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!168
No description provided.