Skip to content

fix(daemon): keep scheduled-task fallback waits on the monotonic clock - #182859

Merged
steipete merged 2 commits into
openclaw:mainfrom
mikasa0818:fix/problem-schtasks-monotonic-fallback-waits
Oct 26, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
mikasa0818:fix/problem-schtasks-monotonic-fallback-waits

Conversation

@mikasa0818

@mikasa0818 mikasa0818 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Windows service takeover can keep waiting long after its intended budget when the system clock moves backward during startup or restart.

User Impact

The Scheduler evidence wait and Startup login-item reprobe retain their existing elapsed-time budgets across clock corrections.

Why This Change Was Made

Use the same monotonic clock as the other runtime inspection deadlines. Keep the existing takeover decisions, native probe allowances, and process ownership checks.

Thanks to @mikasa0818 for the original fix and supplied Windows trace. The contributor's commits are preserved.

Evidence

  • Regression proof exercises both production wait owners and rewinds Date.now by ten minutes after each wait starts. Both regressions remained pending at their deadline with the original wall-clock code; all 93 runtime, deadline, and startup-fallback tests pass with the fix. The new cases took 15 ms combined; the full targeted command took 57.04 seconds, mostly cold compilation.
  • The existing native-probe deadline cases and startup fallback consumer tests remain covered. The virtual elapsed clock in the consumer fixture follows performance.now.
  • The contributor supplied a real Windows Task Scheduler trace showing the old 15-second evidence wait still pending beyond 30 seconds after a rewind, versus about 15.4 seconds with the fix. That trace has no linked run and was not independently reproduced.
  • Native Windows service takeover was not live-tested in this pass: this host is macOS, and the focused production-owner tests provide the regression proof without a new Windows harness.
  • Production LOC delta: 0; tests: +37; documentation: +3. Removed the redundant standalone regression file. Targeted oxlint and oxfmt pass.
  • Independent P2 review found no actionable issues. Exact-head CI run 40249262048 passed.
  • ClawSweeper found no code defects on the final head but requested an inspectable native Windows artifact. That live-proof gap remains: the supplied trace is unlinked and the local regressions mock native I/O.

@clawsweeper

clawsweeper Bot commented Oct 24, 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 Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR measures Windows Scheduler evidence and Startup fallback waits with a monotonic clock.

Example: The wall clock moves backward ten minutes during the 15-second Scheduler evidence wait.

  • Before: The deadline can remain pending for roughly ten additional minutes.
  • After: The clock correction no longer extends the elapsed-time deadline.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch appears correct, but the available narrative and mocked tests do not satisfy the required real-behavior proof gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Windows service takeover can wait too long or give up early when the system clock changes.
Reason: The patch restores the existing elapsed-time contract without changing configuration, public APIs, or takeover policy.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR repairs a current-main deadline bug with a focused change; no actionable code defects were found.

Priority: P2
Reviewed head: 47dda5e97e21936269d8ed4457651a6e6aec0102

Before merge

  • Add real behavior proof - The two changed runtime owners are exercised by tests with mocked native I/O, while the Windows before/after result appears only as an unlinked narrative summary. Provide inspectable terminal output, redacted logs, or a linked artifact showing the changed waits during Windows takeover with a clock correction and their after-fix results; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Inspectable Windows runtime evidence is still needed for clock corrections during Scheduler evidence and Startup fallback reprobes; the body reports baseline failures, but this review did not run them.
Agent review details

How this fits together

Windows service installation and restart consume runtime observations from the scheduled-task owner to complete takeover, retain a fallback, or report failure.

flowchart TD
  A[Windows install or restart] --> B[Scheduled task runtime owner]
  B --> C[Monotonic wait deadline]
  B --> D[Task Scheduler probe]
  B --> E[Startup process inspection]
  D --> F[Takeover result]
  E --> F
  C --> F
Loading

Technical review

Best possible solution:

Use performance.now consistently in the existing wait owners while preserving their probe, fallback, and process-ownership rules.

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

Current-main source directly establishes the clock-domain failure, and the PR reports red-to-green rewind regressions; no target code was executed during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete repair: it changes the deadline clock in the existing owners and adapts their tests without introducing state, wrappers, or competing policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 286b334736db.

Provenance checked

  • Scheduler evidence deadline keeps the original intent (244d441: Registered-service inspection passes the remaining allowance to native probes and requires current Scheduler running evidence; the earlier runtime split carried the existing deadline.)
  • Startup fallback reprobe deadline keeps the original intent (cb099f5: The runtime split preserved fallback takeover behavior; the earlier fallback repair deliberately bounded reprobes and retained process-ownership checks.)
  • Native deadline tests and consumer clock fixture keeps the original intent (244d441: Tests distinguish timely evidence from hung or late inspection; changing their simulated elapsed clock preserves those independent outcomes.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 244d441 adds src/daemon/schtasks-runtime.ts:161 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 244d44197232; files: src/daemon/schtasks-runtime.ts)

PR surface

Source 0, Tests +37, Docs +3. Total +40 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 5 0
Tests 2 42 5 +37
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 50 10 +40

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: Clock corrections can substantially delay or prematurely end Windows takeover waits, with impact limited to these service lifecycle paths.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-24T20:37:31.477Z sha 439583ed868d7b2111e5d7fa4f9ee287e0a640fc :: needs changes before merge. :: [P3] Use injected clocks for the committed rewind regression
  • reviewed 2026-10-25T18:04:39.366Z sha 16adf28 :: needs maintainer review before merge. :: none

Reviewed October 25, 2026, 8:29 PM ET / October 26, 2026, 00:29 UTC (Revision 3).

@mikasa0818
mikasa0818 force-pushed the fix/problem-schtasks-monotonic-fallback-waits branch from 439583e to 16adf28 Compare October 25, 2026 17:59
@mikasa0818

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 25, 2026
Use the existing monotonic clock for Scheduler evidence and Startup reprobe
budgets. Cover a wall-clock rewind during each wait and retain the native
probe deadline boundaries and startup fallback consumer fixtures.

Co-authored-by: mikasa0818 <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@steipete
steipete merged commit 871e7cb into openclaw:main Oct 26, 2026
154 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
openclaw#182859)

Use the existing monotonic clock for Scheduler evidence and Startup reprobe budgets so a backward wall-clock correction cannot extend scheduled-task fallback waits.

Retain the native probe deadline boundaries and startup fallback consumer fixtures, and cover clock rewinds at both owning waits. All 93 focused tests and exact-head CI passed. Native Windows takeover was not independently live-tested.

Co-authored-by: mikasa0818 <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
#182859)

Use the existing monotonic clock for Scheduler evidence and Startup reprobe budgets so a backward wall-clock correction cannot extend scheduled-task fallback waits.

Retain the native probe deadline boundaries and startup fallback consumer fixtures, and cover clock rewinds at both owning waits. All 93 focused tests and exact-head CI passed. Native Windows takeover was not independently live-tested.

Co-authored-by: mikasa0818 <[email protected]>

(cherry picked from commit 871e7cb)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants