Rule review

Each allow rule is compared with the requests it answered in the last 90 days. An owner sees the narrowest rule that would have answered every one: one key, one action, a lower limit, or removal when it was never used.

On day one an owner writes “allow refund.* for any agent, up to €5,000”, because nobody yet knows how the agent will be used. Two months later only the support bot has used it, only for refund.create, and never above €40. The rule still lets any key refund €5,000. Rule review compares each allow rule with the requests it actually answered and offers the narrowest rule that would have answered every one of them. An owner applies it with one click.

Rule review under Rules: an allow rule for refund.* for any agent up to €5,000 answered 12 requests, and the review offers to narrow it to the support-bot key, refund.create and a limit of €39, with Keep as written and Narrow rule buttons.

A review only ever narrows. It never widens a rule, never suggests a new allow, and never touches ask or deny rules. Nothing changes until an owner applies it.

Rule as written

allow refund.* · any agent key · up to €5000.00

What it answered in 60 days, all from support-bot

  • refund.create €12.00
  • refund.create €38.50
  • refund.create €20.00
  • refund.create €9.99
  • refund.create €25.00
  • refund.create €14.00

The review offers

  • Only key support-bot: no other key used it.
  • Only refund.create: no other action was asked for.
  • Limit €39.00: the largest it answered was €38.50.

allow refund.create · key support-bot · up to €39.00

A worked example in your browser, not a screenshot. It uses the same thresholds and rounding as the API.

What a review looks at

  • Every standing allow rule, and the requests it answered in the last 90 days, or since it was written if that is later.
  • Rules written less than 14 days ago are skipped: they have not had time to be used.
  • ask and deny rules are never reviewed, since they only make agents wait. Neither are rules with an end, such as an answer remembered for an hour or a day: they lapse on their own.
  • A rule with a budget is only ever offered for removal. Its spending is counted per rule, so a rewritten rule would start the budget again.
  • A rule is narrowed only once it answered at least 5 requests. Fewer say too little about how it is used.

What it can offer

remove
The rule is at least 30 days old and answered nothing in the period. Removing it means people decide those requests again.
only_key
The rule is for every agent key, but only one key used it, and that key still works. The rule is pinned to that key.
only_action
The rule covers many actions, such as refund.*, but only one was asked for. The pattern becomes that one action.
lower_limit
The largest amount the rule answered, rounded up to two significant figures (€38.50 gives €39), when the current limit is at least twice that. A rule with no limit gets one only when every request it answered stated an amount in one currency, so nothing it answered falls outside.

One review can offer several changes at once, and applying it makes all of them. Everything else about the rule stays: who decides, two-person approval and its cancel window.

Applying and keeping

  • Applying works the review out again and compares it with the changes you were shown, values included. If it offers anything else now, because new requests came in (a higher limit, another key), nothing changes and the answer is 409 with review_changed. Look again and decide on what is there.
  • The old rule and the narrower one are swapped in one step, so no request is ever judged by both or by neither. The new rule is recorded in the name of the owner who applied it, and the record holds both: the old rule’s removal, which names the rule that replaced it, and the new rule.
  • “Keep as written” hides the review for every owner until the rule is replaced.
  • Only owners, who write rules, see and apply reviews.

The API

List what each rule’s review offers. Rules with nothing to offer are left out:

curl https://api.variantgate.com/v1/workspaces/$WORKSPACE_ID/rule-reviews \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"
{
  "days": 90,
  "reviews": [
    {
      "rule": {
        "id": "01936f4e-8a2b-7c3d-9e4f-5a6b7c8d9e0f",
        "action": "refund.*",
        "agent_key_id": null,
        "effect": "allow",
        "limit_amount": "5000.00",
        "limit_currency": "EUR",
        "ends_at": null,
        "approvals": 1,
        "budget_amount": null,
        "budget_currency": null,
        "budget_period": null,
        "deciders": [],
        "escalate_after_seconds": null,
        "cancel_window_minutes": null,
        "created_by": "owner@example.com",
        "created_at": "2026-09-20T09:14:00Z"
      },
      "answered": 12,
      "since": "2026-09-20",
      "changes": [
        {
          "kind": "only_key",
          "key_id": "01936f4e-1111-7c3d-9e4f-5a6b7c8d9e0f",
          "key_name": "support-bot"
        },
        { "kind": "only_action", "action": "refund.create" },
        {
          "kind": "lower_limit",
          "from_amount": "5000.00",
          "to_amount": "39.00",
          "largest_amount": "38.50",
          "currency": "EUR"
        }
      ]
    }
  ]
}

Apply one by sending back every change you were shown, as the review listed it. The answer is the narrower rule, or removed: true when the review removed it:

curl -X POST \
  https://api.variantgate.com/v1/workspaces/$WORKSPACE_ID/rule-reviews/$RULE_ID/apply \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "changes": [
      { "kind": "only_key", "key_id": "01936f4e-1111-7c3d-9e4f-5a6b7c8d9e0f" },
      { "kind": "only_action", "action": "refund.create" },
      { "kind": "lower_limit", "to_amount": "39.00", "currency": "EUR" }
    ]
  }'

{
  "removed": false,
  "rule": {
    "id": "01937a10-5c6d-7e8f-9a0b-1c2d3e4f5a6b",
    "action": "refund.create",
    "agent_key_id": "01936f4e-1111-7c3d-9e4f-5a6b7c8d9e0f",
    "effect": "allow",
    "limit_amount": "39.00",
    "limit_currency": "EUR",
    …
  }
}

Keep a rule as written with POST /v1/workspaces/{workspace_id}/rule-reviews/{rule_id}/keep, which answers 204.

The other direction

Insights works the other way round: when a person keeps approving the same action from the same key, it suggests an allow rule, and an owner writes it. Rule review then keeps that rule, and every other one, no wider than its use.

Cloud platforms offer this for their own access policies, such as flagging unused permissions. Here it works on the rules that let agents act without asking, with the amounts and actions those agents actually used.