Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
fix(tier3): close isolation review edge cases
Christopher Kevin797fb265dc40
diff --git a/src/skillevaluator/tier3/harbor/adapter.py b/src/skillevaluator/tier3/harbor/adapter.pyindex 887d0df8..8e582524 100644--- a/src/skillevaluator/tier3/harbor/adapter.py+++ b/src/skillevaluator/tier3/harbor/adapter.py@@ -476,6 +476,44 @@ def _authenticated_generated_output_ancestor(return None+def _authenticated_generated_output_latest_alias(+ path: Path,+ root: Path,+ authenticated_roots: set[Path] | None = None,+) -> bool:+ """Recognize only ``latest`` links to an authenticated immediate run child."""+ if path.name != "latest":+ return False+ try:+ metadata = path.lstat()+ except OSError:+ return False+ if not stat.S_ISLNK(metadata.st_mode):+ return False+ try:+ relative_target = path.readlink()+ except OSError:+ return False+ target_text = os.fspath(relative_target)+ if (+ relative_target.is_absolute()+ or len(relative_target.parts) != 1+ or target_text in {"", ".", ".."}+ or "/" in target_text+ or "\\" in target_text+ ):+ return False+ target = path.parent / relative_target+ try:+ target_metadata = target.lstat()+ except OSError:+ return False+ if _path_is_link_or_reparse(target, target_metadata) or not stat.S_ISDIR(target_metadata.st_mode):+ return False+ authenticated = _authenticated_generated_output_ancestor(target, root, authenticated_roots)+ return authenticated is not None and _paths_equivalent(authenticated, target)++def _inside_declared_generated_dataset(path: Path, declared_roots: Sequence[Path]) -> bool:"""Return whether *path* is below a staged dataset marker in a declared output root."""for declared_root in declared_roots:@@ -655,6 +693,11 @@ def _runtime_skill_copy_ignore(skill_root: Path, excluded_roots: Sequence[Path]authenticated_output_roots,)is not None+ or _authenticated_generated_output_latest_alias(+ candidate,+ skill_root,+ authenticated_output_roots,+ )):ignored.add(name)return sorted(ignored)@@ -868,6 +911,8 @@ def _repo_context_ignore_file(authenticated_output_roots = set()if _authenticated_generated_output_ancestor(path, root, authenticated_output_roots) is not None:return True+ if _authenticated_generated_output_latest_alias(path, root, authenticated_output_roots):+ return Truetry:path.resolve().relative_to(root.resolve())except ValueError:diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.pyindex e4c58d0d..b0ff319e 100644--- a/src/skillevaluator/tier3/harbor/runner.py+++ b/src/skillevaluator/tier3/harbor/runner.py@@ -1688,7 +1688,7 @@ def _run_harbor_eval_impl(with ExitStack() as snapshot_stack:try:evaluator_skill_path = snapshot_stack.enter_context(private_evaluator_skill_snapshot(skill_path))- except (FileNotFoundError, ValueError) as exc:+ except (OSError, ValueError) as exc:reporter.emit(ProgressEvent(stage="configuration", state="failed", detail=str(exc)))return {"error": [str(exc)]}forwarded["_evaluator_skill_path"] = evaluator_skill_path@@ -1930,6 +1930,7 @@ def _run_harbor_eval_impl(result_path=str(result_path),))+ staging_failure_stage = "with-skill-tasks"try:for agent in agents:with_dir = tasks_dir / agent / "with"@@ -1962,6 +1963,7 @@ def _run_harbor_eval_impl(reporter.emit(ProgressEvent(stage="with-skill-tasks", state="ready", detail="task inputs staged"))if not skip_baseline:reporter.emit(ProgressEvent(stage="baseline-tasks", state="running"))+ staging_failure_stage = "baseline-tasks"for agent in agents:without_dir = agent_task_dirs[agent][1]if without_dir is not None:@@ -1988,8 +1990,8 @@ def _run_harbor_eval_impl(reporter.emit(ProgressEvent(stage="baseline-tasks", state="ready", detail="baseline inputs staged"))else:reporter.emit(ProgressEvent(stage="baseline-tasks", state="skipped", detail="baseline disabled"))- except (FileNotFoundError, ValueError) as exc:- reporter.emit(ProgressEvent(stage="with-skill-tasks", state="failed", detail=str(exc)))+ except (OSError, ValueError) as exc:+ reporter.emit(ProgressEvent(stage=staging_failure_stage, state="failed", detail=str(exc)))return {"error": [str(exc)], "run_dir": str(run_dir)}task_names = expected_task_names or []diff --git a/src/skillevaluator/tier3/results_location.py b/src/skillevaluator/tier3/results_location.pyindex 0a57feb3..ac5ef4d1 100644--- a/src/skillevaluator/tier3/results_location.py+++ b/src/skillevaluator/tier3/results_location.py@@ -29,6 +29,12 @@ _RUN_TIMESTAMP_FORMATS = (("%Y%m%d_%H%M%S", 15), ("%Y-%m-%d_%H%M%S", 17))# historical summary carries status or attempt coverage, those must be complete._RUN_COMPLETION_ARTIFACTS = ("run_config.json",)_FINAL_RESULT_ARTIFACT = "result.json"+# The writer emits a small enumeration; this generous cap rejects pathological+# metadata without relying on Python's bounded decimal-to-int conversion.+_MAX_LEGACY_OCCURRENCE_DIGITS = 32+# These runtime-owned directories predate canonical run-level ``result.json``;+# ``staged/`` arrived with that artifact and is intentionally not legacy-safe.+_LEGACY_RUNTIME_SIDECAR_DIRS = frozenset({"harbor-run-logs", "astra-cleanup"})def _expand(path: str | Path) -> Path:@@ -218,9 +224,16 @@ def _legacy_run_agents(payload: object) -> tuple[str, ...] | None:or not metadata["model"].strip()or not isinstance(metadata.get("source"), str)or not metadata["source"].strip()- or not isinstance(metadata.get("occurrence"), str)- or not metadata["occurrence"].isdigit()- or int(metadata["occurrence"]) < 1+ or (+ "occurrence" in metadata+ and (+ not isinstance(metadata["occurrence"], str)+ or not 1 <= len(metadata["occurrence"]) <= _MAX_LEGACY_OCCURRENCE_DIGITS+ or not metadata["occurrence"].isascii()+ or not metadata["occurrence"].isdigit()+ or not any(character != "0" for character in metadata["occurrence"])+ )+ )):return Nonenormalized.append(agent)@@ -517,6 +530,8 @@ def _legacy_completion_mtime(return Noneif not stat.S_ISDIR(child_metadata.st_mode):continue+ if child.name in _LEGACY_RUNTIME_SIDECAR_DIRS:+ continueif child.name not in expected_agents:return Noneagent_dirs[child.name] = childdiff --git a/tests/test_harbor_runtime_skill_isolation.py b/tests/test_harbor_runtime_skill_isolation.pyindex 620d506a..48685da3 100644--- a/tests/test_harbor_runtime_skill_isolation.py+++ b/tests/test_harbor_runtime_skill_isolation.py@@ -28,6 +28,7 @@ from skillevaluator.tier3.harbor.adapter import (validate_results_root_location,)from skillevaluator.tier3.output_provenance import mark_generated_output_root+from skillevaluator.tier3.results_location import publish_latest_resultsdef _write_runtime_skill(path: Path, package: str) -> Path:@@ -1014,6 +1015,84 @@ def test_rotated_generated_output_is_excluded_from_runtime_skill_and_repo(assert "OLD-CASE-SECRET" not in readable[email protected]("copy_repo", [False, True])+def test_rotated_results_latest_alias_to_authenticated_run_is_excluded(+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+ copy_repo: bool,+) -> None:+ monkeypatch.setenv(+ "SKILLEVALUATOR_OUTPUT_PROVENANCE_KEY_FILE",+ str(tmp_path / ".skillevaluator-state" / "output-provenance.key"),+ )+ repo, target, _, _ = _write_projection_fixture(tmp_path)+ old_results_root = target / "archived-results"+ run_id = "20260805_120000_123_aaaaaaaaaaaa"+ old_run = old_results_root / run_id+ mark_generated_output_root(old_run)+ (old_run / "run_config.json").write_text("{}\n", encoding="utf-8")+ (old_run / "result.json").write_text(json.dumps({"run_id": run_id}), encoding="utf-8")+ (old_run / "fixture-oracle.txt").write_text("HISTORICAL-RESULT-ORACLE\n", encoding="utf-8")+ assert publish_latest_results(old_results_root, run_id)+ (target / "evals" / "evals.json").write_text(+ json.dumps([{"id": "case-001", "question": "Do not use historical results.", "files": []}]),+ encoding="utf-8",+ )++ task = generate_harbor_tasks(target, tmp_path / f"current-latest-{copy_repo}", copy_repo=copy_repo)[0]++ environment = task / "environment"+ runtime_old_root = environment / "skills" / target.name / old_results_root.relative_to(target)+ assert not (runtime_old_root / run_id).exists()+ assert not (runtime_old_root / "latest").exists()+ if copy_repo:+ repo_old_root = environment / "repo" / target.relative_to(repo) / old_results_root.relative_to(target)+ assert not (repo_old_root / run_id).exists()+ assert not (repo_old_root / "latest").exists()+ readable = "\n".join(+ path.read_text(encoding="utf-8", errors="ignore") for path in environment.rglob("*") if path.is_file()+ )+ assert "HISTORICAL-RESULT-ORACLE" not in readable++[email protected]("lookalike", ["unmarked-latest", "outside-latest", "non-latest-alias"])+def test_rotated_results_symlink_lookalikes_remain_rejected(+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+ lookalike: str,+) -> None:+ monkeypatch.setenv(+ "SKILLEVALUATOR_OUTPUT_PROVENANCE_KEY_FILE",+ str(tmp_path / ".skillevaluator-state" / "output-provenance.key"),+ )+ _, target, _, _ = _write_projection_fixture(tmp_path)+ old_results_root = target / "archived-results"+ old_results_root.mkdir()+ if lookalike == "non-latest-alias":+ target_dir = old_results_root / "marked-run"+ mark_generated_output_root(target_dir)+ alias = old_results_root / "current"+ elif lookalike == "unmarked-latest":+ target_dir = old_results_root / "unmarked-run"+ target_dir.mkdir()+ alias = old_results_root / "latest"+ else:+ target_dir = tmp_path / "outside-run"+ target_dir.mkdir()+ alias = old_results_root / "latest"+ (target_dir / "payload.txt").write_text("UNAUTHENTICATED-LOOKALIKE\n", encoding="utf-8")+ try:+ alias.symlink_to(target_dir.name if target_dir.parent == old_results_root else target_dir)+ except OSError as exc:+ pytest.skip(f"symlink creation unavailable: {exc}")++ output = tmp_path / f"lookalike-{lookalike}"+ with pytest.raises(ValueError, match="symlink"):+ generate_harbor_tasks(target, output)++ assert not output.exists()++@pytest.mark.skipif(sys.platform != "darwin", reason="requires the macOS /var root alias")def test_rotated_output_is_excluded_through_macos_platform_root_alias() -> None:with tempfile.TemporaryDirectory(prefix="issue29-platform-alias-") as temporary:diff --git a/tests/test_results_location_legacy_compatibility.py b/tests/test_results_location_legacy_compatibility.pyindex de5395c9..faa4a28f 100644--- a/tests/test_results_location_legacy_compatibility.py+++ b/tests/test_results_location_legacy_compatibility.py@@ -13,6 +13,7 @@ from pathlib import Pathimport pytestfrom skillevaluator.tier3 import results_location+from skillevaluator.tier3.harbor.metrics import DEFAULT_METRIC_SETfrom skillevaluator.tier3.output_provenance import GENERATED_OUTPUT_MARKER, mark_generated_output_root@@ -26,14 +27,23 @@ def _write_legacy_run_config(run: Path, *agents: str) -> None:(run / "run_config.json").write_text(json.dumps({- "harbor": {"n_attempts": {"value": 1, "source": "ACES default"}},+ "harbor": {+ "environment": {"value": "docker", "source": "CLI"},+ "n_attempts": 1,+ "stop_on_pass": False,+ "n_concurrent": 1,+ "timeout_multiplier": 1.0,+ "base_image_mode": "auto",+ "jobs_retained": False,+ },+ "provider": {"name": "nvidia", "model": "test-model"},"task_source": "evals_json",+ "grading": {"mode": "default"},"agents": {agent: {"agent": agent,"model": "test-model","source": "test default",- "occurrence": "1",}for agent in agents},@@ -77,7 +87,7 @@ def _successful_summary_payload(agent: str = "opencode") -> dict[str, object]:"model_source": "test default","scores": {"security": 0.8},"custom_scores": {},- "metric_set": "aces-default-v2",+ "metric_set": DEFAULT_METRIC_SET,"metrics": ["security"],"dimensions": {"safety": {"score": 0.8, "sources": {"security": 1.0}}},"num_trials": 1,@@ -116,14 +126,110 @@ def test_rejects_current_run_with_list_valued_run_config(tmp_path: Path) -> Noneassert not _is_completed(run)-def test_accepts_pre_result_run_with_valid_summary(tmp_path: Path) -> None:+def test_accepts_pre_result_run_with_public_runner_config_shape(tmp_path: Path) -> None:+ run = _run(tmp_path)+ _write_legacy_run_config(run, "opencode")+ _write_successful_summary(run)++ assert _is_completed(run)++[email protected]("sidecar_name", ["harbor-run-logs", "astra-cleanup"])+def test_accepts_opaque_pre_result_runtime_sidecar(tmp_path: Path, sidecar_name: str) -> None:+ run = _run(tmp_path)+ _write_legacy_run_config(run, "opencode")+ _write_successful_summary(run)+ sidecar = run / sidecar_name+ sidecar.mkdir()+ (sidecar / "unexpected.log").write_text("opaque runtime data", encoding="utf-8")+ nested = sidecar / "unexpected-directory"+ nested.mkdir()+ (nested / "payload.bin").write_bytes(b"opaque")++ assert _is_completed(run)++[email protected]("sidecar_name", ["harbor-run-logs", "astra-cleanup"])+def test_accepts_link_inside_opaque_pre_result_runtime_sidecar(tmp_path: Path, sidecar_name: str) -> None:+ run = _run(tmp_path)+ _write_legacy_run_config(run, "opencode")+ _write_successful_summary(run)+ sidecar = run / sidecar_name+ sidecar.mkdir()+ outside = tmp_path / f"outside-{sidecar_name}.log"+ outside.write_text("opaque runtime data", encoding="utf-8")+ try:+ (sidecar / "unexpected-link").symlink_to(outside)+ except OSError as exc:+ pytest.skip(f"symlink creation unavailable: {exc}")++ assert _is_completed(run)++[email protected]("sibling_name", ["staged", "unknown-runtime"])+def test_rejects_unknown_pre_result_sibling_directory(tmp_path: Path, sibling_name: str) -> None:+ run = _run(tmp_path)+ _write_legacy_run_config(run, "opencode")+ _write_successful_summary(run)+ (run / sibling_name).mkdir()++ assert not _is_completed(run)+++def test_accepts_pre_result_run_with_valid_optional_occurrence(tmp_path: Path) -> None:run = _run(tmp_path)_write_legacy_run_config(run, "opencode")+ config_path = run / "run_config.json"+ payload = json.loads(config_path.read_text(encoding="utf-8"))+ payload["agents"]["opencode"]["occurrence"] = "2"+ config_path.write_text(json.dumps(payload), encoding="utf-8")_write_successful_summary(run)assert _is_completed(run)+ "occurrence",+ [+ None,+ "",+ "0",+ "not-a-number",+ "\N{SUPERSCRIPT TWO}",+ "\N{FULLWIDTH DIGIT ONE}",+ "\N{ARABIC-INDIC DIGIT TWO}",+ 1,+ ],+)+def test_rejects_pre_result_run_with_invalid_optional_occurrence(+ tmp_path: Path,+ occurrence: object,+) -> None:+ run = _run(tmp_path)+ _write_legacy_run_config(run, "opencode")+ config_path = run / "run_config.json"+ payload = json.loads(config_path.read_text(encoding="utf-8"))+ payload["agents"]["opencode"]["occurrence"] = occurrence+ config_path.write_text(json.dumps(payload), encoding="utf-8")+ _write_successful_summary(run)++ assert not _is_completed(run)+++def test_rejects_oversized_ascii_occurrence_without_raising(tmp_path: Path) -> None:+ run = _run(tmp_path)+ _write_legacy_run_config(run, "opencode")+ config_path = run / "run_config.json"+ payload = json.loads(config_path.read_text(encoding="utf-8"))+ payload["agents"]["opencode"]["occurrence"] = "9" * 5000++ assert results_location._legacy_run_agents(payload) is None++ config_path.write_text(json.dumps(payload), encoding="utf-8")+ _write_successful_summary(run)+ assert not _is_completed(run)++def test_accepts_summary_from_before_truthful_status_fields(tmp_path: Path) -> None:run = _run(tmp_path)_write_legacy_run_config(run, "opencode")diff --git a/tests/test_tier3_progress.py b/tests/test_tier3_progress.pyindex fcfec4cf..f038f5c6 100644--- a/tests/test_tier3_progress.py+++ b/tests/test_tier3_progress.py@@ -5,10 +5,12 @@from __future__ import annotations+import errnoimport importlibimport ioimport jsonimport subprocess+import tempfileimport threadingfrom concurrent.futures import ThreadPoolExecutorfrom pathlib import Path@@ -701,6 +703,54 @@ def test_runner_returns_error_when_private_evaluator_snapshot_cannot_be_created(assert result["error"] == [f"No evaluator source directory found at {skill / 'evals'}"]+def test_runner_returns_structured_error_and_cleans_partial_snapshot_on_enospc(+ monkeypatch: pytest.MonkeyPatch,+ tmp_path: Path,+) -> None:+ from skillevaluator.tier3.harbor import adapter, runner++ skill = tmp_path / "snapshot-enospc-skill"+ (skill / "evals").mkdir(parents=True)+ (skill / "SKILL.md").write_text("# Snapshot ENOSPC\n", encoding="utf-8")+ dataset = skill / "evals" / "evals.json"+ dataset.write_text(json.dumps([{"id": "case-1", "question": "Use the skill."}]), encoding="utf-8")+ temporary_root = tmp_path / "snapshot-temporary-root"+ temporary_root.mkdir()+ reporter = _RecordingReporter()+ provider_resolution_calls: list[bool] = []++ def fail_snapshot_copy(_source: Path, destination: Path, **_kwargs: Any) -> None:+ destination.mkdir(parents=True)+ (destination / "partial-copy").write_text("partial\n", encoding="utf-8")+ raise OSError(errno.ENOSPC, "No space left on device")++ def unexpected_provider_resolution() -> None:+ provider_resolution_calls.append(True)+ raise AssertionError("provider resolution must not start after snapshot failure")++ monkeypatch.setattr(adapter, "copytree_secure", fail_snapshot_copy)+ monkeypatch.setattr(tempfile, "tempdir", str(temporary_root))+ monkeypatch.setattr(runner, "resolve_llm_provider", unexpected_provider_resolution)+ results_root = tmp_path / "results"++ result = runner.run_harbor_eval(+ skill,+ ["codex"],+ output_dir=results_root,+ progress_reporter=reporter,+ )++ assert result["error"] == ["[Errno 28] No space left on device"]+ assert provider_resolution_calls == []+ assert not results_root.exists()+ assert list(temporary_root.iterdir()) == []+ assert json.loads(dataset.read_text(encoding="utf-8")) == [{"id": "case-1", "question": "Use the skill."}]+ transitions = [(event.stage, event.state) for event in reporter.events]+ assert ("configuration", "failed") in transitions+ assert transitions[-1] == ("run-finished", "failed")+ assert transitions.count(("run-finished", "failed")) == 1++@pytest.mark.parametrize("kind", ["symlink", "hardlink"])def test_runner_returns_error_for_unsafe_evals_config(tmp_path: Path, kind: str) -> None:from skillevaluator.tier3.harbor import runner@@ -885,6 +935,66 @@ def test_default_task_staging_failure_cleans_transient_artifacts(assert result["harbor_jobs_retained"] is False[email protected]("failure_arm", ["with-skill", "baseline"])+def test_task_staging_enospc_returns_structured_error_without_launch_and_cleans_artifacts(+ monkeypatch: pytest.MonkeyPatch,+ tmp_path: Path,+ failure_arm: str,+) -> None:+ launches: list[dict[str, Any]] = []+ evaluator_snapshots: list[Path] = []++ def fail_staging(_skill: Path, output: Path, **kwargs: Any) -> list[Path]:+ evaluator_snapshots.append(Path(kwargs["evaluator_skill_path"]))+ output.mkdir(parents=True)+ (output / "partial-copy").write_text("partial\n", encoding="utf-8")+ should_fail = (failure_arm == "with-skill" and kwargs["with_skill"]) or (+ failure_arm == "baseline" and not kwargs["with_skill"]+ )+ if should_fail:+ raise OSError(errno.ENOSPC, "No space left on device")+ return [output / "case-1"]++ def record_launch(**kwargs: Any) -> list[str]:+ launches.append(kwargs)+ return []++ runner, skill = _stub_runner(+ monkeypatch,+ tmp_path,+ task_emitter=fail_staging,+ run_agent=record_launch,+ )+ reporter = _RecordingReporter()++ result = runner.run_harbor_eval(+ skill,+ ["codex"],+ skip_baseline=False,+ output_dir=tmp_path / "results",+ progress_reporter=reporter,+ )++ run_dir = Path(result["run_dir"])+ assert result["error"] == ["[Errno 28] No space left on device"]+ assert launches == []+ assert len(evaluator_snapshots) == (1 if failure_arm == "with-skill" else 2)+ assert len(set(evaluator_snapshots)) == 1+ assert not evaluator_snapshots[0].exists()+ assert not (run_dir / "_harbor-jobs").exists()+ assert not (run_dir / "_harbor-tasks").exists()+ assert result["harbor_jobs_retained"] is False+ transitions = [(event.stage, event.state) for event in reporter.events]+ expected_stage = "with-skill-tasks" if failure_arm == "with-skill" else "baseline-tasks"+ assert (expected_stage, "running") in transitions+ assert (expected_stage, "failed") in transitions+ if failure_arm == "baseline":+ assert ("with-skill-tasks", "failed") not in transitions+ assert not any(stage.startswith("agent:") and state == "running" for stage, state in transitions)+ assert transitions[-1] == ("run-finished", "failed")+ assert transitions.count(("run-finished", "failed")) == 1++def test_default_collection_exception_cleans_transient_artifacts(monkeypatch: pytest.MonkeyPatch,tmp_path: Path,