{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "ace://schemas/agent-state-handoff/1.0.0",
  "title": "ACE Agent-State Handoff",
  "type": "object",
  "required": [
    "meta",
    "transition",
    "payload",
    "integrity"
  ],
  "additionalProperties": false,
  "properties": {
    "meta": {
      "type": "object",
      "required": [
        "timestamp",
        "iteration",
        "session_id",
        "log_commit"
      ],
      "additionalProperties": false,
      "properties": {
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "iteration": {
          "type": "integer",
          "minimum": 1
        },
        "session_id": {
          "type": "string",
          "minLength": 1
        },
        "log_commit": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        }
      }
    },
    "transition": {
      "type": "object",
      "required": [
        "from",
        "to",
        "status",
        "reason"
      ],
      "additionalProperties": false,
      "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",
      "required": [
        "primary_artifact",
        "interface_contract",
        "evidence_pointer",
        "known_issues"
      ],
      "additionalProperties": false,
      "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",
      "required": [
        "checksum",
        "file_count"
      ],
      "additionalProperties": false,
      "properties": {
        "checksum": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        },
        "file_count": {
          "type": "integer",
          "minimum": 0
        }
      }
    }
  }
}
