Current policy after applying updates in order:

- cutoff_hour 17, cutoff_inclusive true, lead_minutes 30, timezone America/New_York
- adjacency_allowed true (Update 4), cancelled_blocks true (Update 5), duplicate_policy "first" (Update 5), duration_max 120 (Update 4)
- capacity 1, report_order "id"
- blackout_day "2026-11-01" (Update 6), priority_high_first true (Update 6)

Implementation decisions:

- Deduplication keeps the first occurrence's position and value, with its actual original index. For "last", the value and index would come from the last occurrence while the position stays with the first. Both cases are handled.
- Processing order is priority descending, with ties broken by original index.
- Overlap is computed in UTC. With adjacency allowed, intervals overlap when `s < e2 and s2 < e`. Otherwise they overlap when `s <= e2 and s2 <= e`.
- Cancelled appointments that pass validation reserve capacity and go to blocked. Cancelled appointments with cancelled_blocks=false are rejected.
- The blackout check compares the local date of the start to the blackout_day.
- The cutoff is built on the local start day at cutoff_hour:00 in the zone, then converted to UTC for comparison.
- Report order "id" sorts by id. Otherwise the output is sorted by original index. Ids are compared as given; mixed types fall back to a string key.

```json
{"files": {"main.py": "from core import run\nfrom policy import POLICY\ndef evaluate(payload):\n    return run(payload, POLICY)\n", "policy.py": "POLICY = {\n    'cutoff_hour': 17,\n    'cutoff_inclusive': True,\n    'lead_minutes': 30,\n    'timezone': 'America/New_York',\n    'adjacency_allowed': True,\n    'cancelled_blocks': True,\n    'duplicate_policy': 'first',\n    'duration_max': 120,\n    'capacity': 1,\n    'report_order': 'id',\n    'blackout_day': '2026-11-01',\n    'priority_high_first': True,\n}\n", "helpers.py": "from datetime import datetime, timedelta, timezone, date, time\nfrom zoneinfo import ZoneInfo\n\ndef parse_dt(s):\n    if isinstance(s, str) and s.endswith('Z'):\n        s = s[:-1] + '+00:00'\n    d = datetime.fromisoformat(s)\n    if d.tzinfo is None or d.utcoffset() is None:\n        raise ValueError('naive')\n    return d\n\ndef sort_key(x):\n    return (str(type(x).__name__), str(x)) if not isinstance(x, (int, float, str)) else ((0, x) if not isinstance(x, str) else (1, x))\n", "core.py": "from datetime import datetime, timedelta, timezone, time\nfrom zoneinfo import ZoneInfo\nfrom helpers import parse_dt, sort_key\n\ndef run(payload, policy):\n    tz = ZoneInfo(policy['timezone'])\n    utc = timezone.utc\n    now = parse_dt(payload['now']).astimezone(utc)\n    rows = payload.get('appointments', [])\n    first_pos = {}\n    chosen = {}\n    order = []\n    for i, a in enumerate(rows):\n        k = a['id']\n        if k not in chosen:\n            order.append(k)\n            chosen[k] = (i, a)\n        elif policy['duplicate_policy'] == 'last':\n            chosen[k] = (i, a)\n    items = [(chosen[k][0], chosen[k][1]) for k in order]\n    rev = bool(policy['priority_high_first'])\n    def pk(t):\n        p = t[1].get('priority', 0)\n        return (-p if rev else p, t[0])\n    items.sort(key=pk)\n    lead = timedelta(minutes=policy['lead_minutes'])\n    blackout = policy['blackout_day']\n    accepted = []\n    sel, blk, rej = [], [], []\n    idx = {}\n    adj = policy['adjacency_allowed']\n    for i, a in items:\n        k = a['id']\n        idx[k] = i\n        try:\n            dur = a['duration']\n            if isinstance(dur, bool) or not isinstance(dur, (int, float)) or dur <= 0 or dur > policy['duration_max']:\n                raise ValueError\n            start = parse_dt(a['start']).astimezone(utc)\n            if start < now + lead:\n                raise ValueError\n            ls = start.astimezone(tz)\n            if ls.date().isoformat() == blackout:\n                raise ValueError\n            end = start + timedelta(minutes=dur)\n            cutoff = datetime.combine(ls.date(), time(policy['cutoff_hour'], 0), tzinfo=tz).astimezone(utc)\n            if policy['cutoff_inclusive']:\n                if end > cutoff:\n                    raise ValueError\n            elif end >= cutoff:\n                raise ValueError\n            cancelled = bool(a.get('cancelled', False))\n            if cancelled and not policy['cancelled_blocks']:\n                raise ValueError\n            n = 0\n            for s2, e2 in accepted:\n                if adj:\n                    ov = start < e2 and s2 < end\n                else:\n                    ov = start <= e2 and s2 <= end\n                if ov:\n                    n += 1\n            if n >= policy['capacity']:\n                raise ValueError\n            accepted.append((start, end))\n            (blk if cancelled else sel).append(k)\n        except Exception:\n            rej.append(k)\n    def fin(lst):\n        if policy['report_order'] == 'id':\n            return sorted(lst, key=sort_key)\n        return sorted(lst, key=lambda k: idx[k])\n    return {'selected': fin(sel), 'blocked': fin(blk), 'rejected': fin(rej)}\n"}}
```