{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://cre-acquisition-orchestrator.local/schemas/checkpoint/agent-checkpoint.schema.json",
  "title": "Agent Checkpoint",
  "type": "object",
  "required": [
    "agentName",
    "phase",
    "dealId",
    "status",
    "progress",
    "lastUpdatedAt",
    "outputs",
    "redFlags",
    "dataGaps"
  ],
  "properties": {
    "agentName": {
      "type": "string",
      "minLength": 1
    },
    "phase": {
      "type": "string",
      "minLength": 1
    },
    "dealId": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "$ref": "../common/enums.schema.json#/$defs/status"
    },
    "progress": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "startedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "lastUpdatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "resumePoint": {
      "type": [
        "string",
        "null"
      ]
    },
    "outputs": {
      "type": "object",
      "required": [
        "summary",
        "findings",
        "metrics",
        "verdict"
      ],
      "properties": {
        "summary": {
          "type": "string"
        },
        "findings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "metrics": {
          "type": "object",
          "required": [],
          "properties": {
            "confidence": {
              "type": "number"
            }
          },
          "additionalProperties": false
        },
        "verdict": {
          "$ref": "../common/enums.schema.json#/$defs/nullableVerdict"
        }
      },
      "additionalProperties": false
    },
    "dataGaps": {
      "type": "array",
      "items": {
        "$ref": "../common/flag.schema.json"
      }
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "message",
          "timestamp",
          "recoverable"
        ],
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "recoverable": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }
    },
    "redFlags": {
      "type": "array",
      "items": {
        "$ref": "../common/flag.schema.json"
      }
    },
    "childAgents": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [],
        "properties": {},
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
