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(reporting): align routing summaries and unavailable-score conclusions (#433)

Narendran Raghavan6a5e7c755f6e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index efb80067..bb00c189 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -160,6 +160,12 @@ All notable changes to SkillEvaluator are documented in this file.
### Fixed
+- Tier 3 dataset summaries honor explicit `should_trigger` routing labels before
+ legacy `expected_skill` values. Report insights distinguish unavailable trial
+ scores from scored attempts that miss the pass threshold. Dataset snapshots
+ use schema 1.1; valid schema 1.0 snapshots retain their original datasets and
+ integrity checks, with corrected summaries projected without rewriting files.
+
- Tier 2 includes qualifying shell comment blocks at end of file in context
deduplication. Previously those blocks disappeared unless a blank line or
code followed them, which could hide repeated guidance across shell files.
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py
index 68b5301d..29a5180e 100644
--- a/src/skillevaluator/evaluation/tier3_report.py
+++ b/src/skillevaluator/evaluation/tier3_report.py
@@ -3639,11 +3639,15 @@ def _build_conclusions(
)
failing_trials: list[str] = []
+ unscored_trials: list[str] = []
for agent_name, agent in agents.items():
for trial in agent.get("trials") or []:
overall = _finite_float(trial.get("overall"))
- if overall is None or overall < pass_threshold:
- failing_trials.append(f"{agent_name}/{trial.get('entry_id') or trial.get('trial_id')}")
+ trial_label = f"{agent_name}/{trial.get('entry_id') or trial.get('trial_id')}"
+ if overall is None:
+ unscored_trials.append(trial_label)
+ elif overall < pass_threshold:
+ failing_trials.append(trial_label)
if failing_trials:
conclusions.append(
{
@@ -3655,6 +3659,17 @@ def _build_conclusions(
),
}
)
+ if unscored_trials:
+ conclusions.append(
+ {
+ "severity": "warn",
+ "title": "Unscored trials",
+ "message": (
+ f"{len(unscored_trials)} trial(s) have unavailable overall scores; examples: "
+ + ", ".join(unscored_trials[:5])
+ ),
+ }
+ )
return conclusions
diff --git a/src/skillevaluator/tier3/harbor/report_data.py b/src/skillevaluator/tier3/harbor/report_data.py
index 2ff6948e..747f793a 100644
--- a/src/skillevaluator/tier3/harbor/report_data.py
+++ b/src/skillevaluator/tier3/harbor/report_data.py
@@ -21,6 +21,7 @@ from itertools import islice
from pathlib import Path
from typing import Any
+from skillevaluator.tier3.eval_core.checks import resolve_should_trigger
from skillevaluator.tier3.harbor.metrics import (
CUSTOM_ONLY_METRIC_SET,
DEFAULT_METRIC_SET,
@@ -84,7 +85,7 @@ __all__ = (
)
DATASET_SNAPSHOT_DIGEST_ALGORITHM = "skill-evaluator-dataset-snapshot/1"
-DATASET_SNAPSHOT_SCHEMA_VERSION = "1.0"
+DATASET_SNAPSHOT_SCHEMA_VERSION = "1.1"
class DatasetSnapshotContractError(ValueError):
@@ -124,8 +125,9 @@ def deduplicate_dataset_entries(entries: list[dict[str, Any]]) -> list[dict[str,
def summarize_dataset_entries(entries: list[dict[str, Any]]) -> dict[str, Any]:
"""Summarize unique task identities and their activation intent."""
unique = deduplicate_dataset_entries(entries)
- positive = sum(1 for case in unique if case.get("expected_skill") is not None)
- negative = sum(1 for case in unique if "expected_skill" in case and case.get("expected_skill") is None)
+ routing_intents = [resolve_should_trigger(case) for case in unique]
+ positive = routing_intents.count(True)
+ negative = routing_intents.count(False)
return {
"total_tasks": len(unique),
"positive_tasks": positive,
@@ -197,11 +199,14 @@ def dataset_snapshot_manifest(snapshot: dict[str, Any]) -> dict[str, Any]:
def load_dataset_snapshot(run_dir: Path) -> dict[str, Any] | None:
- """Load a validated run-owned dataset snapshot, if one was persisted."""
+ """Validate the recorded schema, then normalize in memory without rewriting it."""
path = run_dir / "dataset_snapshot.json"
diagnostics: list[dict[str, Any]] = []
snapshot = _load_bounded_json(path, diagnostics, artifact="dataset_snapshot")
- if not isinstance(snapshot, dict) or snapshot.get("schema_version") != DATASET_SNAPSHOT_SCHEMA_VERSION:
+ if not isinstance(snapshot, dict):
+ return None
+ schema_version = snapshot.get("schema_version")
+ if not isinstance(schema_version, str) or schema_version not in {"1.0", DATASET_SNAPSHOT_SCHEMA_VERSION}:
return None
try:
encode_dataset_snapshot(snapshot)
@@ -218,13 +223,27 @@ def load_dataset_snapshot(run_dir: Path) -> dict[str, Any] | None:
[entry for entry in dataset if isinstance(entry, dict)],
evaluator_version=version,
)
- if dataset != expected["dataset"] or summary != expected["dataset_summary"]:
+ expected_summary = expected["dataset_summary"]
+ if snapshot["schema_version"] == "1.0":
+ # Schema 1.0 counted only legacy expected_skill labels. Validate that
+ # exact historical rule before projecting the corrected 1.1 summary.
+ positive = sum(1 for case in expected["dataset"] if case.get("expected_skill") is not None)
+ negative = sum(
+ 1 for case in expected["dataset"] if "expected_skill" in case and case.get("expected_skill") is None
+ )
+ expected_summary = {
+ **expected_summary,
+ "positive_tasks": positive,
+ "negative_tasks": negative,
+ "unclassified_tasks": len(expected["dataset"]) - positive - negative,
+ }
+ if dataset != expected["dataset"] or summary != expected_summary:
return None
if snapshot.get("dataset_digest_algorithm") != DATASET_SNAPSHOT_DIGEST_ALGORITHM:
return None
if snapshot.get("dataset_digest") != expected["dataset_digest"]:
return None
- return snapshot
+ return {**snapshot, **expected}
class _JSONLimitError(ValueError):
diff --git a/tests/evaluation/test_tier3_benchmark_contract.py b/tests/evaluation/test_tier3_benchmark_contract.py
index c8aa1029..26a7aa10 100644
--- a/tests/evaluation/test_tier3_benchmark_contract.py
+++ b/tests/evaluation/test_tier3_benchmark_contract.py
@@ -8,6 +8,8 @@ from __future__ import annotations
import json
from pathlib import Path
+import pytest
+
from skillevaluator import __version__
from skillevaluator.constants import (
DEFAULT_SCORE_POLICY,
@@ -189,6 +191,39 @@ def test_dataset_truth_counts_unique_task_identities() -> None:
assert len(payload["dataset"]) == 2
+ ("routing_fields", "positive", "negative", "unclassified"),
+ [
+ pytest.param({"expected_skill": "demo"}, 1, 0, 0, id="legacy-positive"),
+ pytest.param({"expected_skill": "demo", "should_trigger": False}, 0, 1, 0, id="explicit-negative"),
+ pytest.param({"expected_skill": None, "should_trigger": True}, 1, 0, 0, id="explicit-positive"),
+ pytest.param({"should_trigger": True}, 1, 0, 0, id="positive-label-only"),
+ pytest.param({"should_trigger": False}, 0, 1, 0, id="negative-label-only"),
+ pytest.param({"expected_skill": None}, 0, 1, 0, id="legacy-negative"),
+ pytest.param({}, 0, 0, 1, id="unlabeled"),
+ ],
+)
+def test_dataset_truth_respects_explicit_routing_intent(
+ routing_fields: dict, positive: int, negative: int, unclassified: int
+) -> None:
+ dataset = [{"id": "case-1", **routing_fields}]
+ expected_summary = {
+ "total_tasks": 1,
+ "positive_tasks": positive,
+ "negative_tasks": negative,
+ "unclassified_tasks": unclassified,
+ "source": "dataset",
+ }
+
+ snapshot = build_dataset_snapshot(dataset, evaluator_version=__version__)
+ payload = build_agent_eval_payload("demo", _agents(), dataset=dataset, use_llm_judge=False)
+
+ assert snapshot["dataset_summary"] == expected_summary
+ assert payload is not None
+ assert payload["dataset_summary"] == expected_summary
+ assert payload["summary"]["dataset_summary"] == expected_summary
+
+
def test_dataset_snapshot_rejects_duplicate_or_tampered_dataset(tmp_path: Path) -> None:
entry = {"id": "case-1", "prompt": "Run the skill", "expected_skill": "demo"}
snapshot = build_dataset_snapshot([entry], evaluator_version="0.8.2")
@@ -198,6 +233,82 @@ def test_dataset_snapshot_rejects_duplicate_or_tampered_dataset(tmp_path: Path)
assert load_dataset_snapshot(tmp_path) is None
+def test_dataset_snapshot_migrates_valid_legacy_routing_summary_in_memory(tmp_path: Path) -> None:
+ # This fixture was emitted by the base revision's schema 1.0 builder.
+ original = (Path(__file__).parents[1] / "fixtures" / "legacy-routing-dataset-snapshot-1.0.json").read_bytes()
+ persisted = tmp_path / "dataset_snapshot.json"
+ persisted.write_bytes(original)
+ historical = json.loads(original)
+
+ loaded = load_dataset_snapshot(tmp_path)
+
+ assert loaded is not None
+ assert loaded["schema_version"] == "1.1"
+ assert loaded["dataset"] == historical["dataset"]
+ assert loaded["dataset_digest"] == historical["dataset_digest"]
+ assert loaded["evaluator_version"] == "0.8.0"
+ assert loaded["dataset_summary"] == {
+ "total_tasks": 3,
+ "positive_tasks": 1,
+ "negative_tasks": 2,
+ "unclassified_tasks": 0,
+ "source": "dataset",
+ }
+ assert persisted.read_bytes() == original
+
+
[email protected]("schema_version", ["1.0", "1.1"])
[email protected]("tamper", ["summary-rule", "dataset", "digest", "algorithm"])
+def test_dataset_snapshot_rejects_tampered_versioned_truth(
+ tmp_path: Path, schema_version: str, tamper: str
+) -> None:
+ snapshot = json.loads(
+ (Path(__file__).parents[1] / "fixtures" / "legacy-routing-dataset-snapshot-1.0.json").read_text(encoding="utf-8")
+ )
+ legacy_summary = dict(snapshot["dataset_summary"])
+ current_summary = {
+ "total_tasks": 3,
+ "positive_tasks": 1,
+ "negative_tasks": 2,
+ "unclassified_tasks": 0,
+ "source": "dataset",
+ }
+ snapshot["schema_version"] = schema_version
+ if schema_version == "1.1":
+ snapshot["dataset_summary"] = current_summary
+ if tamper == "summary-rule":
+ snapshot["dataset_summary"] = current_summary if schema_version == "1.0" else legacy_summary
+ elif tamper == "dataset":
+ snapshot["dataset"][0]["prompt"] = "Changed after evaluation"
+ elif tamper == "digest":
+ snapshot["dataset_digest"] = "sha256:" + "0" * 64
+ else:
+ snapshot["dataset_digest_algorithm"] = "unknown-digest"
+ (tmp_path / "dataset_snapshot.json").write_text(json.dumps(snapshot), encoding="utf-8")
+
+ assert load_dataset_snapshot(tmp_path) is None
+
+
+def test_new_dataset_snapshot_versions_corrected_routing_summary() -> None:
+ snapshot = build_dataset_snapshot(
+ [{"id": "negative", "expected_skill": "demo", "should_trigger": False}],
+ evaluator_version=__version__,
+ )
+
+ assert snapshot["schema_version"] == "1.1"
+ assert snapshot["dataset_summary"]["positive_tasks"] == 0
+ assert snapshot["dataset_summary"]["negative_tasks"] == 1
+
+
[email protected]("schema_version", [[], {}, "9.9"], ids=["array", "object", "unknown"])
+def test_dataset_snapshot_rejects_invalid_schema(tmp_path: Path, schema_version: object) -> None:
+ snapshot = build_dataset_snapshot([{"id": "case-1", "expected_skill": "demo"}], evaluator_version=__version__)
+ snapshot["schema_version"] = schema_version
+ (tmp_path / "dataset_snapshot.json").write_text(json.dumps(snapshot), encoding="utf-8")
+
+ assert load_dataset_snapshot(tmp_path) is None
+
+
def test_overall_verdict_requires_every_dimension_even_with_passing_lift() -> None:
agents = _agents()
agents["codex"]["with_skill"]["goal_accuracy"] = 0.3
diff --git a/tests/fixtures/legacy-routing-dataset-snapshot-1.0.json b/tests/fixtures/legacy-routing-dataset-snapshot-1.0.json
new file mode 100644
index 00000000..2f287d8a
--- /dev/null
+++ b/tests/fixtures/legacy-routing-dataset-snapshot-1.0.json
@@ -0,0 +1,28 @@
+{
+ "schema_version": "1.0",
+ "evaluator_version": "0.8.0",
+ "dataset": [
+ {
+ "id": "negative-override",
+ "expected_skill": "demo",
+ "should_trigger": false
+ },
+ {
+ "id": "positive-label",
+ "should_trigger": true
+ },
+ {
+ "id": "negative-label",
+ "should_trigger": false
+ }
+ ],
+ "dataset_summary": {
+ "total_tasks": 3,
+ "positive_tasks": 1,
+ "negative_tasks": 0,
+ "unclassified_tasks": 2,
+ "source": "dataset"
+ },
+ "dataset_digest": "sha256:6961169bde298965d72c82e65a8bbe48fac000fb1a1e08db3779898a765dab5c",
+ "dataset_digest_algorithm": "skill-evaluator-dataset-snapshot/1"
+}
diff --git a/tests/reporting/test_unified_tier3_report.py b/tests/reporting/test_unified_tier3_report.py
index b0add7a5..484ce5c0 100644
--- a/tests/reporting/test_unified_tier3_report.py
+++ b/tests/reporting/test_unified_tier3_report.py
@@ -499,6 +499,60 @@ def test_conclusions_without_case_grounding_do_not_receive_positional_evidence()
assert "evidence" not in conclusions[0]
[email protected]("has_threshold_miss", [False, True])
+def test_conclusions_separate_unavailable_trials_from_threshold_misses(has_threshold_miss: bool) -> None:
+ rewards = [
+ {"entry_id": "unscored", "metric_set": "skill-evaluator-default-v2", "overall": None},
+ {
+ "entry_id": "at-threshold",
+ "metric_set": "skill-evaluator-default-v2",
+ **dict.fromkeys(DEFAULT_METRICS, 0.5),
+ },
+ ]
+ if has_threshold_miss:
+ rewards.append(
+ {
+ "entry_id": "zero-score",
+ "metric_set": "skill-evaluator-default-v2",
+ **dict.fromkeys(DEFAULT_METRICS, 0.0),
+ }
+ )
+ payload = build_agent_eval_payload(
+ "demo",
+ {
+ "codex": {
+ "execution_status": "succeeded",
+ "expected_attempts": len(rewards),
+ "scored_attempts": len(rewards) - 1,
+ "with_skill": dict.fromkeys(DEFAULT_METRICS, 0.8),
+ "rewards": rewards,
+ "rewards_complete": False,
+ }
+ },
+ attempt_policy={"pass_threshold": 0.5},
+ use_llm_judge=False,
+ )
+
+ assert payload is not None
+ assert payload["overall_score"] == 0.8
+ assert payload["agents"]["codex"]["trials"][0]["overall"] is None
+ conclusions = {item["title"]: item["message"] for item in payload["conclusions"]}
+ assert "Unscored trials" in conclusions
+ assert conclusions["Unscored trials"] == (
+ "1 trial(s) have unavailable overall scores; examples: codex/unscored"
+ )
+ html = _render_agent_payload(payload)
+ assert "1 trial(s) have unavailable overall scores; examples: codex/unscored" in html
+ if has_threshold_miss:
+ assert conclusions["Cases needing review"] == (
+ "1 trial(s) missed the pass threshold; examples: codex/zero-score"
+ )
+ assert "1 trial(s) missed the pass threshold; examples: codex/zero-score" in html
+ else:
+ assert "Cases needing review" not in conclusions
+ assert "missed the pass threshold" not in html
+
+
def test_package_loader_reads_template_resources_as_utf8(monkeypatch: pytest.MonkeyPatch) -> None:
class TemplateResource:
def joinpath(self, _path: str) -> TemplateResource:
@@ -2591,6 +2645,79 @@ def test_rerender_uses_run_owned_dataset_and_evaluator_version(tmp_path: Path) -
assert payload["evaluator_version"] == "evaluated-version-1.2.3"
[email protected]("manifest_source", ["absent", "disk", "engine"])
+def test_rerender_preserves_legacy_snapshot_dataset_with_corrected_summary(
+ tmp_path: Path, manifest_source: str
+) -> None:
+ skill = tmp_path / "demo"
+ skill.mkdir()
+ run_dir = tmp_path / "results" / "historical-run"
+ _write_summary(run_dir)
+ original = (Path(__file__).parents[1] / "fixtures" / "legacy-routing-dataset-snapshot-1.0.json").read_bytes()
+ snapshot_path = run_dir / "dataset_snapshot.json"
+ snapshot_path.write_bytes(original)
+ historical = json.loads(original)
+ manifest = {key: value for key, value in historical.items() if key != "dataset"}
+ engine_result = {"dataset_snapshot": manifest} if manifest_source == "engine" else None
+ if manifest_source == "disk":
+ (run_dir / "result.json").write_text(json.dumps({"dataset_snapshot": manifest}), encoding="utf-8")
+
+ tier3 = agent_eval_result_from_directory(skill, run_dir, engine_result=engine_result, use_llm_judge=False)
+
+ assert tier3 is not None
+ payload = tier3.metadata["agent_eval"]
+ assert payload["dataset"] == historical["dataset"]
+ expected_summary = {
+ "total_tasks": 3,
+ "positive_tasks": 1,
+ "negative_tasks": 2,
+ "unclassified_tasks": 0,
+ "source": "dataset",
+ }
+ assert payload["dataset_summary"] == expected_summary
+ assert payload["summary"]["dataset_summary"] == expected_summary
+ assert payload["dataset_digest"] == historical["dataset_digest"]
+ assert payload["evaluator_version"] == "0.8.0"
+ embedded = _embedded_tier3_payload(_render_agent_payload(payload))
+ for rendered, original_case in zip(embedded["dataset"], historical["dataset"], strict=True):
+ assert original_case.items() <= rendered.items()
+ assert embedded["dataset_summary"] == expected_summary
+ assert snapshot_path.read_bytes() == original
+ if manifest_source == "disk":
+ assert json.loads((run_dir / "result.json").read_text(encoding="utf-8"))["dataset_snapshot"] == manifest
+
+
[email protected]("schema_version", [[], {}, "9.9"], ids=["array", "object", "unknown"])
+def test_rerender_falls_back_from_invalid_snapshot_schema(tmp_path: Path, schema_version: object) -> None:
+ skill = tmp_path / "demo"
+ skill.mkdir()
+ run_dir = tmp_path / "results" / "historical-run"
+ _write_summary(run_dir)
+ snapshot = build_dataset_snapshot([{"id": "invalid-snapshot-case"}], evaluator_version="0.8.0")
+ snapshot["schema_version"] = schema_version
+ snapshot_path = run_dir / "dataset_snapshot.json"
+ original = json.dumps(snapshot).encode("utf-8")
+ snapshot_path.write_bytes(original)
+ fallback = {"id": "fallback-case", "expected_skill": "demo", "should_trigger": False}
+ staged = run_dir / "_harbor-tasks" / "fallback-case" / "tests"
+ staged.mkdir(parents=True)
+ (staged / "entry.json").write_text(json.dumps(fallback), encoding="utf-8")
+
+ tier3 = agent_eval_result_from_directory(skill, run_dir, use_llm_judge=False)
+
+ assert tier3 is not None
+ payload = tier3.metadata["agent_eval"]
+ assert payload["dataset"] == [fallback]
+ assert payload["dataset_summary"] == {
+ "total_tasks": 1,
+ "positive_tasks": 0,
+ "negative_tasks": 1,
+ "unclassified_tasks": 0,
+ "source": "dataset",
+ }
+ assert snapshot_path.read_bytes() == original
+
+
def test_rerender_uses_persisted_publication_identity_after_live_source_changes(tmp_path: Path) -> None:
from skillevaluator.publication_identity import publication_target_from_path