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.

perf(tier3): reuse bootstrap means for constant case deltas (#721)

Afloat75380edf7c85
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 813033ca..45ae1604 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@ All notable changes to SkillEvaluator are documented in this file.
- Claude Code log recovery pairs batched and delayed tool results without repeatedly
scanning earlier tool calls, reducing reconstruction time for long trajectories.
+- Tier 3 lift intervals compute faster when every case has the same lift;
+ results are unchanged.
### Documentation
diff --git a/src/skillevaluator/tier3/harbor/stats.py b/src/skillevaluator/tier3/harbor/stats.py
index 963cd1e1..0267564d 100644
--- a/src/skillevaluator/tier3/harbor/stats.py
+++ b/src/skillevaluator/tier3/harbor/stats.py
@@ -565,6 +565,13 @@ def expanded_tail(n_cases: int, confidence: float) -> float:
return _normal_cdf(-math.sqrt(n_cases / (n_cases - 1)) * t_value)
+def _constant_resample_mean(values: Sequence[float]) -> float | None:
+ """Return the exact resample mean when every case has the same value."""
+ if values and all(value == values[0] for value in values):
+ return math.fsum(values) / len(values)
+ return None
+
+
def _resample_means(deltas: Sequence[float], *, resamples: int, seed: int) -> list[float]:
"""The mean of each case resample, in draw order, from a ``random.Random(seed)`` stream.
@@ -573,6 +580,9 @@ def _resample_means(deltas: Sequence[float], *, resamples: int, seed: int) -> li
at the same case indices. That is why the lift ladder's steps add up in
every resample, not only on their means.
"""
+ constant = _constant_resample_mean(deltas)
+ if constant is not None:
+ return [constant] * resamples
n_cases = len(deltas)
rng = random.Random(seed)
return [math.fsum(rng.choices(deltas, k=n_cases)) / n_cases for _ in range(resamples)]
@@ -1007,10 +1017,17 @@ def _ladder_rungs(
resamples = _effective_resamples(len(case_ids))
means: dict[str, list[float]] = {name: [] for name in definitions}
if len(case_ids) >= 2:
+ varying = {}
+ for name, values in deltas.items():
+ constant = _constant_resample_mean(values)
+ if constant is None:
+ varying[name] = values
+ else:
+ means[name] = [constant] * resamples
rng = random.Random(LIFT_BOOTSTRAP_SEED)
- for _ in range(resamples):
+ for _ in range(resamples if varying else 0):
indices = rng.choices(range(len(case_ids)), k=len(case_ids))
- for name, values in deltas.items():
+ for name, values in varying.items():
means[name].append(math.fsum(values[index] for index in indices) / len(indices))
results = {
name: paired_case_bootstrap(
diff --git a/tests/tier3/test_constant_bootstrap.py b/tests/tier3/test_constant_bootstrap.py
new file mode 100644
index 00000000..ebeab675
--- /dev/null
+++ b/tests/tier3/test_constant_bootstrap.py
@@ -0,0 +1,69 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Constant case deltas need no random draws and keep the same bootstrap output."""
+
+from __future__ import annotations
+
+import math
+import random
+
+import pytest
+
+from skillevaluator.tier3.harbor import stats
+
+
[email protected]("value", [0.0, 0.1, -0.3, 1.0])
+def test_constant_resamples_match_explicit_draws_without_sampling(monkeypatch: pytest.MonkeyPatch, value: float) -> None:
+ deltas = [value] * 13
+ rng = random.Random(42)
+ expected = [math.fsum(rng.choices(deltas, k=len(deltas))) / len(deltas) for _ in range(30)]
+
+ def unexpected_draw(*args, **kwargs):
+ pytest.fail("a constant population does not need random choices")
+
+ monkeypatch.setattr(random.Random, "choices", unexpected_draw)
+
+ assert stats._resample_means(deltas, resamples=30, seed=42) == expected
+
+
+def test_constant_ladder_keeps_bootstrap_results_without_sampling(monkeypatch: pytest.MonkeyPatch) -> None:
+ cases = [f"case-{index}" for index in range(10)]
+ scores = {
+ stats.ARM_WITHOUT: dict.fromkeys(cases, 0.0),
+ stats.ARM_SUM_OF_PARTS: dict.fromkeys(cases, 0.25),
+ stats.ARM_LOOSE_PARTS: dict.fromkeys(cases, 0.5),
+ stats.ARM_WITH: dict.fromkeys(cases, 0.75),
+ }
+ expected = {
+ name: stats.paired_case_bootstrap(scores[treatment], scores[control])
+ for name, (treatment, control) in {**stats.LADDER_STEPS, "bundle": stats.LADDER_BUNDLE}.items()
+ }
+
+ def unexpected_draw(*args, **kwargs):
+ pytest.fail("constant ladder steps do not need random choices")
+
+ monkeypatch.setattr(random.Random, "choices", unexpected_draw)
+ steps, bundle, skill = stats._ladder_rungs(scores, cases)
+
+ for name, step in steps.items():
+ assert step == stats._step_fields(expected[name], split=False)
+ assert bundle == stats._step_fields(expected["bundle"], split=False)
+ assert skill == expected["skill"]
+
+
+def test_mixed_ladder_steps_keep_the_seeded_case_indices() -> None:
+ cases = [f"case-{index}" for index in range(10)]
+ scores = {
+ stats.ARM_WITHOUT: dict.fromkeys(cases, 0.0),
+ stats.ARM_SUM_OF_PARTS: dict.fromkeys(cases, 0.25),
+ stats.ARM_LOOSE_PARTS: {case: 0.25 + index / 100 for index, case in enumerate(cases)},
+ stats.ARM_WITH: {case: 0.5 + index / 100 for index, case in enumerate(cases)},
+ }
+
+ steps, bundle, _ = stats._ladder_rungs(scores, cases)
+
+ for name, (treatment, control) in {**stats.LADDER_STEPS, "bundle": stats.LADDER_BUNDLE}.items():
+ expected = stats.paired_case_bootstrap(scores[treatment], scores[control])
+ actual = bundle if name == "bundle" else steps[name]
+ assert actual == stats._step_fields(expected, split=False)
diff --git a/tests/tier3/test_private_comparison_contracts.py b/tests/tier3/test_private_comparison_contracts.py
index 4b602358..961ed7b0 100644
--- a/tests/tier3/test_private_comparison_contracts.py
+++ b/tests/tier3/test_private_comparison_contracts.py
@@ -20,10 +20,14 @@ def reward(case, value=0.5, *, accuracy=None, judge=None):
return row
-def arms(cases=("a", "b", "c", "d", "e")):
+def arms(cases=("a", "b", "c", "d", "e"), *, varying=False):
return {
arm: stats.ArmObservations(
- "succeeded", tuple(stats.TrialObservation(case, reward(case, value)) for case in cases)
+ "succeeded",
+ tuple(
+ stats.TrialObservation(case, reward(case, value * (1 - index / 10) if varying else value))
+ for index, case in enumerate(cases)
+ ),
)
for arm, value in (("without_skill", 0.2), ("sum_of_parts", 0.4), ("loose_parts", 0.6), ("with_skill", 0.8))
}
@@ -38,7 +42,7 @@ def test_ladder_uses_one_shared_bootstrap_draw_stream(monkeypatch):
return original(self, population, *args, **kwargs)
monkeypatch.setattr(stats.random.Random, "choices", choices)
- result = stats.lift_ladder(arms(), None)
+ result = stats.lift_ladder(arms(varying=True), None)
assert len(calls) == result["bootstrap"]["resamples"]
steps = result["steps"]
assert math.isclose(
@@ -46,6 +50,18 @@ def test_ladder_uses_one_shared_bootstrap_draw_stream(monkeypatch):
)
+def test_constant_ladder_needs_no_bootstrap_draws(monkeypatch):
+ def choices(*args, **kwargs):
+ raise AssertionError("constant case deltas do not need random samples")
+
+ monkeypatch.setattr(stats.random.Random, "choices", choices)
+ result = stats.lift_ladder(arms(), None)
+ steps = result["steps"]
+ assert math.isclose(
+ sum(steps[key]["estimate"] for key in ("skill", "capability", "integration")), steps["plugin"]["estimate"]
+ )
+
+
def test_judge_mismatch_does_not_enter_paired_interval_or_ladder():
observed = {}
for arm in arms():