Skip to content

fix: keep probe timings and cache windows stable across clock corrections - #190894

Merged
obviyus merged 17 commits into
mainfrom
fix/process-duration-clock-sweep
Nov 2, 2026
Merged

obviyus merged 17 commits into
mainfrom
fix/process-duration-clock-sweep

Conversation

@obviyus

@obviyus obviyus commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes misleading probe and timeout diagnostics, stale cached results, and premature context-breakdown retries when the host wall clock is corrected while OpenClaw is running.

User Impact

Operators get elapsed durations and cache/retry windows that follow actual time passed, rather than clock corrections. Stored session timestamps, report dates, public probe start/end epochs, timeout budgets, and SDK callback contracts remain unchanged. No configuration or state migration is required.

Why This Change Was Made

Use the existing process-local clock owner in core and the Control UI, and performance.now() inside extensions. Keep wall-clock readings only where an epoch is part of the existing contract. The usage-cache completion check also accepts a valid zero-valued monotonic reading.

Preserves the contributor commits by Alix-007, chengzhichao-xydt, and huwei-xydt from #190846, #190852, #190853, #187703, #187689, #187782, #187765, #189161, #189160, and #190098. Existing owner regressions cover freshness, cooldown, cancellation, timing snapshots, zero-valued clock readings, and retry backoff; duplicated clock-only fixtures and allocation notes are removed. Against frozen main dd96854d2e94c15b1e37946e962b27078a127f37: production +55/−38, tests net 0 lines, documentation +4/−3, wrapper inventory +1. The production growth is the existing clock imports, the separate public-epoch/elapsed readings, and explicit cache clock-domain names—not a new abstraction or exported SDK surface.

Evidence

Built Gateway and CLI artifacts in secretless Node 24.22.1 Docker; real Chromium for the Control UI. Each affected operator workflow was exercised twice on frozen main and twice on the candidate, with ordinary-flow controls. Clock proof uses process-local Date.now wall-clock steps, as in #188293; no system clock was changed and native elapsed clocks/timers were not accelerated.

  • Real Gateway sessions.usage and Pi catalog reads: main retained expired entries after a backward step; the candidate refreshed after the real 30-second TTL. A forward step caused premature usage refresh only on main. Persisted session epochs and Pi source files stayed unchanged.
  • Actual gateway probe, standalone models status --probe, Slack channels.status, and Brave webSearch.test: main reported negative or roughly 60-second-inflated durations; the candidate reported ordinary elapsed durations. Auth/refusal classifications and public wall-clock timestamps were preserved.
  • Anonymous GitHub repository search through projects.searchRemote: main refreshed too early after a forward step and stayed stale after a backward step; the candidate respected the real 60-second TTL in both directions.
  • Actual Telegram channels resolve timeout diagnostics: a forward step made main falsely report about 60 seconds of event-loop starvation; the candidate retained the real 15-second timeout without that hint. A genuinely blocked event-loop control still reported starvation.
  • Built Gateway Discord command deployment: native 15-second REST timeouts appeared as observed=0s/“was aborted” or observed=75s on main, but approximately 15 seconds/“timed out” on the candidate.
  • Real Chromium, seeded agent turn, and actual context-report RPCs: after a controlled transient wire failure, closing/reopening the popover across a forward step retried after 106/64 ms on main, versus 27,204/27,342 ms on the candidate. Ordinary controls waited about 27 seconds on both. The cached UI remained usable on both; screenshots are visual controls, while captured browser WebSocket frames establish retry timing. Stored report and session epochs were unchanged.

Slack, Discord, GitHub, Brave, Telegram, and model-provider peers were task-owned protocol fixtures, not live external accounts. Native client libraries, TLS verification through a task-trusted CONNECT peer where applicable, real request paths, real timer budgets, and captured wire payloads were retained. No live delivery is claimed.

Focused owner checks: 129 tests passed across 12 selected files, plus final zero-reading and unchanged-production consolidation checks; changed-file lint passed all 30 TypeScript files. Before/after screenshots and detailed runtime receipts.

Merge danger: two-way door; reverting restores the previous timing behavior without rewriting persisted data. Blast radius is process-local probe/timeout diagnostics, the shared stale-while-revalidate cache and its existing consumers, Pi candidate discovery, detailed usage-result caching, Discord deployment diagnostics, and the Control UI retry owner.

Alix-007 and others added 17 commits November 2, 2026 10:08
A wall-clock jump during pause made resume() compute a zero remaining
delay and fire the reconnect callback immediately.

Co-Authored-By: Claude Code <[email protected]>
ClawSweeper asked for context-report visibility + wall-clock evidence
beyond the bare retry-owner unit. Drive sessionContextReportsForGateway
through a retryable sessions.usage failure, hide, jump Date by one hour,
show, and assert the 30s backoff still holds.

Co-Authored-By: Claude Code <[email protected]>
Match the existing visibility/backoff test harness (full fake timers,
watch presented before refresh). Partial Date-only fake timers left a
checks-ui shard with request count 0 after refresh.

Co-Authored-By: Claude Code <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 2, 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 docs Improvements or additions to documentation channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: acpx extensions: opencode extensions: github GitHub plugin: link previews and reader labels Nov 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…ions (openclaw#190894)

fix: measure durations, timeouts and cache ages with the monotonic clock

Several timeouts, cache TTLs and retry backoffs measured elapsed time with the wall clock. When the system clock jumped (NTP correction, sleep and resume, manual change), they fired too early, never fired, or ignored server backoff. These callers now use the monotonic clock (`src/shared/monotonic-time.ts` in core, `performance.now()` in extensions). Stored and displayed timestamps stay on the wall clock, and SDK signatures and public epochs are unchanged.

This sweep includes openclaw#190846, openclaw#190852, openclaw#190853, openclaw#187703, openclaw#187689, openclaw#187782, openclaw#187765, openclaw#189161, openclaw#189160 and openclaw#190098, with the contributors' commits kept for credit.

Evidence: built Gateway, CLI and real Chromium, main twice and candidate twice, stepping only the process wall clock (`Date.now`); no system clock change. On main, a Discord deployment timeout aborted or overran after a 60-second step, the Chromium context popover retried after about 100 ms despite server backoff, and the `sessions.usage`, Pi session catalog and GitHub project caches refreshed too early or too late. With this change, each followed real elapsed time. Ordinary controls passed, and epoch timestamps were unchanged. Details: openclaw#190894 (comment).

Thanks @Alix-007, @chengzhichao-xydt, @huwei-xydt.

Co-authored-by: Alix-007 <[email protected]>
Co-authored-by: chengzhichao-xydt <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Co-authored-by: 胡伟0668000622 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram commands Command implementations docs Improvements or additions to documentation extensions: acpx extensions: github GitHub plugin: link previews and reader extensions: opencode gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M 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.

4 participants