Repository navigation
feat(approvals): scoped standing grants make recurring cron automations approvable once - #129526
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 25, 2026, 6:03 PM ET / 22:03 UTC. ClawSweeper reviewWhat this changesAdds expiring, job-scoped standing grants for gateway-host cron exec approvals, routes cron cards to approval clients, and waits for the operator decision inline. Merge readiness⛔ Blocked until stronger real behavior proof is added - 9 items remain Keep this PR open: its new standing-grant authority can be minted from a caller-supplied cron run ID rather than an exact live cron runtime, and its docs still advertise the TUI as an exec-approval surface when it is plugin-only. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherCron runs request command approval through the Gateway; an allow-always decision now creates a durable grant for the same job and operation. The Gateway rechecks that grant immediately before starting the command process. flowchart LR
A[Cron run] --> B[Trusted run identity]
B --> C[Approval request]
C --> D[Operator decision]
D --> E[Scoped grant store]
E --> F[Final grant revalidation]
F --> G[Command process]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The PR introduces a concrete durable-execution authority forgery path through caller-controlled cron provenance. PR surfaceSource +602, Tests +882, Docs +26, Generated +16, Other +7. Total +1533 across 28 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Bind cron provenance, minting, and consumption to the validated exact operational run instance; reject raw caller-provided run IDs, prove allowed and nearest-forbidden final effects, and document only real exec approval surfaces. Do we have a high-confidence way to reproduce the issue? Yes, from source: an operator.approvals client can submit a matching raw runId and agentId, causing the new handler to derive cron provenance without an internal runtime identity. Is this the best way to solve the issue? No: the scoped-grant design is viable, but provenance must come from the exact validated runtime instance rather than a caller-supplied reusable identifier. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c3eca4f50813. 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 (2 earlier review cycles)
|
When an operator resolves allow-always for an approval raised by a cron
job's isolated run, the Gateway now mints a scoped standing grant in the
same SQLite transaction that resolves the approval, instead of writing an
unbounded command digest into the JSON allowlist. Subsequent occurrences
of that job execute the exact approved operation (command text, cwd, env
hash) without prompting while the grant revalidates against authoritative
rows: 30-day expiry, revocation, the cron job still existing with the same
config revision, and the minting approval row still holding allow-always
all fail closed back to the normal prompt. Non-cron allow-always behavior
is unchanged.
- New first-use lazy STRICT table operator_approval_standing_grants in the
shared state DB (declared canonically, no schema-version bump; older and
downgraded readers stay valid without it).
- The cron run owner records run -> {agent, job, config revision} in a
process-local registry at run start; exec.approval.request stamps the
cron source and exact operation binding onto the approval at creation,
so nothing is ever inferred from session keys or run ids.
- The gateway exec host consults grants only when policy would prompt;
ask=always, security=deny, mutable file operands, heredoc, strict
inline-eval, and audit-suppression approvals keep prompting. Grant use
updates last_used_at_ms/use_count and emits the exec approval security
event with the grant and minting approval as lineage.
- Abort-wins guard: a run with an abort tombstone never mints.
…wait inline The standing-grant mint path was unreachable end-to-end: #128031 made cron approval requests register with delivery fully suppressed, so the shared owner expired them as no-approval-route within milliseconds, and even a delivered card would have died seconds later when the isolated run finalized on the approval-pending handoff and authority-close cancelled the parked approval. Cron approval requests now carry deliverToApprovalClientsOnly: the shared delivery owner broadcasts them to connected websocket approval clients (Control UI, TUI) but skips internal chat approval runtimes, forwarder/iOS delivery, and turn-source routes, so the per-occurrence chat spam #128031 removed stays removed. With no approval client connected, the request still expires no-route into the existing headless denial. The gateway exec host additionally waits inline for cron-triggered approvals (the same treatment native chat channels got in #93918), keeping the isolated run and its delegated authority alive for the full approval window; cron jobs are single-flight, so at most one card per job is pending at a time and allow-always ends the recurrence by minting the standing grant. Live-proven on a hermetic gateway: card delivered with ~30-minute window, run waited 72s for the operator click, allow-always executed the occurrence and minted the grant with no JSON allowlist digest, the next occurrence ran promptless (use_count 1, no new approval row), and editing the job failed closed back to a fresh prompt.
…ode cron headless Review findings from ClawSweeper on #129526: - Grant authority is now recorded only at the final effect. The consult path validates without recording a use and returns a revalidateBeforeExecution closure (the mutable-file-binding seam) that consumes the grant immediately before runExecProcess; any invalidation during awaited pre-spawn work (job edit/delete, revocation, parent approval reversal) denies with next-step text instead of executing on stale authority. Regression proves consult leaves use_count at 0 and a reversed minting approval denies at the boundary. - Cron approval-client delivery is scoped to host=gateway. Node-host cron cannot mint or consume grants yet, so it keeps the fully suppressed headless policy from #128031 instead of raising cards whose allow-always could not stick; node-host grant support stays a named follow-up.
57b5b8b to
2358ec9
Compare
|
Both P1 findings were real and are addressed on the new head; thank you — the final-effect gap in particular is exactly the closure-bound-authority invariant this repo documents. P1 — revalidate at the spawn boundary (fixed). Grant authority is now recorded only at the final effect: the consult path calls a new P1 — node-host cron cards (fixed by scoping). Cron approval requests now set Decision item (durable grant policy). This feature was explicitly commissioned by the maintainer (recurring automations approvable once), which is the product acceptance this PR records. Operator revocation exists today through three proven paths: editing or deleting the job invalidates the grant (live-proven, revision recompute against the authoritative Live re-proof on the fixed build (head |
Five explicit vi.mock factories for current-plugin-metadata-snapshot.js exported only getCurrentPluginMetadataSnapshot. Under isolate:false shard composition the incomplete mock can bleed into siblings that import the real module — model-resolution-consistency.test.ts failed on CI with 'No withPluginMetadataSnapshotScope export is defined on the mock'. Spread importOriginal so every binding prod touches stays exported, per the repo mock-factory rule; only the snapshot getter stays overridden.
…uild/ scripts/install-swift-tools.sh installs pinned Swift tools into .build/swift-tools per the lint-swift.sh remediation hint; the 36MB binary must never ride a commit. Remove it and ignore the directory.
Security-sensitive changes notedThis PR includes security-sensitive file changes. The guard is informational because the PR author is a repository admin or a member of
Changed files:
Security review is still recommended before merge when the change is intentional. |
…t mocks The agents-embedded shard still failed after completing five factories: ~20 more test files across the repo mock current-plugin-metadata-snapshot with incomplete explicit factories, and under isolate:false composition any of them can strip withPluginMetadataSnapshotScope from this file's imports. Give the victim a file-local identity mock (importOriginal spread) that always wins, and revert the static-catalog factory edit that tipped that grandfathered file over the max-lines cap — the repo-wide factory completion belongs to a dedicated sweep.
|
Merged via squash.
|
Explicit vi.mock factories for src/plugins/current-plugin-metadata-snapshot.ts exported only getCurrentPluginMetadataSnapshot; under isolate:false shard composition the incomplete mocks leaked into sibling files (CI incident: model-resolution-consistency.test.ts lost withPluginMetadataSnapshotScope, stopgapped in #129526). Convert all 27 incomplete factories to the importOriginal-spread form, overriding only the stubbed binding, and remove the now-unneeded self-defense identity mock. model.static-catalog.test.ts sat at the 1000-counted-line max-lines cap, so its canonicalizeManifestModelCatalogProviderAlias block moved to a new model.static-catalog.provider-alias.test.ts sibling (picked up by the agents-embedded lane glob) instead of adding a suppression.
Explicit vi.mock factories for src/plugins/current-plugin-metadata-snapshot.ts exported only getCurrentPluginMetadataSnapshot; under isolate:false shard composition the incomplete mocks leaked into sibling files (CI incident: model-resolution-consistency.test.ts lost withPluginMetadataSnapshotScope, stopgapped in #129526). Convert all 27 incomplete factories to the importOriginal-spread form, overriding only the stubbed binding, and remove the now-unneeded self-defense identity mock. model.static-catalog.test.ts sat at the 1000-counted-line max-lines cap, so its canonicalizeManifestModelCatalogProviderAlias block moved to a new model.static-catalog.provider-alias.test.ts sibling (picked up by the agents-embedded lane glob) instead of adding a suppression.
…ns approvable once (openclaw#129526) * feat(approvals): mint scoped standing grants for cron allow-always When an operator resolves allow-always for an approval raised by a cron job's isolated run, the Gateway now mints a scoped standing grant in the same SQLite transaction that resolves the approval, instead of writing an unbounded command digest into the JSON allowlist. Subsequent occurrences of that job execute the exact approved operation (command text, cwd, env hash) without prompting while the grant revalidates against authoritative rows: 30-day expiry, revocation, the cron job still existing with the same config revision, and the minting approval row still holding allow-always all fail closed back to the normal prompt. Non-cron allow-always behavior is unchanged. - New first-use lazy STRICT table operator_approval_standing_grants in the shared state DB (declared canonically, no schema-version bump; older and downgraded readers stay valid without it). - The cron run owner records run -> {agent, job, config revision} in a process-local registry at run start; exec.approval.request stamps the cron source and exact operation binding onto the approval at creation, so nothing is ever inferred from session keys or run ids. - The gateway exec host consults grants only when policy would prompt; ask=always, security=deny, mutable file operands, heredoc, strict inline-eval, and audit-suppression approvals keep prompting. Grant use updates last_used_at_ms/use_count and emits the exec approval security event with the grant and minting approval as lineage. - Abort-wins guard: a run with an abort tombstone never mints. * feat(approvals): deliver cron exec approvals to approval clients and wait inline The standing-grant mint path was unreachable end-to-end: openclaw#128031 made cron approval requests register with delivery fully suppressed, so the shared owner expired them as no-approval-route within milliseconds, and even a delivered card would have died seconds later when the isolated run finalized on the approval-pending handoff and authority-close cancelled the parked approval. Cron approval requests now carry deliverToApprovalClientsOnly: the shared delivery owner broadcasts them to connected websocket approval clients (Control UI, TUI) but skips internal chat approval runtimes, forwarder/iOS delivery, and turn-source routes, so the per-occurrence chat spam openclaw#128031 removed stays removed. With no approval client connected, the request still expires no-route into the existing headless denial. The gateway exec host additionally waits inline for cron-triggered approvals (the same treatment native chat channels got in openclaw#93918), keeping the isolated run and its delegated authority alive for the full approval window; cron jobs are single-flight, so at most one card per job is pending at a time and allow-always ends the recurrence by minting the standing grant. Live-proven on a hermetic gateway: card delivered with ~30-minute window, run waited 72s for the operator click, allow-always executed the occurrence and minted the grant with no JSON allowlist digest, the next occurrence ran promptless (use_count 1, no new approval row), and editing the job failed closed back to a fresh prompt. * chore(protocol): regenerate Swift models for deliverToApprovalClientsOnly * fix(approvals): consume standing grants at the spawn boundary; keep node cron headless Review findings from ClawSweeper on openclaw#129526: - Grant authority is now recorded only at the final effect. The consult path validates without recording a use and returns a revalidateBeforeExecution closure (the mutable-file-binding seam) that consumes the grant immediately before runExecProcess; any invalidation during awaited pre-spawn work (job edit/delete, revocation, parent approval reversal) denies with next-step text instead of executing on stale authority. Regression proves consult leaves use_count at 0 and a reversed minting approval denies at the boundary. - Cron approval-client delivery is scoped to host=gateway. Node-host cron cannot mint or consume grants yet, so it keeps the fully suppressed headless policy from openclaw#128031 instead of raising cards whose allow-always could not stick; node-host grant support stays a named follow-up. * test(agents): complete plugin-metadata-snapshot mock factories Five explicit vi.mock factories for current-plugin-metadata-snapshot.js exported only getCurrentPluginMetadataSnapshot. Under isolate:false shard composition the incomplete mock can bleed into siblings that import the real module — model-resolution-consistency.test.ts failed on CI with 'No withPluginMetadataSnapshotScope export is defined on the mock'. Spread importOriginal so every binding prod touches stays exported, per the repo mock-factory rule; only the snapshot getter stays overridden. * chore: drop accidentally committed pinned swiftlint binary; ignore .build/ scripts/install-swift-tools.sh installs pinned Swift tools into .build/swift-tools per the lint-swift.sh remediation hint; the 36MB binary must never ride a commit. Remove it and ignore the directory. * test(agents): shield model-resolution-consistency from leaked snapshot mocks The agents-embedded shard still failed after completing five factories: ~20 more test files across the repo mock current-plugin-metadata-snapshot with incomplete explicit factories, and under isolate:false composition any of them can strip withPluginMetadataSnapshotScope from this file's imports. Give the victim a file-local identity mock (importOriginal spread) that always wins, and revert the static-catalog factory edit that tipped that grandfathered file over the max-lines cap — the repo-wide factory completion belongs to a dedicated sweep.
…law#129791) Explicit vi.mock factories for src/plugins/current-plugin-metadata-snapshot.ts exported only getCurrentPluginMetadataSnapshot; under isolate:false shard composition the incomplete mocks leaked into sibling files (CI incident: model-resolution-consistency.test.ts lost withPluginMetadataSnapshotScope, stopgapped in openclaw#129526). Convert all 27 incomplete factories to the importOriginal-spread form, overriding only the stubbed binding, and remove the now-unneeded self-defense identity mock. model.static-catalog.test.ts sat at the 1000-counted-line max-lines cap, so its canonicalizeManifestModelCatalogProviderAlias block moved to a new model.static-catalog.provider-alias.test.ts sibling (picked up by the agents-embedded lane glob) instead of adding a suppression.
…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.
…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.
…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
Recurring cron jobs whose command needs exec approval are unusable today: every occurrence is auto-denied. #128031 suppressed cron approval delivery entirely (cards spammed chat on every occurrence and could not be usefully answered), so a scheduled command under
askpolicy dead-ends with "Automation runs cannot wait for interactive exec approval" forever, and the only fix is hand-editing the allowlist. Resolving a cron approval with Allow always also used to write an unbounded generated command digest into the JSON allowlist — a permanent, job-independent grant that survives job edits and deletion.Why This Change Was Made
This PR makes recurring automation approvable exactly once, with tightly scoped durable authority:
operator_approval_standing_grantsfirst-use lazy STRICT table in the shared state DB, no schema-version bump): when an operator resolves Allow always on an approval raised by a cron job's isolated run, the Gateway mints a grant bound to that exact agent, cron job, job config revision, and operation (command text, cwd, env hash) inside the same SQLite transaction that resolves the approval — instead of writing a JSON allowlist digest. Later occurrences of the same job execute that exact operation without prompting. Every use revalidates against authoritative rows and fails closed: 30-day expiry, revocation, job edited/deleted (config revision recompute against the livecron_jobsrow), or the minting approval row no longer allow-always all fall back to a normal prompt. Mutable file operands, heredocs, strict inline eval, and audit-suppression approvals keep prompting per occurrence. An abort tombstone on the run blocks minting. Non-cron approvals are unchanged.deliverToApprovalClientsOnly— the shared delivery owner broadcasts them to connected websocket approval clients (Control UI, TUI) but skips chat approval runtimes, forwarder/iOS delivery, and turn-source routes, so the per-occurrence chat spam fix: stop cron exec approval spam #128031 removed stays removed. With no approval client connected, the request still expires no-route into the existing headless denial with the same remediation text.approval-pendinghandoff and authority-close cancels the parked approval seconds later, leaving a ~3-second answer window. Cron jobs are single-flight, so at most one card per job is pending at a time, and the card carries the full approval window (default 30 minutes).The cron fact is recorded where it happens: the cron run owner registers run → {agent, job, config revision} in a process-local registry at run start, and
exec.approval.requeststamps the cron source and operation binding onto the approval at creation. Nothing is inferred from session keys or run ids, and the parentoperator_approvalsrow remains the sole authorization owner (grants are derivative, revalidated correlation).User Impact
An operator with the Control UI (or TUI) open sees one inbox card per scheduled job that needs approval — "Automation:
$ <command>" with Allow once / Always allow / Deny. Always allow runs the current occurrence and permanently (30 days, revalidated) unblocks that exact job operation; the card never comes back until the job changes. Allow once runs just this occurrence. Editing the job brings the prompt back. Headless gateways behave exactly as before. The JSON allowlist no longer accumulates generated command digests from automation approvals.Evidence
Live-proven end to end on a hermetic dev gateway (isolated
OPENCLAW_STATE_DIR, own port, Anthropic Haiku, cron job runningid -unevery minute undertools.exec.mode=allowlist, real Control UI attached in a browser):exec.approval.waitDecisionresolved after 72.6 s when the operator clicked).steipete, exit 0, in the session transcript), and grant8953a518…was minted in the resolving transaction, bound to approval5e24d5a7…, agentmain, and the job id.exec_approvals_configstill has"agents": {}— no generated digest.use_count0→1, zero new approval rows.openclaw cron edit … --message '… # revised'→ next occurrence did not use the grant (use_countstill 1) and parked a fresh pending approval — fail-closed on config revision proven live.denied/cancelledwithin 1 ms–3.3 s; no operator could ever answer.Inbox card (post-edit reprompt, showing the revised command and full window):
Focused suites green:
operator-approval-standing-grants.test.ts(14),bash-tools.exec-host-gateway.test.ts+bash-tools.exec.approval-id.test.ts(141),approval-shared.test.ts(41 incl. 2 new clients-only cases),bash-tools.exec-host-node.test.ts;check:changedclean; fullpnpm buildclean.Production LOC: grants feature +495 (new capability: durable scoped-grant store, mint/consume funnels, cron source registry); delivery/inline-wait fix +38/−15. Follow-ups (not in this PR): grants list/revoke RPC + UI surface, node-host exec grant coverage, doctor migration retiring legacy cron-generated allowlist digests, per-use decision-receipt projection.