Repository navigation
fix(infra): ssh tunnel listener timeout no longer affected by clock skew - #135281
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 5:58 AM ET / 09:58 UTC. ClawSweeper reviewWhat this changesThis PR changes SSH tunnel readiness polling to use a monotonic clock and adds public-boundary regression tests for forward and backward wall-clock changes. Merge readiness⛔ Blocked until stronger real behavior proof is added - 3 items remain The monotonic-clock repair is the correct owner-boundary change and current main still uses the wall clock, but the supplied real-SSH proof covers an earlier revision while the exact current head explicitly has final execution evidence pending. Keep this PR open for exact-head behavior proof. Priority: P2 Review scores
Verification
How this fits togetherGateway status can create an SSH local port forward to reach a remote Gateway, then waits for the local listener before probing it. Startup must either return a usable tunnel or cleanly time out or cancel while reaping the SSH child. flowchart LR
A[Gateway status command] --> B[Start SSH tunnel]
B --> C[Poll local listener]
C --> D{Listener ready in budget?}
D -->|Yes| E[Probe remote Gateway]
D -->|No or cancelled| F[Stop and reap SSH child]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +37. Total +37 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single monotonic readiness budget and publish a redacted exact-head trace showing both forward and backward Date.now() steps consume roughly the configured budget while startup cleanup still completes. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main’s Date.now()-based loop can terminate early after a forward clock step or continue after a backward one, and the PR’s boundary test models both paths. This read-only review did not execute the contributor branch. Is this the best way to solve the issue? Yes. Replacing the time source inside the existing readiness-loop owner preserves the existing cancellation and child-reaping design, unlike adding another timeout around its callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0f553a2d6075. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
@clawsweeper re-review CI proof has been added at exact heads. The production SSH boundary now shows the expected before/after behavior under simulated wall-clock jumps; see the updated ## Evidence section. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Measure listener readiness with the monotonic clock in the existing polling owner. Preserve cancellation, joined readiness work, shared child reaping, and the canonical port allocator. Exercise forward and backward wall-clock steps through the public startup boundary with shared synthetic-child coverage. Production net 0; tests net +37. Current-main defect and lifecycle controls reproduced; independent P0 review clean. Final execution/CI proof remains pending publication. Co-authored-by: xialonglee <[email protected]>
|
Merged via squash.
|
…kew (openclaw#135281) * fix(infra): use monotonic clock for ssh tunnel listener deadline * fix(infra): keep ssh tunnel listener helper private and test clock skew at boundary --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: xialonglee <[email protected]>
What Problem This Solves
Fixes an issue where operators opening an SSH tunnel to a remote Gateway could receive an immediate listener timeout or wait indefinitely when the system clock changed during startup.
Why This Change Was Made
The listener-polling owner now measures elapsed time with
performance.now(). It keeps the existing polling cadence and the current cancellation, readiness-join, child-reaping, and shared-stop behavior. The fix changes the clock used by the existing loop instead of adding another timeout path.The regression cases exercise the public
startSshPortForwardboundary with real listener probes and timers. They move wall time forward or backward only after the first probe begins, reuse the existing synthetic-child fixture, and retain the current abort/join coverage. The private listener helper remains private.Production delta against integrated main: +2/-2, net 0. Tests: +50/-13, net +37.
Thanks to Peter Lee (@xialonglee) for identifying and repairing the clock-skew failure and supplying the original SSH proof.
User Impact
Clock adjustments no longer determine whether SSH tunnel startup ends too early or continues beyond its polling budget. Startup cancellation and tunnel cleanup still wait for the owned work to finish.
This preserves the existing polling granularity and socket-probe timeout; it does not introduce a strict end-to-end startup deadline.
Evidence
Independent reproduction on current main
At
6426cb310d6e8be691785621ea6f0f244819facc, a maintainer-authored driver used the real public startup function, real loopback socket probes and timers, and isolated synthetic Node child processes. No SSH credentials or external host were used for this baseline.Every case returned only after child exit and closure of its readiness sockets. The established-tunnel case also checked that concurrent stop callers share the same promise. These observations reproduce the defect and protect the newer lifetime behavior; they are baseline results, not execution of the final revision.
Exact published revision: observed startup and cleanup tests
CI run 33616128322 completed successfully for
e8c60ff3365c341580531311ce7fdf095dfc512f. The runner checked out merge3a6d41e6db476eaeec37df60081cf0358d0f5538; both SSH source and test files are byte-identical to the reviewed published revision.All 23 SSH tests passed, including these two new public-boundary cases:
Each case calls the real
startSshPortForward, makes realnet.connectloopback probes, and uses real timers. The clock changes only after the initial probe begins. With a 250 ms configured budget, both cases require the listener-timeout error and assert at least 200 ms of measured monotonic startup time. The 254 ms values above are Vitest's complete case durations, not separately printed startup measurements. A backward-clock hang would reach the 1,000 ms safety abort and fail the required timeout-error assertion.The same run also passed the existing shared-stop TERM/KILL join tests, established-tunnel cancellation, startup-abort child-exit ordering, all six pending socket/retry failure/exit/abort joins, port fallback, and stderr-error controls.
The SSH child in these tests is synthetic. This is exact-revision observed proof at the changed public startup boundary with real sockets and timers; it is not an exact-revision real OpenSSH connection or authenticated Gateway-forwarding run. The earlier real-SSH evidence below remains labeled with its original revision. This addresses the latest review's request for observed forward/backward clock-step behavior without conflating these proof types.
Verified historical original-head CI
Upstream CI run 33526979240 ran the original
20fa5557cb1c7dc10feb3c9a5ee26de18abf8da4change through merge4651df2aae67335d0d599a9cb9d703992b7985a9. All 14 SSH tests passed, including both wall-clock regression cases at 255 ms. The tested owner and test blobs match the original PR change.Retrieved original real-SSH proof
The contributor's proof run and artifact were downloaded and inspected, resolving the artifact-access limitation in an earlier ClawSweeper review. Its workflow has empty GitHub permissions, anonymously fetches the immutable source revisions, and runs the real OpenSSH client, real listener probes, and real timers with isolated state.
f1fb06eef9b46b55359f27451c10f0ba0996b53420fa5557cb1c7dc10feb3c9a5ee26de18abf8da4The original workflow's backward scenario holds
Date.now()constant; the independent baseline above additionally performs an actual backward step. The retrieved workflow tests a stalled TEST-NET SSH connection, so this evidence proves startup-timeout behavior rather than successful authenticated Gateway forwarding.Additional validation recorded by the contributor on the original revision
The contributor recorded 14 passing SSH boundary tests, successful core/test type checks, Oxlint and formatting, and one real SSH/Gateway forwarding QA case:
The upstream CI and retrieved startup proof were independently inspected. The separate successful-forwarding QA command above was reported by the contributor and has not been independently rerun for the revised candidate.
Final revision validation
The final revision retains the current main's abortable readiness loop, joined socket cleanup, shared stop promise, and port allocator. A fresh independent P0 review of the complete two-file candidate passed with no findings. Exact-head CI is successful, and the final 23-test SSH boundary run is recorded above. Historical original-head evidence remains separate. A final-revision real OpenSSH/Gateway forwarding run has not been performed.