{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://uwmd.org/schemas/issue-remediation.schema.json",
  "title": "UW Issue Remediation Entry",
  "description": "One entry in a remediation registry. Renderers SHOULD surface the title and remediation text verbatim — the goal is uniform UX across every conforming implementation. Modules ship their own entries to extend BUILTIN_REMEDIATIONS. Mirrors the IssueRemediation interface in @uwmd/verify's protocol.ts and is referenced by ProtocolError.code lookups. See UW_PROTOCOL.md §III.6a.",
  "type": "object",
  "required": ["code", "severity", "title", "description", "remediation"],
  "additionalProperties": false,
  "properties": {
    "code": {
      "type": "string",
      "pattern": "^[A-Z][A-Z0-9_-]{2,}$",
      "description": "Stable validation code (e.g. 'CC-01'). MUST match the code on a ValidationMessage / ProtocolError for the renderer to look it up. RFC 0072 adds DQ-07 (scenario vocabulary), DQ-08 (BTR carrier agreement) and DQ-09 (BTR class scope), all warnings in both format generations."
    },
    "severity": {
      "enum": ["error", "warning", "info"],
      "description": "Default severity emitted by the validator. Implementations MAY override per institution config."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "description": "Short title shown in the issue list (e.g. 'Sources & Uses imbalance')."
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "description": "Plain-language description of what is wrong."
    },
    "remediation": {
      "type": "string",
      "minLength": 1,
      "description": "Imperative remediation copy (e.g. 'Recompute LTV = loan_amount / underwritten value and restate debt_structure.ltv.')."
    },
    "spec_ref": {
      "type": "string",
      "description": "Spec section anchor for deep-linking (e.g. '§5.3 CC-01')."
    }
  },
  "examples": [
    {
      "code": "CC-04",
      "severity": "error",
      "title": "Sources & Uses imbalance",
      "description": "sources_uses.total_sources does not equal sources_uses.total_uses (within $1).",
      "remediation": "Reconcile the capital stack — equity + debt proceeds + other sources MUST equal price + closing + reserves.",
      "spec_ref": "§5.3 CC-04"
    }
  ]
}
