Repository navigation
refactor(cron): schedule foreign receipt reconciliation - #159114
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 maintainer review before merge. Reviewed September 26, 2026, 3:11 PM ET / 19:11 UTC. ClawSweeper reviewWhat this changesThe cron service moves periodic checks of runs owned by another process onto the Gateway scheduler and updates receipt recovery tests to drive that shared clock. Merge readiness✅ Ready for maintainer review Keep open: current main still uses a private two-second receipt timer, and this PR is a distinct follow-up to the merged scheduler work. The inspected patch has no concrete blocking defect. Priority: P3 Review scores
Verification
How this fits togetherCron receipts identify active runs owned by another process. The Gateway cron monitor checks those receipts so recovery can settle them and release waiting runs. flowchart LR
A[Gateway cron service] --> B[Foreign receipt monitor]
B --> C[Gateway scheduler]
C --> D[Receipt reconciliation]
E[Receipt store] --> D
D --> E
D --> F[Waiting cron runs]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +5, Tests +24. Total +29 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the Gateway scheduler as the wake owner while preserving receipt recovery, waiter settlement, and cancellation across stop and reload. Do we have a high-confidence way to reproduce the issue? Not applicable: this is an internal refactor, not a reported runtime failure. Current-main source confirms the separate timeout it replaces. Is this the best way to solve the issue? Yes: the existing Gateway scheduler supports periodic jobs and joins pending work, and the PR keeps receipt reconciliation in its existing cron owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8d8bd43120f3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
Cron foreign-run receipt reconciliation owns a private two-second timeout outside the Gateway schedule.
User Impact
Existing foreign-receipt recovery behavior remains unchanged. Their wakes share the Gateway's next-wake and shutdown owner.
Why This Change Was Made
Use the required cron scheduler for the existing two-second reconciliation cadence. Cancel its job when the last foreign receipt settles and on monitor stop, removing the private timeout/unref/rearm loop. Existing receipt authority, reconciliation, waiter settlement and admitted-work ownership remain unchanged.
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 +20/−15/net +5; tests +94/−70/net +24; docs +0/−0/net 0.
Evidence
Reviewed refresh on main
f61e10a7f49798cd7a041ca3509d3a2c5e0b99bc, then mechanically rebased after the due-timer prerequisite merged. Publication head63b90dfb04e0634966790b5622ce0cbbe9e24bbc; exact-head CI attaches on publication. Candidate treeea84bd5824b9f1349c760f158aaafb836450f3a5. 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 tree36bf5e409bf16c4fff17d95d3753b5d1d40faf88passed 3 file runs and 157 case executions in 75.778s 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/cron/service/owner-hardening.test.tssrc/cron/service/run-receipt-settlement.test.tssrc/gateway/server-cron.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.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 foreign-receipt monitor followup after cron due-timer arming. The due-timer prerequisite is merged as #159099; system-job retry follows this slice. Combined post-ready #159047 precedes this work.
Task maintenance #159038, generation #159042, approvals #159081, cold storage #159088, and outbound recovery #159096 are merged. Periodic maintenance #159111 is pending. Remaining reviewed work includes media maintenance, diagnostic/SDK lifetimes, session delivery, update watchers, and cron system-job timing. Final timer exceptions and the merged-main Gateway/cron/suspend/shutdown proof follow the last slice.