{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oms.local/schemas/run-manifest.schema.json",
  "title": "OMS non-certifying audit run manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "manifest_id",
    "run_id",
    "run_kind",
    "start_intent_id",
    "created_at",
    "policy_digest",
    "verification_gate_digest",
    "ticket_set_digest",
    "service_plan_digest",
    "service_plan_directory",
    "state_root",
    "workspace_root",
    "selected_ticket_ids",
    "ticket_snapshot",
    "provider_started",
    "manual_conductor_start_required",
    "certifying",
    "release",
    "merge_disposition"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "manifest_id": { "type": "string", "pattern": "^manifest-[a-f0-9]{48}$" },
    "run_id": { "type": "string", "pattern": "^run-[a-f0-9]{48}$" },
    "run_kind": { "type": "string", "enum": ["12h", "24h", "until-empty"] },
    "start_intent_id": { "type": "string", "pattern": "^run-intent-[a-f0-9]{48}$" },
    "created_at": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$" },
    "policy_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "verification_gate_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "ticket_set_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "service_plan_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "service_plan_directory": { "type": "string", "pattern": "^/", "maxLength": 4096 },
    "state_root": { "type": "string", "pattern": "^/", "maxLength": 4096 },
    "workspace_root": { "type": "string", "pattern": "^/", "maxLength": 4096 },
    "selected_ticket_ids": {
      "type": "array",
      "maxItems": 10000,
      "items": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" }
    },
    "ticket_snapshot": {
      "type": "array",
      "maxItems": 10000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["ticket_id", "initial_version", "initial_attempt", "initial_state", "source_ref_sha256", "content_sha256", "policy_version", "policy_digest", "gate_digest"],
        "properties": {
          "ticket_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
          "initial_version": { "type": "integer", "minimum": 0 },
          "initial_attempt": { "type": "integer", "minimum": 1 },
          "initial_state": { "type": "string", "enum": ["pending", "leased", "running", "verifying", "retryable", "parked", "blocked"] },
          "source_ref_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "content_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "policy_version": { "type": "integer", "minimum": 1 },
          "policy_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "gate_digest": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" }
        }
      }
    },
    "provider_started": { "const": false },
    "manual_conductor_start_required": { "const": true },
    "certifying": { "const": false },
    "release": { "const": "not_stable" },
    "merge_disposition": { "const": "human_hold" }
  }
}
