Files
Peter Steinberger de12e0a06c feat(approvals): standing-grant ledger, revocation, and configurable terms (#131602)
* feat(approvals): standing-grant ledger, revocation, and configurable terms

Completes the operator half of cron standing grants (#129526):

- Grants are listable and revocable. New gateway methods
  exec.approval.grants.list/revoke (operator.approvals scope), CLI
  'openclaw approvals grants list|revoke', and a Standing grants section
  on the Control UI approvals page with per-row revoke. Revocation is
  idempotent, records the acting client, and takes effect at the next
  occurrence's spawn boundary.
- Grant terms are frozen at mint and configurable. Default stays
  until-revoked (matching what shipped Always allow has always meant);
  tools.exec.grantExpiryDays sets a day-bounded default for future
  grants (enterprise fleet policy), and resolve surfaces may override
  per grant via grantExpiresInDays / --expires-in-days. Existing grants
  keep their minted terms; config changes are never retroactive.
- expires_at_ms goes nullable (NULL = until revoked). The mandatory-
  expiry shape never reached a release tag, so the lazy ensure rebuilds
  it in place; grants are re-derivable authority, so the fail-closed
  cost is one re-prompt.
- Approval cards say what Always allow does. Automation approvals carry
  a standing-grant ApprovalScope (new union member) built server-side
  from the cron run registry (now carrying the job display name); the
  Control UI inbox card and modal render it via i18n, e.g. 'Always
  allow runs this exact command for "grant-demo" without asking, for
  10 days (revocable)'.
- Aux method registries stay in lockstep: new parity test fails when a
  GATEWAY_AUX_METHODS entry lacks a lazy handler (this gap produced
  live unknown-method errors during bring-up).

Live-proven on a hermetic gateway: until-revoked grant ran 62 promptless
occurrences; UI and CLI revocation each returned the prompt on the next
occurrence; config default stamped exactly 10.0 days via a UI resolve;
--expires-in-days 99 override stamped 99.0 days; ledger and card
screenshots captured from the running Control UI.

* chore(ui): annotate the scope narrowing assertion for the safety ratchet

* test(gateway): move aux-method parity check to its own suite

* fix(ci): boundary-parse UI approval scope; register grants schemas for native codegen

- The Swift/Kotlin generators discover named schemas through the
  protocol schema fragments; the standing-grant scope member and the
  grants list/revoke shapes were missing there, which made the Swift
  generator silently drop the ApprovalScope union and broke ios-build.
  Registered, regenerated, union and new struct emitted again.
- The chained-assertion lane rejects 'as unknown as' in the UI scope
  parser; replaced with a real per-kind boundary parser, which is what
  the rule asks for.
- The sqlite-allow-raw marker must share the line of a mid-statement
  prepare() call for the Kysely guardrail; split the pragma read so the
  SAFETY comment and the allow marker each sit on their own guarded
  line.

* chore(ui): record startup-budget growth for the approvals scope line

The standing-grant scope renderer and grants-ledger strings ride the
boot path (~700 B gzip). Recorded via the check's --update-baseline flow
with the reason inline; well under the committed 350 KiB hard cap.

* fix(gateway): restore the channel-restart helper export dropped on main

#118157 made startGatewayChannelFromActiveRegistry module-local while
its colocated test still imports it, breaking check-test-types and the
compact shard on every merge ref. Smallest correct main heal per the
broken-CI doctrine; the test passes again.

* fix(gateway): drive channel-restart reload coverage through its exported owner

Replaces the prior export restore: #118157 made the restart helper
module-local (the dead-export scan is right that tests are not
production consumers), but left its colocated test importing it, so
main failed check-test-types either way. The test now exercises the
same preserveManualStop semantics through rollbackStoppedGatewayChannels,
the exported reload owner, and the helper stays private.

* test(ui): answer the grants ledger request in approvals-page history tests

The approvals page now loads the standing-grant ledger next to history;
a method-aware stub answers it out of band so the ordered history mocks
keep their call counts. Adds coverage for the ledger render and the
revoke round-trip.

* chore(ui): record CI-observed startup-JS baseline for the grants surface

The e2e-real-gateway lane builds the same tree ~600 B larger than checks-ui
and local builds, past the 64 B variance allowance; record the CI-observed
value so the enforcement limit stops straddling cross-lane build variance.

* fix(cli): escape standing-grant ledger fields visibly; register grants methods in inventory tests

The grant ledger's revokedBy (client display name), automation label, and
agent-authored command now go through escapeApprovalTextForTerminal like the
pending-approvals table, so hostile control characters render as visible
\u{...} escapes instead of being silently stripped by the table renderer.
Regression test fails pre-fix. Also lists exec.approval.grants.list/revoke
in the 2026.8 release-train roster, classifies the approvals grants command
group for JSON output, and fixes the stubGrants mock typing.
2026-08-28 02:56:20 -07:00

11 KiB

summary, read_when, title
summary read_when title
CLI reference for `openclaw approvals` and `openclaw exec-policy`
You want to edit exec approvals from the CLI
You need to manage allowlists on gateway or node hosts
You need to list or resolve a pending approval without a chat surface
Approvals

openclaw approvals

Manage exec approvals for the local host, gateway host, or a node host. With no target flag, commands read/write the local approvals document in shared SQLite state. Use --gateway to target the gateway, or --node <id|name|ip> to target a specific node.

Alias: openclaw exec-approvals

Related: Exec approvals, Nodes

openclaw exec-policy

openclaw exec-policy is the local-only convenience command that keeps requested tools.exec.* config and the local host approvals document in sync in one step:

openclaw exec-policy show
openclaw exec-policy show --json

openclaw exec-policy preset yolo
openclaw exec-policy preset cautious --json

openclaw exec-policy set --host gateway --security full --ask off --ask-fallback full --json

Presets (yolo, cautious, deny-all) apply host, security, ask, and askFallback together. set applies only the flags you pass; each accepted value is validated (--host auto|sandbox|gateway|node, --security deny|allowlist|full, --ask off|on-miss|always, --ask-fallback deny|allowlist|full).

show, preset, and set accept --json and return the same requested, host, and effective policy facts as one JSON object.

Scope:

  • Updates the local config file and local approvals document together; does not push policy to the gateway or a node host.
  • --host node is rejected: node exec approvals are fetched from the node at runtime, so local exec-policy cannot synchronize them. Use openclaw approvals set --node <id|name|ip> instead.
  • exec-policy show marks host=node scopes as node-managed at runtime instead of deriving an effective policy from the local approvals document.

For remote host approvals, use openclaw approvals set --gateway or openclaw approvals set --node <id|name|ip> directly.

Common commands

openclaw approvals get
openclaw approvals get --node <id|name|ip>
openclaw approvals get --gateway
openclaw approvals pending
openclaw approvals resolve <id> <allow-once|allow-always|deny>

get shows the effective exec policy for the target: the requested tools.exec policy, the host approvals-file policy, and the merged effective result. Nodes with a host-native policy, such as the Windows companion, show that policy directly instead of applying OpenClaw approvals-file policy math.

For file-backed nodes, the merged view requires a host-resolved policy snapshot. Older nodes show the effective policy as unavailable instead of assuming the Gateway's requested policy also applies on the host.

Per-session `/exec` overrides are not included. Run `/exec` in the relevant session to inspect its current defaults.

Precedence:

  • The host approvals document is the enforceable source of truth.
  • Requested tools.exec policy can narrow or broaden intent, but the effective result is derived from host rules.
  • --node combines the node host approvals document with gateway tools.exec policy (both apply at runtime).
  • If gateway config is unavailable, the CLI falls back to the node approvals snapshot and notes that the final runtime policy could not be computed.

Pending approvals

List pending exec, plugin, and OpenClaw system-agent approvals from the Gateway:

openclaw approvals pending
openclaw approvals pending --json

Complete enumeration and the matching operator-wide resolve flow use operator.admin because approval records otherwise retain requester/reviewer filtering. Resolution also requests the dedicated operator.approvals scope. The standard CLI operator grant includes both scopes; a restricted third-party client should not request admin merely to emulate this command.

Human output shows the approval kind, agent/session attribution, request age, time until expiry, a shortened command or summary, and a shell-neutral id64_<base64url> id token. A Full request text block always follows the compact table with every complete token and a losslessly escaped request, so terminal-width shortening cannot hide a suffix or the token needed for resolution. Copy the complete token into resolve. Unsafe terminal characters in other fields are shown as visible Unicode escapes. JSON output returns normalized entries under approvals, preserving the original raw id, summary, createdAtMs, and expiresAtMs for scripts; raw ids remain accepted by resolve unless they use the reserved id64_ display-token prefix.

If a supplied id64_ value matches both a literal raw id and the decoded display token for another approval, the CLI rejects it as ambiguous instead of risking resolution of the wrong request.

Resolve one approval by its full id:

openclaw approvals resolve <id> allow-once
openclaw approvals resolve <id> allow-always
openclaw approvals resolve <id> deny --reason "Not expected during maintenance"

For exec requests, allow-always means always allow here: the generated grant is tied to the command's exact arguments and current working directory. The same command from another directory requires a separate approval.

For approvals raised by an automation (cron) run, allow-always mints a scoped standing grant instead of a JSON allowlist entry (see Standing grants for automations). By default the grant lives until revoked; --expires-in-days <n> freezes an explicit lifetime instead of the configured tools.exec.grantExpiryDays default:

openclaw approvals resolve <id> allow-always --expires-in-days 30

Standing grants

Standing grants minted by allow-always on automation approvals are listed and revoked from the same command group:

openclaw approvals grants list
openclaw approvals grants list --json
openclaw approvals grants revoke <grant-id>

The list shows the owning automation, the exact command, the use count, and each grant's state (until revoked, expires in N days, expired, or revoked). Revocation is idempotent and takes effect at the next occurrence's spawn boundary — that occurrence prompts again. Editing or deleting the automation invalidates its grants without needing an explicit revoke.

The CLI reads the unified approval record to select its kind, checks the requested decision against the record's allowed decisions, and then calls the unified resolver. A first successful decision exits 0. Repeating the recorded decision also exits 0 and reports already resolved (same decision). A conflicting decision, missing approval, expired approval, or decision unavailable for that approval kind prints a clear error and exits non-zero.

--reason adds a local note to the CLI confirmation. The current Gateway approval record has no free-text resolution-reason field, so this note is not persisted or sent to other approval surfaces.

Replace approvals from a file

openclaw approvals set --file ./exec-approvals.json
openclaw approvals set --stdin <<'EOF'
{ version: 1, defaults: { security: "full", ask: "off", askFallback: "full" } }
EOF
openclaw approvals set --node <id|name|ip> --file ./exec-approvals.json
openclaw approvals set --gateway --file ./exec-approvals.json

set accepts JSON5, not only strict JSON. Use either --file or --stdin, not both.

Host-native Windows nodes use their own policy shape:

openclaw approvals set --node <id|name|ip> --stdin <<'EOF'
{
  defaultAction: "deny",
  rules: [{ pattern: "hostname", action: "allow" }]
}
EOF

The CLI reads the node's current hash first and sends it with the update, so concurrent local edits are rejected instead of overwritten. rules is required because this operation replaces the node's complete rule list; defaultAction is optional. A node that reports its native policy as disabled cannot be configured remotely; enable or configure the policy on that host first. Host-native policies do not support the allowlist add|remove helpers.

"Never prompt" / YOLO example

Set the host approvals defaults to full + off for a host that should never stop on exec approvals:

openclaw approvals set --stdin <<'EOF'
{
  version: 1,
  defaults: {
    security: "full",
    ask: "off",
    askFallback: "full"
  }
}
EOF

For nodes that expose an OpenClaw approvals document, use the same body with openclaw approvals set --node <id|name|ip> --stdin. Host-native nodes require their owner-specific shape shown above.

This changes the host approvals document only. To keep the requested OpenClaw policy aligned, also set:

openclaw config set tools.exec.host gateway
openclaw config set tools.exec.mode full

tools.exec.host=gateway is explicit here because host=auto still means "sandbox when available, otherwise gateway": YOLO is about approvals, not routing. Use gateway (or /exec host=gateway) when you want host exec even with a sandbox configured.

Omitted askFallback defaults to deny. Set askFallback: "full" explicitly when upgrading a no-UI host that should keep never-prompt behavior.

Local shortcut for the same intent, on the local machine only:

openclaw exec-policy preset yolo

Allowlist helpers

openclaw approvals allowlist add "~/Projects/**/bin/rg"
openclaw approvals allowlist add --agent main --node <id|name|ip> "/usr/bin/uptime"
openclaw approvals allowlist add --agent "*" "/usr/bin/uname"

openclaw approvals allowlist remove "~/Projects/**/bin/rg"

Common options

get, set, and allowlist add|remove all support:

  • --node <id|name|ip> (resolves id, name, IP, or id prefix; same resolver as openclaw nodes)
  • --gateway
  • shared node RPC options: --url, --token, --timeout, --json

No target flag means the local approvals row in the shared state database.

allowlist add|remove also supports --agent <id> (defaults to "*", applying to all agents).

pending and resolve always use the Gateway because pending requests are live Gateway state. They support the shared Gateway connection options --url, --token, and --timeout; pending also supports --json.

Notes

  • The node host must advertise system.execApprovals.get/set (macOS app, headless node host, or Windows companion).
  • After upgrading from an argv-only generated-grant version, run openclaw doctor --fix if the update did not already do so. Doctor removes only inactive generated grants; manual allowlist rules stay in place. Rerun affected workflows to approve them in the intended directory.
  • Approvals are stored per host in $OPENCLAW_STATE_DIR/state/openclaw.sqlite#exec_approvals_config, or ~/.openclaw/state/openclaw.sqlite#exec_approvals_config when the variable is unset. The suffix identifies the singleton SQLite row.