{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oms.local/schemas/run-completion-proof.schema.json",
  "title": "OMS non-certifying audit run completion proof",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "proof_id",
    "run_id",
    "manifest_id",
    "completed_at",
    "ticket_set_digest",
    "queue_watermark_sha256",
    "tickets",
    "certifying"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "proof_id": { "type": "string", "pattern": "^run-proof-[a-f0-9]{48}$" },
    "run_id": { "type": "string", "pattern": "^run-[a-f0-9]{48}$" },
    "manifest_id": { "type": "string", "pattern": "^manifest-[a-f0-9]{48}$" },
    "completed_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$" },
    "ticket_set_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "queue_watermark_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "tickets": {
      "type": "array",
      "maxItems": 10000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["ticket_id", "version", "attempt", "verification_evidence", "grade_evidence"],
        "properties": {
          "ticket_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
          "version": { "type": "integer", "minimum": 0 },
          "attempt": { "type": "integer", "minimum": 1 },
          "verification_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", "minLength": 6, "maxLength": 96 }
            }
          },
          "grade_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", "minLength": 6, "maxLength": 96 }
            }
          }
        }
      }
    },
    "certifying": { "const": false }
  }
}
