Repository navigation
refactor(cron): consume standing grants through the Gateway owner (cron 3/3) - #164864
Conversation
Bind prepared effects to exact receipt facts and the existing Gateway-owned FIFO. Keep repeatable assertions separate from one-shot native initiation, and release exclusion before awaiting the provider response. Allow a use to borrow its own gate for consumption while preserving native publication and settlement. Closing retires unused effects and joins accepted borrowed persistence independently of scheduler cancellation. This additive interface supports the message and standing-grant cutovers; it does not activate either consumer or change schema, retention, or policy.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 3:45 PM ET / 19:45 UTC (Revision 21). ClawSweeper reviewWhat this changesThe PR moves scheduled-command grant checks into database workers and keeps Gateway-held authorization active through native process startup. Merge readiness✅ Ready for maintainer review This remains useful, distinct work. The previously required upgrade qualification is now supplied for the unchanged pinned head, and this review found no remaining actionable correctness or proof blocker. Priority: P2 Review scores
Verification
How this fits togetherCron schedules agent runs that can execute commands under previously approved standing grants. The Gateway coordinates receipt, approval, and policy authority before the process supervisor launches those commands. flowchart TD
A[Scheduled agent run] --> B[Gateway receipt owner]
B --> C[Approval read worker]
C --> D[Atomic grant consumption]
D --> E[Current receipt and policy checks]
E --> F[Native process startup]
E --> G[Refusal without command I/O]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +939, Tests +1310, Docs +21, Other +7. Total +2277 across 76 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Preserve one-shot accounting and current authorization across every native launch transport while retaining released PTY compatibility. Do we have a high-confidence way to reproduce the issue? Yes, from source: fetched main releases consumption custody before deferred native launch. The supplied negative controls and native boundary runs support that mechanism; this read-only review did not execute it. Is this the best way to solve the issue? Yes. The patch extends the existing receipt, approval, and process owners, preserves accounting and stored formats, and supplies authority and upgrade evidence for the changed boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a0c1b065b5b2. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (20 earlier review cycles; latest 8 shown)
|
Keep ordinary queued spawn and execa cancellation on their native settlement path. Restrict the pre-launch cancellation refusal to guarded preparations. Update the PTY and relay expectations without weakening credential checks. Exercise standing-grant and receipt authority through the real exec runtime, supervisor, and native file effects. Cover single consumption, replay refusal, revoked grants, stale receipts, and tightened policy. Retain the released PTY call signature with a type-only Plugin SDK compatibility check. Validation: 82 tests across eight files; 41 process tests rerun for the final guard; four targeted type graphs; scoped lint, formatting and P2 review clean.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge main after cron1 landed, preserving captured caller scope, accepted-write settlement, expiry checks, and Gateway close behavior. Reject logical receipt drainage when native initiation remains uncertain while retaining physical database custody and sealed admission. Add isolated native proof and preserve save/consume close coverage. Validation: 314 unique selected tests across 21 files, core and six test type graphs, scoped lint and formatting, and clean P2 autoreview. Cron2, final SDK reporting, exact-head CI and published-driver update proof remain landing gates.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merge main after cron2 landed. Keep message and standing-grant authority on the same receipt observation, retain cross-owner persistence through settlement, and preserve native acknowledgement failure custody. Use the dependency-free refusal error owner and combine message queue retirement with save and consume Gateway-close proof. No grant eligibility, receipt accounting, schema, retention, or released callable change. Validation: 239 tests across 16 files, seven type graphs, scoped lint and formatting, and clean P2 autoreview. Final-head SDK reporting, Windows CI, and the published-driver update cell remain landing gates.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Incorporate main 9da00b0, including d1fc40d which aligns the embedded admission test owner with its infra routing. The merge is mechanical and preserves the reviewed cron consume-to-spawn implementation. Validation: 344 tests across seven focused files, core and state test type graphs, diff checks, and fresh P2 review passed. Prior SDK, update and Windows evidence remains historical pending the new exact-head qualifications.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Incorporate main 5f497e7, including b7645dd which repairs the inherited model-picker browser assertions after the quiet-send change. The merge is mechanical; cron, process, policy and CLI implementation files remain unchanged. Validation: all 295 routing cases passed; diff checks and fresh P2 review passed for the exact staged tree. Preserve prior-head runtime proof and refresh final-head CI, SDK and published-driver qualification after publication.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge main 2be4d4f, including the schema-freshness repair in 8f7e75a and the shutdown/reindex fixture repair in 83f4c29. The merge is mechanical and changes no cron3 production file; the previous three-root CI exception is now historical. Validation: fresh P2 review and diff checks passed for the exact staged tree. Main forget-settlement proof now passes all four cases. Reuse unchanged native grant and process proof while qualifying the replacement head through CI, SDK comparison and the published-driver update cell.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…on 3/3) (openclaw#164864) * refactor(cron): publish receipt authority from the Gateway owner * fix(cron): preserve SDK admission factory contracts * fix(cron): settle receipt authority before releasing close custody * refactor(cron): add held receipt authority uses Bind prepared effects to exact receipt facts and the existing Gateway-owned FIFO. Keep repeatable assertions separate from one-shot native initiation, and release exclusion before awaiting the provider response. Allow a use to borrow its own gate for consumption while preserving native publication and settlement. Closing retires unused effects and joins accepted borrowed persistence independently of scheduler cancellation. This additive interface supports the message and standing-grant cutovers; it does not activate either consumer or change schema, retention, or policy. * refactor(cron): consume standing grants through Gateway owner * fix(cron): preserve broker cancellation and prove native grant execution Keep ordinary queued spawn and execa cancellation on their native settlement path. Restrict the pre-launch cancellation refusal to guarded preparations. Update the PTY and relay expectations without weakening credential checks. Exercise standing-grant and receipt authority through the real exec runtime, supervisor, and native file effects. Cover single consumption, replay refusal, revoked grants, stale receipts, and tightened policy. Retain the released PTY call signature with a type-only Plugin SDK compatibility check. Validation: 82 tests across eight files; 41 process tests rerun for the final guard; four targeted type graphs; scoped lint, formatting and P2 review clean.
What Problem This Solves
Cron standing-grant lookup and consumption still ran SQLite on the Gateway thread. A committed consume did not retain live authority through child, PTY, and relay preparation, leaving a consume-to-spawn revocation gap.
Why This Change Was Made
Move lookup and atomic consumption into the existing shared-state read worker and approval writer. Bind each attempt to its exact admitted receipt, operational instance, selected grant and parent, operation binding, and physical database. Message and standing-grant uses share cron2's receipt observation and FIFO held-use owner through native initiation and acknowledgement.
Consumption accounts once. Unknown consumption never launches, retries, or refunds; a proven pre-initiation fallback revalidates the same grant without another count. Close seals new effects and joins accepted writes and native settlement before retiring resources. Rejected native acknowledgement now fails logical drainage explicitly while retaining physical custody and sealed admission; the Gateway process must retire before that database can reopen.
The existing exec-policy owner supplies prepared final assertions without new SQL and coordinates pending/committed invalidation. Permission withdrawal refuses while native acknowledgement remains unresolved. Local exec-policy mutations retain supported offline behavior and refuse a foreign live Gateway owner. Normal unguarded spawn cancellation and signal-zero behavior remain intact.
User Impact
Scheduled commands retain current receipt, grant and policy authority until native startup, while grant lookup and consumption run through database workers. Eligibility, use accounting, stored schemas, retention, configuration and required released-call parameters are unchanged. There are zero new OPENCLAW_* names. The released two-argument asynchronous PTY call remains supported with an optional lifecycle hook; no released callable is removed or changed from synchronous to asynchronous.
Both prerequisites are merged and incorporated: foundation #164805 (
58bcc015) and held-use transport #164906 (9a7b4dab). Final candidate7025348efa4832bc973437e899113a5d2e04725dincorporates main2be4d4fc561b281a13042ec1c55d3c7b1b5404bfthrough merge commits, without rebasing. Later main integrations preserve the shared receipt owner, main persistence settlement and dependency-free refusal leaf. The latest integration is mechanical and changes no cron3 production file.Incidental overlap with #162433 and the test cleanup #164976 is preserved. #112375 receipt semantics and #158244 skill-policy expansion are not adopted. The initial general approval evaluation retains its pre-existing native policy load (
src/infra/exec-approvals.ts:82), and the non-standing/public SDK final assertion retains its reader (src/infra/exec-approvals-authorization.ts:61); neither is credited as migrated here. Standing lookup, consumption and final guards are the migrated boundary. No pre-existing other-owner SQL remains inside those new worker grants.Operator behavior and worker ownership are documented in
docs/tools/exec-approvals.mdanddocs/reference/database-schemas/worker-access.md. This PR carries its release-note context; CHANGELOG.md remains release-owned.Evidence
All current-head qualification below binds
7025348e/ tree6adf0b5eaf7fc396bcab6b52e52989111c5d111c. Native preparation completed ingithub_pendingmode and verified that the published head already matched the prepared head; it did not repush or rebase.The SDK main digest is
d99c3c9a154a754f211641f0ffd1ad9fe802f52e43d4ab1f4e5df8dba8ba0190(ackd99c3c9a): no direct entrypoint/export/signature changes, 127 reachable closures and the same 16 distinct reviewed declaration changes. Release digestc43ed69eca4f9081cd6a81bc1af2e44232a528f5a9e60dbf180da43a8ef578a1(ackc43ed69e) has exactly the same direct differences as release-to-main, including all 79 signature differences. Candidate/main declarations were freshly rendered. Immutable release reuse was qualified against 41 renderer modules, 51 source/config objects and unchanged compiler/tsx/fs-safe resolutions; the lockfile changed only four Baileys patch hashes. The released PTY parameter, handle and subscription types remain compatible, with retained compatibility type-test proof for unchanged inputs.The update candidate SHA-256 is
37c0019051c4d206682f90efa05fb1a3e7318d2865a38841adbfc4c5d13cb447; build ID2026.9.8-7025348efa48-2026-10-04T19-11-45.335Z. Canonical prepack took 645.471s; the cell took 489.730s within the unchanged 1,125-second deadline. The real updater exited 0 in 383.870s and durably finished run566ec3ce-ed89-4e4d-b5ec-eb5a1cdaa458. All three SQLite stores retained their logical hashes and passed integrity/FK checks; global schema 19→20 and reclamation 0→2 were followed by successful idempotent Doctor maintenance (16.275s), without repeated conversion. Connected server build identity and readiness were verified; operator-read diagnostics remained scope-limited.Update limitations and infrastructure outcomes remain explicit. Changed agent snapshots retain manual-recovery protection for later writes; container service membership used managed stop/update/start; advisory Doctor inspections were deferred. The build emitted a nonblocking startup-JavaScript diagnostic of 365.1 KiB versus a 364.7 KiB budget, so no passing performance-budget claim is made. Testbox timed out after 15 minutes in admission before any payload ran and was stopped before AWS allocation. AWS telemetry/automatic-heartbeat warnings were handled with successful supported keepalives within the original budget. After the successful cell, the task-owned tar command returned 1 for a directory-mtime change. Its existing archive was recovered and independently verified: 75 files, SHA-256
9402fc8a5e41a9b4533d8f67c2d9f1afb72ecbaeae8b31be841f3f1831720883. The outer capture failure is not relabeled green. No updater or prepack rerun was performed.Explicitly approved inherited CI failure
Only job
111498230245(checks-node-changed-extensions-config-27) and aggregate111499788525are qualified for the native admin route. Inextensions/qa-lab/src/gateway-child-artifacts.test.ts,cleanupQaGatewayTempRoots > retains runtime on agent close failure, removes staging, and permits cleanup retryexpectstempRoot: close failedbut receivestempRoot: Agent database close failed. The unchanged agent lifecycle aggregates close errors, while QA intentionally exposes only the redacted top-level message. The fixture still expects the older inner text; the shared-store variant passes. Cron authority and native spawn acknowledgement do not produce this mismatch.The same case fails independently on main
2be4d4fc(10 passed / 1 failed, 146.291s wall) and in all five historical head/base pairs. The actual CI checkout is851fa1e13652c401ac8795bbb702778c6fe39ed5, with ordered parents mainc9bff77155b0d6fde8214b5e9cbfbc32178eff09and candidate7025348e. Its treebc1414e3ecbd9c6631a1d2fde8b6186466a1586aexactly matches a fresh merge reconstruction. All 103 inspected QA/auth/config/lifecycle/normalization/SDK/SQLite objects match baseline to tested merge. This covers the specific failing path, not the complete transitive process/import closure. The five critical QA/cleanup/SDK/lifecycle files remain unchanged through the final inspected main3071b147; no QA repair has landed there.The owner-approved exception binds this completed attempt, original logs, independent main reproduction, source objects, merge reconstruction and actual passing scoped proof. Security, required reviews and live authority remain enforced. Tests remain recorded as failed; only this root and its downstream aggregate are admitted. No CI rerun was requested.
Repairs, retained proof and measurement
Landing repair
19803abffixes the introduced broker regression: ordinary queued spawn/execa cancellation must settle through its native cancellation result instead of being rejected as guarded startup. Five full-file runs per revision first failed on original head99e1dfa3and passed on stack base2a4d54f9; focused repaired process proof passed 41 tests in 120.43s. Integration/repair938dc4fcfixes rejected native acknowledgement hanging logical drainage while preserving physical custody, sealed admission and refusal of replay/refund/reopening. Its disposable child regression failed on the original code (5.532s) and passed on the repair (11.205s). No recoverability was introduced into that failed process.Current CI validates the integrated candidate. Reused proof is explicitly historical and applies to unchanged production inputs: 344 tests across seven files on
1a3bc505, including 15 real native grants, 19 receipt-owner cases, two real Gateway-close cases and required worker/import/runtime-build graphs; 239 tests across 16 files and seven type graphs on4c0a856e; 55 compiled CLI cases; and 295 routing cases on8fa59cbc(844.10s wrapper wall). The native grant proof composes real storage, receipt/policy authority, consumption, exec runtime, supervisor and native file I/O. Valid authority appends/consumes once; replay, revoked/replaced/finished authority and tightened policy prevent an unauthorized append. Initial approval evaluation and RPC are mocked outside the migrated boundary. Repair-head CI at19803abfran the 14 grant cases in 11.248s, with native-effect cases individually costing 0.617–1.130s; the later retained-custody child supplies the additional failure-lifetime contract.Incorporated main repairs resolved the former routing, browser-spinner, memory-schema and reindex-fixture failures. Origins now pass 11/11, forget settlement 4/4 and reindex 24/24 on main
2be4d4fc, and their current CI lanes pass. Historical Bun socket and real-Gateway ownership failures did not reproduce in five head/base pairs and remain unattributed; later passing CI is not claimed as their root-cause repair, and neither is waived. Doctor auth-consumer proof passed on the earlier integration; its original cause remains unproven. Prior CI attempts and old update/SDK receipts are historical, not substituted for current-head qualification.A fresh matched original-scope cron-tick replay measured 1,620 main-thread SQL statements on each revision; all 274 method/SQL frequency pairs match, with zero SQL errors and zero standing-grant operations. Worker SQL was 3,833→3,799; caller prepares were 538→538. Eight differing full-stack rows are existing schema-refresh pairs moving between publication and placement callers, whose 28 source files have identical blobs: publication worktree lookup (
src/gateway/github-publication-availability.ts:153) and database opening (src/gateway/github-repository-publication-store.ts:58) each go 1→0; placement lookup (src/gateway/worker-environments/worker-turn-launcher.ts:207) and publication table lookup (src/gateway/github-repository-publication.kernel.ts:162) each go 0→1.readSqliteCacheDataVersion(src/infra/sqlite-schema-facts.ts:309) charges refresh to the first observer of a foreign commit; the new pair adds no frequency. Only the per-run timestamp literal in an unchanged session migration statement was normalized.The deleted historical 1,652→1,661 (+9) traces cannot be reconstructed and remain unattributed. The new pair establishes no added main-thread SQL in its fixture; zero grant operations make it smoke/attribution evidence, not a grant-consumption speedup claim. Original-scope inventory credited only standing-grant R6: T1 914→908, worker sites 975→981, total primitive sites unchanged at 2,541; these are not final integrated-main counts.