Skip to content

fix(cron): prevent run waits from failing after clock changes - #129805

Merged
steipete merged 1 commit into
mainfrom
codex/cron-wait-monotonic-clock
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cron-wait-monotonic-clock

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators running openclaw cron run --wait could receive an immediate false timeout after the system clock moved forward, or wait far beyond their requested deadline after the clock moved backward.

Why This Change Was Made

Measure the existing CLI wait deadline with the monotonic clock instead of wall time. Round elapsed milliseconds down before deriving each Gateway RPC timeout so fractional monotonic readings preserve the existing positive safe-integer timeout contract, including the initial poll for a zero-duration wait.

User Impact

Manual cron runs remain observable and respect their requested wait deadline across NTP corrections and manual system-clock changes. Explicit shorter RPC timeouts and zero-duration waits retain their existing behavior.

Evidence

  • Before: the existing real Commander cron CLI test exits with code 1 after a one-hour forward jump; a one-hour backward jump inflates a remaining 75ms deadline into a 600000ms Gateway timeout.
  • Before: a naive monotonic conversion without integer rounding fails all three unchanged/forward/backward regression cases by producing fractional Gateway timeouts.
  • After: the same table-driven CLI regression passes unchanged, forward-jump, and backward-jump scenarios with injected fractional monotonic readings and safe-integer timeout assertions.
  • Full affected suites: 219 passed across src/cli/cron-cli.test.ts and src/cli/cron-cli/register.cron-simple.test.ts.
  • Targeted formatting and strict lint pass; independent owner-boundary review and fresh automated review are clean.
  • The complete local changed-file gate passes 16 guards before unrelated existing dependency/type mismatches in Google finish reasons, markdown-it, and @earendil-works/pi-tui; exact-head hosted CI must validate the fresh dependency graph.
  • Production delta: +3/-3; regression tests: +14/-2.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 03:08
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 11:47 PM ET / August 26, 2026, 03:47 UTC.

ClawSweeper review

What this changes

This PR changes openclaw cron run --wait polling to use monotonic elapsed time and adds forward- and backward-system-clock-jump regression cases.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer handling: current main still measures the wait budget with wall time, while this focused patch moves that owner loop to monotonic elapsed time without a concrete regression found in review. The remaining exact-head check is still in progress.

Priority: P2
Reviewed head: 97d19f86ece3bb3266a66519a3007ce1cad993f0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-neutral owner-boundary repair with relevant regression coverage and no identified correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its body supplies focused after-fix test evidence, while hosted validation is still completing.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its body supplies focused after-fix test evidence, while hosted validation is still completing.
Evidence reviewed 6 items Current-main defect: Current main uses wall-clock subtraction at both wait-budget checks, so a system clock correction can incorrectly shorten or lengthen the polling deadline.
Patch owner-boundary repair: The proposed change replaces those elapsed-time reads with performance.now() and floors values before deriving the RPC timeout.
Timeout contract: Gateway timeout parsing accepts only positive safe integers; flooring monotonic milliseconds preserves that downstream contract.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.unit.config.ts src/cli/cron-cli.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs run --config test/vitest/vitest.unit.config.ts src/cli/cron-cli.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs run --config test/vitest/vitest.unit.config.ts src/cli/cron-cli.test.ts"

at-filter.browser-import.test.ts, src/auto-reply/heartbeat-filter.test.ts, src/auto-reply/heartbeat-reply-payload.test.ts, src/auto-reply/heartbeat-tool-respons
e.test.ts, src/auto-reply/heartbeat.test.ts, src/auto-reply/media-note.test.ts, src/auto-reply/model.test.ts, src/auto-reply/reply-payload.test.ts, src/auto-rep
ly/reply.directive.directive-behavior.prefers-alias-matches-fuzzy-selection-is-ambiguous.test.ts, src/auto-reply/reply.directive.directive-behavior.shows-curren
t-verbose-level-verbose-has-no.test.ts, src/auto-reply/reply.directive.parse.test.ts, src/auto-reply/reply.media-note.test.ts, src/auto-reply/reply.raw-body.tes
t.ts, src/auto-reply/reply/acp-stream-settings.test.ts, src/auto-reply/reply/agent-runner-command-output.test.ts, src/auto-reply/reply/agent-runner-context-reco
very.test.ts, src/auto-reply/reply/agent-runner-core.test.ts, src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts, src/auto-reply/reply/agent-runn
er-execution-cli-sessions.test.ts, src/auto-reply/reply/agent-runner-execution-runtime.test.ts, src/auto-reply/reply/agent-runner-execution-state.test.ts, src/a
uto-reply/reply/agent-runner-failure-reply.test.ts, src/auto-reply/reply/agent-runner-memory.dedup.test.ts, src/auto-reply/reply/agent-runner-presentation.test.
ts, src/auto-reply/reply/agent-runner-reminder-guard.test.ts, src/auto-reply/reply/agent-runner-runtime-config.test.ts, src/auto-reply/reply/agent-runner-usage-
line.test.ts, src/auto-reply/reply/block-reply-pipeline.multi-message.test.ts, src/auto-reply/reply/block-streaming.test.ts, src/auto-reply/reply/channel-run-ad
mission.test.ts, src/auto-reply/reply/command-context-rewrite.test.ts, src/auto-reply/reply/commands-acp/shared.test.ts, src/auto-reply/reply/commands-handlers.
registration.test.ts, src/auto-reply/reply/commands-learn.test.ts, src/auto-reply/reply/commands-loop.test.ts, src/auto-reply/reply/commands-openclaw-cli.test.t
s, src/auto-reply/reply/commands-parse.test.ts, src/auto-reply/reply/commands-reset-mode.test.ts, src/auto-reply/reply/commands-setunset.test.ts, src/auto-reply
/reply/commands-slash-parse.test.ts, src/auto-reply/reply/completion-delivery-policy.test.ts, src/auto-reply/reply/directive-handling.model-picker.test.ts, src/
auto-reply/reply/directive-handling.queue-validation.test.ts, src/auto-reply/reply/dispatch-from-config.final-outcome-counts.test.ts, src/auto-reply/reply/effec
tive-reply-route.test.ts, src/auto-reply/reply/get-reply-exec-overrides.test.ts, src/auto-reply/reply/get-reply-run-execute.test.ts, src/auto-reply/reply/get-re
ply-run-helpers.media-facts.test.ts, src/auto-reply/reply/history.test.ts, src/auto-reply/reply/inbound-context.test.ts, src/auto-reply/reply/inbound-media.test
.ts, src/auto-reply/reply/mcp-connect-channel-action.test.ts, src/auto-reply/reply/memory-flush.test.ts, src/auto-reply/reply/mentions.test.ts, src/auto-reply/r
eply/model-selection-directive.test.ts, src/auto-reply/reply/origin-routing.test.ts, src/auto-reply/reply/pending-final-delivery.test.ts, src/auto-reply/reply/p
rivate-message-tool-final.test.ts, src/auto-reply/reply/prompt-prelude.test.ts, src/auto-reply/reply/queue-policy.test.ts, src/auto-reply/reply/queue.media-carr
ier.test.ts, src/auto-reply/reply/queue/drain.client-caps.test.ts, src/auto-reply/reply/queue/drain.identity-guard.test.ts, src/auto-reply/reply/queue/settings.
test.ts, src/auto-reply/reply/queue/state.test.ts, src/auto-reply/reply/reply-elevated.test.ts, src/auto-reply/reply/reply-inline.test.ts, src/auto-reply/reply/
routing-policy.test.ts, src/auto-reply/reply/runtime-policy-session-key.test.ts, src/auto-reply/reply/session-delivery.test.ts, src/auto-reply/reply/session-ent
ry-persistence.test.ts, src/auto-reply/reply/sessions-yield-acknowledgment.test.ts, src/auto-reply/reply/source-reply-delivery-mode.test.ts, src/auto-reply/repl
y/source-turn-id.test.ts, src/auto-reply/reply/strip-inbound-meta.test.ts, src/auto-reply/reply/typing-policy.te
… output truncated …

Assertions:

  • FAIL expect_output: cron-cli.test.ts

How this fits together

The cron CLI starts a queued manual run, then polls the Gateway task ledger until it records a terminal status or the operator’s wait budget expires. The wait loop derives each polling RPC timeout and returns the final result to the CLI.

flowchart LR
  A[Operator runs cron command] --> B[CLI queues manual run]
  B --> C[Wait loop]
  C --> D[Monotonic elapsed-time budget]
  D --> E[Gateway run-history poll]
  E --> F{Terminal status?}
  F -->|yes| G[CLI prints completion]
  F -->|no| C
Loading

Decision needed

Question Recommendation
After the remaining exact-head check completes, should this member-authored cron CLI repair be landed against the refreshed main branch? Land after validation: Refresh against current main and land once the remaining exact-head check is green.

Why: The protected maintainer label and member authorship require explicit human handling even though the code review found no blocking defect.

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind current main, and one exact-head check remains in progress; refresh the merge result after that check completes.
  • Complete next step (P2) - No repair lane is needed because this PR already owns the narrow source-proven correction; it awaits normal exact-head validation and maintainer handling.
Agent review details

Security

None.

PR surface

Source 0, Tests +12. Total +12 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 3 0
Tests 1 14 2 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 17 5 +12

Review metrics

Metric Value Why it matters
Production versus regression-test delta production net 0; tests net +12 The repair replaces the timing source without production growth, while the added test coverage protects clock jumps and integer RPC timeouts.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the monotonic clock at the CLI wait-loop owner, retain integer timeout derivation, and land only after the remaining exact-head validation and maintainer review complete.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the monotonic clock at the CLI wait-loop owner, retain integer timeout derivation, and land only after the remaining exact-head validation and maintainer review complete.

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

Yes, by source: current main subtracts Date.now() in the wait loop, and the focused Commander regression changes wall time between polls to expose the false timeout or inflated remaining budget.

Is this the best way to solve the issue?

Yes. The wait loop owns the deadline, and monotonic elapsed time plus integer rounding fixes the clock-jump defect without changing gateway protocol or user configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 345cfde43dc9.

Labels

Label justifications:

  • P2: A clock correction can misreport or overextend a manual cron wait, but the impact is limited to the optional CLI wait path.
  • 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: This member-authored PR is exempt from the external-contributor proof gate; its body supplies focused after-fix test evidence, while hosted validation is still completing.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame for the affected wait loop and the recent feature history both identify Peter Steinberger; he also authored this focused follow-up. (role: recent area contributor and current wait-loop author; confidence: high; commits: 4048b57b7d25, 97d19f86ece3; files: src/cli/cron-cli/register.cron-simple.ts, src/cli/cron-cli.test.ts)

Rank-up moves

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

  • Let the remaining exact-head check complete, then refresh the merge result against current main.

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-08-26T03:14:30.930Z sha 97d19f8 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 3e0d9a6 into main Aug 26, 2026
297 of 299 checks passed
@steipete
steipete deleted the codex/cron-wait-monotonic-clock branch August 26, 2026 04:11
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (24 commits)
  fix(gateway): reject rootless session permission modes (#128149)
  docs(memory): document shipped turn-taint propagation for network tool output (#129837)
  fix(ui): pool reply-less wake activity into one chat rollup (#128442)
  fix(package): prevent installs from deleting validated runtime assets (#129724)
  fix(nodes): approve silent initial node surfaces and name the pending surface approval (#129795)
  fix(backup): preserve configured agent state roots (#129773)
  fix(ui): own chat history issuance with a closed state machine (#129776)
  fix(cron): preserve cancellation reason after late finalization (#129331)
  fix(cron): prevent run waits from failing after clock changes (#129805)
  fix(telegram): route commentary through one frozen progress owner (#128259)
  fix(release): start approved VCR mirror recovery jobs (#129829)
  test: complete current-plugin-metadata-snapshot mock factories (#129791)
  test(telegram): remove duplicate reaction case (#129848)
  fix(channels): honor supported account reply-threading policies (#129679)
  refactor(cli): deduplicate lazy subcommand registration (#129351)
  fix(ai): report interrupted local-model streams instead of empty success (#129794)
  refactor(cli): consolidate Gateway fallback and hook ownership (#129802)
  fix(qa): reject token confidence lanes without executed evidence (#129830)
  fix(tui): fence session state and delayed actions (#129810)
  fix(control-ui): keep task progress full width on hover (#129832)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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