{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/toolpin-dev/json-schema/toolpin-dev-envelope-server-record-schema.json",
  "title": "Envelope[ServerRecord]",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/toolpin-dev-openapi.json#/components/schemas/Envelope_ServerRecord_",
  "properties": {
    "as_of": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "As Of",
      "description": "When all critical jobs had last succeeded. Null if one has never run."
    },
    "stale": {
      "type": "boolean",
      "title": "Stale",
      "description": "True when a daily job has not succeeded recently. The data is still served, and it is older than it should be."
    },
    "data": {
      "$ref": "#/$defs/ServerRecord"
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "as_of",
    "stale",
    "data"
  ],
  "$defs": {
    "AuthShape": {
      "properties": {
        "challenge": {
          "type": "boolean",
          "title": "Challenge"
        },
        "scheme": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Scheme"
        },
        "resource_metadata": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Resource Metadata"
        },
        "realm": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Realm"
        },
        "scope": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Scope"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Error"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "challenge"
      ],
      "title": "AuthShape",
      "description": "How a gated endpoint says to get in. Never a credential."
    },
    "Baseline": {
      "properties": {
        "drift_rate_per_day": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Drift Rate Per Day"
        },
        "window_days": {
          "type": "integer",
          "title": "Window Days"
        },
        "reachable_servers": {
          "type": "integer",
          "title": "Reachable Servers"
        },
        "drift_events_in_window": {
          "type": "integer",
          "title": "Drift Events In Window"
        },
        "note": {
          "type": "string",
          "title": "Note"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "drift_rate_per_day",
        "window_days",
        "reachable_servers",
        "drift_events_in_window",
        "note"
      ],
      "title": "Baseline",
      "description": "The catalog rate a per-server count has to be read against."
    },
    "EndpointRecord": {
      "properties": {
        "url": {
          "type": "string",
          "title": "Url"
        },
        "transport": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Transport"
        },
        "primary": {
          "type": "boolean",
          "title": "Primary",
          "description": "The endpoint that speaks for this server. Never infer this from position in the list."
        },
        "probe_status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Probe Status"
        },
        "status_text": {
          "type": "string",
          "title": "Status Text"
        },
        "last_checked": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Checked",
          "description": "A probe was attempted. Not the same as a check."
        },
        "last_verified_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Verified At",
          "description": "A tool list was actually read and hashed."
        },
        "last_status_code": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Status Code"
        },
        "latency_ms": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Latency Ms"
        },
        "consecutive_failures": {
          "type": "integer",
          "title": "Consecutive Failures"
        },
        "first_seen": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "First Seen"
        },
        "auth": {
          "anyOf": [
            {
              "$ref": "#/$defs/AuthShape"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "url",
        "transport",
        "primary",
        "probe_status",
        "status_text",
        "last_checked",
        "last_verified_at",
        "last_status_code",
        "latency_ms",
        "consecutive_failures",
        "first_seen"
      ],
      "title": "EndpointRecord"
    },
    "Repository": {
      "properties": {
        "url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Url"
        },
        "stars": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Stars"
        },
        "pushed_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Pushed At"
        },
        "archived": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Archived"
        },
        "fork": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Fork"
        },
        "gone": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Gone"
        },
        "checked_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Checked At"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "url",
        "stars",
        "pushed_at",
        "archived",
        "fork",
        "gone",
        "checked_at"
      ],
      "title": "Repository"
    },
    "ServerRecord": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "display_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Display Name"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description"
        },
        "status": {
          "type": "string",
          "title": "Status"
        },
        "latest_version": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Latest Version"
        },
        "website_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Website Url"
        },
        "protocol_version": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Protocol Version"
        },
        "transports": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Transports"
        },
        "first_seen": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "First Seen"
        },
        "last_seen": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Seen"
        },
        "registry_updated_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Registry Updated At"
        },
        "repository": {
          "$ref": "#/$defs/Repository"
        },
        "endpoints": {
          "items": {
            "$ref": "#/$defs/EndpointRecord"
          },
          "type": "array",
          "title": "Endpoints"
        },
        "tools": {
          "$ref": "#/$defs/ToolSummary"
        },
        "recent_changes": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object",
          "title": "Recent Changes"
        },
        "baseline": {
          "$ref": "#/$defs/Baseline"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "display_name",
        "description",
        "status",
        "latest_version",
        "website_url",
        "protocol_version",
        "transports",
        "first_seen",
        "last_seen",
        "registry_updated_at",
        "repository",
        "endpoints",
        "tools",
        "recent_changes",
        "baseline"
      ],
      "title": "ServerRecord"
    },
    "ToolSummary": {
      "properties": {
        "count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Count"
        },
        "server_hash": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Server Hash"
        },
        "captured_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Captured At"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "count",
        "server_hash",
        "captured_at"
      ],
      "title": "ToolSummary"
    }
  }
}