{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sigelo-io/json-schema/sigelo-io-policy-change-schema.json",
  "title": "PolicyChange",
  "description": "The keeper-local policy change (apps/keeper/policychange.ts; not a SPEC object). Signed by an owner; single use by `nonce`.",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sigelo-io-openapi.yaml#/components/schemas/PolicyChange",
  "type": "object",
  "required": [
    "v",
    "typ",
    "keeper",
    "net",
    "agent",
    "set",
    "nonce",
    "iat",
    "exp"
  ],
  "additionalProperties": false,
  "properties": {
    "v": {
      "const": "sigelo/0"
    },
    "typ": {
      "const": "policy-change"
    },
    "keeper": {
      "$ref": "../../schema/common.json#/$defs/did"
    },
    "net": {
      "$ref": "#/$defs/Net"
    },
    "agent": {
      "type": "string",
      "description": "The agent's name in policy.json (a root)."
    },
    "set": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": false,
      "properties": {
        "per_tx_max": {
          "$ref": "#/$defs/Atomic"
        },
        "per_period_max": {
          "$ref": "#/$defs/Atomic"
        },
        "period_seconds": {
          "type": "integer",
          "minimum": 1
        },
        "rate_per_minute": {
          "type": "integer",
          "minimum": 1
        },
        "approval_above": {
          "oneOf": [
            {
              "$ref": "#/$defs/Atomic"
            },
            {
              "type": "null"
            }
          ]
        },
        "max_delegates": {
          "type": "integer",
          "minimum": 0
        },
        "allow": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AllowRule"
          }
        },
        "paused": {
          "type": "boolean"
        }
      }
    },
    "nonce": {
      "type": "string",
      "pattern": "^[0-9a-f]{32}$"
    },
    "iat": {
      "$ref": "../../schema/common.json#/$defs/unixSeconds"
    },
    "exp": {
      "$ref": "../../schema/common.json#/$defs/unixSeconds"
    }
  },
  "$defs": {
    "AllowRule": {
      "type": "object",
      "description": "An allowlist rule (policy.ts): `{addr, label?}` a literal address, or a DID / issuer rule.",
      "properties": {
        "addr": {
          "type": "string"
        },
        "label": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._-]{1,64}$"
        },
        "did": {
          "$ref": "../../schema/common.json#/$defs/did"
        },
        "issuer": {
          "$ref": "../../schema/common.json#/$defs/did"
        },
        "ctx": {
          "type": "string"
        }
      }
    },
    "Atomic": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$",
      "description": "Atomic units as a decimal string (1 XMR = 10^12). Never a JSON number."
    },
    "Net": {
      "enum": [
        "mainnet",
        "stagenet",
        "testnet"
      ]
    }
  }
}