{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hushspec.org/schemas/hushspec-conformance-execution-experimental.v1.schema.json",
  "title": "Experimental conformance execution record 0.1.0",
  "type": "object", "additionalProperties": false,
  "required": ["protocol", "run_id", "implementation", "requested_level", "outcome", "abort_reason", "generated_at", "declared_build_context", "controller", "engine", "profile", "manifest", "corpus", "builtins", "declared_materials", "args", "environment", "os", "architecture", "limits", "planned", "unattempted", "cases", "report", "limitations"],
  "properties": {
    "protocol": {"const": "0.1.0"},
    "run_id": {"type": "string", "minLength": 1, "maxLength": 128},
    "implementation": {
      "type": "object", "additionalProperties": false, "required": ["name", "version", "language"],
      "properties": {"name": {"type": "string", "minLength": 1}, "version": {"type": "string", "minLength": 1}, "language": {"type": "string", "minLength": 1}}
    },
    "requested_level": {"type": "integer", "minimum": 0, "maximum": 3},
    "outcome": {"enum": ["qualified", "not_qualified"]},
    "abort_reason": {"type": ["string", "null"]},
    "generated_at": {"type": "string", "format": "date-time"},
    "declared_build_context": {"type": "object", "additionalProperties": false, "properties": {
      "source_sha": {"type": "string", "pattern": "^[a-f0-9]{40,64}$"},
      "ci_run": {"type": "string", "minLength": 1, "maxLength": 128}, "ci_attempt": {"type": "string", "minLength": 1, "maxLength": 128}
    }},
    "controller": {"$ref": "#/$defs/artifact"}, "engine": {"$ref": "#/$defs/artifact"},
    "profile": {"$ref": "#/$defs/artifact"}, "manifest": {"$ref": "#/$defs/artifact"}, "report": {"$ref": "#/$defs/artifact"},
    "corpus": {"type": "array", "maxItems": 4096, "items": {"$ref": "#/$defs/artifact"}},
    "builtins": {"type": "array", "maxItems": 4096, "items": {"$ref": "#/$defs/artifact"}},
    "declared_materials": {"type": "array", "maxItems": 16, "items": {"$ref": "#/$defs/artifact"}},
    "args": {"type": "array", "maxItems": 32, "items": {"type": "string", "maxLength": 4096}},
    "environment": {"type": "object", "additionalProperties": false, "required": ["LANG", "LC_ALL", "TZ"], "properties": {"LANG": {"const": "C"}, "LC_ALL": {"const": "C"}, "TZ": {"const": "UTC"}}},
    "os": {"const": "linux"}, "architecture": {"type": "string", "minLength": 1},
    "limits": {"$ref": "#/$defs/limits"},
    "planned": {"type": "array", "maxItems": 10000, "items": {"$ref": "#/$defs/planned"}},
    "unattempted": {"type": "array", "items": {"$ref": "#/$defs/slot"}},
    "cases": {"type": "array", "maxItems": 10000, "items": {"$ref": "#/$defs/case"}},
    "limitations": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}
  },
  "$defs": {
    "digest": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
    "operation": {"enum": ["parse", "validate", "merge", "resolve", "evaluate", "canonicalize"]},
    "artifact": {"type": "object", "additionalProperties": false, "required": ["path", "sha256", "bytes"], "properties": {
      "path": {"type": "string", "pattern": "^[A-Za-z0-9_-][A-Za-z0-9_.-]*(/[A-Za-z0-9_-][A-Za-z0-9_.-]*)*$", "maxLength": 4096},
      "sha256": {"$ref": "#/$defs/digest"}, "bytes": {"type": "integer", "minimum": 0, "maximum": 268435456}
    }},
    "slot": {"type": "object", "additionalProperties": false, "required": ["path", "category", "level"], "properties": {
      "path": {"type": "string", "minLength": 1}, "category": {"type": "string", "minLength": 1}, "level": {"type": "integer", "minimum": 0, "maximum": 5}
    }},
    "planned": {"type": "object", "additionalProperties": false, "required": ["case_id", "operation", "input_sha256", "slots"], "properties": {
      "case_id": {"type": "string", "minLength": 1}, "operation": {"$ref": "#/$defs/operation"}, "input_sha256": {"$ref": "#/$defs/digest"},
      "slots": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/slot"}}
    }},
    "case": {"type": "object", "additionalProperties": false, "required": ["case_id", "request", "input", "stdout", "stderr", "process", "protocol_failure"], "properties": {
      "case_id": {"type": "string", "minLength": 1}, "request": {"$ref": "#/$defs/artifact"}, "input": {"$ref": "#/$defs/artifact"},
      "stdout": {"$ref": "#/$defs/artifact"}, "stderr": {"$ref": "#/$defs/artifact"}, "process": {"$ref": "#/$defs/process"},
      "protocol_failure": {"type": ["string", "null"]}
    }},
    "process": {"type": "object", "additionalProperties": false, "required": ["exit_code", "signal", "failure", "elapsed_ms", "truncated"], "properties": {
      "exit_code": {"type": ["integer", "null"]}, "signal": {"type": ["integer", "null"]}, "failure": {"type": ["string", "null"]},
      "elapsed_ms": {"type": "integer", "minimum": 0}, "truncated": {"type": "boolean"}
    }},
    "limits": {"type": "object", "additionalProperties": false, "required": ["timeout_ms", "total_timeout_ms", "stdout_bytes", "stderr_bytes", "total_output_bytes", "total_request_bytes"], "properties": {
      "timeout_ms": {"type": "integer", "minimum": 1, "maximum": 30000}, "total_timeout_ms": {"type": "integer", "minimum": 1, "maximum": 3600000},
      "stdout_bytes": {"type": "integer", "minimum": 1, "maximum": 16777216}, "stderr_bytes": {"type": "integer", "minimum": 1, "maximum": 16777216},
      "total_output_bytes": {"type": "integer", "minimum": 1, "maximum": 268435456}, "total_request_bytes": {"type": "integer", "minimum": 1, "maximum": 268435456}
    }}
  }
}
