{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://sec.hypermedia.au/schemas/analysis-provenance/v1.schema.json",
  "title": "Analysis Provenance Evidence v1 Schema",
  "description": "Validates the JSON payloads carried in-band (as application/json attachments) by analysis-provenance attestation evidence. The attestation is this data's authoritative home — the FRE 901 authentication set, frozen at promotion — so it travels inside the signed artifact; this schema is where its structure is enforced. Verifiers decode data[0].contents.attachment.content and validate against #/definitions/provInputsData or #/definitions/provNonreproData per the evidence propertyName. Normative requirements: https://sec.hypermedia.au/standards/analysis-provenance/v1",
  "type": "object",
  "oneOf": [
    { "$ref": "#/definitions/provInputsData" },
    { "$ref": "#/definitions/provNonreproData" }
  ],
  "definitions": {
    "provInputsData": {
      "type": "object",
      "required": ["modelId", "modelVersion", "weightsDigest", "quantization", "kvBits", "promptHash", "inputRefs", "params"],
      "properties": {
        "modelId": { "type": "string", "minLength": 1 },
        "modelVersion": { "type": "string", "minLength": 1 },
        "weightsDigest": { "$ref": "#/definitions/digest" },
        "quantization": { "type": "string", "minLength": 1 },
        "kvBits": { "type": "integer" },
        "promptHash": { "$ref": "#/definitions/digest" },
        "inputRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["ref", "hash"],
            "properties": {
              "ref": { "type": "string", "pattern": "^urn:cdx:.+" },
              "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
            }
          },
          "description": "APRV-002: declared inputs resolved into the sealed catalog, each pinned by hash"
        },
        "params": {
          "type": "object",
          "required": ["temperature", "topP", "seed", "maxTokens"],
          "properties": {
            "temperature": { "type": "number" },
            "topP": { "type": "number" },
            "seed": { "type": "integer" },
            "maxTokens": { "type": "integer" }
          }
        },
        "cacheSignature": { "type": "string" }
      },
      "description": "APRV-001..003: the prov-inputs block (evidence propertyName cyberbench:provenance:inputs)"
    },
    "provNonreproData": {
      "type": "object",
      "required": ["outputByteReproducible", "methodReproducible", "integrityBasis", "outputHash"],
      "properties": {
        "outputByteReproducible": { "type": "boolean", "const": false },
        "methodReproducible": { "type": "boolean" },
        "integrityBasis": { "type": "string", "const": "hash-at-rest" },
        "outputHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
      },
      "description": "APRV-004/005: the prov-nonrepro block (evidence propertyName cyberbench:provenance:reproducibility)"
    },
    "digest": {
      "type": "object",
      "required": ["alg", "content"],
      "properties": {
        "alg": { "type": "string", "enum": ["SHA-256", "SHA-512", "SHA3-256", "SHA3-512", "BLAKE3"] },
        "content": { "type": "string", "pattern": "^[a-f0-9]{64}$|^[a-f0-9]{128}$" }
      }
    }
  }
}
