Repository navigation
refactor(cron): schedule system-job reconciliation retries - #159129
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. |
b10dd24 to
aba3339
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 8:30 PM ET / September 27, 2026, 00:30 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch moves the Gateway’s 30-second heartbeat and Workshop reconciliation retry into its shared scheduler and adapts the cron and reload tests to an injected clock. Merge readiness✅ Ready for maintainer review Keep this PR open. Current main still uses a private timeout for system-job reconciliation retries, so the branch has a distinct purpose. The reviewed scheduler and cancellation paths show no concrete introduced defect. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway cron service reconciles system-owned heartbeat and Workshop jobs from accepted configuration into automation jobs. Its retry wake feeds a failed reconciliation back through the same service, while the Gateway scheduler owns wakeups and shutdown. flowchart LR
A[Accepted Gateway config] --> B[Cron reconciliation]
B --> C{Jobs converged?}
C -- Yes --> D[Heartbeat and Workshop jobs]
C -- No --> E[Shared Gateway scheduler]
E --> F[Retry after 30 seconds]
F --> B
G[Gateway stop] --> E
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests -3. Total -3 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep cron as the owner of system-job convergence and use the existing Gateway scheduler for its retry wake, preserving the retry interval and stop and reload fences. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR changes ownership of an existing retry wake rather than reporting a failing user flow. Current main and the introduced hunk provide a direct source comparison. Is this the best way to solve the issue? Yes. The Gateway already has a required shared scheduler, and the branch uses it while leaving reconciliation decisions in the cron service. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e8e68eaee9d9. 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 (1 earlier review cycle)
|
aba3339 to
5c2ed54
Compare
5c2ed54 to
e97be61
Compare
What Problem This Solves
Gateway-owned heartbeat and Workshop job reconciliation schedules its own retry timeout outside the shared scheduler.
User Impact
Existing heartbeat and Workshop convergence behavior remains unchanged. Retry wakes share the Gateway's next-wake and shutdown owner.
Why This Change Was Made
Use the required Gateway scheduler for the existing 30-second retry. Remove native timeout/unref/clearTimeout plumbing while preserving accepted-config serialization, epoch invalidation, warnings and retry convergence. Existing cron/system-job policy remains with its owner.
One scheduler instance per Gateway process, enforced by types. This followup consumes the required scheduler introduced by the cron due-timer slice and creates no new scheduler instance. Existing installs retain their cron rows, run receipts, configuration, ports and spools. No migration, new deadline store, storage policy, config, SDK or RPC contract change is introduced.
Production +8/−8/net +0; tests +18/−21/net -3; docs +0/−0/net 0.
Evidence
Reviewed refresh on main
f61e10a7f49798cd7a041ca3509d3a2c5e0b99bc, then mechanically rebased after both cron prerequisites merged. Publication headb10dd2421727a29886d6ae4bd5f08b9ab0252b9e; exact-head CI attaches on publication. Candidate tree998b4172698fc319ca28cf5be318f4922467ea94. The canonical patch ID is unchanged, and every changed followup file plus every exercised test file is byte-identical to the reviewed/proven composition. Main's already-landed scheduler plumbing is preserved in the prerequisite. Whitespace and source/index checks pass. The original complete due-plus-owner composition passed independent Codex review through P2; this mechanical refresh introduces no new runtime adaptation.Prior focused proof on base
d4e7850dd56abcfb66ba8cda511378ff2f98c0daand exact tree01f600d095ae1b4f703c7bc8565d4da72874c4dapassed 2 file runs and 336 case executions in 56.510s command wall. These are recorded executions, not unique-case counts. Provider: blacksmith-testbox; leasetbx_01m3f70jxsg7e3036jppdwwv8j; run 36253776173. Frozen installation and exact source checks preceded execution; source was verified afterward. The proof's private checkout and owned processes were removed on completion.Every row used
pnpm test <file> --maxWorkers=1:src/gateway/server-cron.test.tssrc/gateway/server-reload-handlers.test.tsThese measurements include wrapper/compiler setup and do not establish a performance improvement. Existing native receipt/store and Gateway/reload compositions remain covered; the changed scheduling cases use the shared injected clock without new sleeps or per-test Gateway boots. The earlier exact owner proof is reused; no refreshed-head Testbox or CI run is claimed here. GitHub's enforced
openclaw/ci-gatesupplies changed-file validation. Final merged-main Gateway/cron/suspend/shutdown proof follows the final stack slice.CI recovery: the original missing-scheduler fixture failures were fixed on main by
c0e6951d6f02. The subsequent exact-head run 36271132339, compact-large-7, failed during session-group test teardown: retirement attempted to adopt a replacement shared database. Its original five-group CI order reproduced on matching Testbox hardware (8 actual CPUs, 33.2 GB RAM; Node 24.19.0 and the same Bun canary). Baseline standalone passed, confirming an order-sensitive cleanup race. The owner fix independently landed in #159163, commitd9fd43d6cf4286e1734e4a6ff91b962cb3e35e82; it awaits agent cleanup before shared-state teardown. Our equivalent repair passed twenty standalone and three full original-order runs; this is proof of the cleanup diagnosis, not a new production change in this PR.Previous publication head
5c2ed546a5bab56f8b736dfa48d1ca6d3660546ewas based on main8d3f946089b543d282765bdf15a7bc73d9e94330, containing both owner fixes. All three changed files are byte-identical to the reviewed/proved prior head. Required CI on this exact head remains the merge gate. The approved earliest-deadline contract has also landed in #159260, unblocking session delivery #159275.The refreshed head
5c2ed546a5bab56f8b736dfa48d1ca6d3660546ehit a separate failure in CI run 36282356610, job108517149230(checks-node-changed-compact-small-20):server.subagent-settle-replay.harness.test.tstimed out after 120 s while recovering public work through a sibling, followed by fixture-closing errors and a 300 s cleanup-hook timeout. The first 14-file Gateway group reported 13 passing files and one failed file, with 64 passing and two failed cases. On blacksmith-testbox leasetbx_01m3g6q6b7x9nvanv9zngc0r1q, run 36284825347, the unchanged historical CI mergeec90c688338b4fcb506b58e810a96daa17d9a361passed its exact ten-group manifest first: 271 files / 4,046 cases in 395.332 s. The standalone file then passed 12 cases in 54.058 s. The replay matched the original 32-class Blacksmith label, 8 actual logical CPUs, 33,229,729,792 bytes RAM, Node 24.19.0, pnpm 12.4.2, worker intersections and runtime policy. Both attempts retained the original source tree; neither used instrumentation, retries, altered assertions or longer timeouts. These are non-reproductions, not evidence of a fix. Source review found no safe additional repair. Fresh main incorporates the independently landed fixture-order fix, canonical fixture-root fix, and cleanup-owner changed06b334112a; the latter changes worker retirement and reader cleanup but is not a proved fix for this timeout. The original stall's cause remains unresolved, and the new head must pass ordinary enforced CI.Current publication head
e97be61a59974a519092524afb6f070ee0714f84is rebased onto mainb143de4dc63f059bf64b3543ec9529e55308f5a8, incorporating those landed owner changes. All three slice files are byte-identical to the reviewed/proved head; there is no test assertion or timer-policy change in this refresh.Scheduler stack
Earlier slices: diagnostic preparation #157517, auth factory naming #158275, kernel scheduler #158423, event-loop health #158531, channel health #158537, mention expiry #158614, upstream monitoring #158617, worker placement #158662, idle/prewarm #158666, Incognito expiry #158690, OAuth maintenance #158717, initial lifetime maintenance #158727, worker reconciliation #158812, PR subscriptions #158821, update checks #158909, Gmail renewal #158913, metadata capture maintenance #158959, and audit maintenance #158982.
This PR is the system-job retry followup after cron due-timer arming. The preceding due-timer #159099 and foreign-receipt #159114 slices are merged. Combined post-ready #159047 precedes this work.
Task maintenance #159038, generation #159042, approvals #159081, cold storage #159088, outbound recovery #159096, and periodic maintenance #159111 are merged. Media maintenance is merged in #159126. Remaining reviewed work includes diagnostic/SDK lifetimes, session delivery, and update watchers. Final timer exceptions and the merged-main Gateway/cron/suspend/shutdown proof follow the last slice.