Repository navigation
fix(irc): report probe latency across clock changes - #188238
chengzhichao-xydt wants to merge 1 commit into
Conversation
|
🦞👀 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 changes before merge. What this changesThis PR measures IRC probe latency with a monotonic clock so system-clock changes cannot distort the result. Example: The wall clock moves backward one hour during IRC registration.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR: it fixes a real IRC latency bug still present on main, but the clock change breaks an existing test and needs a focused repair. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe IRC channel status adapter passes account configuration into probeIrc, which connects and registers through the IRC client, disconnects, and returns connectivity details and latency. flowchart LR
A[Channel status request] --> B[IRC status adapter]
B --> C[Account resolution]
C --> D[IRC probe]
D --> E[TCP or TLS registration]
E --> D
D --> F[Status and latency result]
Technical reviewBest possible solution: Keep the local monotonic-clock fix, update the existing probe test's clock fixture, and retain only distinct regression coverage. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows wall-clock subtraction across an awaited registration, and the contributor supplies a matching base-versus-head TCP trace; this review executed no target code. Is this the best way to solve the issue? Replacing the two clock readings in the existing probe owner is the smallest complete fix; the shared-helper parity claim is inaccurate, but does not undermine this local repair. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aef29790c634. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +2, Tests +58, Other +2. Total +62 across 3 files. Added test files: 1. View PR surface stats
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, 6:24 AM ET / 10:24 UTC. |
Co-Authored-By: Claude Code <[email protected]>
ffa4dfa to
54c2f37
Compare
|
Updated per review: the existing |
…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:
probeIrcreports a negative or wildly inflatedlatencyMswhen the system clock steps while a probe connect is in flight (NTP correction, manual change, VM snapshot restore), because the elapsed reading is computed fromDate.now(). Doctor/status output then shows absurd probe latencies for an otherwise healthy server.User Impact
Probe latency stays accurate and non-negative across system-clock corrections. No configuration, public API, schema, or migration changes.
Why This Change Was Made
Latency is a duration, so it now comes from
performance.now(), which is monotonic and immune to system-clock steps. This matches the sharedrunChannelProbehelper, which already measures elapsed time on the monotonic clock. Probe behavior, timeouts, and the result shape are unchanged. A new test file covers a real loopback success reading, a wall-clock backward step mid-connect, and the unconfigured-account path.Evidence
node scripts/run-vitest.mjs run extensions/irc/src/probe.test.ts extensions/irc/src/send.test.ts: both suites pass (the wall-clock step case is red against the base implementation). The existingsend.test.tslatency fixture now drivesperformance.now, preserving its timeout-forwarding and quit assertions.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 +51 lines (new file) is recorded inconfig/test-lines-allocations/chengzhichao-irc-probe-clock-20261030.txt.Real behavior proof
Behavior addressed: IRC probe
latencyMsmust not follow wall-clock steps during a connect.Real environment tested: This branch at HEAD
54c2f37d0559ebe1114bd1ffe2d42501110ad7ca, Node v24.13.1, Linux x64; productionprobeIrcdriven against a real loopback TCP server that completes IRC registration and then stepsDate.nowback one hour;performance.nowstays native.Exact steps or command run after this patch:
WT=$PWD OUT=/tmp/clock-proof/probe-head.json node --import tsx /tmp/clock-proof/probe.mts, then the same command withextensions/irc/src/probe.tsrestored to the base revision.Evidence after fix: HEAD:
{"ok":true,"latencyMs":178.37}after a one-hour backward wall-clock step during registration. BASE:{"ok":true,"latencyMs":-3599987}under identical perturbation. Receipts:/tmp/clock-proof/probe-{head,base}.json.Observed result after fix: Reported latency follows the monotonic clock and stays sane; base reports a negative latency of roughly the step size.
What was not tested: Live IRC networks, TLS probes, NickServ flows, and OS/NTP clock adjustment. The connect timeout path is unchanged.
Intentionally out of scope
runChannelProbehelper already covers.