{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/git-top/json-schema/git-top-sync-status-response-schema.json",
  "title": "SyncStatusResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/git-top-openapi.json#/components/schemas/SyncStatusResponse",
  "type": "object",
  "required": [
    "detail",
    "health",
    "freshness",
    "priority"
  ],
  "properties": {
    "detail": {
      "type": "string",
      "enum": [
        "summary",
        "full"
      ]
    },
    "health": {
      "type": "string"
    },
    "freshness": {
      "type": "string"
    },
    "cursor": {
      "type": "object",
      "additionalProperties": true
    },
    "latest_success": {
      "type": "object",
      "additionalProperties": true
    },
    "recent_failures": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "priority": {
      "type": "object",
      "required": [
        "policy",
        "counts",
        "refresh_due_counts",
        "stale_counts",
        "stale_rates",
        "freshness_slo",
        "capacity"
      ],
      "properties": {
        "policy": {
          "type": "object",
          "properties": {
            "hot_target_days": {
              "type": "integer"
            },
            "warm_target_days": {
              "type": "integer"
            },
            "cold_target_days": {
              "type": "integer"
            }
          }
        },
        "counts": {
          "type": "object",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "refresh_due_counts": {
          "type": "object",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "stale_counts": {
          "type": "object",
          "additionalProperties": {
            "type": "integer"
          }
        },
        "stale_rates": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        },
        "freshness_slo": {
          "$ref": "#/$defs/SyncFreshnessSlo"
        },
        "capacity": {
          "type": "object",
          "required": [
            "scheduled_daily_capacity",
            "required_daily_syncs",
            "utilization",
            "headroom",
            "target_feasible"
          ],
          "properties": {
            "scheduled_runs_per_day": {
              "type": "integer"
            },
            "refresh_limit_per_run": {
              "type": "integer"
            },
            "scheduled_daily_capacity": {
              "type": "integer"
            },
            "required_daily_syncs": {
              "type": "integer"
            },
            "utilization": {
              "type": "number"
            },
            "headroom": {
              "type": "integer"
            },
            "target_feasible": {
              "type": "boolean"
            }
          }
        },
        "priority_preview": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "refresh_due_preview": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    },
    "derived": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": true,
  "$defs": {
    "SyncFreshnessSlo": {
      "type": "object",
      "required": [
        "hot_projects",
        "whole_corpus"
      ],
      "properties": {
        "hot_projects": {
          "allOf": [
            {
              "$ref": "#/$defs/SyncFreshnessSloSegment"
            },
            {
              "type": "object",
              "required": [
                "target_hours"
              ],
              "properties": {
                "target_hours": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          ]
        },
        "whole_corpus": {
          "allOf": [
            {
              "$ref": "#/$defs/SyncFreshnessSloSegment"
            },
            {
              "type": "object",
              "required": [
                "target_basis"
              ],
              "properties": {
                "target_basis": {
                  "type": "string",
                  "enum": [
                    "tier_policy"
                  ]
                }
              }
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "SyncFreshnessSloSegment": {
      "type": "object",
      "required": [
        "total",
        "within_target",
        "freshness_rate",
        "target_rate",
        "meets_target"
      ],
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "within_target": {
          "type": "integer",
          "minimum": 0
        },
        "freshness_rate": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "target_rate": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "meets_target": {
          "type": "boolean"
        }
      }
    }
  }
}