Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ All notable changes to SkillEvaluator are documented in this file.
- The Tier 3 report data and JSON report record which execution backend ran the
evaluation, as `execution_backend` (`harbor` or `nemo-gym`), next to the sandbox
`environment`.
- `report.html` shows the Tier 3 execution backend (Harbor or NeMo Gym) beside the
sandbox environment, in the agent evaluation summary and the evaluation dataset header.
- Document measured real-provider saved-catalog scale separately from 5,000-entry
in-memory qualification, as fixture-dependent examples rather than guarantees.
- `harness` results flag a project skill that has a same-named copy in a user-level
Expand Down
16 changes: 16 additions & 0 deletions src/skillevaluator/reporting/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,19 @@ def _tier3_not_applicable_reason(_context: Any, metric: object, with_skill: bool
return not_applicable_reason(str(metric), with_skill=with_skill is True)


_TIER3_BACKEND_LABELS = {"harbor": "Harbor", "nemo-gym": "NeMo Gym"}


def _tier3_backend_label(value: object) -> str | None:
"""Return the display name of a recorded execution backend id, or ``None``.

The payload is untyped metadata, so a dict, list or other non-string value
can sit where the id should be; it counts as no backend rather than being
used as a lookup key (an unhashable one would raise inside the template).
"""
return _TIER3_BACKEND_LABELS.get(value) if isinstance(value, str) else None


def _tier3_text_mapping(value: object) -> dict[str, str]:
"""Normalize public label maps without silently overwriting aliases."""
if not isinstance(value, dict):
Expand Down Expand Up @@ -2259,6 +2272,7 @@ def _create_environment() -> Environment:
environment.filters["adaptive_interval_percent"] = _adaptive_interval_percent
environment.filters["skip_reason"] = get_skip_reason
environment.filters["not_applicable_reason"] = _tier3_not_applicable_reason
environment.filters["tier3_backend_label"] = _tier3_backend_label
return environment

@staticmethod
Expand Down Expand Up @@ -3309,6 +3323,7 @@ def merge_strings(value: object, additions: list[str]) -> list[str]:
"publication_target_conflict",
"run_id",
"environment",
"execution_backend",
"evaluated_at",
"evaluator_version",
"benchmark_policy",
Expand All @@ -3325,6 +3340,7 @@ def merge_strings(value: object, additions: list[str]) -> list[str]:
"publication_target_conflict",
"run_id",
"environment",
"execution_backend",
"evaluated_at",
"evaluator_version",
"benchmark_policy",
Expand Down
4 changes: 4 additions & 0 deletions src/skillevaluator/reporting/templates/report.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,7 @@
<div class="hero-side">
{% if has_tier3 %}
{% set tier3_environment = (tier3.summary.environment if tier3.summary is defined and tier3.summary else None) or tier3.environment %}
{% set tier3_backend = (tier3.summary.execution_backend if tier3.summary is defined and tier3.summary else None) | tier3_backend_label %}
{% if tier3_is_skipped %}
<span class="verdict-chip warn">Tier 3 quality: {{ verdict_words['skipped'] }}</span>
<div class="agent-hero-detail">
Expand Down Expand Up @@ -3910,6 +3911,8 @@
<span class="t3-ds-chip">{{ content_label }}: <b>{{ tier3.skill_name or 'unknown' }}</b></span>
{% if t3_best_name %}<span class="t3-ds-chip">Best Performing Agent: <b>{{ t3_best_name }}</b></span>{% endif %}
{% set t3_env = (tier3.summary.environment if tier3.summary is defined and tier3.summary else None) or tier3.environment %}
{% set t3_backend = (tier3.summary.execution_backend if tier3.summary is defined and tier3.summary else None) | tier3_backend_label %}
{% if t3_backend %}<span class="t3-ds-chip">Backend: <b>{{ t3_backend }}</b></span>{% endif %}
{% if t3_env %}<span class="t3-ds-chip">Environment: <b>{{ t3_env }}</b></span>{% endif %}
<span class="t3-ds-chip">Schema: <b>v{{ tier3.schema_version or '2.0' }}</b></span>
</div>
Expand Down Expand Up @@ -4726,6 +4729,7 @@
{% if has_tier3 %}<div><strong>Agent evaluation</strong> {% if completed_agent and completed_agent.recovered_attempts %}<div>{{ completed_agent.recovered_attempts }} timeout attempt(s) recovered; failed history retained.</div>{% endif %}
<div class="trial-coverage">{{ hero_trials }}</div>{% for detail in presentation.coverage.details %}<div>{{ detail }}</div>{% endfor %}
<div><strong>Metrics:</strong> {{ hero_metric_count }} evaluators</div>
{% if tier3_backend %}<div><strong>Backend:</strong> {{ tier3_backend }}</div>{% endif %}
{% if tier3_environment %}<div><strong>Environment:</strong> <code>{{ tier3_environment }}</code></div>{% endif %}
{% if tier3.get('overall_lift') is not none %}<div><strong>Best-agent lift:</strong> {{ "%+.2f" | format(tier3.get('overall_lift')) }}</div>{% endif %}
</div>{% endif %}
Expand Down
128 changes: 126 additions & 2 deletions tests/reporting/test_execution_backend_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import pytest

from skillevaluator.evaluation import tier3_report
from skillevaluator.models import ValidationResult
from skillevaluator.reporting import HTMLReporter
from skillevaluator.tier3.harbor import report_data
from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS

Expand All @@ -30,13 +32,17 @@ def _agents():
}


def _payload(monkeypatch, run_dir, **kwargs):
def _result(monkeypatch, run_dir, **kwargs):
monkeypatch.setattr(report_data, "load_agent_data", lambda *_args, **_kwargs: _agents())
result = tier3_report.agent_eval_result_from_directory(
run_dir / "demo", run_dir, env_mode="docker", use_llm_judge=False, **kwargs
)
assert result is not None
return result.metadata["agent_eval"]
return result


def _payload(monkeypatch, run_dir, **kwargs):
return _result(monkeypatch, run_dir, **kwargs).metadata["agent_eval"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -69,3 +75,121 @@ def test_payload_built_without_a_run_leaves_the_backend_unset():

assert payload is not None
assert payload["summary"]["execution_backend"] is None


@pytest.mark.parametrize(
("result_json", "label"),
[({}, "Harbor"), ({"execution_backend": {"name": "nemo-gym", "sandbox": "docker"}}, "NeMo Gym")],
)
def test_html_report_shows_the_backend_beside_the_environment(monkeypatch, tmp_path, result_json, label):
(tmp_path / "result.json").write_text(json.dumps(result_json))

html = HTMLReporter(report_scope="tier3", include_timestamp=False).render_all([_result(monkeypatch, tmp_path)])

assert f"<div><strong>Backend:</strong> {label}</div>" in html
assert "<div><strong>Environment:</strong> <code>docker</code></div>" in html


def _dataset_result(backend):
"""A Tier 3 result with a dataset, so the report renders the dataset header too."""
agent = {
"execution_status": "succeeded",
"execution_errors": [],
"expected_attempts": 1,
"scored_attempts": 1,
"with_skill": {"security": 1.0, "goal_accuracy": 1.0},
"rewards": [{"entry_id": "case", "security": 1.0, "goal_accuracy": 1.0}],
}
payload = tier3_report.build_agent_eval_payload(
"demo",
{"codex": agent},
dataset=[{"id": "case", "prompt": "Add 2 and 3."}],
env_mode="docker",
execution_backend=backend,
use_llm_judge=False,
)
return tier3_report._validation_result_from_payload(payload)


@pytest.mark.parametrize(("backend", "label"), [("harbor", "Harbor"), ("nemo-gym", "NeMo Gym")])
def test_dataset_header_shows_the_backend_beside_the_environment(backend, label):
html = HTMLReporter(report_scope="tier3", include_timestamp=False).render_all([_dataset_result(backend)])

assert f'<span class="t3-ds-chip">Backend: <b>{label}</b></span>' in html
assert '<span class="t3-ds-chip">Environment: <b>docker</b></span>' in html


def test_html_report_omits_an_unrecorded_backend():
payload = tier3_report.build_agent_eval_payload("demo", _agents(), use_llm_judge=False)
result = tier3_report._validation_result_from_payload(payload)

html = HTMLReporter(report_scope="tier3", include_timestamp=False).render_all([result])

assert "Backend:" not in html


# The report payload is untyped metadata, so the backend can arrive as anything.
_NOT_A_BACKEND_NAME = [
pytest.param({"name": "nemo-gym", "sandbox": "docker"}, id="dict"),
pytest.param(["nemo-gym"], id="list"),
pytest.param(7, id="int"),
pytest.param(None, id="none"),
pytest.param("", id="empty"),
pytest.param(" ", id="whitespace"),
pytest.param("some-other-backend", id="unknown-name"),
]


@pytest.mark.parametrize("backend", _NOT_A_BACKEND_NAME)
def test_html_report_omits_a_backend_that_is_not_a_known_name(backend):
html = HTMLReporter(report_scope="tier3", include_timestamp=False).render_all([_dataset_result(backend)])

assert "Backend:" not in html
assert "<div><strong>Environment:</strong> <code>docker</code></div>" in html
assert '<span class="t3-ds-chip">Environment: <b>docker</b></span>' in html


def _untrusted_result(backend):
# A success claim with no agent evidence must be rebuilt as incomplete.
return ValidationResult(
validator_name="AGENT_EVAL",
metadata={
"agent_eval": {
"skill_name": "demo",
"execution_status": "succeeded",
"verdict": "pass",
"summary": {"environment": "docker", "execution_backend": backend},
"agents": {},
}
},
)


@pytest.mark.parametrize(("backend", "label"), [("harbor", "Harbor"), ("nemo-gym", "NeMo Gym")])
def test_html_report_keeps_a_recorded_backend_when_rebuilding_untrusted_evidence(backend, label):
html = HTMLReporter(report_scope="tier3", include_timestamp=False).render_all([_untrusted_result(backend)])

assert "Tier 3 quality: Incomplete" in html
assert f"<div><strong>Backend:</strong> {label}</div>" in html
assert "<div><strong>Environment:</strong> <code>docker</code></div>" in html


@pytest.mark.parametrize("backend", _NOT_A_BACKEND_NAME)
def test_html_report_omits_a_malformed_backend_on_an_untrusted_payload(backend):
result = _untrusted_result(backend)

html = HTMLReporter(report_scope="tier3", include_timestamp=False).render_all([result])

assert "Tier 3 quality: Incomplete" in html
assert "Backend:" not in html


def test_html_report_still_shows_a_string_backend_next_to_malformed_ones():
reporter = HTMLReporter(report_scope="tier3", include_timestamp=False)

html = reporter.render_all([_dataset_result({"name": "nemo-gym"})])
assert "Backend:" not in html

html = reporter.render_all([_dataset_result("nemo-gym")])
assert "<div><strong>Backend:</strong> NeMo Gym</div>" in html
assert '<span class="t3-ds-chip">Backend: <b>NeMo Gym</b></span>' in html
Loading