{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://okstra.dev/schemas/convergence-critic-results-v1.0.json",
  "title": "OKSTRA Convergence Critic Results (v1.0)",
  "type": "object",
  "required": ["schemaVersion", "taskKey", "mode", "provider", "terminalStatus", "durationMs", "candidates"],
  "additionalProperties": false,
  "properties": {
    "schemaVersion": { "const": "1.0" },
    "taskKey": { "type": "string", "pattern": "\\S" },
    "mode": { "enum": ["coverage", "acceptance-devils-advocate"] },
    "provider": { "type": "string", "pattern": "\\S" },
    "terminalStatus": { "enum": ["completed", "timeout", "error", "not-run"] },
    "durationMs": { "type": "integer", "minimum": 0 },
    "candidates": {
      "type": "array",
      "items": { "$ref": "#/$defs/Candidate" }
    }
  },
  "$defs": {
    "Candidate": {
      "type": "object",
      "required": ["candidateId", "summary", "category", "ticketIds", "originEvidence"],
      "additionalProperties": false,
      "properties": {
        "candidateId": { "type": "string", "pattern": "\\S" },
        "summary": { "type": "string", "pattern": "\\S" },
        "category": { "type": "string", "pattern": "\\S" },
        "ticketIds": {
          "type": "array",
          "items": { "type": "string", "pattern": "\\S" }
        },
        "originEvidence": { "type": "string", "pattern": "\\S" },
        "severity": { "enum": ["critical", "major", "minor"] },
        "evidenceArtifacts": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/EvidenceArtifact" }
        }
      }
    },
    "EvidenceArtifact": {
      "type": "object",
      "required": ["path", "sha256", "command", "environment"],
      "additionalProperties": false,
      "properties": {
        "path": {
          "type": "string",
          "pattern": "^\\.okstra/(?!\\.{1,2}(?:/|$))(?!.*?/\\.{1,2}(?:/|$))[^/\\\\\\r\\n]+(?:/[^/\\\\\\r\\n]+)*$"
        },
        "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "command": { "type": "string", "pattern": "\\S" },
        "environment": { "type": "string", "pattern": "\\S" }
      }
    }
  }
}
