{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "installationId",
    "revision",
    "generatedAt",
    "range",
    "timezone",
    "window",
    "lifetime",
    "activity",
    "records",
    "blocks",
    "rounds",
    "oracle"
  ],
  "properties": {
    "schemaVersion": {
      "const": 2
    },
    "installationId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "revision": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "generatedAt": {
      "$ref": "#/$defs/d0_timestamp"
    },
    "range": {
      "enum": [
        "7d",
        "30d"
      ]
    },
    "timezone": {
      "const": "UTC"
    },
    "window": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "startAt",
        "endAt",
        "dayCount",
        "bucketSeconds",
        "roundSeconds"
      ],
      "properties": {
        "startAt": {
          "$ref": "#/$defs/d0_timestamp"
        },
        "endAt": {
          "$ref": "#/$defs/d0_timestamp"
        },
        "dayCount": {
          "enum": [
            7,
            30
          ]
        },
        "bucketSeconds": {
          "const": 1800
        },
        "roundSeconds": {
          "const": 600
        }
      }
    },
    "lifetime": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "acceptedWorkUnits",
        "observedDistanceMm",
        "activeDayCount",
        "settledBlockCount",
        "settlementCount",
        "settledWorkUnits",
        "coverageBps",
        "firstObservedAt"
      ],
      "properties": {
        "acceptedWorkUnits": {
          "$ref": "#/$defs/d1_decimal"
        },
        "observedDistanceMm": {
          "$ref": "#/$defs/d1_decimal"
        },
        "activeDayCount": {
          "$ref": "#/$defs/d2_count"
        },
        "settledBlockCount": {
          "$ref": "#/$defs/d1_decimal"
        },
        "settlementCount": {
          "$ref": "#/$defs/d1_decimal"
        },
        "coverageBps": {
          "$ref": "#/$defs/d3_coverageBps"
        },
        "firstObservedAt": {
          "$ref": "#/$defs/d0_timestamp"
        },
        "settledWorkUnits": {
          "$ref": "#/$defs/d1_decimal"
        }
      }
    },
    "activity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "provenance",
        "coverage",
        "summary",
        "days",
        "typicalDay"
      ],
      "properties": {
        "provenance": {
          "const": "accepted_rounds"
        },
        "coverage": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "expectedRoundCount",
            "observedRoundCount",
            "coverageBps",
            "complete"
          ],
          "properties": {
            "expectedRoundCount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 4320
            },
            "observedRoundCount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 4320
            },
            "coverageBps": {
              "$ref": "#/$defs/d3_coverageBps"
            },
            "complete": {
              "type": "boolean"
            }
          }
        },
        "summary": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "observedWorkUnits",
            "observedDistanceMm",
            "activeDayCount",
            "inactiveDayCount",
            "averageWorkPerActiveDayMilli",
            "medianWorkPerActiveDay",
            "averageDistancePerActiveDayMm",
            "mostActiveDate",
            "mostActiveDateWorkUnits",
            "peakWindowStartMinuteUtc"
          ],
          "properties": {
            "observedWorkUnits": {
              "$ref": "#/$defs/d1_decimal"
            },
            "observedDistanceMm": {
              "$ref": "#/$defs/d1_decimal"
            },
            "activeDayCount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 30
            },
            "inactiveDayCount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 30
            },
            "averageWorkPerActiveDayMilli": {
              "$ref": "#/$defs/d4_nullableDecimal"
            },
            "medianWorkPerActiveDay": {
              "$ref": "#/$defs/d4_nullableDecimal"
            },
            "averageDistancePerActiveDayMm": {
              "$ref": "#/$defs/d4_nullableDecimal"
            },
            "mostActiveDate": {
              "anyOf": [
                {
                  "$ref": "#/$defs/d5_date"
                },
                {
                  "type": "null"
                }
              ]
            },
            "mostActiveDateWorkUnits": {
              "$ref": "#/$defs/d4_nullableDecimal"
            },
            "peakWindowStartMinuteUtc": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 1410,
                  "multipleOf": 30
                },
                {
                  "type": "null"
                }
              ]
            }
          }
        },
        "days": {
          "type": "array",
          "minItems": 7,
          "maxItems": 30,
          "items": {
            "$ref": "#/$defs/d6_activityDay"
          }
        },
        "typicalDay": {
          "type": "array",
          "minItems": 48,
          "maxItems": 48,
          "items": {
            "$ref": "#/$defs/d8_typicalBucket"
          }
        }
      }
    },
    "records": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mostWorkHalfHour",
        "mostWorkUtcDay",
        "maximumDailyDistanceMm",
        "peakObservedRpmMilli",
        "peakObservedSpeedMmPerSecond",
        "longestActiveWindowMinutes",
        "longestActiveDayStreak"
      ],
      "properties": {
        "mostWorkHalfHour": {
          "anyOf": [
            {
              "$ref": "#/$defs/d9_recordValue"
            },
            {
              "type": "null"
            }
          ]
        },
        "mostWorkUtcDay": {
          "anyOf": [
            {
              "$ref": "#/$defs/d9_recordValue"
            },
            {
              "type": "null"
            }
          ]
        },
        "maximumDailyDistanceMm": {
          "anyOf": [
            {
              "$ref": "#/$defs/d9_recordValue"
            },
            {
              "type": "null"
            }
          ]
        },
        "peakObservedRpmMilli": {
          "anyOf": [
            {
              "$ref": "#/$defs/d9_recordValue"
            },
            {
              "type": "null"
            }
          ]
        },
        "peakObservedSpeedMmPerSecond": {
          "anyOf": [
            {
              "$ref": "#/$defs/d9_recordValue"
            },
            {
              "type": "null"
            }
          ]
        },
        "longestActiveWindowMinutes": {
          "anyOf": [
            {
              "$ref": "#/$defs/d9_recordValue"
            },
            {
              "type": "null"
            }
          ]
        },
        "longestActiveDayStreak": {
          "anyOf": [
            {
              "$ref": "#/$defs/d9_recordValue"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "blocks": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "completedInRange",
            "completedAllTime",
            "averagePerActiveDayMilli",
            "mostInDay",
            "mostInDayDate",
            "zeroBlockDayCount",
            "medianCompletionMs",
            "p90CompletionMs"
          ],
          "properties": {
            "status": {
              "const": "available"
            },
            "completedInRange": {
              "$ref": "#/$defs/d1_decimal"
            },
            "completedAllTime": {
              "$ref": "#/$defs/d1_decimal"
            },
            "averagePerActiveDayMilli": {
              "$ref": "#/$defs/d1_decimal"
            },
            "mostInDay": {
              "$ref": "#/$defs/d1_decimal"
            },
            "mostInDayDate": {
              "$ref": "#/$defs/d5_date"
            },
            "zeroBlockDayCount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 30
            },
            "medianCompletionMs": {
              "$ref": "#/$defs/d10_nullableCount"
            },
            "p90CompletionMs": {
              "$ref": "#/$defs/d10_nullableCount"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "reason"
          ],
          "properties": {
            "status": {
              "const": "unavailable"
            },
            "reason": {
              "enum": [
                "completion_boundaries_unavailable",
                "insufficient_history"
              ]
            }
          }
        }
      ]
    },
    "rounds": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "observedCount",
        "activeCount",
        "zeroWorkCount",
        "missingCount",
        "activeRateBps",
        "averageActiveWorkMilli",
        "medianActiveWork",
        "p90ActiveWork",
        "mostActiveWork"
      ],
      "properties": {
        "observedCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4320
        },
        "activeCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4320
        },
        "zeroWorkCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4320
        },
        "missingCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4320
        },
        "activeRateBps": {
          "$ref": "#/$defs/d3_coverageBps"
        },
        "averageActiveWorkMilli": {
          "$ref": "#/$defs/d4_nullableDecimal"
        },
        "medianActiveWork": {
          "$ref": "#/$defs/d4_nullableDecimal"
        },
        "p90ActiveWork": {
          "$ref": "#/$defs/d4_nullableDecimal"
        },
        "mostActiveWork": {
          "$ref": "#/$defs/d4_nullableDecimal"
        }
      }
    },
    "oracle": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "coverageStartsAt",
            "completeForWindow",
            "submissionCount",
            "confirmedCount",
            "revertedCount",
            "supersededCount",
            "zeroBlockSubmissionCount",
            "confirmationRateBps",
            "revertRateBps",
            "submitP50Ms",
            "submitP90Ms",
            "finalityP50Ms",
            "finalityP90Ms"
          ],
          "properties": {
            "status": {
              "const": "available"
            },
            "coverageStartsAt": {
              "$ref": "#/$defs/d0_timestamp"
            },
            "completeForWindow": {
              "type": "boolean"
            },
            "submissionCount": {
              "$ref": "#/$defs/d2_count"
            },
            "confirmedCount": {
              "$ref": "#/$defs/d2_count"
            },
            "revertedCount": {
              "$ref": "#/$defs/d2_count"
            },
            "supersededCount": {
              "$ref": "#/$defs/d2_count"
            },
            "zeroBlockSubmissionCount": {
              "$ref": "#/$defs/d2_count"
            },
            "confirmationRateBps": {
              "$ref": "#/$defs/d3_coverageBps"
            },
            "revertRateBps": {
              "$ref": "#/$defs/d3_coverageBps"
            },
            "submitP50Ms": {
              "$ref": "#/$defs/d10_nullableCount"
            },
            "submitP90Ms": {
              "$ref": "#/$defs/d10_nullableCount"
            },
            "finalityP50Ms": {
              "$ref": "#/$defs/d10_nullableCount"
            },
            "finalityP90Ms": {
              "$ref": "#/$defs/d10_nullableCount"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "reason"
          ],
          "properties": {
            "status": {
              "const": "unavailable"
            },
            "reason": {
              "enum": [
                "projection_not_initialized",
                "insufficient_history"
              ]
            }
          }
        }
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "type": "object",
        "properties": {
          "range": {
            "const": "7d"
          }
        },
        "required": [
          "range"
        ]
      },
      "then": {
        "type": "object",
        "properties": {
          "window": {
            "type": "object",
            "properties": {
              "dayCount": {
                "const": 7
              }
            }
          },
          "activity": {
            "type": "object",
            "properties": {
              "days": {
                "type": "array",
                "minItems": 7,
                "maxItems": 7
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "type": "object",
        "properties": {
          "range": {
            "const": "30d"
          }
        },
        "required": [
          "range"
        ]
      },
      "then": {
        "type": "object",
        "properties": {
          "window": {
            "type": "object",
            "properties": {
              "dayCount": {
                "const": 30
              }
            }
          },
          "activity": {
            "type": "object",
            "properties": {
              "days": {
                "type": "array",
                "minItems": 30,
                "maxItems": 30
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "d0_timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "d1_decimal": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$",
      "maxLength": 78,
      "format": "uint256-decimal"
    },
    "d2_count": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "d3_coverageBps": {
      "type": "integer",
      "minimum": 0,
      "maximum": 10000
    },
    "d4_nullableDecimal": {
      "anyOf": [
        {
          "$ref": "#/$defs/d1_decimal"
        },
        {
          "type": "null"
        }
      ]
    },
    "d5_date": {
      "type": "string",
      "format": "date",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "d7_activityBucket": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "startMinuteUtc",
        "coverage",
        "observedRoundCount",
        "workUnits"
      ],
      "properties": {
        "startMinuteUtc": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1410,
          "multipleOf": 30
        },
        "coverage": {
          "enum": [
            "complete",
            "partial",
            "missing",
            "future"
          ]
        },
        "observedRoundCount": {
          "enum": [
            0,
            1,
            2,
            3
          ]
        },
        "workUnits": {
          "$ref": "#/$defs/d4_nullableDecimal"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "coverage": {
                "const": "complete"
              }
            },
            "required": [
              "coverage"
            ]
          },
          "then": {
            "properties": {
              "observedRoundCount": {
                "const": 3
              },
              "workUnits": {
                "$ref": "#/$defs/d1_decimal"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "coverage": {
                "const": "partial"
              }
            },
            "required": [
              "coverage"
            ]
          },
          "then": {
            "properties": {
              "observedRoundCount": {
                "enum": [
                  1,
                  2
                ]
              },
              "workUnits": {
                "$ref": "#/$defs/d1_decimal"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "coverage": {
                "enum": [
                  "missing",
                  "future"
                ]
              }
            },
            "required": [
              "coverage"
            ]
          },
          "then": {
            "properties": {
              "observedRoundCount": {
                "const": 0
              },
              "workUnits": {
                "type": "null"
              }
            }
          }
        }
      ]
    },
    "d6_activityDay": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "date",
        "coverage",
        "observedWorkUnits",
        "distanceMm",
        "buckets"
      ],
      "properties": {
        "date": {
          "$ref": "#/$defs/d5_date"
        },
        "coverage": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "expectedRoundCount",
            "observedRoundCount",
            "coverageBps"
          ],
          "properties": {
            "expectedRoundCount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 144
            },
            "observedRoundCount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 144
            },
            "coverageBps": {
              "$ref": "#/$defs/d3_coverageBps"
            }
          }
        },
        "observedWorkUnits": {
          "$ref": "#/$defs/d1_decimal"
        },
        "distanceMm": {
          "$ref": "#/$defs/d4_nullableDecimal"
        },
        "buckets": {
          "type": "array",
          "minItems": 48,
          "maxItems": 48,
          "items": {
            "$ref": "#/$defs/d7_activityBucket"
          }
        }
      }
    },
    "d8_typicalBucket": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "startMinuteUtc",
        "totalWorkUnits",
        "observedDayCount",
        "meanWorkMilli"
      ],
      "properties": {
        "startMinuteUtc": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1410,
          "multipleOf": 30
        },
        "totalWorkUnits": {
          "$ref": "#/$defs/d1_decimal"
        },
        "observedDayCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 30
        },
        "meanWorkMilli": {
          "$ref": "#/$defs/d4_nullableDecimal"
        }
      }
    },
    "d9_recordValue": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value",
        "occurredAt",
        "coverage"
      ],
      "properties": {
        "value": {
          "$ref": "#/$defs/d1_decimal"
        },
        "occurredAt": {
          "$ref": "#/$defs/d0_timestamp"
        },
        "coverage": {
          "enum": [
            "complete",
            "partial"
          ]
        }
      }
    },
    "d10_nullableCount": {
      "anyOf": [
        {
          "$ref": "#/$defs/d2_count"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "$comment": "Public response structure from source snapshot 9e38b9313c9b4926ad15c7cd691d7f5789bdbc55. See endpoint notes for semantic constraints."
}
