Repository navigation
Conversation
scheduleAbsoluteDeadline defaulted to Date.now(), so a wall-clock rewind inflated the remaining budget and let a healthy handoff hang past its configured timeout. Seed and read the deadline with performance.now(). Ref: BUG-164 (local finding)
|
🦞👀 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 makes managed-service handoff response deadlines use elapsed time unaffected by wall-clock changes. Example: The wall clock rewinds 90 seconds during a 30-second helper-readiness wait.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main retains the clock-dependent handoff timeout, and this focused repair has no actionable correctness or security findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe update parent launches a detached helper and waits for readiness or control responses; the deadline scheduler invokes existing rejection and cleanup when the response budget expires. flowchart LR
A[Update request] --> B[Managed handoff owner]
B --> C[Detached helper]
C --> D[Response waiter]
E[Monotonic deadline] --> D
D --> F[Response or timeout cleanup]
Technical reviewBest possible solution: Keep the existing handoff owner and scheduler, using one monotonic clock for deadline creation and expiry checks. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the rewind failure through the scheduler's wall-clock recheck, and supplied production traces demonstrate it; no target code was executed during this read-only review. Is this the best way to solve the issue? This is the smallest complete repair: both clock reads change together, existing settlement and cleanup remain intact, and the existing regression gains the distinct rewind case without new machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 55fec79d1ec5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +4, Tests 0. Total +4 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 Reviewed November 15, 2026, 11:12 AM ET / 16:12 UTC. |
|
Thanks for the work here. We're closing this along with the other open PRs that apply the same change one call site at a time. This series moves individual deadlines to the monotonic clock one at a time; the shared owner is src/shared/monotonic-time.ts, and remaining call sites should be handled together. Please open one issue (or one PR at the shared owner) that covers the whole pattern, with a reproduction of real user-visible harm, instead of separate per-site PRs. Further per-site variants of this pattern will be closed. |
fix: keep five local elapsed-time waits on the monotonic clock Five local waits measured elapsed time with the wall clock, so a clock step (NTP correction, sleep/wake, manual change) ended them early or let them overrun: the exec-approval follow-up wait, the runtime auth deadline, the managed update handoff response wait, and two Windows scheduled-task waits (process exit and settlement). They now use `src/shared/monotonic-time.ts`, passing `monotonicNow` to `scheduleAbsoluteDeadline` where it's used. Epoch values that cross process, RPC or persistence boundaries stay epochs, RPC timeouts stay integers, upstream epoch auth deadlines are untouched, and the handoff `closed` command keeps its helper-owned settlement. No new text. Evidence: full-build CLI with the process-local Date.now stepped by a preload in that process only, main twice and this change twice, plus unstepped controls. Exec-approval follow-up: main ends after about 60 s; this change waits the real ~360 s, the same as unstepped. Runtime auth: a forward step makes main expire after ~367 ms of a ~9.3 s allowance and a backward step makes it overrun to ~12.4 s; this change keeps the allowance and aborts on time. The Windows scheduled-task sites have unit-level proof with a stepped clock, and the handoff wait has source-level proof through a real child pipe. 75 consumer and 55 daemon tests pass; full build and packed smoke pass. CI red is inherited from main (receipt: #199951 (comment)). Receipts: #199951 (comment). Supersedes the closed per-site PRs #181942, #187439, #190976, #195457, #199640 and #199665. Co-authored-by: Ayaan Zaidi <[email protected]>
…199951) fix: keep five local elapsed-time waits on the monotonic clock Five local waits measured elapsed time with the wall clock, so a clock step (NTP correction, sleep/wake, manual change) ended them early or let them overrun: the exec-approval follow-up wait, the runtime auth deadline, the managed update handoff response wait, and two Windows scheduled-task waits (process exit and settlement). They now use `src/shared/monotonic-time.ts`, passing `monotonicNow` to `scheduleAbsoluteDeadline` where it's used. Epoch values that cross process, RPC or persistence boundaries stay epochs, RPC timeouts stay integers, upstream epoch auth deadlines are untouched, and the handoff `closed` command keeps its helper-owned settlement. No new text. Evidence: full-build CLI with the process-local Date.now stepped by a preload in that process only, main twice and this change twice, plus unstepped controls. Exec-approval follow-up: main ends after about 60 s; this change waits the real ~360 s, the same as unstepped. Runtime auth: a forward step makes main expire after ~367 ms of a ~9.3 s allowance and a backward step makes it overrun to ~12.4 s; this change keeps the allowance and aborts on time. The Windows scheduled-task sites have unit-level proof with a stepped clock, and the handoff wait has source-level proof through a real child pipe. 75 consumer and 55 daemon tests pass; full build and packed smoke pass. CI red is inherited from main (receipt: openclaw#199951 (comment)). Receipts: openclaw#199951 (comment). Supersedes the closed per-site PRs openclaw#181942, openclaw#187439, openclaw#190976, openclaw#195457, openclaw#199640 and openclaw#199665. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
During a managed service update the parent process waits for the helper's handoff response under an absolute deadline. That deadline was seeded and read with the wall clock (
Date.now()), so a host clock correction during the handoff skewed the remaining budget: a rewind inflated it and let a wedged handoff hang far past its configured timeout, while a forward jump shrank it and could terminate a healthy handoff early. The deadline now runs on the monotonic clock.scheduleAbsoluteDeadline(Date.now() + timeoutMs, cb)computed the remaining budget on the wall clock; a 90 s rewind turned a 5 s handoff budget into ~95 s of waiting.performance.now()and pass that clock explicitly toscheduleAbsoluteDeadline.src/infra/update-managed-service-handoff-control.ts— thewaitForHandoffResponsedeadline arm only; plus a rewind regression folded into the existing handoff readiness-timeout case.Why This Change Was Made
The handoff deadline is purely in-process: it is not serialized, persisted, or reported to the UI, so a full switch to the monotonic clock is safe and needs no dual-clock-domain conversion. This is the same canonical pattern already merged for the update-operation deadline (
scheduleAbsoluteDeadlinewith an explicit monotonicnow), keeping the deadline utilities consistent. Risk is low:performanceis a Node global and only the deadline arm changed.scheduleAbsoluteDeadlinealready consumes.performance.now()is monotonic per process, unaffected by NTP steps or manual clock changes, and matches the clock domain of the update-operation deadline.performance.now()is a Node global available since Node 16; the handoff runtime is a sealed subprocess that does not re-read the clock after launch. Boundary left unchanged: the handoff line reader, exit/error settlement, and child-process kill logic.User Impact
Operators running a managed service update no longer risk a stuck or prematurely cancelled handoff when the host clock is corrected (NTP step, manual change, VM restore). The handoff deadline tracks real elapsed time and fires at the configured budget.
Evidence
All evidence below is for reviewed head
a921354150a843d908ffbeca4f9a2f9e710072fb.Shipped command:
The real detached
managed-handoff-runtimehelper was used. Full run logs in the GHA links below.1. Completed managed update across the published-driver/candidate boundary. The repository's own
published-driver-updatecell (scripts/e2e/published-driver-update-docker.sh, the same cell CI runs for update changes) upgraded the published2026.10.8driver to the package built from this head. Candidate build: commita921354150a8, built2026-10-28T05:49:28Z. The cell relabels the branch manifest's2026.10.7to the driver version so the future-version guard exercises an upgrade rather than a downgrade.Operator state survived the update (identical durable session row before and after):
2. Committed regression: green on head, red on base. Same test, only
src/infra/update-managed-service-handoff-control.tsreverted to its parent:3. Handoff deadline under a real 90 s rewind. Isolated systemd-managed install; shipped
update.runGateway RPC with the real detachedmanaged-handoff-runtimehelper; readiness line held 12 s and a-90 swall-clock step applied the moment the deadline timer arms:Runs: managed-update cell, regression red/green.
Open PR collision check: searched open PR topics
handoff deadline/monotonic clock/managed-service-handoff-controland changed-file lists — no open PR touchessrc/infra/update-managed-service-handoff-control.ts.This replaces a previously closed PR carrying the identical commit (same fix, same proof); the branch is unchanged apart from being pushed from a different fork.
Workstation note: this host's systemd 239
libsystemdlackssd_bus_set_method_call_timeout, so the published driver cannot inspect a local managed unit here; the completed upgrade therefore ran in CI's own cell (Ubuntu 24.04, systemd 257) with the same script CI uses.