fix(rectification): compare health and occupation aliases through one merge (BUG-672)
Skipped or already-reported health must not be asked again as health_pressure, and occupation declined as other must still close the occupation line. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -228,6 +228,13 @@ EXISTENCE_NEARBY_YEARS = {
|
||||
_SEMANTIC_YEAR = re.compile(r"^(?P<domain>[a-z_]+)\.(?P<year>(?:19|20)\d{2})(?:\.|$)")
|
||||
|
||||
|
||||
def canonical_domain(raw: object) -> str:
|
||||
value = str(raw or "").strip()
|
||||
if value == "health":
|
||||
return "health_pressure"
|
||||
return value
|
||||
|
||||
|
||||
def asked_years_for_domain(asked_probe_keys: Sequence[str] | None, domain: str) -> set[int]:
|
||||
years: set[int] = set()
|
||||
prefix = f"{domain}."
|
||||
@@ -1248,17 +1255,18 @@ def _quality_encoded(event: dict[str, Any], domain: str) -> bool:
|
||||
def _year_quality_encoded(events: Sequence[dict[str, Any]], domain: str, year: int) -> bool:
|
||||
return any(
|
||||
isinstance(event, dict)
|
||||
and str(event.get("domain") or "") == domain
|
||||
and canonical_domain(event.get("domain")) == canonical_domain(domain)
|
||||
and _event_year(event) == year
|
||||
and _quality_encoded(event, domain)
|
||||
and _quality_encoded(event, canonical_domain(domain))
|
||||
for event in events
|
||||
)
|
||||
|
||||
|
||||
def _event_years(events: Sequence[dict[str, Any]], domain: str) -> set[int]:
|
||||
years: set[int] = set()
|
||||
wanted = canonical_domain(domain)
|
||||
for event in events:
|
||||
if not isinstance(event, dict) or str(event.get("domain") or "") != domain:
|
||||
if not isinstance(event, dict) or canonical_domain(event.get("domain")) != wanted:
|
||||
continue
|
||||
year = _event_year(event)
|
||||
if year is not None:
|
||||
|
||||
@@ -588,8 +588,10 @@ def precision_stage(scan: dict[str, Any], event_count: int) -> dict[str, Any]:
|
||||
|
||||
|
||||
def oos_blind_prompts(request: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
from scripts.rectification.event_probes import canonical_domain
|
||||
|
||||
covered = {
|
||||
str(event.get("domain"))
|
||||
canonical_domain(event.get("domain"))
|
||||
for event in request.get("events") or []
|
||||
if isinstance(event, dict) and event.get("domain")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user