{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "anu_v3/schemas/task_runtime_record.schema.json",
  "title": "anu_v3.task_runtime_record.v1",
  "description": "Per-track runtime record registered at dispatch and reconciled against result/.done/normal-collector/fallback observation. Single source of per-task runtime truth.",
  "type": "object",
  "required": [
    "task_id",
    "executor",
    "dispatch_cron_id",
    "fallback_callback_cron_id",
    "expected_artifacts",
    "normal_collector_registered",
    "normal_collector_executed",
    "by_design_no_normal_collector",
    "result_present",
    "done_present",
    "fallback_state",
    "classification",
    "recovery_eligible",
    "terminal_outcome",
    "hold_for_chair"
  ],
  "properties": {
    "task_id": { "type": "string" },
    "executor": { "type": "string" },
    "dispatch_cron_id": { "type": "string" },
    "dispatch_status": { "type": "string" },
    "expected_normal_collector_cron_id": { "type": ["string", "null"] },
    "fallback_callback_cron_id": { "type": "string" },
    "expected_artifacts": { "type": "array", "items": { "type": "string" } },
    "normal_collector_registered": { "type": "boolean" },
    "normal_collector_executed": { "type": "boolean" },
    "by_design_no_normal_collector": { "type": "boolean" },
    "result_present": { "type": "boolean" },
    "done_present": { "type": "boolean" },
    "fallback_state": { "type": "string", "enum": ["PENDING", "FIRED", "CANCELLED", "NONE"] },
    "fallback_fire_kst": { "type": ["string", "null"] },
    "classification": {
      "type": "string",
      "enum": [
        "NORMAL_COLLECTOR_COMPLETED",
        "RESULT_READY_NO_NORMAL_CALLBACK",
        "WAIT_FOR_FALLBACK",
        "RESULT_MISSING_BOT_STALE",
        "TRACK_MISMATCH",
        "DISPATCH_FAILED"
      ]
    },
    "recovery_eligible": { "type": "boolean" },
    "recovery_note": { "type": "string" },
    "terminal_outcome": {
      "type": "string",
      "enum": ["MERGED", "PASS", "DONE", "HOLD", "PENDING", "UNKNOWN"]
    },
    "hold_for_chair": { "type": "boolean" },
    "track_mismatch_reasons": { "type": "array", "items": { "type": "string" } }
  },
  "additionalProperties": true
}
