{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aletheia.lab/schemas/action.schema.json",
  "title": "Action",
  "type": "object",
  "required": ["id", "intent_id", "type", "channel", "operation", "payload", "policy_gate"],
  "properties": {
    "id": { "type": "string", "pattern": "^act_[a-zA-Z0-9_-]+$" },
    "intent_id": { "type": "string", "pattern": "^intent_[a-zA-Z0-9_-]+$" },
    "type": {
      "type": "string",
      "enum": ["read", "write", "compute", "store", "transfer_value", "publish", "admin"]
    },
    "channel": {
      "type": "string",
      "enum": ["matrix", "telegram", "discord", "email", "web", "filesystem", "db", "wallet", "internal"]
    },
    "operation": { "type": "string", "minLength": 1 },
    "payload": { "type": "object" },
    "policy_gate": {
      "type": "object",
      "required": ["mode", "requires_confirmation", "checks"],
      "properties": {
        "mode": { "type": "string", "enum": ["A0", "A1", "A2"] },
        "requires_confirmation": { "type": "boolean" },
        "checks": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["name", "result"],
            "properties": {
              "name": {
                "type": "string",
                "enum": ["clarity_ok", "risk_ok", "budget_ok", "permission_ok", "target_ok", "privacy_ok", "rate_limit_ok", "logging_ok"]
              },
              "result": { "type": "string", "enum": ["pass", "fail", "needs_user_input"] },
              "details": { "type": "string" }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "expected_effect": { "type": "string", "default": "" },
    "reversibility": { "type": "string", "enum": ["reversible", "partially_reversible", "irreversible"], "default": "reversible" }
  },
  "additionalProperties": false
}
