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(tier3): use one overall-score formula (#124)

Narendran Raghavan488f4fec03ed
diff --git a/CHANGELOG.md b/CHANGELOG.md
index db55af5f..9d13e6e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -119,9 +119,258 @@ All notable changes to SkillEvaluator are documented in this file.
two votes and could reverse the reported lift direction. Current artifacts
persist `skill-evaluator-dimension-mean-v1`; legacy and partial artifacts
retain their historical semantics. Conditions keep their own recorded metric
- sets; overall lift and best-agent rankings are omitted across incomparable
- metric sets while individual scores are preserved
+ sets; overall lift and best-agent rankings are omitted across different
+ standard metric sets while individual scores are preserved, and
+ `tier3 compare` refuses standard agents with different policies or metric
+ sets. Custom-only agents keep their grader's own overall and are ranked and
+ compared against standard agents
(Relates to [#61](https://github.com/NVIDIA/SkillEvaluator/issues/61)).
+- Preserve explicit Claude and OpenCode read failure metadata in reconstructed
+ ATIF trajectories. Failed isolated SKILL.md reads and failed native Skill
+ calls lose credit; compound shell failures and shell reads whose path may
+ expand to several files (braces, globs, `$` or backticks) remain ambiguous
+ and retain prior credit in host and verifier grading. Unattributed errors do
+ not cancel successful reads, and shell reads count dash-prefixed filenames
+ after `--`.
+- Tier 1 pyproject dependency audits now inspect static target declarations
+ rather than the evaluator environment. Exact direct pins (including optional
+ groups) are queried without installation or build-script execution;
+ unresolved declarations and invalid scanner evidence are incomplete.
+- Tier 1 PII scanning now includes `.mdc` rules and workflows.
+- Tier 3 negative-case accuracy excludes inapplicable skill identification and
+ records its scoring policy. Reports separately expose measured token and
+ agent execution-time differences with complete matching-arm coverage, while
+ efficiency continues to measure routing and productive tool use.
+- Derive accuracy scores from complete criterion verdicts in both judge
+ runtimes (passing applicable criteria divided by applicable criteria), so an
+ inconsistent model-supplied total cannot distort Skill Lift. Correct the
+ Harbor prompt example to score five passing criteria as 1.0.
+- Include schema-valid ATIF message content parts in final answers, conversation
+ summaries, and judge evidence references in the host and Harbor verifier.
+ Image and audio parts use markers without exposing their source paths.
+- Preserve scored Harbor trials when agent answers mention authentication errors
+ and per-step token usage is present but aggregate ATIF token metrics are absent
+ or zero. Explicit runtime exceptions and error events still invalidate trials.
+- Safety-classifier refusals, content filters and output-token truncation are
+ detected instead of being read as empty or malformed output. `--llm-verify`
+ and rubric evaluation report the cause, and `--llm-verify` keeps the
+ complete verdicts of a truncated reply. Claude 5.5 or later requests to the
+ native Claude API use server-side fallback to Claude Opus 4.8. In the Harbor
+ verifier, Bedrock retries a filtered Claude 5.5 reply on Claude Opus 4.8, and
+ a refusal or empty judge reply moves on to the next
+ `LLM_JUDGE_FALLBACK_MODELS` entry.
+- The Harbor verifier's last-resort judge model follows the selected provider.
+ With no judge or chat model configured, it used to request an OpenAI model
+ from Anthropic, Bedrock, NVIDIA Build and gateways. The unused host-side
+ `llm_judge.DEFAULT_JUDGE_MODEL` constant is removed.
+- Fixed Docker Codex and Claude Code setup wasting its timeout installing
+ distribution Node/npm before Harbor's own installers. Native, gateway Codex,
+ and NVIDIA Build agents now provision Node/npm only on the installer branches
+ that need them, while preserving installed-agent and version-pin checks.
+- Preserved multiline skill descriptions when saving and loading Tier 2
+ embedding catalogs. Descriptions can contain line breaks and tabs, while
+ catalog identifiers and other control characters remain strictly validated.
+- Brought the published documentation in line with 0.5.0. It now covers how
+ standard grading builds judge evidence and rebuilds trajectories from
+ OpenCode and Codex logs, structured judge output and retries, the evidence
+ budget and judge time-budget variables, and the Harbor process environment.
+ The CLI reference adds `validate --workers`, the full `--env-mode` list, and
+ the exit codes the CLI actually returns (`0`, `1`, `2`).
+- `BENCHMARK.md` publication verdicts now require completed Tier 1 and Tier 2
+ execution evidence by default (Tier 1 must cover every default check that
+ applies to the content type, so a run narrowed with `--checks` cannot
+ certify publication), conservatively resolve conflicting peer
+ policy and Tier 3 result metadata, bind every tier and policy claim to one
+ versioned source-tree digest, preserve the Tier 3 run ID, persist an explicit
+ publication status in JSON and HTML, and reject
+ publication `PASS` cards whose decision evidence is missing, incomplete,
+ linked, or hidden in raw HTML. Tier 3 evidence now cross-checks complete
+ per-condition attempt and error records, and the public-card gate rejects
+ ambiguous structural headings, browser-rendered decision-text aliases, and
+ literal or entity-encoded Unicode control/format characters. The source
+ identity is read without following links before and after each producer,
+ follows the host filesystem's case aliases, and records a bounded
+ source-change marker. Tier 3 runs that stage repository context, external
+ reference or workspace skills, or task inputs with `.git`, `.venv`,
+ `__pycache__`, or `node_modules` entries remain runnable but cannot certify
+ publication, and neither can a target whose authored paths below the root
+ use names that Tier 1 skips (such as `references/results/`).
+- Clean and not-applicable License, Code Risk, Secrets, and Dependency Audit
+ runs now record structured execution evidence, so legitimate built-in Tier 1
+ results can satisfy publication without relying on findings or errors.
+- Skip reasons are bounded, control-free, and escaped in reports and in the
+ terminal, so oversized metadata, Rich markup, or terminal escape sequences
+ cannot corrupt them. Reports show one line; the pipeline view keeps the
+ reason's line breaks.
+- SkillSpector issue paths with NUL bytes or lone surrogates now make the
+ security scan incomplete instead of being accepted.
+- The public benchmark gate rejects `PASS` cards with placeholder identities,
+ malformed or future evaluation dates, a missing Tier 3 run ID, hostile
+ benchmark-policy metadata, or environment-label substitutions in required
+ proof fields.
+- Hardened Tier 3 HTML and Markdown reporting against recursive or malformed
+ display metadata, Markdown structure injection, and inline-JavaScript
+ injection through untrusted agent or skill names.
+
+## 0.5.0 - 2026-10-06
+
+### Added
+
+- Transparent HTTP 429 (rate-limiting), transient 5xx, and timeout recovery for
+ LLM judges in both the Harbor container verifier (`eval.py`) and host runtime
+ (`LLMClient`). Features zero-dependency full jitter exponential backoff,
+ RFC-7231 `Retry-After` header parsing, finite-value environment overrides
+ (`SKILL_EVAL_LLM_MAX_RETRIES`, `SKILL_EVAL_LLM_RETRY_BASE_DELAY`, and
+ `SKILL_EVAL_LLM_RETRY_MAX_DELAY`), and
+ automatic container forwarding via Harbor `task.toml`, and a per-judge
+ verifier time budget that leaves room for failure artifacts, without altering
+ benchmark metrics or scoring formulas.
+- Provider-aware structured JSON schema enforcement (`response_format` for
+ OpenAI-compatible / Gemini Vertex / NVIDIA NIM endpoints and `output_config`
+ for Anthropic `/v1/messages`) across the custom `judge_accuracy`,
+ `judge_goal_accuracy`, and `judge_behavior_check` paths, with automatic
+ schema-specific `HTTP 400`/`422` downgrade and per-target memoization
+ (`_SCHEMA_UNSUPPORTED_TARGETS`), boolean prompt alignment, and a guard for
+ missing `message` fields on reasoning token exhaustion. The canonical OpenAI
+ RAGAS goal scorer retains its separate scoring path.
+- Configurable evidence bundle budgets (`SKILL_EVAL_ACCURACY_BUDGET`, `SKILL_EVAL_GOAL_ACCURACY_BUDGET`, `SKILL_EVAL_BEHAVIOR_CHECK_BUDGET`) and final response limit (`SKILL_EVAL_BEHAVIOR_FINAL_RESPONSE_LIMIT`).
+- Tier 3 log converters now rebuild ATIF trajectories from OpenCode JSON streams
+ (`opencode.txt`) and structured Codex tee logs (`codex.txt`) when
+ `trajectory.json` is missing or empty.
+
+### Changed
+
+- Upgraded the optional Tier 3 backend to Harbor 0.24.0 and its compatible
+ LiteLLM 1.92-1.93 window. Existing SkillEvaluator agent and environment
+ options now use Harbor's unified selectors; installed Codex adapters preserve
+ merged user and MCP configuration; Docker and local execution stream redacted
+ callbacks under a shared 16 MiB per-command output limit, while the parent
+ Harbor orchestration process has a separate 16 MiB combined stdout/stderr
+ limit; and Docker supports stdin plus isolated sidecar operations without
+ exposing environment values on Compose argv. Generated schema 1.3 and
+ unmodified native task schemas remain compatible, while collection accepts
+ Harbor 0.24 job, trial, reward, and ATIF v1.8 artifacts. Multimodal tool
+ output reaches judges and reports as text with `[image]`/`[audio]` markers.
+ Native tasks' own test scripts must write numeric `reward.json` values, which
+ Harbor 0.24 enforces; a failed job now names the trial or step exception that
+ Harbor recorded.
+- Exposed 23 Harbor 0.24 backends alongside local mode. `cua-cloud`,
+ `opensandbox`, `hf-sandbox`, `podman`, `kata`, `runta`, `prime`, `mosaic`,
+ and `smol` remain disabled until generated tasks can be projected through a
+ trusted image or backend-native provisioning path. Non-secret backend
+ constructor options can be supplied with repeatable, operator-only
+ `--environment-kwarg` / `--ek` flags; skill-owned configuration,
+ credentials, and sandbox-policy overrides remain outside that surface.
+ Harbor's `stream` and `enable_environment_dir_upload` options are reserved,
+ and Modal's `modal_sandbox_v2` option no longer exists.
+- `--env-mode wandb` now runs Harbor's `cwsandbox` backend with W&B
+ authentication, because Harbor 0.24 merged the two. Install
+ `harbor[cwsandbox]==0.24.0` instead of the removed `harbor[wandb]` extra.
+- Harbor now always starts in an empty, evaluator-owned working directory with
+ `.env` loading and Harbor telemetry disabled. A `.env.local` or `.env` file
+ near the operator's project can no longer add credentials or settings that
+ SkillEvaluator's allowlisted environment removed. The `tier3` extra requires
+ python-dotenv 1.2.0.
+- Codex runs with `reasoning_effort=high`, the default under Harbor 0.22, so
+ scores and cost stay comparable after Harbor stopped pinning it.
+- Native tasks follow Harbor 0.24's separate-verifier precedence. A dedicated
+ verifier image or build definition must ship its own test script and never
+ receives SkillEvaluator's grader. Otherwise the verifier is built from
+ `environment/`, whose Compose model must stay within the verifier's
+ environment allowlist. `docker-compose.yml` verifier definitions, which
+ Harbor ignores, are rejected.
+
+### Fixed
+
+- Report non-string YAML keys as validation errors in skills, rules, workflows,
+ and plugin manifests instead of raising a `TypeError`, including frontmatter
+ `metadata` keys. Show boolean, null, and date keys in a readable YAML form.
+- Harbor ``result.json`` case ids now prefer canonical ``task_id.path`` metadata
+ over repository-prefixed ``task_name`` values when resolving eval entries.
+- Codex log synthesis maps ``web_search`` action payloads and ``collab_tool_call``
+ thread items into ATIF, and error-recovery checks recognize ``status=failed`` /
+ ``exit_code=`` terminal evidence emitted by Codex converters.
+- Tier 3 Harbor dual-arm evaluation propagates arm suffixes (`-with-skill`,
+ `-without-skill`) to `[task] name` in staged native `task.toml` files,
+ normalizes external repository and namespace prefixes, and commutatively
+ resolves canonical case IDs across attempt and arm suffix combinations
+ while preserving expected case IDs.
+- Tier 3 native-task collection now keeps Harbor's staged directory selector,
+ logical dataset ID, and display name separate; ambiguous or unresolved
+ persisted identities fail closed instead of trusting grader-authored IDs.
+ Runner-owned attempt ordinals are carried structurally, so `attempt`-like
+ text in authored selectors, logical IDs, or display names cannot corrupt
+ pass@k or `stop_on_pass` accounting, including truncated aggregate names.
+- Tier 3 Harbor subprocess, Docker, and local diagnostics now redact raw and
+ percent-decoded URI/proxy userinfo components across streamed callbacks,
+ nonzero exits, timeouts, output limits, and persisted launch errors.
+- Tier 3 local OpenCode runs routed through NVIDIA Build now retain the rendered
+ user instruction for ATIF conversion and fail on OpenCode error events, in
+ parity with Harbor's upstream agent lifecycle. Remote MCP servers in that
+ configuration disable OAuth, as Harbor's own OpenCode configuration does.
+- Tier 3 reports now use the collector's logical attempt overall whenever a
+ condition mixes standard and custom rewards, including across separate
+ trials, and aggregate execution summaries preserve child-declared hidden
+ error counts and truncation through launch-error overlays.
+- Tier 3 now rejects non-finite, overflowing, and finite-but-unscalable timeout
+ multipliers at YAML, programmatic, and Harbor command boundaries.
+- Tier 3 now preserves paired baseline isolation by rejecting skill-owned
+ pre-agent setup, native task/step healthchecks, native step workdir overlays,
+ and Harbor task-shipped prior trajectories whenever the baseline arm is
+ enabled. Native standard grading also fails closed on step test overlays,
+ separate verifier contexts, post-agent collect hooks, and task-controlled
+ verifier executable-path, shell, loader, proxy/TLS, provider, and judge
+ environment controls; exact operator-staged provider/judge placeholders and
+ unrelated verifier variables remain compatible. Operator-configured judge
+ fallback models are forwarded only to standard verifier jobs, not agent or
+ `custom_only` environments. Its Python payload now runs from a replaced
+ evaluator-owned directory in isolated mode. `custom_only`
+ retains Harbor-native collect hooks and Harbor's shared/separate
+ step-test resolution, and fully authored native test paths are left untouched
+ instead of replacing their unused `tests/skill_evaluator/` package.
+ All native grading modes reject Windows agent or effective verifier
+ environments until evaluator projection and verifier scripts are OS-aware.
+- Tier 3 collection now fails closed on unsafe reward identities and malformed
+ custom-metric contracts, publishes exact truncation metadata for bounded
+ case and failure-detail samples, and keeps findings, attribution, and
+ per-trial JSON inside the report loader's artifact envelope.
+- Tier 3 progress output, diagnostics, and result summaries no longer redact
+ counts such as `0/1 scored` or `1 errored` when a credential-named
+ environment variable holds a short flag value such as `1`. Short credential
+ fragments in proxy URLs are still redacted.
+- `create-eval-dataset --refine` no longer requires the `tier3` extra to read
+ case IDs from Harbor result files, and no longer fails on multimodal
+ trajectory messages.
+
+## 0.4.0 - 2026-09-30
+
+### Fixed
+
+- Render untrusted skill content, paths, tool messages, and LLM output literally
+ in CLI reports and logs. Escape Rich markup and strip terminal control
+ sequences to prevent rendering failures and misleading output, including
+ catalog summaries and the compact validation view. Preserve Windows paths
+ and literal emoji codes
+ ([#173](https://github.com/NVIDIA/SkillEvaluator/pull/173),
+ [#175](https://github.com/NVIDIA/SkillEvaluator/pull/175)).
+- Make sensitive-assignment, JWT, and private-key redaction linear-time,
+ preventing long adversarial text from stalling logs and reports. Apply the
+ JWT fix to Tier 3 command output and the bundled Harbor verifier
+ ([#172](https://github.com/NVIDIA/SkillEvaluator/pull/172),
+ [#176](https://github.com/NVIDIA/SkillEvaluator/pull/176)).
+- `--no-llm` full datasets include a negative bucket only when eval guidance
+ supplies an off-skill prompt; template mode no longer guesses canned
+ negatives from a fixed question list. CLI and docs now describe `--full` as
+ up to four cases instead of always four.
+- Treat `apply_patch` file headers (`*** Add File:`, `*** Update File:`, `*** Delete File:`,
+ `*** Move to:`) as write targets in the Tier 3 security check. A patch that targets a shell
+ profile, SSH, credential, or privileged config path, sent as an `apply_patch` tool call or a
+ shell heredoc, is now a critical `sensitive_file_write` finding whose evidence names the
+ protected path, not the patch. Every header in the patch is checked.
+- Mask GitHub tokens (`ghp_`, `gho_`, `ghu_`, `ghs_`, `ghr_`, and `github_pat_`) in Tier 3
+ evidence excerpts and Harbor verifier log output.
+- Stop the PII scan reporting User-Agent product versions such as `Chrome/140.0.0.0`
+ as public IP addresses. Chromium's reduced User-Agent gives every version this shape.
- Separate Tier 2 collection limits from the 256-file per-skill limit. Fresh
similarity scans now allow 1,024 selected manifests and 128 million scalar
comparisons by default, covering 343 skills with 2,048-dimensional embeddings.
@@ -341,14 +590,46 @@ All notable changes to SkillEvaluator are documented in this file.
### Fixed
-- Tier 3 now uses one versioned, equal-weight five-dimension overall-score
- policy across Harbor rewards, pass@k, Skill Lift, reports, comparisons, and
- best-agent selection. Previously, some paths averaged all six evaluators
- directly while reports averaged five dimensions, which gave Effectiveness
- two votes and could reverse the reported lift direction. Current artifacts
- persist `skill-evaluator-dimension-mean-v1`; legacy and partial artifacts
- retain their historical semantics
- (Relates to [#61](https://github.com/NVIDIA/SkillEvaluator/issues/61)).
+- Fully covered documentation-only skills no longer fail security validation
+ solely because non-applicable SkillSpector analyzers report a partial status
+ ([#137](https://github.com/NVIDIA/SkillEvaluator/issues/137)).
+- Embedding chunking now rejects zero-sized or non-progressing windows before
+ entering the splitter or contacting the embedding provider
+ ([#139](https://github.com/NVIDIA/SkillEvaluator/issues/139)).
+- Scoped network exfiltration command flag patterns in security checks, enforcing command-position anchoring, quote-aware argument segmentation, explicit HTTP method flags, and case-sensitive `-F`/`-d`/`-T` flags to prevent false-positive flags on safe URLs, packages, or download scripts while reliably detecting quoted secrets and subshell wrappers.
+- Malformed, non-UTF-8, or unreadable bundled and custom policy files now
+ produce path-specific CLI errors instead of leaking raw parser or I/O errors
+ ([#128](https://github.com/NVIDIA/SkillEvaluator/issues/128)).
+- `create-eval-dataset --refine` resolves Harbor trial case ids from persisted
+ `reward.json` `entry_id` metadata, using folder-name parsing only as an
+ unambiguous legacy fallback.
+- Tier 3 local mode now drops evaluator-managed empty process-loader resets
+ while continuing to reject non-empty loader overrides, allowing generated
+ tasks to reach agent execution
+ ([#132](https://github.com/NVIDIA/SkillEvaluator/issues/132)).
+- Unpinned-dependency warnings are no longer suppressed by comparison
+ operators inside PEP 508 environment markers; requirements such as
+ `pkg; python_version < "3.13"` are now correctly reported, while direct
+ references are treated as pinned independently of marker contents.
+- Schema, frontmatter, quality parsing, and security PII scanning accept a leading
+ UTF-8 BOM, matching the unicode scanner's "benign BOM" note
+ ([#91](https://github.com/NVIDIA/SkillEvaluator/issues/91)).
+- SPDX headers keep the full license expression, so `MIT OR GPL-3.0` is
+ no longer truncated to MIT and allowed. Closing comment markers such as
+ `*/` and `-->` are not treated as part of the expression
+ ([#86](https://github.com/NVIDIA/SkillEvaluator/issues/86)).
+- Windows personal-path PII now flags `C:\Users\...` usernames that start with
+ `s` (for example `steve`), matching the intended whitespace class rather than
+ excluding the letter `s` ([#87](https://github.com/NVIDIA/SkillEvaluator/issues/87)).
+- Quality scoring, script lint, and `create-eval-dataset` now treat `tools/`
+ the same as `scripts/` for executable helpers.
+- License detection no longer treats a frontmatter `license` identifier as
+ authoritative when a LICENSE file declares a different license. Claiming
+ MIT while shipping GPL-3.0 now fails closed. Every LICENSE/COPYING file is
+ reconciled, NOTICE files stay informational, an unidentified license file is
+ not treated as absent, and a blocking conflict no longer publishes
+ `license_status=allowed`
+ ([#85](https://github.com/NVIDIA/SkillEvaluator/issues/85)).
- `--llm-verify` now refuses to send file context from paths outside the
skill root, including `..`, absolute paths, and outbound file symlinks.
- Gitleaks path allowlist now skips test/example/fixture/mock directories
diff --git a/docs/reports.mdx b/docs/reports.mdx
index c6e8393a..5d9efcce 100644
--- a/docs/reports.mdx
+++ b/docs/reports.mdx
@@ -405,8 +405,12 @@ set. A shared policy name alone does not make five-metric and six-metric means
comparable. When two conditions use different metric sets under the same
policy, their individual scores and shared per-metric deltas remain available,
but overall Skill Lift and the pass@k comparison are omitted. Reports containing
-agents scored on different metric sets retain their individual scores and mark
-the overall comparison as incomplete, without selecting a best agent.
+agents scored on different standard metric sets retain their individual scores
+and mark the overall comparison as incomplete, without selecting a best agent.
+A custom-only agent, one whose conditions use only its grader's own overall
+(`custom-overall-v1`), is still ranked against standard agents by that score,
+and `tier3 compare` shows it beside them. `tier3 compare` refuses standard
+agents scored under different policies or metric sets.
### Skill Lift
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py
index 4ef06e4a..4121a597 100644
--- a/src/skillevaluator/evaluation/tier3_report.py
+++ b/src/skillevaluator/evaluation/tier3_report.py
@@ -103,6 +103,15 @@ def _skill_lift_value(value: object) -> float | None:
return numeric if numeric is not None and -1.0 <= numeric <= 1.0 else None
+def _token_counter(value: object) -> int | None:
+ """Return one browser-safe token count, preserving unavailable as null."""
+ return (
+ value
+ if isinstance(value, int) and not isinstance(value, bool) and 0 <= value <= _MAX_JSON_SAFE_INTEGER
+ else None
+ )
+
+
def _sanitize_json_numbers(value: Any) -> Any:
"""Copy a payload while replacing numbers browsers cannot represent safely."""
if isinstance(value, bool):
@@ -246,6 +255,7 @@ def _advisory_agent_eval_payload(
"dataset_digest": None,
"dataset_digest_algorithm": None,
"score_policy": attempt_policy["score_policy"],
+ "evaluated_source": None,
"verdict_policy": verdict_policy,
"execution_status": "skipped",
"execution_errors": [message],
@@ -286,6 +296,7 @@ def _advisory_agent_eval_payload(
"dataset_digest": None,
"dataset_digest_algorithm": None,
"score_policy": attempt_policy["score_policy"],
+ "evaluated_source": None,
"verdict_policy": verdict_policy,
"provenance": {
"source": "advisory",
@@ -472,6 +483,11 @@ def agent_eval_result_from_directory(
run_truth = _run_truth_metadata(run_dir, engine_result, load_dataset_snapshot(run_dir))
dataset = run_truth.get("dataset") or load_staged_harbor_dataset(run_dir)
attempt_policy = _read_attempt_policy(run_dir)
+ publication_target = run_truth.get("publication_target")
+ persisted_skill_name = publication_target.get("skill_name") if isinstance(publication_target, dict) else None
+ skill_name = (
+ persisted_skill_name if isinstance(persisted_skill_name, str) and persisted_skill_name else skill_path.name
+ )
payload = build_agent_eval_payload(
skill_name,
agents,
@@ -600,6 +616,10 @@ def build_agent_eval_payload(
dataset_digest: str | None = None,
dataset_digest_algorithm: str | None = None,
historical_missing_score_policy: bool = False,
+ run_id: str | None = None,
+ publication_target: dict[str, str] | None = None,
+ publication_target_conflict: str | None = None,
+ evaluated_source: dict[str, Any] | None = None,
use_llm_judge: bool = True,
) -> dict[str, Any] | None:
"""Assemble the canonical Tier 3 ``agent_eval`` payload from loaded agent data.
@@ -618,11 +638,17 @@ def build_agent_eval_payload(
from skillevaluator.tier3.harbor.report_data import (
build_dataset_snapshot,
deduplicate_dataset_entries,
+ metrics_for_agents,
metrics_for_condition,
)
- metrics = metrics_for_agents(agents)
- policy_metrics = _policy_metrics_from_agents(agents, metrics)
+ # Custom-only agents publish their grader's own overall under the custom
+ # policy and rank against standard agents. The run-level policy, its
+ # conflict checks and the metric-set comparison cover standard agents.
+ custom_only_agents = {name for name, info in agents.items() if _is_custom_only_agent(info)}
+ policy_agents = {name: info for name, info in agents.items() if name not in custom_only_agents} or agents
+ metrics = metrics_for_agents(policy_agents)
+ policy_metrics = _policy_metrics_from_agents(policy_agents, metrics)
from skillevaluator.tier3.harbor.metrics import (
CUSTOM_SCORE_POLICY,
@@ -636,7 +662,7 @@ def build_agent_eval_payload(
if not attempt_policy:
policy.pop("score_definition", None)
policy.pop("score_policy", None)
- recorded_policies = _recorded_score_policies(agents)
+ recorded_policies = _recorded_score_policies(policy_agents)
stored_policy = policy.get("score_policy")
if isinstance(stored_policy, str) and stored_policy.strip():
policy["score_policy"] = stored_policy.strip()
@@ -660,12 +686,29 @@ def build_agent_eval_payload(
for name in sorted(agents):
info = agents[name]
model = _agent_model(name, info, run_config)
- agent_payloads[name] = _build_agent(name, info, metrics, model, policy["score_policy"])
+ agent_payloads[name] = _build_agent(
+ name,
+ info,
+ metrics_for_condition(info, "with_skill"),
+ metrics_for_condition(info, "without_skill"),
+ model,
+ CUSTOM_SCORE_POLICY if name in custom_only_agents else policy["score_policy"],
+ )
if not agent_payloads:
return None
- best_agent = "" if conflicting_policies else _pick_best_agent(agent_payloads)
+ scored_metric_sets = {
+ frozenset(agent["metrics_with_skill"])
+ for name, agent in agent_payloads.items()
+ if name not in custom_only_agents
+ and agent["execution_status"] == "succeeded"
+ and agent["with_skill"] is not None
+ }
+ conflicting_metric_sets = len(scored_metric_sets) > 1
+ if conflicting_metric_sets and not conflicting_policies:
+ policy["score_definition"] = "overall unavailable: incomparable metric sets across agents"
+ best_agent = "" if conflicting_policies or conflicting_metric_sets else _pick_best_agent(agent_payloads)
detail_priority = ([best_agent] if best_agent else []) + [name for name in agent_payloads if name != best_agent]
for name in detail_priority:
_attach_agent_report_details(
@@ -680,7 +723,6 @@ def build_agent_eval_payload(
str(error) for agent in agent_payloads.values() for error in agent.get("execution_errors", []) if error
)
)
- execution_error_details = _aggregate_execution_error_details(agent_payloads, len(execution_errors))
statuses = [agent.get("execution_status") for agent in agent_payloads.values()]
if statuses and all(status == "succeeded" for status in statuses):
execution_status = "succeeded"
@@ -695,12 +737,17 @@ def build_agent_eval_payload(
execution_errors.append(
"Conflicting score policies across scored conditions: " + ", ".join(sorted(recorded_policies))
)
+ elif conflicting_metric_sets:
+ execution_status = "failed"
+ execution_errors.append("Incomparable metric sets across scored agents; overall ranking is unavailable")
elif policy["score_policy"] not in SUPPORTED_SCORE_POLICIES and any(
agent.get("execution_status") == "succeeded" and agent.get("with_skill") is None
for agent in agent_payloads.values()
):
execution_status = "failed"
execution_errors.append("Unsupported score policy has no persisted overall score")
+ # Count score-policy errors appended above as displayed diagnostics.
+ execution_error_details = _aggregate_execution_error_details(agent_payloads, len(execution_errors))
raw_overall_score = best.get("with_skill")
overall_score = _finite_float(raw_overall_score) if execution_status == "succeeded" else None
@@ -750,6 +797,9 @@ def build_agent_eval_payload(
"dataset_digest": effective_dataset_digest,
"dataset_digest_algorithm": effective_dataset_digest_algorithm,
"score_policy": policy["score_policy"],
+ "run_id": run_id,
+ "publication_target": dict(publication_target) if isinstance(publication_target, dict) else None,
+ "evaluated_source": effective_evaluated_source,
"verdict_policy": verdict_policy,
"execution_status": execution_status,
"execution_errors": execution_errors,
@@ -814,6 +864,9 @@ def build_agent_eval_payload(
"dataset_digest": effective_dataset_digest,
"dataset_digest_algorithm": effective_dataset_digest_algorithm,
"score_policy": policy["score_policy"],
+ "run_id": run_id,
+ "publication_target": dict(publication_target) if isinstance(publication_target, dict) else None,
+ "evaluated_source": effective_evaluated_source,
"verdict_policy": verdict_policy,
"agents": agent_payloads,
"dimensions": best_dimensions,
@@ -1354,6 +1407,21 @@ def _policy_metrics_from_agents(
return available or tuple(metrics)
+def _is_custom_only_agent(info: dict[str, Any]) -> bool:
+ """Return whether every condition of an agent is scored only by its custom grader."""
+ from skillevaluator.tier3.harbor.metrics import CUSTOM_SCORE_POLICY
+ from skillevaluator.tier3.harbor.report_data import metrics_for_condition
+
+ recorded = {
+ policy.strip()
+ for condition in ("with_skill", "without_skill")
+ if isinstance(policy := info.get(f"score_policy_{condition}"), str) and policy.strip()
+ }
+ if recorded:
+ return recorded == {CUSTOM_SCORE_POLICY}
+ return not metrics_for_condition(info, "with_skill") and not metrics_for_condition(info, "without_skill")
+
+
def _recorded_score_policies(agents: dict[str, dict[str, Any]]) -> set[str]:
recorded: set[str] = set()
for info in agents.values():
@@ -1428,17 +1496,14 @@ def _build_agent(
PARTIAL_SCORE_POLICY,
overall_score_from_metrics,
)
- from skillevaluator.tier3.harbor.report_data import metrics_for_condition
with_scores = info.get("with_skill") or {}
without_scores = info.get("without_skill") or {}
- with_metrics = metrics_for_condition(info, "with_skill")
- without_metrics = metrics_for_condition(info, "without_skill")
condition_policies = {
value.strip() if isinstance(value, str) and value.strip() else score_policy
for value in (info.get("score_policy_with_skill"), info.get("score_policy_without_skill"))
}
- comparable_scores = set(with_metrics) == set(without_metrics) and len(condition_policies) == 1
+ comparable_scores = set(with_metrics) == set(baseline_metrics) and len(condition_policies) == 1
lift_data = info.get("lift") or {}
with_quality_available = _condition_quality_available(info, "with_skill")
baseline_quality_available = _condition_quality_available(info, "without_skill")
@@ -1459,8 +1524,8 @@ def _build_agent(
overall_ws = None
overall_bl = None
if score_policy == LEGACY_SCORE_POLICY:
- overall_ws = _complete_metric_mean(with_scores, metrics) if with_quality_available else None
- overall_bl = _complete_metric_mean(without_scores, metrics) if baseline_quality_available else None
+ overall_ws = _complete_metric_mean(with_scores, with_metrics) if with_quality_available else None
+ overall_bl = _complete_metric_mean(without_scores, baseline_metrics) if baseline_quality_available else None
if overall_ws is None and not with_scores and with_quality_available:
overall_ws = _unit_interval_score(info.get("overall_with_skill"))
if overall_bl is None and not without_scores and baseline_quality_available:
@@ -1469,10 +1534,9 @@ def _build_agent(
overall_ws = overall_score_from_metrics(with_scores, DEFAULT_METRICS) if with_quality_available else None
overall_bl = overall_score_from_metrics(without_scores, DEFAULT_METRICS) if baseline_quality_available else None
elif score_policy == PARTIAL_SCORE_POLICY:
- selected_metrics = tuple(metrics)
- overall_ws = overall_score_from_metrics(with_scores, selected_metrics) if with_quality_available else None
+ overall_ws = overall_score_from_metrics(with_scores, tuple(with_metrics)) if with_quality_available else None
overall_bl = (
- overall_score_from_metrics(without_scores, selected_metrics) if baseline_quality_available else None
+ overall_score_from_metrics(without_scores, tuple(baseline_metrics)) if baseline_quality_available else None
)
if overall_ws is None:
overall_ws = _mean(with_dimension_values)
@@ -1485,29 +1549,64 @@ def _build_agent(
}:
overall_ws = _unit_interval_score(info.get("overall_with_skill")) if with_quality_available else None
overall_bl = _unit_interval_score(info.get("overall_without_skill")) if baseline_quality_available else None
- if overall_ws is None and not metrics and with_quality_available and score_policy == CUSTOM_SCORE_POLICY:
+ with_mixed_contract = with_quality_available and _condition_has_mixed_metric_contracts(
+ info,
+ flag="mixed_metric_contracts_with_skill",
+ rewards="rewards",
+ )
+ baseline_mixed_contract = baseline_quality_available and _condition_has_mixed_metric_contracts(
+ info,
+ flag="mixed_metric_contracts_without_skill",
+ rewards="rewards_baseline",
+ )
+ custom_with = score_policy == CUSTOM_SCORE_POLICY and overall_ws is None and not with_metrics
+ custom_baseline = score_policy == CUSTOM_SCORE_POLICY and overall_bl is None and not baseline_metrics
+ if with_mixed_contract or (custom_with and with_quality_available):
+ # Custom-only runs have no dimension mean. For mixed condition
+ # contracts, the standard-metric overall covers only standard rows and
+ # can overstate Harbor's logical attempt score used by pass@k. In both
+ # cases, prefer the collector-owned logical overall.
overall_ws = _unit_interval_score(info.get("overall_with_skill"))
if overall_ws is None and info.get("rewards_complete") is not False:
overall_ws = _logical_reward_mean(info.get("rewards"), "overall")
- if overall_bl is None and not metrics and baseline_quality_available and score_policy == CUSTOM_SCORE_POLICY:
+ if baseline_mixed_contract or (custom_baseline and baseline_quality_available):
overall_bl = _unit_interval_score(info.get("overall_without_skill"))
if overall_bl is None and info.get("rewards_baseline_complete") is not False:
overall_bl = _logical_reward_mean(info.get("rewards_baseline"), "overall")
- overall_lift = round(overall_ws - overall_bl, 4) if overall_ws is not None and overall_bl is not None else None
- if score_policy == LEGACY_SCORE_POLICY and overall_lift is not None and metrics:
- with_values = tuple(_unit_interval_score(with_scores.get(metric)) for metric in metrics)
- baseline_values = tuple(_unit_interval_score(without_scores.get(metric)) for metric in metrics)
+ overall_lift = (
+ round(overall_ws - overall_bl, 4)
+ if comparable_scores and overall_ws is not None and overall_bl is not None
+ else None
+ )
+ if score_policy == LEGACY_SCORE_POLICY and overall_lift is not None and with_metrics:
+ with_values = tuple(_unit_interval_score(with_scores.get(metric)) for metric in with_metrics)
+ baseline_values = tuple(_unit_interval_score(without_scores.get(metric)) for metric in with_metrics)
if all(value is not None for value in (*with_values, *baseline_values)):
# Historical lift subtracted the unrounded metric means. Recompute
# that value from trusted metrics instead of a mutable lift artifact.
overall_lift = round(
- sum(w - b for w, b in zip(with_values, baseline_values, strict=True)) / len(metrics),
+ sum(w - b for w, b in zip(with_values, baseline_values, strict=True)) / len(with_metrics),
4,
)
- trials = _normalize_trials(info.get("rewards") or [], metrics)
- baseline_trials = _normalize_trials(info.get("rewards_baseline") or [], metrics)
- _attach_baseline_pairs(trials, baseline_trials, metrics, comparable_overall=comparable_scores)
+ trials = _normalize_trials(info.get("rewards") or [], with_metrics)
+ baseline_trials = _normalize_trials(info.get("rewards_baseline") or [], baseline_metrics)
+ _attach_baseline_pairs(trials, baseline_trials, with_metrics, comparable_overall=comparable_scores)
+ from skillevaluator.tier3.harbor.resource_usage import resource_comparison
+
+ resources = resource_comparison(
+ trials,
+ baseline_trials,
+ with_complete=with_quality_available and info.get("rewards_complete") is True,
+ baseline_complete=baseline_quality_available and info.get("rewards_baseline_complete") is True,
+ )
+
+ execution_errors = (
+ [str(error) for error in info.get("execution_errors", [])]
+ if isinstance(info.get("execution_errors"), list)
+ else []
+ )
+ execution_error_details = _aggregate_execution_error_details({name: info}, len(execution_errors))
return {
"name": name,
@@ -1529,7 +1628,7 @@ def _build_agent(
"baseline": overall_bl,
"lift": overall_lift,
"metrics_with_skill": with_metrics,
- "metrics_without_skill": without_metrics,
+ "metrics_without_skill": baseline_metrics,
"num_trials": int(info.get("num_trials", 0) or 0),
"num_trials_baseline": int(info.get("num_trials_baseline", len(baseline_trials)) or 0),
"trials": trials,
@@ -2893,7 +2992,26 @@ def _canonical_agent_rank(agent: dict[str, Any]) -> tuple[float, float] | None:
return score, _as_float(agent.get("lift"))
-def _canonical_agent_rank_from_info(info: dict[str, Any]) -> tuple[float, float] | None:
+def _agent_score_policy(info: dict[str, Any]) -> str:
+ """Return the with-skill score policy used to rank one agent's raw Harbor data.
+
+ A recorded policy wins. Artifacts without one use the policy for their
+ with-skill metric set, as ``build_agent_eval_payload`` does.
+ """
+ from skillevaluator.tier3.harbor.metrics import score_policy_for_metrics
+ from skillevaluator.tier3.harbor.report_data import metrics_for_condition
+
+ recorded = info.get("score_policy_with_skill")
+ if isinstance(recorded, str) and recorded.strip():
+ return recorded.strip()
+ metrics = metrics_for_condition(info, "with_skill")
+ return score_policy_for_metrics(_policy_metrics_from_agents({"agent": info}, metrics))
+
+
+def _canonical_agent_rank_from_info(
+ info: dict[str, Any],
+ score_policy: str | None = None,
+) -> tuple[float, float] | None:
"""Build and rank raw Harbor agent data exactly as the canonical report does."""
from skillevaluator.tier3.harbor.report_data import metrics_for_condition
@@ -2903,6 +3021,7 @@ def _canonical_agent_rank_from_info(info: dict[str, Any]) -> tuple[float, float]
metrics_for_condition(info, "with_skill"),
metrics_for_condition(info, "without_skill"),
None,
+ score_policy or _agent_score_policy(info),
)
return _canonical_agent_rank(agent)
diff --git a/src/skillevaluator/tier3/commands.py b/src/skillevaluator/tier3/commands.py
index b30f56c0..9bd2fbbd 100644
--- a/src/skillevaluator/tier3/commands.py
+++ b/src/skillevaluator/tier3/commands.py
@@ -38,9 +38,12 @@ from skillevaluator.tier3.harbor import (
canonical_agent_name,
)
from skillevaluator.tier3.harbor.metrics import (
+ CUSTOM_ONLY_METRIC_SET,
CUSTOM_SCORE_POLICY,
+ DEFAULT_METRIC_SET,
DEFAULT_METRICS,
DEFAULT_SCORE_POLICY,
+ LEGACY_METRIC_SET,
LEGACY_METRICS,
LEGACY_SCORE_POLICY,
PARTIAL_SCORE_POLICY,
@@ -1080,11 +1083,15 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> int
"num_trials": data.get("num_trials", "?"),
"overall_with_skill": overall,
"score_policy_with_skill": _summary_score_policy(data),
+ "standard_metrics": _summary_standard_metrics(data),
+ "custom_only": _summaries_are_custom_only([data]),
}
wo_summary = agent_dir / "without-skill" / "summary.json"
if wo_summary.exists():
try:
wo_data = json.loads(wo_summary.read_text(encoding="utf-8"))
+ if isinstance(wo_data, dict):
+ root_meta[agent_name]["custom_only"] = _summaries_are_custom_only([data, wo_data])
wo_scores = _summary_scores(
wo_data,
allow_missing_status=allow_missing_status,
@@ -1118,9 +1125,12 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> int
return 1
agents = sorted(agent_with)
+ # Custom-only agents are compared by their grader's own overall, as in the
+ # canonical report. Standard agents must share one policy and metric set.
+ standard_agents = [agent for agent in agents if not agent_meta[agent].get("custom_only")]
comparison_policies = {
_effective_compare_policy(agent_meta[agent].get("score_policy_with_skill"), agent_with[agent])
- for agent in agents
+ for agent in standard_agents
}
if len(comparison_policies) > 1:
console.print(
@@ -1128,6 +1138,13 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> int
"Rerun the agents under one policy.[/red]"
)
return 1
+ comparison_metric_sets = {agent_meta[agent].get("standard_metrics") for agent in standard_agents}
+ if len(comparison_metric_sets) > 1:
+ console.print(
+ "[red]Cannot compare overall scores across agents scored on different metric sets. "
+ "Rerun the agents with one metric set.[/red]"
+ )
+ return 1
display_metrics, overall_metrics = _display_metrics(agent_with)
table = Table(show_header=True, header_style="bold dim", box=SIMPLE, padding=(0, 1), show_edge=False, expand=True)
@@ -1253,6 +1270,33 @@ def _summary_score_policy(data: dict[str, Any]) -> str | None:
return value.strip() if isinstance(value, str) and value.strip() else None
+def _summary_standard_metrics(data: dict[str, Any]) -> frozenset[str]:
+ """Return the standard metric set one condition summary declares."""
+ metrics = data.get("metrics")
+ if isinstance(metrics, list):
+ return frozenset(str(metric) for metric in metrics)
+ metric_set = data.get("metric_set")
+ if metric_set == DEFAULT_METRIC_SET:
+ return frozenset(DEFAULT_METRICS)
+ if metric_set == LEGACY_METRIC_SET:
+ return frozenset(LEGACY_METRICS)
+ if metric_set == CUSTOM_ONLY_METRIC_SET:
+ return frozenset()
+ scores = data.get("scores")
+ return frozenset(metric for metric in DEFAULT_METRICS if isinstance(scores, dict) and metric in scores)
+
+
+def _summaries_are_custom_only(summaries: list[dict[str, Any]]) -> bool:
+ """Return whether every condition of an agent is scored only by its custom grader.
+
+ Recorded policies win; without them, no condition may declare standard metrics.
+ """
+ recorded = {policy for summary in summaries if (policy := _summary_score_policy(summary))}
+ if recorded:
+ return recorded == {CUSTOM_SCORE_POLICY}
+ return not any(_summary_standard_metrics(summary) for summary in summaries)
+
+
def _effective_compare_policy(policy: object, scores: dict[str, float]) -> str:
"""Treat unversioned complete SkillEvaluator summaries as historical scores."""
if isinstance(policy, str) and policy.strip():
diff --git a/src/skillevaluator/tier3/harbor/collector.py b/src/skillevaluator/tier3/harbor/collector.py
index 0d791326..756e5b33 100644
--- a/src/skillevaluator/tier3/harbor/collector.py
+++ b/src/skillevaluator/tier3/harbor/collector.py
@@ -32,12 +32,16 @@ from skillevaluator.tier3.eval_core.checks import check_negative_case
from skillevaluator.tier3.eval_core.codex_tool_call_normalizer import atif_content_text
from skillevaluator.tier3.harbor.metrics import (
CUSTOM_ONLY_METRIC_SET,
+ CUSTOM_SCORE_POLICY,
DEFAULT_METRIC_SET,
DEFAULT_METRICS,
DEFAULT_SCORE_POLICY,
LEGACY_METRIC_SET,
LEGACY_METRICS,
LEGACY_SCORE_POLICY,
+ MAX_CUSTOM_METRICS,
+ RESERVED_METRIC_NAMES,
+ CustomMetricContractError,
average_custom_metrics,
average_metrics,
custom_metric_contract_error,
@@ -48,8 +52,10 @@ from skillevaluator.tier3.harbor.metrics import (
metric_value,
overall_score,
overall_score_from_metrics,
+ rewards_have_mixed_metric_contracts,
score_definition,
score_policy_for_metrics,
+ score_value,
)
from skillevaluator.tier3.output_provenance import write_output_file_atomically
from skillevaluator.tier3.toml_utils import extract_toml_metadata_entry_id
@@ -4516,11 +4522,13 @@ def _logical_attempt_rewards(rewards: list[dict[str, Any]]) -> list[dict[str, An
logical_reward["custom_metrics"] = custom_scores
if (overall := _average_overall(rows)) is not None:
logical_reward["overall"] = overall
+ logical_reward["_logical_overall"] = overall
logical_policy, policy_ambiguous = _score_policy_for_rewards(rows, metrics)
if not policy_ambiguous:
logical_reward["score_policy"] = logical_policy
if logical_policy == "mixed-score-policies":
logical_reward.pop("overall", None)
+ logical_reward.pop("_logical_overall", None)
if any(row.get("_has_trajectory") for row in rows):
logical_reward["_has_trajectory"] = True
# Keep every step's judge models so lift can spot a judge fallback in any step.
@@ -4981,12 +4989,15 @@ def _compute_lift(
with_rewards: list[dict[str, Any]] | None = None,
without_rewards: list[dict[str, Any]] | None = None,
expected_case_ids: list[str] | None = None,
+ *,
+ score_policy: str | None = None,
) -> dict[str, Any]:
"""Compute skill lift (with-skill minus without-skill) per metric.
With the per-trial rewards, a case whose arms were judged by different
models (a judge fallback in one arm) is left out of that judge metric's
- lift and counted in ``judge_mixed_cases``.
+ lift and counted in ``judge_mixed_cases``. The overall lift aggregates the
+ paired metric scores with the conditions' score policy.
"""
lift: dict[str, Any] = {}
paired_scores: dict[str, tuple[float, float]] = {}
@@ -5018,12 +5029,15 @@ def _compute_lift(
"direction": "up" if delta > 0 else ("down" if delta < 0 else "flat"),
}
metrics = tuple(paired_scores)
- if metrics in {DISPLAY_METRICS, LEGACY_METRICS}:
- overall_with = overall_score_from_metrics(with_scores, metrics)
- overall_without = overall_score_from_metrics(without_scores, metrics)
- else:
- overall_with = None
- overall_without = None
+ overall_with: float | None = None
+ overall_without: float | None = None
+ if metrics in {DISPLAY_METRICS, LEGACY_METRICS} and score_policy == LEGACY_SCORE_POLICY:
+ # Historical artifacts keep their recorded six-metric mean.
+ overall_with = sum(paired_scores[m][0] for m in metrics) / len(metrics)
+ overall_without = sum(paired_scores[m][1] for m in metrics) / len(metrics)
+ elif metrics in {DISPLAY_METRICS, LEGACY_METRICS} and score_policy in {None, score_policy_for_metrics(metrics)}:
+ overall_with = overall_score_from_metrics({m: paired_scores[m][0] for m in metrics}, metrics)
+ overall_without = overall_score_from_metrics({m: paired_scores[m][1] for m in metrics}, metrics)
if overall_with is not None and overall_without is not None:
lift["overall"] = {
"with_skill": round(overall_with, 4),
@@ -5098,9 +5112,18 @@ def _aggregate_condition_overall(
rewards: list[dict[str, Any]],
*,
score_policy: str | None = None,
+ mixed_metric_contracts: bool = False,
) -> float | None:
- """Aggregate a condition consistently with lift and canonical reports."""
- if not metrics or (score_policy is not None and score_policy != score_policy_for_metrics(metrics)):
+ """Aggregate a condition consistently with lift and canonical reports.
+
+ Mixed metric contracts use the logical attempt overall: the standard-metric
+ mean covers only standard rows and would overstate pass@k's attempt score.
+ """
+ if (
+ mixed_metric_contracts
+ or not metrics
+ or (score_policy is not None and score_policy != score_policy_for_metrics(metrics))
+ ):
return _average_overall(rewards)
score = overall_score_from_metrics(scores, metrics)
return round(score, 4) if score is not None else None
@@ -6172,6 +6195,25 @@ def _condition_execution_summary(
}
+def _fail_execution_with_error(execution: dict[str, Any], error: str) -> None:
+ """Fail one execution summary and publish ``error`` within the bounded error contract."""
+ execution["execution_status"] = "failed"
+ errors = execution.get("execution_errors")
+ if not isinstance(errors, list):
+ errors = []
+ execution["execution_errors"] = errors
+ if error in errors:
+ return
+ raw_total = execution.get("execution_error_details_total")
+ total = raw_total if isinstance(raw_total, int) and not isinstance(raw_total, bool) and raw_total >= 0 else 0
+ total = min(_MAX_JSON_SAFE_INTEGER, max(total, len(errors)) + 1)
+ if len(errors) < PUBLISHED_EXECUTION_ERRORS_MAX:
+ errors.append(error)
+ execution["execution_error_details_total"] = total
+ execution["execution_error_details_shown"] = len(errors)
+ execution["execution_error_details_truncated"] = len(errors) < total
+
+
def _aggregate_execution(summaries: list[dict[str, Any]]) -> dict[str, Any]:
"""Aggregate execution status while retaining hidden child error counts.
@@ -6293,6 +6335,8 @@ def collect_harbor_results(
with_overall_score: float | None = None
with_policy = DEFAULT_SCORE_POLICY
with_policy_ambiguous = False
+ with_metrics: tuple[str, ...] = ()
+ with_summary: dict[str, Any] | None = None
with_arm_suffix = "-with-skill" if not skip_baseline else ""
if with_job_dir:
@@ -6353,16 +6397,19 @@ def collect_harbor_results(
pass_threshold=pass_threshold,
)
if with_policy == "mixed-score-policies":
- with_execution["execution_status"] = "failed"
- with_execution.setdefault("execution_errors", []).append(
- "Conflicting score policies within the with-skill condition"
- )
+ _fail_execution_with_error(with_execution, "Conflicting score policies within the with-skill condition")
if with_execution["execution_status"] != "succeeded":
with_scores = {}
with_custom_scores = {}
with_pass = {}
with_overall_score = (
- _aggregate_condition_overall(with_scores, with_metrics, with_logical_rewards, score_policy=with_policy)
+ _aggregate_condition_overall(
+ with_scores,
+ with_metrics,
+ with_logical_rewards,
+ score_policy=with_policy,
+ mixed_metric_contracts=with_mixed_metric_contracts,
+ )
if with_execution["execution_status"] == "succeeded"
else None
)
@@ -6377,28 +6424,32 @@ def collect_harbor_results(
agent_model_source=agent_model_source,
expected_case_ids=expected_case_ids,
)
- (agent_dir / "with-skill" / "summary.json").write_text(
- json.dumps(
- {
- "agent": agent,
- "model": agent_model,
- "model_source": agent_model_source,
- "scores": with_scores,
- "custom_scores": with_custom_scores,
- "overall_score": with_overall_score,
- "metric_set": with_metric_set,
- "metrics": list(with_metrics),
- "score_policy": with_policy,
- "dimensions": dimension_scores(with_scores),
- "num_trials": len(with_rewards),
- "pass_at_k": with_pass,
- **with_execution,
- "job_failure": with_job_failure,
- "trial_failures": with_trial_failures,
- },
- indent=2,
- ),
- encoding="utf-8",
+ with_summary = {
+ "agent": agent,
+ "model": agent_model,
+ "model_source": agent_model_source,
+ "scores": with_scores,
+ "custom_scores": with_custom_scores,
+ "overall_score": with_overall_score,
+ "metric_set": with_metric_set,
+ "metrics": list(with_metrics),
+ "score_policy": with_policy,
+ "dimensions": dimension_scores(with_scores),
+ "num_trials": len(with_logical_rewards),
+ "num_reward_rows": len(with_collected_rewards),
+ "mixed_metric_contracts": with_mixed_metric_contracts,
+ "pass_at_k": _public_pass_summary(with_pass),
+ **with_execution,
+ "job_failure": with_job_failure,
+ "trial_failures": _public_failure_list(with_trial_failures),
+ **_failure_list_metadata("trial_failure_details", with_trial_failures),
+ }
+ _write_generated_root_json(agent_dir / "with-skill" / "summary.json", output_dir, with_summary)
+ logger.debug(
+ "Agent %s with-skill: %d trials, scores=%s",
+ agent,
+ len(with_logical_rewards),
+ with_scores,
)
else:
with_job_failure = f"No Harbor job found for {with_job_name}"
@@ -6483,6 +6534,8 @@ def collect_harbor_results(
without_overall_score: float | None = None
without_policy = DEFAULT_SCORE_POLICY
without_policy_ambiguous = False
+ without_metrics: tuple[str, ...] = ()
+ without_summary: dict[str, Any] | None = None
without_job_dir: Path | None = None
if not skip_baseline:
without_job_name = f"{skill_name}-{agent}-without"
@@ -6541,9 +6594,9 @@ def collect_harbor_results(
pass_threshold=pass_threshold,
)
if without_policy == "mixed-score-policies":
- without_execution["execution_status"] = "failed"
- without_execution.setdefault("execution_errors", []).append(
- "Conflicting score policies within the without-skill condition"
+ _fail_execution_with_error(
+ without_execution,
+ "Conflicting score policies within the without-skill condition",
)
if without_execution["execution_status"] != "succeeded":
without_scores = {}
@@ -6555,6 +6608,7 @@ def collect_harbor_results(
without_metrics,
without_logical_rewards,
score_policy=without_policy,
+ mixed_metric_contracts=without_mixed_metric_contracts,
)
if without_execution["execution_status"] == "succeeded"
else None
@@ -6570,29 +6624,27 @@ def collect_harbor_results(
agent_model_source=agent_model_source,
expected_case_ids=expected_case_ids,
)
- (agent_dir / "without-skill" / "summary.json").write_text(
- json.dumps(
- {
- "agent": agent,
- "model": agent_model,
- "model_source": agent_model_source,
- "scores": without_scores,
- "custom_scores": without_custom_scores,
- "overall_score": without_overall_score,
- "metric_set": without_metric_set,
- "metrics": list(without_metrics),
- "score_policy": without_policy,
- "dimensions": dimension_scores(without_scores),
- "num_trials": len(without_rewards),
- "pass_at_k": without_pass,
- **without_execution,
- "job_failure": without_job_failure,
- "trial_failures": without_trial_failures,
- },
- indent=2,
- ),
- encoding="utf-8",
- )
+ without_summary = {
+ "agent": agent,
+ "model": agent_model,
+ "model_source": agent_model_source,
+ "scores": without_scores,
+ "custom_scores": without_custom_scores,
+ "overall_score": without_overall_score,
+ "metric_set": without_metric_set,
+ "metrics": list(without_metrics),
+ "score_policy": without_policy,
+ "dimensions": dimension_scores(without_scores),
+ "num_trials": len(without_logical_rewards),
+ "num_reward_rows": len(without_collected_rewards),
+ "mixed_metric_contracts": without_mixed_metric_contracts,
+ "pass_at_k": _public_pass_summary(without_pass),
+ **without_execution,
+ "job_failure": without_job_failure,
+ "trial_failures": _public_failure_list(without_trial_failures),
+ **_failure_list_metadata("trial_failure_details", without_trial_failures),
+ }
+ _write_generated_root_json(agent_dir / "without-skill" / "summary.json", output_dir, without_summary)
logger.debug(
"Agent %s without-skill: %d trials, scores=%s",
agent,
@@ -6610,27 +6662,27 @@ def collect_harbor_results(
without_job_failure = _published_job_failure(without_job_failure)
summary_dir = agent_dir / "without-skill"
summary_dir.mkdir(parents=True, exist_ok=True)
- (summary_dir / "summary.json").write_text(
- json.dumps(
- {
- "agent": agent,
- "model": agent_model,
- "model_source": agent_model_source,
- "scores": {},
- "custom_scores": {},
- "overall_score": None,
- "metric_set": DEFAULT_METRIC_SET,
- "metrics": list(DISPLAY_METRICS),
- "score_policy": DEFAULT_SCORE_POLICY,
- "dimensions": {},
- "num_trials": 0,
- "pass_at_k": {},
- "job_failure": without_job_failure,
- "trial_failures": [],
- },
- indent=2,
- ),
- encoding="utf-8",
+ _write_generated_root_json(
+ summary_dir / "summary.json",
+ output_dir,
+ {
+ "agent": agent,
+ "model": agent_model,
+ "model_source": agent_model_source,
+ "scores": {},
+ "custom_scores": {},
+ "overall_score": None,
+ "metric_set": DEFAULT_METRIC_SET,
+ "metrics": list(DISPLAY_METRICS),
+ "score_policy": DEFAULT_SCORE_POLICY,
+ "dimensions": {},
+ "num_trials": 0,
+ "num_reward_rows": 0,
+ "mixed_metric_contracts": False,
+ "pass_at_k": {},
+ "job_failure": without_job_failure,
+ "trial_failures": [],
+ },
)
if not without_execution:
@@ -6648,27 +6700,27 @@ def collect_harbor_results(
if not skip_baseline and without_job_dir is None:
summary_dir = agent_dir / "without-skill"
summary_dir.mkdir(parents=True, exist_ok=True)
- (summary_dir / "summary.json").write_text(
- json.dumps(
- {
- "agent": agent,
- "model": agent_model,
- "model_source": agent_model_source,
- "scores": {},
- "custom_scores": {},
- "overall_score": None,
- "metrics": [],
- "score_policy": DEFAULT_SCORE_POLICY,
- "dimensions": {},
- "num_trials": 0,
- "pass_at_k": {},
- **without_execution,
- "job_failure": without_job_failure,
- "trial_failures": [],
- },
- indent=2,
- ),
- encoding="utf-8",
+ _write_generated_root_json(
+ summary_dir / "summary.json",
+ output_dir,
+ {
+ "agent": agent,
+ "model": agent_model,
+ "model_source": agent_model_source,
+ "scores": {},
+ "custom_scores": {},
+ "overall_score": None,
+ "metrics": [],
+ "score_policy": DEFAULT_SCORE_POLICY,
+ "dimensions": {},
+ "num_trials": 0,
+ "num_reward_rows": 0,
+ "mixed_metric_contracts": False,
+ "pass_at_k": {},
+ **without_execution,
+ "job_failure": without_job_failure,
+ "trial_failures": [],
+ },
)
if (
@@ -6676,19 +6728,22 @@ def collect_harbor_results(
and with_execution.get("execution_status") == "succeeded"
and without_execution.get("execution_status") == "succeeded"
and with_policy != without_policy
+ and set(with_metrics) == set(without_metrics)
):
if with_policy_ambiguous and not without_policy_ambiguous:
with_policy = without_policy
- summary_path = agent_dir / "with-skill" / "summary.json"
- summary = json.loads(summary_path.read_text(encoding="utf-8"))
- summary["score_policy"] = with_policy
- summary_path.write_text(json.dumps(summary, indent=2), encoding="utf-8")
+ if with_summary is not None:
+ with_summary["score_policy"] = with_policy
+ _write_generated_root_json(agent_dir / "with-skill" / "summary.json", output_dir, with_summary)
elif without_policy_ambiguous and not with_policy_ambiguous:
without_policy = with_policy
- summary_path = agent_dir / "without-skill" / "summary.json"
- summary = json.loads(summary_path.read_text(encoding="utf-8"))
- summary["score_policy"] = without_policy
- summary_path.write_text(json.dumps(summary, indent=2), encoding="utf-8")
+ if without_summary is not None:
+ without_summary["score_policy"] = without_policy
+ _write_generated_root_json(
+ agent_dir / "without-skill" / "summary.json",
+ output_dir,
+ without_summary,
+ )
all_results["score_policy"] = with_policy
all_results["attempt_policy"]["score_policy"] = with_policy
if with_job_dir:
@@ -6701,14 +6756,15 @@ def collect_harbor_results(
)
if policy_conflict:
reason = f"Conflicting score policies across conditions: {with_policy}, {without_policy}"
- for condition, execution in (("with-skill", with_execution), ("without-skill", without_execution)):
- execution["execution_status"] = "failed"
- execution.setdefault("execution_errors", []).append(reason)
- summary_path = agent_dir / condition / "summary.json"
- summary = json.loads(summary_path.read_text(encoding="utf-8"))
- summary.update(execution)
- summary.update({"scores": {}, "custom_scores": {}, "overall_score": None, "pass_at_k": {}})
- summary_path.write_text(json.dumps(summary, indent=2), encoding="utf-8")
+ for condition, execution, summary in (
+ ("with-skill", with_execution, with_summary),
+ ("without-skill", without_execution, without_summary),
+ ):
+ _fail_execution_with_error(execution, reason)
+ if summary is not None:
+ summary.update(execution)
+ summary.update({"scores": {}, "custom_scores": {}, "overall_score": None, "pass_at_k": {}})
+ _write_generated_root_json(agent_dir / condition / "summary.json", output_dir, summary)
with_scores = {}
without_scores = {}
with_custom_scores = {}
@@ -6724,17 +6780,34 @@ def collect_harbor_results(
and without_execution.get("execution_status") == "succeeded"
)
if paired_execution_succeeded and with_scores and without_scores:
- lift = _compute_lift(with_scores, without_scores)
- # A score policy must be known for both arms before an overall lift
- # can be published; per-metric deltas remain useful independently.
- lift.pop("overall", None)
- if with_overall_score is not None and without_overall_score is not None:
- lift["overall"] = {
- "with_skill": with_overall_score,
- "without_skill": without_overall_score,
- "delta": round(with_overall_score - without_overall_score, 4),
- }
- (agent_dir / "lift.json").write_text(json.dumps(lift, indent=2), encoding="utf-8")
+ lift = _compute_lift(
+ with_scores,
+ without_scores,
+ with_logical_rewards,
+ without_logical_rewards,
+ expected_case_ids,
+ score_policy=with_policy,
+ )
+ # The policy and scored metric set must match before comparing
+ # overall scores; shared per-metric deltas remain useful separately.
+ judge_aware_overall = lift.pop("overall", None)
+ if (
+ set(with_metrics) == set(without_metrics)
+ and with_overall_score is not None
+ and without_overall_score is not None
+ ):
+ if "judge_mixed_cases" not in lift:
+ lift["overall"] = {
+ "with_skill": with_overall_score,
+ "without_skill": without_overall_score,
+ "delta": round(with_overall_score - without_overall_score, 4),
+ }
+ elif judge_aware_overall is not None and not (
+ with_mixed_metric_contracts or without_mixed_metric_contracts
+ ):
+ # Cases whose arms used different judges stay out of the overall delta.
+ lift["overall"] = judge_aware_overall
+ _write_generated_root_json(agent_dir / "lift.json", output_dir, lift)
custom_lift: dict[str, Any] = {}
if (
@@ -6806,6 +6879,8 @@ def collect_harbor_results(
"without_skill": without_scores,
"overall_with_skill": with_overall_score,
"overall_without_skill": without_overall_score,
+ "metrics_with_skill": list(with_metrics),
+ "metrics_without_skill": list(without_metrics),
"score_policy_with_skill": with_policy,
"score_policy_without_skill": without_policy if not skip_baseline else None,
"custom_with_skill": with_custom_scores,
@@ -6853,7 +6928,10 @@ def collect_harbor_results(
for info in all_results["agents"].values()
if info.get("execution_status") == "succeeded" and info.get("score_policy_with_skill")
}
- run_policy_conflict = len(scored_policies) > 1
+ # Custom-only agents publish their grader's own overall and rank against
+ # standard agents, so only standard score policies can conflict.
+ standard_policies = scored_policies - {CUSTOM_SCORE_POLICY}
+ run_policy_conflict = len(standard_policies) > 1
if run_policy_conflict:
all_results["score_policy"] = "mixed-score-policies"
all_results["attempt_policy"]["score_policy"] = "mixed-score-policies"
@@ -6861,9 +6939,11 @@ def collect_harbor_results(
"overall unavailable: conflicting score policies across agents"
)
elif scored_policies:
- score_policy = next(iter(scored_policies))
+ score_policy = next(iter(standard_policies or scored_policies))
scored_agent = next(
- info for info in all_results["agents"].values() if info.get("execution_status") == "succeeded"
+ info
+ for info in all_results["agents"].values()
+ if info.get("execution_status") == "succeeded" and info.get("score_policy_with_skill") == score_policy
)
selected_metrics = tuple(metric for metric in DEFAULT_METRICS if metric in scored_agent["with_skill"])
all_results["metric_set"] = (
@@ -6884,9 +6964,9 @@ def collect_harbor_results(
top_execution = _aggregate_execution(list(all_results["agents"].values()))
if run_policy_conflict:
- top_execution["execution_status"] = "failed"
- top_execution["execution_errors"].append(
- "Conflicting score policies across agents: " + ", ".join(sorted(scored_policies))
+ _fail_execution_with_error(
+ top_execution,
+ "Conflicting score policies across agents: " + ", ".join(sorted(standard_policies)),
)
all_results.update(top_execution)
if top_execution["execution_errors"]:
diff --git a/src/skillevaluator/tier3/harbor/metrics.py b/src/skillevaluator/tier3/harbor/metrics.py
index b5bdcca3..dbd6beb3 100644
--- a/src/skillevaluator/tier3/harbor/metrics.py
+++ b/src/skillevaluator/tier3/harbor/metrics.py
@@ -6,10 +6,12 @@
from __future__ import annotations
import math
+import re
from collections.abc import Iterable, Mapping
from typing import Any
from skillevaluator.constants import DEFAULT_SCORE_POLICY, DIMENSION_MAPPING
+from skillevaluator.utils.redaction import contains_credential_value, is_sensitive_key
DEFAULT_METRIC_SET = "skill-evaluator-default-v2"
LEGACY_METRIC_SET = "skill-evaluator-default-v1"
@@ -391,9 +393,7 @@ def overall_score(reward: dict[str, Any]) -> float | None:
SkillEvaluator metrics can still pass through by emitting numeric ``overall``.
"""
_, metrics = metric_set_for_reward(reward)
- persisted = _finite_number(reward.get("overall"))
- if persisted is not None and not 0.0 <= persisted <= 1.0:
- persisted = None
+ persisted = score_value(reward.get("overall"))
policy = reward.get("score_policy")
policy = policy.strip() if isinstance(policy, str) and policy.strip() else None
if not metrics:
diff --git a/src/skillevaluator/tier3/harbor/report.py b/src/skillevaluator/tier3/harbor/report.py
index 548ec1b0..aed1fdb8 100644
--- a/src/skillevaluator/tier3/harbor/report.py
+++ b/src/skillevaluator/tier3/harbor/report.py
@@ -20,16 +20,14 @@ from skillevaluator.evidence import evidence_ref_identity
from skillevaluator.tier3.eval_core.llm_judge import _redact_configured_credentials
from skillevaluator.tier3.harbor import report_data
from skillevaluator.tier3.harbor.metrics import (
- DEFAULT_METRIC_SET,
DEFAULT_METRICS,
- LEGACY_METRIC_SET,
- LEGACY_SCORE_POLICY,
+ MAX_CUSTOM_METRICS,
METRIC_DESCRIPTIONS,
METRIC_DISPLAY,
METRIC_QUESTIONS,
extract_custom_metrics,
- overall_score,
- overall_score_from_metrics,
+ metric_set_for_reward,
+ metric_value,
)
from skillevaluator.tier3.output_provenance import write_output_file_atomically
from skillevaluator.utils.redaction import redact_sensitive_data, redact_sensitive_text
@@ -129,9 +127,10 @@ def _pick_best_agent(
from skillevaluator.evaluation.tier3_report import _canonical_agent_rank_from_info
best_agent = ""
- best_score = -1.0
+ best_rank: tuple[float, float] | None = None
scored_metric_sets: set[frozenset[str]] = set()
- for agent, data in agents_data.items():
+ for agent in sorted(agents_data):
+ data = agents_data[agent]
if not _findings_eligible(data):
continue
persisted = persisted_agents.get(agent) if isinstance(persisted_agents, dict) else None
@@ -143,24 +142,17 @@ def _pick_best_agent(
or any(metric_value(with_scores, metric) is None for metric in standard_metrics)
):
continue
- metrics = tuple(m for m in DISPLAY_METRICS if m in with_scores) or DISPLAY_METRICS
- if data.get("score_policy_with_skill") == LEGACY_SCORE_POLICY:
- overall = overall_score(
- {
- "metric_set": DEFAULT_METRIC_SET if "security" in with_scores else LEGACY_METRIC_SET,
- "score_policy": LEGACY_SCORE_POLICY,
- **with_scores,
- }
- )
- else:
- overall = overall_score_from_metrics(with_scores, metrics)
- if overall is None:
+ rank = _canonical_agent_rank_from_info(ranking_data)
+ if rank is None:
continue
- scored_metric_sets.add(frozenset(metrics))
+ # Overall scores from different standard metric sets cannot be ranked
+ # against each other. Custom-only agents rank by their grader's overall.
+ if standard_metrics:
+ scored_metric_sets.add(frozenset(standard_metrics))
if len(scored_metric_sets) > 1:
return ""
- if overall > best_score:
- best_score = overall
+ if best_rank is None or rank > best_rank:
+ best_rank = rank
best_agent = agent
return best_agent
diff --git a/src/skillevaluator/tier3/harbor/report_data.py b/src/skillevaluator/tier3/harbor/report_data.py
index 36ced7a9..2990d686 100644
--- a/src/skillevaluator/tier3/harbor/report_data.py
+++ b/src/skillevaluator/tier3/harbor/report_data.py
@@ -27,7 +27,10 @@ from skillevaluator.tier3.harbor.metrics import (
DEFAULT_METRICS,
LEGACY_METRIC_SET,
LEGACY_METRICS,
+ PARTIAL_SCORE_POLICY,
+ metric_set_for_reward,
)
+from skillevaluator.tier3.harbor.resource_usage import agent_execution_seconds
logger = logging.getLogger(__name__)
@@ -506,8 +509,19 @@ def _metrics_for_rewards(rewards: list[dict[str, Any]]) -> list[str]:
def metrics_for_condition(agent_info: dict[str, Any], condition: str) -> list[str]:
- """Use one condition's recorded metrics, inferring only for older artifacts."""
- configured = agent_info.get(f"metrics_{condition}")
+ """Return the standard metric contract declared by one agent condition.
+
+ Recorded metrics win. Older artifacts fall back to the recorded metric set,
+ then to the standard metrics present in the condition scores, then rewards.
+ """
+ if condition == "with_skill":
+ metrics_key, scores_key, rewards_key = "metrics_with_skill", "with_skill", "rewards"
+ elif condition == "without_skill":
+ metrics_key, scores_key, rewards_key = "metrics_without_skill", "without_skill", "rewards_baseline"
+ else:
+ return []
+
+ configured = agent_info.get(metrics_key)
if isinstance(configured, list):
return list(dict.fromkeys(str(metric) for metric in configured))
recorded_set = agent_info.get(f"metric_set_{condition}")
@@ -517,10 +531,14 @@ def metrics_for_condition(agent_info: dict[str, Any], condition: str) -> list[st
return list(LEGACY_METRICS)
if recorded_set == CUSTOM_ONLY_METRIC_SET:
return []
- scores = agent_info.get(condition, {})
+ scores = agent_info.get(scores_key, {})
if isinstance(scores, dict) and scores:
+ if "security" in scores and agent_info.get(f"score_policy_{condition}") != PARTIAL_SCORE_POLICY:
+ # Unversioned Security scores claim the default v2 contract, so a
+ # missing evaluator leaves the condition incomplete, not partial.
+ return list(DEFAULT_METRICS)
return [metric for metric in DEFAULT_METRICS if metric in scores]
- rewards = agent_info.get("rewards" if condition == "with_skill" else "rewards_baseline", [])
+ rewards = agent_info.get(rewards_key, [])
return _metrics_for_rewards(rewards) if isinstance(rewards, list) else []
@@ -687,6 +705,13 @@ def load_agent_data(
)
if isinstance(data.get("score_policy"), str) and data["score_policy"].strip():
agent_info[score_policy_key] = data["score_policy"].strip()
+ mixed_contract_key = (
+ "mixed_metric_contracts_with_skill"
+ if variant == "with-skill"
+ else "mixed_metric_contracts_without_skill"
+ )
+ if isinstance(data.get("mixed_metric_contracts"), bool):
+ agent_info[mixed_contract_key] = data["mixed_metric_contracts"]
dimension_key = "dimensions_with_skill" if variant == "with-skill" else "dimensions_without_skill"
if "dimensions" in data:
agent_info[dimension_key] = data.get("dimensions", {})
diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.py
index b77cae21..c0e6a489 100644
--- a/src/skillevaluator/tier3/harbor/runner.py
+++ b/src/skillevaluator/tier3/harbor/runner.py
@@ -86,6 +86,7 @@ from skillevaluator.tier3.harbor.adapter import (
)
from skillevaluator.tier3.harbor.artifact_retention import HarborArtifactLifecycle, RetentionOutcome
from skillevaluator.tier3.harbor.collector import (
+ TRUNCATED_AGGREGATE_ATTEMPT_PREFIX,
_score_definition_for_policy,
collect_harbor_results,
harbor_job_passed,
diff --git a/src/skillevaluator/tier3/harbor/templates/custom_grader_runner.py b/src/skillevaluator/tier3/harbor/templates/custom_grader_runner.py
index 1c6f56bd..fb073154 100644
--- a/src/skillevaluator/tier3/harbor/templates/custom_grader_runner.py
+++ b/src/skillevaluator/tier3/harbor/templates/custom_grader_runner.py
@@ -53,6 +53,7 @@ RESERVED = {
"metric_set_version",
"metrics",
"overall",
+ "score_policy",
"trajectory_detail",
"trajectory_source",
}
diff --git a/tests/evaluation/test_tier3_benchmark_contract.py b/tests/evaluation/test_tier3_benchmark_contract.py
index 64d4c582..c8aa1029 100644
--- a/tests/evaluation/test_tier3_benchmark_contract.py
+++ b/tests/evaluation/test_tier3_benchmark_contract.py
@@ -142,6 +142,7 @@ def test_advisory_payload_exposes_same_report_truth_metadata() -> None:
assert payload["evaluated_at"] is None
assert payload["evaluator_version"] == __version__
assert payload["score_policy"] == DEFAULT_SCORE_POLICY
+ assert payload["evaluated_source"] is None
assert payload["dataset_summary"] == {
"total_tasks": 0,
"positive_tasks": 0,
@@ -156,6 +157,8 @@ def test_advisory_payload_exposes_same_report_truth_metadata() -> None:
"dataset_summary",
"dataset_digest",
"dataset_digest_algorithm",
+ "score_policy",
+ "evaluated_source",
"verdict_policy",
):
assert payload["summary"][field] == payload[field]
diff --git a/tests/reporting/test_unified_tier3_report.py b/tests/reporting/test_unified_tier3_report.py
index 1e2eb6dc..b6903c7c 100644
--- a/tests/reporting/test_unified_tier3_report.py
+++ b/tests/reporting/test_unified_tier3_report.py
@@ -37,9 +37,11 @@ from skillevaluator.tier3.harbor.metrics import (
DEFAULT_SCORE_POLICY,
LEGACY_METRICS,
LEGACY_SCORE_POLICY,
+ MAX_CUSTOM_METRIC_NAME_BYTES,
PARTIAL_SCORE_POLICY,
)
-from skillevaluator.tier3.harbor.report_data import build_dataset_snapshot
+from skillevaluator.tier3.harbor.report import _extract_findings
+from skillevaluator.tier3.harbor.report_data import build_dataset_snapshot, metrics_for_agents
def _write_summary(
@@ -817,12 +819,18 @@ def test_authenticated_pre_status_rerender_preserves_historical_scores(tmp_path:
pytest.param(0.5583, "future-weighted-policy-v2", "future-weighted-policy-v2", 0.5583, id="future-policy"),
],
)
+ "evaluated_source",
+ [None, {"repository": "NVIDIA/SkillEvaluator", "commit": "a" * 40}],
+ ids=["without-source", "with-source"],
+)
def test_default_v2_rerender_respects_recorded_or_historical_policy(
tmp_path: Path,
stored_overall: object,
recorded_policy: str | None,
expected_policy: str,
expected_score: float,
+ evaluated_source: dict[str, str] | None,
) -> None:
skill = tmp_path / "demo"
skill.mkdir()
@@ -886,6 +894,9 @@ def test_default_v2_rerender_respects_recorded_or_historical_policy(
assert payload["overall_score"] == pytest.approx(expected_score)
assert payload["agents"]["opencode"]["with_skill"] == pytest.approx(expected_score)
assert payload["score_policy"] == expected_policy
+ assert payload["summary"]["score_policy"] == expected_policy
+ assert payload["evaluated_source"] == evaluated_source
+ assert payload["summary"]["evaluated_source"] == evaluated_source
assert payload["attempt_policy"]["score_policy"] == expected_policy
if expected_policy == LEGACY_SCORE_POLICY:
assert payload["best_agent"] == "opencode"
@@ -958,6 +969,7 @@ def test_canonical_report_fails_closed_on_different_condition_policies() -> None
assert payload["execution_status"] == "failed"
assert payload["overall_score"] is None
assert payload["overall_lift"] is None
+ assert payload["agents"]["opencode"]["lift"] is None
assert any("conflicting score policies" in error.lower() for error in payload["execution_errors"])
@@ -1033,6 +1045,77 @@ def test_known_legacy_policy_lift_uses_condition_scores_not_stale_lift_artifact(
assert payload["agents"]["opencode"]["lift"] == 0.2
+def test_legacy_report_honors_recorded_metric_membership_and_ignores_order() -> None:
+ payload = build_agent_eval_payload(
+ "recorded-metrics-demo",
+ {
+ "opencode": {
+ "execution_status": "succeeded",
+ "with_skill": {**dict.fromkeys(LEGACY_METRICS, 0.8), "security": 0.0},
+ "without_skill": dict.fromkeys(LEGACY_METRICS, 0.6),
+ "metrics_with_skill": list(LEGACY_METRICS),
+ "metrics_without_skill": list(reversed(LEGACY_METRICS)),
+ "score_policy_with_skill": LEGACY_SCORE_POLICY,
+ "score_policy_without_skill": LEGACY_SCORE_POLICY,
+ }
+ },
+ use_llm_judge=False,
+ )
+ assert payload is not None
+ assert payload["overall_score"] == 0.8
+ assert payload["agents"]["opencode"]["baseline"] == 0.6
+ assert payload["overall_lift"] == 0.2
+
+
+def test_partial_reports_do_not_rank_agents_scored_on_different_metrics() -> None:
+ payload = build_agent_eval_payload(
+ "partial-metrics-demo",
+ {
+ "codex": {
+ "execution_status": "succeeded",
+ "with_skill": {"security": 0.8},
+ "score_policy_with_skill": PARTIAL_SCORE_POLICY,
+ },
+ "opencode": {
+ "execution_status": "succeeded",
+ "with_skill": {"security": 0.4, "accuracy": 0.6},
+ "score_policy_with_skill": PARTIAL_SCORE_POLICY,
+ },
+ },
+ use_llm_judge=False,
+ )
+ assert payload is not None
+ assert payload["agents"]["codex"]["with_skill"] == 0.8
+ assert payload["agents"]["opencode"]["with_skill"] == 0.5
+ assert payload["best_agent"] == ""
+ assert payload["overall_score"] is None
+ assert payload["execution_status"] == "failed"
+
+
[email protected]("missing_metric", [False, True])
+def test_legacy_report_keeps_declared_metric_set_when_metric_names_are_absent(
+ tmp_path: Path, missing_metric: bool
+) -> None:
+ skill = tmp_path / "demo"
+ skill.mkdir()
+ run_dir = tmp_path / "results"
+ _write_summary(run_dir, score=0.6)
+ summary_path = run_dir / "opencode/with-skill/summary.json"
+ summary = json.loads(summary_path.read_text(encoding="utf-8"))
+ summary.pop("metrics")
+ summary["metric_set"] = "skill-evaluator-default-v2"
+ summary["score_policy"] = LEGACY_SCORE_POLICY
+ if missing_metric:
+ summary["scores"].pop("security")
+ summary_path.write_text(json.dumps(summary), encoding="utf-8")
+
+ result = agent_eval_result_from_directory(skill, run_dir, use_llm_judge=False)
+ assert result is not None
+ payload = result.metadata["agent_eval"]
+ assert payload["agents"]["opencode"]["metrics_with_skill"] == list(DEFAULT_METRICS)
+ assert payload["agents"]["opencode"]["with_skill"] == (None if missing_metric else 0.6)
+
+
def test_unknown_report_policy_without_a_persisted_score_is_incomplete() -> None:
payload = build_agent_eval_payload(
"unknown-policy-demo",
diff --git a/tests/test_harbor_metrics_truth.py b/tests/test_harbor_metrics_truth.py
index 28ffe67e..f784113e 100644
--- a/tests/test_harbor_metrics_truth.py
+++ b/tests/test_harbor_metrics_truth.py
@@ -29,6 +29,7 @@ from skillevaluator.tier3.harbor.collector import (
_pass_rate_delta,
_pass_summary,
_probability_text,
+ _public_pass_summary,
_score_policy_for_rewards,
_wilson_score_interval,
)
@@ -41,13 +42,19 @@ from skillevaluator.tier3.harbor.metrics import (
LEGACY_METRIC_SET,
LEGACY_METRICS,
LEGACY_SCORE_POLICY,
+ MAX_CUSTOM_METRIC_NAME_BYTES,
+ MAX_CUSTOM_METRICS,
+ CustomMetricContractError,
+ average_custom_metrics,
average_metrics,
canonical_dimension_mean,
+ custom_metric_contract_error,
extract_custom_metrics,
metric_set_for_reward,
metric_value,
overall_score,
overall_score_from_metrics,
+ rewards_have_mixed_metric_contracts,
score_definition,
score_policy_for_metrics,
)
@@ -661,7 +668,8 @@ def test_lift_leaves_out_cases_whose_arms_used_different_judges() -> None:
assert lift["accuracy"] == {"with_skill": 0.8, "without_skill": 0.4, "delta": 0.4, "direction": "up"}
assert lift["judge_mixed_cases"] == {"accuracy": 1}
- assert lift["overall"]["delta"] == round(0.4 / len(DEFAULT_METRICS), 4)
+ # Accuracy is the whole Correctness dimension in the five-dimension overall.
+ assert lift["overall"]["delta"] == round(0.4 / 5, 4)
assert "judge_mixed_cases" not in _compute_lift(with_scores, without_scores, with_rewards[1:], without_rewards)
diff --git a/tests/test_harbor_runner_environment.py b/tests/test_harbor_runner_environment.py
index e5d56b89..835f2ef7 100644
--- a/tests/test_harbor_runner_environment.py
+++ b/tests/test_harbor_runner_environment.py
@@ -21,6 +21,7 @@ from skillevaluator.provider_config import ProviderConfig, ProviderConfiguration
from skillevaluator.tier3.harbor import runner, runtime_preflight
from skillevaluator.tier3.harbor.adapter import _verifier_env_vars
from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS, LEGACY_SCORE_POLICY
+from skillevaluator.tier3_environments import HARBOR_NATIVE_ENV_MODES
def _provider(provider: str = "openai") -> ProviderConfig:
@@ -1191,17 +1192,20 @@ def test_run_harbor_eval_stages_per_agent_credential_trees(
monkeypatch.setattr(
runner,
"collect_harbor_results",
- lambda **_kwargs: {
- "execution_status": "complete",
- "execution_errors": [],
- "metrics": list(DEFAULT_METRICS),
- "score_policy": LEGACY_SCORE_POLICY,
- "attempt_policy": {
+ lambda **kwargs: (
+ collected.update(kwargs)
+ or {
+ "execution_status": "complete",
+ "execution_errors": [],
+ "metrics": list(DEFAULT_METRICS),
"score_policy": LEGACY_SCORE_POLICY,
- "score_definition": "historical six-metric mean",
- },
- "agents": {},
- },
+ "attempt_policy": {
+ "score_policy": LEGACY_SCORE_POLICY,
+ "score_definition": "historical six-metric mean",
+ },
+ "agents": {},
+ }
+ ),
)
monkeypatch.setattr(runner, "render_agent_eval_html_report", lambda *_args, **_kwargs: tmp_path / "report.html")
result = runner.run_harbor_eval(
diff --git a/tests/test_issue55_collector_truth.py b/tests/test_issue55_collector_truth.py
index e29cb3d3..7b8e7191 100644
--- a/tests/test_issue55_collector_truth.py
+++ b/tests/test_issue55_collector_truth.py
@@ -14,7 +14,11 @@ from pathlib import Path
import pytest
-from skillevaluator.evaluation.tier3_report import build_agent_eval_payload, render_agent_eval_html_report
+from skillevaluator.evaluation.tier3_report import (
+ agent_eval_result_from_directory,
+ build_agent_eval_payload,
+ render_agent_eval_html_report,
+)
from skillevaluator.tier3.harbor import collector as collector_module
from skillevaluator.tier3.harbor import report, report_data
from skillevaluator.tier3.harbor.collector import (
@@ -25,12 +29,16 @@ from skillevaluator.tier3.harbor.collector import (
)
from skillevaluator.tier3.harbor.metrics import (
CUSTOM_ONLY_METRIC_SET,
+ CUSTOM_SCORE_POLICY,
DEFAULT_METRIC_SET,
DEFAULT_METRICS,
DEFAULT_SCORE_POLICY,
LEGACY_METRIC_SET,
LEGACY_METRICS,
LEGACY_SCORE_POLICY,
+ MAX_CUSTOM_METRIC_NAME_BYTES,
+ MAX_CUSTOM_METRICS,
+ extract_custom_metrics,
overall_score,
)
@@ -393,6 +401,52 @@ def test_multi_agent_collection_rejects_incomparable_score_policies(tmp_path: Pa
assert any("score policies" in error.lower() for error in result["execution_errors"])
+def test_multi_agent_collection_ranks_custom_only_agent_against_standard_agent(tmp_path: Path) -> None:
+ rewards = {
+ "opencode": {
+ "entry_id": "case-001",
+ "metric_set": DEFAULT_METRIC_SET,
+ "score_policy": DEFAULT_SCORE_POLICY,
+ **dict.fromkeys(DEFAULT_METRICS, 0.8),
+ "overall": 0.8,
+ },
+ "codex": {
+ "entry_id": "case-001",
+ "metric_set": CUSTOM_ONLY_METRIC_SET,
+ "overall": 0.9,
+ "domain_quality": 0.9,
+ },
+ }
+ for agent, reward in rewards.items():
+ job_dir = tmp_path / "jobs" / f"demo-{agent}-with"
+ _write_reward(job_dir, "case-001__attempt", reward)
+ _write_complete_job_result(job_dir, ["case-001__attempt"])
+
+ result = collect_harbor_results(
+ skill_name="demo",
+ agents=list(rewards),
+ output_dir=tmp_path / "results",
+ jobs_dir=tmp_path / "jobs",
+ skip_baseline=True,
+ expected_cases=1,
+ expected_case_ids=["case-001"],
+ expected_trials=1,
+ )
+
+ assert result["execution_status"] == "succeeded"
+ assert result["score_policy"] == result["attempt_policy"]["score_policy"] == DEFAULT_SCORE_POLICY
+ assert result["agents"]["codex"]["score_policy_with_skill"] == CUSTOM_SCORE_POLICY
+ assert "comparison" in result
+ for agents in (result["agents"], report_data.load_agent_data(tmp_path / "results")):
+ payload = build_agent_eval_payload("demo", agents, attempt_policy=result["attempt_policy"], use_llm_judge=False)
+ assert payload is not None
+ assert payload["execution_status"] == "succeeded"
+ assert payload["agents"]["opencode"]["with_skill"] == 0.8
+ assert payload["agents"]["codex"]["with_skill"] == 0.9
+ assert payload["best_agent"] == "codex"
+ assert report._pick_best_agent(agents) == "codex"
+
+
def test_failed_later_agent_does_not_relabel_a_successful_legacy_agent(tmp_path: Path) -> None:
job_dir = tmp_path / "jobs" / "demo-opencode-with"
_write_reward(
@@ -424,6 +478,112 @@ def test_failed_later_agent_does_not_relabel_a_successful_legacy_agent(tmp_path:
assert LEGACY_SCORE_POLICY in result["attempt_policy"]["score_definition"]
[email protected]("reverse_conditions", [False, True])
+def test_different_condition_metric_sets_preserve_scores_without_overall_lift(
+ tmp_path: Path, reverse_conditions: bool
+) -> None:
+ legacy = {
+ "entry_id": "case-001",
+ "metric_set": LEGACY_METRIC_SET,
+ "score_policy": LEGACY_SCORE_POLICY,
+ **dict.fromkeys(LEGACY_METRICS, 0.8),
+ "overall": 0.8,
+ }
+ historical = {**legacy, "metric_set": DEFAULT_METRIC_SET, "security": 0.0, "overall": 0.6667}
+ conditions = [legacy, historical]
+ if reverse_conditions:
+ conditions.reverse()
+ for variant, reward in zip(("with", "without"), conditions, strict=True):
+ job_dir = tmp_path / "jobs" / f"demo-opencode-{variant}"
+ _write_reward(job_dir, "case-001__attempt", reward)
+ _write_complete_job_result(job_dir, ["case-001__attempt"])
+
+ result = _collect(tmp_path, skip_baseline=False, case_ids=["case-001"])
+ agent = result["agents"]["opencode"]
+ assert result["execution_status"] == "succeeded"
+ assert agent["overall_with_skill"] == conditions[0]["overall"]
+ assert agent["overall_without_skill"] == conditions[1]["overall"]
+ assert "overall" not in agent["lift"]
+ assert all(agent["lift"][metric]["delta"] == 0.0 for metric in LEGACY_METRICS)
+ assert agent["pass_at_k"]["lift"] == {}
+ persisted_lift = json.loads((tmp_path / "results/opencode/lift.json").read_text(encoding="utf-8"))
+ assert "overall" not in persisted_lift
+ assert not (tmp_path / "results/opencode/pass_at_k_lift.json").exists()
+
+ # Rendering older artifacts must not revive the invalid comparisons either.
+ persisted_lift["overall"] = {"with_skill": 0.8, "without_skill": 0.6667, "delta": 0.1333}
+ (tmp_path / "results/opencode/lift.json").write_text(json.dumps(persisted_lift), encoding="utf-8")
+ (tmp_path / "results/opencode/pass_at_k_lift.json").write_text(
+ json.dumps({"with_skill": 1.0, "without_skill": 0.0, "delta": 1.0}), encoding="utf-8"
+ )
+ for agents in (result["agents"], report_data.load_agent_data(tmp_path / "results")):
+ payload = build_agent_eval_payload(
+ "demo", agents, attempt_policy=result["attempt_policy"], use_llm_judge=False
+ )
+ assert payload is not None
+ assert payload["overall_score"] == conditions[0]["overall"]
+ assert payload["agents"]["opencode"]["baseline"] == conditions[1]["overall"]
+ assert payload["agents"]["opencode"]["lift"] is None
+ assert payload["overall_lift"] is None
+ assert payload["pass_at_k"]["lift"] == {}
+ assert all("baseline_overall" not in trial for trial in payload["trials"])
+
+
[email protected]("reverse_agents", [False, True])
[email protected]("same_metric_set", [False, True])
+def test_multi_agent_legacy_reports_preserve_each_agents_metric_set(
+ tmp_path: Path, reverse_agents: bool, same_metric_set: bool
+) -> None:
+ agents = ["opencode", "codex"]
+ for agent, score in zip(agents, (0.9, 0.7), strict=True):
+ use_legacy = agent == "opencode" or same_metric_set
+ metrics = LEGACY_METRICS if use_legacy else DEFAULT_METRICS
+ job_dir = tmp_path / "jobs" / f"demo-{agent}-with"
+ _write_reward(
+ job_dir,
+ "case-001__attempt",
+ {
+ "entry_id": "case-001",
+ "metric_set": LEGACY_METRIC_SET if use_legacy else DEFAULT_METRIC_SET,
+ "score_policy": LEGACY_SCORE_POLICY,
+ **dict.fromkeys(metrics, score),
+ "overall": score,
+ },
+ )
+ _write_complete_job_result(job_dir, ["case-001__attempt"])
+ if reverse_agents:
+ agents.reverse()
+ result = collect_harbor_results(
+ skill_name="demo",
+ agents=agents,
+ output_dir=tmp_path / "results",
+ jobs_dir=tmp_path / "jobs",
+ skip_baseline=True,
+ expected_cases=1,
+ expected_case_ids=["case-001"],
+ expected_trials=1,
+ )
+
+ for data in (result["agents"], report_data.load_agent_data(tmp_path / "results")):
+ payload = build_agent_eval_payload(
+ "demo", data, attempt_policy=result["attempt_policy"], use_llm_judge=False
+ )
+ assert payload is not None
+ assert payload["agents"]["opencode"]["with_skill"] == 0.9
+ assert payload["agents"]["codex"]["with_skill"] == 0.7
+ if same_metric_set:
+ assert payload["execution_status"] == "succeeded"
+ assert payload["best_agent"] == "opencode"
+ assert payload["overall_score"] == 0.9
+ assert report._pick_best_agent(data) == "opencode"
+ else:
+ assert payload["best_agent"] == ""
+ assert payload["overall_score"] is None
+ assert payload["execution_status"] == "failed"
+ assert any("metric sets" in error.lower() for error in payload["execution_errors"])
+ assert report._pick_best_agent(data) == ""
+
+
def test_failed_judge_sidecar_is_merged_but_never_scored_and_reason_is_safe(tmp_path: Path) -> None:
job_dir = tmp_path / "jobs" / "demo-opencode-with"
trial_name = "case-001__attempt"
diff --git a/tests/test_tier3_compare.py b/tests/test_tier3_compare.py
index 56e8a527..5125dde4 100644
--- a/tests/test_tier3_compare.py
+++ b/tests/test_tier3_compare.py
@@ -17,6 +17,7 @@ from skillevaluator.tier3.harbor.metrics import (
CUSTOM_SCORE_POLICY,
DEFAULT_METRICS,
DEFAULT_SCORE_POLICY,
+ LEGACY_METRICS,
LEGACY_SCORE_POLICY,
)
from skillevaluator.tier3.output_provenance import mark_generated_output_root
@@ -70,6 +71,102 @@ def test_compare_rejects_cross_agent_overalls_with_different_score_policies(
assert "different score policies" in capsys.readouterr().out.lower()
+def _write_compare_summary(run_dir: Path, agent: str, condition: str, summary: dict[str, object]) -> None:
+ path = run_dir / agent / condition / "summary.json"
+ path.parent.mkdir(parents=True)
+ path.write_text(json.dumps({"execution_status": "succeeded", "num_trials": 1, **summary}), encoding="utf-8")
+
+
+_STANDARD_COMPARE_SUMMARY = {
+ "scores": dict.fromkeys(DEFAULT_METRICS, 0.8),
+ "overall_score": 0.8,
+ "score_policy": DEFAULT_SCORE_POLICY,
+ "metric_set": "skill-evaluator-default-v2",
+ "metrics": list(DEFAULT_METRICS),
+}
+
+
[email protected]("recorded_policy", [True, False], ids=("recorded-policy", "unversioned"))
+def test_compare_scores_custom_only_agent_against_standard_agent(
+ tmp_path: Path,
+ capsys: pytest.CaptureFixture[str],
+ recorded_policy: bool,
+) -> None:
+ skill_path = tmp_path / "demo"
+ skill_path.mkdir()
+ run_dir = tmp_path / "results" / "demo" / "20260709_010000"
+ _write_compare_summary(run_dir, "codex", "with-skill", _STANDARD_COMPARE_SUMMARY)
+ custom_summary: dict[str, object] = {
+ "scores": {},
+ "custom_scores": {"domain_quality": 0.9},
+ "overall_score": 0.9,
+ "metric_set": "custom-only",
+ "metrics": [],
+ }
+ if recorded_policy:
+ custom_summary["score_policy"] = CUSTOM_SCORE_POLICY
+ _write_compare_summary(run_dir, "opencode", "with-skill", custom_summary)
+ _complete_current_run(run_dir)
+
+ assert compare_results(skill_path, results_dir=tmp_path / "results") == 0
+ output = capsys.readouterr().out
+ assert "different score policies" not in output.lower()
+ assert "different metric sets" not in output.lower()
+ overall_line = next(line for line in output.splitlines() if "Overall" in line)
+ assert "0.80" in overall_line
+ assert "0.90" in overall_line
+
+
+def test_compare_still_rejects_custom_agent_with_a_standard_baseline(
+ tmp_path: Path,
+ capsys: pytest.CaptureFixture[str],
+) -> None:
+ skill_path = tmp_path / "demo"
+ skill_path.mkdir()
+ run_dir = tmp_path / "results" / "demo" / "20260709_010000"
+ _write_compare_summary(run_dir, "codex", "with-skill", _STANDARD_COMPARE_SUMMARY)
+ _write_compare_summary(
+ run_dir,
+ "opencode",
+ "with-skill",
+ {"scores": {}, "overall_score": 0.9, "score_policy": CUSTOM_SCORE_POLICY, "metrics": []},
+ )
+ _write_compare_summary(run_dir, "opencode", "without-skill", _STANDARD_COMPARE_SUMMARY)
+ _complete_current_run(run_dir)
+
+ assert compare_results(skill_path, results_dir=tmp_path / "results") == 1
+ assert "different score policies" in capsys.readouterr().out.lower()
+
+
+def test_compare_rejects_cross_agent_overalls_with_different_standard_metric_sets(
+ tmp_path: Path,
+ capsys: pytest.CaptureFixture[str],
+) -> None:
+ skill_path = tmp_path / "demo"
+ skill_path.mkdir()
+ run_dir = tmp_path / "results" / "demo" / "20260709_010000"
+ for agent, metric_set, metrics in (
+ ("current", "skill-evaluator-default-v2", DEFAULT_METRICS),
+ ("historical", "skill-evaluator-default-v1", LEGACY_METRICS),
+ ):
+ _write_compare_summary(
+ run_dir,
+ agent,
+ "with-skill",
+ {
+ "scores": dict.fromkeys(metrics, 0.5),
+ "overall_score": 0.5,
+ "score_policy": LEGACY_SCORE_POLICY,
+ "metric_set": metric_set,
+ "metrics": list(metrics),
+ },
+ )
+ _complete_current_run(run_dir)
+
+ assert compare_results(skill_path, results_dir=tmp_path / "results") == 1
+ assert "different metric sets" in capsys.readouterr().out.lower()
+
+
def test_overall_display_preserves_pre_policy_default_v2_semantics() -> None:
scores = {
"security": 0.3875,
diff --git a/tests/tier3/test_judge_failure_artifacts.py b/tests/tier3/test_judge_failure_artifacts.py
index 988d9013..93cc585b 100644
--- a/tests/tier3/test_judge_failure_artifacts.py
+++ b/tests/tier3/test_judge_failure_artifacts.py
@@ -26,6 +26,8 @@ from skillevaluator.tier3.harbor.adapter import _EVALUATOR_TESTS_SUBDIR, _write_
from skillevaluator.tier3.harbor.metrics import (
DEFAULT_METRIC_SET,
DEFAULT_SCORE_POLICY,
+ MAX_CUSTOM_METRIC_NAME_BYTES,
+ MAX_CUSTOM_METRICS,
RESERVED_METRIC_NAMES,
custom_metric_name_is_publishable,
extract_custom_metrics,