Repository navigation
fix: preserve operation budgets across wall-clock changes - #186484
Merged
Merged
Conversation
…otonic clock Seed and consume the provider-operation deadline with performance.now() instead of the wall clock, so a host clock jump (NTP correction, VM pause/resume) no longer corrupts the remaining-time budget. This is the canonical owner of the deadline, so it heals all 30+ media-understanding providers at once. Keeps the deadline payload, timeout policy, and downstream provider helpers unchanged.
…onic clock reconcileSubagentAgentDispatch anchored its reconciliation deadline and the remaining-budget reads to Date.now() (wall clock), then fed the result into two monotonic consumers: the Gateway RPC timeout (callGateway timeoutMs) and the inter-iteration delay (node:timers/promises setTimeout). A wall-clock step (NTP sync) landing between two loop iterations distorts remainingMs: a forward step shrinks it below zero and prematurely kills a healthy reconciliation, while a backward step stretches the Gateway timeout and the delay well past the intended budget. The deadline is a pure in-process closure variable (never serialized, persisted, or reported across processes), so it is safe to anchor to performance.now(). All three reads now use the monotonic clock, keeping the budget stable across wall steps. Regression test drives the reconcile loop through callNativeSubagentGateway and steps Date.now() forward 10s between two iterations; pre-fix it aborts with "gateway timeout after 5000ms", post-fix the run is admitted and the per-call Gateway RPC timeout stays at the 800ms interval cap.
…ic clock NodeHostStatsCheckpoints throttles host-telemetry persistence to one write per node every five minutes, and that deadline was read from the wall clock both when arming the timer and again in the callback. A backward system-clock correction therefore left the checkpoint slipping by the size of the correction. Pair each received sample's persisted receipt with the monotonic clock while the two are still in sync (record), snapshot that deadline with the sample being written, and promote it once the write succeeds. The timer delay, the fire-time check, and every later schedule reuse the stored deadline instead of re-reading the wall clock. Capturing at receipt (rather than at write time) matters because the timer writes a buffered sample: converting when that write completes would fold a clock step that happened since the sample was received into the following budget. Later schedules must also not re-derive the deadline, or a report arriving after a jump (the normal 60s telemetry cadence) or a timer firing a millisecond early would push an armed deadline out. updatedAtMs stays a persisted wall-clock epoch; the monotonic deadline is in-memory only and the public API (record / forget / close) is unchanged. Regression coverage folds three cases into the existing host stats checkpoints suite: a backward jump with the node going quiet, with telemetry still arriving, and a write that follows the jump, each asserting nothing persists before the armed deadline and the next checkpoint stays anchored to its receipt.
…ttle deadline abortAndDrainCapturedEmbeddedAgentRun seeded its settle deadline from Date.now() and computed the remaining budget with Date.now(), but the budget is consumed by monotonic setTimeout/AbortSignal.timeout paths (waitForCapturedSessionNativeAttemptEnd / waitForReplyOperationOwnerSettlement). A wall-clock rollback between the seed and the read inflates the budget, stretching stuck-recovery owner settlement far past its configured window. Use performance.now() for both the seed and the remaining-budget read so the deadline stays in the monotonic clock domain of its consumers.
…onic clock reconcileSubagentAgentDispatch anchored its reconciliation deadline and the remaining-budget reads to Date.now() (wall clock), then fed the result into two monotonic consumers: the Gateway RPC timeout (callGateway timeoutMs) and the inter-iteration delay (node:timers/promises setTimeout). A wall-clock step (NTP sync) landing between two loop iterations distorts remainingMs: a forward step shrinks it below zero and prematurely kills a healthy reconciliation, while a backward step stretches the Gateway timeout and the delay well past the intended budget. The deadline is a pure in-process closure variable (never serialized, persisted, or reported across processes), so it is safe to anchor to performance.now(). All three reads now use the monotonic clock, keeping the budget stable across wall steps. The regression folds into the existing ambiguous-dispatch reconcile case: its pending replay steps Date.now() forward 10s and the case still requires the admitted run plus the 800ms per-call Gateway RPC cap, so the suite keeps its real 800ms interval wait and adds no test lines.
Contributor
|
🦞👀 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. |
obviyus
added a commit
that referenced
this pull request
Oct 28, 2026
…lock (#186531) fix(team-reports): keep the report worker's reply budget on the monotonic clock The Team Reports runner measured the time left for a worker reply with Date.now, so a forward wall-clock step made a healthy report worker time out. The budget now uses performance.now, as the other extension budgets have since the #186484 sweep. Evidence: real built Gateway with the Team Reports plugin enabled, native report and SQLite workers, and a local HTTP summary provider. With Date.now stepped forward 2 hours inside the process only, main failed with "worker task timed out" (twice); with this change the reports succeeded (twice). No-step controls succeeded twice on each ref, and all successful runs stored valid summaries. Details: #186531 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus
added a commit
that referenced
this pull request
Oct 29, 2026
…6829) fix(memory-core): keep the session-index deadline on the monotonic clock The memory session-index pass recomputed its pending publication deadline with Date.now, so a forward wall-clock step made the index publish early (or a backward step delayed it). The three memory-core deadline sites now use performance.now(), as the other extension budgets do since #186484. Evidence: built Gateway with real transcript appends and SQLite FTS publication. At 280 s on the monotonic clock, Date.now was stepped forward 120 s inside the process only, followed by another real append. Main rearmed for 0 ms and published at once (twice); with this change it rearmed for 20,000 ms, was still unpublished at 299,999 ms and published at 300 s (twice). No-step controls published at 300 s on both refs, and memory search found the marker in every run. Details: #186829 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus
added a commit
that referenced
this pull request
Oct 29, 2026
…lock (#186850) fix(browser): keep the download quiet window on the monotonic clock The browser plugin measured the download quiet window with Date.now, so a forward wall-clock step while a download was in progress ended the window early and a following download was missed. The window now uses performance.now(), as the other extension budgets do since #186484. Evidence: built Gateway with real Chromium over the browser HTTP bridge. A process-local +10 s Date.now step was placed between the window's timestamp write and its elapsed-time read, and logs confirm the order. Main missed the second download (twice); with this change both files were captured (twice). No-step controls captured both on each ref, and the system clock was not touched. Details: #186850 (comment). Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
…86484) fix: measure deadlines and budgets on one monotonic clock owner Many deadline, budget and timeout calculations used Date.now(), so a wall-clock step (NTP correction, VM resume, manual change) made them expire early or run long. Contributors had been fixing these one call site at a time. Core now has one owner, src/shared/monotonic-time.ts, for process-local deadlines and elapsed time, replacing the supervisor-local helper and the per-site variants. Bundled extensions use performance.now() directly. Wall-clock values stay where they are persisted, shown to users or exchanged between processes: the public provider deadline stays epoch-valued, with monotonic enforcement kept privately, and the plugin SDK facade is unchanged. This absorbs the per-site fixes from @SunnyShu0925 (openclaw#186039, openclaw#186134, openclaw#186412, openclaw#184716, openclaw#184613) and @mikasa0818 (openclaw#184576, openclaw#184525, openclaw#182064), whose original commits are kept. Update, Doctor, Windows-only and security-held sites are listed under "Not fixed here" in the PR. Evidence: built CLI suspend wait, browser Gateway CDP waits, Discord READY wait and node host-stats checkpoint, each with Date.now stepped inside the process only. On main each misbehaved under the clock step (early expiry or a stretched wait); with this change each matched the no-step control. Media generation's guard blocks local fixtures, so that family relies on the shared owner's regression. Production 479 changed lines, tests net 0. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: mikasa0818 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
…186679) test(deepgram): fake the monotonic clock in the audio-flux deadline test openclaw#186484 (f4034e1) moved provider operation budgets onto the monotonic clock. The Deepgram audio-flux deadline test faked Date and timers but not performance, so its fake-time advances no longer used up the budget, and the "keeps decoding" case hung until the 120 s test timeout. It failed on every pull request whose CI selected the Deepgram lane. The fixture now also fakes performance. Production code is unchanged. Evidence: the full test file passed 5 of 5 runs on 4996b42 (before the sweep), failed 5 of 5 on f4034e1 and on main 20badbb, and passed 3 of 3 with this change. The hosted Deepgram lane passed 10 tests, with the deadline case in 1176 ms. The other files the sweep touched were checked, and none fail the same way. Details: openclaw#186679 (comment). Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
…penclaw#177179) fix(gateway): keep queued RPC deadlines on the monotonic clock Queued work from RPC sources measured its deadline with Date.now, so a wall-clock step made queued items expire early (clock moved forward) or run after they should have expired (clock moved back). The deadline now uses the shared monotonic owner, src/shared/monotonic-time.ts, from the openclaw#186484 sweep. Evidence: built Gateway differential with Date.now stepped inside the process only. On main, queued work that had expired still ran after a backward step, and work expired early after a forward step (twice each); with this change the elapsed budgets held, and the no-step control behaves the same on both refs. Details: openclaw#177179 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
…lock (openclaw#186531) fix(team-reports): keep the report worker's reply budget on the monotonic clock The Team Reports runner measured the time left for a worker reply with Date.now, so a forward wall-clock step made a healthy report worker time out. The budget now uses performance.now, as the other extension budgets have since the openclaw#186484 sweep. Evidence: real built Gateway with the Team Reports plugin enabled, native report and SQLite workers, and a local HTTP summary provider. With Date.now stepped forward 2 hours inside the process only, main failed with "worker task timed out" (twice); with this change the reports succeeded (twice). No-step controls succeeded twice on each ref, and all successful runs stored valid summaries. Details: openclaw#186531 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
…nclaw#186829) fix(memory-core): keep the session-index deadline on the monotonic clock The memory session-index pass recomputed its pending publication deadline with Date.now, so a forward wall-clock step made the index publish early (or a backward step delayed it). The three memory-core deadline sites now use performance.now(), as the other extension budgets do since openclaw#186484. Evidence: built Gateway with real transcript appends and SQLite FTS publication. At 280 s on the monotonic clock, Date.now was stepped forward 120 s inside the process only, followed by another real append. Main rearmed for 0 ms and published at once (twice); with this change it rearmed for 20,000 ms, was still unpublished at 299,999 ms and published at 300 s (twice). No-step controls published at 300 s on both refs, and memory search found the marker in every run. Details: openclaw#186829 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
…lock (openclaw#186850) fix(browser): keep the download quiet window on the monotonic clock The browser plugin measured the download quiet window with Date.now, so a forward wall-clock step while a download was in progress ended the window early and a following download was missed. The window now uses performance.now(), as the other extension budgets do since openclaw#186484. Evidence: built Gateway with real Chromium over the browser HTTP bridge. A process-local +10 s Date.now step was placed between the window's timestamp write and its elapsed-time read, and logs confirm the order. Main missed the second download (twice); with this change both files were captured (twice). No-step controls captured both on each ref, and the system clock was not touched. Details: openclaw#186850 (comment). Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
This was referenced Oct 29, 2026
This was referenced Oct 29, 2026
This was referenced Oct 31, 2026
This was referenced Nov 14, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes premature timeouts, extended waits, and delayed node-stat checkpoints when the wall clock changes during an operation.
User Impact
Selected browser, media, agent, Gateway, and CLI operations keep their original elapsed-time budgets across NTP corrections or manual clock changes. Persisted timestamps and user-facing dates keep their existing meaning. This is a bounded first cutover, not a claim that every wall-clock elapsed measurement in OpenClaw is fixed.
Why This Change Was Made
src/shared/monotonic-time.tsowns core process-local clock readings and primitive deadline arithmetic. Bundled extensions use the platform'sperformance.now()directly, without adding plugin SDK exports. The supervisor-local allocating deadline helper is removed. Existing operation owners still control normalization, polling, pause/resume, cancellation, and rounding; no timeout ceiling changes.The shipped provider-operation DTO remains epoch-valued and serializable. Its
owner keeps private monotonic anchors across bundled SDK chunks; legacy/frozen
or deserialized DTOs are translated on admission, and public epoch edits are
honored. MCP normalizes fractional remaining time at its native integer-only
timeout boundary. Neither change adds a public field or changes a timeout ceiling.
Original contributor fix commits are preserved before the owner cutover. Credit to SunnyShu0925 and mikasa0818.
Absorbed sites
Source-PR audit: the five Sunny PRs are now closed externally, unmerged. The
three mikasa PRs remain open and are covered for closure after this lands.
None had assignees or maintainer-authored commits; original authorship is retained.
The same owner also replaces local clock reads from the already-merged fixes #182778, #169360, #184212, #184293, #184116, #185704, #185753, #186037, #186388, #186390, #185290, #185327, #184711, and #185146. Their existing epoch/reporting conversions remain intact.
Additional mechanical local waits: browser launch/navigation/tab discovery/action/download budgets; MCP initialization; Claw agent availability and plugin reload clients; Control UI document/onboarding observation; Gateway CI-detail request and node dispatch drain budgets; ClawHub skill download, APNs tunnel, and Tailscale readiness; meeting audio/speech prerequisites; node-worker exit; setup recommendation search; FaceTime helper authentication, Google Meet browser creation, Slack startup authentication, and shared transport/QA health waits.
Not fixed here
Evidence
Sanitized clock-step captures and detailed boundaries.
CI fixture repairs and inherited-blocker comparisons.
Runtime builds and focused checks run in secretless
node:24.22.1Docker isolation. Clock steps are injected by overridingDate.now()inside only the process under test; native timers,performance.now(), and the host/system clock are unchanged.gateway suspend --wait 1against a busy Gateway fixturebrowser openagainst synthetic CDPdevice.pair.listThe media Gateway attempt reached
video_generate, but fal's SSRF policy rejectedthe loopback fixture and then its explicit proxy endpoint, including with HTTPS
and a task-owned CA. No guard was bypassed. Media therefore uses the shared-owner
regression above plus the provider consumer suite. Subagent reconciliation has
an owning spawn-seam regression that fails on main and passes here; it was not
independently triggered through a shipped command. Buzz's authenticated
post-write setup hook and embedded stuck-recovery phase likewise use the shared
clock regression and focused consumer suites, not an unobserved E2E claim.
No daemon paths are changed.
Latest no-export cutover rerun: 430 passed across 28 files, including browser, Buzz, Discord, memory, Slack, FaceTime, and internal QA consumers. Earlier timing-consumer checks passed 570 cases across 35 files, retaining 1 existing platform/root-dependent skip.
The nested browser pause and ambiguous subagent dispatch regressions fail on
the original implementation for their intended timeout/acceptance assertions.
Both runtime builds, targeted Oxfmt/Oxlint (including the repaired browser test's type-aware lint), and
git diff --checkpassed.Against the merge base: production +291/−188 (479 changed, net +103), tests
+121/−121 (net 0), docs +10. Growth is primarily core shared imports,
private provider anchors, and separate node receipt/deadline state; the old
allocating helper is removed. No code/test/timeout ceiling or baseline is
increased. The time-runtime facade is byte-identical to base; internal QA and
transport-ready facade edits preserve their exported signatures byte-for-byte.
Changed-test wall durations with one worker: browser 0.47s, spawn 9.27s,
onboarding 4.86s, fal 6.69s, provider deadlines 0.72s, node checkpoints 0.65s,
suspend CLI 0.46s, supervisor subprocess 15.52s. The supervisor case exercises
the real native process-group retirement grace. Hosted CI timings are reported
by the checks on this PR.
The first completed CI run
found Date-controlled consumer fixtures and a typed Promise-rejection issue;
those are repaired and passed focused checks without production changes.
Two unrelated failures also reproduce on both the pristine base and candidate:
Shared-state admission requires the host broker.replyToIdis undefined at the existing reply assertion.Neither unrelated path is changed or suppressed here. The completed run has
zero cancelled jobs; a green aggregate CI gate is not claimed.
The next completed run, 40630944182
at
74422ea, confirms the repaired fixture/lint jobs pass. Its aggregate is redwith zero cancelled jobs: the same broker and reply failures, plus
plugin capture custody
(
plugin-source-capture-directory.test.ts, missing legacyindex.cjs).The latter is in an untouched path and has no established base attribution;
it is not silently classified as inherited or patched here.
For that third red, pristine-base attribution checks pass: 34/34 complete-suite
cases and ten independent custody runs (30/30 cases). The hosted ENOENT therefore
remains un-attributed, not proven inherited and not override-ready on that basis.
Final-head run 40634354654
at
f706ffd5892d9fa1ca6d12c67ea5c5e9e36d34a8is completed. Its only twofailing test jobs exactly match the proven base/candidate broker and QA reply
receipts; zero jobs were cancelled. The legacy capture ENOENT does not fail
this final run. The raw aggregate gate remains red; the maintainer owns any
override. Exact final-job matches.
The final head has been reviewed ready at 4/6.
Revert is a two-way door: no stored-data or config migration. Blast radius is local timeout/cadence enforcement in the listed callers plus plugins using the shared provider-operation deadline contract; an incorrect clock-domain conversion can cause premature or extended waits.