{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/housedata-uk/json-schema/housedata-uk-score-result-schema.json",
  "title": "ScoreResult",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/housedata-uk-openapi.json#/components/schemas/ScoreResult",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "finalScore",
    "riskBand",
    "subScores",
    "riskFlags",
    "conveyancerGuidance",
    "model_version"
  ],
  "properties": {
    "finalScore": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "Headline consent-gap risk score."
    },
    "riskBand": {
      "type": "string",
      "enum": [
        "LOW",
        "MODERATE",
        "ELEVATED",
        "HIGH"
      ],
      "description": "LOW ≤20, MODERATE ≤45, ELEVATED ≤70, HIGH above. Raised above the weighted band when a single sub-score warrants it."
    },
    "weightedBand": {
      "type": "string",
      "enum": [
        "LOW",
        "MODERATE",
        "ELEVATED",
        "HIGH"
      ]
    },
    "bandElevatedBySubScore": {
      "type": "boolean"
    },
    "subScores": {
      "type": "object",
      "properties": {
        "floorAreaDelta": {
          "$ref": "#/$defs/SubScore"
        },
        "roomDelta": {
          "$ref": "#/$defs/SubScore"
        },
        "planningMatch": {
          "$ref": "#/$defs/SubScore"
        },
        "heritage": {
          "$ref": "#/$defs/SubScore"
        },
        "flood": {
          "$ref": "#/$defs/SubScore"
        },
        "transaction": {
          "$ref": "#/$defs/SubScore"
        }
      }
    },
    "riskFlags": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/RiskFlag"
      }
    },
    "conveyancerGuidance": {
      "type": "string"
    },
    "heritageAmplified": {
      "type": "boolean"
    },
    "dataQualityFlags": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "remediation": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "Remediation options (retrospective consent, indemnity insurance, price renegotiation); present when finalScore > 45."
    },
    "postcode": {
      "type": "string"
    },
    "uprn": {
      "type": [
        "string",
        "null"
      ]
    },
    "address": {
      "type": [
        "string",
        "null"
      ]
    },
    "epcCount": {
      "type": "integer"
    },
    "propertyType": {
      "type": [
        "string",
        "null"
      ]
    },
    "constructionYear": {
      "type": [
        "integer",
        "null"
      ]
    },
    "computed_at": {
      "type": "string",
      "format": "date-time"
    },
    "model_version": {
      "type": "string"
    },
    "data_sources": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "epcHistory": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "planningApplications": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "heritage": {
      "type": "object",
      "additionalProperties": true
    },
    "floodZone": {
      "type": [
        "integer",
        "null"
      ]
    },
    "transactions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "localMedianPrice": {
      "type": [
        "number",
        "null"
      ]
    }
  },
  "$defs": {
    "RiskFlag": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "risk",
            "info"
          ]
        },
        "signal": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "SubScore": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "weight": {
          "type": "number",
          "description": "Weight of this signal in the headline score."
        },
        "dataSource": {
          "type": [
            "string",
            "null"
          ]
        },
        "flags": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RiskFlag"
          }
        },
        "rawValues": {
          "type": "object",
          "additionalProperties": true
        }
      }
    }
  }
}