{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://civitas-cerebrum.github.io/element-interactions/schemas/subagent-returns/phase-validator.schema.json",
  "title": "Phase-validator return",
  "type": "object",
  "additionalProperties": true,
  "required": ["handover"],
  "properties": {
    "handover": {
      "allOf": [
        { "$ref": "handover.schema.json" }
      ]
    },
    "phase": { "type": "integer", "minimum": 1, "maximum": 8 },
    "sub-skill": { "type": "string" },
    "exit-criteria-checked": {
      "type": "array",
      "items": { "type": "object", "additionalProperties": true }
    },
    "findings": {
      "type": "array",
      "items": { "type": "object", "additionalProperties": true }
    },
    "summary": { "type": "string" }
  },
  "allOf": [
    {
      "if": {
        "type": "object",
        "properties": { "handover": { "type": "object", "required": ["status"], "properties": { "status": { "const": "improvements-needed" } } } }
      },
      "then": {
        "type": "object",
        "required": ["findings"],
        "properties": { "findings": { "type": "array", "minItems": 1 } }
      }
    },
    {
      "if": {
        "type": "object",
        "properties": { "handover": { "type": "object", "required": ["status"], "properties": { "status": { "const": "greenlight" } } } }
      },
      "then": {
        "type": "object",
        "required": ["exit-criteria-checked"],
        "properties": { "exit-criteria-checked": { "type": "array" } }
      }
    }
  ]
}
