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): keep benchmark uplift consistent with displayed scores (#269)

Narendran Raghavan8532d57b7067
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d6e4928..ea92671c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -379,6 +379,18 @@ All notable changes to SkillEvaluator are documented in this file.
Static reports are accepted when a provider is available but LLM analysis
was neither requested nor applied; availability alone is not execution.
+- `BENCHMARK.md` score transitions round half-up to one decimal place, keep
+ extra decimals for a score near a dimension verdict threshold so it is never
+ shown in a higher band (`49.95%`, not `50.0%`), and derive uplift from the
+ displayed scores. Whole-percent rounding of each value separately had
+ published contradictions such as `58% → 95% (+36 points)` and
+ `50% → 50% (+0 points)`. Scores outside 0–1 and invalid recorded baselines
+ are shown as `Not available` instead of being published. The public
+ benchmark gate (`scripts/ci/check_public_benchmarks.py`) now rejects a
+ Results at a Glance cell whose uplift does not equal the displayed difference
+ or whose scores are outside 0–100%; consistent whole-number cards from
+ earlier releases still pass.
+
- PII email scans recognize all RFC 2606 reserved domains, including their
subdomains, mixed-case forms, trailing dots, and prose ellipses. A local-part
boundary prevents quadratic rescanning of long excluded addresses. Ordinary
diff --git a/docs/benchmark-rollout.mdx b/docs/benchmark-rollout.mdx
index ccdc29c0..5304c67e 100644
--- a/docs/benchmark-rollout.mdx
+++ b/docs/benchmark-rollout.mdx
@@ -116,7 +116,9 @@ diff -u \
Expected presentation changes include:
- the verdict and recommendation moving to the top;
-- `Baseline → Skill Uplift` cells with uplift labeled in percentage points;
+- `Baseline → Skill Uplift` cells with uplift labeled in percentage points,
+ scores shown to one decimal place (more near a verdict threshold), and uplift
+ computed from the displayed scores;
- removal of the `Num` column;
- explicit `NOT RUN`, `SKIPPED`, and `INCOMPLETE` tier states;
- collapsible methodology and non-blocking observations;
@@ -172,7 +174,12 @@ The linter rejects configured known leak patterns such as retired product
identities, any validation-profile metadata line, common absolute home paths,
ambiguous legacy uplift cells, the old `Num` column, missing metadata/decision
sections, and a publication `PASS` without completed required Tier 1, Tier 2,
-or Tier 3 evidence.
+or Tier 3 evidence. It also rejects a Results at a Glance cell whose uplift is
+not exactly the displayed skill score minus the displayed baseline, or whose
+scores fall outside 0–100%. Whole-number cells from earlier releases still
+pass when their arithmetic holds; a card whose whole-number rounding produced a
+contradiction such as `58% → 95% (+36 points)`, or a signed zero such as
+`50% → 50% (+0 points)`, fails until it is regenerated.
Structural H1/H2 headings must be undecorated, root-level Markdown; raw HTML,
formatted, quoted, and list-nested headings are rejected as ambiguous. Decision
text is checked using its rendered form, including line breaks and image alt
diff --git a/docs/reports.mdx b/docs/reports.mdx
index 4cf054ad..f3b24533 100644
--- a/docs/reports.mdx
+++ b/docs/reports.mdx
@@ -130,6 +130,13 @@ dataset provenance, agent/model details, and a dimension-by-dimension
`Baseline → Skill Uplift` table when Tier 3 ran. Public cards omit validation
profile names and absolute host paths.
+Table scores are rounded half-up to one decimal place. A score near a dimension
+verdict threshold keeps as many extra decimals as it needs to stay in its band,
+so `0.4995` is shown as `49.95%`, not as a passing `50.0%`. Uplift is the
+difference of the two displayed scores, so a cell such as
+`58.4% → 94.8% (+36.4 points)` always adds up. A score outside 0–1 is shown as
+`Not available`.
+
The card carries one overall verdict — `PASS`, `NEUTRAL`, `FAIL`, or
`INCOMPLETE`. It fails closed: if a required scanner produced no trustworthy
evidence, the verdict is `INCOMPLETE` and the card explicitly says not to use
diff --git a/scripts/ci/check_public_benchmarks.py b/scripts/ci/check_public_benchmarks.py
index 2c7e733d..2d05e1bf 100644
--- a/scripts/ci/check_public_benchmarks.py
+++ b/scripts/ci/check_public_benchmarks.py
@@ -17,6 +17,7 @@ import sys
import unicodedata
from dataclasses import dataclass
from datetime import UTC, date, datetime, timedelta
+from decimal import Context, Decimal, localcontext
from functools import lru_cache
from html import unescape
from html.parser import HTMLParser
@@ -96,6 +97,15 @@ LINE_RULES = (
),
)
+# A `baseline% → score% (uplift points)` transition in a Results at a Glance
+# cell. The uplift must equal the exact difference of the two displayed scores,
+# whatever their precision, so consistent whole-number cells from earlier
+# releases still pass.
+_SCORE_TRANSITION = re.compile(
+ r"(?<![\d.])(?P<baseline>-?\d+(?:\.\d+)?)%\s*(?:→|->)\s*(?P<score>-?\d+(?:\.\d+)?)%\s*"
+ r"\((?P<delta>[+±-]\d+(?:\.\d+)?) points?\)"
+)
+
_AGENT_MODEL_STATE = re.compile(
r"^(?P<agent>[^,]+) \((?P<model>`[^`]+`|model not recorded)\)$",
flags=re.IGNORECASE,
@@ -769,11 +779,55 @@ def scan_file(path: Path, *, require_source_provenance: bool = False) -> list[Of
_check_required_headings(path, text, offenders)
_check_metadata_semantics(path, text, offenders, require_source_provenance=require_source_provenance)
_check_verdict_tier_consistency(path, text, offenders, require_source_provenance=require_source_provenance)
+ _check_score_transitions(path, text, offenders)
_check_untrusted_structural_headings(path, text, offenders)
_check_html_rendering_safety(path, text, offenders)
return offenders
+def _check_score_transitions(path: Path, text: str, offenders: list[Offender]) -> None:
+ """Check the score transitions in Results at a Glance table body cells.
+
+ The reporter writes only its own numbers into these cells, so untrusted
+ finding or label text elsewhere on the card cannot trip this check.
+ """
+ for _start_line, section_tokens in _section_occurrences(text, "Results at a Glance"):
+ in_body_cell = False
+ for token in section_tokens:
+ if token.type in {"td_open", "td_close"}:
+ in_body_cell = token.type == "td_open"
+ continue
+ if not in_body_cell or token.type != "inline" or token.map is None:
+ continue
+ cell = _semantic_text(" ".join(_inline_visible_lines(token, include_code=True)))
+ problems = {
+ problem
+ for match in _SCORE_TRANSITION.finditer(cell)
+ if (problem := _score_transition_problem(match)) is not None
+ }
+ offenders.extend(Offender(path, token.map[0] + 1, problem) for problem in sorted(problems))
+
+
+def _score_transition_problem(match: re.Match[str]) -> str | None:
+ """Return why a score transition is malformed or inconsistent, or ``None`` when it is exact."""
+ raw_baseline, raw_score, raw_delta = match.group("baseline", "score", "delta")
+ # Enough precision for an exact difference of any two matched decimals.
+ with localcontext(Context(prec=len(match.group(0)))):
+ baseline = Decimal(raw_baseline)
+ score = Decimal(raw_score)
+ magnitude = Decimal(raw_delta[1:])
+ difference = score - baseline
+ if "-" in raw_baseline + raw_score or baseline > 100 or score > 100:
+ return "malformed score transition"
+ # A zero uplift is written as an unsigned ±0; a sign claims a direction.
+ if raw_delta[0] == "±":
+ return None if magnitude == 0 and difference == 0 else "score transition uplift does not match displayed scores"
+ expected = magnitude if raw_delta[0] == "+" else -magnitude
+ if magnitude == 0 or difference != expected:
+ return "score transition uplift does not match displayed scores"
+ return None
+
+
def _check_required_headings(path: Path, text: str, offenders: list[Offender]) -> None:
"""Require canonical headings in rendered Markdown structure."""
headings = _heading_entries(text)
diff --git a/src/skillevaluator/reporting/benchmark.py b/src/skillevaluator/reporting/benchmark.py
index 013f520f..f5e6618a 100644
--- a/src/skillevaluator/reporting/benchmark.py
+++ b/src/skillevaluator/reporting/benchmark.py
@@ -10,6 +10,7 @@ import re
import unicodedata
from collections import Counter
from datetime import UTC, datetime
+from decimal import ROUND_HALF_UP, Context, Decimal, localcontext
from pathlib import PurePosixPath, PureWindowsPath
from typing import TYPE_CHECKING, Any
@@ -120,6 +121,9 @@ _PUBLICATION_WWW_PREFIX = re.compile(r"\bwww\.", flags=re.IGNORECASE)
_TRAILING_PATH_PUNCTUATION = ".,;!?)]}>`'\""
_LEGACY_AMBIGUOUS_UPLIFT = re.compile(r"\b(?P<score>\d+%)\s+\((?P<change>[+-]\d+%)\)")
_LEGACY_NUM_HEADER = re.compile(r"\|\s*Dimension\s*\|\s*Num\s*\|", flags=re.IGNORECASE)
+# Score cells round half-up in this isolated context, so a caller's ambient
+# decimal precision or rounding mode cannot change the published numbers.
+_DISPLAY_DECIMAL_CONTEXT = Context(prec=28, rounding=ROUND_HALF_UP)
class BenchmarkReporter(ReporterBase):
@@ -465,8 +469,8 @@ class BenchmarkReporter(ReporterBase):
overall_row = ["Overall"]
overall_row.extend(
_score_transition_values(
- _number(agent.get("baseline")),
- _number(agent.get("with_skill", agent.get("overall_score"))),
+ agent.get("baseline"),
+ agent.get("with_skill", agent.get("overall_score")),
skill_never_activated=_mapping(agent.get("skill_activation")).get("status") == "never_activated",
)
for agent in agents.values()
@@ -495,12 +499,14 @@ class BenchmarkReporter(ReporterBase):
"",
(
"**How to read this table:** baseline is the same task attempted without the target skill. "
- "Uplift is `skill score - baseline score`, shown in percentage points."
+ "Scores are rounded to one decimal; threshold-adjacent values use additional precision so "
+ "their displayed band matches the verdict. Uplift is `skill score - baseline score`, "
+ "computed from those displayed scores and shown in percentage points."
),
"",
(
- "Example: `47% → 92% (+45 points)` means the skill-assisted run scored 92%, "
- "45 percentage points above its 47% no-skill baseline."
+ "Example: `47.0% → 92.0% (+45.0 points)` means the skill-assisted run scored 92.0%, "
+ "45.0 percentage points above its 47.0% no-skill baseline."
),
"",
]
@@ -1168,31 +1174,90 @@ def _agent_dimension(agent: dict[str, Any], dim_id: str) -> dict[str, Any] | Non
def _score_transition(dimension: dict[str, Any] | None, *, skill_never_activated: bool = False) -> str:
if not dimension:
return "Not available"
- baseline = _number(dimension.get("baseline"))
- score = _number(dimension.get("with_skill", dimension.get("score")))
- return _score_transition_values(baseline, score, skill_never_activated=skill_never_activated)
+ return _score_transition_values(
+ dimension.get("baseline"),
+ dimension.get("with_skill", dimension.get("score")),
+ skill_never_activated=skill_never_activated,
+ )
-def _score_transition_values(
- baseline: float | None, score: float | None, *, skill_never_activated: bool = False
-) -> str:
- if score is None:
+def _score_transition_values(baseline: object, score: object, *, skill_never_activated: bool = False) -> str:
+ """Render ``baseline → score (uplift)`` so the visible arithmetic is exact.
+
+ Scores are fractions in [0, 1]. A missing, non-finite, or out-of-range score,
+ or a recorded baseline that is not a valid score, is reported as unavailable
+ rather than clamped or published.
+ """
+ parsed_score = _number(score)
+ if parsed_score is None or not 0 <= parsed_score <= 1:
+ return "Not available"
+ parsed_baseline = _number(baseline)
+ if skill_never_activated:
+ # No uplift is shown, so the baseline neither sets the precision nor withholds the score.
+ parsed_baseline = None
+ elif baseline is not None and (parsed_baseline is None or not 0 <= parsed_baseline <= 1):
return "Not available"
- skill_label = f"{score:.0%}"
+ endpoints = (parsed_score,) if parsed_baseline is None else (parsed_baseline, parsed_score)
+ decimal_places = _score_display_decimal_places(*endpoints)
+ displayed_score = _percentage_point_units(parsed_score, decimal_places)
+ skill_label = _format_percentage(displayed_score, decimal_places)
if skill_never_activated:
return f"{skill_label} — INCONCLUSIVE: skill never activated; uplift unavailable"
- if baseline is None:
+ if parsed_baseline is None:
return f"{skill_label} — baseline not run; uplift unavailable"
- delta = score - baseline
- return f"{baseline:.0%} → {skill_label} ({_format_points(delta)})"
+ # Subtract the displayed values, not the raw scores, so a rounding carry can
+ # never publish an uplift that disagrees with the two numbers beside it.
+ displayed_baseline = _percentage_point_units(parsed_baseline, decimal_places)
+ return (
+ f"{_format_percentage(displayed_baseline, decimal_places)} → {skill_label} "
+ f"({_format_points(displayed_score - displayed_baseline, decimal_places)})"
+ )
+
+
+def _score_band(score: float) -> int:
+ """Return the dimension verdict band: 0 for FAIL, 1 for NEUTRAL, 2 for PASS."""
+ if score < DIMENSION_VERDICT_NEUTRAL_THRESHOLD:
+ return 0
+ if score < DIMENSION_VERDICT_PASS_THRESHOLD:
+ return 1
+ return 2
+
+
+def _score_display_decimal_places(*scores: float) -> int:
+ """Return one decimal place, or more when rounding would move a score into another verdict band."""
+ for decimal_places in range(1, 18):
+ scale = 100 * 10**decimal_places
+ if all(
+ _score_band(score) == _score_band(_percentage_point_units(score, decimal_places) / scale)
+ for score in scores
+ ):
+ return decimal_places
+ return 17
+
+
+def _percentage_point_units(score: float, decimal_places: int) -> int:
+ """Round a [0, 1] score half-up to whole units of ``10**-decimal_places`` percentage points."""
+ with localcontext(_DISPLAY_DECIMAL_CONTEXT):
+ scale = Decimal(100 * 10**decimal_places)
+ return int((Decimal(str(score)) * scale).to_integral_value(rounding=ROUND_HALF_UP))
+
+
+def _format_units(value: int, decimal_places: int) -> str:
+ sign = "-" if value < 0 else ""
+ whole, fractional = divmod(abs(value), 10**decimal_places)
+ return f"{sign}{whole}.{fractional:0{decimal_places}d}"
+
+
+def _format_percentage(value: int, decimal_places: int) -> str:
+ return f"{_format_units(value, decimal_places)}%"
-def _format_points(delta: float) -> str:
- points = delta * 100
- if math.isclose(points, 0.0, abs_tol=0.05):
- return "±0 points"
- sign = "+" if points > 0 else "-"
- return f"{sign}{abs(points):.0f} points"
+def _format_points(delta: int, decimal_places: int) -> str:
+ """Format an uplift given in displayed units; an exact zero is shown as ``±0.0 points``."""
+ if delta == 0:
+ return f"±{_format_units(0, decimal_places)} points"
+ sign = "+" if delta > 0 else "-"
+ return f"{sign}{_format_units(abs(delta), decimal_places)} points"
def _tier_status(
diff --git a/tests/golden/benchmark_fail/BENCHMARK.md b/tests/golden/benchmark_fail/BENCHMARK.md
index 499721ac..d0003870 100644
--- a/tests/golden/benchmark_fail/BENCHMARK.md
+++ b/tests/golden/benchmark_fail/BENCHMARK.md
@@ -38,16 +38,16 @@ The three-tier evaluation checks whether the skill:
| Measure | Claude Code (Baseline → Skill Uplift) | Codex (Baseline → Skill Uplift) |
|---|---:|---:|
-| Overall | 72% → 31% (-41 points) | 65% → 38% (-27 points) |
-| Security | 72% → 31% (-41 points) | 65% → 38% (-27 points) |
-| Correctness | 72% → 31% (-41 points) | 65% → 38% (-27 points) |
-| Discoverability | 72% → 31% (-41 points) | 65% → 38% (-27 points) |
-| Effectiveness | 72% → 31% (-41 points) | 65% → 38% (-27 points) |
-| Efficiency | 72% → 31% (-41 points) | 65% → 38% (-27 points) |
+| Overall | 72.0% → 31.0% (-41.0 points) | 65.0% → 38.0% (-27.0 points) |
+| Security | 72.0% → 31.0% (-41.0 points) | 65.0% → 38.0% (-27.0 points) |
+| Correctness | 72.0% → 31.0% (-41.0 points) | 65.0% → 38.0% (-27.0 points) |
+| Discoverability | 72.0% → 31.0% (-41.0 points) | 65.0% → 38.0% (-27.0 points) |
+| Effectiveness | 72.0% → 31.0% (-41.0 points) | 65.0% → 38.0% (-27.0 points) |
+| Efficiency | 72.0% → 31.0% (-41.0 points) | 65.0% → 38.0% (-27.0 points) |
-**How to read this table:** baseline is the same task attempted without the target skill. Uplift is `skill score - baseline score`, shown in percentage points.
+**How to read this table:** baseline is the same task attempted without the target skill. Scores are rounded to one decimal; threshold-adjacent values use additional precision so their displayed band matches the verdict. Uplift is `skill score - baseline score`, computed from those displayed scores and shown in percentage points.
-Example: `47% → 92% (+45 points)` means the skill-assisted run scored 92%, 45 percentage points above its 47% no-skill baseline.
+Example: `47.0% → 92.0% (+45.0 points)` means the skill-assisted run scored 92.0%, 45.0 percentage points above its 47.0% no-skill baseline.
## Tier Status
diff --git a/tests/golden/benchmark_pass/BENCHMARK.md b/tests/golden/benchmark_pass/BENCHMARK.md
index cc9b18ae..e73863d2 100644
--- a/tests/golden/benchmark_pass/BENCHMARK.md
+++ b/tests/golden/benchmark_pass/BENCHMARK.md
@@ -40,16 +40,16 @@ The three-tier evaluation checks whether the skill:
| Measure | Claude Code (Baseline → Skill Uplift) | Codex (Baseline → Skill Uplift) |
|---|---:|---:|
-| Overall | 47% → 92% (+45 points) | 55% → 88% (+33 points) |
-| Security | 47% → 92% (+45 points) | 55% → 88% (+33 points) |
-| Correctness | 47% → 92% (+45 points) | 55% → 88% (+33 points) |
-| Discoverability | 47% → 92% (+45 points) | 55% → 88% (+33 points) |
-| Effectiveness | 47% → 92% (+45 points) | 55% → 88% (+33 points) |
-| Efficiency | 47% → 92% (+45 points) | 55% → 88% (+33 points) |
+| Overall | 47.0% → 92.0% (+45.0 points) | 55.0% → 88.0% (+33.0 points) |
+| Security | 47.0% → 92.0% (+45.0 points) | 55.0% → 88.0% (+33.0 points) |
+| Correctness | 47.0% → 92.0% (+45.0 points) | 55.0% → 88.0% (+33.0 points) |
+| Discoverability | 47.0% → 92.0% (+45.0 points) | 55.0% → 88.0% (+33.0 points) |
+| Effectiveness | 47.0% → 92.0% (+45.0 points) | 55.0% → 88.0% (+33.0 points) |
+| Efficiency | 47.0% → 92.0% (+45.0 points) | 55.0% → 88.0% (+33.0 points) |
-**How to read this table:** baseline is the same task attempted without the target skill. Uplift is `skill score - baseline score`, shown in percentage points.
+**How to read this table:** baseline is the same task attempted without the target skill. Scores are rounded to one decimal; threshold-adjacent values use additional precision so their displayed band matches the verdict. Uplift is `skill score - baseline score`, computed from those displayed scores and shown in percentage points.
-Example: `47% → 92% (+45 points)` means the skill-assisted run scored 92%, 45 percentage points above its 47% no-skill baseline.
+Example: `47.0% → 92.0% (+45.0 points)` means the skill-assisted run scored 92.0%, 45.0 percentage points above its 47.0% no-skill baseline.
## Tier Status
diff --git a/tests/golden/test_benchmark_card.py b/tests/golden/test_benchmark_card.py
index a1434ff8..4f24d804 100644
--- a/tests/golden/test_benchmark_card.py
+++ b/tests/golden/test_benchmark_card.py
@@ -408,7 +408,7 @@ def test_evaluation_date_is_normalized_to_utc_before_publication(tmp_path: Path)
assert "- Tier 3 evidence: required for publication" in rendered
assert "Each task attempt ran in its own isolated sandbox." in rendered
assert "| Measure | Claude Code (Baseline → Skill Uplift) | Codex (Baseline → Skill Uplift) |" in rendered
- assert "| Overall | 47% → 92% (+45 points) | 55% → 88% (+33 points) |" in rendered
+ assert "| Overall | 47.0% → 92.0% (+45.0 points) | 55.0% → 88.0% (+33.0 points) |" in rendered
assert "| Dimension | Num |" not in rendered
assert "The 50% attempt pass threshold is a separate per-task gate" in rendered
assert "`goal_accuracy` (50%) + `behavior_check` (50%)" in rendered
@@ -1121,17 +1121,156 @@ def test_benchmark_no_baseline_never_fabricates_uplift() -> None:
assert "Overall verdict: INCOMPLETE" in rendered
assert "Tier 3 ran but lacks publication-complete provenance or dimension evidence" in rendered
- assert "92% — baseline not run; uplift unavailable" in rendered
- assert "88% — baseline not run; uplift unavailable" in rendered
+ assert "92.0% — baseline not run; uplift unavailable" in rendered
+ assert "88.0% — baseline not run; uplift unavailable" in rendered
assert "Publication Recommendation" not in rendered
def test_benchmark_zero_and_negative_lift_use_percentage_points() -> None:
+ from skillevaluator.reporting.benchmark import _score_transition, _score_transition_values
+
+ assert _score_transition_values(1.0, 1.0) == "100.0% → 100.0% (±0.0 points)"
+ assert _score_transition_values(0.7, 0.62) == "70.0% → 62.0% (-8.0 points)"
+ assert _score_transition_values(0.0, 0.0) == "0.0% → 0.0% (±0.0 points)"
+ assert _score_transition_values(-0.0, 0.5) == "0.0% → 50.0% (+50.0 points)"
+ # Raw scores differ, but the displayed endpoints are equal, so the uplift is an unsigned zero.
+ assert _score_transition_values(0.50004, 0.500049) == "50.0% → 50.0% (±0.0 points)"
+ assert _score_transition_values(0.500049, 0.50004) == "50.0% → 50.0% (±0.0 points)"
+ assert _score_transition_values(None, 0.92) == "92.0% — baseline not run; uplift unavailable"
+ assert _score_transition_values(0.5, None) == "Not available"
+ assert _score_transition({"baseline": float("nan"), "with_skill": 0.92}) == "Not available"
+ assert _score_transition({"baseline": 0.5, "with_skill": float("inf")}) == "Not available"
+
+
+ ("baseline", "score", "expected"),
+ [
+ # Whole-percent rounding used to publish "58% → 95% (+36 points)" here.
+ (0.5842, 0.9479, "58.4% → 94.8% (+36.4 points)"),
+ (0.9479, 0.5842, "94.8% → 58.4% (-36.4 points)"),
+ # Rounding carry: the uplift follows the displayed endpoints, not the raw +20.04 points.
+ (0.5002, 0.7006, "50.0% → 70.1% (+20.1 points)"),
+ # Ties round half-up on the decimal value; binary float formatting shows 50.0% and 12.3% here.
+ (0.5005, 0.7005, "50.1% → 70.1% (+20.0 points)"),
+ (0.1235, 0.9865, "12.4% → 98.7% (+86.3 points)"),
+ ],
+)
+def test_score_transition_derives_uplift_from_displayed_endpoints(
+ baseline: float,
+ score: float,
+ expected: str,
+) -> None:
+ from skillevaluator.reporting.benchmark import _score_transition_values
+
+ assert _score_transition_values(baseline, score) == expected
+
+
+ ("baseline", "score", "expected"),
+ [
+ # Below the 50% PASS threshold: one decimal would display 50.0%.
+ (0.4, 0.4995, "40.00% → 49.95% (+9.95 points)"),
+ (0.3, 0.49996, "30.000% → 49.996% (+19.996 points)"),
+ # Below the 40% NEUTRAL threshold: one decimal would display 40.0%.
+ (0.3995, 0.4, "39.95% → 40.00% (+0.05 points)"),
+ (0.39996, 0.6, "39.996% → 60.000% (+20.004 points)"),
+ # Exactly on a threshold needs no extra precision.
+ (0.4, 0.5, "40.0% → 50.0% (+10.0 points)"),
+ ],
+)
+def test_threshold_adjacent_scores_keep_their_verdict_band(baseline: float, score: float, expected: str) -> None:
+ from skillevaluator.reporting.benchmark import _score_transition_values
+
+ assert _score_transition_values(baseline, score) == expected
+
+
+ ("baseline", "score"),
+ [
+ (-0.00004, 0.92),
+ (0.5, 1.00004),
+ (0.0, 1.5),
+ (0.5, float("nan")),
+ (float("-inf"), 0.92),
+ (float("nan"), 0.92),
+ (True, 0.92),
+ ("0.5", 0.92),
+ ],
+)
+def test_score_transition_does_not_publish_invalid_raw_scores(baseline: object, score: object) -> None:
from skillevaluator.reporting.benchmark import _score_transition_values
- assert _score_transition_values(1.0, 1.0) == "100% → 100% (±0 points)"
- assert _score_transition_values(0.7, 0.62) == "70% → 62% (-8 points)"
- assert _score_transition_values(None, 0.92) == "92% — baseline not run; uplift unavailable"
+ assert _score_transition_values(baseline, score) == "Not available"
+
+
+def test_never_activated_cell_ignores_baseline_and_keeps_threshold_precision() -> None:
+ from skillevaluator.reporting.benchmark import _score_transition_values
+
+ expected = "49.95% — INCONCLUSIVE: skill never activated; uplift unavailable"
+ assert _score_transition_values(0.4, 0.4995, skill_never_activated=True) == expected
+ assert _score_transition_values(float("nan"), 0.4995, skill_never_activated=True) == expected
+ assert _score_transition_values(0.4, 1.5, skill_never_activated=True) == "Not available"
+
+
+def test_threshold_adjacent_card_scores_keep_their_band_and_pass_the_gate(tmp_path: Path) -> None:
+ tier3 = deepcopy(_live_tier3_result())
+ codex = tier3.metadata["agent_eval"]["agents"]["codex"]
+ codex["dimensions"][0]["with_skill"] = 0.49996
+ codex["dimensions"][1]["baseline"] = 0.39996
+
+ rendered = BenchmarkReporter(include_timestamp=True).render_all([*_deterministic_results(), tier3])
+ benchmark = tmp_path / "BENCHMARK.md"
+ benchmark.write_text(rendered, encoding="utf-8")
+ _files, offenders = benchmark_gate.find_offenders([benchmark])
+
+ assert "| Security | 47.0% → 92.0% (+45.0 points) | 55.000% → 49.996% (-5.004 points) |" in rendered
+ assert "| Correctness | 47.0% → 92.0% (+45.0 points) | 39.996% → 88.000% (+48.004 points) |" in rendered
+ assert "threshold-adjacent values use additional precision so their displayed band matches the verdict" in rendered
+ assert offenders == []
+
+
+def test_rendered_score_transitions_satisfy_the_gate_and_keep_verdict_bands() -> None:
+ import random
+ from decimal import Decimal
+
+ from skillevaluator.constants import DIMENSION_VERDICT_NEUTRAL_THRESHOLD, DIMENSION_VERDICT_PASS_THRESHOLD
+ from skillevaluator.reporting.benchmark import _score_transition_values
+
+ neutral = Decimal(str(DIMENSION_VERDICT_NEUTRAL_THRESHOLD))
+ passing = Decimal(str(DIMENSION_VERDICT_PASS_THRESHOLD))
+
+ def band(fraction: Decimal) -> int:
+ return 0 if fraction < neutral else 1 if fraction < passing else 2
+
+ edges = [0.0, 1.0, 0.4, 0.5, 0.39995, 0.3999999, 0.49995, 0.4999999, 0.5842, 0.9479, 0.0005, 0.9995]
+ rng = random.Random(20260903)
+ pairs = [(baseline, score) for baseline in edges for score in edges]
+ pairs.extend((rng.random(), rng.random()) for _ in range(2000))
+ for baseline, score in pairs:
+ cell = _score_transition_values(baseline, score)
+ match = benchmark_gate._SCORE_TRANSITION.fullmatch(cell)
+ assert match is not None, cell
+ assert benchmark_gate._score_transition_problem(match) is None, cell
+ for raw, shown in ((baseline, match.group("baseline")), (score, match.group("score"))):
+ assert band(Decimal(str(raw))) == band(Decimal(shown) / 100), cell
+
+
+def test_score_rendering_is_isolated_from_the_ambient_decimal_context() -> None:
+ from decimal import ROUND_DOWN, localcontext
+
+ tier3 = deepcopy(_live_tier3_result())
+ codex = tier3.metadata["agent_eval"]["agents"]["codex"]
+ codex["baseline"] = 0.5842
+ codex["with_skill"] = 0.9479
+ codex["dimensions"][-1]["with_skill"] = 1e25
+
+ with localcontext() as ambient_context:
+ ambient_context.prec = 2
+ ambient_context.rounding = ROUND_DOWN
+ rendered = BenchmarkReporter(include_timestamp=False).render_all([*_deterministic_results(), tier3])
+
+ assert "| Overall | 47.0% → 92.0% (+45.0 points) | 58.4% → 94.8% (+36.4 points) |" in rendered
+ assert "| Efficiency | 47.0% → 92.0% (+45.0 points) | Not available |" in rendered
def test_benchmark_local_mode_does_not_claim_sandboxing() -> None:
diff --git a/tests/reporting/test_activation_benchmark_html_regressions.py b/tests/reporting/test_activation_benchmark_html_regressions.py
index 86236e9a..12d93c25 100644
--- a/tests/reporting/test_activation_benchmark_html_regressions.py
+++ b/tests/reporting/test_activation_benchmark_html_regressions.py
@@ -71,7 +71,7 @@ def test_benchmark_never_activated_scores_do_not_reconstruct_uplift(baseline: bo
scores = {"Overall": agent["with_skill"], **{d["id"].title(): d["with_skill"] for d in agent["dimensions"]}}
assert len(rows) == len(DIMENSION_MAPPING) + 1
for measure, cells in rows.items():
- assert f"{scores[measure]:.0%}" in cells[0]
+ assert f"{scores[measure]:.1%}" in cells[0]
assert "INCONCLUSIVE: skill never activated" in cells[0]
assert "uplift unavailable" in cells[0]
assert "points" not in cells[0]
diff --git a/tests/test_public_benchmark_gate.py b/tests/test_public_benchmark_gate.py
index 42d52b9a..8a26a739 100644
--- a/tests/test_public_benchmark_gate.py
+++ b/tests/test_public_benchmark_gate.py
@@ -171,6 +171,85 @@ def test_gate_accepts_redesigned_public_card(tmp_path: Path) -> None:
assert offenders == []
+ "cell",
+ [
+ # Whole-number cells from earlier releases stay valid when their arithmetic holds.
+ "47% → 92% (+45 points)",
+ "47.0% → 92.0% (+45.0 points)",
+ "94.8% → 58.4% (-36.4 points)",
+ "40.00% → 49.95% (+9.95 points)",
+ "50.0% → 50.0% (±0.0 points)",
+ "0.0% → 100.0% (+100.0 points)",
+ "92.0% — baseline not run; uplift unavailable",
+ "49.95% — INCONCLUSIVE: skill never activated; uplift unavailable",
+ "Not available",
+ ],
+)
+def test_gate_accepts_consistent_score_cells(tmp_path: Path, cell: str) -> None:
+ benchmark = tmp_path / "BENCHMARK.md"
+ benchmark.write_text(_valid_benchmark().replace("47% → 92% (+45 points)", cell), encoding="utf-8")
+
+ _files, offenders = benchmark_gate.find_offenders([benchmark])
+
+ assert offenders == []
+
+
+ ("cell", "reason"),
+ [
+ # Whole-percent rounding of 0.5842 → 0.9479 published this contradictory cell.
+ ("58% → 95% (+36 points)", "score transition uplift does not match displayed scores"),
+ ("47% → 92% (+44 points)", "score transition uplift does not match displayed scores"),
+ ("47% → 92% (-45 points)", "score transition uplift does not match displayed scores"),
+ ("47% -> 92% (+44 points)", "score transition uplift does not match displayed scores"),
+ ("47% &rarr; 92% (+44 points)", "score transition uplift does not match displayed scores"),
+ ("94.8% → 58.4% (\u221236.3 points)", "score transition uplift does not match displayed scores"),
+ (
+ "47.0000000000000000000000000001% → 92% (+45 points)",
+ "score transition uplift does not match displayed scores",
+ ),
+ ("50% → 50% (+0 points)", "score transition uplift does not match displayed scores"),
+ ("50% → 50% (-0 points)", "score transition uplift does not match displayed scores"),
+ ("49% → 50% (±0 points)", "score transition uplift does not match displayed scores"),
+ ("-1% → 92% (+93 points)", "malformed score transition"),
+ ("-0% → 92% (+92 points)", "malformed score transition"),
+ ("101% → 92% (-9 points)", "malformed score transition"),
+ ],
+)
+def test_gate_rejects_inconsistent_or_out_of_range_score_transitions(
+ tmp_path: Path,
+ cell: str,
+ reason: str,
+) -> None:
+ benchmark = tmp_path / "BENCHMARK.md"
+ benchmark.write_text(_valid_benchmark().replace("47% → 92% (+45 points)", cell), encoding="utf-8")
+
+ _files, offenders = benchmark_gate.find_offenders([benchmark])
+
+ assert [(offender.line, offender.reason) for offender in offenders] == [(23, reason)]
+
+
+def test_gate_checks_score_transitions_only_in_results_table_cells(tmp_path: Path) -> None:
+ # Finding and label text is untrusted and may quote arbitrary numbers; only
+ # the reporter-owned Results at a Glance cells carry score transitions.
+ benchmark = tmp_path / "BENCHMARK.md"
+ benchmark.write_text(
+ _valid_benchmark()
+ .replace(
+ "| Measure | Codex (Baseline → Skill Uplift) |",
+ "| Measure 58% → 95% (+36 points) | Codex (Baseline → Skill Uplift) |",
+ )
+ .replace("## Tier Status", "Quoted note: 58% → 95% (+36 points)\n\n## Tier Status")
+ + "\n- Finding: skill text claims 58% → 95% (+36 points)\n",
+ encoding="utf-8",
+ )
+
+ _files, offenders = benchmark_gate.find_offenders([benchmark])
+
+ assert offenders == []
+
+
@pytest.mark.parametrize(
"evaluation_date",
["2026-02-30", "2026-13-01", "0000-01-01", "9999-99-99"],
@@ -862,6 +941,25 @@ def test_real_reporter_cards_pass_publication_gate(tmp_path: Path, verdict: str)
assert offenders == []
+def test_real_reporter_rounding_boundary_card_passes_publication_gate(tmp_path: Path) -> None:
+ tier3 = _tier3_result("PASS")
+ agent = tier3.metadata["agent_eval"]["agents"]["codex"]
+ agent["baseline"] = 0.5842
+ agent["with_skill"] = 0.9479
+ agent["dimensions"][0].update(baseline=0.5842, with_skill=0.9479, lift=0.9479 - 0.5842)
+ agent["dimensions"][1].update(baseline=0.5002, with_skill=0.7006, lift=0.7006 - 0.5002)
+
+ rendered = BenchmarkReporter(include_timestamp=True).render_all([_tier1_result(), _tier2_result(), tier3])
+ benchmark = tmp_path / "BENCHMARK.md"
+ benchmark.write_text(rendered, encoding="utf-8")
+ _files, offenders = benchmark_gate.find_offenders([benchmark])
+
+ assert "| Overall | 58.4% → 94.8% (+36.4 points) |" in rendered
+ assert "| Security | 58.4% → 94.8% (+36.4 points) |" in rendered
+ assert "| Correctness | 50.0% → 70.1% (+20.1 points) |" in rendered
+ assert offenders == []
+
+
def test_real_reporter_normalizes_positive_offset_evaluation_date_to_utc(tmp_path: Path) -> None:
tier3 = _tier3_result("PASS")
tier3.metadata["agent_eval"]["evaluated_at"] = "2026-07-25T00:02:00+14:00"