Repository navigation
fix(ssh): recover abandoned caches without deleting live dependencies - #23281
Conversation
34ec82f to
fab1e57
Compare
310fa67 to
9eeef0a
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This reviews the seven-file delta against the installation/retry branch: the native-deps and ripgrep cache GC now recover an abandoned tombstone by claiming it with a fresh rename, and only restore or delete it after a reference recheck.
- Native tombstone recovery (
ssh-relay-native-deps-cache-gc.ts): the listing yields{name, key}for complete entries and stale tombstones, and each abandoned tombstone is claimed by a randomized rename before the recheck decides restore vs. delete. - New native tombstone namespace (
ssh-relay-native-deps-cache.ts,-commands.ts): the prefix moves to.native-gc-so an older client's mtime-only.gc-tombstone.*sweep can no longer blind-delete a live tree; the listing-time sweep is dropped and tombstones are recovered instead. - Marker-gated restore (
-commands.ts): restore requires.deps-completeand an absent destination, and deletion drops the marker beforerm -rf, so a partially deleted tree can never be restored as complete. - Reference-scan hardening (
-commands.ts): the reference listing answersREFS_ERRwhen the install root or any child directory is unreadable, closing a hole where a narrowed reference set could authorise a deletion. - Ripgrep parity (
ssh-relay-ripgrep-cache-gc.ts): abandoned ripgrep tombstones are claimed and restored the same way, with timestamps validated as safe integers. - Tests (
*-gc-real.test.ts,native-deps-cache.test.ts): real-shell regressions for competing passes, clock movement, partial deletion, legacy recovery, unreadable references, and recreated destinations.
I read the complete seven-file delta, traced the claim/recheck paths and their callers, and ran pnpm tc:node, oxlint on the changed files, and the four touched test files (90 tests) — all green. Two independent sub-reviews found no reachable interleaving of two GC passes, or a GC pass with a deploy/installer, in which the new claim logic deletes the only copy of a live-referenced tree: every deletion routes through a fresh reference scan under the rename, and keep = true never deletes.
ℹ️ Referenced legacy tombstones are preserved but never restored
A legacy .gc-tombstone. tree is unmarked before it is claimed, so the marker-gated restore always answers BUSY and the tree is left under a fresh .native-gc- name; a relay that still references it keeps a dangling node_modules and must reinstall. While the reference persists, each pass past the 30-minute staleness window re-claims that directory under a new random name — bounded to one rename per window, not a growing leak. This matches the conservative choice documented in the PR Notes; no change requested.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The head moved from 34ec82f to fab1e57c, a rebase onto the updated base (9eeef0a). The generated PR diff is byte-for-byte identical (diff -q on the two revisions), so no source changed since the prior review — its findings stand: no blocking or must-address issues, plus the one informational note about referenced legacy tombstones never being restored. No further comments.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
fab1e57 to
b9759a6
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughNative-dependency cache garbage collection now lists current and legacy tombstones, claims stale tombstones, and rechecks references before removing or restoring entries. Ripgrep cache garbage collection now uses the same claim-and-recovery pattern. New tests cover recovery, deletion, reference-scan errors, interrupted operations, concurrent passes, and destination changes. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Cache recovery is safe for live dependencies. However, some leftover native-dependency directories can stay on remote disks for as long as a relay references that dependency set. This is a bounded disk-usage follow-up, not a merge blocker. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Recovery is better protected against competing cleanup passes, but a previously interrupted deletion of the shared search-binary cache can be restored without checking that its contents are complete. The demonstrated scope is relays sharing an affected SSH host; no privilege escalation is established. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 33629e79-8f82-4f47-9ab1-077bb672578f
📒 Files selected for processing (7)
src/main/ssh/ssh-relay-native-deps-cache-commands.tssrc/main/ssh/ssh-relay-native-deps-cache-gc-real.test.tssrc/main/ssh/ssh-relay-native-deps-cache-gc.tssrc/main/ssh/ssh-relay-native-deps-cache.test.tssrc/main/ssh/ssh-relay-native-deps-cache.tssrc/main/ssh/ssh-relay-ripgrep-cache-gc-real.test.tssrc/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; 6 remain after this review.

ELI5
An interrupted cache deletion can leave the only copy of a running SSH relay’s dependencies in a renamed directory. Orca now checks who still needs that copy and lets only one cleanup pass recover or delete it.
What Changed
Why
Age alone does not establish that a cache is unused or intact. Reference checks, a claim rename, and completion markers address those separate facts without introducing a cache database or global scheduler.
This is 2 of 2. #23273 is merged; this PR is rebased onto main and contains only the seven-file cache-recovery change. The patch is byte-for-byte identical to the reviewed stack delta.
Linked Issue
No existing issue. Cache-recovery portion split from #23273, following #23128.
Visual Proof
N/A — remote cache cleanup and recovery; no rendered UI changes.
Testing
3544e8f675, which passed full CI and 2,742 local SSH tests (22 skipped).Review
Fresh reviews inspect this seven-file delta separately from installation/retry behavior. No new behavior was added while splitting. Both Codex and Claude Opus independently reviewed this split; no blockers found.
Agent skill upstream boundary
Notes
Referenced legacy native leftovers are retained but not automatically restored as complete; reconnect may need to reinstall dependencies. A replacement at the original path can leave an extra recovery copy. These conservative choices preserve files under uncertainty. Bounded listings and future-dated names can delay cleanup; a concurrent claim can also make a removal log overcount without deleting the other pass’s files. POSIX shell paths run locally; Windows paths receive generated-command and fault-injection coverage plus CI. No tracking/design documents included.
Checklist