{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Qualification evidence metadata",
  "description": "Structural metadata, not proof of test execution. check_contracts.py also verifies local file hashes and refuses fixture evidence for product-contract PASS.",
  "type": "object",
  "required": ["version", "status", "scope", "reason"],
  "properties": {
    "version": {"const": 1},
    "status": {"enum": ["NOT RUN", "PASS", "FAIL", "GATED", "DEFERRED", "DEVIATION"]},
    "scope": {"enum": ["qualification_fixture", "product_contract"]},
    "reason": {"type": "string", "minLength": 1},
    "sources": {"$ref": "#/$defs/hashedFiles"},
    "binaries": {"$ref": "#/$defs/hashedFiles"},
    "artifacts": {"$ref": "#/$defs/hashedFiles"},
    "command": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
    "host": {"type": "string", "minLength": 1},
    "toolchain": {
      "type": "object", "required": ["compiler", "version", "flags"],
      "properties": {"compiler": {"type": "string", "minLength": 1}, "version": {"type": "string", "minLength": 1}, "flags": {"type": "array", "items": {"type": "string"}}}
    },
    "workload_sha256": {"$ref": "#/$defs/sha256"},
    "dependencies_sha256": {"$ref": "#/$defs/sha256"},
    "samples": {"type": "integer", "minimum": 1},
    "durability_policy": {"type": "string", "minLength": 1},
    "failure_model": {"type": "string", "minLength": 1},
    "contract_ids": {"type": "array", "items": {"type": "string", "pattern": "^[HDPC][0-9]{2}$"}},
    "teardown": {
      "type": "object", "required": ["status", "resources"],
      "properties": {"status": {"enum": ["cleaned", "not-required"]}, "resources": {"type": "array", "maxItems": 0}}
    }
  },
  "allOf": [{"if": {"properties": {"status": {"const": "PASS"}}}, "then": {"required": ["sources", "binaries", "artifacts", "command", "host", "toolchain", "workload_sha256", "dependencies_sha256", "samples", "durability_policy", "failure_model", "contract_ids", "teardown"]}}],
  "$defs": {
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "hashedFiles": {"type": "array", "minItems": 1, "items": {"type": "object", "required": ["path", "sha256"], "properties": {"path": {"type": "string", "minLength": 1}, "sha256": {"$ref": "#/$defs/sha256"}}}}
  }
}
