{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kiwe.dev/contracts/seam.visual-proof.v1.schema.json",
  "title": "SEAM visual proof v1",
  "type": "object", "additionalProperties": false,
  "required": ["schema", "sourceHash", "targetHash", "comparator", "thresholds", "status", "grade", "matrix", "summary", "limitations", "repairPlan"],
  "properties": {
    "schema": { "const": "seam.visual-proof.v1" },
    "sourceHash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "targetHash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "comparator": { "type": "object", "additionalProperties": false, "required": ["name", "version", "deterministic", "anchorBasis", "expectedAnchors", "anchorSetHash", "referenceCaptureHash", "candidateCaptureHash"], "properties": { "name": { "const": "SEAM Visual Proof" }, "version": { "type": "string" }, "deterministic": { "const": true }, "anchorBasis": { "enum": ["capture-all", "bricks-plan"] }, "expectedAnchors": { "type": "integer", "minimum": 1 }, "anchorSetHash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }, "referenceCaptureHash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }, "candidateCaptureHash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" } } },
    "thresholds": { "type": "object", "additionalProperties": false, "required": ["pixelDelta", "pixelMismatchRatio", "maxBoxDeltaPx", "styleMismatchRatio", "minAnchorCoverage"], "properties": { "pixelDelta": { "type": "number", "minimum": 0, "maximum": 1 }, "pixelMismatchRatio": { "type": "number", "minimum": 0, "maximum": 1 }, "maxBoxDeltaPx": { "type": "number", "minimum": 0 }, "styleMismatchRatio": { "type": "number", "minimum": 0, "maximum": 1 }, "minAnchorCoverage": { "type": "number", "minimum": 0, "maximum": 1 } } },
    "status": { "enum": ["passed", "failed", "blocked"] },
    "grade": { "enum": ["matrix-exact", "matrix-high", "partial", "unverified"] },
    "matrix": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/viewportResult" } },
    "summary": { "type": "object", "additionalProperties": false, "required": ["viewports", "passed", "failed", "blocked", "worstPixelMismatchRatio", "worstBoxDeltaPx", "anchorCoverage", "styleMismatchRatio", "accessibilityMismatches", "newDiagnostics"], "properties": { "viewports": { "type": "integer" }, "passed": { "type": "integer" }, "failed": { "type": "integer" }, "blocked": { "type": "integer" }, "worstPixelMismatchRatio": { "type": "number" }, "worstBoxDeltaPx": { "type": "number" }, "anchorCoverage": { "type": "number" }, "styleMismatchRatio": { "type": "number" }, "accessibilityMismatches": { "type": "integer" }, "newDiagnostics": { "type": "integer" } } },
    "limitations": { "type": "array", "items": { "type": "string" } },
    "repairPlan": { "type": ["string", "null"] }
  },
  "$defs": {
    "check": { "enum": ["passed", "failed", "blocked"] },
    "viewportResult": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "width", "height", "theme", "state", "status", "screenshots", "pixels", "geometry", "styles", "accessibility", "diagnostics", "checks"],
      "properties": {
        "id": { "type": "string" }, "width": { "type": "integer" }, "height": { "type": "integer" }, "theme": { "type": "string" }, "state": { "type": "string" }, "status": { "$ref": "#/$defs/check" },
        "screenshots": { "type": "object" }, "pixels": { "type": "object" }, "geometry": { "type": "object" }, "styles": { "type": "object" }, "accessibility": { "type": "object" }, "diagnostics": { "type": "object" },
        "checks": { "type": "object", "additionalProperties": false, "required": ["pixels", "geometry", "styles", "accessibility", "diagnostics"], "properties": { "pixels": { "$ref": "#/$defs/check" }, "geometry": { "$ref": "#/$defs/check" }, "styles": { "$ref": "#/$defs/check" }, "accessibility": { "$ref": "#/$defs/check" }, "diagnostics": { "$ref": "#/$defs/check" } } }
      }
    }
  }
}
