{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "certification",
    "run_id",
    "disclosure_evidence",
    "status",
    "failed_phase",
    "error",
    "issue_count",
    "synced_count",
    "synced_tickets"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "certification": { "type": "string", "enum": ["live", "non-certifying"] },
    "run_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "disclosure_evidence": {
      "type": "object",
      "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": 69 }
      }
    },
    "status": { "type": "string", "enum": ["success", "failure"] },
    "failed_phase": { "type": ["string", "null"], "enum": ["contact", "sync", "evidence", null] },
    "error": { "type": ["string", "null"], "maxLength": 4096 },
    "issue_count": { "type": "integer", "minimum": 0 },
    "synced_count": { "type": "integer", "minimum": 0 },
    "synced_tickets": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["ticket_id", "content_sha256", "content_file", "record_version", "sync_status"],
        "properties": {
          "ticket_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
          "content_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "content_file": { "type": "string", "minLength": 71, "maxLength": 133 },
          "record_version": { "type": "integer", "minimum": 0 },
          "sync_status": { "type": "string", "enum": ["created", "refreshed", "unchanged"] }
        }
      }
    }
  }
}
