{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/repowise-dev/json-schema/repowise-dev-health-trend-response-schema.json",
  "title": "HealthTrendResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/repowise-dev-code-health-api-openapi.yml#/components/schemas/HealthTrendResponse",
  "properties": {
    "history": {
      "items": {
        "$ref": "#/$defs/HealthTrendKpiRow"
      },
      "type": "array",
      "title": "History",
      "default": []
    },
    "summary": {
      "$ref": "#/$defs/HealthTrendSummary"
    },
    "alerts": {
      "items": {
        "$ref": "#/$defs/HealthTrendAlert"
      },
      "type": "array",
      "title": "Alerts",
      "default": []
    },
    "file_deltas": {
      "items": {
        "$ref": "#/$defs/HealthFileDelta"
      },
      "type": "array",
      "title": "File Deltas",
      "default": []
    },
    "file_deltas_total": {
      "type": "integer",
      "title": "File Deltas Total",
      "default": 0
    },
    "file_deltas_worse": {
      "type": "integer",
      "title": "File Deltas Worse",
      "default": 0
    },
    "file_deltas_improved": {
      "type": "integer",
      "title": "File Deltas Improved",
      "default": 0
    },
    "snapshot_count": {
      "type": "integer",
      "title": "Snapshot Count",
      "default": 0
    },
    "scope": {
      "type": "string",
      "title": "Scope",
      "default": "all"
    }
  },
  "type": "object",
  "required": [
    "summary"
  ],
  "$defs": {
    "HealthFileDelta": {
      "properties": {
        "file_path": {
          "type": "string",
          "title": "File Path"
        },
        "before": {
          "type": "number",
          "title": "Before"
        },
        "after": {
          "type": "number",
          "title": "After"
        },
        "delta": {
          "type": "number",
          "title": "Delta"
        }
      },
      "type": "object",
      "required": [
        "file_path",
        "before",
        "after",
        "delta"
      ],
      "title": "HealthFileDelta",
      "description": "One file's movement between the last two snapshots."
    },
    "HealthTrendAlert": {
      "properties": {
        "kind": {
          "type": "string",
          "title": "Kind"
        },
        "metric": {
          "type": "string",
          "title": "Metric"
        },
        "current": {
          "type": "number",
          "title": "Current"
        },
        "baseline": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Baseline"
        },
        "delta": {
          "type": "number",
          "title": "Delta"
        },
        "message": {
          "type": "string",
          "title": "Message"
        },
        "driver": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Driver"
        },
        "structure_delta": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Structure Delta"
        },
        "history_delta": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "History Delta"
        }
      },
      "type": "object",
      "required": [
        "kind",
        "metric",
        "current",
        "delta",
        "message"
      ],
      "title": "HealthTrendAlert"
    },
    "HealthTrendKpiRow": {
      "properties": {
        "taken_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Taken At"
        },
        "hotspot_health": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Hotspot Health"
        },
        "average_health": {
          "type": "number",
          "title": "Average Health"
        },
        "worst_performer_path": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Worst Performer Path"
        },
        "worst_performer_score": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Worst Performer Score"
        },
        "structure_average": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Structure Average"
        },
        "history_average": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "History Average"
        },
        "maintainability_average": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Maintainability Average"
        },
        "doc_drift_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Doc Drift Count"
        }
      },
      "type": "object",
      "required": [
        "average_health"
      ],
      "title": "HealthTrendKpiRow",
      "description": "One snapshot in the repo-level history, newest first."
    },
    "HealthTrendSummary": {
      "properties": {
        "current_hotspot_health": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Current Hotspot Health"
        },
        "current_average_health": {
          "type": "number",
          "title": "Current Average Health"
        },
        "previous_hotspot_health": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Previous Hotspot Health"
        },
        "previous_average_health": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Previous Average Health"
        },
        "hotspot_delta": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Hotspot Delta"
        },
        "average_delta": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Average Delta"
        },
        "current_structure_deduction": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Current Structure Deduction"
        },
        "current_history_deduction": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Current History Deduction"
        }
      },
      "type": "object",
      "required": [
        "current_average_health"
      ],
      "title": "HealthTrendSummary"
    }
  }
}