#!/usr/bin/env python3 """Release entry point for v5.2-rc5g with consistent role diagnostics. The scoring behavior is defined by :mod:`eval_geometric052_rc5g`. This thin add-only wrapper exists because the current host cannot update an existing file: it makes each role rejected by the dispersion gate explicitly report ``reliable=False`` in both formal reward scopes. """ from __future__ import annotations from pathlib import Path from typing import Any, Mapping try: from . import eval_geometric052_rc5g as RC5G except ImportError: # direct evaluator import import eval_geometric052_rc5g as RC5G METRIC_VERSION = RC5G.METRIC_VERSION SCHEMA_VERSION = RC5G.SCHEMA_VERSION ENGINEERING_THRESHOLDS = dict(RC5G.ENGINEERING_THRESHOLDS) PHYSICAL_SUPPORTED_SEMANTICS = RC5G.PHYSICAL_SUPPORTED_SEMANTICS MAX_MATCHED_OFFSET_DISPERSION_FRACTION = ( RC5G.MAX_MATCHED_OFFSET_DISPERSION_FRACTION ) def _mark_dispersion_rejections(layout: Any) -> None: if not isinstance(layout, dict): return details = layout.get("details") if not isinstance(details, dict): return rejected = { str(role) for role in details.get("high_offset_dispersion_roles", []) } role_offsets = details.get("role_offsets") if not isinstance(role_offsets, dict): return for role in rejected: detail = role_offsets.get(role) if not isinstance(detail, dict): continue detail["reliable"] = False detail["support_mode"] = "high_offset_dispersion" detail["offset_dispersion_gate_pass"] = False for role, detail in role_offsets.items(): if ( isinstance(detail, dict) and int(detail.get("support_count", 0) or 0) >= 2 and str(role) not in rejected ): detail["offset_dispersion_gate_pass"] = True def score_dxf_pair( pred: str | Path, gt: str | Path, sidecar: Mapping[str, Any] | None = None, category: str | None = None, **kwargs: Any, ) -> dict[str, Any]: result = RC5G.score_dxf_pair( pred, gt, sidecar=sidecar, category=category, **kwargs ) components = result.get("components") if isinstance(components, dict): _mark_dispersion_rejections(components.get("layout")) prompt = result.get("online_reward_prompt_masked") if isinstance(prompt, dict): prompt_components = prompt.get("components") if isinstance(prompt_components, dict): _mark_dispersion_rejections(prompt_components.get("layout")) result.setdefault("metric_definition", {})[ "dispersion_role_diagnostics_consistent" ] = True return result __all__ = [ "ENGINEERING_THRESHOLDS", "MAX_MATCHED_OFFSET_DISPERSION_FRACTION", "METRIC_VERSION", "PHYSICAL_SUPPORTED_SEMANTICS", "SCHEMA_VERSION", "score_dxf_pair", ]