{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aletheia.lab/schemas/budget_policy.schema.json",
  "title": "BudgetPolicy",
  "type": "object",
  "required": ["id", "mode", "limits", "allowlist"],
  "properties": {
    "id": { "type": "string", "pattern": "^bud_[a-zA-Z0-9_-]+$" },
    "mode": { "type": "string", "enum": ["A0", "A1", "A2"] },
    "limits": {
      "type": "object",
      "required": ["max_actions_per_hour", "max_external_writes_per_hour", "max_spend_per_day"],
      "properties": {
        "max_actions_per_hour": { "type": "integer", "minimum": 0 },
        "max_external_writes_per_hour": { "type": "integer", "minimum": 0 },
        "max_spend_per_day": { "type": "number", "minimum": 0 },
        "max_spend_per_tx": { "type": "number", "minimum": 0, "default": 0 },
        "max_post_length": { "type": "integer", "minimum": 0, "default": 0 }
      },
      "additionalProperties": false
    },
    "allowlist": {
      "type": "object",
      "properties": {
        "channels": {
          "type": "array",
          "items": { "type": "string", "enum": ["matrix", "telegram", "discord", "email", "web", "wallet", "db", "filesystem"] }
        },
        "targets": { "type": "array", "items": { "type": "string" }, "default": [] }
      },
      "additionalProperties": false
    },
    "denylist": {
      "type": "object",
      "properties": {
        "channels": { "type": "array", "items": { "type": "string" }, "default": [] },
        "targets": { "type": "array", "items": { "type": "string" }, "default": [] }
      },
      "additionalProperties": false,
      "default": {}
    },
    "requires_confirmation": {
      "type": "object",
      "properties": {
        "read_external": { "type": "boolean", "default": true },
        "write_external": { "type": "boolean", "default": true },
        "spend_money": { "type": "boolean", "default": true },
        "publish_public": { "type": "boolean", "default": true }
      },
      "additionalProperties": false,
      "default": {}
    }
  },
  "additionalProperties": false
}
