{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tangxusc.github.io/block-play-table/a2a/extensions/execution/v1/artifact.schema.json",
  "title": "Block Play Table A2A artifact metadata v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["kind", "version", "role", "executionId", "attempt", "turn", "eventId", "sequence", "createdAt"],
  "properties": {
    "kind": { "const": "bpt.execution.artifact" },
    "version": { "const": "1.0" },
    "role": { "enum": ["manifest", "log", "conversation", "interaction", "result", "output", "diagnostic"] },
    "executionId": { "$ref": "#/$defs/identifier" },
    "attempt": { "type": "integer", "minimum": 1 },
    "turn": { "type": "integer", "minimum": 1 },
    "eventId": { "$ref": "#/$defs/uuidV7" },
    "sequence": { "type": "integer", "minimum": 1 },
    "stream": { "enum": ["stdout", "stderr", "system"] },
    "chunkIndex": { "type": "integer", "minimum": 0 },
    "finalChunk": { "type": "boolean" },
    "mimeType": { "type": "string", "maxLength": 1024 },
    "compacted": { "type": "boolean" },
    "createdAt": { "type": "string", "format": "date-time" }
  },
  "allOf": [
    {
      "if": { "properties": { "role": { "const": "log" } }, "required": ["role"] },
      "then": { "required": ["stream", "chunkIndex", "finalChunk"] }
    }
  ],
  "$defs": {
    "identifier": { "type": "string", "minLength": 1, "maxLength": 256 },
    "uuidV7": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89aAbB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    }
  }
}
