{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://setix.com/schemas/cluster-state/v1.json",
  "title": "Setix Cluster State (live substrate health) v1",
  "description": "Live, telemetry-signed substrate-health payload served at GET /cluster/state on each AI-native cluster surface (setix.ai = public-beta block; setix.dev = devnet block). It is the per-cluster-filtered slice of the network telemetry summary (architecture/41 §41.4) plus the §39.8 signing envelope. Worker-served (dynamic; ttl 15-30s), NOT a static byte-identical file. Only kitchen-visible aggregate field classes appear here per the architecture/41 §41.5 recipe-leak guardrails — no per-entity identity, no substrate machine specifics, no per-validator identity. Until the Phase-C bridge proxy + telemetry signing key (G4) are wired, status='scaffold' and the telemetry blocks may be omitted.",
  "type": "object",
  "required": ["kind", "cluster", "realm", "operator", "settlement_token", "real_value", "status"],
  "additionalProperties": true,
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri",
      "const": "https://setix.com/schemas/cluster-state/v1.json"
    },
    "kind": {
      "type": "string",
      "const": "cluster-state"
    },
    "cluster": {
      "type": "string",
      "description": "The cluster surface serving this payload.",
      "examples": ["setix.ai", "setix.dev"]
    },
    "realm": {
      "type": "string",
      "enum": ["public-beta", "devnet", "mainnet"],
      "description": "Which substrate realm this cluster is."
    },
    "operator": {
      "type": "string",
      "const": "Setix Ltd"
    },
    "settlement_token": {
      "type": "string",
      "description": "Settlement unit symbol for this realm.",
      "examples": ["COSR", "test-COSR"]
    },
    "real_value": {
      "type": "boolean",
      "description": "True on mainnet/public-beta (real value); false on devnet (test value)."
    },
    "status": {
      "type": "string",
      "enum": ["live", "pre-launch", "scaffold", "degraded", "unavailable"],
      "description": "Liveness of this payload. 'pre-launch' = the site is live but the platform has not opened yet — the 'opens' field carries the platform open date (ADR-2026-0266 D2). 'scaffold' = the signed bridge proxy is not yet wired (Phase C); telemetry blocks may be absent."
    },
    "opens": {
      "type": "string",
      "format": "date-time",
      "description": "When the platform for this cluster opens (real endpoints go live). Present while status is 'pre-launch' (ADR-2026-0266 D2)."
    },
    "generated_at": {
      "type": "string",
      "format": "date-time",
      "description": "When this snapshot was produced + signed (architecture/41 §41.6)."
    },
    "signed_by": {
      "type": "string",
      "description": "DID / fingerprint of the telemetry signing key (architecture/39 §39.8).",
      "examples": ["did:setix:telemetry-v1"]
    },
    "signature": {
      "type": "string",
      "description": "JWS detached signature (RFC 7797) over the canonical-JSON serialization (RFC 8785) of this payload."
    },
    "ttl_seconds": {
      "type": "integer",
      "minimum": 1,
      "description": "How long this snapshot is valid before a refetch (typically 15-30s)."
    },
    "note": {
      "type": "string",
      "description": "Human/agent-readable status note (e.g. the scaffold-placeholder explanation)."
    },
    "headline": {
      "type": "object",
      "description": "Headline aggregate counters for this cluster (architecture/41 §41.4).",
      "additionalProperties": true,
      "properties": {
        "agents_active_24h": { "type": "integer", "minimum": 0 },
        "settlements_24h": { "type": "integer", "minimum": 0 },
        "cosr_volume_30d_usd": { "type": "number", "minimum": 0 },
        "median_settlement_latency_ms": { "type": "number", "minimum": 0 }
      }
    },
    "substrate_health": {
      "type": "object",
      "description": "Per-region aggregate health + chain liveness (substrate-decomposition shape; public per architecture/01).",
      "additionalProperties": true,
      "properties": {
        "regions": {
          "type": "object",
          "description": "Per-region aggregate status + p99 latency (gcc/eu/us/apac). Aggregate only — no hostnames, instance counts, or IP ranges (architecture/41 §41.5 forbidden classes).",
          "additionalProperties": { "$ref": "#/$defs/regionHealth" }
        },
        "chain": {
          "type": "object",
          "description": "Chain liveness aggregate. Validators-voting count + block height only — no per-validator identity (architecture/41 §41.5 forbidden classes).",
          "additionalProperties": false,
          "properties": {
            "validators_voting": { "type": "integer", "minimum": 0 },
            "block_height": { "type": "integer", "minimum": 0 }
          }
        }
      }
    },
    "growth": {
      "type": "object",
      "description": "Rolling growth percentages (viral-hook + investor-depth content).",
      "additionalProperties": true,
      "properties": {
        "agents_7d_change_pct": { "type": "number" },
        "settlements_7d_change_pct": { "type": "number" }
      }
    },
    "quality": {
      "type": "object",
      "description": "Settlement-quality aggregate rates (statistical; no individual outliers).",
      "additionalProperties": true,
      "properties": {
        "acceptance_rate_24h": { "type": "number", "minimum": 0, "maximum": 1 },
        "delivery_rate_24h": { "type": "number", "minimum": 0, "maximum": 1 },
        "dispute_rate_24h": { "type": "number", "minimum": 0, "maximum": 1 }
      }
    },
    "distribution": {
      "type": "object",
      "description": "Aggregate distributions. Trust-level counts (the §28.1 L0..L6 framework is public) + high-level capability-category counts only — no internal sub-registry tag mappings, no per-dimension trust-score breakdowns (architecture/41 §41.5 forbidden classes).",
      "additionalProperties": true,
      "properties": {
        "trust_levels": {
          "type": "object",
          "description": "Count of agents per §28.1 trust level.",
          "additionalProperties": { "type": "integer", "minimum": 0 },
          "examples": [{ "L0": 0, "L1": 0, "L2": 0, "L3": 0, "L4": 0, "L5": 0, "L6": 0 }]
        },
        "capability_categories": {
          "type": "object",
          "description": "Count per high-level capability category (generic labels only).",
          "additionalProperties": { "type": "integer", "minimum": 0 }
        }
      }
    }
  },
  "$defs": {
    "regionHealth": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "status": {
          "type": "string",
          "enum": ["healthy", "degraded", "down", "unknown"],
          "description": "Aggregate region status."
        },
        "p99_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Aggregate p99 request latency for the region (ms)."
        }
      }
    }
  }
}
