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): add opt-in --max-cases limit for exploratory runs (#283)

Narendran Raghavan6d5d57f35c33
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c7f0a83..1e820c3f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -78,6 +78,15 @@ All notable changes to SkillEvaluator are documented in this file.
- CI-native per-skill HTML pages link Download JSON to the retained
`skillevaluator-tier1.json` and do not embed a second copy of the report
JSON. Standalone CLI HTML reports embed it for Export JSON.
+- Tier 3 runs can be limited to the first N eval cases with the opt-in
+ `--max-cases N` flag on `validate`, `tier3`, and `tier3 evaluate`, or the
+ `harbor.max_cases` key in `evals/config.yml`; the CLI value wins. Unset, every
+ case runs as before. Cases are taken in staged order (dataset order, or
+ task-directory name order for native Harbor tasks) and the same subset runs
+ for every agent's with-skill and baseline arms. The dataset snapshot and
+ expected-case checks cover only the cases that ran, `run_config.json` records
+ the selection as `case_selection`, and a run that skipped cases is reported
+ as publication-incomplete in JSON, HTML, and BENCHMARK.md.
### Changed
diff --git a/docs/cli-reference.mdx b/docs/cli-reference.mdx
index 3b558022..3a854b9f 100644
--- a/docs/cli-reference.mdx
+++ b/docs/cli-reference.mdx
@@ -267,6 +267,7 @@ The following flags are forwarded to the live-eval engine when Tier 3 is enabled
| `--skip-baseline` | off | Skip the without-skill baseline (no lift analysis, faster). |
| `--n-concurrent INTEGER` | unset | Concurrent eval cases per agent. |
| `--max-agents INTEGER` | unset | Maximum agents to run in parallel. |
+| `--max-cases INTEGER RANGE` | unset | Run only the first N eval cases in staged order (minimum `1`); without a limit every case runs. A run that skips cases is recorded in `run_config.json` and is never publication evidence. |
| `--n-attempts INTEGER` | unset | Attempts per eval case (pass@k). |
| `--pass-threshold FLOAT` | unset | Score threshold (0.0–1.0) for a case to count as passed. |
| `--stop-on-pass / --no-stop-on-pass` | unset | Stop a case's remaining attempts once one passes. |
@@ -436,6 +437,7 @@ Use `skillevaluator tier3 PATH` for the complete workflow with automatic missing
| `--stop-on-pass / --no-stop-on-pass` | unset | Stop a case's remaining attempts once one passes. |
| `--n-concurrent INTEGER` | unset | Concurrent eval cases per agent. |
| `--max-agents INTEGER` | unset | Maximum agents to run in parallel. |
+| `--max-cases INTEGER RANGE` | unset | Run only the first N eval cases in staged order (minimum `1`); without a limit every case runs. A run that skips cases is recorded in `run_config.json` and is never publication evidence. |
| `--model TEXT` | unset | Global agent model override. |
| `--agent-model TEXT` | unset | Per-agent model override, `AGENT=MODEL` (repeatable), e.g. `--agent-model codex=gpt-6.1-sol`. Accepts the `claude` alias for `claude-code`. |
| `--custom-dockerfile-mode [preserve\|rebase]` | unset | How a custom `evals/environment/Dockerfile` is applied: `rebase` (built-in default) swaps its `FROM` line onto the eval base image; `preserve` keeps your `FROM` and appends the eval dependencies. |
diff --git a/docs/eval-datasets.mdx b/docs/eval-datasets.mdx
index 8cc3ae8c..539eaee6 100644
--- a/docs/eval-datasets.mdx
+++ b/docs/eval-datasets.mdx
@@ -253,6 +253,7 @@ grading:
| `harbor.stop_on_pass` | boolean | Stop a case's remaining attempts after the first pass. Requires `n_attempts` > 1. |
| `harbor.n_concurrent` | integer ≥ 1 | Concurrent trials. |
| `harbor.max_agents` | integer ≥ 1 | Cap on agents evaluated in one run. |
+| `harbor.max_cases` | integer ≥ 1 | Run only the first N cases in staged order (eval dataset order, or task-directory name order for native Harbor tasks). Unset runs every case. A run that skips cases is not publication evidence. The `--max-cases` CLI flag overrides this value. |
| `harbor.timeout_multiplier` | finite number > 0 | Scales task timeouts. Values that would overflow Harbor's mandatory lifecycle timeouts are rejected before execution. |
| `harbor.agent_runtime_preflight` | boolean | Opt-in extra agent-only execution of the first staged task before the measured evaluation. Default: `false`; the CLI flag overrides this value. |
| `harbor.agent_workdir` | string | Working directory for the agent inside the container. |
diff --git a/docs/tier3-live-evaluation.mdx b/docs/tier3-live-evaluation.mdx
index 21b7049b..cf3dbf9f 100644
--- a/docs/tier3-live-evaluation.mdx
+++ b/docs/tier3-live-evaluation.mdx
@@ -520,7 +520,12 @@ dataset iteration, `--skip-baseline` removes the without-skill arm and usually
cuts the live trial count roughly in half, but that run cannot produce Skill
Lift. Re-enable the baseline for any result you intend to compare or publish.
For multi-attempt runs, `--stop-on-pass` can avoid remaining attempts after a
-pass; it is rejected with `--n-attempts 1`. By contrast,
+pass; it is rejected with `--n-attempts 1`. To try a large dataset before
+paying for every case, `--max-cases N` (or `harbor.max_cases`) runs only the
+first N cases in staged order: eval dataset order, or task-directory name
+order for native Harbor tasks. The run records the selection in
+`run_config.json`, its dataset snapshot covers only the cases that ran, and
+reports mark it publication-incomplete when cases were skipped. By contrast,
`--n-concurrent` and `--max-agents` control parallelism and elapsed time; they
do not reduce the total planned trials or model work.
@@ -552,6 +557,7 @@ The high-signal flags, with defaults:
| `--pass-threshold` | `0.5` | Score an attempt needs to count as passed |
| `--n-concurrent` | `4` | Concurrent eval cases per agent |
| `--max-agents` | selected-agent count | Maximum agents run in parallel |
+| `--max-cases` | every case | Run only the first N eval cases; a run that skips cases is not publication evidence |
| `--skip-baseline` | off | Skip the without-skill arm; faster, but no Skill Lift |
| `--stop-on-pass` | off | Stop a case's remaining attempts once one passes |
| `--agent-runtime-preflight` | off | Add one agent-only execution of the first staged task per agent before the full A/B matrix; `--no-agent-runtime-preflight` overrides a config value that enables it |
diff --git a/src/skillevaluator/cli.py b/src/skillevaluator/cli.py
index 9c5a23f8..99ec28e7 100644
--- a/src/skillevaluator/cli.py
+++ b/src/skillevaluator/cli.py
@@ -777,6 +777,7 @@ def _run_agent_eval_or_skip(
skip_baseline: bool,
n_concurrent: int | None,
max_agents: int | None,
+ max_cases: int | None = None,
n_attempts: int | None = None,
pass_threshold: float | None = None,
stop_on_pass: bool | None = None,
@@ -836,6 +837,7 @@ def _run_agent_eval_or_skip(
skip_baseline=skip_baseline,
n_concurrent=n_concurrent,
max_agents=max_agents,
+ max_cases=max_cases,
n_attempts=n_attempts,
pass_threshold=pass_threshold,
stop_on_pass=stop_on_pass,
@@ -1146,6 +1148,8 @@ def _catalog_child_argv_from_ctx(
argv.extend(["--n-concurrent", str(params["n_concurrent"])])
if params.get("max_agents") is not None:
argv.extend(["--max-agents", str(params["max_agents"])])
+ if params.get("max_cases") is not None:
+ argv.extend(["--max-cases", str(params["max_cases"])])
if params.get("n_attempts") is not None:
argv.extend(["--n-attempts", str(params["n_attempts"])])
if params.get("pass_threshold") is not None:
@@ -1774,6 +1778,14 @@ def _print_run_banner(target_path: Path, content_type: str, profile: str | None)
help_group=_TIER3_GROUP,
help="Maximum agents to run in parallel.",
)
+ "--max-cases",
+ type=click.IntRange(min=1),
+ default=None,
+ cls=GroupedOption,
+ help_group=_TIER3_GROUP,
+ help="Run only the first N eval cases (default: every case); a partial run is not publication evidence.",
+)
@click.option(
"--n-attempts",
type=int,
@@ -1914,6 +1926,7 @@ def validate(
skip_baseline: bool,
n_concurrent: int | None,
max_agents: int | None,
+ max_cases: int | None,
n_attempts: int | None,
pass_threshold: float | None,
stop_on_pass: bool | None,
@@ -2225,6 +2238,7 @@ def validate(
skip_baseline=skip_baseline,
n_concurrent=n_concurrent,
max_agents=max_agents,
+ max_cases=max_cases,
n_attempts=n_attempts,
pass_threshold=pass_threshold,
stop_on_pass=stop_on_pass,
@@ -2823,6 +2837,12 @@ def _tier2_workflow(
)
@click.option("--n-concurrent", type=int, default=None)
@click.option("--max-agents", type=int, default=None)
+ "--max-cases",
+ type=click.IntRange(min=1),
+ default=None,
+ help="Run only the first N eval cases (default: every case); a partial run is not publication evidence.",
+)
@click.option("--model", default=None, help="Global agent model override.")
@click.option("--agent-model", multiple=True, help="Per-agent model override, AGENT=MODEL.")
@click.option("--custom-dockerfile-mode", type=click.Choice(["preserve", "rebase"]), default=None)
@@ -2882,6 +2902,7 @@ def evaluate(
stop_on_pass: bool | None,
n_concurrent: int | None,
max_agents: int | None,
+ max_cases: int | None,
model: str | None,
agent_model: tuple[str, ...],
custom_dockerfile_mode: str | None,
@@ -2930,6 +2951,7 @@ def evaluate(
stop_on_pass=stop_on_pass,
n_concurrent=n_concurrent,
max_agents=max_agents,
+ max_cases=max_cases,
model=model,
agent_model=agent_model,
custom_dockerfile_mode=custom_dockerfile_mode,
diff --git a/src/skillevaluator/evaluation/options.py b/src/skillevaluator/evaluation/options.py
index c3b02379..c25ab78f 100644
--- a/src/skillevaluator/evaluation/options.py
+++ b/src/skillevaluator/evaluation/options.py
@@ -52,6 +52,8 @@ class EvaluationOptions:
# the tree that runs the evaluator is not the tree being evaluated.
evaluated_source: dict[str, str] | None = None
environment_kwargs: dict[str, str] = field(default_factory=dict)
+ # Appended so legacy positional construction keeps its field order.
+ max_cases: int | None = None
def engine_kwargs(self) -> dict[str, Any]:
"""Return keyword arguments (excluding ``skill_path``) for the engine."""
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py
index 0bcaf344..5386454a 100644
--- a/src/skillevaluator/evaluation/tier3_report.py
+++ b/src/skillevaluator/evaluation/tier3_report.py
@@ -869,6 +869,9 @@ def build_agent_eval_payload(
}
if publication_target_conflict in _PUBLICATION_TARGET_CONFLICT_MARKERS:
summary["publication_target_conflict"] = publication_target_conflict
+ case_selection = _case_selection(run_config)
+ if case_selection is not None:
+ summary["case_selection"] = case_selection
if harbor_summary:
summary["harbor_viewer"] = {
key: harbor_summary[key] for key in ("job_url", "analysis_url") if harbor_summary.get(key)
@@ -972,6 +975,8 @@ def build_agent_eval_payload(
}
if publication_target_conflict in _PUBLICATION_TARGET_CONFLICT_MARKERS:
payload["publication_target_conflict"] = publication_target_conflict
+ if case_selection is not None:
+ payload["case_selection"] = dict(case_selection)
if harbor_summary:
payload["harbor_viewer"] = harbor_summary
@@ -3649,6 +3654,16 @@ def _agent_model(name: str, info: dict[str, Any], run_config: dict[str, Any] | N
return str(model) if model else None
+def _case_selection(run_config: dict[str, Any] | None) -> dict[str, Any] | None:
+ """Return the recorded ``max_cases`` counts so reports can flag a partial run."""
+ if not isinstance(run_config, dict) or "case_selection" not in run_config:
+ return None
+ selection = run_config["case_selection"]
+ if not isinstance(selection, dict):
+ selection = {}
+ return {key: selection.get(key) for key in ("policy", "limit", "total", "selected", "skipped")}
+
+
def _read_attempt_policy(run_dir: Path) -> dict[str, Any]:
policy = _default_attempt_policy()
policy_file = run_dir / "attempt_policy.json"
diff --git a/src/skillevaluator/reporting/base.py b/src/skillevaluator/reporting/base.py
index a22017ef..848adbce 100644
--- a/src/skillevaluator/reporting/base.py
+++ b/src/skillevaluator/reporting/base.py
@@ -1384,6 +1384,27 @@ def _agent_eval_publication_aggregates_consistent(
return root_dimensions == agent_dimensions
+def agent_eval_case_selection_issue(payload: dict[str, Any] | None) -> str | None:
+ """Return why a run limited by ``max_cases`` cannot be publication evidence."""
+ if not isinstance(payload, dict):
+ return None
+ summary = payload.get("summary") if isinstance(payload.get("summary"), dict) else {}
+ recorded = [container["case_selection"] for container in (payload, summary) if "case_selection" in container]
+ if not recorded:
+ return None
+ selection = recorded[0]
+ total = _agent_eval_count(selection.get("total")) if isinstance(selection, dict) else 0
+ selected = _agent_eval_count(selection.get("selected")) if isinstance(selection, dict) else 0
+ if any(value != selection for value in recorded) or not 0 < selected <= total:
+ return "Tier 3 case selection metadata is missing, invalid, or contradictory."
+ if selected < total:
+ return (
+ f"Tier 3 ran only the first {selected} of {total} cases (max_cases); "
+ "a partial suite is not publication evidence."
+ )
+ return None
+
+
def agent_eval_publication_evidence_complete(payload: dict[str, Any] | None) -> bool:
"""Return whether a payload carries the minimum publication Tier 3 evidence."""
if not isinstance(payload, dict):
@@ -1420,6 +1441,7 @@ def agent_eval_publication_evidence_complete(payload: dict[str, Any] | None) ->
and publication_target is not None
and publication_target.skill_name == skill_name
and agent_eval_publication_run_id(payload) is not None
+ and agent_eval_case_selection_issue(payload) is None
)
@@ -2239,7 +2261,8 @@ def assess_tier3_evidence(
execution_status,
raw_verdict,
selected_payload,
- "Tier 3 ran but lacks publication-complete provenance or dimension evidence.",
+ agent_eval_case_selection_issue(selected_payload)
+ or "Tier 3 ran but lacks publication-complete provenance or dimension evidence.",
)
return Tier3EvidenceAssessment(
"incomplete" if tier3_results or selected_payload else "not_run",
diff --git a/src/skillevaluator/tier3/commands.py b/src/skillevaluator/tier3/commands.py
index f414ad5f..e84b68dd 100644
--- a/src/skillevaluator/tier3/commands.py
+++ b/src/skillevaluator/tier3/commands.py
@@ -667,6 +667,7 @@ def evaluate(
stop_on_pass: bool | None = None,
n_concurrent: int | None,
max_agents: int | None,
+ max_cases: int | None = None,
model: str | None,
agent_model: tuple[str, ...],
custom_dockerfile_mode: str | None,
@@ -749,6 +750,7 @@ def evaluate(
stop_on_pass=stop_on_pass,
n_concurrent=n_concurrent,
max_agents=max_agents,
+ max_cases=max_cases,
model=model,
agent_models=agent_models or None,
custom_dockerfile_mode=custom_dockerfile_mode,
diff --git a/src/skillevaluator/tier3/evals_config.py b/src/skillevaluator/tier3/evals_config.py
index c90b2613..00cfb019 100644
--- a/src/skillevaluator/tier3/evals_config.py
+++ b/src/skillevaluator/tier3/evals_config.py
@@ -43,6 +43,7 @@ _HARBOR_KEYS = {
"stop_on_pass",
"n_concurrent",
"max_agents",
+ "max_cases",
"timeout_multiplier",
"agent_runtime_preflight",
"agent_workdir",
@@ -209,6 +210,8 @@ def _validate_config(raw: dict[str, Any], config_path: Path) -> dict[str, Any]:
harbor["n_concurrent"] = _int_at_least(harbor_raw["n_concurrent"], 1, config_path, "harbor.n_concurrent")
if "max_agents" in harbor_raw:
harbor["max_agents"] = _int_at_least(harbor_raw["max_agents"], 1, config_path, "harbor.max_agents")
+ if "max_cases" in harbor_raw:
+ harbor["max_cases"] = _int_at_least(harbor_raw["max_cases"], 1, config_path, "harbor.max_cases")
if "timeout_multiplier" in harbor_raw:
harbor["timeout_multiplier"] = _float_greater_than(
harbor_raw["timeout_multiplier"],
diff --git a/src/skillevaluator/tier3/evals_spec.py b/src/skillevaluator/tier3/evals_spec.py
index dc617479..c0ff4b3c 100644
--- a/src/skillevaluator/tier3/evals_spec.py
+++ b/src/skillevaluator/tier3/evals_spec.py
@@ -101,7 +101,7 @@ EVALS_SPEC: list[EntrySpec] = [
formats=[".yml", ".yaml"],
validation_notes=[
"schema_version must be 1.",
- "Supported harbor keys include task_source (auto|evals_json|native_harbor), custom_dockerfile_mode, base_image_mode, n_attempts, pass_threshold, stop_on_pass, n_concurrent, max_agents, timeout_multiplier, agent_runtime_preflight, runtime_env, pre_agent_setup, and agents.<name>.model.",
+ "Supported harbor keys include task_source (auto|evals_json|native_harbor), custom_dockerfile_mode, base_image_mode, n_attempts, pass_threshold, stop_on_pass, n_concurrent, max_agents, max_cases, timeout_multiplier, agent_runtime_preflight, runtime_env, pre_agent_setup, and agents.<name>.model.",
"passthrough_env and setup_commands are accepted as compatibility aliases for runtime_env and pre_agent_setup.",
"Supported skill_workspace keys: mode (isolated|group), include.",
"Supported grading keys: mode (default|default_plus_custom|custom_only).",
diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.py
index 3c3c3999..56079543 100644
--- a/src/skillevaluator/tier3/harbor/runner.py
+++ b/src/skillevaluator/tier3/harbor/runner.py
@@ -3238,6 +3238,41 @@ def _workspace_skills(skill_path: Path, values: list[str | Path]) -> list[Path]:
return resolved
+def _limit_staged_cases(
+ task_selectors: list[str],
+ case_id_by_task_selector: Mapping[str, str],
+ staged_task_paths: Iterable[Path],
+ *,
+ max_cases: int,
+) -> dict[str, Any]:
+ """Remove staged cases after the first ``max_cases`` and describe the selection.
+
+ Harbor discovers local dataset tasks from their directories, so pruning the
+ unselected task directories from every agent's with-skill and baseline
+ datasets limits what runs. This happens before the dataset snapshot and the
+ collector's expected cases are derived, so both describe exactly the cases
+ that ran. The staged ``dataset.toml`` is not read by ``harbor run`` and is
+ left as staged.
+ """
+ selected = task_selectors[:max_cases]
+ skipped = set(task_selectors[max_cases:])
+ for task_path in staged_task_paths:
+ if task_path.name not in skipped:
+ continue
+ if task_path.is_dir() and not task_path.is_symlink():
+ shutil.rmtree(task_path)
+ else:
+ task_path.unlink(missing_ok=True)
+ return {
+ "policy": "first_n",
+ "limit": max_cases,
+ "total": len(task_selectors),
+ "selected": len(selected),
+ "skipped": len(task_selectors) - len(selected),
+ "selected_ids": [case_id_by_task_selector[selector] for selector in selected],
+ }
+
+
def _task_timeout_plan(task_roots: list[Path], timeout_multiplier: float) -> float | None:
"""Return the largest staged agent timeout after applying Harbor scaling."""
timeouts: list[float] = []
@@ -4550,6 +4585,7 @@ def _run_harbor_eval_impl(
stop_on_pass: bool | None = None,
n_concurrent: int | None = None,
max_agents: int | None = None,
+ max_cases: int | None = None,
model: str | None = None,
agent_models: dict[str, str | list[str]] | None = None,
custom_dockerfile_mode: str | None = None,
@@ -4629,6 +4665,7 @@ def _run_harbor_eval_impl(
stop_on_pass = stop_on_pass if stop_on_pass is not None else harbor_config.get("stop_on_pass", False)
n_concurrent = n_concurrent if n_concurrent is not None else harbor_config.get("n_concurrent", 4)
max_agents = max_agents if max_agents is not None else harbor_config.get("max_agents", len(agents))
+ max_cases = max_cases if max_cases is not None else harbor_config.get("max_cases")
timeout_multiplier = (
timeout_multiplier if timeout_multiplier is not None else harbor_config.get("timeout_multiplier", 1.0)
)
@@ -4672,6 +4709,9 @@ def _run_harbor_eval_impl(
if not isinstance(max_agents, int) or max_agents < 1:
reporter.emit(ProgressEvent(stage="configuration", state="failed", detail="invalid agent concurrency"))
return {"error": ["max_agents must be >= 1"]}
+ if max_cases is not None and (isinstance(max_cases, bool) or not isinstance(max_cases, int) or max_cases < 1):
+ reporter.emit(ProgressEvent(stage="configuration", state="failed", detail="invalid case limit"))
+ return {"error": ["max_cases must be >= 1"]}
try:
timeout_multiplier = _validated_timeout_multiplier(timeout_multiplier)
except ValueError as exc:
@@ -5002,6 +5042,8 @@ def _run_harbor_eval_impl(
# source tree that was evaluated, not the evaluator build that ran it.
"evaluated_source": normalized_evaluated_source(evaluated_source),
}
+ if max_cases is not None:
+ run_config["harbor"]["max_cases"] = max_cases
verifier_env = {**configured_runtime_env, **provider_env}
staged_verifier_env = {
name: f"${{{name}}}"
@@ -5288,6 +5330,34 @@ def _run_harbor_eval_impl(
reporter.emit(ProgressEvent(stage=staging_failure_stage, state="failed", detail=str(exc)))
return _persist_pre_execution_failure([str(exc)])
+ if max_cases is not None:
+ all_task_selectors = expected_task_selectors or []
+ all_case_ids = expected_case_id_by_task_selector or {}
+ try:
+ case_selection = _limit_staged_cases(
+ all_task_selectors,
+ all_case_ids,
+ staged_task_paths,
+ max_cases=max_cases,
+ )
+ except OSError as exc:
+ reporter.emit(ProgressEvent(stage="case-selection", state="failed", detail=str(exc)))
+ return _persist_pre_execution_failure([str(exc)])
+ expected_task_selectors = all_task_selectors[:max_cases]
+ expected_case_id_by_task_selector = {selector: all_case_ids[selector] for selector in expected_task_selectors}
+ staged_task_paths = [path for path in staged_task_paths if path.name in expected_case_id_by_task_selector]
+ run_config["case_selection"] = case_selection
+ reporter.emit(
+ ProgressEvent(
+ stage="case-selection",
+ state="complete",
+ detail=(
+ f"running the first {case_selection['selected']} of {case_selection['total']} cases "
+ f"(max_cases={max_cases})"
+ ),
+ )
+ )
+
if not _runtime_context_is_bound_to_publication_target(
skill_path,
staged_task_paths,
diff --git a/src/skillevaluator/tier3/workflow.py b/src/skillevaluator/tier3/workflow.py
index cb1573f9..34b3f7cc 100644
--- a/src/skillevaluator/tier3/workflow.py
+++ b/src/skillevaluator/tier3/workflow.py
@@ -129,6 +129,7 @@ def _preflight_options(skill_path: Path, params: dict[str, Any]) -> dict[str, An
"stop_on_pass",
"n_concurrent",
"max_agents",
+ "max_cases",
"timeout_multiplier",
"agent_runtime_preflight",
"custom_dockerfile_mode",
diff --git a/tests/golden/cli_surface.json b/tests/golden/cli_surface.json
index 760d91c1..293cf70d 100644
--- a/tests/golden/cli_surface.json
+++ b/tests/golden/cli_surface.json
@@ -478,6 +478,14 @@
"param_type": "option",
"type": "integer"
},
+ {
+ "name": "max_cases",
+ "opts": [
+ "--max-cases"
+ ],
+ "param_type": "option",
+ "type": "integer range"
+ },
{
"name": "model",
"opts": [
@@ -2382,6 +2390,14 @@
"param_type": "option",
"type": "integer"
},
+ {
+ "name": "max_cases",
+ "opts": [
+ "--max-cases"
+ ],
+ "param_type": "option",
+ "type": "integer range"
+ },
{
"name": "model",
"opts": [
@@ -2898,6 +2914,14 @@
"param_type": "option",
"type": "integer"
},
+ {
+ "name": "max_cases",
+ "opts": [
+ "--max-cases"
+ ],
+ "param_type": "option",
+ "type": "integer range"
+ },
{
"name": "model",
"opts": [
@@ -3397,6 +3421,14 @@
"param_type": "option",
"type": "integer"
},
+ {
+ "name": "max_cases",
+ "opts": [
+ "--max-cases"
+ ],
+ "param_type": "option",
+ "type": "integer range"
+ },
{
"name": "n_attempts",
"opts": [
diff --git a/tests/reporting/test_advisory_skip_verdict.py b/tests/reporting/test_advisory_skip_verdict.py
index 3a008881..aa97579c 100644
--- a/tests/reporting/test_advisory_skip_verdict.py
+++ b/tests/reporting/test_advisory_skip_verdict.py
@@ -2805,6 +2805,56 @@ def test_succeeded_under_scored_attempts_cannot_certify_publication(tmp_path: Pa
_assert_publication_incomplete_across_reporters(results, tmp_path)
+def test_partial_case_selection_cannot_certify_publication(tmp_path: Path) -> None:
+ results = _publication_ready_results("MAX-CASES")
+ payload = results[-1].metadata["agent_eval"]
+ selection = {"policy": "first_n", "limit": 1, "total": 3, "selected": 1, "skipped": 2}
+ payload["case_selection"] = dict(selection)
+ payload["summary"]["case_selection"] = dict(selection)
+
+ _assert_publication_incomplete_across_reporters(results, tmp_path)
+ json_payload = json.loads(JSONReporter(include_timestamp=False).render_all(results))
+ benchmark = BenchmarkReporter(include_timestamp=False).render_all(results)
+ assert "first 1 of 3 cases" in json_payload["publication"]["tier3"]["reason"]
+ assert json_payload["publication"]["tier3"]["status"] == "pass"
+ assert "first 1 of 3 cases" in benchmark
+
+
+ ("payload_selection", "summary_selection"),
+ [
+ ({"total": 3, "selected": 3}, {"total": 3, "selected": 2}),
+ ({"total": 3, "selected": 4}, {"total": 3, "selected": 4}),
+ ("first_n", "first_n"),
+ ],
+ ids=["contradictory", "over-selected", "malformed"],
+)
+def test_invalid_case_selection_cannot_certify_publication(
+ tmp_path: Path,
+ payload_selection: object,
+ summary_selection: object,
+) -> None:
+ results = _publication_ready_results("MAX-CASES-INVALID")
+ payload = results[-1].metadata["agent_eval"]
+ payload["case_selection"] = payload_selection
+ payload["summary"]["case_selection"] = summary_selection
+
+ _assert_publication_incomplete_across_reporters(results, tmp_path)
+
+
+def test_case_limit_covering_the_whole_suite_remains_publication_evidence() -> None:
+ results = _publication_ready_results("MAX-CASES-FULL")
+ payload = results[-1].metadata["agent_eval"]
+ selection = {"policy": "first_n", "limit": 10, "total": 3, "selected": 3, "skipped": 0}
+ payload["case_selection"] = dict(selection)
+ payload["summary"]["case_selection"] = dict(selection)
+
+ json_payload = json.loads(JSONReporter(include_timestamp=False).render_all(results))
+
+ assert agent_eval_publication_evidence_complete(payload) is True
+ assert json_payload["publication_status"] == "pass"
+
+
@pytest.mark.parametrize("agent_status", ["failed", "skipped", "incomplete", "unknown", None])
def test_non_succeeded_agent_peer_cannot_certify_publication(
tmp_path: Path,
diff --git a/tests/test_tier3_max_cases.py b/tests/test_tier3_max_cases.py
new file mode 100644
index 00000000..3b152942
--- /dev/null
+++ b/tests/test_tier3_max_cases.py
@@ -0,0 +1,312 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Opt-in ``max_cases`` limit for Tier 3 runs.
+
+Unset, every staged case runs. When set, only the first N staged cases run in
+every agent's with-skill and baseline datasets, and the persisted dataset
+snapshot, collector expectations and run config all describe that subset.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+from typing import Any
+
+import pytest
+from click.testing import CliRunner
+
+from skillevaluator.cli import cli
+from skillevaluator.evaluation.tier3_report import build_agent_eval_payload
+from skillevaluator.provider_config import ProviderConfig
+from skillevaluator.tier3.evals_config import EvalsConfigError, load_evals_config
+from skillevaluator.tier3.harbor import runner, runtime_preflight
+
+CASES = ("case-001", "case-002", "case-003", "case-004", "case-005")
+FIXTURE = Path(__file__).parent / "fixtures" / "skills" / "simple"
+
+
+def _provider() -> ProviderConfig:
+ return ProviderConfig(
+ provider="nv_build",
+ model="test-model",
+ api_key="provider-key",
+ base_url="https://provider.example/v1",
+ litellm_model="openai/test-model",
+ )
+
+
+def _run_engine(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+ config_yaml: str = "schema_version: 1\nharbor:\n task_source: evals_json\n",
+ **engine_kwargs: Any,
+) -> tuple[dict[str, Any], dict[str, Any]]:
+ """Run ``run_harbor_eval`` over five staged cases with the Harbor edges mocked."""
+ skill = tmp_path / "demo"
+ (skill / "evals").mkdir(parents=True)
+ (skill / "evals" / "config.yml").write_text(config_yaml, encoding="utf-8")
+
+ captured: dict[str, Any] = {"pairs": [], "collect": {}, "progress": []}
+
+ monkeypatch.setattr(runner, "resolve_llm_provider", _provider)
+ monkeypatch.setattr(runner, "find_evals_file", lambda _path: skill / "evals" / "evals.json")
+ monkeypatch.setattr(runner, "_check_prerequisites", lambda **_kwargs: [])
+
+ def emit(_skill: Path, target: Path, **_kwargs: Any) -> list[Path]:
+ tasks = []
+ for case_id in CASES:
+ task = target / case_id
+ (task / "tests").mkdir(parents=True)
+ (task / "tests" / "entry.json").write_text(json.dumps({"id": case_id}), encoding="utf-8")
+ tasks.append(task)
+ return tasks
+
+ def pair(**kwargs: Any) -> list[str]:
+ datasets = [kwargs["with_skill"], kwargs["baseline"]]
+ captured["pairs"].append(
+ {
+ "task_names": kwargs["task_names"],
+ "expected_trials": kwargs["expected_trials"],
+ "staged": [sorted(path.name for path in dataset.iterdir() if path.is_dir()) for dataset in datasets],
+ }
+ )
+ return []
+
+ def collect(**kwargs: Any) -> dict[str, Any]:
+ captured["collect"] = kwargs
+ return {"execution_status": "succeeded", "execution_errors": [], "metrics": [], "agents": {}}
+
+ class _Reporter:
+ is_active = False
+
+ def start(self, _plan: Any) -> None:
+ pass
+
+ def set_secret_values(self, _values: Any) -> None:
+ pass
+
+ def emit(self, event: Any) -> None:
+ captured["progress"].append((event.stage, event.state, event.detail))
+
+ def heartbeat(self) -> None:
+ pass
+
+ def close(self) -> None:
+ pass
+
+ monkeypatch.setattr(runner, "generate_harbor_tasks", emit)
+ monkeypatch.setattr(runner, "_run_agent_pair", pair)
+ monkeypatch.setattr(runner, "collect_harbor_results", collect)
+ monkeypatch.setattr(runner, "render_agent_eval_html_report", lambda *_args, **_kwargs: tmp_path / "report.html")
+ monkeypatch.setattr(
+ runtime_preflight,
+ "probe_model",
+ lambda selected_provider: runtime_preflight.ModelProbeResult(
+ True,
+ selected_provider.provider,
+ selected_provider.model,
+ f"model {selected_provider.model} is available",
+ ),
+ )
+ result = runner.run_harbor_eval(
+ skill,
+ engine_kwargs.pop("agents", ["opencode", "codex"]),
+ output_dir=tmp_path / "results",
+ env_mode="docker",
+ agent_runtime_preflight=False,
+ keep_harbor_jobs=True,
+ progress_reporter=_Reporter(),
+ **engine_kwargs,
+ )
+ return result, captured
+
+
+def _snapshot_ids(result: dict[str, Any]) -> list[str]:
+ snapshot = json.loads(Path(result["dataset_snapshot_path"]).read_text(encoding="utf-8"))
+ return [entry["id"] for entry in snapshot["dataset"]]
+
+
+def test_unset_max_cases_runs_every_staged_case(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
+ result, captured = _run_engine(monkeypatch, tmp_path)
+
+ assert "error" not in result
+ assert "case_selection" not in result["run_config"]
+ assert "max_cases" not in result["run_config"]["harbor"]
+ assert captured["collect"]["expected_case_ids"] == list(CASES)
+ assert all(pair["task_names"] == list(CASES) for pair in captured["pairs"])
+ assert not any(stage == "case-selection" for stage, _state, _detail in captured["progress"])
+
+
+def test_max_cases_runs_only_the_first_cases_in_every_dataset(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+) -> None:
+ result, captured = _run_engine(monkeypatch, tmp_path, max_cases=2)
+
+ assert "error" not in result
+ selected = ["case-001", "case-002"]
+ assert len(captured["pairs"]) == 2
+ for pair in captured["pairs"]:
+ assert pair["task_names"] == selected
+ assert pair["expected_trials"] == 2
+ # Harbor discovers local tasks from the dataset directory, so the
+ # unselected cases must be gone from both arms of every agent.
+ assert pair["staged"] == [selected, selected]
+ assert captured["collect"]["expected_cases"] == 2
+ assert captured["collect"]["expected_case_ids"] == selected
+ assert captured["collect"]["case_id_by_task_selector"] == {case: case for case in selected}
+ assert _snapshot_ids(result) == selected
+ assert result["dataset_summary"]["total_tasks"] == 2
+ assert result["run_config"]["harbor"]["max_cases"] == 2
+ assert result["run_config"]["case_selection"] == {
+ "policy": "first_n",
+ "limit": 2,
+ "total": 5,
+ "selected": 2,
+ "skipped": 3,
+ "selected_ids": selected,
+ }
+ persisted = json.loads((Path(result["run_dir"]) / "run_config.json").read_text(encoding="utf-8"))
+ assert persisted["case_selection"] == result["run_config"]["case_selection"]
+ assert ("case-selection", "complete", "running the first 2 of 5 cases (max_cases=2)") in captured["progress"]
+
+
+def test_max_cases_from_config_applies_and_cli_value_overrides_it(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+) -> None:
+ config = "schema_version: 1\nharbor:\n task_source: evals_json\n max_cases: 3\n"
+
+ configured, configured_capture = _run_engine(monkeypatch, tmp_path / "config", config)
+ overridden, overridden_capture = _run_engine(monkeypatch, tmp_path / "cli", config, max_cases=1)
+
+ assert configured_capture["collect"]["expected_case_ids"] == ["case-001", "case-002", "case-003"]
+ assert configured["run_config"]["case_selection"]["skipped"] == 2
+ assert overridden_capture["collect"]["expected_case_ids"] == ["case-001"]
+ assert overridden["run_config"]["case_selection"]["limit"] == 1
+
+
+def test_max_cases_larger_than_the_suite_keeps_every_case(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
+ result, captured = _run_engine(monkeypatch, tmp_path, max_cases=10)
+
+ assert captured["collect"]["expected_case_ids"] == list(CASES)
+ assert _snapshot_ids(result) == list(CASES)
+ assert result["run_config"]["case_selection"]["selected"] == 5
+ assert result["run_config"]["case_selection"]["skipped"] == 0
+
+
[email protected]("value", [0, -3, True])
+def test_invalid_max_cases_is_rejected_before_staging(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+ value: object,
+) -> None:
+ result, captured = _run_engine(monkeypatch, tmp_path, max_cases=value)
+
+ assert result["error"] == ["max_cases must be >= 1"]
+ assert captured["pairs"] == []
+
+
+def test_max_cases_is_configurable_per_skill(tmp_path: Path) -> None:
+ skill = tmp_path / "skill"
+ (skill / "evals").mkdir(parents=True)
+ config_path = skill / "evals" / "config.yml"
+
+ config_path.write_text("schema_version: 1\nharbor:\n max_cases: 6\n", encoding="utf-8")
+ config, _path = load_evals_config(skill)
+ assert config["harbor"]["max_cases"] == 6
+
+ for invalid in ("0", "true", "two"):
+ config_path.write_text(f"schema_version: 1\nharbor:\n max_cases: {invalid}\n", encoding="utf-8")
+ with pytest.raises(EvalsConfigError, match=r"harbor\.max_cases"):
+ load_evals_config(skill)
+
+
+def test_payload_carries_the_recorded_case_selection() -> None:
+ agents = {
+ "codex": {
+ "model": "test-model",
+ "execution_status": "succeeded",
+ "with_skill": {"overall": 0.8},
+ "without_skill": {"overall": 0.4},
+ }
+ }
+ selection = {"policy": "first_n", "limit": 2, "total": 5, "selected": 2, "skipped": 3, "selected_ids": ["a", "b"]}
+
+ limited = build_agent_eval_payload("demo", agents, run_config={"case_selection": selection})
+ unlimited = build_agent_eval_payload("demo", agents, run_config={})
+
+ expected = {"policy": "first_n", "limit": 2, "total": 5, "selected": 2, "skipped": 3}
+ assert limited is not None
+ assert limited["case_selection"] == expected
+ assert limited["summary"]["case_selection"] == expected
+ assert unlimited is not None
+ assert "case_selection" not in unlimited
+ assert "case_selection" not in unlimited["summary"]
+
+
[email protected]("command", [["evaluate"], ["tier3", "evaluate"]])
+def test_evaluate_forwards_max_cases(monkeypatch: pytest.MonkeyPatch, command: list[str]) -> None:
+ from skillevaluator.evaluation import EvaluationService
+
+ captured: dict[str, Any] = {}
+
+ def _fake_evaluate(self, options, *, progress_reporter=None):
+ captured["options"] = options
+ return {"execution_status": "succeeded", "execution_errors": []}
+
+ monkeypatch.setattr(EvaluationService, "evaluate", _fake_evaluate, raising=True)
+ result = CliRunner().invoke(cli, [*command, str(FIXTURE), "--progress", "off", "--max-cases", "3"])
+
+ assert result.exit_code == 0, result.output
+ assert captured["options"].engine_kwargs()["max_cases"] == 3
+
+
+def test_evaluate_rejects_a_non_positive_max_cases(monkeypatch: pytest.MonkeyPatch) -> None:
+ from skillevaluator.evaluation import EvaluationService
+
+ def _unreachable(self, options, *, progress_reporter=None):
+ raise AssertionError("the engine must not run with an invalid case limit")
+
+ monkeypatch.setattr(EvaluationService, "evaluate", _unreachable, raising=True)
+ result = CliRunner().invoke(cli, ["tier3", "evaluate", str(FIXTURE), "--max-cases", "0"])
+
+ assert result.exit_code == 2
+ assert "Invalid value for '--max-cases'" in result.output
+
+
+def test_validate_forwards_max_cases(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
+ from skillevaluator import cli as cli_module
+ from skillevaluator.models.result import ValidationResult
+
+ captured: dict[str, Any] = {}
+
+ def _tier3(*_args: Any, **kwargs: Any) -> ValidationResult:
+ captured.update(kwargs)
+ result = ValidationResult(validator_name="AGENT_EVAL")
+ result.add_success("agent_eval", "ok")
+ return result
+
+ monkeypatch.setattr(cli_module, "_run_agent_eval_or_skip", _tier3)
+ result = CliRunner().invoke(
+ cli,
+ [
+ "validate",
+ "--no-autopilot",
+ str(FIXTURE),
+ "--no-llm",
+ "--no-tier2",
+ "--tier3",
+ "--max-cases",
+ "4",
+ "--checks",
+ "schema",
+ "--output-dir",
+ str(tmp_path / "reports"),
+ ],
+ )
+
+ assert result.exit_code == 0, result.output
+ assert captured["max_cases"] == 4