{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:compute-capital:contribution:v2",
  "title": "Minimized passive throughput contribution v2",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": 2
    },
    "contract_version": {
      "const": "observed-throughput-2"
    },
    "method_version": {
      "const": "llm-throughput-2.0.0"
    },
    "contribution_id": {
      "type": "string",
      "format": "uuid"
    },
    "contributor_scoped_host_key": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "inventory_binding_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "hostclass": {
      "$ref": "#/definitions/hardware"
    },
    "model": {
      "$ref": "#/definitions/model"
    },
    "profile": {
      "$ref": "#/definitions/profile"
    },
    "window": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "start",
        "end"
      ]
    },
    "measurements": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "output_tokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "task_seconds": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 3686400
        },
        "sample_count": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000000
        }
      },
      "required": [
        "output_tokens",
        "task_seconds",
        "sample_count"
      ]
    },
    "consent": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "version": {
          "const": "observed-throughput-2"
        },
        "consent_id": {
          "type": "string",
          "format": "uuid"
        },
        "publication_opt_in": {
          "const": true
        },
        "approved_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "version",
        "consent_id",
        "publication_opt_in",
        "approved_at"
      ]
    },
    "integrity": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "payload_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "signature": {
          "type": "null"
        }
      },
      "required": [
        "payload_sha256",
        "signature"
      ]
    },
    "test_only": {
      "type": "boolean"
    }
  },
  "required": [
    "schema_version",
    "contract_version",
    "method_version",
    "contribution_id",
    "contributor_scoped_host_key",
    "inventory_binding_sha256",
    "hostclass",
    "model",
    "profile",
    "window",
    "measurements",
    "consent",
    "integrity",
    "test_only"
  ],
  "definitions": {
    "model": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "label": {
          "type": "string",
          "pattern": "^(?!(?:sha256:)?[a-f0-9]{10,64}$)[A-Za-z0-9][A-Za-z0-9._:/+\\-]{0,199}$(?![\\s\\S])"
        },
        "format": {
          "enum": [
            "gguf",
            "safetensors",
            "onnx",
            "mlx",
            null
          ]
        },
        "quantization": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^(?:Q[2-8](?:_[A-Z0-9]+){0,3}|IQ[1-4](?:_[A-Z0-9]+){0,3}|BF16|F16|F32|FP8|FP4|NVFP4)$"
        }
      },
      "required": [
        "id",
        "label",
        "format",
        "quantization"
      ]
    },
    "configuration": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "architecture": {
          "enum": [
            "arm64",
            "x86_64"
          ]
        },
        "cpu": {
          "type": "string",
          "pattern": "^(?:apple-m[0-9]+(?:-(?:pro|max|ultra))?|intel-core-i[3579]-[0-9]{4,5}[a-z]{0,3}|amd-ryzen-[3579]-[0-9]{4,5}[a-z]{0,3})$"
        },
        "physical_cores": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4096
        },
        "logical_cores": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8192
        },
        "memory_bytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "memory_type": {
          "enum": [
            "unified",
            "system"
          ]
        },
        "gpus": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "model": {
                "type": "string",
                "pattern": "^(?:apple-m[0-9]+(?:-(?:pro|max|ultra))?|nvidia-(?:rtx|gtx)-[0-9]{3,4}(?:-(?:ti|super))?)$"
              },
              "cores": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "memory_bytes": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "model",
              "cores",
              "memory_bytes"
            ]
          }
        }
      },
      "required": [
        "architecture",
        "cpu",
        "physical_cores",
        "logical_cores",
        "memory_bytes",
        "memory_type",
        "gpus"
      ]
    },
    "hardware": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^hc2-[a-f0-9]{64}$"
        },
        "label": {
          "type": "string",
          "maxLength": 120
        },
        "configuration": {
          "$ref": "#/definitions/configuration"
        }
      },
      "required": [
        "id",
        "label",
        "configuration"
      ]
    },
    "profile": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "source": {
          "const": "ollama-slot-progress-v1"
        },
        "context_length": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100000000
        },
        "concurrency": {
          "type": "integer",
          "minimum": 1,
          "maximum": 64
        },
        "input_bucket": {
          "enum": [
            "0-512",
            "513-2048",
            "2049-8192",
            "8193-32768",
            "32769-131072",
            "131073+",
            "unknown"
          ]
        },
        "output_bucket": {
          "enum": [
            "0-512",
            "513-2048",
            "2049-8192",
            "8193-32768",
            "32769-131072",
            "131073+",
            "unknown"
          ]
        },
        "cache": {
          "enum": [
            "hit",
            "uncached",
            "unknown"
          ]
        },
        "temperature": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "top_p": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "speculative": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "runtime": {
          "const": "ollama"
        },
        "runtime_version": {
          "type": "string",
          "pattern": "^(?:[0-9]+(?:\\.[0-9]+){1,3}|unknown)$"
        },
        "backend": {
          "enum": [
            "metal",
            "cuda",
            "rocm",
            "cpu",
            "vulkan",
            "unknown"
          ]
        },
        "os_family": {
          "enum": [
            "macos",
            "linux",
            "windows",
            "unknown"
          ]
        },
        "os_version": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9]+(?:[._+ -][A-Za-z0-9]+)*$",
          "maxLength": 80
        },
        "thinking": {
          "enum": [
            "off",
            "on",
            "low",
            "medium",
            "high",
            "unknown"
          ]
        }
      },
      "required": [
        "source",
        "context_length",
        "concurrency",
        "input_bucket",
        "output_bucket",
        "cache",
        "temperature",
        "top_p",
        "speculative",
        "runtime",
        "runtime_version",
        "backend",
        "os_family",
        "os_version",
        "thinking"
      ]
    },
    "cohort": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "hostclass": {
          "$ref": "#/definitions/hardware"
        },
        "model": {
          "$ref": "#/definitions/model"
        },
        "profile": {
          "$ref": "#/definitions/profile"
        },
        "mean_output_tokens_per_second": {
          "type": "number",
          "minimum": 0
        },
        "median_output_tokens_per_second": {
          "type": "number",
          "minimum": 0
        },
        "q1": {
          "type": "number",
          "minimum": 0
        },
        "q3": {
          "type": "number",
          "minimum": 0
        },
        "host_count": {
          "type": "integer",
          "minimum": 1
        },
        "contributor_count": {
          "type": "integer",
          "minimum": 1
        },
        "sample_count": {
          "type": "integer",
          "minimum": 1
        },
        "publication": {
          "enum": [
            "local-preview-only",
            "eligible-for-review"
          ]
        }
      },
      "required": [
        "id",
        "hostclass",
        "model",
        "profile",
        "mean_output_tokens_per_second",
        "median_output_tokens_per_second",
        "q1",
        "q3",
        "host_count",
        "contributor_count",
        "sample_count",
        "publication"
      ]
    },
    "classrow": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^hc2-[a-f0-9]{64}$"
        },
        "label": {
          "type": "string",
          "maxLength": 120
        },
        "configuration": {
          "$ref": "#/definitions/configuration"
        },
        "host_count": {
          "type": "integer",
          "minimum": 1
        },
        "models": {
          "type": "array",
          "maxItems": 20000,
          "items": {
            "$ref": "#/definitions/model"
          }
        }
      },
      "required": [
        "id",
        "label",
        "configuration",
        "host_count",
        "models"
      ]
    },
    "available": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "status": {
          "const": "available"
        },
        "classes": {
          "type": "array",
          "maxItems": 1000,
          "items": {
            "$ref": "#/definitions/classrow"
          }
        },
        "cohorts": {
          "type": "array",
          "maxItems": 20000,
          "items": {
            "$ref": "#/definitions/cohort"
          }
        },
        "coverage": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "hostclasses": {
              "type": "integer",
              "minimum": 0
            },
            "model_variants": {
              "type": "integer",
              "minimum": 0
            },
            "measured_profiles": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "hostclasses",
            "model_variants",
            "measured_profiles"
          ]
        },
        "unclassified_observations": {
          "type": "integer",
          "minimum": 0
        },
        "window": {
          "const": "retained local observations"
        },
        "privacy": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "minimum_hosts": {
              "const": 3
            },
            "minimum_contributors": {
              "const": 3
            },
            "scope": {
              "const": "local-preview-only"
            }
          },
          "required": [
            "minimum_hosts",
            "minimum_contributors",
            "scope"
          ]
        }
      },
      "required": [
        "status",
        "classes",
        "cohorts",
        "coverage",
        "unclassified_observations",
        "window",
        "privacy"
      ]
    },
    "unavailable": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "status": {
          "enum": [
            "not_configured",
            "unavailable",
            "sharing_disabled",
            "production_selected",
            "local_deletion_pending"
          ]
        },
        "classes": {
          "type": "array",
          "maxItems": 0
        },
        "cohorts": {
          "type": "array",
          "maxItems": 0
        }
      },
      "required": [
        "status",
        "classes",
        "cohorts"
      ]
    }
  }
}
