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.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
fix(tier3): use one overall-score formula (#124)
Christopher Kevinf923f0a1dead
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.pyindex 18a39a50..4ef06e4a 100644--- a/src/skillevaluator/evaluation/tier3_report.py+++ b/src/skillevaluator/evaluation/tier3_report.py@@ -625,8 +625,10 @@ def build_agent_eval_payload(policy_metrics = _policy_metrics_from_agents(agents, metrics)from skillevaluator.tier3.harbor.metrics import (+ CUSTOM_SCORE_POLICY,DEFAULT_METRICS,LEGACY_SCORE_POLICY,+ SUPPORTED_SCORE_POLICIES,score_policy_for_metrics,)@@ -634,21 +636,24 @@ 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)stored_policy = policy.get("score_policy")if isinstance(stored_policy, str) and stored_policy.strip():policy["score_policy"] = stored_policy.strip()+ elif len(recorded_policies) == 1:+ policy["score_policy"] = next(iter(recorded_policies))+ elif historical_missing_score_policy and policy_metrics == DEFAULT_METRICS:+ policy["score_policy"] = LEGACY_SCORE_POLICYelse:- recorded_policy = _recorded_score_policy(agents)- if recorded_policy is not None:- policy["score_policy"] = recorded_policy- elif historical_missing_score_policy and policy_metrics == DEFAULT_METRICS:- policy["score_policy"] = LEGACY_SCORE_POLICY- else:- policy["score_policy"] = score_policy_for_metrics(policy_metrics)- policy.setdefault(- "score_definition",- _score_definition_for_policy(policy_metrics, policy["score_policy"]),+ policy["score_policy"] = score_policy_for_metrics(policy_metrics)+ conflicting_policies = len(recorded_policies) > 1 or bool(+ recorded_policies and policy["score_policy"] not in recorded_policies)+ if conflicting_policies:+ policy["score_policy"] = "mixed-score-policies"+ policy.pop("score_definition", None)+ if policy["score_policy"] != CUSTOM_SCORE_POLICY or not isinstance(policy.get("score_definition"), str):+ policy["score_definition"] = _score_definition_for_policy(policy_metrics, policy["score_policy"])report_budget = _ReportBudget(artifact_loading=_artifact_loading_reasons(agents, dataset))agent_payloads: dict[str, dict[str, Any]] = {}@@ -660,15 +665,7 @@ def build_agent_eval_payload(if not agent_payloads:return None- scored_metric_sets = {- frozenset(agent["metrics_with_skill"])- for agent in agent_payloads.values()- if 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)+ best_agent = "" if conflicting_policies 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(@@ -698,9 +695,6 @@ 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 Nonefor agent in agent_payloads.values()@@ -1345,20 +1339,22 @@ def _policy_metrics_from_agents(agents: dict[str, dict[str, Any]],metrics: list[str],) -> tuple[str, ...]:+ from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS+available = tuple(metric- for metric in metrics+ for metric in (metrics or DEFAULT_METRICS)if any(- _finite_float(scores.get(metric)) is not None+ _condition_quality_available(info, "with_skill") and _finite_float(scores.get(metric)) is not Nonefor info in agents.values()- for scores in (info.get("with_skill"), info.get("without_skill"))+ for scores in (info.get("with_skill"),)if isinstance(scores, dict)))return available or tuple(metrics)-def _recorded_score_policy(agents: dict[str, dict[str, Any]]) -> str | None:+def _recorded_score_policies(agents: dict[str, dict[str, Any]]) -> set[str]:recorded: set[str] = set()for info in agents.values():for condition, scores_key, policy_key in (@@ -1370,25 +1366,38 @@ def _recorded_score_policy(agents: dict[str, dict[str, Any]]) -> str | None:if (_condition_quality_available(info, condition)and isinstance(scores, dict)- and scores+ and (scores or _unit_interval_score(info.get(f"overall_{condition}")) is not None)and isinstance(policy, str)and policy.strip()):recorded.add(policy.strip())- return next(iter(recorded)) if len(recorded) == 1 else None+ return recordeddef _score_definition_for_policy(metrics: tuple[str, ...], score_policy: str) -> str:- from skillevaluator.tier3.harbor.metrics import LEGACY_SCORE_POLICY, score_definition+ from skillevaluator.tier3.harbor.metrics import (+ CUSTOM_SCORE_POLICY,+ DEFAULT_METRICS,+ DEFAULT_SCORE_POLICY,+ LEGACY_SCORE_POLICY,+ PARTIAL_SCORE_POLICY,+ score_definition,+ )if score_policy == LEGACY_SCORE_POLICY and metrics:return f"overall = mean({', '.join(metrics)}) [{LEGACY_SCORE_POLICY}]"- return score_definition(metrics)+ if score_policy == CUSTOM_SCORE_POLICY:+ return score_definition(())+ if score_policy == DEFAULT_SCORE_POLICY:+ return score_definition(DEFAULT_METRICS)+ if score_policy == PARTIAL_SCORE_POLICY:+ return score_definition(metrics)+ return f"overall = persisted score; formula unavailable [{score_policy}]"def _complete_metric_mean(scores: dict[str, Any], metrics: list[str]) -> float | None:values = tuple(_finite_float(scores.get(metric)) for metric in metrics)- if not values or any(value is None for value in values):+ if not values or any(value is None or not 0.0 <= value <= 1.0 for value in values):return Nonereturn round(sum(value for value in values if value is not None) / len(values), 4)@@ -1412,9 +1421,11 @@ def _build_agent(score_policy: str,) -> dict[str, Any]:from skillevaluator.tier3.harbor.metrics import (- LEGACY_METRICS,+ CUSTOM_SCORE_POLICY,+ DEFAULT_METRICS,+ DEFAULT_SCORE_POLICY,LEGACY_SCORE_POLICY,- canonical_dimension_mean,+ PARTIAL_SCORE_POLICY,overall_score_from_metrics,)from skillevaluator.tier3.harbor.report_data import metrics_for_condition@@ -1448,8 +1459,8 @@ def _build_agent(overall_ws = Noneoverall_bl = Noneif score_policy == LEGACY_SCORE_POLICY:- overall_ws = _complete_metric_mean(with_scores, with_metrics) if with_quality_available else None- overall_bl = _complete_metric_mean(without_scores, without_metrics) if baseline_quality_available else None+ 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 Noneif 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:@@ -1458,9 +1469,10 @@ def _build_agent(overall_ws = overall_score_from_metrics(with_scores, DEFAULT_METRICS) if with_quality_available else Noneoverall_bl = overall_score_from_metrics(without_scores, DEFAULT_METRICS) if baseline_quality_available else Noneelif score_policy == PARTIAL_SCORE_POLICY:- overall_ws = overall_score_from_metrics(with_scores, tuple(with_metrics)) if with_quality_available else None+ selected_metrics = tuple(metrics)+ overall_ws = overall_score_from_metrics(with_scores, selected_metrics) if with_quality_available else Noneoverall_bl = (- overall_score_from_metrics(without_scores, tuple(without_metrics)) if baseline_quality_available else None+ overall_score_from_metrics(without_scores, selected_metrics) if baseline_quality_available else None)if overall_ws is None:overall_ws = _mean(with_dimension_values)@@ -1473,45 +1485,23 @@ def _build_agent(}:overall_ws = _unit_interval_score(info.get("overall_with_skill")) if with_quality_available else Noneoverall_bl = _unit_interval_score(info.get("overall_without_skill")) if baseline_quality_available else None- if overall_ws is None:- overall_ws = _complete_metric_mean(with_scores, metrics)- if overall_bl is None:- overall_bl = _complete_metric_mean(without_scores, metrics)- elif tuple(metrics) == LEGACY_METRICS:- if overall_ws is None:- overall_ws = overall_score_from_metrics(with_scores, LEGACY_METRICS)- if overall_bl is None:- overall_bl = overall_score_from_metrics(without_scores, LEGACY_METRICS)- else:- if overall_ws is None:- overall_ws = canonical_dimension_mean(with_dimension_values)- if overall_bl is None:- overall_bl = canonical_dimension_mean(baseline_dimension_values)- if overall_ws is None:- overall_ws = _mean(with_dimension_values)- if overall_bl is None:- overall_bl = _mean(baseline_dimension_values)- if overall_ws is None and not metrics and with_quality_available:+ if overall_ws is None and not metrics and with_quality_available and score_policy == CUSTOM_SCORE_POLICY: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:+ if overall_bl is None and not metrics and baseline_quality_available and score_policy == CUSTOM_SCORE_POLICY: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 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)+ 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)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(with_metrics),+ sum(w - b for w, b in zip(with_values, baseline_values, strict=True)) / len(metrics),4,)@@ -2969,6 +2959,8 @@ def _read_attempt_policy(run_dir: Path) -> dict[str, Any]:policy.update(loaded)if "score_policy" not in loaded:policy.pop("score_policy", None)+ if "score_definition" not in loaded:+ policy.pop("score_definition", None)return policypolicy.pop("score_definition", None)policy.pop("score_policy", None)diff --git a/src/skillevaluator/tier3/commands.py b/src/skillevaluator/tier3/commands.pyindex 846f72cb..b30f56c0 100644--- a/src/skillevaluator/tier3/commands.py+++ b/src/skillevaluator/tier3/commands.py@@ -38,10 +38,12 @@ from skillevaluator.tier3.harbor import (canonical_agent_name,)from skillevaluator.tier3.harbor.metrics import (+ CUSTOM_SCORE_POLICY,DEFAULT_METRICS,DEFAULT_SCORE_POLICY,LEGACY_METRICS,LEGACY_SCORE_POLICY,+ PARTIAL_SCORE_POLICY,overall_score_from_metrics,)from skillevaluator.tier3.harbor.progress import (@@ -1066,14 +1068,17 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> intdata = json.loads(summary.read_text(encoding="utf-8"))except (ValueError, OSError):continue+ if not isinstance(data, dict):+ continuescores = _summary_scores(data, allow_missing_status=allow_missing_status)- if scores:+ overall = _summary_overall(data) if _summary_is_scoreable(data, allow_missing_status) else None+ if scores or overall is not None:root_with[agent_name] = scoresroot_meta[agent_name] = {"timestamp": ts_dir.name,"path": str(agent_dir),"num_trials": data.get("num_trials", "?"),- "overall_with_skill": _summary_overall(data),+ "overall_with_skill": overall,"score_policy_with_skill": _summary_score_policy(data),}wo_summary = agent_dir / "without-skill" / "summary.json"@@ -1084,11 +1089,21 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> intwo_data,allow_missing_status=allow_missing_status,)- if wo_scores:+ wo_overall = (+ _summary_overall(wo_data)+ if isinstance(wo_data, dict) and _summary_is_scoreable(wo_data, allow_missing_status)+ else None+ )+ if (wo_scores or wo_overall is not None) and (+ _effective_compare_policy(+ root_meta[agent_name]["score_policy_with_skill"], root_with[agent_name]+ )+ == _effective_compare_policy(_summary_score_policy(wo_data), wo_scores)+ ):root_without[agent_name] = wo_scoresroot_meta[agent_name].update({- "overall_without_skill": _summary_overall(wo_data),+ "overall_without_skill": wo_overall,"score_policy_without_skill": _summary_score_policy(wo_data),})@@ -1103,6 +1118,16 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> intreturn 1agents = sorted(agent_with)+ comparison_policies = {+ _effective_compare_policy(agent_meta[agent].get("score_policy_with_skill"), agent_with[agent])+ for agent in agents+ }+ if len(comparison_policies) > 1:+ console.print(+ "[red]Cannot compare overall scores across agents with different score policies. "+ "Rerun the agents under one policy.[/red]"+ )+ return 1display_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)@@ -1116,11 +1141,17 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> introw: list[str | Text] = [Text(strip_terminal_controls(metric))]for agent in agents:with_score = _safe_score(agent_with[agent], metric)- row.append(Text(f"{with_score:.2f}", style=f"bold {_score_style(with_score)}"))+ row.append(+ Text(f"{with_score:.2f}", style=f"bold {_score_style(with_score)}")+ if with_score is not None+ else Text("-", style="dim")+ )if agent in agent_without:without_score = _safe_score(agent_without[agent], metric)- delta = with_score - without_score- if delta > 0:+ delta = with_score - without_score if with_score is not None and without_score is not None else None+ if delta is None:+ row.append(Text("-", style="dim"))+ elif delta > 0:row.append(Text(f"+{delta:.2f}", style="green"))elif delta < 0:row.append(Text(f"{delta:.2f}", style="red"))@@ -1138,7 +1169,11 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> intpersisted_overall=meta.get("overall_with_skill"),score_policy=meta.get("score_policy_with_skill"),)- overall_row.append(Text(f"{with_avg:.2f}", style=f"bold {_score_style(with_avg)}"))+ overall_row.append(+ Text(f"{with_avg:.2f}", style=f"bold {_score_style(with_avg)}")+ if with_avg is not None+ else Text("-", style="dim")+ )if agent in agent_without:without_avg = _overall_score_for_display(agent_without[agent],@@ -1146,10 +1181,13 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> intpersisted_overall=meta.get("overall_without_skill"),score_policy=meta.get("score_policy_without_skill"),)- delta = with_avg - without_avg- delta_text = f"+{delta:.2f}" if delta > 0 else f"{delta:.2f}"- delta_style = "bold green" if delta > 0 else ("bold red" if delta < 0 else "bold dim")- overall_row.append(Text(delta_text, style=delta_style))+ if with_avg is None or without_avg is None:+ overall_row.append(Text("-", style="dim"))+ else:+ delta = with_avg - without_avg+ delta_text = f"+{delta:.2f}" if delta > 0 else f"{delta:.2f}"+ delta_style = "bold green" if delta > 0 else ("bold red" if delta < 0 else "bold dim")+ overall_row.append(Text(delta_text, style=delta_style))table.add_row(*overall_row)console.print()@@ -1174,23 +1212,38 @@ def compare_results(skill_path: Path, *, results_dir: Path | None = None) -> intdef _summary_scores(data: dict[str, Any], *, allow_missing_status: bool = False) -> dict[str, float]:if not isinstance(data, dict):return {}- status = data.get("execution_status")- if status != "succeeded" and not (allow_missing_status and status is None):+ if not _summary_is_scoreable(data, allow_missing_status):return {}scores: dict[str, float] = {}raw_scores = data.get("scores", data)if isinstance(raw_scores, dict):for key, value in raw_scores.items():- if isinstance(value, int | float) and not isinstance(value, bool):- scores[str(key)] = float(value)+ numeric = _unit_interval_score(value) if key in DEFAULT_METRICS else _finite_numeric(value)+ if numeric is not None:+ scores[str(key)] = numericcustom_scores = data.get("custom_scores")if isinstance(custom_scores, dict):for key, value in custom_scores.items():- if isinstance(value, int | float) and not isinstance(value, bool):- scores[f"custom: {key}"] = float(value)+ if (numeric := _finite_numeric(value)) is not None:+ scores[f"custom: {key}"] = numericreturn scores+def _summary_is_scoreable(data: dict[str, Any], allow_missing_status: bool) -> bool:+ status = data.get("execution_status")+ return status == "succeeded" or (allow_missing_status and status is None)+++def _finite_numeric(value: object) -> float | None:+ if not isinstance(value, int | float) or isinstance(value, bool):+ return None+ try:+ numeric = float(value)+ except OverflowError:+ return None+ return numeric if math.isfinite(numeric) else None++def _summary_overall(data: dict[str, Any]) -> float | None:return _unit_interval_score(data.get("overall_score"))@@ -1200,6 +1253,15 @@ def _summary_score_policy(data: dict[str, Any]) -> str | None:return value.strip() if isinstance(value, str) and value.strip() else None+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():+ return policy.strip()+ if any(metric in scores for metric in DEFAULT_METRICS):+ return LEGACY_SCORE_POLICY if set(DEFAULT_METRICS).issubset(scores) else PARTIAL_SCORE_POLICY+ return CUSTOM_SCORE_POLICY++def _display_metrics(agent_with: dict[str, dict[str, float]]) -> tuple[tuple[str, ...], tuple[str, ...]]:has_default_scores = any(any(metric in scores for metric in DEFAULT_METRICS) for scores in agent_with.values())if has_default_scores:@@ -1214,9 +1276,8 @@ def _display_metrics(agent_with: dict[str, dict[str, float]]) -> tuple[tuple[strreturn metrics, metrics-def _safe_score(scores: dict[str, float], metric: str) -> float:- value = scores.get(metric, 0.0)- return float(value) if isinstance(value, int | float) else 0.0+def _safe_score(scores: dict[str, float], metric: str) -> float | None:+ return _finite_numeric(scores.get(metric))def _unit_interval_score(value: object) -> float | None:@@ -1236,7 +1297,7 @@ def _overall_score_for_display(*,persisted_overall: object = None,score_policy: object = DEFAULT_SCORE_POLICY,-) -> float:+) -> float | None:"""Honor persisted score truth before inferring a policy from metric names."""recorded_overall = _unit_interval_score(persisted_overall)@@ -1249,16 +1310,13 @@ def _overall_score_for_display(return recorded_overallif score_policy == LEGACY_SCORE_POLICY or (score_policy is None and metrics == DEFAULT_METRICS):- values = tuple(scores.get(metric) for metric in metrics)- if values and all(- isinstance(value, int | float) and not isinstance(value, bool) and math.isfinite(value) for value in values- ):- return round(sum(float(value) for value in values) / len(values), 4)+ values = tuple(_safe_score(scores, metric) for metric in metrics)+ if values and all(value is not None for value in values):+ return round(sum(value for value in values if value is not None) / len(values), 4)- score = overall_score_from_metrics(scores, metrics)- if score is not None:- return score- return sum(_safe_score(scores, metric) for metric in metrics) / len(metrics)+ if score_policy is None:+ return overall_score_from_metrics(scores, metrics)+ return Nonedef _score_style(score: float) -> str:diff --git a/src/skillevaluator/tier3/harbor/collector.py b/src/skillevaluator/tier3/harbor/collector.pyindex f696f90f..0d791326 100644--- a/src/skillevaluator/tier3/harbor/collector.py+++ b/src/skillevaluator/tier3/harbor/collector.py@@ -37,9 +37,7 @@ from skillevaluator.tier3.harbor.metrics import (DEFAULT_SCORE_POLICY,LEGACY_METRIC_SET,LEGACY_METRICS,- MAX_CUSTOM_METRICS,- RESERVED_METRIC_NAMES,- CustomMetricContractError,+ LEGACY_SCORE_POLICY,average_custom_metrics,average_metrics,custom_metric_contract_error,@@ -4518,7 +4516,11 @@ def _logical_attempt_rewards(rewards: list[dict[str, Any]]) -> list[dict[str, Anlogical_reward["custom_metrics"] = custom_scoresif (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)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.@@ -5041,13 +5043,64 @@ def _average_overall(rewards: list[dict[str, Any]]) -> float | None:return round(sum(value for value in values if value is not None) / len(values), 4)+def _score_policy_for_rewards(rewards: list[dict[str, Any]], metrics: tuple[str, ...]) -> tuple[str, bool]:+ """Recover recorded reward policy; flag a policy shared by equal-score formulas as ambiguous."""+ decisive_policies: set[str] = set()+ ambiguous_equal_score = False+ for reward in rewards:+ recorded = reward.get("score_policy")+ if isinstance(recorded, str) and recorded.strip():+ decisive_policies.add(recorded.strip())+ continue+ if metrics == DEFAULT_METRICS:+ values = [metric_value(reward, metric) for metric in metrics]+ persisted = reward.get("overall")+ if (+ all(value is not None for value in values)+ and isinstance(persisted, int | float)+ and not isinstance(persisted, bool)+ ):+ try:+ stored = float(persisted)+ except OverflowError:+ stored = float("nan")+ current = overall_score_from_metrics(reward, metrics)+ historical = round(sum(value for value in values if value is not None) / len(values), 4)+ if math.isfinite(stored) and current is not None:+ stored = round(stored, 4)+ if stored == historical and stored != current:+ decisive_policies.add(LEGACY_SCORE_POLICY)+ continue+ if stored != historical:+ decisive_policies.add(DEFAULT_SCORE_POLICY)+ continue+ ambiguous_equal_score = True+ continue+ decisive_policies.add(score_policy_for_metrics(metrics))+ if len(decisive_policies) > 1:+ return "mixed-score-policies", False+ if decisive_policies:+ return next(iter(decisive_policies)), False+ return score_policy_for_metrics(metrics), ambiguous_equal_score+++def _score_definition_for_policy(metrics: tuple[str, ...], policy: str) -> str:+ if policy == LEGACY_SCORE_POLICY and metrics:+ return f"overall = mean({', '.join(metrics)}) [{LEGACY_SCORE_POLICY}]"+ if policy != score_policy_for_metrics(metrics):+ return f"overall = persisted score; formula unavailable [{policy}]"+ return score_definition(metrics)++def _aggregate_condition_overall(scores: dict[str, float],metrics: tuple[str, ...],rewards: list[dict[str, Any]],+ *,+ score_policy: str | None = None,) -> float | None:"""Aggregate a condition consistently with lift and canonical reports."""- if not metrics:+ if 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@@ -6240,7 +6293,6 @@ def collect_harbor_results(with_overall_score: float | None = Nonewith_policy = DEFAULT_SCORE_POLICYwith_policy_ambiguous = False- with_metrics: tuple[str, ...] = ()with_arm_suffix = "-with-skill" if not skip_baseline else ""if with_job_dir:@@ -6274,11 +6326,12 @@ def collect_harbor_results(with_mixed_metric_contracts = rewards_have_mixed_metric_contracts(with_rewards)with_trial_failures.extend(invalid_score_failures)with_scores, with_metric_set, with_metrics = average_metrics(with_logical_rewards)+ with_policy, with_policy_ambiguous = _score_policy_for_rewards(with_logical_rewards, with_metrics)all_results["metric_set"] = with_metric_setall_results["metrics"] = list(with_metrics)- all_results["attempt_policy"]["score_definition"] = score_definition(with_metrics)- all_results["score_policy"] = score_policy_for_metrics(with_metrics)- all_results["attempt_policy"]["score_policy"] = score_policy_for_metrics(with_metrics)+ all_results["attempt_policy"]["score_definition"] = _score_definition_for_policy(with_metrics, with_policy)+ all_results["score_policy"] = with_policy+ all_results["attempt_policy"]["score_policy"] = with_policywith_custom_scores = average_custom_metrics(with_logical_rewards)with_pass = _pass_summary(with_logical_rewards,@@ -6299,12 +6352,17 @@ def collect_harbor_results(stop_on_pass=stop_on_pass,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"+ )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)+ _aggregate_condition_overall(with_scores, with_metrics, with_logical_rewards, score_policy=with_policy)if with_execution["execution_status"] == "succeeded"else None)@@ -6330,7 +6388,7 @@ def collect_harbor_results("overall_score": with_overall_score,"metric_set": with_metric_set,"metrics": list(with_metrics),- "score_policy": score_policy_for_metrics(with_metrics),+ "score_policy": with_policy,"dimensions": dimension_scores(with_scores),"num_trials": len(with_rewards),"pass_at_k": with_pass,@@ -6425,7 +6483,6 @@ def collect_harbor_results(without_overall_score: float | None = Nonewithout_policy = DEFAULT_SCORE_POLICYwithout_policy_ambiguous = False- without_metrics: tuple[str, ...] = ()without_job_dir: Path | None = Noneif not skip_baseline:without_job_name = f"{skill_name}-{agent}-without"@@ -6460,6 +6517,9 @@ def collect_harbor_results(without_mixed_metric_contracts = rewards_have_mixed_metric_contracts(without_rewards)without_trial_failures.extend(invalid_score_failures)without_scores, without_metric_set, without_metrics = average_metrics(without_logical_rewards)+ without_policy, without_policy_ambiguous = _score_policy_for_rewards(+ without_logical_rewards, without_metrics+ )without_custom_scores = average_custom_metrics(without_logical_rewards)without_pass = _pass_summary(without_logical_rewards,@@ -6480,12 +6540,22 @@ def collect_harbor_results(stop_on_pass=stop_on_pass,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"+ )if without_execution["execution_status"] != "succeeded":without_scores = {}without_custom_scores = {}without_pass = {}without_overall_score = (- _aggregate_condition_overall(without_scores, without_metrics, without_logical_rewards)+ _aggregate_condition_overall(+ without_scores,+ without_metrics,+ without_logical_rewards,+ score_policy=without_policy,+ )if without_execution["execution_status"] == "succeeded"else None)@@ -6511,7 +6581,7 @@ def collect_harbor_results("overall_score": without_overall_score,"metric_set": without_metric_set,"metrics": list(without_metrics),- "score_policy": score_policy_for_metrics(without_metrics),+ "score_policy": without_policy,"dimensions": dimension_scores(without_scores),"num_trials": len(without_rewards),"pass_at_k": without_pass,@@ -6606,7 +6676,6 @@ 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@@ -6656,14 +6725,10 @@ def collect_harbor_results()if paired_execution_succeeded and with_scores and without_scores:lift = _compute_lift(with_scores, without_scores)- # The policy and scored metric set must match before comparing- # overall scores; shared per-metric deltas remain useful separately.+ # 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 (- set(with_metrics) == set(without_metrics)- and with_overall_score is not None- and without_overall_score is not 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,@@ -6741,8 +6806,6 @@ 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,@@ -6785,14 +6848,46 @@ def collect_harbor_results("output_dir": str(agent_dir.resolve()),}+ scored_policies = {+ info["score_policy_with_skill"]+ 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+ if run_policy_conflict:+ all_results["score_policy"] = "mixed-score-policies"+ all_results["attempt_policy"]["score_policy"] = "mixed-score-policies"+ all_results["attempt_policy"]["score_definition"] = (+ "overall unavailable: conflicting score policies across agents"+ )+ elif scored_policies:+ score_policy = next(iter(scored_policies))+ scored_agent = next(+ info for info in all_results["agents"].values() if info.get("execution_status") == "succeeded"+ )+ selected_metrics = tuple(metric for metric in DEFAULT_METRICS if metric in scored_agent["with_skill"])+ all_results["metric_set"] = (+ DEFAULT_METRIC_SET+ if "security" in selected_metrics+ else (LEGACY_METRIC_SET if selected_metrics else CUSTOM_ONLY_METRIC_SET)+ )+ all_results["metrics"] = list(selected_metrics)+ all_results["score_policy"] = score_policy+ all_results["attempt_policy"]["score_policy"] = score_policy+ all_results["attempt_policy"]["score_definition"] = _score_definition_for_policy(selected_metrics, score_policy)_write_generated_root_json(output_dir / "attempt_policy.json", output_dir, all_results["attempt_policy"])- if len(agents) > 1:+ if len(agents) > 1 and not run_policy_conflict:comparison = _build_comparison(all_results["agents"])all_results["comparison"] = comparison_write_generated_root_json(output_dir / "comparison.json", output_dir, comparison)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))+ )all_results.update(top_execution)if top_execution["execution_errors"]:all_results["error"] = list(top_execution["execution_errors"])diff --git a/src/skillevaluator/tier3/harbor/metrics.py b/src/skillevaluator/tier3/harbor/metrics.pyindex 5d63cd07..b5bdcca3 100644--- a/src/skillevaluator/tier3/harbor/metrics.py+++ b/src/skillevaluator/tier3/harbor/metrics.py@@ -18,6 +18,9 @@ CUSTOM_ONLY_METRIC_SET = "custom-only"LEGACY_SCORE_POLICY = "skill-evaluator-metric-mean-v1"CUSTOM_SCORE_POLICY = "custom-overall-v1"PARTIAL_SCORE_POLICY = "legacy-partial-dimension-mean-v1"+SUPPORTED_SCORE_POLICIES = frozenset(+ {DEFAULT_SCORE_POLICY, LEGACY_SCORE_POLICY, CUSTOM_SCORE_POLICY, PARTIAL_SCORE_POLICY}+)DEFAULT_METRICS = ("security",@@ -100,6 +103,7 @@ _RESERVED_METADATA_KEYS = {"metric_set_version","metrics","overall",+ "score_policy","trajectory_detail","trajectory_source",}@@ -353,9 +357,9 @@ def canonical_dimension_mean(values: Iterable[object]) -> float | None:if len(raw_values) != len(DIMENSION_DEFINITIONS):return Nonenumeric = tuple(_finite_number(value) for value in raw_values)- if any(value is None for value in numeric):+ if any(value is None or not 0.0 <= value <= 1.0 for value in numeric):return None- return sum(value for value in numeric if value is not None) / len(numeric)+ return round(sum(value for value in numeric if value is not None) / len(numeric), 4)def overall_score_from_metrics(@@ -364,7 +368,7 @@ def overall_score_from_metrics() -> float | None:"""Aggregate one metric set using its versioned score policy."""values = tuple(_finite_number(scores.get(metric)) for metric in metrics)- if not values or any(value is None for value in values):+ if not values or any(value is None or not 0.0 <= value <= 1.0 for value in values):return Noneif metrics != LEGACY_METRICS and all(metric in DEFAULT_METRICS for metric in metrics):@@ -374,9 +378,9 @@ def overall_score_from_metrics()if metrics == DEFAULT_METRICS:return canonical_dimension_mean(dimension_values)- return sum(dimension_values) / len(dimension_values) if dimension_values else None+ return round(sum(dimension_values) / len(dimension_values), 4) if dimension_values else None- return sum(value for value in values if value is not None) / len(values)+ return round(sum(value for value in values if value is not None) / len(values), 4)def overall_score(reward: dict[str, Any]) -> float | None:@@ -387,10 +391,36 @@ 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)- if metrics:- return overall_score_from_metrics({metric: metric_value(reward, metric) for metric in metrics}, metrics)+ persisted = _finite_number(reward.get("overall"))+ if persisted is not None and not 0.0 <= persisted <= 1.0:+ persisted = None+ policy = reward.get("score_policy")+ policy = policy.strip() if isinstance(policy, str) and policy.strip() else None+ if not metrics:+ return persisted if policy in {None, CUSTOM_SCORE_POLICY} else None+ if policy == CUSTOM_SCORE_POLICY:+ return None+ if policy == DEFAULT_SCORE_POLICY and metrics != DEFAULT_METRICS:+ return None+ if policy == PARTIAL_SCORE_POLICY and metrics in {DEFAULT_METRICS, LEGACY_METRICS}:+ return None- return score_value(reward.get("overall"))+ scores = {metric: metric_value(reward, metric) for metric in metrics}+ if any(value is None or not 0.0 <= value <= 1.0 for value in scores.values()):+ return None+ if policy is None:+ current = overall_score_from_metrics(scores, metrics)+ if persisted is not None and metrics == DEFAULT_METRICS:+ historical = round(sum(value for value in scores.values() if value is not None) / len(scores), 4)+ if round(persisted, 4) == historical and historical != current:+ return historical+ return current+ if policy not in SUPPORTED_SCORE_POLICIES:+ # A new attempt using an unknown formula cannot be scored here.+ return None+ if policy == LEGACY_SCORE_POLICY:+ return round(sum(scores.values()) / len(scores), 4)+ return overall_score_from_metrics(scores, metrics)def score_definition(metrics: tuple[str, ...] = DEFAULT_METRICS) -> str:diff --git a/src/skillevaluator/tier3/harbor/report.py b/src/skillevaluator/tier3/harbor/report.pyindex 346e2ac3..548ec1b0 100644--- a/src/skillevaluator/tier3/harbor/report.py+++ b/src/skillevaluator/tier3/harbor/report.py@@ -20,12 +20,15 @@ from skillevaluator.evidence import evidence_ref_identityfrom skillevaluator.tier3.eval_core.llm_judge import _redact_configured_credentialsfrom skillevaluator.tier3.harbor import report_datafrom skillevaluator.tier3.harbor.metrics import (+ DEFAULT_METRIC_SET,DEFAULT_METRICS,- MAX_CUSTOM_METRICS,+ LEGACY_METRIC_SET,+ LEGACY_SCORE_POLICY,METRIC_DESCRIPTIONS,METRIC_DISPLAY,METRIC_QUESTIONS,extract_custom_metrics,+ overall_score,overall_score_from_metrics,)from skillevaluator.tier3.output_provenance import write_output_file_atomically@@ -140,11 +143,11 @@ def _pick_best_agent(or any(metric_value(with_scores, metric) is None for metric in standard_metrics)):continue- metrics = tuple(report_data.metrics_for_condition(data, "with_skill"))+ metrics = tuple(m for m in DISPLAY_METRICS if m in with_scores) or DISPLAY_METRICSif data.get("score_policy_with_skill") == LEGACY_SCORE_POLICY:overall = overall_score({- "metric_set": DEFAULT_METRIC_SET if "security" in metrics else LEGACY_METRIC_SET,+ "metric_set": DEFAULT_METRIC_SET if "security" in with_scores else LEGACY_METRIC_SET,"score_policy": LEGACY_SCORE_POLICY,**with_scores,}diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.pyindex ad19318e..b77cae21 100644--- a/src/skillevaluator/tier3/harbor/runner.py+++ b/src/skillevaluator/tier3/harbor/runner.py@@ -86,12 +86,12 @@ from skillevaluator.tier3.harbor.adapter import ()from skillevaluator.tier3.harbor.artifact_retention import HarborArtifactLifecycle, RetentionOutcomefrom skillevaluator.tier3.harbor.collector import (- TRUNCATED_AGGREGATE_ATTEMPT_PREFIX,+ _score_definition_for_policy,collect_harbor_results,harbor_job_passed,validate_harbor_job_result,)-from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS, score_definition, score_policy_for_metrics+from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS, score_policy_for_metricsfrom skillevaluator.tier3.harbor.progress import (MIN_EXACT_SECRET_CHARS,NullProgressReporter,@@ -4770,15 +4770,25 @@ def _run_harbor_eval_impl("dataset_digest": dataset_truth["dataset_digest"],"dataset_digest_algorithm": dataset_truth["dataset_digest_algorithm"],"run_config": run_config,- "attempt_policy": {- "max_attempts": n_attempts,- "pass_threshold": float(pass_threshold),- "stop_on_pass": bool(stop_on_pass),- "score_definition": score_definition(tuple(results.get("metrics", DEFAULT_METRICS))),- "score_policy": score_policy_for_metrics(tuple(results.get("metrics", DEFAULT_METRICS))),- },})+ selected_metrics = tuple(results.get("metrics", DEFAULT_METRICS))+ collected_attempt_policy = results.get("attempt_policy")+ attempt_policy = dict(collected_attempt_policy) if isinstance(collected_attempt_policy, dict) else {}+ selected_policy = results.get("score_policy") or attempt_policy.get("score_policy")+ if not isinstance(selected_policy, str) or not selected_policy.strip():+ selected_policy = score_policy_for_metrics(selected_metrics)+ attempt_policy.update(+ {+ "max_attempts": n_attempts,+ "pass_threshold": float(pass_threshold),+ "stop_on_pass": bool(stop_on_pass),+ "score_policy": selected_policy,+ "score_definition": attempt_policy.get("score_definition")+ or _score_definition_for_policy(selected_metrics, selected_policy),+ }+ )+ results["attempt_policy"] = attempt_policy_finalize_harbor_artifacts(run_dir_value=run_dir,keep_requested=keep_harbor_jobs,diff --git a/src/skillevaluator/tier3/harbor/templates/eval.py b/src/skillevaluator/tier3/harbor/templates/eval.pyindex 7b32e59c..f1ae290d 100644--- a/src/skillevaluator/tier3/harbor/templates/eval.py+++ b/src/skillevaluator/tier3/harbor/templates/eval.py@@ -174,6 +174,7 @@ WASTE_INDICATORS = []DEFAULT_METRIC_SET = "skill-evaluator-default-v2"+DEFAULT_SCORE_POLICY = "skill-evaluator-dimension-mean-v1"DISPLAY_METRICS = ["security","skill_execution",@@ -8752,6 +8753,7 @@ def main():"goal_accuracy": 0,"behavior_check": 0,"metric_set": DEFAULT_METRIC_SET,+ "score_policy": DEFAULT_SCORE_POLICY,"error": "No trajectory or reconstructible agent log","trajectory_source": traj_meta.get("source"),"trajectory_detail": traj_meta.get("warning") or traj_meta.get("note"),@@ -8888,6 +8890,7 @@ def main():"goal_accuracy": ga_score,"behavior_check": bc_score,"metric_set": DEFAULT_METRIC_SET,+ "score_policy": DEFAULT_SCORE_POLICY,"entry_id": entry.get("id"),"has_skill": entry.get("has_skill", True),"trajectory_source": traj_meta.get("source"),diff --git a/src/skillevaluator/tier3/harbor/templates/metric.py b/src/skillevaluator/tier3/harbor/templates/metric.pyindex 91cce43e..017469de 100644--- a/src/skillevaluator/tier3/harbor/templates/metric.py+++ b/src/skillevaluator/tier3/harbor/templates/metric.py@@ -14,6 +14,7 @@ Output: JSON with six averaged evaluator scores and their five-dimension overallimport argparseimport json+import mathfrom pathlib import PathDEFAULT_METRICS = [@@ -31,29 +32,73 @@ LEGACY_METRICS = ["goal_accuracy","behavior_check",]+DEFAULT_SCORE_POLICY = "skill-evaluator-dimension-mean-v1"+LEGACY_SCORE_POLICY = "skill-evaluator-metric-mean-v1"def _metrics_for_rewards(rewards: list[dict]) -> list[str]:- if any(isinstance(reward.get("security"), int | float) for reward in rewards):+ declared = {reward.get("metric_set") for reward in rewards if reward.get("metric_set")}+ if len(declared) > 1:+ raise ValueError("Cannot aggregate rewards with different metric sets")+ if declared == {"skill-evaluator-default-v2"}:return DEFAULT_METRICS- if any(any(isinstance(reward.get(m), int | float) for m in LEGACY_METRICS) for reward in rewards):+ if declared == {"skill-evaluator-default-v1"}:return LEGACY_METRICS- return DEFAULT_METRICS+ if declared:+ raise ValueError("Unsupported reward metric set")+ if any("security" in reward for reward in rewards):+ return DEFAULT_METRICS+ if any(any(m in reward for m in LEGACY_METRICS) for reward in rewards):+ return LEGACY_METRICS+ raise ValueError("No supported SkillEvaluator metrics in rewards")+++def _score_policy_for_rewards(rewards: list[dict], metrics: list[str]) -> str:+ declared = [reward.get("score_policy") for reward in rewards]+ if any(policy is not None for policy in declared):+ if any(not isinstance(policy, str) or not policy.strip() for policy in declared):+ raise ValueError("Cannot aggregate rewards with missing score policies")+ policies = {policy.strip() for policy in declared}+ if len(policies) != 1:+ raise ValueError("Cannot aggregate rewards with different score policies")+ policy = policies.pop()+ else:+ policy = DEFAULT_SCORE_POLICY if metrics == DEFAULT_METRICS else LEGACY_SCORE_POLICY+ if policy not in {DEFAULT_SCORE_POLICY, LEGACY_SCORE_POLICY}:+ raise ValueError("Unsupported reward score policy")+ if policy == DEFAULT_SCORE_POLICY and metrics != DEFAULT_METRICS:+ raise ValueError("Current score policy requires the default v2 metric set")+ return policy+++def _unit_score(value: object) -> float | None:+ if isinstance(value, bool) or not isinstance(value, int | float):+ return None+ try:+ numeric = float(value)+ except OverflowError:+ return None+ return numeric if math.isfinite(numeric) and 0.0 <= numeric <= 1.0 else Nonedef main(input_path: Path, output_path: Path) -> None:rewards: list[dict] = []- for line in input_path.read_text().splitlines():+ for line in input_path.read_text(encoding="utf-8").splitlines():line = line.strip()if not line:continuereward = json.loads(line)if reward is None:continue+ if not isinstance(reward, dict):+ raise ValueError("Expected one reward object per JSONL row")rewards.append(reward)+ if not rewards:+ raise ValueError("No rewards to aggregate")metrics = _metrics_for_rewards(rewards)+ score_policy = _score_policy_for_rewards(rewards, metrics)sums: dict[str, float] = dict.fromkeys(metrics, 0.0)counts: dict[str, int] = dict.fromkeys(metrics, 0)@@ -63,16 +108,18 @@ def main(input_path: Path, output_path: Path) -> None:if val is None and isinstance(reward.get("metrics"), dict):m_data = reward["metrics"].get(metric)val = m_data.get("score") if isinstance(m_data, dict) else m_data- if isinstance(val, (int, float)):- sums[metric] += float(val)- counts[metric] += 1+ score = _unit_score(val)+ if score is None:+ raise ValueError(f"Incomplete or invalid {metric} reward")+ sums[metric] += score+ counts[metric] += 1- result: dict[str, float] = {}+ result: dict[str, float | str] = {}for metric in metrics:c = counts[metric]- result[metric] = round(sums[metric] / c, 4) if c > 0 else 0.0+ result[metric] = round(sums[metric] / c, 4)- if metrics == DEFAULT_METRICS:+ if score_policy == DEFAULT_SCORE_POLICY:dimensions = (result["security"],result["accuracy"],@@ -82,8 +129,9 @@ def main(input_path: Path, output_path: Path) -> None:)result["overall"] = round(sum(dimensions) / len(dimensions), 4)else:- result["overall"] = round(sum(result.values()) / len(result), 4) if result else 0.0+ result["overall"] = round(sum(float(result[metric]) for metric in metrics) / len(metrics), 4)result["metric_set"] = "skill-evaluator-default-v2" if "security" in metrics else "skill-evaluator-default-v1"+ result["score_policy"] = score_policyoutput_path.write_text(json.dumps(result, indent=2))diff --git a/src/skillevaluator/tier3/result_display.py b/src/skillevaluator/tier3/result_display.pyindex 8f20b8c1..12cf2bb2 100644--- a/src/skillevaluator/tier3/result_display.py+++ b/src/skillevaluator/tier3/result_display.py@@ -24,7 +24,9 @@ from skillevaluator.tier3.harbor.metrics import (CUSTOM_ONLY_METRIC_SET,DEFAULT_METRIC_SET,DEFAULT_METRICS,+ DEFAULT_SCORE_POLICY,DIMENSION_DISPLAY,+ LEGACY_SCORE_POLICY,METRIC_DISPLAY,overall_score_from_metrics,)@@ -127,19 +129,35 @@ def _custom_only_with_skill_overall(data: Mapping[str, Any]) -> float | None:return round(sum(scores) / len(scores), 4)-def _with_skill_overall(data: Mapping[str, Any], metric_set: object) -> float | None:+def _with_skill_overall(+ data: Mapping[str, Any], metric_set: object, *, score_policy: object = DEFAULT_SCORE_POLICY+) -> float | None:if data.get("execution_status") != "succeeded":return Noneif _condition_status(data, "without_skill") == "skipped":if metric_set == DEFAULT_METRIC_SET:- return _default_with_skill_overall(data)+ if score_policy == DEFAULT_SCORE_POLICY:+ return _default_with_skill_overall(data)+ persisted = _finite_number(data.get("overall_with_skill"))+ if persisted is not None:+ return persisted+ if score_policy == LEGACY_SCORE_POLICY or score_policy is None:+ scores = data.get("with_skill")+ if isinstance(scores, Mapping):+ values = [_finite_number(scores.get(metric)) for metric in DEFAULT_METRICS]+ if all(value is not None for value in values):+ return round(sum(value for value in values if value is not None) / len(values), 4)+ return Noneif metric_set == CUSTOM_ONLY_METRIC_SET:return _custom_only_with_skill_overall(data)return Nonelift = data.get("lift")overall = lift.get("overall") if isinstance(lift, Mapping) else None+ if not isinstance(overall, Mapping) and metric_set == CUSTOM_ONLY_METRIC_SET:+ custom_lift = data.get("custom_lift")+ overall = custom_lift.get("overall") if isinstance(custom_lift, Mapping) else Nonepersisted = overall.get("with_skill") if isinstance(overall, Mapping) else Nonereturn _finite_number(persisted)@@ -441,11 +459,17 @@ def _render_agent_scores(table.add_row(*row)if not metrics and not custom_with and not custom_without and not show_baseline:- with_overall = _with_skill_overall(data, result.get("metric_set"))+ with_overall = _with_skill_overall(+ data,+ result.get("metric_set"),+ score_policy=data.get("score_policy_with_skill", result.get("score_policy")),+ )score, bar = _score_cell(with_overall)table.add_row(Text("Overall", style="bold"), score, bar)overall = lift.get("overall") if isinstance(lift.get("overall"), Mapping) else {}+ if not overall and result.get("metric_set") == CUSTOM_ONLY_METRIC_SET:+ overall = custom_lift.get("overall") if isinstance(custom_lift.get("overall"), Mapping) else {}with_overall = overall.get("with_skill") if with_usable else Nonebaseline_overall = overall.get("without_skill") if baseline_usable else Noneif show_baseline and (_finite_number(with_overall) is not None or _finite_number(baseline_overall) is not None):@@ -458,7 +482,7 @@ def _render_agent_scores(else None)table.add_row(- Text("Skill Lift", style="bold"),+ Text("Overall" if result.get("metric_set") == CUSTOM_ONLY_METRIC_SET else "Skill Lift", style="bold"),with_score,with_bar,baseline_score,diff --git a/tests/reporting/test_unified_tier3_report.py b/tests/reporting/test_unified_tier3_report.pyindex 284e46e1..1e2eb6dc 100644--- a/tests/reporting/test_unified_tier3_report.py+++ b/tests/reporting/test_unified_tier3_report.py@@ -814,6 +814,7 @@ def test_authenticated_pre_status_rerender_preserves_historical_scores(tmp_path:pytest.param(2.0, None, LEGACY_SCORE_POLICY, 0.5583, id="out-of-range-overall"),pytest.param(10**4000, None, LEGACY_SCORE_POLICY, 0.5583, id="overflowing-overall"),pytest.param(None, DEFAULT_SCORE_POLICY, DEFAULT_SCORE_POLICY, 0.49, id="current-policy"),+ pytest.param(0.5583, "future-weighted-policy-v2", "future-weighted-policy-v2", 0.5583, id="future-policy"),],)def test_default_v2_rerender_respects_recorded_or_historical_policy(@@ -851,6 +852,8 @@ def test_default_v2_rerender_respects_recorded_or_historical_policy(if recorded_policy is not None:summary_payload["score_policy"] = recorded_policysummary.write_text(json.dumps(summary_payload), encoding="utf-8")+ if evaluated_source is not None:+ (run_dir / "run_config.json").write_text(json.dumps({"evaluated_source": evaluated_source}), encoding="utf-8")if recorded_policy is None:comparison_summary = run_dir / "codex" / "with-skill" / "summary.json"comparison_summary.parent.mkdir(parents=True)@@ -889,6 +892,9 @@ def test_default_v2_rerender_respects_recorded_or_historical_policy(definition = payload["attempt_policy"]["score_definition"]if expected_policy == LEGACY_SCORE_POLICY:assert definition.startswith("overall = mean(security,")+ elif expected_policy == "future-weighted-policy-v2":+ assert "future-weighted-policy-v2" in definition+ assert DEFAULT_SCORE_POLICY not in definitionelse:assert "mean(Security, Correctness, Discoverability, Effectiveness, Efficiency)" in definition@@ -952,7 +958,6 @@ def test_canonical_report_fails_closed_on_different_condition_policies() -> Noneassert payload["execution_status"] == "failed"assert payload["overall_score"] is Noneassert payload["overall_lift"] is None- assert payload["agents"]["opencode"]["lift"] is Noneassert any("conflicting score policies" in error.lower() for error in payload["execution_errors"])@@ -1028,77 +1033,6 @@ 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.pyindex b7182064..28ffe67e 100644--- a/tests/test_harbor_metrics_truth.py+++ b/tests/test_harbor_metrics_truth.py@@ -29,16 +29,18 @@ from skillevaluator.tier3.harbor.collector import (_pass_rate_delta,_pass_summary,_probability_text,- _public_pass_summary,+ _score_policy_for_rewards,_wilson_score_interval,)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,average_metrics,canonical_dimension_mean,extract_custom_metrics,@@ -245,6 +247,15 @@ def test_overall_score_requires_a_complete_finite_metric_set() -> None:assert overall_score({"metric_set": CUSTOM_ONLY_METRIC_SET, "overall": float("nan")}) is None[email protected]("invalid", [-0.1, 1.1])+def test_default_overall_rejects_out_of_range_evaluator_scores(invalid: float) -> None:+ scores = dict.fromkeys(DEFAULT_METRICS, 0.5)+ scores["security"] = invalid++ assert overall_score_from_metrics(scores) is None+ assert overall_score({"metric_set": DEFAULT_METRIC_SET, **scores}) is None++def test_default_overall_score_uses_the_canonical_dimension_mean() -> None:reward = {"metric_set": DEFAULT_METRIC_SET,@@ -265,6 +276,72 @@ def test_default_overall_score_uses_the_canonical_dimension_mean() -> None:)+def test_pre_policy_default_reward_preserves_its_persisted_overall() -> None:+ reward = {+ "metric_set": DEFAULT_METRIC_SET,+ "security": 0.3875,+ "skill_execution": 0.3875,+ "skill_efficiency": 0.3875,+ "accuracy": 0.3875,+ "goal_accuracy": 0.9,+ "behavior_check": 0.9,+ "overall": 0.5583,+ }++ assert "score_policy" not in reward+ assert overall_score(reward) == pytest.approx(0.5583)+++def test_default_overall_rounds_at_the_canonical_policy_boundary() -> None:+ scores = dict.fromkeys(DEFAULT_METRICS, 0.0)+ scores["security"] = 0.0001++ assert overall_score_from_metrics(scores) == 0.0+++def test_score_policy_metadata_is_not_a_custom_metric() -> None:+ assert extract_custom_metrics({"score_policy": 0.75}) == {}+++def test_known_legacy_policy_uses_metrics_even_if_stored_overall_disagrees() -> None:+ reward = {+ "metric_set": DEFAULT_METRIC_SET,+ "score_policy": LEGACY_SCORE_POLICY,+ **dict.fromkeys(DEFAULT_METRICS, 0.2),+ "overall": 0.9,+ }++ assert overall_score(reward) == 0.2+++def test_unknown_reward_policy_cannot_score_a_new_attempt() -> None:+ reward = {+ "metric_set": DEFAULT_METRIC_SET,+ "score_policy": "future-weighted-policy-v2",+ **dict.fromkeys(DEFAULT_METRICS, 0.2),+ "overall": 0.9,+ }++ assert overall_score(reward) is None+++ ("metric_set", "policy", "metrics", "score"),+ [+ (DEFAULT_METRIC_SET, CUSTOM_SCORE_POLICY, DEFAULT_METRICS, 0.9),+ (LEGACY_METRIC_SET, DEFAULT_SCORE_POLICY, LEGACY_METRICS, 0.9),+ (CUSTOM_ONLY_METRIC_SET, DEFAULT_SCORE_POLICY, (), 0.9),+ (CUSTOM_ONLY_METRIC_SET, CUSTOM_SCORE_POLICY, (), 1.1),+ ],+)+def test_reward_rejects_incompatible_policy_or_out_of_range_custom_overall(+ metric_set: str, policy: str, metrics: tuple[str, ...], score: float+) -> None:+ reward = {"metric_set": metric_set, "score_policy": policy, **dict.fromkeys(metrics, 0.2), "overall": score}++ assert overall_score(reward) is None++def test_best_agent_selection_uses_the_canonical_dimension_mean() -> None:direction_reversing = {"security": 0.3875,@@ -286,6 +363,33 @@ def test_best_agent_selection_uses_the_canonical_dimension_mean() -> None:assert _pick_best_agent(agents) == "dimension-mean-winner"+def test_best_agent_selection_respects_historical_policy_scores() -> None:+ historical_scores = {+ "security": 0.3875,+ "skill_execution": 0.3875,+ "skill_efficiency": 0.3875,+ "accuracy": 0.3875,+ "goal_accuracy": 0.9,+ "behavior_check": 0.9,+ }+ agents = {+ "historical-winner": {+ "execution_status": "succeeded",+ "with_skill": historical_scores,+ "overall_with_skill": 0.5583,+ "score_policy_with_skill": LEGACY_SCORE_POLICY,+ },+ "current-winner": {+ "execution_status": "succeeded",+ "with_skill": dict.fromkeys(DEFAULT_METRICS, 0.52),+ "overall_with_skill": 0.52,+ "score_policy_with_skill": DEFAULT_SCORE_POLICY,+ },+ }++ assert _pick_best_agent(agents) == "historical-winner"++def test_standalone_harbor_metric_aggregation_uses_the_canonical_dimension_mean(tmp_path: Path) -> None:reward = {"metric_set": DEFAULT_METRIC_SET,@@ -309,7 +413,9 @@ def test_standalone_harbor_metric_aggregation_uses_the_canonical_dimension_mean()assert completed.returncode == 0, completed.stderr- assert json.loads(output_path.read_text(encoding="utf-8"))["overall"] == 0.49+ artifact = json.loads(output_path.read_text(encoding="utf-8"))+ assert artifact["overall"] == 0.49+ assert artifact["score_policy"] == DEFAULT_SCORE_POLICYprecision_reward = {"metric_set": DEFAULT_METRIC_SET,@@ -332,6 +438,111 @@ def test_standalone_harbor_metric_aggregation_uses_the_canonical_dimension_mean(assert json.loads(output_path.read_text(encoding="utf-8"))["overall"] == 0.0001+def test_standalone_harbor_metric_aggregation_preserves_explicit_legacy_policy(tmp_path: Path) -> None:+ reward = {+ "metric_set": DEFAULT_METRIC_SET,+ "score_policy": LEGACY_SCORE_POLICY,+ "security": 0.3875,+ "skill_execution": 0.3875,+ "skill_efficiency": 0.3875,+ "accuracy": 0.3875,+ "goal_accuracy": 0.9,+ "behavior_check": 0.9,+ }+ input_path = tmp_path / "rewards.jsonl"+ output_path = tmp_path / "metrics.json"+ input_path.write_text(json.dumps(reward) + "\n", encoding="utf-8")+ metric_script = Path(__file__).parents[1] / "src/skillevaluator/tier3/harbor/templates/metric.py"++ completed = subprocess.run(+ [sys.executable, str(metric_script), "-i", str(input_path), "-o", str(output_path)],+ check=False,+ capture_output=True,+ text=True,+ )++ assert completed.returncode == 0, completed.stderr+ artifact = json.loads(output_path.read_text(encoding="utf-8"))+ assert artifact["overall"] == 0.5583+ assert artifact["score_policy"] == LEGACY_SCORE_POLICY++ input_path.write_text(+ json.dumps(reward) + "\n" + json.dumps({**reward, "score_policy": DEFAULT_SCORE_POLICY}) + "\n",+ encoding="utf-8",+ )+ completed = subprocess.run(+ [sys.executable, str(metric_script), "-i", str(input_path), "-o", str(output_path)],+ check=False,+ capture_output=True,+ text=True,+ )+ assert completed.returncode != 0+++def test_explicit_legacy_policy_rejects_out_of_range_metric_values() -> None:+ reward = {+ "metric_set": DEFAULT_METRIC_SET,+ "score_policy": LEGACY_SCORE_POLICY,+ **dict.fromkeys(DEFAULT_METRICS, 0.5),+ "security": 1.5,+ }++ assert overall_score(reward) is None+++def test_collapsed_equal_score_steps_remain_policy_ambiguous() -> None:+ equal = {+ "entry_id": "case-001",+ "metric_set": DEFAULT_METRIC_SET,+ **dict.fromkeys(DEFAULT_METRICS, 0.5),+ "overall": 0.5,+ "_trial_root_name": "case-001__attempt",+ "_step_name": "step-1",+ }+ historical = {+ "entry_id": "case-002",+ "metric_set": DEFAULT_METRIC_SET,+ **dict.fromkeys(DEFAULT_METRICS, 0.3875),+ "goal_accuracy": 0.9,+ "behavior_check": 0.9,+ "overall": 0.5583,+ "_trial_root_name": "case-002__attempt",+ }++ logical = _logical_attempt_rewards([equal, {**equal, "_step_name": "step-2"}, historical])++ assert "score_policy" not in logical[0]+ assert _score_policy_for_rewards(logical, DEFAULT_METRICS) == (LEGACY_SCORE_POLICY, False)+++ "change",+ [+ {"behavior_check": None},+ {"security": float("nan")},+ {"security": 1.1},+ ],+)+def test_standalone_metric_rejects_incomplete_or_invalid_default_rewards(+ tmp_path: Path, change: dict[str, object]+) -> None:+ reward = {"metric_set": DEFAULT_METRIC_SET, **dict.fromkeys(DEFAULT_METRICS, 0.5), **change}+ input_path = tmp_path / "rewards.jsonl"+ output_path = tmp_path / "metrics.json"+ input_path.write_text(json.dumps(reward) + "\n", encoding="utf-8")+ metric_script = Path(__file__).parents[1] / "src/skillevaluator/tier3/harbor/templates/metric.py"++ completed = subprocess.run(+ [sys.executable, str(metric_script), "-i", str(input_path), "-o", str(output_path)],+ check=False,+ capture_output=True,+ text=True,+ )++ assert completed.returncode != 0+ assert not output_path.exists()++def test_legacy_overall_score_preserves_the_historical_metric_mean() -> None:reward = {"metric_set": LEGACY_METRIC_SET,diff --git a/tests/test_harbor_runner_environment.py b/tests/test_harbor_runner_environment.pyindex a05a0e30..e5d56b89 100644--- a/tests/test_harbor_runner_environment.py+++ b/tests/test_harbor_runner_environment.py@@ -20,7 +20,7 @@ from harbor.utils.env import resolve_env_varsfrom skillevaluator.provider_config import ProviderConfig, ProviderConfigurationError, resolve_llm_providerfrom skillevaluator.tier3.harbor import runner, runtime_preflightfrom skillevaluator.tier3.harbor.adapter import _verifier_env_vars-from skillevaluator.tier3_environments import HARBOR_NATIVE_ENV_MODES+from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS, LEGACY_SCORE_POLICYdef _provider(provider: str = "openai") -> ProviderConfig:@@ -1191,10 +1191,17 @@ def test_run_harbor_eval_stages_per_agent_credential_trees(monkeypatch.setattr(runner,"collect_harbor_results",- lambda **kwargs: (- collected.update(kwargs)- or {"execution_status": "complete", "execution_errors": [], "metrics": [], "agents": {}}- ),+ lambda **_kwargs: {+ "execution_status": "complete",+ "execution_errors": [],+ "metrics": list(DEFAULT_METRICS),+ "score_policy": LEGACY_SCORE_POLICY,+ "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(@@ -1211,6 +1218,11 @@ def test_run_harbor_eval_stages_per_agent_credential_trees()assert "error" not in result+ assert result["score_policy"] == result["attempt_policy"]["score_policy"] == LEGACY_SCORE_POLICY+ assert result["attempt_policy"]["score_definition"] == "historical six-metric mean"+ assert result["attempt_policy"]["max_attempts"] == 1+ persisted = json.loads(Path(result["result_path"]).read_text(encoding="utf-8"))+ assert persisted["attempt_policy"]["score_policy"] == LEGACY_SCORE_POLICYassert {(path.split("/")[-2], path.split("/")[-1], with_skill)for path, with_skill, _runtime_env, _verifier_env in emitteddiff --git a/tests/test_issue55_collector_truth.py b/tests/test_issue55_collector_truth.pyindex ed12143f..e29cb3d3 100644--- a/tests/test_issue55_collector_truth.py+++ b/tests/test_issue55_collector_truth.py@@ -30,9 +30,7 @@ from skillevaluator.tier3.harbor.metrics import (DEFAULT_SCORE_POLICY,LEGACY_METRIC_SET,LEGACY_METRICS,- MAX_CUSTOM_METRIC_NAME_BYTES,- MAX_CUSTOM_METRICS,- extract_custom_metrics,+ LEGACY_SCORE_POLICY,overall_score,)@@ -426,112 +424,6 @@ 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.pyindex 67845232..56e8a527 100644--- a/tests/test_tier3_compare.py+++ b/tests/test_tier3_compare.py@@ -7,12 +7,18 @@ from __future__ import annotationsimport jsonimport os+import refrom pathlib import Pathimport pytestfrom skillevaluator.tier3.commands import _overall_score_for_display, _summary_overall, compare_results-from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS, DEFAULT_SCORE_POLICY+from skillevaluator.tier3.harbor.metrics import (+ CUSTOM_SCORE_POLICY,+ DEFAULT_METRICS,+ DEFAULT_SCORE_POLICY,+ LEGACY_SCORE_POLICY,+)from skillevaluator.tier3.output_provenance import mark_generated_output_root@@ -37,6 +43,33 @@ def test_compare_overall_uses_the_canonical_dimension_mean() -> None:assert _overall_score_for_display(scores, DEFAULT_METRICS) == pytest.approx(0.49)+def test_compare_rejects_cross_agent_overalls_with_different_score_policies(+ 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, policy in (("current", DEFAULT_SCORE_POLICY), ("historical", LEGACY_SCORE_POLICY)):+ summary = run_dir / agent / "with-skill" / "summary.json"+ summary.parent.mkdir(parents=True)+ summary.write_text(+ json.dumps(+ {+ "execution_status": "succeeded",+ "scores": dict.fromkeys(DEFAULT_METRICS, 0.5),+ "overall_score": 0.5,+ "score_policy": policy,+ "num_trials": 1,+ }+ ),+ encoding="utf-8",+ )+ _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_overall_display_preserves_pre_policy_default_v2_semantics() -> None:scores = {"security": 0.3875,@@ -135,6 +168,144 @@ def test_compare_carries_persisted_historical_overall(assert "+0.06" in output+def test_compare_renders_scalar_only_custom_summaries(+ tmp_path: Path,+ capsys: pytest.CaptureFixture[str],+) -> None:+ skill_path = tmp_path / "demo"+ skill_path.mkdir()+ run_dir = tmp_path / "results" / "demo" / "20260709_010000"+ agent_dir = run_dir / "opencode"+ for condition, overall in (("with-skill", 0.8), ("without-skill", 0.4)):+ summary = agent_dir / condition / "summary.json"+ summary.parent.mkdir(parents=True)+ summary.write_text(+ json.dumps(+ {+ "execution_status": "succeeded",+ "scores": {},+ "custom_scores": {},+ "overall_score": overall,+ "score_policy": CUSTOM_SCORE_POLICY,+ "metric_set": "custom-only",+ "metrics": [],+ "num_trials": 1,+ }+ ),+ encoding="utf-8",+ )+ _complete_current_run(run_dir)++ assert compare_results(skill_path, results_dir=tmp_path / "results") == 0+ output = capsys.readouterr().out+ assert "Overall" in output+ assert "0.80" in output+ assert "+0.40" in output+ assert "No agent results" not in output+++def test_compare_does_not_fabricate_missing_standard_scores(+ tmp_path: Path,+ capsys: pytest.CaptureFixture[str],+) -> None:+ skill_path = tmp_path / "demo"+ skill_path.mkdir()+ run_dir = tmp_path / "results" / "demo" / "20260709_010000"+ summary = run_dir / "opencode" / "with-skill" / "summary.json"+ summary.parent.mkdir(parents=True)+ summary.write_text(+ json.dumps({"execution_status": "succeeded", "scores": {"security": 0.8}, "num_trials": 1}),+ encoding="utf-8",+ )+ _complete_current_run(run_dir)++ assert _overall_score_for_display({"security": 0.8}, DEFAULT_METRICS) is None+ assert compare_results(skill_path, results_dir=tmp_path / "results") == 0+ output = capsys.readouterr().out+ assert re.search(r"Accuracy\s+-", output, flags=re.IGNORECASE)+ assert re.search(r"Overall\s+-", output)+ assert "0.13" not in output+++def test_compare_ignores_nonfinite_component_scores() -> None:+ assert _overall_score_for_display({"security": float("nan")}, DEFAULT_METRICS) is None+ assert _overall_score_for_display({}, (), score_policy=CUSTOM_SCORE_POLICY) is None+++def test_compare_ignores_out_of_range_standard_scores() -> None:+ scores = dict.fromkeys(DEFAULT_METRICS, 0.5)+ scores["security"] = 2.0++ assert _overall_score_for_display(scores, DEFAULT_METRICS) is None+++def test_compare_does_not_pair_summaries_with_different_score_policies(+ 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 condition, score, policy in (+ ("with-skill", 0.8, DEFAULT_SCORE_POLICY),+ ("without-skill", 0.2, "skill-evaluator-metric-mean-v1"),+ ):+ summary = run_dir / "opencode" / condition / "summary.json"+ summary.parent.mkdir(parents=True)+ summary.write_text(+ json.dumps(+ {+ "execution_status": "succeeded",+ "scores": dict.fromkeys(DEFAULT_METRICS, score),+ "overall_score": score,+ "score_policy": policy,+ "num_trials": 1,+ }+ ),+ encoding="utf-8",+ )+ _complete_current_run(run_dir)++ assert compare_results(skill_path, results_dir=tmp_path / "results") == 0+ output = capsys.readouterr().out+ assert "0.80" in output+ assert "+0.60" not in output+ assert "lift" not in output.lower()+++def test_compare_does_not_pair_unversioned_metric_and_scalar_policies(+ 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 condition, scores, score in (+ ("with-skill", dict.fromkeys(DEFAULT_METRICS, 0.8), 0.8),+ ("without-skill", {}, 0.2),+ ):+ summary = run_dir / "opencode" / condition / "summary.json"+ summary.parent.mkdir(parents=True)+ summary.write_text(+ json.dumps(+ {+ "execution_status": "succeeded",+ "scores": scores,+ "overall_score": score,+ "num_trials": 1,+ }+ ),+ encoding="utf-8",+ )+ _complete_current_run(run_dir)++ assert compare_results(skill_path, results_dir=tmp_path / "results") == 0+ output = capsys.readouterr().out+ assert "0.80" in output+ assert "lift" not in output.lower()+ assert "+0.60" not in output++def _write_authentic_pre_status_run(root: Path, run_id: str, *, score: float = 0.8) -> Path:run_dir = root / run_idsummary_dir = run_dir / "opencode" / "with-skill"diff --git a/tests/test_tier3_result_display.py b/tests/test_tier3_result_display.pyindex d03441a0..6c5c6bee 100644--- a/tests/test_tier3_result_display.py+++ b/tests/test_tier3_result_display.py@@ -12,7 +12,13 @@ import pytestfrom rich.console import Consolefrom rich.panel import Panel-from skillevaluator.tier3.harbor.metrics import CUSTOM_ONLY_METRIC_SET, DEFAULT_METRIC_SET, DEFAULT_METRICS+from skillevaluator.tier3.harbor.metrics import (+ CUSTOM_ONLY_METRIC_SET,+ DEFAULT_METRIC_SET,+ DEFAULT_METRICS,+ DEFAULT_SCORE_POLICY,+ LEGACY_SCORE_POLICY,+)from skillevaluator.tier3.result_display import _with_skill_overall, render_evaluation_result, render_result@@ -204,6 +210,50 @@ def test_skip_baseline_default_overall_uses_the_dimension_score_policy() -> Noneassert _with_skill_overall(agent, DEFAULT_METRIC_SET) == pytest.approx(0.49)+def test_skip_baseline_historical_default_keeps_its_recorded_metric_mean() -> None:+ agent = _skip_baseline_agent(+ {+ "security": 0.3875,+ "skill_execution": 0.3875,+ "skill_efficiency": 0.3875,+ "accuracy": 0.3875,+ "goal_accuracy": 0.9,+ "behavior_check": 0.9,+ }+ )+ agent["score_policy_with_skill"] = LEGACY_SCORE_POLICY+ agent["overall_with_skill"] = 0.5583++ assert _with_skill_overall(agent, DEFAULT_METRIC_SET, score_policy=LEGACY_SCORE_POLICY) == 0.5583+ assert _with_skill_overall(agent, DEFAULT_METRIC_SET, score_policy=DEFAULT_SCORE_POLICY) == 0.49+++def test_paired_custom_only_result_displays_its_recorded_overall_lift() -> None:+ result = {+ "execution_status": "succeeded",+ "metric_set": CUSTOM_ONLY_METRIC_SET,+ "metrics": [],+ "agents": {+ "opencode": {+ "execution_status": "succeeded",+ "with_skill": {},+ "without_skill": {},+ "lift": {},+ "custom_lift": {"overall": {"with_skill": 0.8, "without_skill": 0.7, "delta": 0.1}},+ "conditions": {+ "with_skill": {"execution_status": "succeeded"},+ "without_skill": {"execution_status": "succeeded"},+ },+ }+ },+ }++ output = render_result(result)++ assert re.search(r"Overall\s+0\.80\s+\S*\s+0\.70\s+\S*\s+\+0\.10", output)+ assert "OVERALL SKILL LIFT +0.10" in output++def test_skip_baseline_custom_only_uses_persisted_attempt_scores() -> None:agent = _skip_baseline_agent({}, pass_rate=0.5)agent["pass_at_k"] = {diff --git a/tests/tier3/test_judge_failure_artifacts.py b/tests/tier3/test_judge_failure_artifacts.pyindex c52ddd22..988d9013 100644--- a/tests/tier3/test_judge_failure_artifacts.py+++ b/tests/tier3/test_judge_failure_artifacts.py@@ -25,8 +25,7 @@ from skillevaluator.tier3.harbor import collector, reportfrom skillevaluator.tier3.harbor.adapter import _EVALUATOR_TESTS_SUBDIR, _write_test_shfrom skillevaluator.tier3.harbor.metrics import (DEFAULT_METRIC_SET,- MAX_CUSTOM_METRIC_NAME_BYTES,- MAX_CUSTOM_METRICS,+ DEFAULT_SCORE_POLICY,RESERVED_METRIC_NAMES,custom_metric_name_is_publishable,extract_custom_metrics,@@ -134,6 +133,7 @@ def test_verifier_main_fails_closed_after_collecting_every_required_judge(assert rich["accuracy"] is Noneassert rich["goal_accuracy"] is Noneassert rich["behavior_check"] is None+ assert rich["score_policy"] == DEFAULT_SCORE_POLICYassert rich["evaluation_status"] == "failed"assert rich["details"]["accuracy"]["status"] == "error"assert rich["details"]["goal_accuracy"]["status"] == "error"@@ -361,6 +361,7 @@ def test_verifier_main_keeps_genuine_zero_judge_verdicts_scoreable(numeric = json.loads(verifier.REWARD_JSON.read_text(encoding="utf-8"))assert "evaluation_status" not in richassert "evaluation_errors" not in rich+ assert rich["score_policy"] == DEFAULT_SCORE_POLICYassert {metric: numeric[metric] for metric in verifier.DISPLAY_METRICS} == {"security": 1.0,"skill_execution": 1.0,