{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ProvenanceCode Risk Acceptance",
  "type": "object",
  "required": [
    "schema",
    "ra_id",
    "repo",
    "ref",
    "title",
    "status",
    "created_at",
    "updated_at",
    "risk_statement",
    "severity",
    "likelihood",
    "scope",
    "acceptance",
    "mitigations"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "type": "string",
      "const": "provenancecode.risk@1.0"
    },
    "ra_id": {
      "type": "string",
      "pattern": "^RA-\\d{6}$"
    },
    "repo": {
      "type": "object",
      "required": [
        "org",
        "name"
      ],
      "properties": {
        "org": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        },
        "name": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        }
      },
      "additionalProperties": true
    },
    "ref": {
      "type": "string",
      "pattern": "^pc:\\/\\/[a-z0-9-]+\\/[a-z0-9-]+\\/risk\\/RA-\\d{6}$"
    },
    "title": {
      "type": "string",
      "minLength": 8
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "expired",
        "closed"
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "risk_statement": {
      "type": "string",
      "minLength": 20
    },
    "severity": {
      "type": "string",
      "enum": [
        "low",
        "medium",
        "high",
        "critical"
      ]
    },
    "likelihood": {
      "type": "string",
      "enum": [
        "low",
        "medium",
        "high"
      ]
    },
    "scope": {
      "type": "object",
      "properties": {
        "paths": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "components": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": true
    },
    "acceptance": {
      "type": "object",
      "required": [
        "accepted_by",
        "accepted_at",
        "expires_at",
        "reason"
      ],
      "properties": {
        "accepted_by": {
          "type": "string",
          "minLength": 1
        },
        "accepted_at": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "reason": {
          "type": "string",
          "minLength": 10
        }
      },
      "additionalProperties": true
    },
    "mitigations": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "minLength": 1
          },
          "detail": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": true
      }
    },
    "links": {
      "type": "object",
      "properties": {
        "decisions": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^DEC-\\d{6}$"
              },
              {
                "type": "string",
                "pattern": "^pc:\\/\\/[a-z0-9-]+\\/[a-z0-9-]+\\/decision\\/DEC-\\d{6}$"
              }
            ]
          }
        },
        "specs": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^SPEC-\\d{6}$"
              },
              {
                "type": "string",
                "pattern": "^pc:\\/\\/[a-z0-9-]+\\/[a-z0-9-]+\\/spec\\/SPEC-\\d{6}$"
              }
            ]
          }
        },
        "mistakes": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^MR-\\d{6}$"
              },
              {
                "type": "string",
                "pattern": "^pc:\\/\\/[a-z0-9-]+\\/[a-z0-9-]+\\/mistake\\/MR-\\d{6}$"
              }
            ]
          }
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "pull_requests": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": true
    }
  }
}
