Skip to content

fix(ssh): preserve interrupted installation outcomes through retries - #23273

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/np-ssh-interrupted-install-cleanup
Sep 27, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/np-ssh-interrupted-install-cleanup

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When an SSH installation times out, its remote command may still be running. Orca now keeps that uncertainty through its retry and cleanup paths, preventing conflicting retries or removal of files the command may still use.

What Changed

  • Preserve the existing unconfirmed-termination error through install probes, lock/claim handling, ripgrep installation, and cleanup callers.
  • Wait for both optional installers before cleanup; serialize them on single-command SSH transports. An admitted bootstrap probe finishes before a refused parallel session retries sequentially.
  • Preserve staging files and locks after uncertain mutations. Keep an already-connected relay usable if its launch-lock release cannot be confirmed, while disabling further optional work.
  • Guard restoration after a failed read-only cache-reference recheck, then propagate the original uncertainty.

Why

Best-effort catches previously erased the transport error that prevents unsafe retries. Carrying that existing information fixes the decision without a new scheduler or wire protocol.

This is 1 of 2 split PRs. Cache listing, abandoned-cache claims, legacy recovery, and completion-marker changes belong to the stacked cache-recovery PR #23281. This PR is independently buildable and tested; merge it first.

Linked Issue

No existing issue. Follow-up to #23128; split from the previously reviewed combined #23273.

Visual Proof

N/A — SSH installation and cleanup logic; no rendered UI changes.

Testing

  • Exact first-PR snapshot: 2,697 SSH tests passed, 22 skipped across 185 files; Node type checking passed.
  • Fault injection exercises probes, staging, locks, claims, cleanup, launch retention, concurrent/single-command transports, and retry suppression.
  • Independent Codex review of this exact split found no blockers or missing dependencies. Dedicated Claude Opus review found no P0/P1; final split-head CI passed, including Docker SSH E2E.
  • I manually tested these changes locally
  • Automated tests added/updated

Review

The original combined implementation passed full CI and Codex/Opus review. Both split PRs received fresh independent Codex and Claude Opus review; no blockers found. The combined source tree is unchanged. An unused restore-command deletion was moved into this first PR after review.

Agent skill upstream boundary

  • Not applicable; no upstream skill source or instructions copied.

Notes

Uncertain GC claims remain until the existing stale-recovery window. Unconfirmed sibling termination can take diagnostic precedence over an earlier bootstrap failure; an optional pre-launch timeout may stop that connect rather than assume the command ended. These safety tradeoffs are intentional. Confirmed optional failures retain their fallbacks. No package split, wire change, tracking document, or migration change.

Checklist

  • Focused on interrupted installation and retry decisions
  • Explained behavior, mechanism, and approach
  • Cross-platform and SSH boundaries considered
  • No rendered UI change
  • Final split-head CI passes

@OrcaWin
OrcaWin marked this pull request as ready for review September 26, 2026 21:32
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2dcf514f-9bc6-400d-8ccf-070f4fdd488e

📥 Commits

Reviewing files that changed from the base of the PR and between 3544e8f and 9eeef0a.

📒 Files selected for processing (2)
  • src/main/ssh/ssh-relay-native-deps-cache-gc.ts
  • src/main/ssh/ssh-relay-ripgrep-cache-gc.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Remote SSH install, deployment, lock, and garbage-collection paths now distinguish unconfirmed command termination from other failures. Unconfirmed termination errors propagate instead of triggering fallback results or further cleanup commands. Cache collectors use guarded moves and reference checks, and attempt to restore renamed entries when scans fail or find references. Tests cover confirmed and unconfirmed outcomes across Linux and Windows paths.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 9eeef

The new Orcad GC test is expected to fail, blocking the SSH test workflow. Correct its classifier mock before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 9eeef

The reviewed paths generally preserve locks and staged files, stop cleanup after uncertain remote operations, and wait for overlapping work before retrying. No introduced security exposure was established, but recovery behavior and incomplete coverage leave some uncertainty.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The repository-visible effect is bounded to operations performed with an existing SSH connection against remote installation and cache assets. Attacker control of SSH failures, tenant scope, and runtime reachability were not established.

Trust Boundaries and Controls

  • observed — Callers distinguish an SSH command whose channel closure is unconfirmed from an ordinary error, then retain ownership fences or halt cleanup rather than treating the remote mutation as finished.

Resilience and Maintainability Implications

  • inferred — Retaining locks and stopping the cleanup chain favors containment over immediate recovery after interruption. Best-effort restoration of ordinary failures remains a recovery limitation, but its introduction or material worsening by this PR was not established.

Hardening Proposals

  • proposed — For future recovery hardening, verify that restoration returned a usable destination before considering a referenced cache entry recovered, including when the command reports a destination conflict.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 33 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the SSH installation change and its purpose: preserving interrupted outcomes through retries.
Description check ✅ Passed The description includes all template sections, explains the user-facing behavior and mechanism, documents testing and platform coverage, and identifies the related pull requests and issue context. It…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Minor suggestions only — one latent native-deps cache data-loss path worth hardening.

Reviewed changes

  • Uncertainty propagation across all SSH install/GC paths — adds isUnconfirmedSshCommandTermination(...) → rethrow to the best-effort catches in orcad-remote-install.ts, orcad-remote-gc.ts, remote-install-gc.ts, ssh-relay-gc-claim.ts, ssh-relay-gc-tombstone.ts, ssh-relay-install-lock.ts, ssh-relay-repair-lock.ts, ssh-relay-ripgrep-cache-gc.ts, ssh-relay-ripgrep-install.ts, ssh-relay-superseded-endpoints.ts, ssh-relay-versioned-install.ts. Confirmed failures keep their prior fallbacks.
  • Deploy orchestration (ssh-relay-deploy.ts) — resolveRelayBootstrapState no longer aborts the admitted sibling probe on a session-limit error and now surfaces an unconfirmed sibling rejection; the upload/lock/promote block is flattened to one outer catch that sets uploadStageCleanupAllowed = !unconfirmed; launchRelay moves outside the launch try, launchLivenessObserved is replaced by launchCleanupSettled, and background cleanup is now gated on Promise.all([ripgrepInstall, runtimeInstall]) so it is serialized behind both installers on all transports.
  • Native-deps cache GC — tombstone prefix renamed .gc-tombstone. → .native-gc- (legacy still read) so older clients' mtime-only sweep can't delete new tombstones; the shell listing now returns tombstones instead of sweeping them in-shell; GC restores a referenced tombstone and removes an unreferenced abandoned tombstone without re-renaming. restoreRemoteTreeCommand is extracted to ssh-remote-commands.ts (POSIX now also refuses a dangling-symlink destination) and replaces the removed restoreEntryCommand.
  • Tests — new fault-injection suites across install lock, GC claim, repair lock, versioned install, orcad install, ripgrep install/cache, superseded endpoints, plus real-shell POSIX transactions for the native cache.

The concurrent-bootstrap, launch-fence, and stage-cleanup changes were traced against the old behavior: cleanup is strictly more serialized, unconfirmed fence/claim failures are preserved for stale recovery, and the error-precedence shifts are the stated intent. One finding below.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (597ba83): commit 50554f349c, which hardens the native-deps and ripgrep cache collectors against a clock step during GC.

  • Stamped tombstone identity at parse time — parseCacheEntryListing (ssh-relay-native-deps-cache-gc.ts) now returns {name, key}[] and parseEntries (ssh-relay-ripgrep-cache-gc.ts) returns {name, entry}[], deriving the key/entry once where the listing is parsed. The GC loops consume that stamped value instead of recomputing the Date.now()-dependent staleTombstoneKey/staleTombstoneEntry after the awaited reference scan, so a backward wall-clock step can no longer reclassify an admitted tombstone and bypass its reference check.
  • Real-shell clock-step regressions — both -real.test.ts suites now mock Date.now() to step backward while the reference scan runs, and assert the referenced tree is restored and preserved. These fail against the pre-fix code, so they genuinely cover the finding.

The prior inline thread on ssh-relay-native-deps-cache-gc.ts:114 was addressed by this commit and is already resolved; no remaining concerns. config/scripts/hourly-build-version.test.mjs appears in commit 50554f349c but is net-zero against main and therefore not part of the PR diff.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 779ab66e-aa2f-449a-ac16-74385a458334

📥 Commits

Reviewing files that changed from the base of the PR and between ee6281f and 7ba47f5.

📒 Files selected for processing (34)
  • src/main/ssh/orcad-remote-gc.test.ts
  • src/main/ssh/orcad-remote-gc.ts
  • src/main/ssh/orcad-remote-install-termination.test.ts
  • src/main/ssh/orcad-remote-install.ts
  • src/main/ssh/remote-install-gc-termination.test.ts
  • src/main/ssh/remote-install-gc.ts
  • src/main/ssh/ssh-relay-deploy-staged-upload.test.ts
  • src/main/ssh/ssh-relay-deploy-windows-pipe.test.ts
  • src/main/ssh/ssh-relay-deploy.test.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/ssh/ssh-relay-gc-claim-termination.test.ts
  • src/main/ssh/ssh-relay-gc-claim.ts
  • src/main/ssh/ssh-relay-gc-retry.test.ts
  • src/main/ssh/ssh-relay-gc-tombstone.ts
  • src/main/ssh/ssh-relay-install-lock-termination.test.ts
  • src/main/ssh/ssh-relay-install-lock.ts
  • src/main/ssh/ssh-relay-native-deps-cache-commands.ts
  • src/main/ssh/ssh-relay-native-deps-cache-gc-real.test.ts
  • src/main/ssh/ssh-relay-native-deps-cache-gc.ts
  • src/main/ssh/ssh-relay-native-deps-cache.test.ts
  • src/main/ssh/ssh-relay-native-deps-cache.ts
  • src/main/ssh/ssh-relay-repair-lock-termination.test.ts
  • src/main/ssh/ssh-relay-repair-lock.ts
  • src/main/ssh/ssh-relay-ripgrep-cache-gc-commands.ts
  • src/main/ssh/ssh-relay-ripgrep-cache-gc-real.test.ts
  • src/main/ssh/ssh-relay-ripgrep-cache-gc.ts
  • src/main/ssh/ssh-relay-ripgrep-install.test.ts
  • src/main/ssh/ssh-relay-ripgrep-install.ts
  • src/main/ssh/ssh-relay-superseded-endpoints.test.ts
  • src/main/ssh/ssh-relay-superseded-endpoints.ts
  • src/main/ssh/ssh-relay-versioned-install-termination.test.ts
  • src/main/ssh/ssh-relay-versioned-install.test.ts
  • src/main/ssh/ssh-relay-versioned-install.ts
  • src/main/ssh/ssh-remote-commands.ts
💤 Files with no reviewable changes (1)
  • src/main/ssh/ssh-relay-ripgrep-cache-gc-commands.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread src/main/ssh/orcad-remote-gc.test.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (50554f3): the merge of main (7ba47f50, no src/main/ssh change) and commit 3544e8f6, "claim abandoned cache trees before recovery".

  • Claim-by-rename in both cache GCs — recoverAbandonedTombstone now renames an abandoned tombstone to a fresh random name (ownedTombstonePath: randomInt(1, 2**47) + Date.now()) before any restore or delete, so only the pass whose rename wins acts on it; collectOwnedTombstone rechecks references under the rename and restores when referenced or the scan is unreadable, else deletes. The fresh name sits outside the 30-minute staleTombstoneKey/staleTombstoneEntry window, and moveRemoteTreeCommand answers MOVED/BUSY, so a losing pass returns without deleting.
  • Native completion-marker discipline — ssh-relay-native-deps-cache-commands.ts adds restoreRelayNativeDepsCacheTombstoneCommand (requires .deps-complete and an absent destination), dropRelayNativeDepsCacheCompletionMarkerCommand, and removeRelayNativeDepsCacheTombstoneCommand (drop marker && rm -rf). An interrupted deletion can no longer be restored as complete. Legacy .gc-tombstone. trees are deliberately unmarked before claiming and never auto-restored; the referenced-but-unrestorable outcome is asserted by the new real-shell tests.
  • Rethrow propagation — the native listing, reference-scan, move, and remove paths now rethrow isUnconfirmedSshCommandTermination; the recheck error path attempts a self-restore then rethrows the scan error.
  • Tests — real-shell claim-race and interrupted-deletion regressions in both -real.test.ts suites; startsWith('rm -rf') assertions relaxed to includes('rm -rf') because the native removal command now begins with the marker-drop group. I ran the four directly affected suites (121 tests) and they pass.

The prior clock-step inline thread is resolved and the two candidate concerns a specialist surfaced (ripgrep lacks a native-style completeness marker; a shell-level restore/delete TOCTOU on the same tombstone) were validated and dropped: the ripgrep restore behavior is unchanged from the prior commit and its completeness is enforced downstream by the size-checking probe, and the TOCTOU needs a second actor on the same fresh name, which the fresh-name plus stale-window discipline precludes.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin force-pushed the OrcaWin/np-ssh-interrupted-install-cleanup branch from 3544e8f to 310fa67 Compare September 27, 2026 00:21
@OrcaWin OrcaWin changed the title fix(ssh): preserve interrupted installs through cleanup and retries fix(ssh): preserve interrupted installation outcomes through retries Sep 27, 2026
@OrcaWin
OrcaWin force-pushed the OrcaWin/np-ssh-interrupted-install-cleanup branch from 310fa67 to 9eeef0a Compare September 27, 2026 00:25

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — the split is coherent; one dead export left behind by the refactor.

Reviewed changes

This run re-reviewed the delta since the prior pullfrog review (3544e8f): the branch was force-pushed into a single commit that narrows the PR to the interrupted-install outcome propagation, moving the cache-recovery half to a stacked PR.

  • Dropped the cache-recovery half — the native-deps claim-by-rename, the native tombstone shell commands, and the real-shell cache-recovery suites are gone; the native cache listing/parser reverted to the base implementation.
  • One shared tree restore — restoreRemoteTreeCommand in ssh-remote-commands.ts (POSIX also refuses a dangling-symlink destination) replaces moveRemoteTreeCommand/restoreEntryCommand in both cache collectors.
  • Retained the uncertainty propagation and deploy orchestration — the isUnconfirmedSshCommandTermination → rethrow wiring across install locks, GC claims, repair locks, versioned installs, ripgrep install/cache, orcad install/GC, and superseded endpoints is unchanged, as is the deploy launch-fence and cleanup serialization.
  • Verified locally — the seven new *-termination suites (245 tests) and eight affected deploy/cache suites (209 tests) pass against this head.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 6433c3c into main Sep 27, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant