{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/theagentforge-io/json-schema/theagentforge-io-server-history-schema.json",
  "title": "ServerHistory",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/theagentforge-io-api-openapi.json#/components/schemas/ServerHistory",
  "type": "object",
  "required": [
    "contract",
    "contract_version",
    "data_kind",
    "server",
    "status",
    "data_as_of",
    "request",
    "notes",
    "licence"
  ],
  "properties": {
    "contract": {
      "const": "forge.server-history/v1"
    },
    "contract_version": {
      "type": "string",
      "description": "Semver of the contract: a minor bump only adds fields; removing or renaming one is a new contract (v2)."
    },
    "data_kind": {
      "const": "server_history"
    },
    "server": {
      "type": "string"
    },
    "status": {
      "enum": [
        "measured",
        "not_yet_measured"
      ]
    },
    "data_as_of": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "The newest timestamp among the rows read (null when nothing is measured)."
    },
    "tool_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "request": {
      "type": "object",
      "properties": {
        "section": {
          "enum": [
            "all",
            "install_outcomes",
            "definitions",
            "changes"
          ]
        },
        "offset": {
          "type": "integer"
        },
        "limit": {
          "type": "integer"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "install_outcomes": {
      "type": "object",
      "description": "House install outcomes by date and version. Each row carries its family (top500_nightly, weekly_sweep, backfill) and origin; counts are per family and never added across families.",
      "properties": {
        "status": {
          "enum": [
            "measured",
            "not_yet_measured"
          ]
        },
        "taxonomy": {
          "type": "string"
        },
        "families": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "status": {
                "enum": [
                  "measured",
                  "not_yet_measured",
                  "queued"
                ]
              },
              "tested": {
                "type": "integer"
              },
              "installed": {
                "type": "integer"
              },
              "failed": {
                "type": "integer"
              },
              "failed_by_class": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "first_date": {
                "type": "string",
                "format": "date"
              },
              "last_date": {
                "type": "string",
                "format": "date"
              },
              "pending": {
                "type": "integer"
              },
              "excluded_by_reason": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              }
            }
          }
        },
        "total": {
          "type": "integer"
        },
        "offset": {
          "type": "integer"
        },
        "limit": {
          "type": "integer"
        },
        "next": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "date": {
                "type": "string",
                "format": "date"
              },
              "family": {
                "enum": [
                  "top500_nightly",
                  "weekly_sweep",
                  "backfill"
                ]
              },
              "origin": {
                "enum": [
                  "post",
                  "kv_copy",
                  "backfill"
                ]
              },
              "version": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "outcome": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "installed": {
                "type": "boolean"
              },
              "failure_class": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "tools_count": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "observed_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "published_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      }
    },
    "definitions": {
      "type": "object",
      "description": "Tool-definition sets per version as sha256 and counts (no tool text). first_seen is the publish date for backfill rows and the first sighting otherwise; published_at is the registry's publish date where known; observed_at is when we read it.",
      "properties": {
        "status": {
          "enum": [
            "measured",
            "not_yet_measured"
          ]
        },
        "by_origin": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "sets": {
                "type": "integer"
              },
              "versions": {
                "type": "integer"
              }
            }
          }
        },
        "versions": {
          "type": "integer"
        },
        "total": {
          "type": "integer"
        },
        "next": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "version": {
                "type": "string"
              },
              "server": {
                "type": "string",
                "description": "The House id the set was read from (a tool page can list more than one package)."
              },
              "origin": {
                "enum": [
                  "nightly",
                  "carried",
                  "backfill"
                ]
              },
              "description_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "tools_count": {
                "type": "integer"
              },
              "descriptions_count": {
                "type": "integer"
              },
              "rules_version": {
                "type": "string"
              },
              "first_seen": {
                "type": "string",
                "format": "date-time"
              },
              "published_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "observed_at": {
                "type": "string",
                "format": "date-time"
              },
              "last_seen": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      }
    },
    "changes": {
      "type": "object",
      "description": "Consecutive definition sets compared, newest first. new_rule_ids: scanner rule ids the new text matched that the old did not (ids only; a pattern, not a finding).",
      "properties": {
        "status": {
          "enum": [
            "measured",
            "not_yet_measured",
            "not_yet_computed"
          ]
        },
        "pairs": {
          "type": "integer"
        },
        "changed": {
          "type": "integer"
        },
        "changed_without_major_bump": {
          "type": "integer"
        },
        "with_new_rule_ids": {
          "type": "integer"
        },
        "computed_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "total": {
          "type": "integer"
        },
        "next": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "seq": {
                "type": "integer"
              },
              "from_version": {
                "type": "string"
              },
              "to_version": {
                "type": "string"
              },
              "from_sha256": {
                "type": "string"
              },
              "to_sha256": {
                "type": "string"
              },
              "from_published_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "to_published_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "change_classes": {
                "type": "array",
                "items": {
                  "enum": [
                    "tool_added",
                    "tool_removed",
                    "description_changed",
                    "schema_changed"
                  ]
                }
              },
              "tools_added": {
                "type": "integer"
              },
              "tools_removed": {
                "type": "integer"
              },
              "descriptions_changed": {
                "type": "integer"
              },
              "schemas_changed": {
                "type": "integer"
              },
              "major_bump": {
                "type": "boolean"
              },
              "zero_major": {
                "type": "boolean"
              },
              "same_version": {
                "type": "boolean"
              },
              "untested_between": {
                "type": "integer"
              },
              "new_rule_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "notes": {
      "type": "object",
      "additionalProperties": true
    },
    "licence": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  },
  "additionalProperties": true
}