Repository navigation
fix(buzz): keep the setup verification reload wait on the monotonic clock - #184525
mikasa0818 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 maintainer review before merge. What this changesThis PR measures Buzz’s post-setup Gateway reload deadline with performance.now() and adds a regression test. Example: The system clock moves backward 10 minutes while the saved Buzz configuration remains unapplied.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: current main retains the clock-sensitive wait, and this focused repair introduces no actionable defects. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherBuzz’s setup wizard invokes verification after saving configuration; verification polls Gateway config.get until the saved revision is applied, then probes room membership or reports recovery guidance. flowchart TD
A[Buzz setup wizard] --> B[Save configuration]
B --> C[Post-write verification]
C --> D[Gateway config polling]
D --> E[Monotonic reload deadline]
D --> F[Room membership probe]
E --> G[Recovery guidance]
Technical reviewBest possible solution: Keep the deadline in the existing verification owner and use the same monotonic clock for its start and remaining-budget calculation. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the failure mechanism, and the contributor supplies matching before/after real-transport traces; this read-only review ran no target code. Is this the best way to solve the issue? Changing both clock reads is the smallest complete repair: it restores elapsed-time accounting without introducing another owner, changing persisted configuration, or altering reload recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 62a2e746eb04. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +62. Total +65 across 2 files. Added test files: 1. View PR surface stats
LabelsLabel changes: No label 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 HistoryReview history (2 earlier review cycles)
Reviewed October 26, 2026, 9:23 AM ET / 13:23 UTC (Revision 3). |
b2ff0d8 to
4e62175
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
4e62175 to
c4a4968
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
fix: measure deadlines and budgets on one monotonic clock owner Many deadline, budget and timeout calculations used Date.now(), so a wall-clock step (NTP correction, VM resume, manual change) made them expire early or run long. Contributors had been fixing these one call site at a time. Core now has one owner, src/shared/monotonic-time.ts, for process-local deadlines and elapsed time, replacing the supervisor-local helper and the per-site variants. Bundled extensions use performance.now() directly. Wall-clock values stay where they are persisted, shown to users or exchanged between processes: the public provider deadline stays epoch-valued, with monotonic enforcement kept privately, and the plugin SDK facade is unchanged. This absorbs the per-site fixes from @SunnyShu0925 (#186039, #186134, #186412, #184716, #184613) and @mikasa0818 (#184576, #184525, #182064), whose original commits are kept. Update, Doctor, Windows-only and security-held sites are listed under "Not fixed here" in the PR. Evidence: built CLI suspend wait, browser Gateway CDP waits, Discord READY wait and node host-stats checkpoint, each with Date.now stepped inside the process only. On main each misbehaved under the clock step (early expiry or a stretched wait); with this change each matched the no-step control. Media generation's guard blocks local fixtures, so that family relies on the shared owner's regression. Production 479 changed lines, tests net 0. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: mikasa0818 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @mikasa0818. This is now fixed at the root in #186484 (bf10fbe): process-local deadlines and budgets go through one monotonic clock owner, src/shared/monotonic-time.ts (bundled extensions use performance.now()). Your commit from this PR is kept in that merge and you're credited as co-author, so I'm closing this one as covered. For new deadline code, please use that owner rather than a per-site change. |
…86484) fix: measure deadlines and budgets on one monotonic clock owner Many deadline, budget and timeout calculations used Date.now(), so a wall-clock step (NTP correction, VM resume, manual change) made them expire early or run long. Contributors had been fixing these one call site at a time. Core now has one owner, src/shared/monotonic-time.ts, for process-local deadlines and elapsed time, replacing the supervisor-local helper and the per-site variants. Bundled extensions use performance.now() directly. Wall-clock values stay where they are persisted, shown to users or exchanged between processes: the public provider deadline stays epoch-valued, with monotonic enforcement kept privately, and the plugin SDK facade is unchanged. This absorbs the per-site fixes from @SunnyShu0925 (openclaw#186039, openclaw#186134, openclaw#186412, openclaw#184716, openclaw#184613) and @mikasa0818 (openclaw#184576, openclaw#184525, openclaw#182064), whose original commits are kept. Update, Doctor, Windows-only and security-held sites are listed under "Not fixed here" in the PR. Evidence: built CLI suspend wait, browser Gateway CDP waits, Discord READY wait and node host-stats checkpoint, each with Date.now stepped inside the process only. On main each misbehaved under the clock step (early expiry or a stretched wait); with this change each matched the no-step control. Media generation's guard blocks local fixtures, so that family relies on the shared owner's regression. Production 479 changed lines, tests net 0. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: mikasa0818 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: after saving the Buzz channel config, the CLI's wait for the Gateway to apply it keeps polling far past the 15-second reload window when the system wall clock steps backward — the deadline is seeded and compared on the wall clock while the polls sleep on the monotonic clock.
User Impact
User impact: finishing Buzz setup on a machine whose clock steps backward (NTP correction, VM or laptop resume) now always reports the bounded
Gateway did not apply the saved Buzz configuration within 15 secondsoutcome after the real 15-second window, instead of hanging the setup command on a wall-clock-inflated polling loop.Why This Change Was Made
verifyBuzzAfterSetupseedsreloadDeadline = Date.now() + GATEWAY_RELOAD_WAIT_MSand computesremainingMs = reloadDeadline - Date.now()betweenconfig.getround trips that sleep on monotonic timers. A backward wall-clock step stretches the budget by the step, so the loop keeps issuing realconfig.getrequests for15s + step.The deadline now lives on
performance.now()— seed and remaining computation — which is monotonic and unaffected by wall-clock adjustments. This continues the cross-clock-domain series (#174151, #181335, and the merged fleet: #155846 slack auth retries, #182180 Feishu registration poll, #182778 provider local service budgets, #182859 scheduled-task fallback waits, #183742 X media processing wait); the Buzz reload wait is an unclaimed channel-setup site in the same family.The regression test keeps everything on injected clocks (the series' two-clock separation): the gateway transport seam reports a persistently unapplied saved revision, fake timers advance the monotonic deadline, and the wall-clock reading stays frozen at a rewound instant; the bounded failure is asserted through the runtime log the verify call reports when it resolves.
No setup flow, gateway RPC, or recovery semantics change; behavior on a clock that never steps is identical.
Evidence
Pre-fix RED — stock main (
d18177d60f9), regression test only:config.getkeeps reportingappliedConfigHash !== configRevisionHash, and the wall clock is frozen 10 minutes behind once the wait starts. Stock main never resolves within the whole (fake-advanced) 16-second observation:Post-fix GREEN — the same scenario resolves with the bounded report, and the module's suites pass:
Real runtime proof (real Gateway WebSocket transport, in-process wall-clock rewind)
A real local WebSocket gateway fixture speaks the real Gateway wire protocol (server
connect.challenge→ clientconnect→ hello-ok →config.getresponses). The productioncallGatewayFromCliruns its full client stack — event-loop readiness, device identity bootstrap, challenge connect — against that fixture, which answers everyconfig.getwith a persistently unapplied saved revision. OnlyDate.nowis rewound in-process;performance.now()reports all real elapsed times. The budget is the module's real 15-second window. (Captured in a standalone Node process so no vitest worker keeps the event loop busy; the handshake takes ~21s of real bootstrap before the first poll.)Stock main is still issuing real
config.getpolls at the 18-second cap (35 polls, past the whole budget — it would continue for the length of the rewind); with this PR the verify call resolves with the bounded "did not apply" report after exactly the real 15-second budget (30 polls).Behavior matrix (config.get always unapplied, wall clock rewound 10min at poll #1):
Also verified on the changed tree:
pnpm format:checkand the changed-file lint lane frompnpm check:changed(one oxlint finding on the first draft was fixed and re-verified; the pnpm/corepack-shelling lanes fail on this Windows contributor box for the environmental reasons documented on #182778/#182859/#183742, unrelated to this diff). CI runs those lanes authoritatively.