{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/repowise-dev/json-schema/repowise-dev-area-detail-response-schema.json",
  "title": "AreaDetailResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/repowise-dev-areas-api-openapi.yml#/components/schemas/AreaDetailResponse",
  "properties": {
    "area": {
      "$ref": "#/$defs/AreaNode"
    },
    "distribution": {
      "$ref": "#/$defs/AreaDistribution"
    },
    "worst_files": {
      "items": {
        "$ref": "#/$defs/AreaFileRow"
      },
      "type": "array",
      "title": "Worst Files"
    },
    "hotspots": {
      "$ref": "#/$defs/AreaHotspots"
    },
    "owners": {
      "$ref": "#/$defs/AreaOwners"
    },
    "trend": {
      "items": {
        "$ref": "#/$defs/AreaTrendPoint"
      },
      "type": "array",
      "title": "Trend"
    },
    "top_findings": {
      "items": {
        "$ref": "#/$defs/AreaFinding"
      },
      "type": "array",
      "title": "Top Findings"
    },
    "test_reach": {
      "$ref": "#/$defs/AreaTestReach"
    },
    "delta_window": {
      "$ref": "#/$defs/AreaDeltaWindow"
    },
    "coupled_areas": {
      "items": {
        "$ref": "#/$defs/CouplingAreaSummary"
      },
      "type": "array",
      "title": "Coupled Areas"
    }
  },
  "type": "object",
  "required": [
    "area",
    "distribution",
    "worst_files",
    "hotspots",
    "owners",
    "trend",
    "top_findings",
    "test_reach",
    "delta_window"
  ],
  "$defs": {
    "AreaBandCounts": {
      "properties": {
        "at_risk": {
          "type": "integer",
          "title": "At Risk"
        },
        "needs_work": {
          "type": "integer",
          "title": "Needs Work"
        },
        "fair": {
          "type": "integer",
          "title": "Fair"
        },
        "good": {
          "type": "integer",
          "title": "Good"
        },
        "excellent": {
          "type": "integer",
          "title": "Excellent"
        }
      },
      "type": "object",
      "required": [
        "at_risk",
        "needs_work",
        "fair",
        "good",
        "excellent"
      ],
      "title": "AreaBandCounts"
    },
    "AreaBandShare": {
      "properties": {
        "files": {
          "type": "integer",
          "title": "Files"
        },
        "nloc": {
          "type": "integer",
          "title": "Nloc"
        },
        "pct": {
          "type": "number",
          "title": "Pct"
        }
      },
      "type": "object",
      "required": [
        "files",
        "nloc",
        "pct"
      ],
      "title": "AreaBandShare"
    },
    "AreaBandShares": {
      "properties": {
        "at_risk": {
          "$ref": "#/$defs/AreaBandShare"
        },
        "needs_work": {
          "$ref": "#/$defs/AreaBandShare"
        },
        "fair": {
          "$ref": "#/$defs/AreaBandShare"
        },
        "good": {
          "$ref": "#/$defs/AreaBandShare"
        },
        "excellent": {
          "$ref": "#/$defs/AreaBandShare"
        }
      },
      "type": "object",
      "required": [
        "at_risk",
        "needs_work",
        "fair",
        "good",
        "excellent"
      ],
      "title": "AreaBandShares"
    },
    "AreaDeltaWindow": {
      "properties": {
        "target_days": {
          "type": "integer",
          "title": "Target Days"
        },
        "latest_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Latest At"
        },
        "baseline_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Baseline At"
        }
      },
      "type": "object",
      "required": [
        "target_days",
        "latest_at",
        "baseline_at"
      ],
      "title": "AreaDeltaWindow",
      "description": "The snapshots behind ``health_delta_30d``; the baseline may be nearer than 30 days."
    },
    "AreaDistribution": {
      "properties": {
        "total_files": {
          "type": "integer",
          "title": "Total Files"
        },
        "total_nloc": {
          "type": "integer",
          "title": "Total Nloc"
        },
        "bands": {
          "$ref": "#/$defs/AreaBandShares"
        }
      },
      "type": "object",
      "required": [
        "total_files",
        "total_nloc",
        "bands"
      ],
      "title": "AreaDistribution"
    },
    "AreaFileRow": {
      "properties": {
        "path": {
          "type": "string",
          "title": "Path"
        },
        "score": {
          "type": "number",
          "title": "Score"
        },
        "band": {
          "type": "string",
          "enum": [
            "at_risk",
            "needs_work",
            "fair",
            "good",
            "excellent"
          ],
          "title": "Band"
        },
        "nloc": {
          "type": "integer",
          "title": "Nloc"
        }
      },
      "type": "object",
      "required": [
        "path",
        "score",
        "band",
        "nloc"
      ],
      "title": "AreaFileRow"
    },
    "AreaFinding": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "file_path": {
          "type": "string",
          "title": "File Path"
        },
        "biomarker_type": {
          "type": "string",
          "title": "Biomarker Type"
        },
        "severity": {
          "type": "string",
          "title": "Severity"
        },
        "function_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Function Name"
        },
        "line_start": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Line Start"
        },
        "health_impact": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Health Impact"
        },
        "reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reason"
        }
      },
      "type": "object",
      "required": [
        "id",
        "file_path",
        "biomarker_type",
        "severity",
        "function_name",
        "line_start",
        "health_impact",
        "reason"
      ],
      "title": "AreaFinding"
    },
    "AreaHotspots": {
      "properties": {
        "total": {
          "type": "integer",
          "title": "Total"
        },
        "files": {
          "items": {
            "$ref": "#/$defs/AreaFileRow"
          },
          "type": "array",
          "title": "Files"
        }
      },
      "type": "object",
      "required": [
        "total",
        "files"
      ],
      "title": "AreaHotspots"
    },
    "AreaNode": {
      "properties": {
        "path": {
          "type": "string",
          "title": "Path"
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "depth": {
          "type": "integer",
          "title": "Depth"
        },
        "parent": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Parent"
        },
        "has_children": {
          "type": "boolean",
          "title": "Has Children"
        },
        "direct_file_count": {
          "type": "integer",
          "title": "Direct File Count"
        },
        "file_count": {
          "type": "integer",
          "title": "File Count"
        },
        "nloc": {
          "type": "integer",
          "title": "Nloc"
        },
        "health": {
          "type": "number",
          "title": "Health"
        },
        "band": {
          "type": "string",
          "enum": [
            "at_risk",
            "needs_work",
            "fair",
            "good",
            "excellent"
          ],
          "title": "Band"
        },
        "band_counts": {
          "$ref": "#/$defs/AreaBandCounts"
        },
        "worst_file": {
          "$ref": "#/$defs/AreaWorstFile"
        },
        "hotspot_count": {
          "type": "integer",
          "title": "Hotspot Count"
        },
        "bus_factor_1_count": {
          "type": "integer",
          "title": "Bus Factor 1 Count"
        },
        "primary_owner": {
          "anyOf": [
            {
              "$ref": "#/$defs/AreaOwner"
            },
            {
              "type": "null"
            }
          ]
        },
        "line_coverage_pct": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Line Coverage Pct"
        },
        "coverage_file_count": {
          "type": "integer",
          "title": "Coverage File Count"
        },
        "findings": {
          "$ref": "#/$defs/AreaSeverityCounts"
        },
        "health_delta_30d": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Health Delta 30D"
        }
      },
      "type": "object",
      "required": [
        "path",
        "name",
        "depth",
        "parent",
        "has_children",
        "direct_file_count",
        "file_count",
        "nloc",
        "health",
        "band",
        "band_counts",
        "worst_file",
        "hotspot_count",
        "bus_factor_1_count",
        "primary_owner",
        "line_coverage_pct",
        "coverage_file_count",
        "findings",
        "health_delta_30d"
      ],
      "title": "AreaNode"
    },
    "AreaOwner": {
      "properties": {
        "key": {
          "type": "string",
          "title": "Key"
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "kind": {
          "type": "string",
          "enum": [
            "human",
            "agent",
            "bot"
          ],
          "title": "Kind"
        },
        "files": {
          "type": "integer",
          "title": "Files"
        },
        "share": {
          "type": "number",
          "title": "Share"
        }
      },
      "type": "object",
      "required": [
        "key",
        "name",
        "kind",
        "files",
        "share"
      ],
      "title": "AreaOwner"
    },
    "AreaOwners": {
      "properties": {
        "total": {
          "type": "integer",
          "title": "Total"
        },
        "top": {
          "items": {
            "$ref": "#/$defs/AreaOwner"
          },
          "type": "array",
          "title": "Top"
        }
      },
      "type": "object",
      "required": [
        "total",
        "top"
      ],
      "title": "AreaOwners"
    },
    "AreaSeverityCounts": {
      "properties": {
        "critical": {
          "type": "integer",
          "title": "Critical"
        },
        "high": {
          "type": "integer",
          "title": "High"
        },
        "medium": {
          "type": "integer",
          "title": "Medium"
        },
        "low": {
          "type": "integer",
          "title": "Low"
        }
      },
      "type": "object",
      "required": [
        "critical",
        "high",
        "medium",
        "low"
      ],
      "title": "AreaSeverityCounts"
    },
    "AreaTestReach": {
      "properties": {
        "files": {
          "type": "integer",
          "title": "Files"
        },
        "with_test_file": {
          "type": "integer",
          "title": "With Test File"
        },
        "measured_files": {
          "type": "integer",
          "title": "Measured Files"
        },
        "line_coverage_pct": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Line Coverage Pct"
        }
      },
      "type": "object",
      "required": [
        "files",
        "with_test_file",
        "measured_files",
        "line_coverage_pct"
      ],
      "title": "AreaTestReach"
    },
    "AreaTrendPoint": {
      "properties": {
        "taken_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Taken At"
        },
        "health": {
          "type": "number",
          "title": "Health"
        }
      },
      "type": "object",
      "required": [
        "taken_at",
        "health"
      ],
      "title": "AreaTrendPoint"
    },
    "AreaWorstFile": {
      "properties": {
        "path": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Path"
        },
        "score": {
          "type": "number",
          "title": "Score"
        }
      },
      "type": "object",
      "required": [
        "path",
        "score"
      ],
      "title": "AreaWorstFile"
    },
    "CouplingAreaSummary": {
      "properties": {
        "pairs": {
          "type": "integer",
          "title": "Pairs"
        },
        "unexplained_pairs": {
          "type": "integer",
          "title": "Unexplained Pairs"
        },
        "unexplained_share": {
          "type": "number",
          "title": "Unexplained Share"
        },
        "strength": {
          "type": "number",
          "title": "Strength"
        },
        "co_changes": {
          "type": "integer",
          "title": "Co Changes"
        },
        "last_co_change": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Co Change"
        },
        "linked": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Linked"
        },
        "hidden": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Hidden"
        },
        "path": {
          "type": "string",
          "title": "Path"
        }
      },
      "type": "object",
      "required": [
        "pairs",
        "unexplained_pairs",
        "unexplained_share",
        "strength",
        "co_changes",
        "path"
      ],
      "title": "CouplingAreaSummary",
      "description": "One area's coupling: every kept pair with a file in it."
    }
  }
}