Guides · Policies
Policy cookbook
Tested GSL patterns for payments, production safety, data access, delegation, networks and risk.
Each pattern below is a complete policy that the documentation tests parse and validate. Combine them freely —
remember that a forbid anywhere wins and that anything not permitted is denied.
Spend limits with escalation#
Small refunds go through, larger ones need a human, and a daily budget caps the total per agent:
policy "refunds" {
description "Refunds up to 1000, approval above 100, 5000 per agent per day"
effect permit
principal agent where "support" in principal.tags
action "stripe:refunds.create"
resource "stripe:charge/*"
when has(context.amount) && context.amount > 0 && context.amount <= 1000
limit sum(context.amount) <= 5000 per 24h by agent
require approval when context.amount > 100 {
approvers role "approver"
expires 4h
}
}Read-only production#
policy "production-read-only" {
description "No writes in production unless the agent is tagged prod-writer"
effect forbid
principal agent
action any
resource any
environment in ["production"]
when action.category in ["write", "delete", "admin"]
unless "prod-writer" in principal.tags
}action.category is derived from the verb that ends the action (refunds.create → write, repos.delete →
delete, iam.grant → admin, tickets.read → read).
Allow reads everywhere, gate the rest#
policy "agents-read" {
effect permit
principal agent
action any
resource any
when action.category == "read"
}
policy "agents-write-with-review" {
effect permit
principal agent
action any
resource any
when action.category == "write"
require approval {
approvers owner
expires 1h
}
}Outbound email only to known domains#
policy "email-known-domains" {
effect permit
principal agent
action in ["gmail:messages.send", "m365:mail.send"]
resource any
when has(context.to) && domain(context.to) in ["example.com", "example.org"]
}
policy "email-elsewhere-needs-approval" {
effect require_approval
principal agent
action in ["gmail:messages.send", "m365:mail.send"]
resource any
when has(context.to) && !(domain(context.to) in ["example.com", "example.org"])
require approval {
approvers owner
}
}Network origin#
Only accept requests from the corporate network for administrative actions. request.ip is the client address
(behind a proxy, set TRUST_PROXY=true so it reflects X-Forwarded-For):
policy "admin-from-office-only" {
effect forbid
principal any
action "iam:**"
resource any
unless has(request.ip) && (cidr(request.ip, "10.20.0.0/16") || cidr(request.ip, "192.168.8.0/24"))
}Relationship-based access (ReBAC)#
An agent may edit a document only if its owner is an editor of it (tuples written with
POST /v1/authz/relationships):
policy "docs-owner-relationship" {
effect permit
principal agent where has(principal.owner)
action in ["docs:documents.update", "docs:documents.read"]
resource "docs:document/*"
when rel(principal.owner, "editor", resource.id)
}Delegation chains#
Agents acting through delegation (gsd_ tokens exchanged with RFC 8693) carry the chain. Cap its depth and keep
delegated agents away from payments:
policy "delegation-depth" {
effect forbid
principal agent
action any
resource any
when has(delegation.depth) && delegation.depth > 2
}
policy "no-delegated-payments" {
effect forbid
principal agent where has(principal.delegated) && principal.delegated == true
action "payments:**"
resource any
}Risk-based gates#
policy "high-risk-needs-security" {
effect require_approval
principal agent
action any
resource any
risk above 60
require approval {
approvers role "security_admin"
expires 30m
}
}
policy "low-risk-tickets" {
effect permit
principal agent
action "zendesk:tickets.*"
resource any
risk below 30
}The risk thresholds of the organization (PATCH /v1/risk/config, defaults approvalAbove 75 and denyAbove 95)
apply on top of policies.
Business hours#
policy "payroll-business-hours" {
effect permit
principal service_account
action "payroll:*"
resource any
schedule weekdays 08:00 - 18:00 "America/New_York"
}Database gateway#
Queries through the database gateway
are authorized as db:<engine>/<verb> actions (for example db:postgres/select) on
db:<connection>/<database>/<schema>/<table> resources, with the parsed query in context.query:
policy "block-destructive-sql" {
effect forbid
principal agent
action in ["db:*/drop", "db:*/truncate", "db:*/alter", "db:*/grant", "db:*/revoke"]
resource any
}
policy "block-unbounded-writes" {
effect forbid
principal agent
action in ["db:*/update", "db:*/delete"]
resource any
when has(context.query.hasWhere) && context.query.hasWhere == false
}MCP tools#
See MCP tool security for policies on mcp:<server>/<tool> actions.