Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Native bundle evaluation accepts packages containing only hooks, LSP servers,
or supported settings when a selected native adapter can stage them. Each
agent's native plan must support a present component; unsupported plans are
refused in native mode or fall back in auto mode with the reason recorded.
Packages with no runnable plan stop before any trial, naming their components
and the selected agents' loading modes.
- `harness-check` checks a plugin's manifest file or manifest folder (for
example `.claude-plugin/plugin.json`) as the plugin folder it belongs to. In
`--json` output the plugin entry for such a target is now keyed by the plugin
Expand Down
28 changes: 21 additions & 7 deletions src/skillevaluator/tier3/plugin_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,14 @@ def evaluate_prepared_plugin(

from skillevaluator.tier3.commands import parse_agents
from skillevaluator.tier3.plugin_evidence import EvidenceOptions, RuntimeEvidenceObserver
from skillevaluator.tier3.plugin_native import apply_native_refusals, resolve_plugin_load
from skillevaluator.tier3.plugin_native import (
apply_native_refusals,
native_component_types,
refuse_or_fall_back,
resolve_plugin_load,
)
from skillevaluator.tier3.plugin_prepare import bind_runtime_results, stage_wrapper_skill, wrapper_skill_name

if not package.runnable:
# Nothing was evaluated: INCOMPLETE with its recorded reasons, never a successful skip.
reasons = "; ".join(package.incomplete_reasons)
raise PluginLoadError(
"plugin has no runnable skill, rule, MCP server, or text component" + (f" ({reasons})" if reasons else "")
)
agents = parse_agents(options.agents)
if load != "wrapper" and not agents:
raise PluginLoadError("native plugin loading needs explicit agents")
Expand All @@ -463,6 +462,21 @@ def evaluate_prepared_plugin(
decisions = apply_native_refusals(
load, resolve_plugin_load(load, agents, env_mode=options.env_mode), package.native_source
)
if not package.runnable:
Comment thread
Afloat16 marked this conversation as resolved.
Resolved
present = ", ".join(sorted(package.native_source.present_types())) or "none"
for agent, decision in decisions.items():
adapter = HARNESS_ADAPTERS.get(agent)
if decision.native and (adapter is None or not native_component_types(adapter, package.native_source)):
decisions[agent] = refuse_or_fall_back(
load, agent, f"plugin has no runnable component for this native adapter (present: {present})"
)
if not any(decision.native for decision in decisions.values()):
modes = ", ".join(f"{agent}={decision.mode}" for agent, decision in decisions.items()) or "none"
reasons = "; ".join(package.incomplete_reasons)
Comment thread
Afloat16 marked this conversation as resolved.
Resolved
raise PluginLoadError(
"plugin has no runnable component for the selected loading mode and agents "
f"(present: {present}; load: {load}; agents: {modes})" + (f"; {reasons}" if reasons else "")
)
results_dir = options.results_dir or package.native_source.plugin_root / "evals" / "results"
package = bind_runtime_results(package, results_dir)
temp = Path(tempfile.mkdtemp(prefix="skilleval-plugin-", dir=work_dir))
Expand Down
4 changes: 3 additions & 1 deletion tests/cli/test_tier3_evaluate_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ def test_a_package_with_nothing_to_run_is_refused_with_its_reasons(tmp_path, mon
outcome = _invoke(str(bundle), "--results-dir", str(tmp_path / "results"))

assert outcome.exit_code == 1
assert "no runnable skill, rule, MCP server, or text component" in outcome.output
assert "no runnable component for the selected loading mode and agents" in outcome.output
assert "present: none" in outcome.output and "load: wrapper" in outcome.output
assert "opencode=wrapper" in outcome.output


def _incomplete_bundle(root: Path) -> Path:
Expand Down
26 changes: 26 additions & 0 deletions tests/tier3/test_evaluate_bundle_native_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ def test_a_native_run_loads_the_bundle_in_the_with_arm_only_and_counts_the_hooks
assert "Hook census" in (run_dir / "tier3-benchmark.md").read_text(encoding="utf-8")


@pytest.mark.parametrize("load", ["native", "auto"])
def test_native_loading_runs_a_bundle_that_contains_only_hooks(tmp_path, monkeypatch, load):
bundle = _bundle(tmp_path)
(bundle / ".claude-plugin/plugin.json").write_text(json.dumps({"name": "acceptance"}), encoding="utf-8")
(bundle / "evals").mkdir()
(bundle / "evals/evals.json").write_text(
json.dumps([{"id": f"case-{index}", "prompt": f"Perform fixture task {index}."} for index in range(1, 6)]),
encoding="utf-8",
)
shutil.rmtree(bundle / "skills")
launches, agents = _native_engine(monkeypatch, tmp_path / "census")
results = tmp_path / "results"
digest = publication_source_digest(bundle)

outcome = _run(bundle, results, "--plugin-load", load)

assert outcome.exit_code == 0, outcome.output
assert {variant for variant, _tasks in launches} == {"with", "without"}
assert ":Native" in (agents["with"] or "") and ":Native" not in (agents["without"] or "")
assert publication_source_digest(bundle) == digest
census = {row[2]: row for row in _sections(_run_dir(results))["hook_census"]["rows"]}
assert census[PRE][4] == 2 * TRIALS
assert census[POST][4] == TRIALS
assert census[STOP][4] == 0


def test_hook_census_discloses_the_trial_scan_limit(tmp_path, monkeypatch):
bundle = _bundle(tmp_path)
_native_engine(monkeypatch, tmp_path / "census")
Expand Down
72 changes: 72 additions & 0 deletions tests/tier3/test_plugin_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import shutil
import subprocess
from contextlib import nullcontext
from dataclasses import replace
from pathlib import Path

Expand Down Expand Up @@ -121,6 +122,77 @@ def test_permission_bypass_hook_is_recorded_as_a_native_refusal(tmp_path: Path)
assert [kind for kind, _, _ in source.refusals] == ["hook"]


@pytest.mark.parametrize(
("component_file", "config", "applied"),
[
(
"hooks/hooks.json",
{"hooks": {"SessionStart": [{"hooks": [{"type": "command", "command": "echo ready"}]}]}},
True,
),
(".lsp.json", {"python": {"command": "pylsp", "extensionToLanguage": {".py": "python"}}}, True),
("settings.json", {"agent": "reviewer"}, True),
("settings.json", {"env": {"IGNORED": "value"}}, False),
],
ids=["hook", "lsp", "settings", "ignored-settings"],
)
@pytest.mark.parametrize(
("load", "agent", "env_mode", "native"),
[
("native", "claude-code", "docker", True),
("auto", "claude-code", "docker", True),
("wrapper", "claude-code", "docker", False),
("native", "codex", "docker", False),
("auto", "codex", "docker", False),
("native", "claude-code,codex", "docker", False),
("native", "codex,claude-code", "docker", False),
("auto", "claude-code,codex", "docker", True),
("auto", "codex,claude-code", "docker", True),
("auto", "claude-code", "local", False),
("auto", "hermes", "docker", False),
],
)
def test_native_only_components_need_a_supporting_load_decision(
tmp_path: Path, component_file: str, config: dict, applied: bool, load: str, agent: str, env_mode: str, native: bool
) -> None:
root = _tree(
tmp_path / "plugin",
{
".claude-plugin/plugin.json": {"name": "demo"},
component_file: config,
"evals/evals.json": [{"id": "one", "prompt": "do it"}],
},
)
package = prepare_runtime_package(_inventory(root))
assert not package.runnable
calls = []
expected = nullcontext() if native and applied else pytest.raises(PluginLoadError, match="no runnable component")
with expected as refused:
outcome = evaluate_prepared_plugin(
package,
EvaluationOptions(skill_path=root, agents=agent, env_mode=env_mode),
work_dir=tmp_path,
load=load,
evals_source=root / "evals/evals.json",
evaluate=lambda _: calls.append(True) or {"execution_status": "succeeded"},
)
assert outcome.status == "succeeded"
for selected in agent.split(","):
decision = outcome.provenance["load_decisions"][selected]
assert decision["mode"] == ("native" if selected == "claude-code" else "wrapper")
if selected == "codex":
assert "no runnable component" in decision["reason"]
assert all(kind in decision["reason"] for kind in package.native_source.present_types())
if not (native and applied):
assert not calls and not (root / "evals" / "results").exists()
message = str(refused.value)
rejected_agent = (
"claude-code" if not applied and load == "native" and agent.startswith("claude-code") else "codex"
)
assert load in message and (rejected_agent if "codex" in agent else agent) in message
assert all(kind in message for kind in package.native_source.present_types())


SAME_SKILL = "github::owner/repo::skills::csv-loader"
SAME_RULE = "github::owner/repo::rules::style.md"
OTHER_SKILL = "github::other/lib::skills::csv-loader"
Expand Down
Loading