Repository navigation
fix(msteams): expire pending uploads across clock changes - #188239
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 uses a monotonic deadline to expire in-memory Microsoft Teams pending uploads while preserving epoch creation timestamps. Example: A user accepts proof.txt one minute after sending it, after the system clock jumps forward one hour.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR fixes a source-verifiable clock-change bug that remains on current main, and no introduced correctness defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Teams plugin temporarily holds file bytes while awaiting FileConsentCard approval; the consent callback retrieves them for upload or removes them after decline or expiry. flowchart LR
A[Teams file reply] --> B[Consent card preparation]
B --> C[In-memory pending uploads]
B --> D[User consent card]
D --> E[Consent callback]
C --> E
F[Persisted CLI upload fallback] --> E
E --> G[Upload and file info card]
Technical reviewBest possible solution: Keep expiry duration in the existing in-memory upload owner, preserve epoch timestamps and persisted-upload semantics, and retain timer cleanup. Do we have a high-confidence way to reproduce the issue? Current main's wall-clock age check directly establishes the forward-step failure; the contributor also reports a head-versus-base subprocess comparison, but no target code was executed during this read-only review. Is this the best way to solve the issue? The patch is a small, complete repair for the stated in-memory boundary: one deadline field serves the existing expiry owner without changing public values, persistent records, or lifecycle cleanup. 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. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +14, Tests +11, Other +2. Total +27 across 3 files. Added test files: 0. View PR surface stats
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:24 AM ET / 10:24 UTC. |
|
Added the requested shipped-callback proof: a real subprocess drives |
…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: an in-memory Teams pending upload (a file waiting for FileConsentCard approval) can be dropped while still fresh, or kept past its TTL, when the system clock steps (NTP correction, manual change, VM snapshot restore). Besides the 5-minute TTL timer,
getPendingUploadruns an explicit age check for the case where the timer has not fired yet, and that check comparesDate.now()readings — so a backward step keeps stale uploads alive and a forward step makes the user's Accept click hit an already-gone file.User Impact
Pending uploads expire exactly at their 5-minute TTL regardless of system-clock corrections, and fresh uploads are never dropped early by a forward clock jump. No configuration, public API, schema, or migration changes.
Why This Change Was Made
The explicit expiry check is an in-process duration decision, so it now rides a monotonic deadline (
performance.now()), which is immune to system-clock steps. The publiccreatedAtfield keeps its epoch value for API consumers, and the TTL timer itself is unchanged.Evidence
node scripts/run-vitest.mjs run extensions/msteams/src/pending-uploads.test.ts extensions/msteams/src/pending-uploads.lifecycle.test.ts: 7/7 pass. The stale-entry case now advances the monotonic clock without firing timers, and a new regression keeps fresh entries across one-hour wall-clock steps in both directions (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 +10 lines is recorded inconfig/test-lines-allocations/chengzhichao-msteams-uploads-clock-20261030.txt.Real behavior proof
Behavior addressed: The shipped Teams file-consent callback (
runMSTeamsFileConsentInvokeHandler) must still find a fresh pending upload after a wall-clock step.Real environment tested: This branch at HEAD
b0d8d53915f766304669bd9791d4629cf1ca3206, Node v24.13.1, Linux x64; a real subprocess drives the shipped consent handler end to end: real in-memory store plus a real sqlite-backed plugin-state store (isolatedOPENCLAW_STATE_DIR) for the FS fallback path.Date.nowis stepped forward one hour after a realstorePendingUpload;performance.nowstays native. The synthetic upload URL is rejected by the SSRF allowlist as designed, which is what marks reaching the upload stage.Exact steps or command run after this patch:
WT=$PWD OUT=/tmp/clock-proof/msteams-invoke-head.json node --import tsx /tmp/clock-proof/msteams-invoke.mts, then the same command withextensions/msteams/src/pending-uploads.tsrestored to the base revision.Evidence after fix: HEAD terminal output:
{"reachedUploadStage":true,"expiredPath":false,"activities":["File upload failed. Please try again."]}— the fresh upload is found after the step, the handler proceeds to the upload stage, and only the synthetic URL stops it. BASE under the identical step:{"reachedUploadStage":false,"expiredPath":true,"activities":["The file upload request has expired. Please try sending the file again."]}— the fresh upload is wrongly expired before the user is ever served. Receipts:/tmp/clock-proof/msteams-invoke-{head,base}.json.Observed result after fix: A fresh consent accept reaches the upload stage after a one-hour forward wall-clock step; base reports the request as expired instead.
What was not tested: Teams live delivery, Graph upload, the fs-backed pending-upload variant (see below), and OS/NTP clock adjustment. The earlier helper-level red/green pair (driving
storePendingUpload/getPendingUploaddirectly,freshEntrySurvivesForwardSteptrue-vs-false) remains as supplementary evidence.Intentionally out of scope
pending-uploads-fs.ts: the fs-backed variant persistscreatedAtacross restarts, so its expiry must stay on epoch time by design (a monotonic reading cannot cross a process restart).