{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "ace://schemas/handoff/1-0-0",
  "title": "HANDOFF",
  "type": "object",
  "additionalProperties": false,
  "required": ["meta", "transition", "payload", "integrity"],
  "properties": {
    "meta": {
      "type": "object",
      "additionalProperties": false,
      "required": ["timestamp", "iteration", "session_id", "log_commit"],
      "properties": {
        "timestamp": {"type": "string", "format": "date-time"},
        "iteration": {"type": "integer", "minimum": 1},
        "session_id": {"type": "string", "minLength": 8},
        "log_commit": {"type": "string", "minLength": 4}
      }
    },
    "transition": {
      "type": "object",
      "additionalProperties": false,
      "required": ["from", "to", "status", "reason"],
      "properties": {
        "from": {"type": "string", "pattern": "^(capability|agent)-[a-z0-9-]+$"},
        "to": {"type": "string", "pattern": "^(capability|agent)-[a-z0-9-]+$"},
        "status": {"type": "string", "enum": ["READY", "READY_FOR_REVIEW", "BLOCKED", "DONE"]},
        "reason": {"type": "string", "minLength": 1}
      }
    },
    "payload": {
      "type": "object",
      "additionalProperties": false,
      "required": ["primary_artifact", "interface_contract", "evidence_pointer", "known_issues"],
      "properties": {
        "primary_artifact": {"type": "string", "minLength": 1},
        "interface_contract": {"type": "string", "minLength": 1},
        "evidence_pointer": {"type": "string", "minLength": 1},
        "known_issues": {
          "type": "array",
          "items": {"type": "string"}
        }
      }
    },
    "integrity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["checksum", "file_count"],
      "properties": {
        "checksum": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
        "file_count": {"type": "integer", "minimum": 0}
      }
    }
  }
}
