{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "provenancecode.risk.v2",
  "title": "ProvenanceCode Risk Record (v2.0)",
  "description": "Schema for ProvenanceCode v2.0 risk acceptance records",
  "type": "object",
  "required": [
    "schema",
    "risk_id",
    "title",
    "description",
    "severity",
    "status"
  ],
  "properties": {
    "schema": {
      "type": "string",
      "const": "provenancecode.risk.v2",
      "description": "Schema identifier"
    },
    "risk_id": {
      "type": "string",
      "pattern": "^RA-[A-Z0-9]{2,4}-[A-Z0-9]{2,4}-[0-9]{6}$",
      "description": "Unique risk identifier (format: RA-{PROJECT}-{SUBPROJECT}-{SEQ6})"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Brief title of the risk"
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "description": "Detailed description of the risk"
    },
    "severity": {
      "type": "string",
      "enum": ["low", "medium", "high", "critical"],
      "description": "Risk severity level"
    },
    "status": {
      "type": "string",
      "enum": ["open", "monitoring", "mitigated", "accepted", "closed"],
      "description": "Current status of the risk"
    },
    "project": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "pattern": "^[A-Z0-9]{2,4}$"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "subproject": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "pattern": "^[A-Z0-9]{2,4}$"
        },
        "name": {
          "type": "string"
        },
        "workspace": {
          "type": "string"
        }
      }
    },
    "linked_decisions": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^DEC-[A-Z0-9]{2,4}-[A-Z0-9]{2,4}-[0-9]{6}$"
      },
      "description": "Related decision IDs"
    },
    "mitigation": {
      "type": "string",
      "description": "Mitigation strategy or actions taken"
    },
    "impact": {
      "type": "string",
      "description": "Potential impact if risk materializes"
    },
    "probability": {
      "type": "string",
      "enum": ["low", "medium", "high"],
      "description": "Likelihood of risk occurring"
    },
    "timestamps": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "owner": {
      "type": "string",
      "description": "Risk owner or responsible party"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Tags for categorization"
    }
  },
  "additionalProperties": true
}

