{
  "$defs": {
    "FederationBreakerState": {
      "description": "Persisted circuit-breaker state exposed by protected peer status APIs.",
      "oneOf": [
        {
          "const": "closed",
          "description": "Requests may be attempted.",
          "type": "string"
        },
        {
          "const": "open",
          "description": "Requests are blocked until the durable cooldown elapses.",
          "type": "string"
        },
        {
          "const": "half_open",
          "description": "One probe may run after the cooldown.",
          "type": "string"
        },
        {
          "const": "quarantined",
          "description": "Operator quarantine blocks all traffic.",
          "type": "string"
        }
      ]
    }
  },
  "$id": "urn:mars:schema:v1:federation-peer-status",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Protected, secret-free operational status for one peer.",
  "properties": {
    "breakerState": {
      "$ref": "#/$defs/FederationBreakerState",
      "description": "Current circuit-breaker state."
    },
    "consecutiveFailures": {
      "description": "Consecutive failed synchronization attempts.",
      "format": "uint32",
      "minimum": 0,
      "type": "integer"
    },
    "cursor": {
      "description": "Durable synchronization cursor.",
      "format": "uint64",
      "minimum": 0,
      "type": "integer"
    },
    "lag": {
      "description": "Peer-reported sequence lag from the persisted cursor.",
      "format": "uint64",
      "minimum": 0,
      "type": "integer"
    },
    "lastSuccessAt": {
      "description": "Last successful contact.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "latencyMs": {
      "description": "Last successful observed latency in milliseconds.",
      "format": "uint64",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "nextAttemptAt": {
      "description": "Earliest next permitted attempt.",
      "format": "date-time",
      "type": "string"
    },
    "peerDid": {
      "description": "Canonical OAS service DID.",
      "type": "string"
    },
    "quarantines": {
      "description": "Number of quarantined payloads attributed to this peer.",
      "format": "uint64",
      "minimum": 0,
      "type": "integer"
    }
  },
  "required": [
    "peerDid",
    "cursor",
    "breakerState",
    "consecutiveFailures",
    "lag",
    "quarantines",
    "nextAttemptAt"
  ],
  "title": "FederationPeerStatus",
  "type": "object"
}
