Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(ssh): report remote stop failures without losing ownership #10105

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/10105/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

SSH stop could report success and remove ownership files while the remote server still ran. An active disconnect also hid stop-command failures in scope cleanup.

Check that the saved process has exited before removing its PID, port, and ownership files. If it stays alive after the existing two-second wait, keep those files and return SshCommandError. Explicit disconnect now returns that error and permits a later retry. Local tunnel cleanup keeps its existing termination bound.

Run connect and disconnect in order for each target, so reconnect cannot overtake an earlier stop. This replaces the separate pending-attempt bookkeeping. Disconnect waits for an earlier startup on the same target. Other targets can still connect.

External servers remain running. No remote force-kill was added. App shutdown and environment removal keep their existing best-effort policy.

Verification

  • The new real-shell timeout test and disconnect failure test both failed before the fix. The other 31 controls passed.
  • All 42 focused runner, tunnel, and command tests pass, including app cleanup.
  • Two gated reconnect tests failed before per-target ordering. They now cover held local and remote shutdown, shared reconnects, and progress on another target.
  • Real /bin/sh tests cover graceful exit, retained ownership after an ignored SIGTERM, a successful retry, and external-server protection. Fixtures use captured child handles and isolated state.
  • SSH package typecheck, changed-file lint and formatting, and git diff --check pass.

Process checks ran on Linux. No live remote host, live state, or browser was used. There are no UI changes.

Created with GPT-6 Astra in Codex.

Note

Report remote stop failures in disconnectEnvironment and preserve ownership on timeout in buildRemoteStopScript

  • Replaces the per-target pending-entry Deferred map with a per-target Semaphore map so concurrent ensureEnvironment and disconnectEnvironment calls for the same target serialize through one lock.
  • buildRemoteStopScript now checks process liveness after the two-second wait; if the process is still alive it exits unsuccessfully and leaves the PID, port, and ownership files in place for a later retry.
  • Explicit disconnect closes the local tunnel before stopping the remote server and returns a remote stop failure to the caller instead of suppressing it.
  • The tunnel scope finalizer always terminates the local SSH process (even for stale entries), runs owner remote shutdown after local termination, and ignores remote-stop failures.
  • Behavioral Change: disconnectEnvironment can now return errors from buildRemoteStopScript timeouts; ensureTunnelEntry no longer returns a shared pending Deferred result.
Macroscope summarized 4622bec.
    1. Bugbot is paused — on-demand spend limit reached

      Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

      A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.5 KiB13.5 KiB+19 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB−3 B (−0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.5 KiB6.5 KiB+22 B (+0.3%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.0 KiB57.0 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages880 (0.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.6 KiB−28 B (−0.2%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB+1 B (+0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.6 KiB6.5 KiB−29 B (−0.4%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.9 KiB57.8 KiB−44 B (−0.1%)66.4 KiB✅
      ClaudeLive turn messages109−1 (−10.0%)21✅

      Baseline: 7544d3d · PR result: 4622bec · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at aae2e1f

      Macroscope's review found this PR approvable — This is a focused SSH shutdown bug fix that preserves remote ownership on stop failure, surfaces explicit disconnect errors, and serializes reconnects per target. Production changes are confined to the tunnel manager and are covered by targeted lifecycle and concurrency tests.

      No code changes detected at 4622bec. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.