Skip to content

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.

fix(tier3): detect a results directory the Docker daemon cannot see (#80)

genkey631391b5a0670
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f54c4e84..bcda712d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,11 @@ All notable changes to SkillEvaluator are documented in this file.
### Fixed
+- The Tier 3 agent runtime preflight now fails with an actionable diagnostic when
+ the results directory is not visible to the Docker daemon. Previously the smoke
+ run passed -- agent output travels over the Docker exec API rather than through
+ the mounts -- and every scored trial then failed with `RewardFileNotFoundError`
+ while the rewards sat inside the daemon's own filesystem.
- Tier 3 accuracy and custom goal judges now retry one malformed (including
empty) or schema-invalid response with a 4096-token output budget before
failing closed, preventing a transient formatting error from making an otherwise
diff --git a/src/skillevaluator/tier3/harbor/runtime_preflight.py b/src/skillevaluator/tier3/harbor/runtime_preflight.py
index d7ce0d55..a237883f 100644
--- a/src/skillevaluator/tier3/harbor/runtime_preflight.py
+++ b/src/skillevaluator/tier3/harbor/runtime_preflight.py
@@ -11,6 +11,7 @@ import math
import os
import shlex
import ssl
+import stat
import subprocess
from collections.abc import Mapping
from dataclasses import dataclass
@@ -841,10 +842,104 @@ def _first_trial_exception_detail(job_dir: Path) -> str:
return ""
+_MAX_ARTIFACT_SCAN_ENTRIES = 4096
+
+
+def _is_link_or_reparse(info: os.stat_result) -> bool:
+ """Return whether an entry can redirect traversal to another host path."""
+ file_attributes = getattr(info, "st_file_attributes", 0)
+ return stat.S_ISLNK(info.st_mode) or bool(file_attributes & stat.FILE_ATTRIBUTE_REPARSE_POINT)
+
+
+def _has_visible_artifact(directory: Path, *, root: Path) -> bool:
+ """Return whether a directory tree contains a non-empty regular file.
+
+ The tree is written by the evaluated container, so nothing here follows
+ symlinks: a link could point anywhere on the host and make an unrelated file
+ look like proof that the mount worked. Links are skipped rather than
+ resolved, and only regular files reached without traversing one count.
+ """
+ try:
+ relative = directory.relative_to(root)
+ except ValueError:
+ return False
+
+ # ``lstat`` on only the final directory is not enough: an earlier path
+ # component can itself redirect the walk. Validate every component from the
+ # trusted job directory before entering the agent-authored tree.
+ current = root
+ for part in relative.parts:
+ current /= part
+ try:
+ info = current.lstat()
+ except OSError:
+ return False
+ if _is_link_or_reparse(info) or not stat.S_ISDIR(info.st_mode):
+ return False
+
+ pending = [current]
+ scanned = 0
+ while pending and scanned < _MAX_ARTIFACT_SCAN_ENTRIES:
+ current = pending.pop()
+ try:
+ entries = current.iterdir()
+ for entry in entries:
+ scanned += 1
+ if scanned > _MAX_ARTIFACT_SCAN_ENTRIES:
+ return False
+ try:
+ info = entry.lstat()
+ except OSError:
+ continue
+ if _is_link_or_reparse(info):
+ continue
+ if stat.S_ISDIR(info.st_mode):
+ pending.append(entry)
+ elif stat.S_ISREG(info.st_mode) and info.st_size > 0:
+ return True
+ except OSError:
+ continue
+ return False
+
+
+def _agent_artifact_dirs(trial_dir: Path, trial_result: Mapping[str, object]) -> list[Path]:
+ """Return the agent directories Harbor populates for one trial.
+
+ Single-step trials keep them at ``<trial>/agent``; multi-step trials keep one
+ per step at ``<trial>/steps/<step_name>/agent``. Harbor declares
+ ``StepConfig.name`` as a bare ``str``, so a step name may span several path
+ components -- and for the same reason it is not trusted to stay inside the
+ trial directory.
+ """
+ if isinstance(trial_result.get("agent_result"), dict):
+ return [trial_dir / "agent"]
+
+ step_results = trial_result.get("step_results")
+ if not isinstance(step_results, list):
+ return []
+
+ steps_dir = trial_dir / "steps"
+ agent_dirs: list[Path] = []
+ for step_result in step_results:
+ if not isinstance(step_result, dict):
+ continue
+ step_name = step_result.get("step_name")
+ if not isinstance(step_name, str):
+ continue
+ relative = Path(step_name)
+ if relative.anchor or not relative.parts:
+ continue
+ if any(part in ("", ".", "..") for part in relative.parts):
+ continue
+ agent_dirs.append(steps_dir.joinpath(*relative.parts) / "agent")
+ return agent_dirs
+
+
def validate_harbor_agent_only_job_result(
result_path: Path,
*,
expected_trials: int,
+ env_mode: str | None = None,
) -> tuple[bool, str]:
"""Validate a verification-disabled Harbor job and its agent result.
@@ -926,6 +1021,7 @@ def validate_harbor_agent_only_job_result(
f"Harbor agent-only job did not produce {expected_trials} trial result(s); found {len(trial_result_paths)}"
)
+ agent_artifact_dirs: list[Path] = []
for trial_result_path in trial_result_paths:
try:
trial_result = json.loads(trial_result_path.read_text(encoding="utf-8"))
@@ -933,6 +1029,8 @@ def validate_harbor_agent_only_job_result(
return False, f"Harbor produced an unreadable trial result at {trial_result_path}: {exc}"
if not isinstance(trial_result, dict):
return False, f"Harbor trial result at {trial_result_path} is not a JSON object"
+ # Collected before the single-step branch below returns early via ``continue``.
+ agent_artifact_dirs.extend(_agent_artifact_dirs(trial_result_path.parent, trial_result))
if "exception_info" not in trial_result:
return False, f"Harbor trial result at {trial_result_path} is missing exception_info"
if trial_result["exception_info"] is not None:
@@ -978,6 +1076,18 @@ def validate_harbor_agent_only_job_result(
f"Harbor agent-only trial {trial_result_path.parent.name} step {step_name!r} has no agent result"
)
+ if env_mode == "docker" and not any(
+ _has_visible_artifact(agent_dir, root=job_dir) for agent_dir in agent_artifact_dirs
+ ):
+ return False, (
+ f"Harbor reported a completed agent run but left no agent artifacts under {job_dir}, "
+ "so the results directory is not visible to the Docker daemon. Container writes go to a "
+ "bind mount whose source the daemon resolves on its own machine, so a path outside the "
+ "daemon's shared roots becomes an empty directory there and no reward or agent file ever "
+ "reaches the host. Use a results directory the daemon shares -- colima and Lima mount only "
+ "$HOME by default -- or add this path to the daemon's file sharing configuration."
+ )
+
return True, ""
@@ -1413,5 +1523,6 @@ def run_agent_runtime_preflight(
ok, detail = validate_harbor_agent_only_job_result(
jobs_dir / job_name / "result.json",
expected_trials=1,
+ env_mode=env_mode,
)
return PreflightResult(ok, agent, model, _redact_detail(detail, run_env), job_name)
diff --git a/tests/test_harbor_runtime_preflight.py b/tests/test_harbor_runtime_preflight.py
index 634dc5c8..4c862e08 100644
--- a/tests/test_harbor_runtime_preflight.py
+++ b/tests/test_harbor_runtime_preflight.py
@@ -229,7 +229,11 @@ def test_runtime_preflight_hands_nvidia_build_key_only_over_stdin(monkeypatch, t
def test_runtime_preflight_accepts_harbor_0132_unscored_agent_success(monkeypatch, tmp_path: Path) -> None:
jobs_dir = tmp_path / "jobs"
- _write_harbor_0132_unscored_result(jobs_dir)
+ result_path = _write_harbor_0132_unscored_result(jobs_dir)
+ # A real completed agent run always leaves its transcript on the mounted host path.
+ agent_dir = result_path.parent / "case-001__attempt" / "agent"
+ agent_dir.mkdir(parents=True)
+ (agent_dir / "opencode.txt").write_text("agent transcript", encoding="utf-8")
monkeypatch.setattr(runtime_preflight, "build_harbor_run_command", lambda **_kwargs: ["harbor", "run"])
monkeypatch.setattr(
runtime_preflight.subprocess,
@@ -3647,3 +3651,230 @@ def test_live_custom_catalog_401_is_inconclusive_without_exposing_secret(provide
assert runtime_preflight.credential_probe_disposition(provider, result) == "degraded"
assert secret not in result.detail
assert requests == ["/v1/models"]
+
+
+def test_agent_only_validation_accepts_visible_agent_artifacts_in_docker_mode(tmp_path: Path) -> None:
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ agent_dir = result_path.parent / "case-001__attempt" / "agent"
+ agent_dir.mkdir(parents=True)
+ (agent_dir / "opencode.txt").write_text("agent transcript", encoding="utf-8")
+
+ assert runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ ) == (True, "")
+
+
+def test_agent_only_validation_accepts_visible_multistep_agent_artifacts_in_docker_mode(tmp_path: Path) -> None:
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ trial_dir = result_path.parent / "case-001__attempt"
+ (trial_dir / "result.json").write_text(
+ json.dumps(
+ {
+ "trial_name": "case-001__attempt",
+ "agent_result": None,
+ "exception_info": None,
+ "step_results": [
+ {
+ "step_name": "author-skill",
+ "agent_result": {"n_input_tokens": 100},
+ "exception_info": None,
+ }
+ ],
+ }
+ ),
+ encoding="utf-8",
+ )
+ step_agent_dir = trial_dir / "steps" / "author-skill" / "agent"
+ step_agent_dir.mkdir(parents=True)
+ (step_agent_dir / "opencode.txt").write_text("agent transcript", encoding="utf-8")
+
+ assert runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ ) == (True, "")
+
+
+def test_agent_only_validation_rejects_invisible_agent_artifacts_in_docker_mode(tmp_path: Path) -> None:
+ """An empty host-side agent tree means the daemon never shared the results directory."""
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ # Harbor creates the mount points, but a daemon-side bind source leaves them empty.
+ (result_path.parent / "case-001__attempt" / "agent" / "setup").mkdir(parents=True)
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail
+
+
+def test_agent_only_validation_skips_mount_check_outside_docker_mode(tmp_path: Path) -> None:
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ (result_path.parent / "case-001__attempt" / "agent" / "setup").mkdir(parents=True)
+
+ assert runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="local"
+ ) == (True, "")
+
+
+def test_agent_only_validation_ignores_empty_files_when_checking_visibility(tmp_path: Path) -> None:
+ """A zero-byte placeholder is not evidence that container writes reached the host."""
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ agent_dir = result_path.parent / "case-001__attempt" / "agent"
+ agent_dir.mkdir(parents=True)
+ (agent_dir / "opencode.txt").write_text("", encoding="utf-8")
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail
+
+
+def _write_multistep_agent_only_result(jobs_dir: Path, step_name: str) -> Path:
+ """Write a completed agent-only job whose single trial has one named step."""
+ result_path = _write_harbor_0132_unscored_result(jobs_dir)
+ (result_path.parent / "case-001__attempt" / "result.json").write_text(
+ json.dumps(
+ {
+ "trial_name": "case-001__attempt",
+ "agent_result": None,
+ "exception_info": None,
+ "step_results": [
+ {
+ "step_name": step_name,
+ "agent_result": {"n_input_tokens": 100},
+ "exception_info": None,
+ }
+ ],
+ }
+ ),
+ encoding="utf-8",
+ )
+ return result_path
+
+
+def test_agent_only_validation_finds_nested_step_agent_artifacts(tmp_path: Path) -> None:
+ """Harbor declares StepConfig.name as a bare str, so a step name may nest."""
+ result_path = _write_multistep_agent_only_result(tmp_path / "jobs", "phase/author")
+ agent_dir = result_path.parent / "case-001__attempt" / "steps" / "phase" / "author" / "agent"
+ agent_dir.mkdir(parents=True)
+ (agent_dir / "opencode.txt").write_text("agent transcript", encoding="utf-8")
+
+ assert runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ ) == (True, "")
+
+
+def test_agent_only_validation_rejects_empty_nested_step_agent_directory(tmp_path: Path) -> None:
+ result_path = _write_multistep_agent_only_result(tmp_path / "jobs", "phase/author")
+ (result_path.parent / "case-001__attempt" / "steps" / "phase" / "author" / "agent").mkdir(parents=True)
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail
+
+
+def test_agent_only_validation_ignores_step_names_that_escape_the_trial(tmp_path: Path) -> None:
+ """A traversing step name must not be joined onto the trial directory."""
+ result_path = _write_multistep_agent_only_result(tmp_path / "jobs", "../../escape")
+ outside = tmp_path / "jobs" / "escape" / "agent"
+ outside.mkdir(parents=True)
+ (outside / "opencode.txt").write_text("attacker controlled", encoding="utf-8")
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail
+
+
+def test_agent_only_validation_does_not_follow_agent_authored_symlinks(tmp_path: Path) -> None:
+ """A link into the host must not be accepted as proof the mount worked."""
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ outside = tmp_path / "outside.log"
+ outside.write_text("host file the container does not own", encoding="utf-8")
+ agent_dir = result_path.parent / "case-001__attempt" / "agent"
+ agent_dir.mkdir(parents=True)
+ (agent_dir / "claimed.log").symlink_to(outside)
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail
+
+
+def test_agent_only_validation_does_not_follow_symlinked_agent_directory(tmp_path: Path) -> None:
+ """The walk must reject a link at its root, not just links found below it."""
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ outside_dir = tmp_path / "outside"
+ outside_dir.mkdir()
+ (outside_dir / "opencode.txt").write_text("host file the container does not own", encoding="utf-8")
+ agent_dir = result_path.parent / "case-001__attempt" / "agent"
+ agent_dir.symlink_to(outside_dir, target_is_directory=True)
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail
+
+
+def test_agent_only_validation_does_not_follow_nested_step_ancestor_symlink(tmp_path: Path) -> None:
+ """Each path component leading to a nested step's agent tree is untrusted."""
+ result_path = _write_multistep_agent_only_result(tmp_path / "jobs", "phase/author")
+ outside_phase = tmp_path / "outside-phase"
+ outside_agent = outside_phase / "author" / "agent"
+ outside_agent.mkdir(parents=True)
+ (outside_agent / "opencode.txt").write_text("host file the container does not own", encoding="utf-8")
+ steps_dir = result_path.parent / "case-001__attempt" / "steps"
+ steps_dir.mkdir()
+ (steps_dir / "phase").symlink_to(outside_phase, target_is_directory=True)
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail
+
+
+def test_visible_artifact_scan_stops_enumerating_at_entry_limit(monkeypatch, tmp_path: Path) -> None:
+ """The limit must bound directory enumeration, not only later stat calls."""
+ agent_dir = tmp_path / "agent"
+ agent_dir.mkdir()
+ empty_file = agent_dir / "empty.log"
+ empty_file.touch()
+
+ def hostile_iterdir(_directory: Path):
+ for _ in range(runtime_preflight._MAX_ARTIFACT_SCAN_ENTRIES + 1):
+ yield empty_file
+ raise AssertionError("artifact scan enumerated beyond its declared limit")
+
+ monkeypatch.setattr(Path, "iterdir", hostile_iterdir)
+
+ assert runtime_preflight._has_visible_artifact(agent_dir, root=tmp_path) is False
+
+
+def test_agent_only_validation_does_not_follow_symlinked_agent_subdirectories(tmp_path: Path) -> None:
+ result_path = _write_harbor_0132_unscored_result(tmp_path / "jobs")
+ outside_dir = tmp_path / "outside"
+ outside_dir.mkdir()
+ (outside_dir / "opencode.txt").write_text("host file the container does not own", encoding="utf-8")
+ agent_dir = result_path.parent / "case-001__attempt" / "agent"
+ agent_dir.mkdir(parents=True)
+ (agent_dir / "sessions").symlink_to(outside_dir, target_is_directory=True)
+
+ ok, detail = runtime_preflight.validate_harbor_agent_only_job_result(
+ result_path, expected_trials=1, env_mode="docker"
+ )
+
+ assert ok is False
+ assert "not visible to the Docker daemon" in detail