File size: 2,863 Bytes
15d1f1d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #!/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",
]
|