Repository navigation
refactor(cron): centralize durable run queue and launch ownership - #169364
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 centralizes durable Cron requests, execution capacity, and activation in the SQLite worker behind one host launcher. Example: Eight runs occupy service A while sibling service B requests report-job against the same store.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 7 items remain Keep open: this PR implements the approved Cron queue redesign, but two previous lifecycle defects remain and an additional unobserved rejection can terminate the Gateway. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherTimer, manual, and event sources submit durable requests; the host launches existing executors and returns outcomes to receipt, history, and recovery owners. flowchart LR
A[Timer and event sources] --> C[Queue worker]
B[Manual requests] --> C
C --> D[SQLite jobs and receipts]
C --> E[Host launcher]
E --> F[Existing executors]
F --> G[Outcome and recovery owner]
G --> D
Technical reviewBest possible solution: Complete activation-failure reconciliation and rejection handling while preserving existing effect checks and the approved crash semantics. Do we have a high-confidence way to reproduce the issue? Source establishes the lost activation-reply and unobserved rejection paths; no target code was executed during this read-only review. Is this the best way to solve the issue? The approved worker queue provides the appropriate owner, but failure cleanup and promise observation must cover every entry point. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c8dea3b59901. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass was found, but retained queued-caller authority needs final-effect evidence. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. 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 (3 earlier review cycles)
Reviewed October 11, 2026, 7:52 PM ET / 23:52 UTC (Revision 4). |
33514fc to
d62a080
Compare
Unify scheduled, manual, and event launches behind durable receipt requests. Keep the host as the wake producer while the worker owns ordering, capacity, and activation. Preserve logical timeout capacity and recover stale receipts after marker retirement. Refs #168072.
Cancel queued exit requests through the worker before reporting cancellation, keep one receipt settlement owner, and remove obsolete host receipt exports. Split oversized owners and remove unused exports without changing their runtime contracts. Keep queue, recovery, and asynchronous fixture assertions at their owning lifecycle boundaries.
Restore all UI changes and unrelated backend refactors to the PR base. Retain only the cron queue, launcher, required heartbeat caller, and cron test adaptations.
Preserve main's asynchronous notification owner in manual preflight recovery and startup deferral. Keep notification work after synchronous committed publication.
c79d4e1 to
3bd070a
Compare
|
Merging at pinned head
|
Classify operator cancellation and Gateway retirement at their producers so terminal one-shots do not request a repair, alert, safety notice, or retry. This fixes the cancellation regression introduced by #169102 while retaining watchdog timeout retries and recurring-job policy. Preserve completed payload and delivery facts when cancellation interrupts webhook response cleanup. Record terminal timed and watcher-fired on-exit failures through the existing auto-disable owner, making them visible in doctor. Carry watcher occurrence provenance from the durable queue's launcher through worker finalization; keep ordinary paused/armed force-runs out of that terminal disposition and preserve later schedule edits. No schema, configuration, or compatibility path. Use the existing owner repair with alert fallback, a resolved failure alert, or the safety notice. Retain shared cooldown and incident suppression without an extra notice. The safety notice remains active for failureAlert:false and inherited bestEffort suppression. Document terminal behavior and doctor visibility. Release-note context: terminal one-shot failures no longer disappear silently, while operator cancels and restart retirements remain quiet. This maintainer re-expression supersedes #131590 and #167908 on current main after #169364. Co-authored-by: lonexreb <[email protected]> Co-authored-by: erlightbourn-source <[email protected]>
…auncher (openclaw#169364) Cron PR 2b-i of the worker-owned redesign (docs/refactor/cron-worker-owned.md): timer, manual and event sources write idempotent run requests into the existing receipts table; the cron worker owns queue capacity and activation; a host launcher checks liveness and eligibility after commit and owns execution and cleanup lifetimes. Host reservations and capacity bookkeeping are deleted. Also fixes timeout-capacity accounting, markerless receipt recovery, paused manual runs, sibling queue ownership and cancellation settlement. Host scheduling moves in 2b-ii. Production -1,827 LOC. Refs openclaw#168072.
…et (#169314) Classify operator cancellation and Gateway retirement at their producers so terminal one-shots do not request a repair, alert, safety notice, or retry. This fixes the cancellation regression introduced by #169102 while retaining watchdog timeout retries and recurring-job policy. Preserve completed payload and delivery facts when cancellation interrupts webhook response cleanup. Record terminal timed and watcher-fired on-exit failures through the existing auto-disable owner, making them visible in doctor. Carry watcher occurrence provenance from the durable queue's launcher through worker finalization; keep ordinary paused/armed force-runs out of that terminal disposition and preserve later schedule edits. No schema, configuration, or compatibility path. Use the existing owner repair with alert fallback, a resolved failure alert, or the safety notice. Retain shared cooldown and incident suppression without an extra notice. The safety notice remains active for failureAlert:false and inherited bestEffort suppression. Document terminal behavior and doctor visibility. Release-note context: terminal one-shot failures no longer disappear silently, while operator cancels and restart retirements remain quiet. This maintainer re-expression supersedes #131590 and #167908 on current main after #169364. Co-authored-by: lonexreb <[email protected]> Co-authored-by: erlightbourn-source <[email protected]>
…9767) Changed-test selection now follows runtime-worker descriptors (`currentModuleUrl: import.meta.url` with a literal `sourceWorkerName`). Inline descriptors are edges from their declaring module; exported descriptors are edges only from test code that reads that descriptor, so aggregators such as cli-entrypoint.test-support.ts and the worker build manifest do not fan out to every fixture. A change to a fixture's dependencies now selects the process tests that spawn it, e.g. src/cron/service/run-queue.ts selects run-loop.forced-cron.process.test.ts (missed by #169364's CI). Source facts also get their own scan buffer: the full inventory already emits ~16.56 MB against the borrowed 16 MiB git ls-files limit.
…et (openclaw#169314) Classify operator cancellation and Gateway retirement at their producers so terminal one-shots do not request a repair, alert, safety notice, or retry. This fixes the cancellation regression introduced by openclaw#169102 while retaining watchdog timeout retries and recurring-job policy. Preserve completed payload and delivery facts when cancellation interrupts webhook response cleanup. Record terminal timed and watcher-fired on-exit failures through the existing auto-disable owner, making them visible in doctor. Carry watcher occurrence provenance from the durable queue's launcher through worker finalization; keep ordinary paused/armed force-runs out of that terminal disposition and preserve later schedule edits. No schema, configuration, or compatibility path. Use the existing owner repair with alert fallback, a resolved failure alert, or the safety notice. Retain shared cooldown and incident suppression without an extra notice. The safety notice remains active for failureAlert:false and inherited bestEffort suppression. Document terminal behavior and doctor visibility. Release-note context: terminal one-shot failures no longer disappear silently, while operator cancels and restart retirements remain quiet. This maintainer re-expression supersedes openclaw#131590 and openclaw#167908 on current main after openclaw#169364. Co-authored-by: lonexreb <[email protected]> Co-authored-by: erlightbourn-source <[email protected]>
…nclaw#169767) Changed-test selection now follows runtime-worker descriptors (`currentModuleUrl: import.meta.url` with a literal `sourceWorkerName`). Inline descriptors are edges from their declaring module; exported descriptors are edges only from test code that reads that descriptor, so aggregators such as cli-entrypoint.test-support.ts and the worker build manifest do not fan out to every fixture. A change to a fixture's dependencies now selects the process tests that spawn it, e.g. src/cron/service/run-queue.ts selects run-loop.forced-cron.process.test.ts (missed by openclaw#169364's CI). Source facts also get their own scan buffer: the full inventory already emits ~16.56 MB against the borrowed 16 MiB git ls-files limit.
First-parent upstream 84a834e..2b9aa2e (112 commits, including openclaw#169327 actor memory storage for incognito consumers, openclaw#169458 session bookkeeping/transcript workers, openclaw#169449 gateway read paths, openclaw#169364 cron worker queue, openclaw#168401 remote compaction V2, openclaw#169467 transcript backlog). Conflicts: - session-reset-service.ts: upstream moved ensureSessionRuntimeCleanup into session-reset-runtime-cleanup.ts. Took upstream's form and ported our delta into the new module: the `reason` parameter and the awaited clearSessionScopeRuntimeState (continuation cancellation that cannot persist returns UNAVAILABLE). Callers keep passing `reason`. - attempt-execution.ts: upstream made the Claude CLI fallback prelude async; ported the await into our extracted resolveClaudeCliFallbackPrelude. - session-accessor.sqlite-lifecycle.ts: upstream's two actor-storage imports; the eviction kick import stays where the fork moved its caller. - status-message.ts: upstream threads preparedTtsPreferences into the voice line; ported into our status-session-lines.ts helper. - plugin-sdk-surface-report.mts budgets; worker inventory regenerated. Also: session-actor-memory-collaboration-contract.ts (new upstream file) excludes the fork's sharing `authority.capture` op from actor memory commands (it runs only on the sharing writer's owner), as at step 26. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Cron queueing and activation were split between host reservations and persisted receipts, leaving capacity, accepted manual runs, and restart recovery with competing owners.
Refs #168072.
User Impact
Timer, manual, and event requests use one durable queue and one concurrency limit. Explicit force still runs disabled jobs, consumed exit events and stream batches retain their payloads, queued edits take effect before launch, and cancelled requests settle promptly even when all execution slots are occupied.
No schema, dependency, config, or CLI changes. Existing receipt IDs and history joins stay intact. Recovery resumes identifiable timed requests and records requests with unrecoverable launch context as skipped. Uncertain active runs are interrupted, not replayed. The accepted active-commit-to-launch crash window can miss an occurrence, and a disable can race dispatch.
Why This Change Was Made
This is 2b-i: queue and launcher of the worker-owned cron redesign. The SQLite worker owns idempotent receipt requests, queue order, capacity, and activation. Timed IDs encode tagged
[storeKey, jobId, scheduledSlotMs]tuples; manual/event requests have distinct IDs. A small host launcher checks live Gateway/job eligibility after commit and calls the existing executor. Host reservations, capacity bookkeeping, and obsolete command-lane marker plumbing are removed. 2b-ii will move schedule computation, timers, and wake production; they remain on the host here.The cutover also fixes timeout-capacity accounting (active markers, rather than receipts awaiting physical executor settlement) and markerless-receipt recovery. Launched runs retain their caller and Gateway lifetime beyond request acknowledgement. Deferred cleanup joins that launcher scope, and test teardown waits for the launcher before closing state.
The scope correction removes all 21 UI changes and 20 other unrelated files introduced by validation cleanup. Session storage, session sending, updater, plugin-state, validation-cache, and unrelated Gateway fixture changes are restored to the PR base. No UI changes remain in the PR.
Outside
src/cron, the retained implementation is the heartbeat caller adaptation required by removal of command-lane task markers. Other retained callers are cron tests: the standing-grant and monitor fixtures import the moved receipt test helpers, the requester-authority fixture drains cron before closing state, and the Gateway cron/close tests and shared cron helpers cover the new queue contract. The design document records the 2b-i/2b-ii split.Evidence
Current scope correction —
c79d4e1ebbe725d68a282d64a6d204eccadaeab7042db1e7064930a08c534c4487864d7bfb8c5287;git diff $(git merge-base origin/main HEAD) HEAD --stat -- uiis empty after the correction commit. The remaining path inventory contains only cron, Gateway cron integration, the required heartbeat caller, cron tests/helpers, and the design document.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.ui-components.json: passed, including the MCP app tests that failed when unrelated element-type changes were present.node --import ./scripts/tsx.mjs scripts/check-madge-import-cycles.ts: 0 cycles.check:changedpassed the scope ratchets, formatting, core production types, all 28 core test type graphs, root test types, and the preceding guards, then stopped on 84 unique unused-export findings. The same export scanner was run against the exact PR base in this worktree; its finding set was identical (84/84; zero candidate-only entries). The final staged tree was restored and verified exactly afterward. No exports, suppressions, or baselines were changed to bypass this result.typescript(no-misused-promises)inui/src/components/session-group-defaults-dialog.tsx:422. The changed-file line-cap growth ratchet passes. Script lint, schema consistency, database-first storage, sidecar, import-cycle, webhook/auth, and cron test-helper lint checks all passed.Inherited core-lint errors (exact base file bytes retained)
src/plugins/registry-runtime-session-ownership.tssrc/gateway/server-methods/sessions-files.tsui/src/pages/chat/components/chat-detail-panel.tsxsrc/cli/update-cli/update-command-post-update.tssrc/auto-reply/reply/dispatch-from-config.choose-route.tssrc/auto-reply/reply/dispatch-from-config.lifecycle.tssrc/agents/worktrees/checkout.tssrc/gateway/session-worktree-preparation.tssrc/agents/tools/sessions-send-tool.tssrc/config/sessions/transcript.tssrc/plugin-state/plugin-state-store.tssrc/state/openclaw-agent-db-validation-cache.tsui/src/components/session-group-defaults-dialog.tsxEarlier queue/recovery proof remains applicable: the scope correction leaves the cron queue/launcher implementation unchanged from
d62a08096e50d22c1cfa4008a9823c0b80f31610. A copied database created by released [email protected], using isolated state, recovered successfully: an old random receipt was skipped and its marker cleared without changing its ID; a forced successor ran successfully. Owned Gateways were stopped and joined. The earlier manual-tool-authority CI rejection was reproduced and fixed by joiningwaitForIdle()before state cleanup; the current focused run includes that regression.Production: +1,863 / −3,690 LOC (net −1,827). Tests/test support: +2,277 / −3,959 (net −1,682). Documentation: +7 / −1. No unrelated cleanup, suppression, or baseline changes are retained. All proof ran locally; no remote lease was used.