Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Partially executed evaluation arms retain scored attempts and per-arm scores without treating missing attempts as failures or enabling aggregate comparisons.
- Failed Tier 3 arms retain scored and errored trial activation diagnostics without restoring aggregate quality or lift, or double-counting token usage.
- Budget-limited Tier 3 coverage checks retain admitted attempt ordinals, avoiding false missing/excess errors when a denied slot leaves a gap.
- HTML reports retain budget context for fully budget-denied runs without
Expand Down
37 changes: 32 additions & 5 deletions src/skillevaluator/tier3/harbor/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5084,6 +5084,15 @@ def _public_pass_summary(summary: dict[str, Any]) -> dict[str, Any]:
return {key: value for key, value in summary.items() if not key.startswith("_")}


def _partial_pass_summary(summary: dict[str, Any]) -> dict[str, Any]:
return {
**summary,
"failed_cases": summary["required_checks"]["scored"] - summary["passed_cases"],
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved
"rate": None,
"rate_interval": None,
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved
}


def _pass_summary(
rewards: list[dict[str, Any]],
*,
Expand Down Expand Up @@ -7783,7 +7792,13 @@ def budget_expectations(
)
if with_policy == "mixed-score-policies":
_fail_execution_with_error(with_execution, "Conflicting score policies within the with-skill condition")
if with_execution["execution_status"] != "succeeded":
if (
with_execution["execution_status"] != "succeeded"
and 0 < with_execution["scored_attempts"] < with_execution["expected_attempts"]
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved
and with_policy != "mixed-score-policies"
):
with_pass = _partial_pass_summary(with_pass)
elif with_execution["execution_status"] != "succeeded":
with_scores = {}
with_custom_scores = {}
with_pass = {}
Expand Down Expand Up @@ -8037,7 +8052,13 @@ def budget_expectations(
without_execution,
"Conflicting score policies within the without-skill condition",
)
if without_execution["execution_status"] != "succeeded":
if (
without_execution["execution_status"] != "succeeded"
and 0 < without_execution["scored_attempts"] < without_execution["expected_attempts"]
and without_policy != "mixed-score-policies"
):
without_pass = _partial_pass_summary(without_pass)
elif without_execution["execution_status"] != "succeeded":
without_scores = {}
without_custom_scores = {}
without_pass = {}
Expand Down Expand Up @@ -8605,9 +8626,15 @@ def _build_comparison(agents_data: dict[str, Any]) -> dict[str, Any]:
comparison["metrics"][metric] = {}
for agent, data in agents_data.items():
succeeded = data.get("execution_status") == "succeeded"
with_skill = data.get("with_skill", {}).get(metric) if succeeded else None
without_skill = data.get("without_skill", {}).get(metric) if succeeded else None
lift = data.get("lift", {}).get(metric, {}).get("delta") if succeeded else None
with_succeeded = (
succeeded and data.get("conditions", {}).get("with_skill", {}).get("execution_status") == "succeeded"
)
without_succeeded = (
succeeded and data.get("conditions", {}).get("without_skill", {}).get("execution_status") == "succeeded"
)
with_skill = data.get("with_skill", {}).get(metric) if with_succeeded else None
without_skill = data.get("without_skill", {}).get(metric) if without_succeeded else None
lift = data.get("lift", {}).get(metric, {}).get("delta") if with_succeeded and without_succeeded else None
comparison["metrics"][metric][agent] = {
"with_skill": with_skill
if isinstance(with_skill, int | float) and not isinstance(with_skill, bool)
Expand Down
124 changes: 122 additions & 2 deletions tests/test_harbor_collector_runtime_failures.py
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@

import pytest

from skillevaluator.evaluation.tier3_report import render_agent_eval_html_report
from skillevaluator.evaluation.tier3_report import build_agent_eval_payload, render_agent_eval_html_report
from skillevaluator.models import ValidationResult
from skillevaluator.reporting.base import assess_publication
from skillevaluator.reporting.summary_copy import pass_at_k_summary
from skillevaluator.reporting.tier3_scope import completed_agent_result
from skillevaluator.tier3.case_summary import verdict
from skillevaluator.tier3.harbor import collector as collector_module
from skillevaluator.tier3.harbor import report_data
from skillevaluator.tier3.harbor.collector import (
Expand All @@ -22,6 +27,7 @@
)
from skillevaluator.tier3.harbor.metrics import DEFAULT_METRIC_SET, DEFAULT_METRICS
from skillevaluator.tier3.result_display import render_result
from skillevaluator.tier3.results_location import _legacy_pass_at_k_is_complete

_HARBOR_022_AGENT_RUNTIME_EXCEPTION_TYPES = (
"AgentAuthenticationError",
Expand Down Expand Up @@ -874,6 +880,117 @@ def test_partially_errored_job_preserves_only_completed_trial_coverage(tmp_path:
assert any("Scored attempt coverage is 3/4" in error for error in results["execution_errors"])


@pytest.mark.parametrize("partial_variant", ["with", "without"])
@pytest.mark.parametrize("score", [0.0, 1.0])
def test_partial_arm_retains_scored_evidence_without_enabling_quality(
tmp_path: Path, partial_variant: str, score: float
) -> None:
jobs_dir = tmp_path / "jobs"
for variant in ("with", "without"):
for case_id in CASES:
value = score if variant == partial_variant and case_id == "case-a" else 1.0
_write_reward(jobs_dir, variant=variant, case_id=case_id, attempt=1, score=value)
trial = jobs_dir / f"demo-opencode-{variant}" / f"{case_id}_attempt001"
path = trial / "verifier/reward.json"
reward = json.loads(path.read_text(encoding="utf-8"))
reward["custom_metrics"] = {"native_quality": {"score": value}}
path.write_text(json.dumps(reward), encoding="utf-8")
(trial / "agent").mkdir()
prompt, completion = (20, 3) if variant == partial_variant and case_id == "case-b" else (10, 2)
(trial / "agent/trajectory.json").write_text(
json.dumps(
{
"schema_version": "ATIF-v1.7",
"agent": {"name": "opencode", "version": "test"},
"steps": [{"step_id": 1, "source": "agent", "message": "Done"}],
"final_metrics": {"total_prompt_tokens": prompt, "total_completion_tokens": completion},
}
),
encoding="utf-8",
)
_write_variant_job_results(jobs_dir)
partial_job = jobs_dir / f"demo-opencode-{partial_variant}"
failure = {"exception_info": {"exception_type": "AgentTimeoutError", "exception_message": "Agent timed out"}}
(partial_job / "case-b_attempt001/result.json").write_text(json.dumps(failure), encoding="utf-8")
job_result = json.loads((partial_job / "result.json").read_text(encoding="utf-8"))
job_result["stats"]["n_errors"] = 1
(partial_job / "result.json").write_text(json.dumps(job_result), encoding="utf-8")

result = _collect(tmp_path, n_attempts=1, stop_on_pass=False)

agent = result["agents"]["opencode"]
arm = f"{partial_variant}_skill"
complete_arm = "without_skill" if partial_variant == "with" else "with_skill"
assert result["execution_status"] == agent["execution_status"] == "failed"
assert (result["scored_attempts"], result["expected_attempts"]) == (3, 4)
condition = agent["conditions"][arm]
assert condition["execution_status"] == "failed"
assert (condition["scored_attempts"], condition["expected_attempts"]) == (1, 2)
assert agent[arm] and set(agent[arm].values()) == {score}
assert agent[f"custom_{arm}"] == {"native_quality": score}
assert agent[f"overall_{arm}"] is None
assert agent["lift"] == agent["custom_lift"] == agent["pass_at_k"]["lift"] == {}
partial = agent["pass_at_k"][arm]
assert partial["rate"] is None and partial["rate_interval"] is None
assert partial["passed_cases"] == int(score == 1.0)
assert partial["failed_cases"] == int(score == 0.0)
assert partial["attempts_used"] == 1 and partial["max_attempts_possible"] == 2
[attempt] = partial["cases"]["case-a"]["attempts"]
assert attempt["score"] == score and attempt["passed"] is (score == 1.0)
missing = partial["cases"]["case-b"]
assert missing["attempts"] == [] and missing["best_score"] is None
assert missing["attempts_missing"] == 1 and missing["attempts_used"] == 0
summary = json.loads(
(tmp_path / "results/opencode" / f"{partial_variant}-skill/summary.json").read_text(encoding="utf-8")
)
assert summary["pass_at_k"] == partial
assert summary["scores"] == agent[arm] and summary["custom_scores"] == agent[f"custom_{arm}"]
assert not _legacy_pass_at_k_is_complete(partial, num_trials=1, require_scored_attempt=True)
assert "N/A" in pass_at_k_summary(agent["pass_at_k"])
assert verdict(result["agents"])[0] == "inconclusive"
terminal = render_result(result)
check_line = next(line for line in terminal.splitlines() if "REQUIRED CHECKS PASSED" in line)
assert check_line.strip(" │").endswith("N/A")
if partial_variant == "with":
assert "QUALITY VERDICT: FAIL" not in terminal

complete = agent["pass_at_k"][complete_arm]
assert complete["passed_cases"] == complete["attempts_used"] == 2
assert complete["failed_cases"] == 0 and complete["rate"] == 1.0
assert complete["rate_interval"]["confidence_level"] == 0.95
assert agent["conditions"][complete_arm]["execution_status"] == "succeeded"
assert set(agent[complete_arm].values()) == {1.0}
assert agent[f"custom_{complete_arm}"] == {"native_quality": 1.0}

loaded = report_data.load_agent_data(tmp_path / "results")
assert loaded["opencode"][arm] == loaded["opencode"][f"custom_{arm}"] == {}
assert loaded["opencode"][f"pass_{arm}"] == {"attempts_used": 1, "max_attempts_possible": 2}
payload = build_agent_eval_payload("demo", loaded, use_llm_judge=False)
assert payload["execution_status"] == "failed" and payload["overall_score"] is None
assert completed_agent_result(payload) is None
assert payload["agents"]["opencode"]["lift"] is None
trial_key = "trials" if partial_variant == "with" else "trials_baseline"
trials = payload["agents"]["opencode"][trial_key]
assert len(trials) == 2 and all(row["diagnostic_only"] for row in trials)
assert sum(row.get("scored") is False for row in trials) == 1
usage = payload["token_usage"]["agents"]["opencode"]["with_skill" if partial_variant == "with" else "baseline"]
assert usage["coverage"]["observed_attempts"] == usage["coverage"]["measured_attempts"] == 2
assert usage["coverage"]["unscored_attempts"] == 1
assert (
usage["totals"]["prompt_tokens"],
usage["totals"]["completion_tokens"],
usage["totals"]["total_tokens"],
) == (
30,
5,
35,
)
validation = ValidationResult(validator_name="AGENT_EVAL")
validation.metadata["agent_eval"] = payload
assessment = assess_publication([validation])
assert assessment.status != "pass" and not assessment.tier3.evidence_complete


def test_partial_rewards_stay_suppressed_when_not_every_job_error_maps_to_a_trial(tmp_path: Path) -> None:
jobs_dir = tmp_path / "jobs"
job_dir = jobs_dir / "demo-opencode-with"
Expand Down Expand Up @@ -2254,7 +2371,10 @@ def test_multistep_stop_on_pass_uses_authoritative_root_reward(tmp_path: Path) -
assert result["execution_status"] == "failed"
assert result["expected_attempts"] == 2
assert result["scored_attempts"] == 1
assert agent["pass_at_k"]["with_skill"] == {}
partial = agent["pass_at_k"]["with_skill"]
assert partial["rate"] is None
assert partial["attempts_used"] == 1
assert partial["cases"]["case-a"]["attempts_missing"] == 1


def test_duplicate_logical_attempt_ordinals_fail(tmp_path: Path) -> None:
Expand Down
16 changes: 10 additions & 6 deletions tests/test_issue55_collector_truth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2664,10 +2664,14 @@ def test_mixed_failed_condition_suppresses_published_quality_and_paired_artifact
assert agent["conditions"]["with_skill"]["execution_status"] == "failed"
assert agent["conditions"]["with_skill"]["scored_attempts"] == 1
assert agent["conditions"]["without_skill"]["execution_status"] == "succeeded"
assert agent["with_skill"] == {}
assert agent["with_skill"] == dict.fromkeys(DEFAULT_METRICS, 0.9)
assert agent["custom_with_skill"] == {}
assert agent["dimensions_with_skill"] == {}
assert agent["pass_at_k"]["with_skill"] == {}
assert agent["dimensions_with_skill"]
assert agent["overall_with_skill"] is None
partial = agent["pass_at_k"]["with_skill"]
assert partial["attempts_used"] == 1 and partial["rate"] is None
assert partial["cases"]["case-001"]["attempts"][0]["score"] == 0.9
assert partial["cases"]["case-002"]["attempts"] == []
assert agent["without_skill"] == dict.fromkeys(DEFAULT_METRICS, 0.2)
assert agent["dimensions_without_skill"]
assert agent["pass_at_k"]["without_skill"]["rate"] == 0.0
Expand All @@ -2678,10 +2682,10 @@ def test_mixed_failed_condition_suppresses_published_quality_and_paired_artifact

results_dir = tmp_path / "results" / "opencode"
persisted = json.loads((results_dir / "with-skill" / "summary.json").read_text(encoding="utf-8"))
assert persisted["scores"] == {}
assert persisted["scores"] == agent["with_skill"]
assert persisted["custom_scores"] == {}
assert persisted["dimensions"] == {}
assert persisted["pass_at_k"] == {}
assert persisted["dimensions"] == agent["dimensions_with_skill"]
assert persisted["pass_at_k"] == partial
assert not (results_dir / "lift.json").exists()
assert not (results_dir / "custom_lift.json").exists()
assert not (results_dir / "pass_at_k_lift.json").exists()
Expand Down
34 changes: 31 additions & 3 deletions tests/tier3/test_baseline_timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
settle,
unexplained_launch_errors,
)
from skillevaluator.tier3.harbor.collector import collect_harbor_results
from skillevaluator.tier3.harbor.collector import _build_comparison, collect_harbor_results

SKILL = "demo"
CASES = ["case-001", "case-002"]
Expand Down Expand Up @@ -249,19 +249,25 @@ def test_tolerated_agent_stays_scored_on_its_with_skill_arm(tmp_path: Path) -> N
assert opencode["execution_status"] == "succeeded"
assert opencode["execution_errors"] == []
assert opencode["overall_with_skill"] is not None
# The baseline stays honest: failed, with its errors, and never scored or compared.
# The baseline stays failed, with its errors and no aggregate or comparison.
baseline = opencode["conditions"]["without_skill"]
assert baseline["execution_status"] == "failed"
assert (baseline["scored_attempts"], baseline["expected_attempts"]) == (1, 2)
assert "Scored attempt coverage is 1/2" in baseline["execution_errors"]
assert opencode["without_skill"] == {}
assert opencode["without_skill"] == SCORES
assert opencode["overall_without_skill"] is None
assert opencode["lift"] == {}
assert opencode["pass_at_k"]["lift"] == {}
assert opencode["security_attribution"] == {}
assert (opencode["expected_attempts"], opencode["scored_attempts"]) == (4, 3)
assert results["comparison"]["metrics"]["accuracy"]["opencode"]["without_skill"] is None
assert results["comparison"]["metrics"]["accuracy"]["opencode"]["lift"] is None
comparison = json.loads((tmp_path / "results" / "comparison.json").read_text(encoding="utf-8"))
assert comparison["metrics"]["accuracy"]["opencode"] == {
"with_skill": SCORES["accuracy"],
"without_skill": None,
"lift": None,
}
assert opencode[RECORD_KEY] == {
"status": "partial",
"reason": "agent_execution_timeout",
Expand All @@ -288,6 +294,28 @@ def test_tolerated_agent_stays_scored_on_its_with_skill_arm(tmp_path: Path) -> N
assert results["agents"]["codex"]["lift"]


@pytest.mark.parametrize("failed_arm", ["with_skill", "without_skill"])
def test_succeeded_agent_comparison_withholds_failed_arm(failed_arm: str) -> None:
agent = {
"execution_status": "succeeded",
"conditions": {
arm: {"execution_status": "failed" if arm == failed_arm else "succeeded"}
for arm in ("with_skill", "without_skill")
},
"with_skill": {"accuracy": 0.9},
"without_skill": {"accuracy": 0.8},
"lift": {"accuracy": {"delta": 0.1}},
}

comparison = _build_comparison({"opencode": agent})["metrics"]["accuracy"]["opencode"]

assert comparison == {
"with_skill": None if failed_arm == "with_skill" else 0.9,
"without_skill": None if failed_arm == "without_skill" else 0.8,
"lift": None,
}


def test_reports_reload_the_tolerated_agent_from_disk(tmp_path: Path) -> None:
from skillevaluator.evaluation.tier3_report import build_agent_eval_payload
from skillevaluator.reporting.base import (
Expand Down
Loading