{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tokrepo.com/schemas/policy-pack.schema.json",
  "title": "TokRepo Agent Policy Pack",
  "description": "Policy pack consumed by agents before installing or publishing TokRepo assets.",
  "type": "object",
  "required": ["schema_version", "id", "default_action", "rules", "funnel_events"],
  "properties": {
    "schema_version": { "type": "string" },
    "id": { "type": "string" },
    "name": { "type": "string" },
    "default_action": {
      "type": "string",
      "enum": ["allow", "plan_first", "confirm", "stage", "deny"]
    },
    "rules": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "when", "action"],
        "properties": {
          "id": { "type": "string" },
          "when": { "type": "object", "additionalProperties": true },
          "action": { "type": "string", "enum": ["allow", "plan_first", "confirm", "stage", "deny"] },
          "reason": { "type": "string" }
        },
        "additionalProperties": true
      }
    },
    "funnel_events": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "additionalProperties": true
}
