Repository navigation
fix(channels): keep status deadline on the monotonic clock across wall-clock jumps - #177155
Conversation
…l-clock jumps Ref: BUG-178-channels-status-deadline-wall-clock (local finding)
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review blockedAutomated review did not run, so no review verdict was produced. Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here. Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update. Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it. |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
2e0eccc to
300c24d
Compare
@steipete — ClawSweeper input scan blocks review on a pre-existing redaction test fixtureCould you take a look? ClawSweeper keeps refusing this review with What is flaggedThe scanner flags the base blob of baseUrl: "https://runtime-user:[email protected]/?token=runtime-token"This line lives inside Why this PR is otherwise readyThe actual change here is unrelated: it switches the RequestPer the precedent in #1356 / #1745, this deliberate fixture needs to be qualified into the ClawSweeper allowlist so the review can proceed. I can prepare the exact native before/after proof (TruffleHog value digests, source line, committed base/head attribution) mirroring #1745, or open a qualify PR against clawsweeper if that helps. Thanks! |
|
Merged via squash.
|
|
Maintainer landing review for exact head
The PR body now describes the timeout and fake-timer evidence accurately. Source commits are unchanged. Credit to @SunnyShu0925 for the fix and regression coverage. Completion: RoboClaw merged this exact reviewed head concurrently at 2026-10-19 23:30:50 UTC as |
…l-clock jumps (openclaw#177155) Ref: BUG-178-channels-status-deadline-wall-clock (local finding)
What Problem This Solves
channels.statuscan mis-report a healthy channel as timed out when the host wall clock jumps forward, and can inflate the remaining budget passed to plugin hooks when the wall clock rolls back. Insrc/gateway/server-methods/channels.ts, the per-plugin status deadline was seeded and read withDate.now()(wall clock) while the outer status call is bounded byraceWithTimeoutusingsetTimeout. A wall-clock jump forward shrinksdeadline - Date.now()(a healthy channel gets fenced asstatus timed out), while a rollback inflates it (a plugin hook receives an inflated remaining budget; the outer timeout still bounds asynchronous status work).const deadline = Date.now() + timeoutMsseeds the deadline with the wall clock;remainingBudget = () => deadline - Date.now()reads it with the wall clock; the resultingremainingis passed astimeoutMsto plugin hooks, while the outerraceWithTimeoutuses the original bounded duration. A wall-clock correction (NTP, manual, or container clock adjustment) between the seed and each read shifts the budget.performance.now(), andMath.floorthe returned budget so downstreamAbortSignal.timeout/setTimeoutconsumers never receive a float. This matches the repo's canonical wall-clock-to-monotonic pattern (BUG-092/098/102/122 family).channels.tschannelsHandlers["channels.status"]— 1 deadline seed, 1 budget read, 2 deadline comparisons, 1Math.flooron the returned budget. Plus a regression test and two fixture adaptations inchannels.status.test.ts/channels.status.test-helpers.ts.Date.now()sites in this handler (lastProbeAt,now,ts) are wall-clock timestamps for display/recording, not deadline arithmetic.Why This Change Was Made
The channel status deadline is entirely in-process — it never persists, never crosses a process boundary, and is never compared against a wall-clock epoch by another process (0 sqlite/kysely/bridge/worker hits). So the monotonic clock is the only correct clock for it. This matches the repo convention for the same wall-clock-vs-monotonic class (#155603, #155648, #155323, and the merged BUG-092/098/102/122 family).
performance.now()is the minimal absorbed change; the singleremainingBudget()closure is the canonical owner of the budget, andMath.floorthere covers every downstream consumer (plugin hooks may pass the value toAbortSignal.timeout, which rejects floats).User Impact
channels.statusnow fences status probes at their configured budget regardless of wall-clock correction mid-check, instead of discarding healthy probe results after a forward jump or inflating hook budgets after a rollback. Behavior is otherwise identical.Evidence
Before / after — real
channels.statushandler, fake monotonic clockThe regression test drives the real
channelsHandlers["channels.status"]handler throughcreateChannelsStatusHarnesswith a 1000ms probe budget. It uses Vitest fake timers, lets the probe start, jumps the wall clock by ±60,000 ms (vi.setSystemTime, which changes wall time without advancing the fake monotonic clock), then advances the monotonic clock 600 ms. Only the deadline clock source differs between the runs.Date.now()performance.now()status timed out→probe: undefinedprobe: { ok: true }Pre-fix: a forward wall-clock jump of 60s makes
deadline - Date.now()negative, so the healthy channel's probe result is discarded and the channel is reportedrunningwith no probe. Post-fix: the monotonic deadline is unaffected by the wall-clock jump, and the healthy probe is preserved.Regression test RED / GREEN
The regression test arms a 1000ms probe deadline, lets the 500ms probe start, jumps the wall clock +60s, and advances the monotonic clock 600ms.
The RED assertion shows exactly the budget-collapse symptom: after a +60s wall jump, the healthy channel's
probeis dropped (probe: undefined) instead of{ ok: true }.What was not tested
timeoutMsas a wall-clock deadline; the fix keeps the value an integer number of remaining milliseconds, matching the pre-existing contract.Open PR collision check
Searched open PR topics and changed-file lists for
src/gateway/server-methods/channels.ts. No open PR touches this file or thechannels.statusdeadline path; the existing channels PRs (e.g. #172139, #161466, #172959) are unrelated refactors of other channel surfaces.