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.

feat(tier3): case-first CLI summary and case-based report findings (#255)

Narendran Raghavan0b12f055b6c1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b84dcc93..580b1522 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,11 @@ All notable changes to SkillEvaluator are documented in this file.
are formatted with units and percent change, Attempt Details groups each
case's with/without rows and marks passes that missed the goal, and Error
Recovery lists only trials with faults, retries or warnings.
+- Reusable GitHub Actions onboarding for complete Tier 1 checks, with
+ pinned runtime/workflow consumer templates, affected-skill PR selection,
+ optional hosted reports and updated PR feedback. The new guide separates
+ basic scanning from publisher setup; public image publication and generated
+ release files require a reviewed manual release before consumer use.
- `--quality-config PATH` on `validate`, `quality-check`, and `tier1` loads the
deterministic quality check's expected Markdown headings from a YAML file
instead of the built-in list. Each `expected_headers` entry sets a `heading`
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py
index 0665675d..052a103e 100644
--- a/src/skillevaluator/evaluation/tier3_report.py
+++ b/src/skillevaluator/evaluation/tier3_report.py
@@ -3042,8 +3042,8 @@ def _apply_case_findings(
use_llm: bool,
) -> None:
"""Lead the report with the case-based verdict and fixes; also saves them as what_to_fix.json for the CLI."""
+ from skillevaluator.tier3.case_summary import goal_not_met_count, save_case_findings, what_to_fix
from skillevaluator.tier3.case_summary import verdict as case_verdict
- from skillevaluator.tier3.case_summary import what_to_fix
source = engine_result
if not isinstance(source, dict):
@@ -3053,7 +3053,7 @@ def _apply_case_findings(
return
try:
fixes = what_to_fix(source, run_dir=run_dir, skill_path=skill_path, use_llm=use_llm)
- (run_dir / "what_to_fix.json").write_text(json.dumps(fixes, indent=2), encoding="utf-8")
+ save_case_findings(run_dir, fixes)
except Exception: # advisory: the report keeps its metric-based insights
logger.debug("Case findings skipped", exc_info=True)
return
@@ -3072,7 +3072,7 @@ def _apply_case_findings(
message += (
f" · biggest skill lift: {lifted} {lifts[lifted]:+.2f}." if lifted != top else " with the biggest lift."
)
- if missed := sum(f["attempts_lost"] for f in fixes if f["kind"] == "goal not met"):
+ if missed := goal_not_met_count(source, run_dir=run_dir):
message += f" {missed} passing with-skill attempt(s) did not meet the goal (goal accuracy 0.00)."
severity = "pass" if label == "skill helps" and not fixes else "fail" if label == "skill hurts" else "warn"
effect = {"severity": severity, "title": "Skill effect", "message": message, "source": "deterministic"}
diff --git a/src/skillevaluator/reporting/templates/report.html.j2 b/src/skillevaluator/reporting/templates/report.html.j2
index 35181ba9..0c0800b1 100644
--- a/src/skillevaluator/reporting/templates/report.html.j2
+++ b/src/skillevaluator/reporting/templates/report.html.j2
@@ -2447,7 +2447,7 @@
{% if t3_effect %}
{% set t3_fix_count = t3_preview_recommendations | length %}
<p class="t3-next-steps-conclusion">
- {% if t3_fix_count %}{{ t3_fix_count }} issue{{ 's' if t3_fix_count != 1 else '' }} to fix, most attempts lost first:{% else %}Nothing to fix: every with-skill attempt passed and met its goal, and the skill didn't hurt any case.{% endif %}
+ {% if t3_fix_count %}{{ t3_fix_count }} issue{{ 's' if t3_fix_count != 1 else '' }} to fix, most attempts lost first:{% else %}Nothing to fix in the available case evidence.{% endif %}
</p>
{% if t3_fix_count %}
<ol class="t3-next-steps-list">
@@ -2703,7 +2703,14 @@
Higher rates and a positive lift show better observed repeatability on these evaluated cases.
</p>
<div class="table-scroll" tabindex="0" role="region" aria-label="Pass at K summary table">
- {% macro t3_attempts_passed(branch) %}{% if branch.case_details_truncated %}{{ branch.attempts_used or 0 }} of {{ branch.max_attempts_possible or 0 }} scored{% else %}{% set ns = namespace(n=0) %}{% for case in (branch.cases or {}).values() %}{% for att in case.attempts or [] %}{% if att.passed %}{% set ns.n = ns.n + 1 %}{% endif %}{% endfor %}{% endfor %}{{ ns.n }} of {{ branch.attempts_used or 0 }}{% endif %}{% endmacro %}
+ {% macro t3_attempts_passed(branch) %}
+ {% set ns = namespace(n=0, truncated=branch.case_details_truncated or false) %}
+ {% for case in (branch.cases or {}).values() %}
+ {% if case.attempt_details_truncated %}{% set ns.truncated = true %}{% endif %}
+ {% for att in case.attempts or [] %}{% if att.passed %}{% set ns.n = ns.n + 1 %}{% endif %}{% endfor %}
+ {% endfor %}
+ {% if ns.truncated %}{{ branch.attempts_used or 0 }} scored; pass details truncated{% else %}{{ ns.n }} of {{ branch.attempts_used or 0 }}{% endif %}
+ {% endmacro %}
<table class="summary-table pass-at-k-table" style="width:100%;">
<thead><tr>
<th>Agent</th><th>Condition</th><th>Pass Rate</th><th>95% Interval</th><th>Cases Passed</th><th>Attempts Passed</th><th>Lift</th>
@@ -2852,7 +2859,7 @@
{% endif %}
{% set t3_goal_by_trial = {} %}
- {% for trial in tier3.trials or [] %}{% if trial.scores and trial.scores.goal_accuracy is defined %}{% set _ = t3_goal_by_trial.update({trial.trial_id: trial.scores.goal_accuracy}) %}{% endif %}{% endfor %}
+ {% for trial in tier3.trials or [] %}{% if trial.scores and trial.scores.goal_accuracy is defined %}{% set _ = t3_goal_by_trial.update({(trial.agent, trial.trial_id): trial.scores.goal_accuracy}) %}{% endif %}{% endfor %}
{% if t3_attempt_rows %}
<details class="t3-details" id="tier3-attempt-details" open>
<summary>Attempt Details</summary>
@@ -2925,7 +2932,7 @@
</td>
<td>
{% set goal = namespace(missed=0) %}
- {% if row.condition == 'With skill' %}{% for att in attempts %}{% if att.get('passed') and t3_goal_by_trial.get(att.get('trial')) == 0 %}{% set goal.missed = goal.missed + 1 %}{% endif %}{% endfor %}{% endif %}
+ {% if row.condition == 'With skill' %}{% for att in attempts %}{% if att.get('passed') and t3_goal_by_trial.get((row.agent, att.get('trial'))) == 0 %}{% set goal.missed = goal.missed + 1 %}{% endif %}{% endfor %}{% endif %}
{% if passed and goal.missed %}
<span class="t3-pill warning" title="{{ goal.missed }} passing attempt(s) scored goal accuracy 0.00">passed{% if first_pass_attempt is not none %} on scored attempt {{ first_pass_attempt | int }}{% endif %} · goal not met (0.00)</span>
{% elif passed and first_pass_attempt is not none %}
diff --git a/src/skillevaluator/tier3/case_summary.py b/src/skillevaluator/tier3/case_summary.py
index 8b0a0ea2..dd3ad3f2 100644
--- a/src/skillevaluator/tier3/case_summary.py
+++ b/src/skillevaluator/tier3/case_summary.py
@@ -7,10 +7,13 @@ from __future__ import annotations
import json
import logging
+import os
import re
+import tempfile
from collections import Counter
-from collections.abc import Mapping
+from collections.abc import Callable, Mapping
from difflib import SequenceMatcher
+from itertools import islice
from pathlib import Path
from typing import TYPE_CHECKING, Any
@@ -18,6 +21,11 @@ from rich.box import SIMPLE
from rich.table import Table
from rich.text import Text
+from skillevaluator.tier3.harbor.progress import redact_progress_detail, secret_values_from_environment
+from skillevaluator.utils.redaction import redact_sensitive_text
+from skillevaluator.utils.secret_redaction import Redactor
+from skillevaluator.utils.secure_fs import SecurePathError, SecureRoot
+
if TYPE_CHECKING:
from rich.console import Console
@@ -33,6 +41,7 @@ _MAX_REASON_CHARS = 220
_MAX_SKILL_MD_CHARS = 6000
_MAX_TRIAL_JSON_BYTES = 8 * 1024 * 1024
_MAX_LOG_TAIL_BYTES = 64 * 1024
+_MAX_TRIAL_PATHS_SCANNED = 4096
_STDOUT = re.compile(r"\bstdout:\s*(.+?)\s*(?:\bstderr:|$)", re.DOTALL)
_RESTATED_CHARS = 60
_ASKS_FOR_INPUT = re.compile(
@@ -56,6 +65,79 @@ _ENV_ERROR = re.compile(
_JUDGED_METRICS = ("goal_accuracy", "accuracy", "behavior_check")
+def _never_activated(agent: Mapping[str, Any]) -> bool:
+ activation = agent.get("skill_activation")
+ return isinstance(activation, Mapping) and activation.get("status") == "never_activated"
+
+
+def _details_truncated(agent: Mapping[str, Any]) -> bool:
+ branches = agent.get("pass_at_k")
+ for key, _ in _VARIANTS:
+ branch = branches.get(key) if isinstance(branches, Mapping) else None
+ if not isinstance(branch, Mapping):
+ continue
+ if branch.get("case_details_truncated"):
+ return True
+ cases = branch.get("cases")
+ if isinstance(cases, Mapping) and any(
+ isinstance(case, Mapping) and case.get("attempt_details_truncated") for case in cases.values()
+ ):
+ return True
+ return False
+
+
+def _contract_mismatch(agent: Mapping[str, Any]) -> bool:
+ with_metrics, without_metrics = agent.get("metrics_with_skill"), agent.get("metrics_without_skill")
+ if (
+ isinstance(with_metrics, list | tuple)
+ and isinstance(without_metrics, list | tuple)
+ and set(with_metrics) != set(without_metrics)
+ ):
+ return True
+ with_policy, without_policy = agent.get("score_policy_with_skill"), agent.get("score_policy_without_skill")
+ return bool(with_policy and without_policy and with_policy != without_policy)
+
+
+def _execution_unavailable(agent: Mapping[str, Any]) -> bool:
+ if agent.get("execution_status") not in {None, "succeeded", "complete"}:
+ return True
+ conditions = agent.get("conditions")
+ return isinstance(conditions, Mapping) and any(
+ isinstance(condition := conditions.get(key), Mapping)
+ and condition.get("execution_status") not in {None, "succeeded", "complete"}
+ for key, _ in _VARIANTS
+ )
+
+
+def _comparable(agent: Mapping[str, Any]) -> bool:
+ return not (
+ _never_activated(agent)
+ or _details_truncated(agent)
+ or _contract_mismatch(agent)
+ or _case_mismatch(agent)
+ or _execution_unavailable(agent)
+ ) and all(ERROR not in _marks(case) for key, _ in _VARIANTS for case in _cases(agent, key).values())
+
+
+def _case_mismatch(agent: Mapping[str, Any]) -> bool:
+ case_sets = [
+ {
+ case_id
+ for case_id, case in _cases(agent, key).items()
+ if not isinstance(case, Mapping) or not case.get("extra_case")
+ }
+ for key, _ in _VARIANTS
+ ]
+ return bool(all(case_sets) and case_sets[0] != case_sets[1])
+
+
+def _case_comparable(agent: Mapping[str, Any], with_case: Any, without_case: Any) -> bool:
+ return not (_never_activated(agent) or _contract_mismatch(agent) or _execution_unavailable(agent)) and all(
+ isinstance(case, Mapping) and not case.get("attempt_details_truncated") and ERROR not in _marks(case)
+ for case in (with_case, without_case)
+ )
+
+
# ---------------------------------------------------------------- per-case data
@@ -93,7 +175,7 @@ def _scored_trials(agent: Mapping[str, Any], key: str) -> dict[str, dict[str, An
)
cases: dict[str, dict[str, Any]] = {}
for trial in sorted(trials.iterdir()):
- reward = _load_json(trial / "reward.json")
+ reward = _load_json(trial / "reward.json", root=Path(str(output_dir)))
score = reward.get("overall") if isinstance(reward, Mapping) else None
if isinstance(score, int | float) and not isinstance(score, bool):
attempts = cases.setdefault(trial.name.split("__", 1)[0], {"attempts": []})["attempts"]
@@ -146,9 +228,25 @@ def verdict(agents: Mapping[str, Any]) -> tuple[str, str]:
"""Return (label, per-agent detail) using the raw per-attempt success rate."""
deltas: dict[str, float] = {}
not_run: dict[str, int] = {}
+ unavailable: list[str] = []
for name, agent in agents.items():
if not isinstance(agent, Mapping):
continue
+ if _never_activated(agent):
+ unavailable.append(f"{name}: skill never activated; scores are diagnostic only")
+ continue
+ if _details_truncated(agent):
+ unavailable.append(f"{name}: case/attempt details are truncated")
+ continue
+ if _contract_mismatch(agent):
+ unavailable.append(f"{name}: condition score contracts differ")
+ continue
+ if _case_mismatch(agent):
+ unavailable.append(f"{name}: conditions cover different cases")
+ continue
+ if _execution_unavailable(agent):
+ unavailable.append(f"{name}: condition execution is incomplete")
+ continue
missing = sum(_marks(case).count(ERROR) for key, _ in _VARIANTS for case in _cases(agent, key).values())
if missing:
# Rates over different subsets of attempts are not comparable.
@@ -161,9 +259,10 @@ def verdict(agents: Mapping[str, Any]) -> tuple[str, str]:
detail = " · ".join(
[f"{name} {delta:+.0f} pp" for name, delta in deltas.items()]
+ [f"{name}: {n} attempt(s) did not run" for name, n in not_run.items()]
+ + unavailable
)
if not deltas:
- return ("inconclusive", detail) if not_run else ("", "")
+ return ("inconclusive", detail) if not_run or unavailable else ("", "")
if all(delta >= _CLEAR_EFFECT_PP for delta in deltas.values()):
label = "skill helps"
elif all(delta <= -_CLEAR_EFFECT_PP for delta in deltas.values()):
@@ -204,11 +303,13 @@ def _condition_cell(case: Mapping[str, Any] | None) -> Text:
return cell
-def _effect(with_case: Mapping[str, Any] | None, without_case: Mapping[str, Any] | None) -> Text:
+def _effect(
+ with_case: Mapping[str, Any] | None, without_case: Mapping[str, Any] | None, *, comparable: bool = True
+) -> Text:
"""One word per case on what the skill changed: pass rate first, then mean score."""
with_marks, without_marks = _marks(with_case), _marks(without_case)
(wp, wn), (op, on) = _attempt_rate(with_marks), _attempt_rate(without_marks)
- if not wn or not on or ERROR in with_marks + without_marks:
+ if not comparable or not wn or not on or ERROR in with_marks + without_marks:
return Text("inconclusive", style="yellow")
if wp * on != op * wn:
return Text("helps", style="green") if wp * on > op * wn else Text("hurts", style="bold red")
@@ -223,7 +324,13 @@ def _effect(with_case: Mapping[str, Any] | None, without_case: Mapping[str, Any]
def _summary_cells(
- with_value: float | None, without_value: float | None, fmt: str, delta_fmt: str, weak: float | None = None
+ with_value: float | None,
+ without_value: float | None,
+ fmt: str,
+ delta_fmt: str,
+ weak: float | None = None,
+ *,
+ comparable: bool = True,
) -> list[Text]:
def one(value: float | None) -> Text:
if value is None:
@@ -232,7 +339,7 @@ def _summary_cells(
delta = (
Text(delta_fmt.format(with_value - without_value), style="dim")
- if with_value is not None and without_value is not None
+ if comparable and with_value is not None and without_value is not None
else Text("")
)
return [one(with_value), one(without_value), delta]
@@ -264,36 +371,47 @@ def _table(*headers: str | Text) -> Table:
return table
-def _condition_grid(agents: Mapping[str, Any], case_ids: list[str], dims: list[str], title: str) -> Table:
+def _condition_grid(
+ agents: Mapping[str, Any], case_ids: list[str], dims: list[str], title: str, safe: Callable[[object], str]
+) -> Table:
"""One agent: a row per case with both conditions side by side and the effect."""
[agent] = agents.values()
+ comparable = _comparable(agent)
table = _table(title, "with skill", "without skill", "effect")
for case_id in case_ids:
with_case, without_case = _cases(agent, "with_skill").get(case_id), _cases(agent, "without_skill").get(case_id)
table.add_row(
- case_id, _condition_cell(with_case), _condition_cell(without_case), _effect(with_case, without_case)
+ Text(safe(case_id)),
+ _condition_cell(with_case),
+ _condition_cell(without_case),
+ _effect(with_case, without_case, comparable=_case_comparable(agent, with_case, without_case)),
)
table.add_section()
rates = _agent_rates(agent)
table.add_row(
- Text("success rate", style="bold"),
- *_summary_cells(_pct(*rates["with_skill"]), _pct(*rates["without_skill"]), "{:.0f}%", "{:+.0f} pp"),
+ Text("success rate (shown)" if _details_truncated(agent) else "success rate", style="bold"),
+ *_summary_cells(
+ _pct(*rates["with_skill"]), _pct(*rates["without_skill"]), "{:.0f}%", "{:+.0f} pp", comparable=comparable
+ ),
)
table.add_row(
Text("quality score (0-1)", style="bold"),
- *_summary_cells(_quality(agent, "with_skill"), _quality(agent, "without_skill"), "{:.2f}", "{:+.2f}"),
+ *_summary_cells(
+ _quality(agent, "with_skill"), _quality(agent, "without_skill"), "{:.2f}", "{:+.2f}", comparable=comparable
+ ),
)
if dims:
table.add_section()
for dim in dims:
table.add_row(
- Text(f" {dim}", style="dim"),
+ Text(f" {safe(dim)}", style="dim"),
*_summary_cells(
_dimension_score(agent, "with_skill", dim),
_dimension_score(agent, "without_skill", dim),
"{:.2f}",
"{:+.2f}",
weak=0.6,
+ comparable=comparable,
),
)
return table
@@ -305,33 +423,45 @@ def _change(text: str, value: float | None) -> Text:
return Text(f" {text}", style="green" if value > 0 else "red" if value < 0 else "dim")
-def _agent_cell(with_case: Mapping[str, Any] | None, without_case: Mapping[str, Any] | None) -> Text:
+def _agent_cell(
+ with_case: Mapping[str, Any] | None, without_case: Mapping[str, Any] | None, *, comparable: bool = True
+) -> Text:
with_marks, without_marks = _marks(with_case), _marks(without_case)
cell = _marks_text(without_marks)
cell.append(" → ", style="dim")
cell.append_text(_marks_text(with_marks))
(wp, wn), (op, on) = _attempt_rate(with_marks), _attempt_rate(without_marks)
- if not wn or not on or ERROR in with_marks + without_marks:
+ if not comparable or not wn or not on or ERROR in with_marks + without_marks:
return cell.append(" ?", style="yellow")
delta = 100.0 * (wp / wn - op / on)
return cell.append_text(_change(f"{delta:+.0f}" if delta else "·", delta))
-def _arrow_cell(with_value: float | None, without_value: float | None, fmt: str, delta_fmt: str) -> Text:
+def _arrow_cell(
+ with_value: float | None, without_value: float | None, fmt: str, delta_fmt: str, *, comparable: bool = True
+) -> Text:
cell = Text(" → ".join(fmt.format(v) if v is not None else "-" for v in (without_value, with_value)))
- if with_value is None or without_value is None:
+ if not comparable or with_value is None or without_value is None:
return cell
return cell.append_text(_change(delta_fmt.format(with_value - without_value), with_value - without_value))
-def _agent_grid(agents: Mapping[str, Any], case_ids: list[str], dims: list[str], title: str) -> Table:
+def _agent_grid(
+ agents: Mapping[str, Any], case_ids: list[str], dims: list[str], title: str, safe: Callable[[object], str]
+) -> Table:
"""Several agents: a row per case, a column per agent, each cell without skill → with skill."""
- table = _table(title, *(Text.assemble(f"{name}\n", ("(without → with skill)", "dim")) for name in agents))
+ table = _table(title, *(Text.assemble(f"{safe(name)}\n", ("(without → with skill)", "dim")) for name in agents))
for case_id in case_ids:
table.add_row(
- case_id,
+ Text(safe(case_id)),
*(
- _agent_cell(_cases(a, "with_skill").get(case_id), _cases(a, "without_skill").get(case_id))
+ _agent_cell(
+ _cases(a, "with_skill").get(case_id),
+ _cases(a, "without_skill").get(case_id),
+ comparable=_case_comparable(
+ a, _cases(a, "with_skill").get(case_id), _cases(a, "without_skill").get(case_id)
+ ),
+ )
for a in agents.values()
),
)
@@ -340,13 +470,25 @@ def _agent_grid(agents: Mapping[str, Any], case_ids: list[str], dims: list[str],
for a in agents.values():
r = _agent_rates(a)
cell = _arrow_cell(_pct(*r["with_skill"]), _pct(*r["without_skill"]), "{:.0f}%", "{:+.0f} pp")
- complete = all(ERROR not in _marks(c) for key, _ in _VARIANTS for c in _cases(a, key).values())
+ complete = _comparable(a)
rates.append(cell if complete else Text(cell.plain.split(" ")[0]).append(" ?", style="yellow"))
- table.add_row(Text("success rate", style="bold"), *rates)
+ table.add_row(
+ Text(
+ "success rate (shown)" if any(_details_truncated(a) for a in agents.values()) else "success rate",
+ style="bold",
+ ),
+ *rates,
+ )
table.add_row(
Text("quality score (0-1)", style="bold"),
*(
- _arrow_cell(_quality(a, "with_skill"), _quality(a, "without_skill"), "{:.2f}", "{:+.2f}")
+ _arrow_cell(
+ _quality(a, "with_skill"),
+ _quality(a, "without_skill"),
+ "{:.2f}",
+ "{:+.2f}",
+ comparable=_comparable(a),
+ )
for a in agents.values()
),
)
@@ -355,13 +497,14 @@ def _agent_grid(agents: Mapping[str, Any], case_ids: list[str], dims: list[str],
table.add_row(Text("dimensions", style="dim"))
for dim in dims:
table.add_row(
- Text(f" {dim}", style="dim"),
+ Text(f" {safe(dim)}", style="dim"),
*(
_arrow_cell(
_dimension_score(a, "with_skill", dim),
_dimension_score(a, "without_skill", dim),
"{:.2f}",
"{:+.2f}",
+ comparable=_comparable(a),
)
for a in agents.values()
),
@@ -369,8 +512,20 @@ def _agent_grid(agents: Mapping[str, Any], case_ids: list[str], dims: list[str],
return table
-def render_case_summary(result: Mapping[str, Any], *, console: Console, fixes: list[dict[str, Any]] | None) -> bool:
+def render_case_summary(
+ result: Mapping[str, Any],
+ *,
+ console: Console,
+ fixes: list[dict[str, Any]] | None,
+ safe: Callable[[object], str] | None = None,
+) -> bool:
"""Print the case grid and fixes; False when the result has no per-case rows to show."""
+ if safe is None:
+ secrets = secret_values_from_environment(os.environ)
+
+ def safe(value: object) -> str:
+ return redact_progress_detail(value, secret_values=secrets)
+
agents = {k: v for k, v in (result.get("agents") or {}).items() if isinstance(v, Mapping)}
case_ids = _case_ids(agents)
if not case_ids:
@@ -379,7 +534,7 @@ def render_case_summary(result: Mapping[str, Any], *, console: Console, fixes: l
if label:
style = "bold green" if label == "skill helps" else "bold red" if label == "skill hurts" else "bold yellow"
line = Text(f"{'✔' if label == 'skill helps' else '✖' if label == 'skill hurts' else '•'} {label}", style=style)
- line.append(f" {detail}", style="dim")
+ line.append(f" {safe(detail)}", style="dim")
console.print(line)
k = next(
@@ -405,7 +560,7 @@ def render_case_summary(result: Mapping[str, Any], *, console: Console, fixes: l
),
)
grid = _agent_grid if len(agents) > 1 else _condition_grid
- table = grid(agents, case_ids, names, f"test case (k={k})" if k else "test case")
+ table = grid(agents, case_ids, names, f"test case (k={k})" if k else "test case", safe)
console.print(table)
legend = f"{PASS} pass {FAIL} fail {ERROR} did not run {SKIPPED} skipped after a pass"
if len(agents) > 1:
@@ -429,16 +584,20 @@ def render_case_summary(result: Mapping[str, Any], *, console: Console, fixes: l
)
head.append(f" [{safe(fix['kind'])}] · {safe(fix['scope'])}{lost}", style="dim")
console.print(head)
- console.print(Text(f" what happened: {fix['what']}"))
+ console.print(Text(f" what happened: {safe(fix['what'])}"))
if fix.get("action"):
- console.print(Text(f" fix: {fix['action']}", style="green"))
+ console.print(Text(f" fix: {safe(fix['action'])}", style="green"))
if fix.get("evidence"):
- console.print(Text(f" evidence: {fix['evidence']}", style="dim"))
+ console.print(Text(f" evidence: {safe(fix['evidence'])}", style="dim"))
+ elif fixes is not None and any(_details_truncated(a) for a in agents.values()):
+ console.print(
+ Text("How to improve: case/attempt details are incomplete; review the retained artifacts.", style="yellow")
+ )
elif fixes is not None:
console.print()
line = Text("How to improve: ", style="bold")
line.append(
- "nothing to fix. Every with-skill attempt passed and met its goal, and the skill didn't hurt any case.",
+ "nothing to fix in the available case evidence.",
style="green",
)
console.print(line)
@@ -446,22 +605,82 @@ def render_case_summary(result: Mapping[str, Any], *, console: Console, fixes: l
return True
-def _load_json(path: Path) -> Any:
+def _load_json(path: Path, *, root: Path | None = None) -> Any:
try:
- if not path.is_file() or path.stat().st_size > _MAX_TRIAL_JSON_BYTES:
- return None
- return json.loads(path.read_text(encoding="utf-8"))
- except (OSError, ValueError):
+ anchor = root if root is not None else path.parent
+ with SecureRoot(anchor) as reader:
+ raw, _ = reader.read_bytes(path.relative_to(anchor), _MAX_TRIAL_JSON_BYTES)
+ return json.loads(raw)
+ except (OSError, ValueError, SecurePathError):
+ return None
+
+
+def load_case_findings(run_dir: Path) -> list[dict[str, Any]] | None:
+ """Read the optional advisory cache without following artifact links."""
+ value = _load_json(run_dir / "what_to_fix.json", root=run_dir)
+ required = {"case", "scope", "kind", "what", "attempts_lost"}
+ if not isinstance(value, list) or any(not isinstance(item, dict) or not required <= item.keys() for item in value):
return None
+ return value
+
+
+def save_case_findings(run_dir: Path, fixes: list[dict[str, Any]]) -> None:
+ """Replace the advisory cache atomically, including an existing symlink itself."""
+ temporary = None
+ try:
+ with tempfile.NamedTemporaryFile(
+ mode="w", encoding="utf-8", dir=run_dir, prefix=".what_to_fix.", delete=False
+ ) as handle:
+ temporary = Path(handle.name)
+ json.dump(fixes, handle, indent=2)
+ temporary.replace(run_dir / "what_to_fix.json")
+ finally:
+ if temporary is not None:
+ temporary.unlink(missing_ok=True)
def _trial_dir(run_dir: Path, agent: str, variant_dir: str, trial: object) -> Path | None:
- if not isinstance(trial, str) or not _SAFE_TRIAL.match(trial) or not _SAFE_TRIAL.match(agent):
+ if (
+ not isinstance(trial, str)
+ or not _SAFE_TRIAL.fullmatch(trial)
+ or not _SAFE_TRIAL.fullmatch(agent)
+ or trial in {".", ".."}
+ or agent in {".", ".."}
+ ):
return None
path = run_dir / agent / variant_dir / "trials" / trial
+ if any((run_dir / Path(*path.relative_to(run_dir).parts[:i])).is_symlink() for i in range(1, 5)):
+ return None
return path if path.is_dir() else None
+def _trial_dirs(run_dir: Path, agent: str, trial: object) -> list[Path]:
+ """Resolve one logical attempt to its persisted physical or native-step artifacts."""
+ direct = _trial_dir(run_dir, agent, "with-skill", trial)
+ if direct is not None:
+ return [direct]
+ if (
+ not isinstance(trial, str)
+ or not _SAFE_TRIAL.fullmatch(trial)
+ or trial in {".", ".."}
+ or not _SAFE_TRIAL.fullmatch(agent)
+ or agent in {".", ".."}
+ ):
+ return []
+ trials = run_dir / agent / "with-skill" / "trials"
+ if not trials.is_dir():
+ return []
+ matched = []
+ for candidate in sorted(islice(trials.iterdir(), _MAX_TRIAL_PATHS_SCANNED)):
+ path = _trial_dir(run_dir, agent, "with-skill", candidate.name)
+ if path is None:
+ continue
+ reward = _load_json(path / "reward.json", root=run_dir)
+ if isinstance(reward, Mapping) and reward.get("trial_id") == trial:
+ matched.append(path)
+ return matched
+
+
def _short(text: object, limit: int = _MAX_REASON_CHARS) -> str:
value = " ".join(str(text or "").split())
return value if len(value) <= limit else value[: limit - 1].rstrip() + "…"
@@ -493,8 +712,8 @@ def _failed_reasons(reward: Mapping[str, Any]) -> list[str]:
return reasons
-def _env_errors(trial_dir: Path) -> list[str]:
- trajectory = _load_json(trial_dir / "trajectory.json")
+def _env_errors(trial_dir: Path, run_dir: Path) -> list[str]:
+ trajectory = _load_json(trial_dir / "trajectory.json", root=run_dir)
steps = trajectory.get("steps") if isinstance(trajectory, Mapping) else None
found: list[str] = []
for step in steps if isinstance(steps, list) else []:
@@ -503,8 +722,8 @@ def _env_errors(trial_dir: Path) -> list[str]:
return [_short(e, 120) for e in dict.fromkeys(found)]
-def _final_message(trial_dir: Path) -> str:
- trajectory = _load_json(trial_dir / "trajectory.json")
+def _final_message(trial_dir: Path, run_dir: Path) -> str:
+ trajectory = _load_json(trial_dir / "trajectory.json", root=run_dir)
steps = trajectory.get("steps") if isinstance(trajectory, Mapping) else None
for step in reversed(steps if isinstance(steps, list) else []):
if isinstance(step, Mapping) and step.get("source") == "agent" and str(step.get("message") or "").strip():
@@ -512,14 +731,14 @@ def _final_message(trial_dir: Path) -> str:
return ""
-def _root_error_in_logs(trial_dir: Path) -> re.Match[str] | None:
+def _root_error_in_logs(trial_dir: Path, run_dir: Path) -> re.Match[str] | None:
"""Find the agent CLI's own error line in its log (failure.json truncates long messages)."""
for log in sorted(trial_dir.glob("*.txt")):
try:
- with log.open("rb") as handle:
- handle.seek(max(0, log.stat().st_size - _MAX_LOG_TAIL_BYTES))
- text = handle.read().decode("utf-8", "replace")
- except OSError:
+ with SecureRoot(run_dir) as reader:
+ raw, _ = reader.read_bytes(log.relative_to(run_dir), _MAX_TRIAL_JSON_BYTES)
+ text = raw[-_MAX_LOG_TAIL_BYTES:].decode("utf-8", "replace")
+ except (OSError, SecurePathError):
continue
plain = "\n".join(line for line in text.splitlines() if not line.lstrip().startswith("{"))
if match := _ROOT_ERROR.search(plain):
@@ -527,14 +746,14 @@ def _root_error_in_logs(trial_dir: Path) -> re.Match[str] | None:
return None
-def _run_error(trial_dir: Path) -> str:
- failure = _load_json(trial_dir / "failure.json")
+def _run_error(trial_dir: Path, run_dir: Path) -> str:
+ failure = _load_json(trial_dir / "failure.json", root=run_dir)
error = failure.get("error") if isinstance(failure, Mapping) else None
if not isinstance(error, Mapping):
return ""
message = str(error.get("message") or "")
# Agent exit errors embed the whole command line; the root cause is the CLI's own error line.
- root = _root_error_in_logs(trial_dir) or _ROOT_ERROR.search(message)
+ root = _root_error_in_logs(trial_dir, run_dir) or _ROOT_ERROR.search(message)
detail = root.group(1) if root else message.split("\nstdout:", 1)[0]
# Setup-command failures embed the script; its stdout carries the actual cause (e.g. a curl error).
if detail.startswith("Command failed") and (stdout := _STDOUT.search(message)):
@@ -550,19 +769,22 @@ def _diagnose_agent_case(
wp, wn = _attempt_rate(with_marks)
bp, bn = _attempt_rate(without_marks)
errors = with_marks.count(ERROR)
+ not_used = _never_activated(agent)
failed_trials = []
for attempt in with_case.get("attempts", []) if isinstance(with_case, Mapping) else []:
if isinstance(attempt, Mapping) and attempt.get("passed") is not True:
- trial_dir = _trial_dir(run_dir, agent_name, "with-skill", attempt.get("trial"))
- if trial_dir is not None:
- failed_trials.append((attempt.get("score"), trial_dir))
+ failed_trials.extend(
+ (attempt.get("score"), d) for d in _trial_dirs(run_dir, agent_name, attempt.get("trial"))
+ )
errored_trials = []
with_trials = run_dir / agent_name / "with-skill" / "trials"
if errors and with_trials.is_dir() and _SAFE_TRIAL.match(agent_name):
errored_trials = [
d
for d in sorted(with_trials.iterdir())
- if d.name.split("__", 1)[0] == case_id and (d / "failure.json").is_file()
+ if d.name.split("__", 1)[0] == case_id
+ and _trial_dir(run_dir, agent_name, "with-skill", d.name) is not None
+ and (d / "failure.json").is_file()
]
lost = (wn - wp) + errors
@@ -579,18 +801,21 @@ def _diagnose_agent_case(
(r, d) for _, d in failed_trials if isinstance(r := _load_json(d / "reward.json", root=run_dir), Mapping)
]
reasons = Counter(reason for reward, _ in rewards for reason in _failed_reasons(reward))
- env = list(dict.fromkeys(e for _, d in failed_trials for e in _env_errors(d)))
+ env = list(dict.fromkeys(e for _, d in failed_trials for e in _env_errors(d, run_dir)))
activations = [_activated(reward) for reward, _ in rewards]
- finals = [_final_message(d) for _, d in failed_trials]
+ finals = [_final_message(d, run_dir) for _, d in failed_trials]
evidence_dir = (failed_trials or [(None, d) for d in errored_trials] or [(None, None)])[0][1]
- if hurts and wp < wn:
+ if not_used:
+ kind, what = "skill not used", "the skill never activated; scores are diagnostic only"
+ lost = max(lost, wn)
+ elif hurts and wp < wn:
kind, what = "skill hurts", f"passes {bp}/{bn} without the skill but {wp}/{wn} with it"
if reasons:
what += f"; {reasons.most_common(1)[0][0]}"
lost = max(lost, round(bp / bn * wn) - wp)
elif errors and not failed_trials:
- detail = next((e for d in errored_trials if (e := _run_error(d))), "")
+ detail = next((e for d in errored_trials if (e := _run_error(d, run_dir))), "")
kind, what = "run error", f"{errors} attempt(s) never produced a score" + (f": {detail}" if detail else "")
elif finals and all(_ASKS_FOR_INPUT.search(f) for f in finals):
kind = "missing input"
@@ -612,7 +837,7 @@ def _diagnose_agent_case(
"attempts_lost": lost,
"reasons": [r for r, _ in reasons.most_common(6)],
"env_errors": env[:4],
- "final_message": _final_message(failed_trials[0][1]) if failed_trials else "",
+ "final_message": _final_message(failed_trials[0][1], run_dir) if failed_trials else "",
"evidence": _evidence(run_dir, evidence_dir, run_error=kind == "run error"),
}
return [failure, goal] if goal else [failure]
@@ -626,17 +851,22 @@ def _goal_not_met(
passed = [a for a in attempts or [] if isinstance(a, Mapping) and a.get("passed") is True]
misses = []
for attempt in passed:
- trial_dir = _trial_dir(run_dir, agent_name, "with-skill", attempt.get("trial"))
- reward = _load_json(trial_dir / "reward.json") if trial_dir else None
- if isinstance(reward, Mapping) and _score(reward.get("goal_accuracy")) == 0:
- misses.append((reward, trial_dir))
+ rows = [
+ (reward, d)
+ for d in _trial_dirs(run_dir, agent_name, attempt.get("trial"))
+ if isinstance(reward := _load_json(d / "reward.json", root=run_dir), Mapping)
+ ]
+ goals = [_score(reward.get("goal_accuracy")) for reward, _ in rows]
+ # Canonical reports average complete step metrics into one logical trial.
+ if goals and all(goal is not None and 0 <= goal <= 1 for goal in goals) and sum(goals) == 0:
+ misses.append(rows[0])
if not misses:
return None
details = misses[0][0].get("details")
goal = details.get("goal_accuracy") if isinstance(details, Mapping) else None
goal = goal if isinstance(goal, Mapping) else {}
outcome = goal.get("end_state") or goal.get("reason") or ""
- finals = [_final_message(d) for _, d in misses]
+ finals = [_final_message(d, run_dir) for _, d in misses]
what = "passed on the other metrics but scored goal accuracy 0.00"
return {
"case": case_id,
@@ -652,6 +882,20 @@ def _goal_not_met(
}
+def goal_not_met_count(result: Mapping[str, Any], *, run_dir: Path) -> int:
+ """Count every observed passing attempt with goal accuracy zero, independently of the short fix list."""
+ agents = result.get("agents")
+ if not isinstance(agents, Mapping):
+ return 0
+ return sum(
+ issue["attempts_lost"]
+ for name, agent in agents.items()
+ if isinstance(agent, Mapping)
+ for case_id, case in _cases(agent, "with_skill").items()
+ if (issue := _goal_not_met(run_dir, str(name), str(case_id), case)) is not None
+ )
+
+
def _evidence(run_dir: Path, trial_dir: Path | None, *, run_error: bool) -> str:
if trial_dir is None:
return ""
@@ -730,6 +974,8 @@ def _llm_actions(
try:
from skillevaluator.tier3.eval_core.llm_judge import _extract_json, call_public_llm
+ redactor = Redactor(secret_values_from_environment(os.environ))
+ prompt = redact_sensitive_text(redactor.text(prompt))
content, error = call_public_llm(prompt, max_tokens=4096, timeout=120)
parsed = _extract_json(content) if content and not error else None
except Exception: # advisory: fall back to rule-based actions
@@ -741,7 +987,7 @@ def _llm_actions(
def _dataset_entries(run_dir: Path) -> dict[str, Mapping[str, Any]]:
- snapshot = _load_json(run_dir / "dataset_snapshot.json")
+ snapshot = _load_json(run_dir / "dataset_snapshot.json", root=run_dir)
entries = snapshot.get("dataset") if isinstance(snapshot, Mapping) else None
return {str(e["id"]): e for e in entries or [] if isinstance(e, Mapping) and e.get("id") is not None}
@@ -813,8 +1059,8 @@ def what_to_fix(
merged = dict(items[0])
merged["asks_for_input"] = all(item.get("asks_for_input") for item in items)
merged.update(
- scope=names[0] + " only"
- if len(agents) > 1 and len(names) == 1
+ scope=", ".join(names) + " only"
+ if len(agents) > 1 and len(names) < len(agents)
else "all agents"
if len(agents) > 1
else names[0],
@@ -848,13 +1094,26 @@ def what_to_fix(
by_id = dict(zip((id(i) for i in actionable), actions or [], strict=False))
for issue in issues:
issue["action"] = issue.get("action") or by_id.get(id(issue)) or _fallback_action(issue)
- return issues
+ secrets = secret_values_from_environment(os.environ)
+ return [
+ {
+ key: redact_progress_detail(value, secret_values=secrets)
+ if isinstance(value, str)
+ else [redact_progress_detail(item, secret_values=secrets) for item in value]
+ if isinstance(value, list)
+ else value
+ for key, value in issue.items()
+ }
+ for issue in issues
+ ]
def _baseline_saturated(agents: Mapping[str, Mapping[str, Any]]) -> dict[str, Any] | None:
"""Flag agents that pass every case without the skill: the eval cannot show what the skill adds."""
names = []
for name, agent in agents.items():
+ if _details_truncated(agent) or _case_mismatch(agent) or _execution_unavailable(agent):
+ continue
cases = _cases(agent, "without_skill").values()
passed, total = _agent_rates(agent)["without_skill"]
if total and passed == total and not any(ERROR in _marks(case) for case in cases):
diff --git a/src/skillevaluator/tier3/result_display.py b/src/skillevaluator/tier3/result_display.py
index 09b3d4e2..1b1fa24c 100644
--- a/src/skillevaluator/tier3/result_display.py
+++ b/src/skillevaluator/tier3/result_display.py
@@ -6,7 +6,6 @@
from __future__ import annotations
import io
-import json
import logging
import math
import os
@@ -747,18 +746,22 @@ def _render_feedback_and_suggestions(
def _case_first_summary(result: Mapping[str, Any], *, console: Console, skill_path: Path | None) -> bool:
- from skillevaluator.tier3.case_summary import render_case_summary, what_to_fix
+ from skillevaluator.tier3.case_summary import (
+ load_case_findings,
+ render_case_summary,
+ save_case_findings,
+ what_to_fix,
+ )
run_dir = result.get("run_dir") or result.get("output_dir")
fixes = None
if run_dir and Path(str(run_dir)).is_dir():
- saved = Path(str(run_dir)) / "what_to_fix.json"
try:
# The HTML report render writes this first; reuse it so CLI and report show the same fixes.
- fixes = json.loads(saved.read_text(encoding="utf-8")) if saved.is_file() else None
+ fixes = load_case_findings(Path(str(run_dir)))
if not isinstance(fixes, list):
fixes = what_to_fix(result, run_dir=Path(str(run_dir)), skill_path=skill_path)
- saved.write_text(json.dumps(fixes, indent=2), encoding="utf-8")
+ save_case_findings(Path(str(run_dir)), fixes)
except Exception: # advisory panel: never break the run summary
logging.getLogger(__name__).debug("What-to-fix skipped", exc_info=True)
return render_case_summary(result, console=console, fixes=fixes)
diff --git a/tests/reporting/test_case_findings_report.py b/tests/reporting/test_case_findings_report.py
index 1d727263..1c0a9218 100644
--- a/tests/reporting/test_case_findings_report.py
+++ b/tests/reporting/test_case_findings_report.py
@@ -59,5 +59,49 @@ def test_report_says_nothing_to_fix_when_every_case_passes_and_meets_its_goal(tm
html = render_agent_eval_html_report(tmp_path, run, use_llm_judge=False).read_text(encoding="utf-8")
assert json.loads((run / "what_to_fix.json").read_text()) == []
- assert "Nothing to fix: every with-skill attempt passed and met its goal" in html
+ assert "Nothing to fix in the available case evidence." in html
assert "goal not met (0.00)" not in html
+
+
+def test_goal_flags_keep_agent_identity_when_trial_names_repeat(tmp_path) -> None:
+ import re
+ import shutil
+
+ run = _run(tmp_path, goal_accuracy=0.0)
+ shutil.copytree(run / "opencode", run / "z-other")
+ reward_path = run / "z-other" / "with-skill" / "trials" / "case__1" / "reward.json"
+ reward = json.loads(reward_path.read_text())
+ reward["goal_accuracy"] = 1.0
+ reward_path.write_text(json.dumps(reward))
+ source = json.loads((run / "result.json").read_text())
+ source["agents"]["z-other"] = source["agents"]["opencode"]
+ (run / "result.json").write_text(json.dumps(source))
+
+ html = render_agent_eval_html_report(tmp_path, run, use_llm_judge=False).read_text(encoding="utf-8")
+ attempts = html.split('id="t3-attempts-table"', 1)[1].split("</table>", 1)[0]
+ rows = re.findall(r"<tr>(.*?)</tr>", attempts, flags=re.DOTALL)
+ missed = [row for row in rows if "goal not met (0.00)" in row]
+ assert len(missed) == 1
+ assert "opencode" in missed[0] and "With skill" in missed[0]
+
+
+def test_goal_count_includes_passes_in_a_case_with_other_failed_attempts(tmp_path) -> None:
+ run = _run(tmp_path, goal_accuracy=0.0)
+ source = json.loads((run / "result.json").read_text())
+ case = source["agents"]["opencode"]["pass_at_k"]["with_skill"]["cases"]["case"]
+ case["attempts"].append({"attempt": 2, "trial": "case__2", "score": 0.2, "passed": False})
+ (run / "result.json").write_text(json.dumps(source))
+ html = render_agent_eval_html_report(tmp_path, run, use_llm_judge=False).read_text(encoding="utf-8")
+ assert "1 passing with-skill attempt(s) did not meet the goal" in html
+
+
+def test_truncated_attempt_details_do_not_invent_an_attempts_passed_count(tmp_path) -> None:
+ run = _run(tmp_path, goal_accuracy=1.0)
+ for arm in ("with-skill", "without-skill"):
+ summary_path = run / "opencode" / arm / "summary.json"
+ summary = json.loads(summary_path.read_text())
+ summary["pass_at_k"]["attempts_used"] = 4
+ summary["pass_at_k"]["cases"]["case"]["attempt_details_truncated"] = True
+ summary_path.write_text(json.dumps(summary))
+ html = render_agent_eval_html_report(tmp_path, run, use_llm_judge=False).read_text(encoding="utf-8")
+ assert "4 scored; pass details truncated" in html
diff --git a/tests/test_tier3_case_summary.py b/tests/test_tier3_case_summary.py
index 4b7fdc75..f95b9d06 100644
--- a/tests/test_tier3_case_summary.py
+++ b/tests/test_tier3_case_summary.py
@@ -67,10 +67,10 @@ def test_grid_shows_one_row_per_case_with_attempt_marks_per_agent() -> None:
assert "✗✗ → ✓✓ +100" in rows["c1"] and "- → ✓✗ ?" in rows["c1"]
assert "- → ✗✓ ?" in rows["c2"] and "✓✓ → ✗⊘ ?" in rows["c2"]
rates = next(line for line in output.splitlines() if line.startswith("success rate"))
- assert "0% → 75% +75 pp" in rates and rates.rstrip().endswith("?")
+ assert "0% → 75% ?" in rates and rates.rstrip().endswith("?")
assert output.index("effectiveness") < output.index("security")
assert output.count("(without → with skill)") == 2 and "change in pass rate" in output
- assert "skill helps claude-code +75 pp · codex: 1 attempt(s) did not run" in output
+ assert "inconclusive" in output and "conditions cover different cases" in output
def test_verdict_thresholds() -> None:
@@ -297,7 +297,7 @@ def test_how_to_improve_says_nothing_to_fix_only_when_the_list_was_computed_and_
for fixes, expected in (([], True), (None, False)):
console = Console(record=True, width=120)
render_case_summary(result, console=console, fixes=fixes)
- assert ("How to improve: nothing to fix." in console.export_text()) is expected
+ assert ("How to improve: nothing to fix in the available case evidence." in console.export_text()) is expected
def test_passing_attempts_that_miss_the_goal_are_reported_with_a_prompt_fix(tmp_path: Path) -> None: