{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:compute-capital:public-snapshot:v1",
  "title": "Compute Capital public aggregate snapshot v1",
  "description": "Website-facing aggregate contract. No raw observations or private identifiers. Acceptance does not attest benchmark truth.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": 1
    },
    "snapshot_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "source": {
      "const": "compute-capital-first-party"
    },
    "publication_status": {
      "enum": [
        "empty",
        "approved"
      ]
    },
    "test_only": {
      "const": false
    },
    "method_version": {
      "const": "0.1.0"
    },
    "input_manifest_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "suite_versions": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 120,
        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
      }
    },
    "freshness_days": {
      "const": 90
    },
    "privacy": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "minimum_hosts": {
          "const": 3
        },
        "minimum_contributors": {
          "const": 3
        }
      },
      "required": [
        "minimum_hosts",
        "minimum_contributors"
      ]
    },
    "coverage": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "hostclasses": {
          "type": "integer",
          "minimum": 0
        },
        "models": {
          "type": "integer",
          "minimum": 0
        },
        "hosts": {
          "type": "integer",
          "minimum": 0
        },
        "contributors": {
          "type": "integer",
          "minimum": 0
        },
        "observations": {
          "type": "integer",
          "minimum": 0
        },
        "eligible_runs": {
          "type": "integer",
          "minimum": 0
        },
        "excluded_runs": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "hostclasses",
        "models",
        "hosts",
        "contributors",
        "observations",
        "eligible_runs",
        "excluded_runs"
      ]
    },
    "exclusions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "count": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "reason",
          "count"
        ]
      }
    },
    "sample_window": {
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "start": {
              "type": "string",
              "format": "date-time",
              "pattern": "Z$"
            },
            "end": {
              "type": "string",
              "format": "date-time",
              "pattern": "Z$"
            }
          },
          "required": [
            "start",
            "end"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "data_quality": {
      "enum": [
        "empty",
        "insufficient",
        "sufficient"
      ]
    },
    "aggregates": {
      "type": "array",
      "maxItems": 10000,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "stratum_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
          },
          "hostclass": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "hostclass_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              }
            },
            "required": [
              "hostclass_id",
              "label"
            ]
          },
          "model": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              },
              "digest": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "quantization": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              },
              "format": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              }
            },
            "required": [
              "name",
              "digest",
              "quantization",
              "format"
            ]
          },
          "runtime": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              },
              "version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              },
              "backend": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              },
              "os_version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+()-]*$"
              },
              "driver_version": {
                "type": [
                  "string",
                  "null"
                ],
                "minLength": 1,
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+()-]*$"
              }
            },
            "required": [
              "name",
              "version",
              "backend",
              "os_version",
              "driver_version"
            ]
          },
          "workload": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._+():/×-]*$"
              },
              "suite_version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120,
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
              },
              "suite_sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "profile_sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "id",
              "label",
              "suite_version",
              "suite_sha256",
              "profile_sha256"
            ]
          },
          "host_count": {
            "type": "integer",
            "minimum": 3
          },
          "contributor_count": {
            "type": "integer",
            "minimum": 3
          },
          "run_count": {
            "type": "integer",
            "minimum": 3
          },
          "attempts": {
            "type": "integer",
            "minimum": 1
          },
          "successes": {
            "type": "integer",
            "minimum": 0
          },
          "cancellations": {
            "type": "integer",
            "minimum": 0
          },
          "sample_window": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "start": {
                "type": "string",
                "format": "date-time",
                "pattern": "Z$"
              },
              "end": {
                "type": "string",
                "format": "date-time",
                "pattern": "Z$"
              }
            },
            "required": [
              "start",
              "end"
            ]
          },
          "metrics": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "successful_tasks_per_hour": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "output_tokens_per_second": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "decode_q1": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "decode_q3": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "ttft_ms": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "wall_kwh_per_100_tasks": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "energy_method": {
                "enum": [
                  "wall_meter",
                  "missing"
                ]
              }
            },
            "required": [
              "successful_tasks_per_hour",
              "output_tokens_per_second",
              "decode_q1",
              "decode_q3",
              "ttft_ms",
              "wall_kwh_per_100_tasks",
              "energy_method"
            ]
          },
          "confidence": {
            "enum": [
              "limited",
              "moderate"
            ]
          },
          "quality": {
            "anyOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "method_version": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]*$"
                  },
                  "threshold": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "score": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "method_version",
                  "threshold",
                  "score"
                ]
              }
            ]
          }
        },
        "required": [
          "stratum_id",
          "hostclass",
          "model",
          "runtime",
          "workload",
          "host_count",
          "contributor_count",
          "run_count",
          "attempts",
          "successes",
          "cancellations",
          "sample_window",
          "metrics",
          "confidence",
          "quality"
        ]
      }
    }
  },
  "required": [
    "schema_version",
    "snapshot_id",
    "created_at",
    "generated_at",
    "source",
    "publication_status",
    "test_only",
    "method_version",
    "input_manifest_sha256",
    "suite_versions",
    "freshness_days",
    "privacy",
    "coverage",
    "exclusions",
    "sample_window",
    "data_quality",
    "aggregates"
  ]
}
