{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://seanmcquilling.com/schemas/agent-run-plan.schema.json",
  "title": "Trace Lab Agent Run Plan",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "name", "task", "scope", "commands", "checks", "approvals", "expires", "backupRequired", "sensitive", "permissions", "customActions"],
  "properties": {
    "$schema": { "const": "https://seanmcquilling.com/schemas/agent-run-plan.schema.json" },
    "version": { "const": 2 },
    "name": { "type": "string", "minLength": 1, "maxLength": 160 },
    "task": { "type": "string", "minLength": 1 },
    "scope": { "type": "string", "minLength": 1 },
    "commands": { "type": "string" },
    "checks": { "type": "string", "minLength": 1 },
    "approvals": { "type": "string" },
    "expires": { "type": "string" },
    "backupRequired": { "type": "boolean" },
    "sensitive": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
    "permissions": {
      "type": "object",
      "properties": {
        "read": { "enum": ["allow", "ask", "block"] },
        "write": { "enum": ["allow", "ask", "block"] },
        "commands": { "enum": ["allow", "ask", "block"] },
        "network": { "enum": ["allow", "ask", "block"] },
        "secrets": { "enum": ["allow", "ask", "block"] },
        "publish": { "enum": ["allow", "ask", "block"] },
        "delete": { "enum": ["allow", "ask", "block"] }
      },
      "additionalProperties": { "enum": ["allow", "ask", "block"] },
      "required": ["read", "write", "commands", "network", "secrets", "publish", "delete"]
    },
    "customActions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "label", "rule"],
        "properties": {
          "id": { "type": "string", "minLength": 1 },
          "label": { "type": "string", "minLength": 1 },
          "rule": { "enum": ["allow", "ask", "block"] }
        }
      }
    }
  }
}
