Repository navigation
feat(approvals): standing-grant ledger, revocation, and configurable terms - #131602
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
5ac2414 to
0e716ed
Compare
|
Codex review: found issues before merge. Reviewed August 28, 2026, 5:24 AM ET / 09:24 UTC. ClawSweeper reviewWhat this changesAdds 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 Regression provenancePossible 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 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherCron 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]
Decision needed
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
Findings
Agent review detailsSecurityNeeds attention: The branch can mint durable authority with a term different from the operator’s disclosed or requested term. PR surfaceSource +816, Tests +347, Docs +73, Generated 0, Other +158. Total +1394 across 44 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0e1afb2e8c16. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
…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.
f3141e9 to
960451a
Compare
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.
…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.
|
Addressed the review findings on the new head:
|
|
Merged via squash.
|
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.
…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.
What Problem This Solves
Standing grants (#129526) shipped as durable execution authority with no operator surface:
revoked_at_ms/revoked_byexisted 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:
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.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 (grantExpiresInDaysonapproval.resolve/exec.approval.resolve,--expires-in-dayson 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_msgoes 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.standing-grantApprovalScope (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.unknown methoderrors only. A new parity test fails whenGATEWAY_AUX_METHODSand 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.grantExpiryDaysand 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, andautomation/cron-jobs.Evidence
Live end-to-end on a hermetic gateway (isolated state dir, port 19791, Haiku,
id -unautomation every minute, real Control UI):expires_at_ms = NULL; the grant then ran 62 consecutive promptless occurrences (spawn-boundary consume, zero new approval rows) over ~an hour.revoked_by = openclaw-control-ui; the next occurrence parked a fresh approval card (revoked authority fails closed live).grantExpiryDays: 10, the next card's scope fact carriedexpiresInDays: 10, and resolving via the UI's "Always allow here" stamped a grant with exactlyexpires − created = 10.0 days.approvals grants revoke→ next occurrence prompted;approvals resolve <id> allow-always --expires-in-days 99stamped exactly 99.0 days;approvals grants listrenders the ledger with "expires in 99d".check:changedfully green; Codex autoreview clean (0.97).Approval card with the standing-grant scope line (10-day config default active):
Standing grants ledger on the approvals settings page:
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.