RiskboundDocs

Policy library

Policy templates

Ready-made Cedar policies for the actions agents most often get wrong. Copy one, change the limits, and load it into Riskbound.

TemplateTools it guardsWhat it stops
refundsrefundLarge refunds. The reference policy from docs/use-case-refunds.md
paymentssend_payment, add_payeeLarge payments, money to new payees, other currencies
data-exportexport_customer_dataBulk exports, personal data leaving the company
recordsbulk_update_records, delete_recordsMass changes and deletes, changes to protected tables
emailsend_emailMass mail, attachments to outsiders, denied domains
accessgrant_access, revoke_accessAdmin grants, agents granting to themselves, long grants
cloud-spendprovision_resourceCostly resources, GPUs, unknown regions
code-executionrun_codeCode outside a sandbox, known dangerous commands

Three templates model whole support desks, for the industries where agents already handle money with customers:

TemplateTools it guardsWhat it stops
marketplaceissue_refund, send_replacement, issue_goodwill_credit, change_delivery_addressLarge refunds, refund abuse, address changes after shipping
food-deliveryrefund_order, credit_wallet, pay_partner_incentive, cancel_order"Not delivered" claims on delivered orders, repeat refunders, costly cancellations. Amounts in INR
ride-hailingadjust_fare, waive_cancellation_fee, pay_driver_adjustment, deactivate_accountRefunds above the fare, large driver payouts, deactivation without a person

Each folder has three files:

  • <name>.cedar: the policy.
  • README.md: what it guards, the params it expects, and how to tune it.
  • cases.json: example requests and the outcome each one must get.

How a template decides#

Riskbound has four outcomes. A policy grants one of three Cedar actions, and Riskbound asks about them in this order (docs/adr/0002):

Cedar actionOutcome if permitted
actallow: the action runs
act_with_approvalask_human: it waits for a person
dry_rundry_run: only the caller's dry-run handler runs. Offered only when the caller has one
none of themblock

A forbid beats every permit, so a hard limit is one forbid with no action in its scope. A forbid on Action::"act" alone sends a request to a person instead of blocking it (see cloud-spend).

The params a guard sends become context. Riskbound adds three keys of its own, which a request cannot overwrite: context.tool, context.agent and context.spent_today_minor.

Rules every template follows#

  • Amounts are whole numbers in minor units (amount_minor: 48000 is $480.00). Cedar has no floats, and Riskbound refuses fractions.
  • A missing param blocks. If a policy reads a param the request did not send, Cedar cannot evaluate it and Riskbound blocks with policy_error. The agent must send every param the template lists.
  • Every policy is scoped to its tool, so templates combine into one policy set without touching each other. Ids are unique across the library.
  • No rule means block. A tool no policy mentions is blocked with no_matching_policy.

Load a template#

A tenant has one live policy set. To use several templates, join them into one file. These commands store a new version and make it live. They need an admin key (npm run db:seed:dev prints one) and jq.

bash
export RISKBOUND_ADMIN_KEY=rb_admin_...
cat policies/refunds/refunds.cedar policies/payments/payments.cedar \
  | jq -Rs '{source: ., note: "refunds and payments templates"}' \
  | curl -s -X POST "http://localhost:8200/v1/policies" \
      -H "authorization: Bearer $RISKBOUND_ADMIN_KEY" -H 'content-type: application/json' -d @-

The answer has a version. Nothing changes until you make it live:

bash
curl -s -X POST "http://localhost:8200/v1/policies/2/activate" \
  -H "authorization: Bearer $RISKBOUND_ADMIN_KEY" -H 'content-type: application/json' \
  -d '{"actor": "you@example.com"}'

A new version replaces the old one. Policies are never edited in place.

Try a change before it goes live#

/v1/policies/simulate answers one request against a draft and the live policy, and records nothing:

bash
jq -Rs '{source: ., agent: "support-bot", tool: "send_payment",
         params: {amount_minor: 250000, currency: "USD", payee_is_new: true}}' \
  policies/payments/payments.cedar \
  | curl -s -X POST "http://localhost:8200/v1/policies/simulate" \
      -H "authorization: Bearer $RISKBOUND_ADMIN_KEY" -H 'content-type: application/json' -d @-

Test a template#

test/policy-templates.spec.ts runs every cases.json through the real policy engine, alone and with all templates joined. CI runs it. After you change a limit, change the cases to match and run:

bash
npx vitest run test/policy-templates.spec.ts

A case looks like this. reasons lists the policy ids that decided it. dry_run_supported, spent_today_minor and agent are optional.

json
{
  "name": "a $480 refund waits for a person",
  "tool": "refund",
  "params": { "amount_minor": 48000, "currency": "USD" },
  "expect": { "outcome": "ask_human", "reasons": ["refund-needs-approval"] }
}

What policy does not cover#

The daily spend cap and the rate limit are settings on the agent (POST /v1/agents), not policy text, because they depend on history. Pause, kill and the tenant kill switch also sit outside policy. All of them block before policy is asked.