{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developer.reits.tech/schemas/consumer-evidence.v1.schema.json",
  "title": "REITS consumer evidence v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "taskId", "idempotencyKey", "contract", "producer", "consumer", "result", "command", "artifacts", "environment", "observedAt"],
  "properties": {
    "schemaVersion": { "const": "developer.reits.tech/consumer-evidence/v1" },
    "taskId": { "type": "string", "pattern": "^[A-Z][A-Z0-9-]{3,79}$" },
    "idempotencyKey": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{7,127}$" },
    "contract": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "version"],
      "properties": { "id": { "type": "string", "minLength": 3 }, "version": { "type": "string", "minLength": 1 } }
    },
    "producer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository", "revision"],
      "properties": { "repository": { "type": "string", "minLength": 2 }, "revision": { "const": "SELF" } }
    },
    "consumer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository", "revision"],
      "properties": { "repository": { "type": "string", "minLength": 2 }, "revision": { "const": "SELF" } }
    },
    "result": { "enum": ["PASS", "FAIL", "BLOCKED"] },
    "command": { "type": "string", "minLength": 4 },
    "artifacts": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "sha256"],
        "properties": {
          "path": { "type": "string", "minLength": 1 },
          "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
        }
      }
    },
    "environment": { "type": "string", "minLength": 2 },
    "observedAt": { "type": "string", "format": "date-time" }
  }
}
