{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sproutpad.ai/spec/conformance-report.schema.json",
  "title": "SproutPad signed conformance run",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "profile",
    "runId",
    "runner",
    "target",
    "startedAt",
    "completedAt",
    "suites",
    "summary",
    "previousDigest"
  ],
  "properties": {
    "schemaVersion": {
      "enum": ["sproutpad.conformance.run.v1", "sproutpad.conformance.run.v2"]
    },
    "profile": { "enum": ["anonymous", "governed"] },
    "runId": { "type": "string", "pattern": "^[A-Za-z0-9._:-]{3,160}$" },
    "runner": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "repository",
        "workflow",
        "workflowRef",
        "runUrl",
        "commitSha",
        "runAttempt"
      ],
      "properties": {
        "kind": { "enum": ["github-actions", "local"] },
        "repository": { "type": "string", "minLength": 1, "maxLength": 200 },
        "workflow": { "const": "public-conformance.yml" },
        "workflowRef": { "type": "string", "minLength": 1, "maxLength": 300 },
        "runUrl": { "type": "string", "minLength": 1, "maxLength": 500 },
        "commitSha": { "type": "string", "minLength": 1, "maxLength": 64 },
        "runAttempt": { "type": "integer", "minimum": 1 }
      }
    },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": ["baseUrl", "buildId", "specDigest", "schemaDigest"],
      "properties": {
        "baseUrl": { "type": "string", "format": "uri", "maxLength": 300 },
        "buildId": { "type": "string", "minLength": 1, "maxLength": 160 },
        "specDigest": { "$ref": "#/$defs/digest" },
        "schemaDigest": { "$ref": "#/$defs/digest" }
      }
    },
    "startedAt": { "type": "string", "format": "date-time" },
    "completedAt": { "type": "string", "format": "date-time" },
    "suites": {
      "type": "array",
      "minItems": 3,
      "maxItems": 3,
      "items": { "$ref": "#/$defs/suite" }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["passed", "failed", "skipped", "outcome"],
      "properties": {
        "passed": { "type": "integer", "minimum": 0 },
        "failed": { "type": "integer", "minimum": 0 },
        "skipped": { "type": "integer", "minimum": 0 },
        "outcome": { "enum": ["pass", "fail"] }
      }
    },
    "previousDigest": {
      "oneOf": [{ "$ref": "#/$defs/digest" }, { "type": "null" }]
    }
  },
  "$defs": {
    "digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "suite": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "required", "outcome", "probes"],
      "properties": {
        "id": { "enum": ["wire", "discovery", "governed"] },
        "required": { "type": "boolean" },
        "outcome": { "enum": ["pass", "fail", "not_run"] },
        "probes": { "type": "array", "items": { "$ref": "#/$defs/probe" } }
      }
    },
    "probe": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "status"],
      "properties": {
        "id": { "type": "string", "minLength": 1, "maxLength": 160 },
        "status": { "enum": ["pass", "fail", "skip", "not_run"] },
        "latencyMs": { "type": "integer", "minimum": 0 },
        "httpStatus": { "type": "integer", "minimum": 100, "maximum": 599 },
        "spec": { "type": "string", "maxLength": 200 },
        "error": { "type": "string", "maxLength": 500 }
      }
    }
  }
}
