{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hummand.com.br/.well-known/humanproof/schema-acesso-1.json",
  "title": "humanproof-acesso/1",
  "description": "Recibo assinado de um acesso à evidência de um ato da Hummand. Só hashes e identificadores opacos: nenhum campo carrega o texto do motivo, conteúdo de registro ou dado do titular. Campo desconhecido é erro.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "formato", "acesso_id", "tenant", "ato_id", "ator", "motivo_hash", "componentes",
    "desfecho", "ts_acesso", "prev_hash", "kid", "alg", "assinatura"
  ],
  "properties": {
    "formato": { "const": "humanproof-acesso/1" },
    "acesso_id": { "$ref": "#/$defs/id" },
    "tenant": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "nome_publico"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "nome_publico": { "type": "string", "minLength": 1, "maxLength": 200 }
      }
    },
    "ato_id": { "$ref": "#/$defs/id" },
    "ator": {
      "type": "object",
      "additionalProperties": false,
      "required": ["papel", "id"],
      "properties": {
        "papel": { "enum": ["cliente", "operador_hummand", "revisor_hummand", "integracao", "terceiro"] },
        "id": { "type": "string", "pattern": "^(usuario|operador|revisor|apikey|compartilhamento):[A-Za-z0-9_.-]{1,120}$" }
      }
    },
    "motivo_hash": { "$ref": "#/$defs/hash" },
    "componentes": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["registro", "registro_id", "desfecho"],
        "properties": {
          "registro": { "type": "string", "pattern": "^[a-z_]{1,64}$" },
          "registro_id": { "$ref": "#/$defs/id" },
          "desfecho": { "enum": ["aberto", "apagado", "nunca_houve", "negado", "erro"] }
        }
      }
    },
    "desfecho": { "enum": ["concedido", "negado", "erro"] },
    "ts_acesso": { "$ref": "#/$defs/ts" },
    "prev_hash": { "$ref": "#/$defs/hash" },
    "kid": { "type": "string", "minLength": 1, "maxLength": 64 },
    "alg": { "enum": ["ES256", "EdDSA"] },
    "assinatura": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" }
  },
  "$defs": {
    "id": { "type": "string", "minLength": 1, "maxLength": 128 },
    "hash": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "ts": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?Z$" }
  }
}
