Repository navigation
fix(channels): avoid false silence and slow-listener reports after clock changes - #188452
Conversation
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Co-Authored-By: Claude Code <[email protected]> (cherry picked from commit 45180b4)
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Built-Gateway clock differential: main The contributor-only Discord candidate still emitted IRC's forward step was timed to one native watchdog callback by temporary observation hooks in both builds, changing the process-wide |
|
Codex review: needs maintainer review before merge. What this changesThis PR uses monotonic elapsed time for IRC silence detection and both Discord slow-listener diagnostics. Example: The wall clock moves backward one hour after IRC registration, then the server becomes silent.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes current channel timing defects with a focused patch; no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherIRC receive traffic feeds the client's silence watchdog and existing reconnect monitor; Discord Gateway events pass through queued listeners and completion diagnostics. flowchart LR
A[IRC TCP traffic] --> B[Monotonic silence watchdog]
B --> C[Keepalive or reconnect monitor]
D[Discord Gateway events] --> E[Queued listener execution]
E --> F[Monotonic duration measurements]
F --> G[Slow listener diagnostics]
Technical reviewBest possible solution: Use performance.now() consistently within the existing duration owners while preserving thresholds, epoch timestamps, and recovery ownership. Do we have a high-confidence way to reproduce the issue? Current-main source exposes both clock-step failures, and supplied base-versus-candidate Gateway traces demonstrate them through the affected transports; this read-only review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair: replace the clock at each existing timestamp producer and consumer, including the generic Discord queue, without adding abstractions or changing policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4cc05039cfa1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource 0, Tests -1. Total -1 across 6 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 11:14 AM ET / 15:14 UTC. |
…ock changes (openclaw#188452) fix(irc,discord): measure remaining channel durations with a monotonic clock Follow-up to openclaw#188293. Three more in-process durations used wall-clock time, so a system clock jump changed their results: - IRC silence detection: a forward jump could drop a healthy connection, and a backward jump could hide real silence. - Discord slow-listener timing, in both the thread listener wrapper and the generic event queue: clock jumps could create false slow-listener warnings or hide a listener that was really slow. These durations now use `performance.now()`. Thresholds, APIs and persisted timestamps are unchanged. Evidence: built Gateway paths in secretless Docker on node:24.22.1, with `Date.now` stepped inside the process only, main twice and candidate twice. On main, IRC dropped healthy connections after forward steps and missed silence after backward steps; with this change it did neither. On main, the Discord thread listener and event queue warned about fast listeners and missed a real listener of about 31 seconds; with this change they did neither. Real silence and slow-listener controls were still detected. Details: openclaw#188452 (comment). Includes the fixes from openclaw#188411 and openclaw#188412, with their commits kept. Co-authored-by: chengzhichao-xydt <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Healthy IRC connections can be dropped, silent connections can go undetected, and Discord can fabricate or hide slow-listener warnings when the wall clock changes.
Related: #188411 and #188412. This combines chengzhichao-xydt's fixes and retains their contributor commits.
User Impact
IRC silence detection and Discord listener diagnostics follow elapsed time rather than system-clock corrections. Existing keepalive, disconnect and warning thresholds are unchanged; no configuration changes are required.
Why This Change Was Made
Use
performance.now()directly at the existing private duration owners, including the generic Discord event queue on the same shipped listener path. The real Gateway proof found that fixing only the monitor wrapper still left the generic queue reporting a fast listener as 3,600,110 ms. Both layers now use the same clock domain without adding an SDK export or changing APIs.Public and persisted epoch timestamps remain on
Date. Consolidated the regressions into the existing liveness, rejection and queue-ordering cases, retained shutdown/error/threshold assertions, and removed duplicate new cases and test allocations. Against the merge base: production 0 net lines; tests −1 net line.Evidence
Sanitized runtime capture and before/after results.
Built main
66004e076d4dcfb7e6d1ff14c1a894a03f475908and candidates in secretless Docker on Node 24.22.1. Proof used the built Gateway with explicit isolated profiles and owned state/config/database paths, real TCP/WebSocket/REST traffic, native timers and nativeperformance.now(). Only process-localDate.now()was stepped; the system clock was never changed.Two repetitions of each case on main and candidate:
THREAD_UPDATE→ actual thread listener → thread-members REST PUT, +1-hour completion stepControls: ordinary IRC silence still sent PING and disconnected after a real four-minute receive deadline (next 30-second check at ~260 seconds after the control's last receive). Ordinary fast Discord listeners did not warn; ordinary real 31-second listeners still warned in both layers. Each Discord event completed its actual thread rejoin REST operation. No helper was called directly, no threshold was shortened, and no timers or monotonic clock were accelerated.
The IRC forward step was synchronized to one native watchdog callback with temporary, symmetric observation hooks, then restored immediately, avoiding unrelated Gateway epoch-health recovery.
Date.now()changed process-wide during that window, not according to its caller. The backward step remained active during the real silence window. Those hooks are not in this PR.IRC runtime proof used built candidate
4eb43fb104ac5b6632cfbceda5995cf1ade75c9a; its IRC production file is byte-identical to PR headeb537c44591b987f9566b5c3364dd91f5eef09b6(Git blob09db4e2890641b5a8c849d6ecab0942015beac29). Discord was rebuilt and proved at90114e74595ef8201cfb63f3ef2f94ee1fbc98bbafter the generic-queue correction. The PR head has the identical tree and additionally preserves the contributor's rewritten45180b4ecommit, whose correction was already included. Runtime evidence is reused where inputs are unchanged.Final owner checks: 62/62 passed across the three clock owner suites. Unchanged IRC monitor and Discord listener consumers: 47/47 passed. Pre-fix regression replays: 7 failed / 41 passed for IRC/private Discord owners, and 2 failed / 12 passed for the generic Discord queue. The IRC negative controls fail in bounded time, not at the suite timeout. Changed-file formatting and lint passed.
Merge danger: two-way door; reverting restores the previous duration calculations without changing stored data or configuration. Blast radius is IRC silence/keepalive handling and Discord slow-listener diagnostics; public epoch fields, thresholds and other channels are untouched.