{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.dharma-ai.io/evidence-request/v1",
  "title": "Evidence Request",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "requestId",
    "organizationId",
    "deviceId",
    "workspaceId",
    "trajectoryId",
    "purpose",
    "selectors",
    "maximumBytes",
    "retentionClass",
    "requestedBy",
    "authorityDecisionId",
    "createdAt",
    "expiresAt",
    "nonce",
    "signature"
  ],
  "properties": {
    "schema": {
      "const": "dharma.evidence-request/v1"
    },
    "requestId": {
      "type": "string",
      "format": "uuid"
    },
    "organizationId": {
      "type": "string",
      "minLength": 1
    },
    "deviceId": {
      "type": "string",
      "minLength": 1
    },
    "workspaceId": {
      "type": "string",
      "minLength": 1
    },
    "trajectoryId": {
      "type": "string",
      "format": "uuid"
    },
    "capsuleRevision": {
      "type": "integer",
      "minimum": 1
    },
    "capsuleHash": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    },
    "purpose": {
      "type": "string",
      "enum": [
        "evaluation",
        "remediation_validation",
        "incident_response",
        "customer_review",
        "support"
      ]
    },
    "selectors": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "contentId"
        ],
        "properties": {
          "contentId": {
            "type": "string",
            "pattern": "^(sha256|blake3):[A-Fa-f0-9]{32,128}$"
          },
          "range": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": false,
            "properties": {
              "start": {
                "type": "integer",
                "minimum": 0
              },
              "end": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "reason": {
            "type": "string"
          }
        }
      }
    },
    "maximumBytes": {
      "type": "integer",
      "minimum": 1
    },
    "retentionClass": {
      "type": "string"
    },
    "requestedBy": {
      "type": "string",
      "minLength": 1
    },
    "authorityDecisionId": {
      "type": "string",
      "minLength": 1
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "expiresAt": {
      "type": "string",
      "format": "date-time"
    },
    "nonce": {
      "type": "string",
      "minLength": 1
    },
    "keyVersion": {
      "type": "string",
      "minLength": 1
    },
    "signature": {
      "type": [
        "string",
        "null"
      ]
    }
  }
}
