Skip to content

refactor(cron): schedule foreign receipt reconciliation - #159114

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

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

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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 head 63b90dfb04e0634966790b5622ce0cbbe9e24bbc; exact-head CI attaches on publication. Candidate tree ea84bd5824b9f1349c760f158aaafb836450f3a5. 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 36bf5e409bf16c4fff17d95d3753b5d1d40faf88 passed 3 file runs and 157 case executions in 75.778s 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/cron/service/owner-hardening.test.ts 14 28.701s
src/cron/service/run-receipt-settlement.test.ts 15 17.494s
src/gateway/server-cron.test.ts 128 29.583s

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.

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.

@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:10
@clawsweeper

clawsweeper Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 3:11 PM ET / 19:11 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 63b90dfb04e0634966790b5622ce0cbbe9e24bbc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch follows the existing scheduler contract and has meaningful lifecycle coverage, with no concrete review blocker found.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored internal refactor is exempt from the external contributor proof gate. The reported Testbox run exercises production cron recovery with child processes, SQLite receipts, and an injected scheduler clock as supplemental evidence; 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 member-authored internal refactor is exempt from the external contributor proof gate. The reported Testbox run exercises production cron recovery with child processes, SQLite receipts, and an injected scheduler clock as supplemental evidence; no stored-data contract changes.
Evidence reviewed 9 items Introduced monitor change: The pinned PR delta replaces the private timeout with a named periodic Gateway scheduler job and cancels it when the last foreign receipt settles.
Still needed on main: Current main retains the monitor's private setTimeout and rearm loop, so the central change is not already implemented there.
Scheduler contract: The existing scheduler supports named periodic jobs, cancellation, and joining pending work during shutdown.
Findings None None.
Security None None.

How this fits together

Cron 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +24. Total +29 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 15 +5
Tests 3 94 70 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 114 85 +29

Review metrics

None.

Technical review

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

Labels

Label changes:

  • add P3: This is a focused internal timer-ownership refactor with no claimed user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a focused internal timer-ownership refactor with no claimed user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 362cee1 adds src/infra/gateway-scheduler.ts:83 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 362cee12114d; files: src/infra/gateway-scheduler.ts)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant