Repository navigation
fix(irc): reset reconnect backoff across clock changes - #188237
chengzhichao-xydt wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Code <[email protected]>
|
🦞👀 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. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR measures IRC connection stability with a monotonic clock so wall-clock changes cannot incorrectly reset reconnect backoff. Example: With jitter disabled, an IRC connection lasts 10 seconds while the system clock jumps forward one hour after an earlier failed connection.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it fixes a concrete current-main bug with a focused change that preserves the existing reconnect policy; no introduced correctness defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe IRC monitor records successful connections and asks the plugin-local backoff owner for a delay after disconnects; that delay schedules the next real IRC connection attempt. flowchart LR
A[IRC socket connects] --> B[IRC monitor]
B --> C[Record monotonic connection time]
D[Socket disconnects] --> B
B --> E[Backoff stability decision]
C --> E
E --> F[Reconnect timer]
F --> A
Technical reviewBest possible solution: Use performance.now in the existing reconnect-backoff owner while retaining the current stability threshold, jitter, and attempt lifecycle. Do we have a high-confidence way to reproduce the issue? Current-main source establishes both failures directly: wall-clock steps alter the elapsed-time comparison independently of actual connection uptime; no target code or tests were executed during this review. Is this the best way to solve the issue? The patch is the smallest complete production fix: replace both clock readings in the existing duration owner, preserving policy and callers, with regressions for the two distinct failure directions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aef29790c634. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +30, Other +2. Total +34 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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, 6:23 AM ET / 10:23 UTC. |
|
Added the requested monitor-boundary proof: the shipped |
…nges (#188293) fix(irc,msteams): measure in-process durations with a monotonic clock IRC and Microsoft Teams measured some in-process durations with wall-clock time, so a system clock jump changed them: - the IRC probe latency could be wrong; - IRC reconnect backoff reset too early or not at all; - a fresh Teams file-consent upload could expire too early. These durations now use `performance.now()`. Persisted dates and public `createdAt` timestamps are unchanged, and so are the budgets. Evidence: built Gateway, main twice and candidate twice, with `Date.now` stepped inside the process only. Main reproduced the wrong probe latency, the wrong reconnect resets and the early expiry of a fresh Teams upload; the candidate corrected all three. The Teams path ran authenticated consent invokes, exact-byte uploads and the original card update. Controls passed: normal timing and expiry, invalid JWT, conversation mismatch and decline. Details: #188293 (comment). Includes the fixes from #188237, #188238 and #188239, 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]>
|
Thanks @chengzhichao-xydt. Your fix landed in #188293 (9b5c4e8), which keeps your commit. I'm closing this one as included. |
…nges (openclaw#188293) fix(irc,msteams): measure in-process durations with a monotonic clock IRC and Microsoft Teams measured some in-process durations with wall-clock time, so a system clock jump changed them: - the IRC probe latency could be wrong; - IRC reconnect backoff reset too early or not at all; - a fresh Teams file-consent upload could expire too early. These durations now use `performance.now()`. Persisted dates and public `createdAt` timestamps are unchanged, and so are the budgets. Evidence: built Gateway, main twice and candidate twice, with `Date.now` stepped inside the process only. Main reproduced the wrong probe latency, the wrong reconnect resets and the early expiry of a fresh Teams upload; the candidate corrected all three. The Teams path ran authenticated consent invokes, exact-byte uploads and the original card update. Controls passed: normal timing and expiry, invalid JWT, conversation mismatch and decline. Details: openclaw#188293 (comment). Includes the fixes from openclaw#188237, openclaw#188238 and openclaw#188239, 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
Fixes: IRC reconnect delays stay stuck near the 30-second cap after a stable connection, or reset too early while a peer keeps flapping, when the system clock steps (NTP correction, manual change, VM snapshot restore). The reconnect backoff decides whether a connection stayed up for the 60-second stability window by comparing
Date.now()readings, so a backward step erases accumulated uptime and a forward step fabricates it.User Impact
Reconnect delays recover to the 1-second initial delay after a stable minute even if the system clock jumps, and a forward clock jump no longer lets a repeatedly dropped connection hammer the server. No configuration, public API, schema, or migration changes.
Why This Change Was Made
Uptime is a duration, not a wall-clock reading. The stability window now reads
performance.now(), which is monotonic and immune to system-clock steps; backoff policy values, jitter, and the reset threshold are unchanged, and no timestamps leave the process. Existing tests now drive the monotonic clock, and two regressions pin a backward step after a stable minute and a forward step during a fresh connection.Evidence
node scripts/run-vitest.mjs run extensions/irc/src/reconnect-backoff.test.ts: 5/5 pass (both new wall-clock regressions are red against the base implementation).oxlintandoxfmt --checkclean on changed files. Local tsgo lane unavailable on this host (glibc 2.28 vs binary requirement 2.33+); type gates run in hosted CI. Net test growth +30 lines is recorded inconfig/test-lines-allocations/chengzhichao-irc-backoff-clock-20261030.txtfor the two wall-clock regressions.Real behavior proof
Behavior addressed: IRC reconnect scheduling through the shipped
monitorIrcProviderboundary must survive wall-clock steps in both directions.Real environment tested: This branch at HEAD
5b36005a7401a32f5b70e1fe8d68b469a523122b, Node v24.13.1, Linux x64. The realmonitorIrcProviderruns against a real loopback TCP server with REAL timers throughout; onlyDate.nowis stepped (+/-120s) between a disconnect and the next scheduled reconnect whileperformance.nowstays native. The server records each connection arrival; the reported delay is measured at the socket boundary, not read from the implementation.Exact steps or command run after this patch:
node scripts/run-vitest.mjs run extensions/irc/src/monitor-clock-step.proof.test.ts(throwaway harness driving the shipped monitor; not committed), then the identical command withextensions/irc/src/reconnect-backoff.tsrestored to the base revision.Evidence after fix: Terminal output, HEAD:
BASE (same harness, same perturbation):
Both cases flip as required (base fails the harness assertions; head passes).
Observed result after fix: The shipped monitor's actual reconnect timer follows monotonic connection uptime: a forward wall-clock step no longer resets a fresh connection's backoff (2256ms, attempt-2 band), and a backward step no longer erases a stable minute (1141ms, reset band). Base behavior inverts both.
What was not tested: Live IRC networks, TLS registration paths, OS/NTP clock adjustment, and the gateway host process. Backoff policy values themselves are unchanged. The earlier helper-level red/green pair (driving
createIrcReconnectBackoffdirectly, forward step 2000-vs-1000, backward step 1000-vs-2000) remains as supplementary evidence.Intentionally out of scope