{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oms.local/schemas/dispatch-advice-payload.schema.json",
  "title": "OMS durable pre-dispatch advice payload",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "advice_id",
    "request_id",
    "expected_evidence_id",
    "dispatch_intent_sha256",
    "canonical_intent",
    "created_at",
    "updated_at",
    "contact_reference",
    "contact_owner_process",
    "provider_started_at",
    "advisor_evidence",
    "verdict",
    "blocked_reason"
  ],
  "properties": {
    "advice_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "request_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "expected_evidence_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "dispatch_intent_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "canonical_intent": { "type": "object" },
    "created_at": { "type": "string", "minLength": 20, "maxLength": 24 },
    "updated_at": { "type": "string", "minLength": 20, "maxLength": 24 },
    "contact_reference": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["contact_id", "sha256", "file_name"],
      "properties": {
        "contact_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
        "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "file_name": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9.-]{0,132}[a-z0-9])?\\.json$" }
      }
    },
    "contact_owner_process": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["process_id", "boot_id", "start_ticks"],
      "properties": {
        "process_id": { "type": "integer", "minimum": 1 },
        "boot_id": { "type": "string", "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$" },
        "start_ticks": { "type": "string", "pattern": "^[1-9][0-9]*$" }
      }
    },
    "provider_started_at": { "type": ["string", "null"], "minLength": 20, "maxLength": 24 },
    "advisor_evidence": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["evidence_id", "sha256", "file_name"],
      "properties": {
        "evidence_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
        "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "file_name": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9.-]{0,132}[a-z0-9])?\\.json$" }
      }
    },
    "verdict": { "enum": [null, "approve", "revise", "veto"] },
    "blocked_reason": { "type": ["string", "null"], "minLength": 1, "maxLength": 4096 }
  }
}
