Repository navigation
refactor(cron): remove receipt custody before worker cutover - #168772
Conversation
|
🦞👀 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 real behavior proof before merge. What this changesThis PR removes cron receipt custody and its consumers while retaining host scheduling and durable run receipts. Example: An operator revokes the daily-report standing grant after its first use commits.
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness⛔ Blocked before merge - 6 items remain Keep open: this PR implements an approved simplification, but two authority regressions and a stale SDK contract remain actionable. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Gateway schedules cron runs and supplies their tool authority; shared-state workers persist jobs, receipts, and approvals, while channel transports and process launchers perform effects. flowchart TD
A[Host scheduler] --> B[Cron run admission]
B --> C[Tools and approvals]
C --> D[Shared state worker]
D --> E[SQLite state]
C --> F[Transport and process effects]
Technical reviewBest possible solution: Remove custody while preserving permission invalidation independently of reply delivery and carrying existing live assertions to final transport effects. Do we have a high-confidence way to reproduce the issue? Source establishes both failing paths, supported by the removed lost-reply regression and Twitch's awaited preparation; no target code was executed during this read-only review. Is this the best way to solve the issue? The approved simplification is appropriate, but the surviving permission and transport owners must retain their actual checks without restoring the removed custody machinery. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 35ab90410d55. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Two reachable regressions allow scheduled effects to use withdrawn authority. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource -1295, Tests -1631, Docs +10. Total -2916 across 55 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed October 11, 2026, 4:39 AM ET / 08:39 UTC (Revision 9). |
1216af9 to
87c4a17
Compare
87c4a17 to
f8753d3
Compare
Keep the host scheduler and durable run receipts while removing the receipt custody owner, prepared uses, and publication hooks from cron, approvals, agent removal, and Gateway shutdown. Existing run, permission, approval-row, and transcript owners retain their checks; a committed standing-grant use may race later revocation. Repair two inherited fixtures exposed by the required proof: use the prebuilt CLI in the real-Gateway media test, and observe the current cache-prune execute boundary in the memory reservation test. Refs #168072.
a77f1cc to
509cd7a
Compare
…8772) Cron PR 2a of the worker-owned redesign (docs/refactor/cron-worker-owned.md): deletes cron receipt custody/revocation and its consumers across scheduling, standing grants, operator approvals, agent removal and Gateway shutdown. Independent live checks stay at each effect (run active, grant current and unexpired, host exec policy, approval rows); the accepted revocation-after-check race is named in code. Host remains the scheduler until 2b. Production -1,291 LOC. Refs openclaw#168072.
Failed state-database resource drainage left its read seal held, and retries reused the stale seal, so every capture failed with STATE_DATABASE_READ_ADMISSION_INVALIDATED until restart. Native handles are not retired on that path, so release the seal while keeping failed resource custody, and seal again before each retry drains. Failed native retirement still keeps its seal. Fixes #162085 Backport adaptation: kept the release branch's worker-access.md; its stale-sentence removal depends on #168772, which is not on this line. (cherry picked from commit 63c8229)
First-parent upstream c96fac1..d9eba8a (10 PRs: openclaw#168948 GitHub connection authority to workers, openclaw#168975, openclaw#168772 cron receipt custody removal, openclaw#169012, openclaw#169006, openclaw#169009, openclaw#168283 test batch d042, openclaw#168994, openclaw#168964, openclaw#168855 approval/placement state in workers). Conflicts: - docs/reference/database-schemas/worker-access-inventory.md: took upstream, then regenerated (db:worker-inventory:gen, 633 files / 2449 calls) instead of hand-merging. - src/agents/embedded-agent-runner/compact-reasons.test.ts: upstream openclaw#168283 deleted low-value cases; kept upstream's file plus our own additions only (unknown_model, empty reason, closed-union check and the isCompactionSkipCode block). session-reset-service.ts auto-merged: upstream's awaited placement retirement (assertCurrent) is disjoint from our continuation-cancellation cleanup reason. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Cron receipt custody serialized scheduler writes, approvals, and agent removal around held launch handles. Gateway shutdown also had to drain that second ownership layer.
Why This Change Was Made
This is PR 2a of the approved worker-owned cron design. The scheduling/launch step is split into 2a (remove custody and its consumers) and 2b (move timer, manual, and event scheduling to the worker together), followed by result/recovery consolidation.
Remove custody owners, attachments, publications, prepared-use handles, and dependent launch/read wrappers. Existing Gateway, run, tool, permission, approval-row, deletion, and transcript owners retain their checks. The host remains the sole scheduler.
The original importer proof also exposed a real-Gateway UI fixture that rebuilt the dirty checkout on every start, restart, and auth bootstrap. It now uses the prepared
openclaw.mjsentrypoint, matching its sibling fixture, with unchanged assertions and timeouts.The integration proof also found a stale cross-process read in the Dreaming restart E2E fixture. The Gateway had completed cleanup, but the test observed its own cached projection. Its initial cleanup assertion now uses the existing
sessions.listRPC, preserving the cleanup and retention assertions.The final importer run also exposed a stale Telegram poll test spy: production uses
openKeyedStoreV2, while failure injection still interceptedopenKeyedStore. The test now intercepts the current API and preserves its warning, absent-route, and no-resend assertions. No Telegram production behavior changed.The CI follow-up repairs the native Gateway fork fixture: generated test code now lives under the repository Vite root, while config, transform cache, and runtime state stay isolated. The child config also inherits the shared Node environment. The missing-receipt probe still requires independent worker-exit proof before disposing its staged input.
User Impact
Scheduling, durable receipt accounting, and database format remain unchanged. Committed standing-grant consumption authorizes one start: revocation may race that already-checked launch; subsequent consumption observes revocation. Run liveness, host policy, expiry, and cancellation still gate initiation. The approval documentation states this accepted tradeoff.
No schema, dependency, config, or CLI changes. Updates and rollback require no data migration.
Refs #168072.
Evidence
Latest rebase:
509cd7ac96dda90966f7b3bf14998d2db09a3af1on90f04bfb10df3b55d7473b6519be8bbe8fab77a2. Pushed with--force-with-leaseagainsta77f1ccca200cc516910f37621953e27d1cdcb02after the conflict-only proof below. The lead reported that prior head's CI green except the known ci-gate.Two conflicts resolved at their owners:
message-action-turn-capability.tskeeps main's new prompt-reaction imports and behavior while removing the obsolete custody type/use hook;send.history.test.tskeeps main's boundopenKeyedStoreV2helper, superseding the PR's earlier unbound helper fix. The native-fork fixture commit rebased unchanged.node scripts/run-vitest.mjs src/gateway/message-action-turn-capability.test.ts src/agents/tools/message-tool.current-prompt-reaction.test.ts extensions/telegram/src/send.history.test.ts --maxWorkers=1: 3 files, 49 tests passed, 150.74 s command wall time on Node 24.19.0. File wall times: 19.80 s, 31.59 s, and 50.70 s; transform/setup dominate these runs.pnpm check:madge-import-cycles: 0 cycles. Formatting andgit diff --checkpassed. Proof was limited to the conflicted owners and their prompt-reaction integration, as requested; no CI wait or merge.Earlier-head evidence follows.
Previous fixture-repair head:
a77f1ccca200cc516910f37621953e27d1cdcb02. This CI repair is a normal push on top off8753d34; the earlier integration was rebased and pushed with--force-with-lease. No merge was attempted.Fetched all three failing node-job logs and checks-ui (2/3) once. The failing node files are
test-helpers.acquisition.test.ts,server.sessions.fixture-lifecycle.test.ts, andserver.startup-fixture-lifetime.test.ts.Root cause and owner: the shared native fork fixture put
fixture.test.tsoutside its Vite root. Child reports show zero executed tests andCannot find module '/@fs/.../fixture.test.ts', before the PID write or Gateway startup. The missing PID then correctly retained fixture inputs and resource claims. This reproduces on the exact PR base, so it is not caused by receipt-custody removal. The generated child config also omitted the shared Node environment, allowing Solid to choose jsdom. The repair fixes both atserver.fixture-lifetime.test-support.ts, without changing production shutdown or weakening joins, assertions, timeouts, or retries.Node 24.19.0 local comparison through
node scripts/run-vitest.mjs, using explicit gateway-database-workers and gateway-server configs and--maxWorkers=1:eec5e318ecaaf8753d34Remaining local proof limit:
startup fixture ownership: public clean cleanupandretains fixture state and fences successors after a required Gateway close failurereached the existing 90-second child deadline. The captured startup diagnostic reportsgateway.server-start-importbeginning after 69,444.6 ms; fresh native source loading/compilation consumes most of that budget on this loaded host. The required-cleanup and kernel-cleanup cases passed in 67.412 s and 50.887 s, and the missing-receipt probe passed in 1.679 s. The acquisition fork passed in 37.808 s. These are recorded slow-fixture limitations, not a fully green native replay. Retained directories and resource claims were preserved; no join was bypassed.UI is inherited from newer main. CI tested merge
40dd42d9againstf2e649da67fa909126980d88171e93f3f99d6f01, which includes the Sessions Solid migrationf4d601a00613.session-row.tsxlost the previous missing-kind icon fallback; the unchanged scope-race fixture supplies archived rows withoutkind, producing the CIprops.data.attributes/REACTIVITY_HALTEDfailure. The UI tree, test config, package manifest, and lockfile are identical between exact PR base and original head.sessions-page.scope-race.test.tspasses all eight tests on both (23.45 s / 15.94 s). A replay of newer main alone halted and was terminated by the existing no-output guard after 195.48 s. Local Bun is 1.4.2; CI used 1.4.3-canary.1, so this is not claimed as an exact-runtime reproduction. No UI changes are included.node scripts/check-changed.mjs --base f8753d343f2910817e090021800498b1d177d5a5 -- <the two changed fixture files>passed formatting, ratchets, guards, and both affected test type graphs (gateway-root 24.1 s, gateway-server 20.7 s). It stopped at the full-tree dead-export scan:src/cli/run-main.test-support.ts: readActiveGatewayLockPortMock. That file and the entire CLI subtree are unchanged from the exact base; source inspection confirms the same unused export there. Production and script export scans passed with zero entries. The final planned targeted oxlint command was run separately and passed. No baseline or suppression changed.pnpm check:madge-import-cycles: 0 cycles.git diff --check: passed. Fresh isolated Codex autoreview was unavailable (HTTP 401, no review report); the campaign fallback applies.This follow-up changes 0 production lines and +23 / -14 test/support lines. Whole-PR production: +329 / -1,620 = -1,291 lines; tests/support: +187 / -1,822 = -1,635 lines. Counts classify
test-helpers.server-lifecycle.tsas test support; the previous count placed its four deleted lines in production. No schema, dependency, config, or CLI option changes.Previous rebase proof
Previous rebase:
f8753d343f2910817e090021800498b1d177d5a5oneec5e318ecaa95def03d5c27254d12db149856fa. This update rebases the PR again and is pushed with--force-with-leaseagainst the previous head87c4a173afe2ecc37bffa41725119da68947c991.The single textual conflict was in
docs/tools/exec-approvals.md: main's plain-language idempotency wording is retained, together with the approved distinction that revocation blocks subsequent consumption while an already-consumed use may still start. The production patch is unchanged. Main's newer shutdown-hook/cleanup ordering remains in place alongside receipt-custody removal. Both3367a12c(Node environment) and8267c240(Solid imports in Node projects) are included.Historical local proof on Node 24.19.0:
test/vitest/vitest.gateway-database-workers.config.ts; 90.41 s command wall time. This includeslocal-request-context,worker-environments/transcript-commit, andinternal-source-reply-persistence, plus the other eight failing files from the prior CI run.pnpm check:madge-import-cycles: 0 cycles.oxfmt --check docs/tools/exec-approvals.mdandgit diff --check: passed.Production remains +329 / −1,624 = −1,295 lines; tests/support +164 / −1,804 = −1,640 lines. No schema, dependency, config, or CLI change was added during this integration. No merge or CI rerun was performed.
Historical proof and diagnosis for the prior heads
Production: +329 / −1,624 = −1,295 lines. Tests/support: +164 / −1,804 = −1,640 lines. No baseline, ignore, or suppression changes.
Validation target:
87c4a173afe2ecc37bffa41725119da68947c991on integrated baseaec34bbde0f56a8fa50f5711f99c8a26508921e1.Final-base proof exercised 527 distinct test files: 8,417 passing cases and one existing platform skip. All selected importer paths were observed in test output. The broad command retained one failing stale-spy case, corrected and rerun below; it is not presented as a wholly green invocation.
node scripts/run-vitest.mjs <526 selected owner/direct/one-barrel files> --maxWorkers=4: 8,031 passed, one failed, one skipped; 4,327.20 s wall time. The single failure was the stale Telegram poll spy described above.Explicit routing of 20 selected files omitted by the broad mixed-project run: 349 passed; 443.57 s. This fills the omitted paths rather than counting selection as execution.
Unchanged
extensions/codex/harness.test.ts --maxWorkers=1: 36 passed; 61.47 s wall time after main's canonical cache-settlement fix.Corrected
extensions/telegram/src/send.history.test.ts --maxWorkers=1: 29 passed; 64.11 s wall time; the write-failure case passed in 0.720 s.The Dreaming fixture's repaired assertion passed through the real Gateway. Its single-worker probe took 78.82 s including preparation; on the final base its test took 64.045 s under the broader run.
pnpm check:madge-import-cycles: 0 cycles.git diff --check: clean.node scripts/check-changed.mjs --base aec34bbde0f56a8fa50f5711f99c8a26508921e1: formatting, ratchets, core types, all core-test types, extension-test types, and root-test types passed. It exited at the dead-export scan after 1,465.33 s. An isolated archived copy of that exact main base reproduced identical findings in both production and full-tree scans (five each); both script scans passed. The remaining checks were run from the same native planner after that inherited failing step, reusing completed typecheck proof: All 12 remaining checks passed (787.38 s), including core/extension/script lint, schema/storage guards, runtime import cycles, webhook and pairing guards. No baseline, ignore, or suppression changed.Inherited export findings are
captureSessionEntryMaintenanceAgeFact,SessionEntryMaintenanceAgeCapture,SqliteReclamationPreparedSource,GatewayApprovalEventPublisherV2,OpenClawAgentDatabaseWorkerCloseResult(production scan), and the UI helperreconnectGateway(full-tree scan).Fresh isolated Codex autoreview was unavailable (HTTP 401, no report). The campaign's explicit fallback applies; the lead approved the substance of the earlier head.
Runtime preparation, real Gateway restarts, browser replay, and worker fixture setup dominate the known slow cases. Measured final-base test times include UI image replay 34.692 s and attachment replay 129.842 s; copied-session lazy cron harness 35.385 s; destination preparation/settlement/recovery 47.161/64.809/34.638 s; updater activation 30.221 s and canary reopen 37.039 s; memory semantic recall 36.248 s; Dreaming restart 64.045 s. These pre-existing integration suites were recorded under the campaign's slow-suite ruling; no timeout, retry, or assertion was weakened.
The first build attempt stopped before tests because this worktree lacked links for main's already-locked workboard Solid dependencies.
pnpm install --frozen-lockfile --ignore-scriptsrestored this worktree's private installation; tracked dependency files stayed unchanged.The lead approved the substance of previous head
1216af901792bb9337dfa010191a48201fca3890. This branch was rebased ontoaec34bbde0f56a8fa50f5711f99c8a26508921e1and pushed with--force-with-lease. The single textual conflict was the memory publication test observer: main already repairs command observation and supports its newer publication dispatch, so main's helper and call site are retained unchanged; the narrower PR-only memory fixture override was removed. Clean overlaps preserve main's async message discovery, post-await target-authority check, and SQLite admission/fact-exchange changes alongside custody removal.An intermediate-base importer run reproduced a native-binding cache deadlock in
extensions/codex/harness.test.ts(120.008 seconds). Main landed its canonical fix,7cc1ca64798c, during this integration: comparison transactions no longer reuse stale cached rows, and native-binding settlement invalidates the affected keys. After rebasing onto that fix, the unchanged harness passed all 36 tests; the blocked case took 1.801 seconds. No speculative Codex test edits remain.Prior-head evidence remains historical, not current-head CI: 618 unique test files exercised; focused owner proof passed 101 tests, with broader importer/owner proof passing 4,873 + 2,825 + 2 + 832 tests and the four memory-helper files passing 61 tests.
check:changedpassed with the dead-export scan run separately; its inherited findings were reproduced on original base9cf7fc279c26cf3493b75e703aeadac6d0deb5ee. No baselines, ignores, or suppressions changed. Madge and runtime import cycles were zero.Original fixture timings: UI cases failed at 180 seconds before the launcher repair, then passed in 30.696 and 83.369 seconds (162.26 seconds file wall; 241.23 seconds including preparation). The old memory observer deadlocked pruning at 240 seconds plus cleanup; that narrower fix is now superseded by main's observer.
No merge was attempted. Hosted CI attribution is recorded below.
CI attribution follow-up — head
87c4a173afe2ecc37bffa41725119da68947c991, run38113595420.Fetched the complete 150-check inventory and each of the seven failed shard logs once. They identify 11 failing Gateway database-worker files. CI tested synthetic merge
5ece9b70, which combines this PR with newer main48a2b3d29bdb71792b5fa7fb97ca9450ac995ac6; that is later than this PR's merge baseaec34bbde0f56a8fa50f5711f99c8a26508921e1.The failures are inherited from main's test environment, not the receipt-custody removal. Main commit 74e8844382e9 adds
controlUiSolidPlugin()totest/vitest/vitest.gateway-database-workers.config.tswithout an explicit environment. The installed Solid plugin defaults unspecified test environments to jsdom. Native SQLite and worker byte arrays then fail realm-sensitive checks:config revision key is corrupt,Session history worker returned an invalid transcript frame, and fs-safe's Uint8Array validation. The implicated production validators are unchanged by this PR.Local comparison through
node scripts/run-vitest.mjs --config test/vitest/vitest.gateway-database-workers.config.ts <the 11 failing files> --maxWorkers=4:aec34bbde0f587c4a173afe2aec34bbde0f587c4a173afe248a2b3d29bdbwithout this PRenvironment: "node"in the database-worker projectCanonical correction: explicitly set
environment: "node"increateGatewayDatabaseWorkersVitestConfig, retaining the Solid transform and the UI test's own jsdom annotation. The correction probe changed no production code, assertions, timeouts, or retries and has been reverted. PR source and head remain unchanged. A broader exact-group replay on the older base was stopped after passing progress once the different CI merge base was identified; it is not claimed as a completed pass. CI remains red until the main test-environment correction lands. No CI rerun or merge was performed.