{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.invalid/ai-agent-engineer/provenance-artifact.schema.json",
  "title": "Offline provenance evaluation artifact",
  "description": "Structural and self-consistency schema for an artifact consumed by a trusted release gate. Oracle agreement, current evidence and authenticity require trusted recomputation; an unkeyed self-hash is not a MAC or signature.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "decision",
    "case_count",
    "passed_case_count",
    "fixture_sha256",
    "fixture_model_sha256",
    "pipeline_fingerprint",
    "snapshot_state_sha256",
    "tombstone_state_sha256",
    "authorization_revision",
    "index_generation_id",
    "index_manifest_sha256",
    "harness_revision",
    "cases",
    "artifact_sha256"
  ],
  "properties": {
    "schema_version": {
      "const": "provenance-eval-v2"
    },
    "decision": {
      "enum": [
        "PASS",
        "BLOCK"
      ]
    },
    "case_count": {
      "type": "integer",
      "minimum": 1
    },
    "passed_case_count": {
      "type": "integer",
      "minimum": 0
    },
    "fixture_sha256": {
      "$ref": "#/$defs/sha256"
    },
    "fixture_model_sha256": {
      "$ref": "#/$defs/sha256"
    },
    "pipeline_fingerprint": {
      "$ref": "#/$defs/sha256"
    },
    "snapshot_state_sha256": {
      "$ref": "#/$defs/sha256"
    },
    "tombstone_state_sha256": {
      "$ref": "#/$defs/sha256"
    },
    "authorization_revision": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300
    },
    "index_generation_id": {
      "type": "string",
      "pattern": "^gen_[0-9a-f]{64}$"
    },
    "index_manifest_sha256": {
      "$ref": "#/$defs/sha256"
    },
    "harness_revision": {
      "const": "offline-provenance-harness-v2"
    },
    "cases": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "query_id",
          "slice",
          "critical",
          "passed",
          "failure_codes"
        ],
        "properties": {
          "query_id": {
            "type": "string",
            "minLength": 1
          },
          "slice": {
            "type": "string",
            "minLength": 1
          },
          "critical": {
            "type": "boolean"
          },
          "passed": {
            "type": "boolean"
          },
          "failure_codes": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    },
    "artifact_sha256": {
      "$ref": "#/$defs/sha256"
    }
  },
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    }
  }
}
