Skip to content

perf(test): fast-forward cron receipt handoff - #124417

Merged
steipete merged 1 commit into
mainfrom
perf/cron-foreign-receipt-test
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/cron-foreign-receipt-test

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The cron durable-ownership handoff regression waits on real two-second monitor intervals while coordinating two external owner processes. The test must prove that the replacement receipt becomes the monitored authority and that its later death is recovered, but it does not need to spend four seconds of wall clock observing those parent-owned timers.

Why This Change Was Made

Keep both real child processes, the shared SQLite state, durable receipt replacement, process death, and final interrupted recovery. After the replacement process has claimed ownership, switch only the parent process to fake timers, isolate the foreign-receipt monitor from the ordinary cron job timer, advance each two-second monitor interval explicitly, and observe the exact replacement receipt in the monitor before killing its owner.

The immediate-yield poll does not advance fake timers, so it can distinguish asynchronous receipt enrollment from another elapsed monitor cycle. Production code and monitor timing remain unchanged.

User Impact

Maintainer cron test feedback is faster and the handoff proof is more deterministic. Runtime behavior is unchanged.

Evidence

Controlled same-Testbox A/B on tbx_01m04cmmjg6s60dwa9n79qxcn8, one excluded warmup plus two retained samples per state, one worker, distinct filesystem module caches, import diagnostics, and /usr/bin/time -v:

Metric Before After Gain
Wall 29.13s 25.36s -3.77s (-12.9%)
Vitest 26.21s 22.42s -14.5%
Test body 22.54s 18.82s -16.5%
Handoff case 6.98s 3.03s -56.6%
Import 3.05s 2.97s effectively flat

CPU and peak RSS were effectively flat, so this PR makes no resource-usage claim.

Validation:

  • 13/13 cron durable-ownership tests.
  • Full core changed gate on the retained Testbox, including core-test typecheck and targeted lint.
  • Fresh post-rebase Codex autoreview: no accepted/actionable findings.
  • Mutation: removing enrollForeignReceipt(state, result.receipt) from superseded-receipt recovery fails waiting for the exact replacement receipt to enter the monitor.
  • Production LOC: +0/-0; test LOC: +32/-4.

Testbox hydration run: https://github.com/openclaw/openclaw/actions/runs/31926297673

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 16, 2026 04:44
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head c0eb64c867c3540e5d459434d24c2c5b17cd2212:

  • Controlled same-Testbox A/B (tbx_01m04cmmjg6s60dwa9n79qxcn8; one excluded warmup, two retained samples per state, one worker, distinct module caches): wall 29.13s → 25.36s (-12.9%), Vitest 26.21s → 22.42s (-14.5%), test body 22.54s → 18.82s (-16.5%), handoff case 6.98s → 3.03s (-56.6%). CPU and RSS were flat.
  • The test retains two real child processes, shared SQLite state, durable receipt supersession, both process deaths, and final interrupted recovery; only the parent-owned monitor clock is advanced explicitly.
  • node scripts/run-vitest.mjs src/cron/service/owner-hardening.test.ts --maxWorkers=1 --reporter=default — 13 passed.
  • Full core changed gate passed on the retained Testbox, including core-test typecheck and targeted lint. The initial run found one Promise-executor lint issue; that line was corrected and the complete gate reran green.
  • Mutation proof: removing superseding-receipt enrollment fails waiting for the exact replacement receipt to enter the foreign monitor.
  • Fresh post-rebase autoreview: no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/31927346993 — all relevant checks green.
  • Native review artifacts validated with READY FOR /prepare-pr and zero findings.

No production code, docs, config, dependencies, or release surfaces changed. Production LOC: +0/-0; test LOC: +32/-4.

@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 Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 12:49 AM ET / 04:49 UTC.

ClawSweeper review

What this changes

The PR replaces real monitor-delay waits in the cron durable-ownership handoff test with parent-only fake-timer advancement while keeping the external processes and SQLite handoff real.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. No blocking correctness or security finding: the test preserves the real child-process and SQLite handoff, then advances only the parent monitor timeout. Likely related people: steipete (high confidence; introduced and recently maintained this cron ownership surface).

Priority: P3
Reviewed head: c0eb64c867c3540e5d459434d24c2c5b17cd2212

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, production-neutral test change with source-aligned assertions and reported Testbox validation.
Proof confidence 🌊 off-meta tidepool Not applicable: Maintainer-authored test-only change; the external-contributor real-behavior-proof gate does not apply, and the PR body supplies focused Testbox validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Maintainer-authored test-only change; the external-contributor real-behavior-proof gate does not apply, and the PR body supplies focused Testbox validation.
Evidence reviewed 7 items Changed test boundary: The branch switches to fake setTimeout/clearTimeout only after the replacement receipt exists, explicitly stops the ordinary cron timer, advances the monitor twice, and restores real timers in cleanup.
Monitor contract: The foreign-receipt monitor uses a bounded two-second setTimeout, clears it on stop, and reconciles the exact receipt set; this is the timer the test advances.
Recovery owner boundary: Lifecycle reconciliation iterates enrolled foreign receipts, replaces a superseded receipt with its successor, and re-arms scheduling only after the durable recovery result changes state.
Findings None None.
Security None None.

How this fits together

Cron persists run-receipt ownership in SQLite so another scheduler can monitor a foreign owner and recover interrupted work. This test exercises the handoff from one external owner to a replacement owner, then verifies the parent service records recovery after that owner exits.

flowchart LR
  A[First cron owner] --> B[SQLite run receipt]
  B --> C[Replacement owner]
  C --> D[Parent receipt monitor]
  D --> E[Owner exit reconciliation]
  E --> F[Interrupted run recovery]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; GitHub reports it cleanly mergeable, but landing should retain the normal exact-head merge-ref CI gate.
  • Complete next step (P2) - No repair lane is needed; the focused test change is sound and awaits the repository’s normal merge gating.
Agent review details

Security

None.

PR surface

Tests +28. Total +28 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 32 4 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 32 4 +28

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +32/-4 The change adds deterministic handoff observation and timer control only in the regression test, leaving runtime scheduling behavior unchanged.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the production monitor interval and land this focused test optimization once the normal exact-head merge gate is green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the production monitor interval and land this focused test optimization once the normal exact-head merge gate is green.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR improves the timing and determinism of an existing regression test rather than reporting a user-facing failure.

Is this the best way to solve the issue?

Yes. The change preserves real process and SQLite ownership transitions while advancing only the lifecycle-owned parent monitor; changing the production interval would alter runtime behavior without improving this test's contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0c7b560b2346.

Labels

Label changes:

  • add P3: This is a low-risk test-speed and determinism improvement with no intended user-facing runtime change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Maintainer-authored test-only change; the external-contributor real-behavior-proof gate does not apply, and the PR body supplies focused Testbox validation.

Label justifications:

  • P3: This is a low-risk test-speed and determinism improvement with no intended user-facing runtime change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Maintainer-authored test-only change; the external-contributor real-behavior-proof gate does not apply, and the PR body supplies focused Testbox validation.

Evidence

What I checked:

Likely related people:

  • steipete: Commit ca84950 introduced the foreign-receipt monitor, lifecycle owner, and original handoff regression test; the current PR refines that same test. (role: introduced behavior and recent area contributor; confidence: high; commits: ca849506f388, c0eb64c867c3; files: src/cron/service/owner-hardening.test.ts, src/cron/service/foreign-receipt-monitor.ts, src/cron/service/ops-lifecycle.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let normal exact-head merge-ref CI validate the clean merge after the base refresh.

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.

@steipete
steipete merged commit f1ca5e2 into main Aug 16, 2026
173 of 174 checks passed
@steipete
steipete deleted the perf/cron-foreign-receipt-test branch August 16, 2026 04:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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