{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Acceptance Tester Output",
  "type": "object",
  "required": ["task_id", "verdict", "checked_criterion_ids", "checks"],
  "properties": {
    "task_id": { "type": "string", "minLength": 1 },
    "verdict": { "type": "string", "enum": ["pass", "fail"] },
    "checked_criterion_ids": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "pattern": "^SC-[0-9]{3}$"
      }
    },
    "checks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["criterion_id", "criterion", "result", "evidence"],
        "properties": {
          "criterion_id": {
            "type": "string",
            "pattern": "^SC-[0-9]{3}$"
          },
          "criterion": { "type": "string", "minLength": 1 },
          "result": { "type": "string", "enum": ["pass", "fail"] },
          "evidence": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      }
    },
    "missing_or_wrong": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": { "verdict": { "const": "pass" } },
        "required": ["verdict"]
      },
      "then": {
        "properties": {
          "checks": {
            "not": {
              "contains": {
                "type": "object",
                "properties": { "result": { "const": "fail" } },
                "required": ["result"]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": { "verdict": { "const": "fail" } },
        "required": ["verdict"]
      },
      "then": {
        "required": ["missing_or_wrong"],
        "properties": {
          "missing_or_wrong": { "type": "array", "minItems": 1 },
          "checks": {
            "contains": {
              "type": "object",
              "properties": { "result": { "const": "fail" } },
              "required": ["result"]
            }
          }
        }
      }
    }
  ],
  "additionalProperties": false
}
