{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://denial-web.github.io/clawguard/schemas/sop-pack.schema.json",
  "title": "ClawGuard SOP Pack",
  "type": "object",
  "required": [
    "schemaVersion",
    "id",
    "title",
    "industry",
    "role",
    "evidence"
  ],
  "properties": {
    "schemaVersion": {
      "const": "clawguard.sopPack.v1"
    },
    "id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "industry": {
      "type": "string"
    },
    "role": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "label",
          "url"
        ],
        "properties": {
          "label": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "additionalProperties": false
      }
    },
    "evidence": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/checkItem"
      }
    },
    "approvals": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/checkItem"
      }
    },
    "thresholds": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "title",
          "field"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "max": {
            "type": "number"
          },
          "severity": {
            "$ref": "#/$defs/severity"
          },
          "decision": {
            "enum": [
              "manual_review",
              "block"
            ]
          },
          "recommendation": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "blockedActions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "title"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "whenMissing": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "whenThreshold": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "severity": {
            "$ref": "#/$defs/severity"
          },
          "reason": {
            "type": "string"
          },
          "recommendation": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "severity": {
      "enum": [
        "low",
        "medium",
        "high",
        "critical"
      ]
    },
    "checkItem": {
      "type": "object",
      "required": [
        "id",
        "title"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "severity": {
          "$ref": "#/$defs/severity"
        },
        "required": {
          "type": "boolean"
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "evidenceId": {
          "type": "string"
        },
        "recommendation": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  }
}
