Skip to content

feat(approvals): standing-grant ledger, revocation, and configurable terms - #131602

Merged
steipete merged 10 commits into
mainfrom
steipete/grants-surface
Aug 28, 2026
Merged

steipete merged 10 commits into
mainfrom
steipete/grants-surface

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Standing grants (#129526) shipped as durable execution authority with no operator surface: revoked_at_ms/revoked_by existed in the schema but nothing could write them, no surface listed what standing authority existed, the fixed 30-day expiry was neither visible nor policy-controllable, and the approval card said "Always allow" without saying what that mints. The audit question "what can run on my machine without asking me?" had no answer short of opening SQLite.

Why This Change Was Made

This completes the operator half of the feature, with grant terms redesigned as frozen-at-mint and configurable:

  • Ledger + revocation. New gateway methods exec.approval.grants.list / exec.approval.grants.revoke (operator.approvals scope), openclaw approvals grants list|revoke, and a Standing grants section on the Control UI approvals settings page with per-row Revoke. Rows show the owning automation, exact command, use count, and state (until revoked / expires in Nd / expired / revoked by whom). Revocation is idempotent, records the acting client identity, and takes effect at the next occurrence's spawn boundary — the already-landed fail-closed consume path needed zero changes.
  • Terms freeze at mint; default matches shipped semantics. A grant now defaults to until revoked — the same meaning "Always allow" has everywhere else in the product, so nothing changes for existing users. tools.exec.grantExpiryDays (new config key, unset by default) sets a day-bounded default for future grants — the fleet-policy knob for managed/enterprise deployments that require periodic re-approval. Resolve surfaces can override per grant (grantExpiresInDays on approval.resolve/exec.approval.resolve, --expires-in-days on the CLI), the override beating the config default. Config changes are never retroactive; existing grants keep their minted terms, and the explicit path for retiring them is the revoke surface.
  • expires_at_ms goes nullable (NULL = until revoked). The mandatory-expiry shape never reached any release tag (verified against all tags through v2026.8.1-beta.3), so the first-use lazy ensure rebuilds the table in place instead of carrying migration debt; grants are re-derivable authority, so the fail-closed cost of a rebuild is one re-prompt.
  • The card says what Always allow does. Automation approvals now carry a standing-grant ApprovalScope (new member of the feat(approvals): typed approval scope summaries on channel cards #130116 union), built server-side from the cron run registry (which now records the job display name — never inferred from session keys). The Control UI inbox card and modal render it via i18n; the persisted approval presentation carries it for every other surface.
  • Registry parity guard. Bring-up surfaced that a gateway aux method must be registered in four places (descriptor, aux name list, schema validator, lazy handler map) and a miss produces live unknown method errors only. A new parity test fails when GATEWAY_AUX_METHODS and the lazy handler map diverge.

User Impact

Operators can finally see and retract standing automation authority: the approvals page lists every grant with a one-click revoke, the CLI mirrors it, and the approval card itself explains the deal before you click — "Always allow runs this exact command for "grant-demo" without asking, for 10 days (revocable)" (or "until revoked" when no policy is set). Defaults are unchanged; enterprises get tools.exec.grantExpiryDays and the per-resolve override for bounded-lifetime policies. Docs updated extensively: tools/exec-approvals (rewritten grants section: coverage, lifetime, listing/revocation), cli/approvals, gateway/config-tools, and automation/cron-jobs.

Evidence

Live end-to-end on a hermetic gateway (isolated state dir, port 19791, Haiku, id -un automation every minute, real Control UI):

  1. Until-revoked default: allow-always minted expires_at_ms = NULL; the grant then ran 62 consecutive promptless occurrences (spawn-boundary consume, zero new approval rows) over ~an hour.
  2. UI revoke: clicking Revoke in the Control UI wrote revoked_by = openclaw-control-ui; the next occurrence parked a fresh approval card (revoked authority fails closed live).
  3. Config default: with grantExpiryDays: 10, the next card's scope fact carried expiresInDays: 10, and resolving via the UI's "Always allow here" stamped a grant with exactly expires − created = 10.0 days.
  4. CLI revoke + override: approvals grants revoke → next occurrence prompted; approvals resolve <id> allow-always --expires-in-days 99 stamped exactly 99.0 days; approvals grants list renders the ledger with "expires in 99d".
  5. Focused suites green: standing-grants store (22 incl. list/revoke/legacy-rebuild/terms-freezing), approval-scope (15 incl. the new union member), exec-host gateway (110), aux-handlers incl. the new parity test, server-methods-list; check:changed fully green; Codex autoreview clean (0.97).

Approval card with the standing-grant scope line (10-day config default active):

Automation approval card showing the standing-grant scope line

Standing grants ledger on the approvals settings page:

Standing grants ledger with revoke action

Production LOC: roughly +560/−80 across store, gateway methods, CLI, and UI (new operator capability: ledger, revocation, configurable frozen terms, card scope facts); tests +480. Follow-ups unchanged from #129526: node-host grant lifecycle, doctor migration retiring legacy cron-generated allowlist digests, and the interactive allow-always → grants convergence decision doc.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 06:52
@steipete
steipete requested a review from a team as a code owner August 28, 2026 06:52
@steipete
steipete force-pushed the steipete/grants-surface branch from 5ac2414 to 0e716ed Compare August 28, 2026 07:31
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 28, 2026, 5:24 AM ET / 09:24 UTC.

ClawSweeper review

What this changes

Adds standing-grant listing, revocation, configurable expiry terms, and approval-card disclosure across the Gateway, CLI, Control UI, and native protocol clients.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/state/openclaw-state-schema.sql. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⛔ Blocked by patch quality or review findings - 14 items remain

Keep open: this maintainer-authored, protected PR has concrete P1 upgrade and authority-term blockers that must be fixed before merge.

Priority: P1
Reviewed head: b697629b3190d9b994c88c429e17dbb5ca854815
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): ClawSweeper live verification passed on the reviewed terminal surface.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): ClawSweeper live verification passed on the reviewed terminal surface.
Evidence reviewed 8 items Cold-open upgrade failure: The PR changes the canonical grant expiry column from mandatory to nullable, but the feature-local rebuild runs only during minting.
Startup validation rejects the old present table: Current startup asserts the full maintenance schema before a feature-local mint can rebuild the table; maintenance compatibility permits this lazy table to be missing, not to have a different column definition.
Generic resolver drops the new expiry override: The generic approval resolver validates the new field but resolveApprovalDecisionParams returns only id, decision, and reviewer, so approval.resolve never receives grantExpiresInDays.
Findings 6 actionable findings [P1] Repair legacy grant tables before startup validation
[P1] Preserve the grant expiry through the generic resolver
[P1] Do not promise a stale lifetime on the approval card
Security Needs attention Preserve the operator-selected expiry term: The generic approval path validates but discards the expiry override, so the documented CLI request can mint a different durable grant lifetime, including the indefinite default.
Keep approval disclosure synchronized with minting: Request-time expiry disclosure and resolution-time policy lookup can diverge after a configuration change, leaving the operator to approve a different authority term.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/operator-approval-standing-grants.test.ts

Result: PASS (completed)

ransaction 329ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant mint › stamps frozen terms when the mint carries an expiry 1
09ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant mint › does not create the table or mint for non-allow-alway
s decisions 118ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant mint › replaces the prior grant for the same agent, job, and
 binding 120ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant mint › mints through the manager only when the mint resolver
 returns a spec 113ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant mint › freezes terms at resolve: config default applies, per
-resolve override wins 111ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › consumes a valid grant and records usage facts
 107ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › returns no-grant when the feature table was ne
ver created 100ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › fails closed for a different operation binding
 108ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › fails closed after a stamped expiry passes 102
ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › keeps until-revoked grants valid far past any
calendar horizon 106ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › fails closed after revocation 101ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › fails closed when the cron job was deleted 106
ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › fails closed when the job config revision chan
ged 105ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › fails closed when the authoritative job row di
sagrees with a stale thread 104ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › fails closed when the minting approval row is
gone or reversed 106ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › cron standing grant consumption › survives a gateway restart and orphan cleanup
of pending approvals 235ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › standing grant operator surfaces › lists grants with the owning job name and par
seable operation 104ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › standing grant operator surfaces › returns an empty list before any grant create
d the table 104ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › standing grant operator surfaces › revokes once, reports already-revoked after,
and fails closed at consume 114ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › standing grant operator surfaces › reports not-found for unknown grants and befo
re the table exists 216ms
 ✓  gateway-core  ../../src/gateway/operator-approval-standing-grants.test.ts › standing grant operator surfaces › rebuilds the unshipped mandatory-expiry table
 shape on first use 103ms

 Test Files  1 passed (1)
      Tests  22 passed (22)
   Start at  09:25:16
   Duration  6.36s (transform 2.60s, setup 972ms, import 2.16s, tests 2.83s, environment 0ms)

[test] passed 1 Vitest shard in 13.81s

Assertions:

  • PASS expect_output: Test Files

How this fits together

Cron automations request exec approval through the Gateway; an allow-always decision can create a standing grant for one exact operation. The Gateway revalidates that grant before execution, while the CLI and Control UI expose its status and revocation.

flowchart LR
  A[Cron automation] --> B[Gateway approval]
  B --> C[Standing grant record]
  C --> D[Spawn-boundary validation]
  D --> E[Command execution]
  C --> F[CLI and Control UI ledger]
  F --> G[Revocation request]
Loading

Decision needed

Question Recommendation
Should a pending approval’s displayed grant term be frozen when the card is created, or should a later policy change refresh the displayed term before the operator can authorize it? Freeze the disclosed term: Persist the card’s configured expiry term with the pending approval and mint exactly that term unless a visible operator-selected override replaces it.

Why: The current implementation combines request-time disclosure with resolution-time policy evaluation, so neither the promised term nor policy-change semantics are coherent.

Before merge

  • Repair legacy grant tables before startup validation (P1) - A database created by the prior standing-grant feature has expires_at_ms INTEGER NOT NULL, but the cold-open path validates the present table against the new nullable canonical definition before any mint can reach this rebuild. The Gateway therefore fails to start after upgrade. Recognize and rebuild this disposable legacy table in shared startup repair, then cover close/reopen before minting.
  • Preserve the grant expiry through the generic resolver (P1) - approval.resolve validates grantExpiresInDays, but resolveApprovalDecisionParams drops it, so this branch’s later resolveParams?.grantExpiresInDays check is always undefined. The documented CLI route therefore ignores --expires-in-days and may mint the configured default instead. Return the validated value and carry it to the manager.
  • Do not promise a stale lifetime on the approval card (P1) - This scope displays the expiry from configuration at request time, while the manager rereads configuration at resolution. Changing the policy while a card is pending can turn a displayed ten-day grant into an indefinite or differently bounded one. Freeze the disclosed term or refresh and re-confirm the exact term before authorization.
  • Clear ledger state when its Gateway source changes (P2) - The reset invalidates requests and clears history but leaves grants and grantsError intact. If the replacement Gateway’s history request fails, the page keeps rendering authority from the previous Gateway and offers its revoke buttons against the new client. Reset ledger state with the source generation and add a swap/failure regression.
  • Honor the revoke outcome before updating the ledger (P2) - The server intentionally returns revoked, already-revoked, or not-found, but this always marks the local row revoked after a resolved RPC. A stale row can therefore claim a successful revocation when no active grant was changed. Branch on the result and reload or show an error for a missing row.
  • Reject partial numeric grant CLI values (P2) - Number.parseInt accepts inputs such as 10junk and 10.5 as ten despite the whole-number contract; the list limit repeats the same pattern. Validate the complete decimal token and bounds before calling either Gateway method.
  • Resolve security concern: Preserve the operator-selected expiry term - The generic approval path validates but discards the expiry override, so the documented CLI request can mint a different durable grant lifetime, including the indefinite default.
  • Resolve security concern: Keep approval disclosure synchronized with minting - Request-time expiry disclosure and resolution-time policy lookup can diverge after a configuration change, leaving the operator to approve a different authority term.
  • Resolve merge risk (P1) - A Gateway opening a database created by the previously merged standing-grant feature can fail schema validation before this PR’s rebuild runs.
  • Resolve merge risk (P1) - The documented CLI expiry override can silently mint the configured term instead, including an indefinite grant, and an approval card can disclose a different term than the one ultimately granted.
  • Resolve merge risk (P1) - The Control UI can retain a prior Gateway’s ledger and report revocation even when the server returned not-found or already-revoked.
  • Improve patch quality - Resolve the security review concern or explain why the changed path is safe.
  • Improve patch quality - Address the highest-priority review finding and re-run the changed-surface validation.

Findings

  • [P1] Repair legacy grant tables before startup validation — src/gateway/operator-approval-standing-grants.ts:122-140
  • [P1] Preserve the grant expiry through the generic resolver — src/gateway/server-methods/approval.ts:487-495
  • [P1] Do not promise a stale lifetime on the approval card — src/gateway/server-methods/exec-approval.ts:354-367
  • [high] Preserve the operator-selected expiry term — src/gateway/server-methods/approval.ts:490
  • [medium] Keep approval disclosure synchronized with minting — src/gateway/server-methods/exec-approval.ts:354
Agent review details

Security

Needs attention: The branch can mint durable authority with a term different from the operator’s disclosed or requested term.

PR surface

Source +816, Tests +347, Docs +73, Generated 0, Other +158. Total +1394 across 44 files.

View PR surface stats
Area Files Added Removed Net
Source 28 836 20 +816
Tests 8 366 19 +347
Docs 4 97 24 +73
Config 0 0 0 0
Generated 1 1 1 0
Other 3 162 4 +158
Total 44 1462 68 +1394

Review metrics

Metric Value Why it matters
Production versus validation delta production +998/-24; tests +366/-19; docs +97/-24; generated +1/-1 The substantial feature growth includes persistent authority, startup compatibility, and operator-facing paths, so the upgrade boundary needs complete proof.
New public control surface 1 config key, 1 CLI expiry option, 2 Gateway methods These additions create durable operator and protocol contracts that must agree on expiry semantics.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/operator-approval-standing-grants.ts, serialized state: src/state/openclaw-state-db.generated.d.ts, unknown-data-model-change: packages/gateway-protocol/src/schema/exec-approvals.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair upgrade and consent invariants (recommended)
    Move the legacy-table rebuild into startup repair, propagate the selected expiry through both resolver paths, and add cold-reopen plus term/outcome regressions before merge.
  2. Pause for expiry-policy direction
    Pause the PR if maintainers want policy changes to affect pending approvals, then implement an explicit refreshed-consent flow.

Technical review

Best possible solution:

Repair the shared cold-open migration path, preserve one explicit grant term from operator disclosure through resolution, and make CLI/UI outcomes reflect the authoritative Gateway response.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: a current database containing the prior mandatory-expiry grant table fails the cold-open schema assertion before the first-use rebuild; the documented CLI override is also discarded by the generic resolver.

Is this the best way to solve the issue?

No. The operator ledger is useful, but startup repair and one coherent, consent-accurate expiry path are required before this is a safe solution.

Full review comments:

  • [P1] Repair legacy grant tables before startup validation — src/gateway/operator-approval-standing-grants.ts:122-140
    A database created by the prior standing-grant feature has expires_at_ms INTEGER NOT NULL, but the cold-open path validates the present table against the new nullable canonical definition before any mint can reach this rebuild. The Gateway therefore fails to start after upgrade. Recognize and rebuild this disposable legacy table in shared startup repair, then cover close/reopen before minting.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.
  • [P1] Preserve the grant expiry through the generic resolver — src/gateway/server-methods/approval.ts:487-495
    approval.resolve validates grantExpiresInDays, but resolveApprovalDecisionParams drops it, so this branch’s later resolveParams?.grantExpiresInDays check is always undefined. The documented CLI route therefore ignores --expires-in-days and may mint the configured default instead. Return the validated value and carry it to the manager.
    Confidence: 0.99
  • [P1] Do not promise a stale lifetime on the approval card — src/gateway/server-methods/exec-approval.ts:354-367
    This scope displays the expiry from configuration at request time, while the manager rereads configuration at resolution. Changing the policy while a card is pending can turn a displayed ten-day grant into an indefinite or differently bounded one. Freeze the disclosed term or refresh and re-confirm the exact term before authorization.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Clear ledger state when its Gateway source changes — ui/src/pages/approvals/approvals-page.ts:224-234
    The reset invalidates requests and clears history but leaves grants and grantsError intact. If the replacement Gateway’s history request fails, the page keeps rendering authority from the previous Gateway and offers its revoke buttons against the new client. Reset ledger state with the source generation and add a swap/failure regression.
    Confidence: 0.97
  • [P2] Honor the revoke outcome before updating the ledger — ui/src/pages/approvals/approvals-page.ts:358-363
    The server intentionally returns revoked, already-revoked, or not-found, but this always marks the local row revoked after a resolved RPC. A stale row can therefore claim a successful revocation when no active grant was changed. Branch on the result and reload or show an error for a missing row.
    Confidence: 0.98
  • [P2] Reject partial numeric grant CLI values — src/cli/exec-approvals-cli.ts:751-757
    Number.parseInt accepts inputs such as 10junk and 10.5 as ten despite the whole-number contract; the list limit repeats the same pattern. Validate the complete decimal token and bounds before calling either Gateway method.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0e1afb2e8c16.

Labels

Label changes:

  • add P1: The proposed change can prevent Gateway startup on existing standing-grant databases and can grant a different lifetime than the operator authorized.
  • remove P2: Current review triage priority is P1, so this older priority label is no longer current.

Label justifications:

  • P1: The proposed change can prevent Gateway startup on existing standing-grant databases and can grant a different lifetime than the operator authorized.
  • merge-risk: 🚨 compatibility: Changing a previously merged SQLite table from mandatory to nullable expiry is not upgrade-safe with the present startup validator.
  • merge-risk: 🚨 security-boundary: The approval disclosure and documented CLI override can produce durable authority with a lifetime different from the operator’s requested term.
  • merge-risk: 🚨 availability: An existing database with the earlier table definition can fail Gateway startup before the lazy rebuild executes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): ClawSweeper live verification passed on the reviewed terminal surface.
  • proof: sufficient: Contributor real behavior proof is sufficient. ClawSweeper live verification passed on the reviewed terminal surface.

Evidence

Security concerns:

  • [high] Preserve the operator-selected expiry term — src/gateway/server-methods/approval.ts:490
    The generic approval path validates but discards the expiry override, so the documented CLI request can mint a different durable grant lifetime, including the indefinite default.
    Confidence: 0.99
  • [medium] Keep approval disclosure synchronized with minting — src/gateway/server-methods/exec-approval.ts:354
    Request-time expiry disclosure and resolution-time policy lookup can diverge after a configuration change, leaving the operator to approve a different authority term.
    Confidence: 0.98

What I checked:

Likely related people:

  • steipete: History attributes the original scoped-standing-grant implementation, approval-scope work, and every commit on this feature branch to steipete. (role: standing-grant feature owner and recent area contributor; confidence: high; commits: 473b4f19e399, 99a02bf115cf, 4d83fbc6e523; files: src/gateway/operator-approval-standing-grants.ts, src/gateway/server-methods/approval.ts, ui/src/pages/approvals/approvals-page.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-28T07:54:41.183Z sha 109670ef0719712da2ed089c825d1842b4193691 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T08:11:35.643Z sha 960451a :: needs changes before merge. :: [P2] Escape the stored revoker label before rendering the CLI ledger
  • reviewed 2026-08-28T08:23:24.662Z sha 288b72f :: found issues before merge. :: [P1] Migrate the mandatory-expiry table before startup validation | [P1] Do not display a grant term that resolution can replace | [P2] Reset and generation-guard grants when the Gateway changes | [P2] Handle the revoke outcome before changing the local ledger | [P2] Reject partial numeric values for grant expiry and list limits

…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.
…r 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.
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.
#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.
…ted 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.
…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.
@steipete
steipete force-pushed the steipete/grants-surface branch from f3141e9 to 960451a Compare August 28, 2026 08:04
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Aug 28, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
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.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 28, 2026
…s 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.
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the review findings on the new head:

  • Escape the stored revoker label (P2 / security) — fixed. renderTerminalSafeTable already strips C0/C1 controls from every cell (packages/terminal-core/src/table.ts → sanitizeTerminalText), so raw escape sequences could not reach the terminal even before this change — but silent stripping is weaker than the file's own convention of visible \u{...} escapes. The ledger now routes revokedBy, the automation label, and the agent-authored command through the existing escapeApprovalTextForTerminal helper, matching the pending-approvals table. Regression test added (src/cli/exec-approvals-cli.pending-resolve.test.ts "escapes hostile grant fields visibly in the standing-grant ledger"); verified it fails pre-fix (fields render control-stripped instead of visibly escaped) and passes post-fix.
  • Durable-authority policy (P1 merge risk) — maintainer-decided, not an open question: the until-revoked default was chosen explicitly because shipped "Always allow" semantics are already indefinite, so changing the default would silently alter what existing operators believe they granted. tools.exec.grantExpiryDays gives enterprises time-bounded defaults for new grants only; terms freeze at mint. The prior fixed-30-day shape never shipped (the grants table exists on no release tag), so the documented fail-closed lazy rebuild is upgrade-safe: pre-release dev databases rebuild the table on first mint, and there is nothing shipped to migrate. This is recorded in the PR body and docs/tools/exec-approvals.md.
  • Also folded in this push: the two cross-lane inventory tests that first fail on full runs (core-descriptors.since.test.ts release-train roster now lists exec.approval.grants.list/.revoke; root-command-descriptions.test.ts classifies the approvals grants container), and a stubGrants typing fix in approvals-page.test.ts.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. labels Aug 28, 2026
@steipete
steipete merged commit de12e0a into main Aug 28, 2026
257 checks passed
@steipete
steipete deleted the steipete/grants-surface branch August 28, 2026 09:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Aug 28, 2026
51 UI changes landed after the #131602 baseline, each inside the 512 B
per-change tolerance but roughly 980 B cumulatively, so main was failing its own
budget gate before this branch: its parent commit measures 347441 B against a
347037 B enforcement limit.

This is the ratchet accumulating as designed, not a single regression, so the
baseline is re-recorded rather than a change reverted. Maintainer-approved.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…terms (openclaw#131602)

* feat(approvals): standing-grant ledger, revocation, and configurable terms

Completes the operator half of cron standing grants (openclaw#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

openclaw#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: openclaw#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: web-ui App: web-ui cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant