{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:cede:schema:monitoring-index:v0",
  "title": "CEDE monitoring index, v0",
  "description": "The body of GET /monitoring — every structure this account has recorded as in force, each with a measurement computed at read time (SPEC.md section 3.6). Each entry is a whole monitoring record: the same document GET /monitoring/{id} answers with, and monitoring.v0.schema.json is the authority on its shape. This schema states the members an entry must carry rather than restating that one in full, because two schemas describing the same bytes drift and then disagree about which is right; the checked-in contract suite validates every entry here against monitoring.v0 as well, so the two are held together by a test rather than by a copy. Everything monitoring.v0 says about the difference between the account holder's assertion and Cede's measurement applies to every entry: recording is the holder's assertion about a transaction executed entirely outside Cede, and an observation is a measurement produced by analytics software, never a determination.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "count", "monitoring"],
  "properties": {
    "schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "count": { "type": "integer", "minimum": 0, "description": "How many records this account has. Equal to the length of `monitoring`: this build pages nothing, and a count that could differ from the list would be a promise of paging that does not exist." },
    "monitoring": {
      "type": "array",
      "description": "The records, oldest first. Another account's records are not here and are not counted — a record that exists but is not yours is itself a disclosure.",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "schema_version",
          "id",
          "structure_id",
          "status",
          "recorded_at",
          "in_force",
          "observation",
          "links"
        ],
        "properties": {
          "schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
          "id": { "type": "string", "minLength": 1 },
          "structure_id": { "type": "string", "minLength": 1 },
          "status": { "type": "string", "enum": ["recorded"] },
          "recorded_at": { "type": "string", "minLength": 20 },
          "in_force": {
            "type": "object",
            "additionalProperties": true,
            "required": ["asserted_by", "asserted_at", "assertion"],
            "properties": {
              "asserted_by": { "type": "string", "enum": ["account_holder"] },
              "asserted_at": { "type": "string", "minLength": 20 },
              "assertion": { "type": "string", "minLength": 1 }
            }
          },
          "observation": {
            "type": "object",
            "additionalProperties": true,
            "description": "The first-class members of a measurement, restated here so a reader of the list alone can rely on them: which model produced it, which snapshot it came from, what the level was, and how far that level is from the attachment.",
            "required": [
              "observed_at",
              "model",
              "feed",
              "index_value",
              "index_unit",
              "attachment_level",
              "distance_to_attachment",
              "attachment_reached",
              "trigger_levels",
              "measurement_window",
              "disclosure"
            ],
            "properties": {
              "observed_at": { "type": "string", "minLength": 20 },
              "model": {
                "type": "object",
                "additionalProperties": true,
                "description": "SPEC.md section 4 P9's label: the model and version that produced this level. Required on a listed entry as it is on the record itself — a list of results with no producing model named is a list of unattributable numbers.",
                "required": ["name", "version"],
                "properties": {
                  "name": { "type": "string", "minLength": 1 },
                  "version": { "type": "string", "minLength": 1 }
                }
              },
              "feed": {
                "type": "object",
                "additionalProperties": true,
                "required": ["id", "version", "vintage", "sha256"],
                "properties": {
                  "id": { "type": "string", "minLength": 1 },
                  "version": { "type": "string", "minLength": 1 },
                  "vintage": { "type": "string", "minLength": 1 },
                  "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
                }
              },
              "index_value": { "type": ["number", "null"] },
              "index_unit": { "type": "string", "minLength": 1 },
              "attachment_level": { "type": "number" },
              "distance_to_attachment": { "type": ["number", "null"] },
              "attachment_reached": { "type": "boolean" },
              "trigger_levels": { "type": "array", "minItems": 1 },
              "measurement_window": { "type": "object" },
              "disclosure": { "type": "string", "minLength": 1 }
            }
          },
          "links": { "type": "object", "required": ["self", "structure"] }
        }
      }
    }
  }
}
