Skip to content

refactor(cron): schedule system-job reconciliation retries - #159129

Merged
steipete merged 1 commit into
mainfrom
hostneutral/scheduler-cron-system-0926
Sep 27, 2026
Merged

steipete merged 1 commit into
mainfrom
hostneutral/scheduler-cron-system-0926

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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 head b10dd2421727a29886d6ae4bd5f08b9ab0252b9e; exact-head CI attaches on publication. Candidate tree 998b4172698fc319ca28cf5be318f4922467ea94. 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 d4e7850dd56abcfb66ba8cda511378ff2f98c0da and exact tree 01f600d095ae1b4f703c7bc8565d4da72874c4da passed 2 file runs and 336 case executions in 56.510s command wall. These are recorded executions, not unique-case counts. Provider: blacksmith-testbox; lease tbx_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:

File Passed case executions Command wall
src/gateway/server-cron.test.ts 128 29.610s
src/gateway/server-reload-handlers.test.ts 208 26.900s

These 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-gate supplies 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, commit d9fd43d6cf4286e1734e4a6ff91b962cb3e35e82; 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 5c2ed546a5bab56f8b736dfa48d1ca6d3660546e was based on main 8d3f946089b543d282765bdf15a7bc73d9e94330, 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 5c2ed546a5bab56f8b736dfa48d1ca6d3660546e hit a separate failure in CI run 36282356610, job 108517149230 (checks-node-changed-compact-small-20): server.subagent-settle-replay.harness.test.ts timed 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 lease tbx_01m3g6q6b7x9nvanv9zngc0r1q, run 36284825347, the unchanged historical CI merge ec90c688338b4fcb506b58e810a96daa17d9a361 passed 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 change d06b334112a; 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 e97be61a59974a519092524afb6f070ee0714f84 is rebased onto main b143de4dc63f059bf64b3543ec9529e55308f5a8, 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.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Sep 26, 2026
@steipete
steipete enabled auto-merge (squash) September 26, 2026 19:42
@steipete
steipete force-pushed the hostneutral/scheduler-cron-system-0926 branch from b10dd24 to aba3339 Compare September 26, 2026 20:54
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 8:30 PM ET / September 27, 2026, 00:30 UTC (Revision 2).

ClawSweeper review

What this changes

The 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
Reviewed head: 5c2ed546a5bab56f8b736dfa48d1ca6d3660546e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrow and preserves the existing retry and lifecycle guards, with relevant integration evidence and no supported correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The review context identifies this as a member-authored internal refactor, so the contributor proof gate does not apply. The PR body reports earlier Testbox coverage of the production cron service with an injected SQLite failure and stored-row recovery; its linked workflow is cancelled overall, and no exact-head live Gateway run is claimed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The review context identifies this as a member-authored internal refactor, so the contributor proof gate does not apply. The PR body reports earlier Testbox coverage of the production cron service with an injected SQLite failure and stored-row recovery; its linked workflow is cancelled overall, and no exact-head live Gateway run is claimed. No stored-data contract changes.
Evidence reviewed 7 items Current main retains the separate retry: The fetched main revision still uses setTimeout and clearTimeout for the 30-second system-job retry.
Pinned PR change: The introduced hunk schedules the same 30-second retry through the required Gateway scheduler and retains epoch invalidation and cancellation.
Scheduler lifecycle: Cancellation removes only the matching job instance; one-shot jobs leave the registration before their callback runs, and scheduler stop joins pending callbacks.
Findings None None.
Security None None.

How this fits together

The 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests -3. Total -3 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 8 0
Tests 2 18 21 -3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 26 29 -3

Review metrics

None.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a bounded internal scheduling refactor with no claimed change to user-visible behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The review context identifies this as a member-authored internal refactor, so the contributor proof gate does not apply. The PR body reports earlier Testbox coverage of the production cron service with an injected SQLite failure and stored-row recovery; its linked workflow is cancelled overall, and no exact-head live Gateway run is claimed. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-26T21:00:59.261Z sha aba3339 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the hostneutral/scheduler-cron-system-0926 branch from 5c2ed54 to e97be61 Compare September 27, 2026 02:24
@steipete
steipete merged commit 9447cc6 into main Sep 27, 2026
205 checks passed
@steipete
steipete deleted the hostneutral/scheduler-cron-system-0926 branch September 27, 2026 02:39
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant