Skip to content

fix(channels): preserve IRC timing and Teams uploads across clock changes - #188293

Merged
obviyus merged 7 commits into
mainfrom
fix/channel-duration-clock-sweep
Oct 30, 2026
Merged

obviyus merged 7 commits into
mainfrom
fix/channel-duration-clock-sweep

Conversation

@obviyus

@obviyus obviyus commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

IRC reconnect delays and probe latency, and fresh Teams file-consent uploads, become incorrect when the system clock changes.

Related: #188237, #188238, #188239. This combines chengzhichao-xydt's three fixes and retains their commits, including the updated IRC probe consumer fix.

User Impact

IRC reconnects retain their normal backoff and healthy-connection reset policy, probes report elapsed connection time, and Teams users can accept a fresh file upload despite a wall-clock correction. No configuration changes or migration are required.

Why This Change Was Made

Use performance.now() directly for these process-local durations. Teams keeps its public createdAt epoch unchanged and adds a private monotonic expiry deadline; filesystem-backed, cross-process upload expiry remains unchanged. No SDK API is added.

Consolidated the regressions into the existing owner/consumer suites, removed the duplicate probe suite and test allocations, and made the IRC monitor's fake clock include performance. Against the merge base: production +14 lines, tests 0 net lines. The private Teams deadline is needed to preserve the public epoch field without measuring expiry against it.

Evidence

Built main ac32225fbbbc799eaa43dd1666e81a25bdb54b9d and candidate d3a4f387b5e0c1314ad270fd6773fd38045eaab6 in secretless Docker on Node 24.22.1. Used the built Gateway, explicit isolated profiles and state/config/database paths. Only Date.now() was stepped inside the process; native timers, performance.now(), reconnect jitter and the real 60-second stable window were unchanged.

Final head e7fdbe41f93dbc53f5f1aa0028634e213d8c0439 only repairs test cleanup typing and uses complete fake timers in two suites; all production files are identical to the built candidate above, so the runtime evidence is reused unchanged. The three adjusted suites were rerun: 45/45 tests passed. This fixes the initial head's check-test-types cleanup callback error and check-lint formatting failures rather than rerunning those jobs.

Sanitized runtime capture and before/after results.

Two iterations on each revision:

Real Gateway path Main Candidate
IRC channels.status probe, local TCP registration delayed ~300 ms, ±1-hour wall steps −3,599,662 / −3,599,573 ms; +3,600,315 / +3,600,355 ms All stepped probes 310–447 ms
IRC monitor, forward step after a short connection Incorrectly reset to 1,065 / 1,070 ms Preserved growing backoff: 4,551 / 4,637 ms
IRC monitor, backward step after 61 real seconds connected Incorrectly retained 4,786 / 4,766 ms Reset normally: 1,154 / 1,194 ms
Teams inbound agent reply → real messenger FileConsentCard → authenticated accept invoke, +360,001 ms step Same-process memory lookup lost fresh entry; no upload, expired response Same-process entry found; actual 51-byte upload and replacement FileInfoCard on both accepts

Controls passed on both revisions: unstepped IRC probes, increasing short-connection backoff, ordinary reset after 61 seconds; Teams ordinary accepted upload, conversation mismatch rejection followed by a valid accept, decline cleanup, and natural expiry after a real five-minute wait. Invalid-signature and wrong-audience Teams webhooks returned HTTP 401. Candidate recorded six exact-byte upload PUTs with Content-Range: bytes 0-50/51 and six corresponding original-card updates across the stepped accepts and ordinary controls.

Teams proof used the normal App/Express authentication and sender/URL guards with synthetic RSA/JWKS identity infrastructure and a loopback Connector/upload transport. Production Connector authority interceptors and middleware remained installed. Temporary observation hooks in both builds recorded the actual messenger store and consent getter with the same Gateway PID; no direct helper invocation, auth bypass or CLI filesystem-backed send was used. A deterministic local Responses provider generated the attachment replies.

Focused checks: 41/41 tests passed across reconnect-backoff, send/probe and pending-upload suites; 19/19 passed across IRC monitor, Teams consent handler and pending-upload lifecycle consumers. The same current owner regressions against main produced 6 failures / 35 passes, covering all three clock defects. Changed-file formatting and lint passed.

Merge danger: two-way door; reverting restores the former duration calculations without changing persisted data or configuration. Blast radius is IRC reconnect/probe timing and same-process Teams pending uploads; filesystem-backed Teams uploads 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.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@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 before/after capture, Node 24.22.1, isolated Docker. Baseline ac32225fbbbc799eaa43dd1666e81a25bdb54b9d; candidate d3a4f387b5e0c1314ad270fd6773fd38045eaab6. Two iterations per revision; no system-clock or monotonic-clock changes.

IRC public channels.status probe (±1-hour Date.now offset during TCP registration)
                    main round 0    main round 1    candidate round 0    candidate round 1
backward latency    -3599662 ms      -3599573 ms     310.521 ms           425.025 ms
forward latency      3600315 ms       3600355 ms     415.454 ms           446.375 ms
no-step latency          312 ms           377 ms     314.856 ms           319.240 ms

IRC actual monitor reconnect delay (policy/jitter unchanged)
early forward jump      1065 ms          1070 ms        4551 ms              4637 ms
61s + backward jump     4786 ms          4766 ms        1154 ms              1194 ms
61s no-step control     1027 ms          1187 ms        1189 ms              1001 ms

Teams real messenger memory store -> actual consent invoke memory lookup
main PID 11347:
  round 0 stored.createdAt=1793359407318; lookup epoch=1793359767366; found=false; uploads=0
  round 1 stored.createdAt=1793359409034; lookup epoch=1793359769069; found=false; uploads=0
candidate PID 12653:
  round 0 stored.createdAt=1793359697989; lookup epoch=1793360058021; found=true; uploads=1
  round 1 stored.createdAt=1793359699591; lookup epoch=1793360059609; found=true; uploads=1
  six upload PUTs total including controls, each exact 51 bytes, Content-Range bytes 0-50/51
  six FileInfoCard PUT updates to the original consent-card activity URLs

Both revisions:
  wrong-audience JWT -> 401; invalid-signature JWT -> 401
  normal upload -> succeeds; mismatched conversation -> no upload, valid retry succeeds
  decline -> entry removed; later accept -> missing
  natural expiry -> both entries missing after >301000ms real wait, no upload

Current regressions against main: 3 files failed; 6 tests failed / 35 passed
Candidate owner/consumer checks: 6 files passed; 60 tests passed

Teams used real SDK JWT validation, sender authorization, consent parsing, memory lookup, URL hostname/public-DNS validation and Connector authority middleware. Synthetic identity/JWKS and loopback transport replaced only provider infrastructure. The attachment came from an inbound agent reply through the shipped messenger, not CLI message send or a direct helper. createdAt remained an epoch timestamp. Native timers and the actual five-minute TTL were not accelerated.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 30, 2026
@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:

@clawsweeper clawsweeper Bot added 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 time for IRC reconnect stability, IRC probe latency, and same-process Teams pending-upload expiry.

Example: A fresh Teams file-consent request is accepted after Date.now advances by 360,001 ms.

  • Before: The pending file is incorrectly expired and no upload occurs.
  • After: The fresh file remains available, uploads successfully, and replaces the consent card with a FileInfoCard.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful repair with shipped-entry-point before/after evidence, preserved storage contracts, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The inspected Node 24.22.1 isolated-Docker capture exercises built-Gateway channels.status, actual IRC reconnect scheduling, and inbound Teams attachment replies through authenticated consent invokes to successful upload PUTs and FileInfoCard updates; rejection and natural-expiry controls are recorded, and the reviewed head has identical production code.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: System-clock corrections can produce absurd IRC latency, disrupt reconnect backoff, and make fresh Teams file approvals report expired.
Reason: This maintainer-authored repair restores existing duration contracts without adding options or changing intended policy.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes three source-confirmed clock-change bugs still present on main, with relevant built-Gateway evidence and no actionable correctness findings; current-head CI remains pending.

Priority: P2
Reviewed head: e7fdbe41f93dbc53f5f1aa0028634e213d8c0439

Before merge

None.

Findings

None.

Agent review details

How this fits together

The IRC plugin measures connection durations for status probes and reconnect scheduling; the Teams plugin holds reply attachments until an authenticated consent callback uploads or removes them.

flowchart LR
 A[Gateway channel operations] --> B[IRC probe and monitor]
 B --> C[Monotonic duration measurements]
 C --> D[Latency and reconnect scheduling]
 A --> E[Teams attachment reply]
 E --> F[Pending upload owner]
 F --> G[Authenticated consent callback]
 G --> H[Upload and file card update]
Loading

Technical review

Best possible solution:

Use the existing duration owners with monotonic readings while preserving reconnect policy, epoch timestamps, persisted-upload semantics, and cleanup.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly establishes all three failures, and the supplied built-Gateway baseline/candidate capture demonstrates them with stepped Date.now readings; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: change the duration clock inside existing owners and retain one private deadline where the public epoch timestamp must remain intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 176c9c7496fd.

Provenance checked

  • IRC reconnect stability keeps the original intent (0ac81cf: Throttle repeated short-lived connections while restoring the initial reconnect delay after 60 seconds of healthy uptime.)
  • Native clock ownership keeps the original intent (3ecfdb7: Remove test-only clock injection while preserving the reconnect algorithm.)
  • IRC probe latency keeps the original intent (fa906b2: Provide connection-health and elapsed-latency reporting for the first-class IRC plugin.)
  • Teams explicit expiry keeps the original intent (0f7f7bb: Expire pending attachments after five minutes even when their cleanup timer has not fired.)
  • Teams upload and timer ownership keeps the original intent (283b8a0: Consolidate upload and timer state into one owner while preserving removal, expiry, and lifecycle cleanup.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 283b8a0 adds extensions/msteams/src/pending-uploads.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 283b8a014381; files: extensions/msteams/src/pending-uploads.ts)
  • Agustin Rivera: Raw commit 0ac81cf adds extensions/irc/src/reconnect-backoff.ts:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0ac81cf6ec1a; files: extensions/irc/src/reconnect-backoff.ts)
  • Vignesh: Raw commit fa906b2 adds extensions/irc/src/probe.ts:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: fa906b26add7; files: extensions/irc/src/probe.ts)

PR surface

Source +14, Tests 0. Total +14 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 25 11 +14
Tests 4 71 71 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 96 82 +14

Review metrics

Metric Value Why it matters
Production versus test LOC Production +25/-11; tests +71/-71 The net production growth holds a private monotonic deadline while preserving the public epoch timestamp; regressions extend existing suites without net test growth.

Root-cause cluster

Relationship: canonical
Canonical: #188293
Summary: This PR consolidates the three linked duration-clock repairs and retains their contributor commits.

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 distort IRC recovery and status or incorrectly expire fresh Teams attachments, with a limited channel-specific blast radius.
  • 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 distort IRC recovery and status or incorrectly expire fresh Teams attachments, with a limited channel-specific blast radius.
  • 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, 7:53 AM ET / 11:53 UTC.

@obviyus
obviyus merged commit 9b5c4e8 into main Oct 30, 2026
108 checks passed
@obviyus
obviyus deleted the fix/channel-duration-clock-sweep branch October 30, 2026 11:58
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 9b5c4e8. Thanks to the author of #188237, #188238 and #188239. Your fixes are included here.

obviyus added a commit that referenced this pull request Oct 30, 2026
…ock changes (#188452)

fix(irc,discord): measure remaining channel durations with a monotonic clock

Follow-up to #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: #188452 (comment).

Includes the fixes from #188411 and #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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…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]>
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: irc channel: msteams Channel integration: msteams 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