Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ jobs:
tests/test_tier3_progress.py
tests/test_tier3_result_display.py
tests/test_harbor_runtime_preflight.py
tests/test_harbor_local_environment.py::test_contained_download_keeps_authored_dot_underscore_files_without_generated_metadata
tests/embedding/test_catalog.py::TestCatalogPersistence::test_catalog_io_supports_root_owned_tmp_alias

# Tier 2 is platform-independent Python, and Linux and Windows run the same
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ All notable changes to SkillEvaluator are documented in this file.
apply to intermediate values as well as the final result, so
`10**1000 - 10**1000`, which printed `Result: 0` before, now returns
`Error: result is too large` because each power has 1001 digits.
- Reject malformed NVIDIA Build backend tool-call names before Anthropic or
Responses streams start, so invalid model output cannot poison replayed tool history.
- Local directory downloads disable macOS-generated AppleDouble tar entries
so extended attributes do not create nonexistent source-file errors. Real
user-authored `._` files and existing containment checks are preserved.
- Retained aggregate Harbor jobs include a provenance log identifying their real
source jobs, allowing Harbor analysis to discover the merged trials without
implying an independent execution.
- Custom graders on task images whose `python3` is 3.9 no longer fail with a
`TypeError` that scored every trial 0.0, including the SkillEvaluator default
score in `default_plus_custom` mode; rerun affected evaluations. Boolean,
non-finite and out-of-range scores are still rejected.

## 1.0.1 - 2026-11-17

Expand Down
76 changes: 73 additions & 3 deletions scripts/ci/smoke_harbor_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# SPDX-License-Identifier: Apache-2.0
"""Stage the installed verifier, then exercise it with a separate task Python.

The staged verifier includes the custom grader runner, which test.sh runs with
the same task Python when a task has a custom grader.

The host needs the tier3 extra. The task interpreter needs only idna and must
not have skillevaluator installed. Use an actual Python 3.9 interpreter in CI:
newer Python parsers do not reproduce every older-interpreter syntax failure.
Expand All @@ -15,6 +18,7 @@
import json
import os
import runpy
import shutil
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -72,8 +76,17 @@ def check_staged(directory: Path) -> None:
assert verifier["_parse_retry_after"]("Thu, 01 Jan 1970 00:00:00 GMT", 7.0) == 0.0
assert verifier["_parse_retry_after"]("Fri, 31 Dec 9999 23:59:59 GMT", 7.0) > 7.0
reward = run_verifier_main(directory)
custom_rewards = run_custom_grader_runner(directory)
print(
json.dumps({"python": sys.version.split()[0], "verifier": str(directory), "results": results, "reward": reward})
json.dumps(
{
"python": sys.version.split()[0],
"verifier": str(directory),
"results": results,
"reward": reward,
"custom_rewards": custom_rewards,
}
)
)


Expand Down Expand Up @@ -134,6 +147,60 @@ def run_verifier_main(directory: Path) -> dict[str, float]:
return reward


# A stub custom grader. The boolean metric must be dropped, not scored.
STUB_CUSTOM_GRADER = """\
import json
import os
from pathlib import Path

reward = {"overall": 0.75, "custom_metrics": {"style": 0.5, "passed": True}}
path = Path(os.environ["HARBOR_LOGS_DIR"]) / "verifier" / "reward.json"
path.write_text(json.dumps(reward), encoding="utf-8")
"""


def run_custom_grader_runner(directory: Path) -> dict[str, dict[str, float]]:
"""Run custom_grader_runner.py in both custom grading modes the way test.sh does."""
expected = {
"custom_only": {"overall": 0.75, "style": 0.5},
# The default score that eval.py wrote stays the overall score.
"default_plus_custom": {"security": 1.0, "overall": 0.8, "style": 0.5},
}
rewards: dict[str, dict[str, float]] = {}
for mode, expected_reward in expected.items():
with tempfile.TemporaryDirectory(prefix="harbor-custom-grader-") as temporary:
root = Path(temporary)
logs, tests, verifier = root / "logs", root / "tests", root / "logs" / "verifier"
verifier.mkdir(parents=True)
tests.mkdir()
(tests / "grader.py").write_text(STUB_CUSTOM_GRADER, encoding="utf-8")
if mode == "default_plus_custom":
default_reward = {"security": 1.0, "overall": 0.8}
(verifier / "skill_evaluator_reward.json").write_text(json.dumps(default_reward), encoding="utf-8")
(verifier / "reward.txt").write_text("0.8", encoding="utf-8")
environment = {
"PATH": os.environ.get("PATH", os.defpath),
"HARBOR_LOGS_DIR": str(logs),
"HARBOR_TESTS_DIR": str(tests),
}
completed = subprocess.run(
[sys.executable, "-I", str(directory / "custom_grader_runner.py"), "--mode", mode],
cwd=root,
env=environment,
capture_output=True,
text=True,
encoding="utf-8",
check=False,
)
assert completed.returncode == 0, mode + "\n" + completed.stdout[-4000:] + completed.stderr[-4000:]
reward = json.loads((verifier / "reward.json").read_text(encoding="utf-8"))
overall = float((verifier / "reward.txt").read_text(encoding="utf-8"))
assert reward == expected_reward, (mode, reward)
assert overall == expected_reward["overall"], (mode, overall)
rewards[mode] = reward
return rewards


def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
mode = parser.add_mutually_exclusive_group(required=True)
Expand All @@ -144,18 +211,21 @@ def main() -> None:
check_staged(arguments.check_staged)
return

from skillevaluator.tier3.harbor.adapter import _copy_verifier
from skillevaluator.tier3.harbor.adapter import TEMPLATES_DIR, _copy_verifier, _evaluator_tests_dir

with tempfile.TemporaryDirectory(prefix="harbor-verifier-smoke-") as temporary:
task = Path(temporary)
_copy_verifier(task)
# Staged next to the verifier, as for a task with a custom grader.
staged = _evaluator_tests_dir(task)
shutil.copy2(TEMPLATES_DIR / "custom_grader_runner.py", staged / "custom_grader_runner.py")
subprocess.run(
[
str(arguments.python.absolute()),
"-I",
str(Path(__file__).resolve()),
"--check-staged",
str(task / "tests" / "skill_evaluator"),
str(staged),
],
cwd=task,
check=True,
Expand Down
1 change: 1 addition & 0 deletions scripts/classify_ci_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
TIER3_PLATFORM_TESTS = frozenset(
{
b"tests/embedding/test_catalog.py",
b"tests/test_harbor_local_environment.py",
b"tests/test_harbor_local_mode.py",
b"tests/test_harbor_local_sandbox.py",
b"tests/test_harbor_runtime_preflight.py",
Expand Down
6 changes: 5 additions & 1 deletion src/skillevaluator/tier3/harbor/local_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,11 @@ def raise_walk_error(error: OSError) -> None:
patterns.append("./" + staging.relative_to(source_root).as_posix())
excludes = " ".join(f"--exclude={shlex.quote(pattern)}" for pattern in patterns)
command = f"tar czf {archive_argument} {excludes} ."
result = await self.exec(command, cwd=str(source), timeout_sec=600, user="root")
# macOS tar otherwise invents AppleDouble members for xattrs;
# disable their creation while retaining real ._ filenames.
result = await self.exec(
command, cwd=str(source), env={"COPYFILE_DISABLE": "1"}, timeout_sec=600, user="root"
)
if result.return_code != 0:
raise RuntimeError(f"Failed to pack local directory transfer (exit code {result.return_code})")
with tarfile.open(archive, "r:gz") as transfer:
Expand Down
2 changes: 2 additions & 0 deletions src/skillevaluator/tier3/harbor/nvidia_build_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,8 @@ def _validate_chat_tool_call(tool_call: Any) -> None:
or not isinstance(function.get("arguments"), str)
):
raise BridgePayloadError("tool calls require function name and string arguments")
if not _is_chat_tool_name(function["name"]):
Comment thread
rng1995 marked this conversation as resolved.
Resolved
raise BridgePayloadError("tool call name is unsupported by NVIDIA Build")


if __name__ == "__main__":
Expand Down
21 changes: 21 additions & 0 deletions src/skillevaluator/tier3/harbor/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4550,8 +4550,10 @@ def _merge_attempt_jobs(job_dirs: list[Path], aggregate_dir: Path) -> None:
merged_trial_results: list[TrialResult] = []
source_started_at: list[datetime] = []
source_updated_at: list[datetime] = []
source_job_provenance: list[dict[str, str]] = []
used_trial_names: set[str] = set()
for source_index, (job_name, job_dir) in enumerate(snapshots):
source_identity = {"name": job_name}
try:
source_job_result = json.loads((job_dir / "result.json").read_text(encoding="utf-8"))
except (json.JSONDecodeError, OSError):
Expand All @@ -4562,12 +4564,14 @@ def _merge_attempt_jobs(job_dirs: list[Path], aggregate_dir: Path) -> None:
except Exception:
source_job_model = None
if source_job_model is not None:
source_identity["id"] = str(source_job_model.id)
source_started_at.append(_utc_aware_datetime(source_job_model.started_at))
source_updated_at.append(
_utc_aware_datetime(
source_job_model.updated_at or source_job_model.finished_at or source_job_model.started_at
)
)
source_job_provenance.append(source_identity)
root_trial_results: dict[str, dict[str, Any]] = {}
if isinstance(source_job_result, dict) and isinstance(source_job_result.get("trial_results"), list):
for candidate in source_job_result["trial_results"]:
Expand Down Expand Up @@ -4737,6 +4741,23 @@ def _merge_attempt_jobs(job_dirs: list[Path], aggregate_dir: Path) -> None:
aggregate_result.model_dump_json(indent=2),
encoding="utf-8",
)
# Harbor's analyzer identifies job directories by job.log. Record the
# real aggregation provenance without implying another agent execution.
(staged_aggregate / "job.log").write_text(
json.dumps(
{
"kind": "skillevaluator_retained_aggregate",
"job_name": aggregate_path.name,
"job_id": str(aggregate_job_id),
"execution": "Trials retained from source jobs; no independent Harbor execution.",
"n_total_trials": aggregate_total_trials,
"source_jobs": source_job_provenance,
},
indent=2,
)
+ "\n",
encoding="utf-8",
)
copytree_secure(
staged_aggregate,
aggregate_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _load_json(path: Path) -> dict[str, Any]:


def _numeric(value: Any) -> float | None:
if not isinstance(value, int | float) or isinstance(value, bool):
if not isinstance(value, (int, float)) or isinstance(value, bool):
return None
try:
score = float(value)
Expand Down
40 changes: 40 additions & 0 deletions tests/test_harbor_local_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,46 @@ async def exercise() -> None:
asyncio.run(exercise())


@pytest.mark.skipif(sys.platform != "darwin", reason="macOS bsdtar generates AppleDouble metadata entries")
Comment thread
rng1995 marked this conversation as resolved.
Resolved
@pytest.mark.parametrize("method", ["download_dir_with_exclusions", "download_dir_filtered"])
def test_contained_download_keeps_authored_dot_underscore_files_without_generated_metadata(
local_output_environment: SkillEvaluatorLocalEnvironment, tmp_path: Path, method: str
) -> None:
environment = local_output_environment
payload = {"keep.txt": b"selected contents\n", "._authored.txt": b"user-authored contents\n"}
target = tmp_path / "downloaded"
target.mkdir()
(target / "retained.txt").write_bytes(b"existing unrelated output\n")

async def exercise() -> None:
await environment.start()
try:
source = environment._resolve_path("/workspace/export")
source.mkdir()
for name, data in payload.items():
(source / name).write_bytes(data)
# Directory metadata creates a synthetic ._. member; selected-file
# metadata creates ._keep.txt even though no such source file exists.
for path in (source, source / "keep.txt"):
subprocess.run(
["/usr/bin/xattr", "-w", "com.skillevaluator.transfer-test", "metadata", str(path)],
check=True,
capture_output=True,
)
before = set(environment._root.rglob("*"))
options = {"exclude": []} if method == "download_dir_with_exclusions" else {"include": ["*.txt"]}

await getattr(environment, method)(source_dir="/workspace/export", target_dir=target, **options)

assert _contained_transfer_files(target) == {**payload, "retained.txt": b"existing unrelated output\n"}
assert _contained_transfer_files(source) == payload
assert set(environment._root.rglob("*")) == before
finally:
await environment.stop(delete=False)

asyncio.run(exercise())


@pytest.mark.skipif(os.name == "nt", reason="real local subprocess backend requires POSIX")
@pytest.mark.parametrize("method", ["download_dir_with_exclusions", "download_dir_filtered"])
@pytest.mark.parametrize("spelling", ["absolute", "mapped-escape", "linked-source"])
Expand Down
38 changes: 38 additions & 0 deletions tests/test_harbor_runner_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,44 @@ def test_merge_attempt_jobs_preserves_regular_trial_artifacts(tmp_path: Path) ->
assert parsed_config.job_name == aggregate_dir.name


def test_merge_attempt_jobs_is_discoverable_by_installed_harbor_analyzer(tmp_path: Path) -> None:
from harbor.analyze.analyzer import _resolve_trial_dirs
from harbor.viewer.scanner import JobScanner

attempts = [tmp_path / "attempt-001", tmp_path / "attempt-002"]
for index, job_dir in enumerate(attempts, start=1):
_write_current_harbor_attempt(
job_dir,
trial_name=f"case-{index:03d}__trial",
root_completed=1,
result_id=index * 10,
)
(job_dir / f"case-{index:03d}__trial" / "trial.log").write_text("Retained source trial log\n", encoding="utf-8")
aggregate_dir = tmp_path / "aggregate"

runner._merge_attempt_jobs(attempts, aggregate_dir)

scanner = JobScanner(tmp_path)
expected_trials = [aggregate_dir / name for name in scanner.list_trials(aggregate_dir.name)]
assert len(expected_trials) == 2
assert _resolve_trial_dirs(aggregate_dir, filter_passing=None, n_trials=None) == expected_trials
aggregate_result = scanner.get_job_result(aggregate_dir.name)
assert aggregate_result is not None
provenance = json.loads((aggregate_dir / "job.log").read_text(encoding="utf-8"))
assert provenance["kind"] == "skillevaluator_retained_aggregate"
assert provenance["job_name"] == aggregate_dir.name
assert provenance["job_id"] == str(aggregate_result.id)
assert provenance["execution"] == "Trials retained from source jobs; no independent Harbor execution."
assert provenance["n_total_trials"] == aggregate_result.n_total_trials
assert provenance["source_jobs"] == [
{
"name": job_dir.name,
"id": json.loads((job_dir / "result.json").read_text(encoding="utf-8"))["id"],
}
for job_dir in attempts
]


def test_merge_attempt_jobs_normalizes_mixed_naive_and_aware_timestamps(tmp_path: Path) -> None:
from harbor.viewer.scanner import JobScanner

Expand Down
Loading
Loading