Skip to content

fix(channels): avoid false silence and slow-listener reports after clock changes - #188452

Merged
obviyus merged 5 commits into
mainfrom
fix/channel-residual-elapsed-clocks
Oct 30, 2026
Merged

obviyus merged 5 commits into
mainfrom
fix/channel-residual-elapsed-clocks

Conversation

@obviyus

@obviyus obviyus commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

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 66004e076d4dcfb7e6d1ff14c1a894a03f475908 and 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 native performance.now(). Only process-local Date.now() was stepped; the system clock was never changed.

Two repetitions of each case on main and candidate:

Shipped path Main Candidate
IRC watchdog, +10-minute step while server sends regular receive pulses Both healthy sockets dropped at ~30.05 real seconds; diagnosed 605 seconds of silence Both sockets stayed connected
IRC watchdog, −1-hour step after registration, then actual silence No keepalive PING or disconnect after 330 real seconds PING at ~120.02 seconds; disconnect at ~240.25 seconds
Discord THREAD_UPDATE → actual thread listener → thread-members REST PUT, +1-hour completion step Two false diagnostic records per fast event; monitor reported 3,600,104 / 3,600,247 ms No slow-listener diagnostic from either layer
Same Discord path with a real 31-second rate-limit retry, −1-hour completion step Both duration layers missed the genuinely slow listener Both layers warned; monitor measured 31,221 / 31,282 ms

Controls: 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 head eb537c44591b987f9566b5c3364dd91f5eef09b6 (Git blob 09db4e2890641b5a8c849d6ecab0942015beac29). Discord was rebuilt and proved at 90114e74595ef8201cfb63f3ef2f94ee1fbc98bb after the generic-queue correction. The PR head has the identical tree and additionally preserves the contributor's rewritten 45180b4e commit, 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.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

Co-Authored-By: Claude Code <[email protected]>
(cherry picked from commit 45180b4)
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Built-Gateway clock differential: main 66004e076d4dcfb7e6d1ff14c1a894a03f475908; IRC candidate 4eb43fb104ac5b6632cfbceda5995cf1ade75c9a; complete Discord candidate 90114e74595ef8201cfb63f3ef2f94ee1fbc98bb. PR head eb537c44591b987f9566b5c3364dd91f5eef09b6 has the identical tree to the complete candidate and preserves the contributor's rewritten commit. IRC's production blob is unchanged between its proof and the final head.

Node 24.22.1 / Linux arm64 / secretless Docker
Native monotonic clock and timers; process-local Date.now offsets only

IRC actual Gateway monitor + local TCP server, repetitions 0 / 1:
                                      main                         candidate
healthy +10m watchdog step             closed at 30.047 / 30.046s    both stay connected
actual watchdog error                  'sent nothing for 605s'      no false timeout
silent -1h, observation at 330s         no PING; no disconnect       PING at 120.022 / 120.022s
silent -1h disconnect                  not detected                 240.246 / 240.246s
normal silence control disconnect      260.078 / 260.078s           260.085 / 260.085s

Discord actual WebSocket THREAD_UPDATE -> real listener -> thread-members PUT:
                                      main                         final candidate
fast +1h, outer elapsed                537 / 526ms                  432 / 592ms
fast +1h, monitor duration             3600104 / 3600247ms           no slow warning
fast +1h, diagnostic records           2 / 2                        0 / 0
slow -1h, outer elapsed                31486 / 31341ms               31621 / 31657ms
slow -1h, diagnostic records           0 / 0                        2 / 2
slow -1h, monitor duration             hidden                       31221 / 31282ms
normal fast control warnings           0 / 0                        0 / 0
normal ~31s control warnings           2 / 2                        2 / 2

Each slow operation: actual HTTP 429 retry_after=31, then a successful rejoin PUT.
Both warning records are intentional existing layers: monitor and generic EventQueue.
No diagnostics were filtered out to make the proof pass.

Owner unit regressions on main:
  IRC + private Discord: 7 failures / 41 passes (bounded run 10.96s)
  generic Discord queue: 2 failures / 12 passes
Candidate owner suites: 62 / 62 pass
Unchanged IRC monitor + Discord listener consumer suites: 47 / 47 pass
Production line delta: 0; test line delta: -1

The contributor-only Discord candidate still emitted [EventQueue] Slow listener detected: DiscordThreadUpdateListener took 3600110ms for event THREAD_UPDATE on the fast forward-step case. That observation led to including the adjacent generic queue clock pair, not hiding its output.

IRC's forward step was timed to one native watchdog callback by temporary observation hooks in both builds, changing the process-wide Date.now() value for that callback and restoring it immediately. The backward step remained active during the real silence interval. The four-minute timeout, two-minute PING threshold, 30-second watchdog interval, real 31-second Discord retry, and all monotonic clocks were unchanged. Discord used the supported loopback API endpoint with actual Gateway identify/READY/heartbeat/dispatch frames. No direct listener/helper invocation, provider credentials, host clock changes or permanent proof hooks were used. All proof Gateways and fixture servers stopped after capture.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro 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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The watchdog sends no keepalive PING and detects no disconnect during the supplied 330-second observation.
  • After: The watchdog sends PING after about 120 seconds and disconnects after about 240 seconds.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal, complete repair with shipped-entry-point differential proof, retained lifecycle regressions, and no actionable findings; required CI is still pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied Linux/Node 24 Docker terminal traces exercise built Gateway IRC monitoring over TCP and Discord THREAD_UPDATE over WebSocket through the real listener and REST retry, showing correct behavior for forward and backward Date.now steps plus ordinary controls; Git identities verify the exercised production code matches this head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Clock corrections can drop healthy IRC connections, delay silent-connection recovery, and fabricate or suppress Discord slow-listener warnings.
Reason: The maintainer-authored direction restores existing elapsed-time contracts without new configuration, public APIs, or persisted state.

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
Reviewed head: eb537c44591b987f9566b5c3364dd91f5eef09b6

Before merge

None.

Findings

None.

Agent review details

How this fits together

IRC 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]
Loading

Technical review

Best 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

  • IRC receive-silence watchdog keeps the original intent (129049b: Detect silent network drops and let the existing monitor reconnect, retaining cleanup on shutdown.)
  • Discord listener completion diagnostics keeps the original intent (150c048: Centralize listener timing and error handling; subsequent extraction and localization retained that responsibility.)
  • Discord generic queued listener timing keeps the original intent (d946c9f: Reuse shared FIFO permits while preserving physical listener settlement and existing diagnostics.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source 0, Tests -1. Total -1 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 7 7 0
Tests 3 40 41 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 47 48 -1

Root-cause cluster

Relationship: canonical
Canonical: #188452
Summary: This PR consolidates the two channel clock fixes; the previously merged timing repair changes different owners.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: Clock corrections can interrupt IRC connectivity or distort Discord diagnostics, with impact limited to these timing paths.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Clock corrections can interrupt IRC connectivity or distort Discord diagnostics, with impact limited to these timing paths.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

Reviewed October 30, 2026, 11:14 AM ET / 15:14 UTC.

@obviyus
obviyus merged commit b6b8ee3 into main Oct 30, 2026
119 checks passed
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in b6b8ee3. Thanks to the author of #188411 and #188412. Your fixes are included here.

@obviyus
obviyus deleted the fix/channel-residual-elapsed-clocks branch October 30, 2026 15:27
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: irc 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. size: S 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.

2 participants