{
  "agents/$agentId/spend/$spendId": {
    "fields": { "amount": "UInt", "memo": "String?" },
    "rules": {
      "read": "@user.id != null && $agentId == @user.id",
      "create": "@user.id != null && $agentId == @user.id",
      "update": "false",
      "delete": "false"
    },
    "tier": "durable",
    "invariants": [
      {
        "type": "rollingSum",
        "name": "spend_cap",
        "field": "amount",
        "windowSeconds": 3600,
        "limit": 100,
        "scopeVariable": "$agentId"
      }
    ]
  }
}
