Repository navigation
Conversation
|
Warning Review limit reachedNext included review available in 4 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (26)
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.
ℹ️ Minor suggestion only — the widening itself is sound.
Reviewed changes
- Runtime-host retirement widening —
forgetPersistedWorktreeMetaForRemovalsand theworktrees:forgetRemovedForExecutionHosthandler now acceptruntime:hosts alongsidessh:, letting a paired client drop persistedworktreeMetarows a runtime scan proved gone. - Per-kind connection guard — the handler's SSH-only
connectionId === targetIdcheck becomes a per-kind check (SSH requires the named connection, runtime requires none). source === 'git'gate — persisted retirement now fires only for a real scan, excluding the truncatedsession-fallbacklegacy listing.OffHostExecutionHostIdcontract type — widensForgetRemovedWorktreesForExecutionHostArgs.executionHostIdfrom SSH-only tossh:|runtime:.
The core fix is correct and well-reasoned: gcStaleWorktreeMeta only condemns local-on-local rows, so runtime-host rows genuinely had no other retirement path, and the source === 'git' gate correctly keeps the truncated session-fallback listing from deleting persisted state. One observation inline about the new connection guard.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
14268f9 to
ee7b95a
Compare
|
Confirmed and fixed — pushed @pullfrog: the runtime arm of Dropped the arm rather than keeping it as defence-in-depth: unreachable code on a destructive path reads as a guarantee it is not making. Kept the SSH arm, which does gate. The test stays — it pins the behavior, which is what matters — with a comment naming |
There was a problem hiding this comment.
ℹ️ Minor: the claimed drop didn't land in the handler.
Reviewed changes
- Reworded the runtime-refusal test comment —
ee7b95aupdatesworktrees-ssh-repo-owner-resolution.test.tsso the connection-backed-repo case namesfindExactRepoOwneras the refusal, rather than implying the handler's runtime arm rejects it. The handler itself was not touched.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
c92c287 to
b3fc07e
Compare
|
@pullfrog is right and I was wrong. Fixed in The gate is now: const repo = findExactRepoOwner(store, args?.repoId ?? '', requestedExecutionHostId)
if (!repo || (parsedHost.kind === 'ssh' && repo.connectionId !== parsedHost.targetId)) {
return nothingForgotten
}The analysis in my earlier comment still stands — Branch restacked on the updated #17893/#17890, which also picked up a strengthened persistence assertion from @coderabbitai's review there. |
|
Tip For best results, initiate chat on the files or code changes.
The updated gate is correct. ✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
|
Confirmed against the committed file:
const repo = findExactRepoOwner(store, args?.repoId ?? '', requestedExecutionHostId)
if (!repo || (parsedHost.kind === 'ssh' && repo.connectionId !== parsedHost.targetId)) {
return nothingForgotten
}The comment above it now documents why there is no runtime arm, so the code reads as the guarantee it actually makes. The analysis stands and the diff now matches it — no further action needed.
|
|
Run failed. View the logs →
|
These three PRs are a strict stack, not three peers — verifiedAll three declare So the "20+ shared files" are not overlap — they are the same commits appearing three times, with byte-identical shared hunks. Consequence: do not squash-merge the lower onesIn stack order (#17890 → #17893 → #17901) there are no conflicts and each later PR simply shrinks. The hazard is squash-merge + rebase: If #17890 is squash-merged, That is exactly where a fix gets silently dropped: the correct resolution is skip, and a mechanical "take ours/theirs" on the test files would look plausible while losing coverage. Recommendation: use merge commits, or simply land #17901 alone — it contains the other two in full. Do not rebase the upper branches after a squash of a lower one. #17901 must stay atomic — splitting it risks metadata deletionThis is the only one of the three that edits an existing gate, and it moves it in both directions within the same PR:
The narrowing is load-bearing for the widening. If anyone cherry-picks the runtime-widening commit without the Not an unsafe pairWorth stating the negative result plainly: there is no pair among these three that can land without another and destroy data, because no pair is independently landable. #17893 cannot ship without #17890's content and #17901 cannot ship without both. The risk here is entirely in the merge mechanics, not in partial landing. |
b3fc07e to
fefff81
Compare
Deregistering a project stranded every row it owned. Each pruning path is gated on the repo still being in `state.repos`, so once an id leaves the catalogue its metadata, identity aliases, lineage and session rows became unreachable forever -- and on a paired client they rendered as phantom worktrees under an "Unknown" project. Reconcile against the repo catalogue on load instead: any repo id that owns rows but is absent from `state.repos` has its rows removed through the same path `removeProject` uses. Host-independent and session-independent, because an orphan has no owner that could object -- which is also why this reaches a client's mirror of a remote host's session partition, something no local removal can do. Only a full `<repoId>::<path>` locator seeds the orphan set; bare keys can be folder workspace ids or repo-keyed revisions, and guessing wrong there would delete live state. `retiredWorktreeNamesByRepo` is deliberately untouched so a re-added repo cannot reissue a name onto a cwd that still holds a prior occupant's agent state. Test fixtures that wrote worktree rows without registering their repo were relying on orphans surviving a reload; they now register the repo they name. Refs stablyai#17776
…ing orphans Review found three holes in the load-time sweep. `sleepingAgentSessionsByPaneKey` and `terminalSurfaceTombstonesByPaneKey` are pruned by the worktreeId they name, not by their own key, but `pruneWorktreeStateForRepo` only collected owner keys from `worktreeMeta` and `lastVisitedAtByWorktreeId`. An orphan whose only residue was a sleeping agent therefore survived the sweep and re-seeded it on the next load, so the store never self-cleared and every launch scheduled another save. Collect owner keys from those records too, which fixes `removeProject` for the same shape. `ownerKeyBelongsToRepo` is restored to its original body. Reordering its two readings was not behavior-preserving as claimed: for a repo named `folder` or `worktree`, checking the workspace-key reading first flips the result. The census now uses `ownerKeyWorktreeIds`, which returns both readings, and seeds only when neither names a live repo -- seeding one reading of a key whose other reading is live would hand the removal pass a live row to delete. Seed from `activeWorktreeId`, `activeWorkspaceKey` and `activeWorktreeIdsOnShutdown`, which are pruned by bespoke rules and so were reachable by no owner-key loop, and record why `terminalTopologyRevisionByRepoId` stays excluded. Refs stablyai#17776
The self-clearing check loaded a second store, but that constructor runs the sweep itself. If the first flush had not persisted the cleanup, the second load would have redone it in memory and the assertion would have passed without meaning anything. Read the profile back and assert the map is empty there first. Refs stablyai#17776
`activeWorktreeId`, `activeWorkspaceKey` and `activeWorktreeIdsOnShutdown` are pruned by bespoke rules rather than by owner key, so no owner-key loop reaches them and each has to be able to seed the sweep alone. The sweep already handles all three -- the census seeds from them and `removeRepoFromWorkspaceSession` clears them -- but nothing pinned it, and dropping that seeding turns all three cases red. The `activeWorkspaceKey` case uses the canonical `worktree:<id>` form, so it also covers unwrapping the workspace key before the repo id is visible. Refs stablyai#17776
…owns it
`pruneMetadataMissingFromAuthoritativeLocalScan` had exactly one caller:
`ipcMain.handle('worktrees:listAll')`. A headless runtime host has no
renderer, so it never ran, and that host's `worktreeMeta` grew without bound
even for its own local repos -- 129 of 139 rows dangling on the profile in
stablyai#17776.
Run it from the runtime's own detected listing instead. That is the same
trigger on the same evidence: `listDetected` already prunes lineage on an
authoritative scan, and a paired client refreshing a remote repo calls
`worktree.detectedList`, so the host now sweeps exactly when the desktop
would have.
The expectation is captured before the scan, because listing can mutate
metadata synchronously before its first await. WSL-routed repos are excluded
for the reason the desktop listing excludes them: the listing runs in the
distro and reports Linux paths while metadata can hold UNC ones, and v1
cannot prove those aliases equivalent. A runtime needing repair throws rather
than resolving routing, which is likewise no basis for deleting rows.
The prune's own gates still apply, so an SSH- or otherwise off-host repo is
never swept from a local stat -- the execution host owns that verdict.
Refs stablyai#17776
The row was stamped `ssh:build-box`, which `captureNativeLocalWorktreeMetadataScanExpectation` filters out before the prune runs -- so it survived whether or not any host gate existed and pinned nothing. Stamp it `local` so it is a genuine prune candidate whose directory really is missing, and make the fixture identical to the first case apart from `connectionId`. That pairing is what proves the behavior: the same fixture without a connection loses the row. Deleting any single gate would not show it, since four independent checks derive from `connectionId` on this path. Refs stablyai#17776
A paired client's WorktreeMeta for a runtime host is exempt from gcStaleWorktreeMeta -- that GC skips any row that is not local on both the repo and the meta's hostId -- so a scan-proven removal is the only thing that ever retires one. Both halves of that path were gated to `ssh:`, so the client kept a row for every remote worktree it had ever seen and dropped none. The renderer already computed the removals for runtime hosts and purged its own in-memory state with them; only the persisted half bailed. Widen it, and the matching main-side handler, to runtime hosts. `OffHostExecutionHostId` names the set precisely: the hosts the local-only GC skips. Also require `source === 'git'` before retiring anything. `session-fallback` reports `authoritative: true` but is the truncated, visibility-filtered `worktree.list` reply from a host too old for `worktree.detectedList`; its omissions are no evidence a checkout is gone. That guard did not matter while this only ran the in-memory purge, and does now that it deletes rows. A repo that reaches its checkouts over a connection is still never condemned under a runtime host id -- the host that executes owns that verdict. Refs stablyai#17776
`findExactRepoOwner` already refuses a repo carrying both a runtime `executionHostId` and a `connectionId` -- `resolveRepoOwnershipEvidence` calls that pair contradictory, and one non-owned candidate voids the whole lookup. There is also no way for a `connectionId` to yield a `runtime:` host id, since `toSshExecutionHostId` always emits `ssh:`. The runtime arm of `connectionMatchesHost` could therefore never decide anything, and the test meant to pin it was passing through the contradiction gate instead. Keep the SSH arm, which does gate, and record where the runtime refusal actually comes from. Unreachable code on a destructive path reads as a guarantee it is not making. Refs stablyai#17776
fefff81 to
5153041
Compare

ELI5
When you use Orca on your laptop against a remote Orca host, your laptop remembers a little record for every worktree it has ever seen on that host. Orca already knows how to throw those away once the host reports the worktree is gone — but the code only did it for SSH hosts, not for paired runtime hosts. So on a paired laptop the records only ever accumulated. This makes that cleanup run for runtime hosts too.
What Changed
authoritative-worktree-removal-memory.ts—forgetPersistedWorktreeMetaForRemovalsnow acceptsruntime:hosts as well asssh:.register-host-catalog-handlers.ts— the matchingworktrees:forgetRemovedForExecutionHosthandler does the same. The SSH-onlyrepo.connectionId === parsedHost.targetIdcheck becomes a per-kind check: SSH requires the connection the host id names, runtime requires no connection at all.detected-worktree-provider-contract.ts— newOffHostExecutionHostIdfor theForget…Argshost field. It names the set precisely: the hostsgcStaleWorktreeMetaskips. The SSH-specific listing contracts in the same file keepSshExecutionHostId.fetched-worktree-merge.ts— retirement now additionally requiressource === 'git'.The renderer already computed authoritative removals for runtime hosts and purged its in-memory state with them (
getRemovedWorktreeIdsAfterAuthoritativeScanis not host-gated). Only the persisted half bailed, so no new evidence is being introduced here — an existing verdict is being allowed to reach the store.Why
gcStaleWorktreeMetaonly ever condemns a row when the repo is local andmeta.hostIdis local. Every off-host row is therefore exempt, and a scan-proven removal is the only thing that ever retires one. The comment onforgetPersistedWorktreeMetaForRemovalssaid exactly this — but scoped the reasoning, and the guard, to SSH.A paired client's host is
runtime:<env-id>, so it fell through the guard: nothing local GC'd those rows, and nothing scan-driven retired them either. That is the client-side half of #17776's unbounded growth — 1,458worktreeMetarows against 19 live directories.The
source === 'git'guard.toLegacyDetectedWorktreeResultreturnsauthoritative: truewithsource: 'session-fallback'. That is theworktree.listreply used against a host too old forworktree.detectedList— truncated atREMOTE_WORKTREE_LIST_PARITY_LIMITand visibility-filtered, so its omissions do not mean "gone". While this only drove the in-memory purge the distinction was tolerable; now that it deletes persisted rows it is not, so retirement requires a real scan. This also tightens the pre-existing SSH path.Execution boundary. A repo with a
connectionIdis never condemned under a runtime host id, because that host does not execute for it. The per-kind connection check enforces this, and there is a test for it.Linked Issue
Refs #17776
Visual Proof
N/A— no UI code changes. The change removes persisted rows that were already excluded from the rendered list by the in-memory purge, so there is nothing visually different to capture.Testing
New
src/renderer/src/store/slices/worktrees-runtime-host-metadata-retirement.test.ts:authoritative: false)session-fallbacklistingNew cases in
src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts:I confirmed both the renderer and main-side additions fail with the widening reverted, so neither passes vacuously. The existing "refuses to retire metadata for non-SSH hosts" case still passes on
localand is renamed to "non-executing hosts", which is what it now checks.pnpm tc— cleanpnpm run check:code-quality:changed— 0 findingspnpm test src/main/ipc src/renderer/src/store— 6608 passed, 0 failedPlatforms: logic is platform-independent. Verified on macOS; the SSH and runtime branches are covered by unit tests rather than live hosts.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Claude Opus 4.5 (Claude Code).
Review
Agent skill upstream boundary
Notes
worktrees:forgetRemovedForExecutionHostis a local IPC between this client's renderer and its own main process; nothing new is sent to a host. The newsource === 'git'guard is specifically what keeps an older host safe: itsworktree.listfallback can no longer retire anything.sourceguard makes the path a no-op rather than a risk.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally (pnpm buildleft to CI)