{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sovereignbench.org/leak-report.schema.json",
  "title": "SovereignBench leak report, standard v0.1 (draft)",
  "description": "Machine-readable form of a leak rate stated under the SovereignBench Leak Rate Reporting Standard v0.1 (https://sovereignbench.org/standard). Conformance of the figures to the rules is checked by the report checker on that page; this schema only describes the shape.",
  "type": "object",
  "required": ["schemaVersion", "system", "testSet", "scoring", "results", "provenance"],
  "properties": {
    "schemaVersion": { "const": "0.1" },
    "note": { "type": "string" },
    "system": {
      "type": "object",
      "description": "R8: what exactly was tested.",
      "required": ["name", "version", "build", "channel", "configuration", "measuredOn"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "minLength": 1 },
        "build": { "type": "string", "minLength": 1, "description": "Build or commit identifier." },
        "channel": { "enum": ["release", "development"] },
        "configuration": { "type": "string", "minLength": 1, "description": "Settings that affect routing or filtering." },
        "measuredOn": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" }
      }
    },
    "testSet": {
      "type": "object",
      "description": "R9: frozen, hashed test set.",
      "required": ["name", "sha256", "languages", "origin", "frozenBeforeMeasurement", "usedForTuning"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "languages": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "origin": { "enum": ["synthetic", "real", "mixed"] },
        "size": { "type": "integer", "minimum": 1 },
        "frozenBeforeMeasurement": { "const": true },
        "usedForTuning": { "const": false }
      }
    },
    "scoring": {
      "type": "object",
      "description": "R1, R3, R4.",
      "required": ["unit", "strictness", "protectedClasses"],
      "properties": {
        "unit": { "const": "request" },
        "strictness": { "const": "strict", "description": "The headline must be strict. A lenient figure may be reported separately." },
        "protectedClasses": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } }
      }
    },
    "results": {
      "type": "object",
      "required": ["requestsWithProtectedValues", "leakingRequests", "rate", "ci95", "protectedByRecognition", "protectedByFallback", "overBlock", "repeatRuns"],
      "properties": {
        "requestsWithProtectedValues": { "type": "integer", "minimum": 1, "description": "R2: n." },
        "leakingRequests": { "type": "integer", "minimum": 0, "description": "R2: k. Requests in which at least one protected value was not fully masked." },
        "rate": { "type": "number", "minimum": 0, "maximum": 1 },
        "ci95": { "type": "array", "prefixItems": [{ "type": "number" }, { "type": "number" }], "minItems": 2, "maxItems": 2, "description": "R5: 95 % Wilson interval, [lower, upper] as fractions." },
        "protectedByRecognition": { "type": "integer", "minimum": 0, "description": "R6" },
        "protectedByFallback": { "type": "integer", "minimum": 0, "description": "R6: protected only because a component failed over to a safe default." },
        "protectedUnclassified": { "type": "integer", "minimum": 0, "description": "R6, optional: protected requests that stayed local for a reason the tester could not classify. Counted in the sum n - k = recognition + fallback + unclassified." },
        "overBlock": {
          "type": "object",
          "description": "R7",
          "required": ["benignRequests", "restricted", "rate", "ci95"],
          "properties": {
            "benignRequests": { "type": "integer", "minimum": 1 },
            "restricted": { "type": "integer", "minimum": 0 },
            "rate": { "type": "number", "minimum": 0, "maximum": 1 },
            "ci95": { "type": "array", "prefixItems": [{ "type": "number" }, { "type": "number" }], "minItems": 2, "maxItems": 2 }
          }
        },
        "repeatRuns": {
          "type": "array",
          "minItems": 3,
          "description": "R10: at least three runs.",
          "items": {
            "type": "object",
            "required": ["requestsWithProtectedValues", "leakingRequests"],
            "properties": {
              "requestsWithProtectedValues": { "type": "integer", "minimum": 1 },
              "leakingRequests": { "type": "integer", "minimum": 0 }
            }
          }
        }
      }
    },
    "provenance": {
      "type": "object",
      "required": ["rawRecordsSha256", "independent"],
      "properties": {
        "rawRecordsSha256": { "type": "string", "pattern": "^[0-9a-f]{64}$", "description": "R10: hash of the per-request records." },
        "evaluatedBy": { "type": "string" },
        "independent": { "type": "boolean", "description": "Self-reported results are not eligible for the SovereignBench leaderboard." }
      }
    }
  }
}
