Skip to content

Fix worktree identity collisions across hosts - #16691

Merged
nwparker merged 19 commits into
stablyai:mainfrom
nwparker:nwparker/worktree-id-hosts-face-with-monocle
Aug 27, 2026
Merged

nwparker merged 19 commits into
stablyai:mainfrom
nwparker:nwparker/worktree-id-hosts-face-with-monocle

Conversation

@nwparker

@nwparker nwparker commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca used a repository path as if it uniquely identified a worktree everywhere. But a local machine and an SSH host can both have the same repository at the same path, so Orca could confuse the two and apply metadata or actions to the wrong one.

This PR gives each checkout a stable identity that includes both its execution host and its own persistent instance ID. Orca can now distinguish “this checkout on my laptop” from “the checkout at the same path on the SSH host,” while continuing to use the existing path-based ID anywhere Git or the filesystem requires it.

What Changed

  • Added an immutable wt2:<host>:<instance> worktree identity derived from the execution host and persisted checkout instanceId.
  • Retained the existing repoId::path value as the Git/filesystem locator and added identity:<identity> as an exact CLI/runtime selector.
  • Added identity-keyed metadata plus host-qualified locator aliases, with lazy migration and repair for legacy or malformed persisted state.
  • Routed single and bulk metadata mutations through host/identity context, including status, pinning, ordering, board moves, review state, rename, and linked-review updates.
  • Made ambiguous writes fail closed. Ambiguous reads choose a deterministic presentation row while preserving all competing identity records.
  • Scoped rename, removal, pruning, cleanup, discovery, degraded SSH listings, and workspace-space scans to the owning host.
  • Hardened SSH target re-adoption so missing identities are repaired, destinations are preflighted, equivalent rows deduplicate safely, and divergent source metadata is preserved.
  • Included canonical-only worktrees in disconnected SSH listings, degraded runtime rows, and cleanup candidates without leaking them across hosts.
  • Kept new identity fields optional so independently updated desktop clients and remote hosts remain wire-compatible.
  • Reused metadata snapshots and repo-owner hydration across catalog work to avoid repeated scans introduced by host-qualified lookup.

Why

Worktree.id is a path-derived locator, not a globally unique identity. Two execution hosts can legitimately publish the same locator. Before this change, a bare-ID read or mutation could select, overwrite, prune, or remove another host's workspace metadata.

The migration is deliberately additive: identity and ownership use the new host/instance key, while Git and filesystem operations continue receiving the established locator. This avoids a breaking replacement of existing IPC, RPC, CLI, and persisted-state contracts.

Code Elegance and Size

The size concern was valid, so the final pass separated production code from tests/support and removed redundant abstractions:

  • The cleanup itself is 135 additions and 222 deletions: 87 net lines removed.
  • The final PR is 1,037 net production-like lines and 1,058 net test/support lines. Roughly half of the net change is validation, fixtures, and support rather than shipping code.
  • The cleanup reused canonical identity composition, centralized metadata normalization, removed the obsolete Map-shaped batch API and an unsafe fallback cast, and simplified alias resolution plus SSH reassignment control flow.
  • The remaining production size implements the coupled persisted-identity migration, repair behavior, host-qualified routing, and mixed-version SSH compatibility. Removing those paths would weaken data preservation or backward compatibility rather than merely simplify presentation.

Why Merge Risk Is Low

  • The migration is additive. The existing locator and selectors remain in place; the canonical identity and exact selector are additional fields and routes.
  • Unsafe ambiguity fails closed. A mutation without enough host/instance context is rejected instead of guessing. Reads preserve every canonical record and choose only a deterministic presentation row.
  • Malformed legacy data cannot delete healthy canonical state. Repair and cleanup are host-scoped, and divergent SSH re-adoption preserves the source metadata rather than overwriting or discarding it.
  • The ownership boundary is covered end to end. Creation, listing, discovery, single and bulk mutations, rename, pruning, cleanup, degraded SSH behavior, and re-adoption all use the same host-qualified contract.
  • The change adds no dependency, binary, updater, signing, or new network surface. No mobile-facing protocol, pairing, route, or persisted mobile state changes.
  • Compatibility is exercised directly. Cross-version wire tests pass, legacy state migration and Windows fixtures are covered, and both old selectors and new exact selectors have regression tests.
  • The final verification is broad. The post-cleanup focused regression set is 381/381 across 28 files, typecheck and changed-file quality checks are clean, and all 57 GitHub contexts on the final head completed successfully or were intentionally skipped. The earlier full local suite reached 63,054 passing tests.
  • Independent review is clean. All 13 review threads are resolved, the readiness checklist found no proven P0/P1/P2 issue, and GitHub reports the head MERGEABLE with merge state CLEAN.

The remaining risk is deliberately bounded: older builds retain their pre-existing ambiguity when they do not understand canonical identity, and broader session/editor/browser raw-ID migration is still a follow-up. Neither changes the established behavior for ordinary non-colliding worktrees.

How Backward Compatibility Works

  1. The legacy locator stays stable. Worktree.id, Git/filesystem paths, and id:<repo-id>::<path> selectors are unchanged. Existing callers keep working when the locator is unambiguous.
  2. The new wire data is optional. New clients and hosts exchange the canonical identity when both sides support it. Older clients ignore the unknown optional field; newer clients fall back to the legacy locator when an older host does not publish it.
  3. The new selector is additive. identity:<identity> provides exact routing without removing or changing existing selector syntax.
  4. Persisted state migrates lazily. Orca derives identity-keyed records from the known execution host and persisted checkout instanceId, while retaining the legacy metadata projection for older builds.
  5. Ambiguous state is preserved, not guessed away. Canonical records remain intact; reads can present a deterministic row, while writes require exact host/identity context. Authoritative host refreshes can rebuild missing host-specific records.
  6. Mixed-version behavior degrades safely. Old builds continue to operate as before and therefore keep their legacy collision limitation; new builds gain collision-safe routing without requiring a coordinated desktop/remote upgrade.
  7. Rollback remains available. Reverting the code restores the old reader, and the retained legacy projection supports non-colliding workspaces. A rollback cannot reconstruct metadata already lost to a collision before this PR, and old code cannot take advantage of the new identity-keyed records.

Cross-version wire compatibility is covered by 5/5 passing tests. The change supports local worktrees, folder workspaces, SSH hosts, relays, and independently updated client/host deployments.

Linked Issue

Part of #10287.

This PR covers collision-safe worktree metadata, discovery, persistence, and mutation routing. Broader raw-ID migration for session, editor, and browser state remains staged follow-up work.

Visual Proof

N/A — this changes identity, persistence, routing, recovery, and CLI contracts; it does not add or alter a visual surface. The user-visible behavior is covered by multi-host collision and metadata-routing tests.

Testing

  • I manually tested these changes locally. The final validation was automated/test-based; no manual desktop or SSH UI run was performed.
  • Automated tests were added or updated for same-locator multi-host ownership, legacy migration, malformed and ambiguous aliases, host-scoped removal/rename/pruning, canonical-only fallback rows, SSH re-adoption, bulk mutation routing, exact selectors, Windows fixtures, and wire compatibility.
  • Post-cleanup focused regression selection: 381/381 passed across 28 files.
  • pnpm tc passed.
  • Full oxlint --format github completed with 0 findings.
  • pnpm run check:code-quality:changed completed with 0 findings.
  • Cross-version wire compatibility: 5/5 passed.
  • git diff --check passed.
  • GitHub status rollup is successful: all 57 contexts completed, with 52 passing and 5 intentionally skipped. This includes every Node 24/26 shard, static analysis, typecheck, E2E, Git compatibility, Ubuntu and Windows native smoke, Linux packaging, and Windows packaging.
  • The earlier full local suite reached 63,054 passing tests. Seven non-PR failures remained: five stale ssh2 mock failures, a Windows gyp patch absent from local node_modules, and one interactive zsh timeout that passed immediately in isolation. The post-cleanup focused suite and authoritative final-head CI are green.

Review

  • Final readiness-checklist verdict: PASS / low merge risk.
  • No proven P0, P1, or P2 findings remained after the final review.
  • Correctness, security/supply chain, performance/resources, persisted-state compatibility, SSH/remoting, Windows/Linux/macOS behavior, and module organization were reviewed.
  • All 13 GitHub review threads are resolved.
  • No human approval is currently recorded (reviewDecision: null), but GitHub does not report it as a merge blocker.

Agent skill upstream boundary

  • Not applicable. This PR copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Scope Boundaries / Follow-ups

  • Session, editor, and browser state still use the legacy locator in some contracts; their broader identity migration is outside this PR.
  • Stable host-registration incarnation fencing remains separate from worktree identity and continues using existing host ownership/generation safeguards.
  • Ambiguous aliases remain readable for catalog presentation but intentionally are not writable until disambiguated. This favors preserving user data over automatic healing.
  • The identity, persistence, discovery, and routing portions are coupled and should not be cherry-picked independently.

Checklist

  • This PR is focused on one coupled identity and ownership contract.
  • The ELI5, implementation, motivation, low-risk rationale, backward-compatibility mechanics, and scope boundaries are documented.
  • Visual proof is marked N/A with a reason.
  • Self-reviewed for correctness, security, performance, persistence, and data-loss risk.
  • Cross-platform, SSH/remote, folder-workspace, mixed-version, and path behavior were considered and tested.
  • Focused tests, typecheck, lint/code-quality checks, compatibility tests, packaging, and required GitHub CI are green; local full-suite exceptions are disclosed above.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds stable, canonical worktree identities and host-qualified metadata persistence. Metadata reads, writes, migrations, aliases, cleanup, and discovery now distinguish execution hosts. IPC and preload APIs accept host identifiers. Runtime selectors support identity:. Renderer metadata actions propagate host context and use typed batch updates. Tests cover identity stability, host collisions, persistence, cleanup, routing, and selector behavior.

Merge Risk: 🟡 Moderate · up to 2b202

This PR makes worktree metadata and mutations host-specific, but several collision edge cases remain: legacy repair can remove another host’s metadata, fallback lifecycle paths can use the wrong host’s state, and reassignment can orphan records when instance identity is missing. Bulk updates, renames, and ordering also retain bounded consistency risks, so merge should wait for fixes or explicit owner acceptance.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.97% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 59 files. (1 skipped:… 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.
Description check ✅ Passed The description is complete and directly explains the identity-collision problem, implementation, compatibility behavior, testing, review status, scope boundaries, and checklist results. It links issu…
Title check ✅ Passed The title clearly and concisely identifies the primary change: fixing worktree identity collisions across hosts.
Full details: Docstring Coverage

Explanation

Docstring coverage is 20.97% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 59 files. (1 skipped: 1 too large.)

Full details: Description check

Explanation

The description is complete and directly explains the identity-collision problem, implementation, compatibility behavior, testing, review status, scope boundaries, and checklist results. It links issue #10287 and explains why visual proof is N/A. The missing standalone Notes heading is non-critical because its required concerns are addressed elsewhere.

  • Fix all pre-merge checks with AI

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.

@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: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/store/slices/worktrees/metadata/update-worktrees-meta.ts (1)

87-102: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Keep host identity in bulk metadata updates. updatesByWorktreeId collapses colliding locators, then Lines 90-102 persist the same update to every owner host. Pinning or moving one worktree can change its colliding sibling. Key batch updates by canonical identity or by { worktreeId, executionHostId }, and persist only the selected owner. As per coding guidelines, “the execution host owns everything that touches execution.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 805b3155-f859-4d52-919c-7729fcffde54

📥 Commits

Reviewing files that changed from the base of the PR and between 96565fe and 66fc1dfec0f2fd5258c2fb81506f042a21c56540.

📒 Files selected for processing (39)
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/cli/selectors.ts
  • src/main/ipc/worktree-metadata-merge.test.ts
  • src/main/ipc/worktree-metadata-merge.ts
  • src/main/ipc/worktrees-create-metadata-persistence.test.ts
  • src/main/ipc/worktrees-test-harness.ts
  • src/main/ipc/worktrees-test-ipc-surface.ts
  • src/main/ipc/worktrees/metadata/register-worktree-metadata-handlers.ts
  • src/main/persistence-repo-lifecycle.test.ts
  • src/main/persistence/loading-store/metadata-lineage-operations.ts
  • src/main/persistence/loading-store/worktree-identity-metadata.ts
  • src/main/persistence/tracking-repos/repo-worktree-pruning.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.test.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/worktree-scan-admin-fingerprint-gate.test.ts
  • src/main/worktree-identity-persistence.test.ts
  • src/preload/api/worktree-api.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-check-and-review-actions.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.test.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.tsx
  • src/renderer/src/components/sidebar/use-workspace-kanban-status-actions.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts
  • src/renderer/src/components/sidebar/use-worktree-card-activation-actions.ts
  • src/renderer/src/components/sidebar/use-worktree-card-foundation.ts
  • src/renderer/src/components/sidebar/use-worktree-card-secondary-details.ts
  • src/renderer/src/components/sidebar/use-worktree-context-menu-commands.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/store/slices/worktrees-linked-review-push-target.test.ts
  • src/renderer/src/store/slices/worktrees-metadata-persistence.test.ts
  • src/renderer/src/store/slices/worktrees/listing/detected-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktrees-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/worktree-meta-persist.ts
  • src/shared/persisted-state-types.ts
  • src/shared/worktree/identity.test.ts
  • src/shared/worktree/identity.ts
  • src/shared/worktree/types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

Comment thread src/cli/help.ts Resolved
Comment thread src/shared/worktree/identity.ts Resolved
Comment thread src/shared/worktree/types.ts Resolved

@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: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aaa7d8bf-36c0-4b88-a89f-186a668f55ad

📥 Commits

Reviewing files that changed from the base of the PR and between 66fc1dfec0f2fd5258c2fb81506f042a21c56540 and c68c037178875deebb775216c5d2b8f842c6df3f.

📒 Files selected for processing (35)
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/main/ipc/worktrees-test-harness.ts
  • src/main/ipc/worktrees-test-ipc-surface.ts
  • src/main/ipc/worktrees/listing/ssh-worktree-fallback.ts
  • src/main/ipc/worktrees/listing/worktree-discovery-metadata.ts
  • src/main/persistence/host-qualified-worktree-meta.ts
  • src/main/persistence/loading-store/metadata-lineage-operations.ts
  • src/main/persistence/loading-store/worktree-identity-metadata.ts
  • src/main/persistence/tracking-repos/repo-worktree-pruning.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.test.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/repo-worktree-row-resolution.ts
  • src/main/workspace-space-repo-scan.ts
  • src/main/worktree-identity-persistence.test.ts
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsx
  • src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.test.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.ts
  • src/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/store/slices/worktree-meta-update-application.ts
  • src/renderer/src/store/slices/worktrees-metadata-persistence.test.ts
  • src/renderer/src/store/slices/worktrees/listing/detected-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/listing/worktree-meta-host-match.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktrees-meta.ts
  • src/renderer/src/store/slices/worktrees/session/worktree-pin-reveal.ts
  • src/shared/execution-host.test.ts
  • src/shared/execution-host.ts
  • src/shared/project-host-setup-projection.test.ts
  • src/shared/project-host-setup-projection.ts
  • src/shared/worktree/identity.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cli/help.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/main/persistence/loading-store/metadata-lineage-operations.ts (1)

247-258: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Preserve host-scoped state during rename.

When a caller supplies an executionHostId that differs from persistedOwner, this method skips migrateWorktreeIdentityOperation. migrateWorktreeMetadataLocator only re-keys identity aliases, so existing tabs and lineage can remain under oldWorktreeId. Migrate the affected host partition and add a regression test.

src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts (1)

99-142: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve all entries from order.updates in the batch. buildManualOrderUpdatesForGroupDrop returns ranks for neighboring worktrees as well as dragged worktrees. This callback creates entries only for drop.worktreeIds, so its find silently drops neighboring rank updates before updateWorktreesMeta. Add each returned worktree with its executionHostId.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 524211ff-7aa0-43ca-80b1-eb86bd5576c6

📥 Commits

Reviewing files that changed from the base of the PR and between c68c037178875deebb775216c5d2b8f842c6df3f and c03b2467261b94a712cfb5204d1a7debb1d23ca9.

📒 Files selected for processing (20)
  • src/main/ipc/worktrees/listing/ssh-worktree-fallback.ts
  • src/main/ipc/worktrees/listing/worktree-discovery-metadata.ts
  • src/main/persistence/loading-store/metadata-lineage-operations.ts
  • src/main/runtime/repo-worktree-row-resolution.test.ts
  • src/main/runtime/repo-worktree-row-resolution.ts
  • src/main/workspace-space-repo-scan.ts
  • src/main/worktree-identity-persistence.test.ts
  • src/main/worktree-metadata-ownership.test.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-status-actions.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts
  • src/renderer/src/components/sidebar/use-worktree-card-activation-actions.ts
  • src/renderer/src/components/sidebar/use-worktree-card-secondary-details.ts
  • src/renderer/src/components/sidebar/use-worktree-context-menu-commands.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.test.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.ts
  • src/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.ts
  • src/renderer/src/store/slices/worktrees-linked-review-push-target.test.ts
  • src/renderer/src/store/slices/worktrees-metadata-persistence.test.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/session/worktree-pin-reveal.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/sidebar/use-worktree-card-secondary-details.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

… identities

The canonical identity store landed write-only: getWorktreeMetaForHost had no
production callers while setWorktreeMetaForHost kept the legacy projection only
for the first known owner, so a second host's edits persisted and were never
read back. Wire the listing paths through host-qualified reads.

An ambiguous alias was also unrecoverable — reads returned undefined and writes
threw forever, and the throw escaped the detected-worktree loop, emptying the
whole repo's sidebar. Fail open onto the most recently active instance instead.

- collapse ambiguous aliases deterministically and persist the repair
- reclaim identity rows in the metadata GC so they cannot outlive their locator
  or resurrect onto a worktree recreated at the same path
- drop every host's rows when a locator is removed outright, not just the owner's
- honour an explicit instanceId so the stale-lineage rotation guard still works
- scope a rename to the moving host; other hosts keep their own locator
- prefer the project host setup matching the repo's own execution host, so a
  repoId registered on two hosts no longer stamps the wrong one durably
- reject an unencoded `|` in a host id, the invariant the alias delimiter needs
- drop the never-populated hostGeneration from the canonical key
@nwparker
nwparker force-pushed the nwparker/worktree-id-hosts-face-with-monocle branch from 465a6dd to 1761fdc Compare August 27, 2026 08:51
@nwparker

Copy link
Copy Markdown
Contributor Author

Risk-reduction follow-up in 1761fdc:

  • Rebasing onto current main removed branch drift and kept the identity work isolated from already-landed runtime changes.
  • Fixed the deterministic Node 24/26 failure in worktree listing: metadata is now snapshotted once per listing operation and threaded through discovery/stamping, avoiding repeated store reads and stale call-count behavior.
  • Verified locally: pnpm tc; focused identity/runtime tests (33); listing/discovery tests (20); fallback-row tests (9); changed-code quality (0 findings).

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

@nwparker, I will review the follow-up changes and the host-qualified metadata snapshot flow.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: Pro Plus

Run ID: d4c3a46f-772f-4dbe-9ca4-e8c097e3db15

📥 Commits

Reviewing files that changed from the base of the PR and between 026389a and 1761fdc.

📒 Files selected for processing (62)
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/cli/selectors.ts
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/main/ipc/worktree-metadata-merge.test.ts
  • src/main/ipc/worktree-metadata-merge.ts
  • src/main/ipc/worktrees-create-metadata-persistence.test.ts
  • src/main/ipc/worktrees-test-harness.ts
  • src/main/ipc/worktrees-test-ipc-surface.ts
  • src/main/ipc/worktrees/listing/register-worktree-catalog-handlers.ts
  • src/main/ipc/worktrees/listing/ssh-worktree-fallback.ts
  • src/main/ipc/worktrees/listing/worktree-discovery-metadata.ts
  • src/main/ipc/worktrees/metadata/register-worktree-metadata-handlers.ts
  • src/main/persistence-repo-lifecycle.test.ts
  • src/main/persistence/host-qualified-worktree-meta.ts
  • src/main/persistence/loading-store/metadata-lineage-operations.ts
  • src/main/persistence/loading-store/worktree-identity-metadata.ts
  • src/main/persistence/tracking-repos/repo-worktree-pruning.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.test.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/repo-worktree-row-resolution.test.ts
  • src/main/runtime/repo-worktree-row-resolution.ts
  • src/main/runtime/worktree-scan-admin-fingerprint-gate.test.ts
  • src/main/workspace-space-repo-scan.ts
  • src/main/worktree-identity-persistence.test.ts
  • src/main/worktree-metadata-ownership.test.ts
  • src/preload/api/worktree-api.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-check-and-review-actions.tsx
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsx
  • src/renderer/src/components/sidebar/WorktreeList.status-lane-lineage-drop.test.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.test.tsx
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.tsx
  • src/renderer/src/components/sidebar/use-workspace-kanban-status-actions.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts
  • src/renderer/src/components/sidebar/use-worktree-card-activation-actions.ts
  • src/renderer/src/components/sidebar/use-worktree-card-foundation.ts
  • src/renderer/src/components/sidebar/use-worktree-card-secondary-details.ts
  • src/renderer/src/components/sidebar/use-worktree-context-menu-commands.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.test.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.ts
  • src/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/store/slices/worktree-meta-update-application.ts
  • src/renderer/src/store/slices/worktrees-linked-review-push-target.test.ts
  • src/renderer/src/store/slices/worktrees-metadata-persistence.test.ts
  • src/renderer/src/store/slices/worktrees-terminal-pr-url-linking.test.ts
  • src/renderer/src/store/slices/worktrees/listing/detected-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/listing/worktree-meta-host-match.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktrees-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/worktree-meta-persist.ts
  • src/renderer/src/store/slices/worktrees/session/worktree-pin-reveal.ts
  • src/shared/execution-host.test.ts
  • src/shared/execution-host.ts
  • src/shared/persisted-state-types.ts
  • src/shared/project-host-setup-projection.test.ts
  • src/shared/project-host-setup-projection.ts
  • src/shared/runtime-client-export-parity.test.ts
  • src/shared/worktree/identity.test.ts
  • src/shared/worktree/identity.ts
  • src/shared/worktree/types.ts
🚧 Files skipped from review as they are similar to previous changes (60)
  • src/renderer/src/components/sidebar/use-worktree-card-foundation.ts
  • src/main/worktree-metadata-ownership.test.ts
  • src/main/ipc/worktrees-test-harness.ts
  • src/main/ipc/worktrees-test-ipc-surface.ts
  • src/renderer/src/store/slices/worktrees/metadata/worktree-meta-persist.ts
  • src/renderer/src/components/sidebar/use-worktree-card-secondary-details.ts
  • src/shared/runtime-client-export-parity.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/shared/execution-host.ts
  • src/main/persistence/host-qualified-worktree-meta.ts
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/shared/execution-host.test.ts
  • src/renderer/src/store/slices/worktrees-terminal-pr-url-linking.test.ts
  • src/renderer/src/components/sidebar/use-worktree-card-activation-actions.ts
  • src/shared/worktree/types.ts
  • src/cli/selectors.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.test.ts
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.tsx
  • src/renderer/src/components/sidebar/use-worktree-context-menu-commands.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.ts
  • src/shared/project-host-setup-projection.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-status-actions.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts
  • src/main/persistence/tracking-repos/repo-worktree-pruning.ts
  • src/renderer/src/components/sidebar/WorktreeMetaDialog.test.tsx
  • src/shared/project-host-setup-projection.test.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.test.ts
  • src/main/persistence/loading-store/worktree-identity-metadata.ts
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.search.test.tsx
  • src/renderer/src/components/sidebar/WorktreeList.status-lane-lineage-drop.test.tsx
  • src/renderer/src/store/slices/worktrees/listing/worktree-meta-host-match.ts
  • src/main/ipc/worktrees/metadata/register-worktree-metadata-handlers.ts
  • src/shared/worktree/identity.test.ts
  • src/renderer/src/store/slices/worktrees-metadata-persistence.test.ts
  • src/renderer/src/store/slices/worktrees/session/worktree-pin-reveal.ts
  • src/main/runtime/repo-worktree-row-resolution.test.ts
  • src/main/persistence/loading-store/metadata-lineage-operations.ts
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-check-and-review-actions.tsx
  • src/main/ipc/workspace-cleanup-scan.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktree-meta.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/main/ipc/worktrees-create-metadata-persistence.test.ts
  • src/renderer/src/store/slices/worktrees-linked-review-push-target.test.ts
  • src/main/runtime/repo-worktree-row-resolution.ts
  • src/main/worktree-identity-persistence.test.ts
  • src/main/persistence-repo-lifecycle.test.ts
  • src/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.ts
  • src/main/ipc/worktrees/listing/worktree-discovery-metadata.ts
  • src/preload/api/worktree-api.ts
  • src/shared/worktree/identity.ts
  • src/shared/persisted-state-types.ts
  • src/main/workspace-space-repo-scan.ts
  • src/renderer/src/store/slices/worktrees/listing/detected-worktree-meta.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.ts
  • src/main/ipc/worktree-metadata-merge.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktrees-meta.ts
  • src/renderer/src/store/slices/worktree-meta-update-application.ts
  • src/main/ipc/worktree-metadata-merge.test.ts
  • src/main/runtime/worktree-scan-admin-fingerprint-gate.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@nwparker

Copy link
Copy Markdown
Contributor Author

Additional high-risk routing fixes in 71c305d:

  • CLI/runtime metadata mutations now persist via the selected execution host and read back through the exact identity selector.
  • Paired-runtime single and batch metadata writes preserve identity selectors when available, avoiding ambiguous raw-ID RPCs.
  • Typecheck and focused persistence/runtime suites pass (34/34).

The remaining known risks are stale-metadata GC, SSH target reassignment migration, and board-drag identity propagation; these remain explicitly out of the merge-safe set pending follow-up.

@nwparker

Copy link
Copy Markdown
Contributor Author

Follow-up in 34de2e6: stale local metadata GC is now explicitly host-scoped, with a regression proving a colliding SSH identity row survives local cleanup. Focused normalization suite passes 7/7.

@nwparker

Copy link
Copy Markdown
Contributor Author

Follow-up: SSH target readoption now rekeys canonical worktree identity aliases and metadata from the old host id to the new host id, preserving identity-only workspace metadata across target replacement. Typecheck and persistence lifecycle tests pass.

@nwparker

Copy link
Copy Markdown
Contributor Author

Follow-up: board projection now removes duplicate raw locator ids from its mutation lookup map. Colliding local/SSH rows remain visible but board status/pin/reorder actions fail closed instead of selecting an arbitrary host. Changed-code quality is clean and board-drop tests pass 16/16.

@nwparker

Copy link
Copy Markdown
Contributor Author

Latest follow-up (5cbfe43): catalog listing now snapshots metadata once for all non-folder repositories, including local-only fleets. This removes repeated store reads identified in review; fallback listing tests remain green.

@nwparker

Copy link
Copy Markdown
Contributor Author

Latest follow-up in 68c9c60: board drops now persist neighboring manual-order ranks as well as dragged rows, preserving the full reorder operation. Board-drop tests pass 16/16.

@nwparker

Copy link
Copy Markdown
Contributor Author

Latest commits are ready for final review; please re-run the review against HEAD 68c9c60. Remaining known rename behavior is intentionally fail-preserving for shared legacy lineage/session state when persisted owner differs from the explicit host.

@nwparker

Copy link
Copy Markdown
Contributor Author

Final tiny follow-up in 2b2028c: extracted the ambiguous board-id mutation index into a named helper and added focused tests proving duplicate raw locator IDs are removed while unique IDs remain routable. Local validation: pnpm tc; pnpm run check:code-quality:changed; pnpm test src/renderer/src/components/sidebar/worktree-unambiguous-id-index.test.ts src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.test.ts --reporter=verbose; git diff --check.\n\n@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

@nwparker, I will review the latest changes at HEAD 2b2028c, including the extracted board-id mutation index helper and its new tests.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: Pro Plus

Run ID: bb150f7a-922b-4723-8eb5-e28f8ec626ef

📥 Commits

Reviewing files that changed from the base of the PR and between 1761fdc and 2b2028c.

📒 Files selected for processing (13)
  • src/main/ipc/worktrees-windows.test.ts
  • src/main/ipc/worktrees/listing/register-worktree-catalog-handlers.ts
  • src/main/persistence/leasing-ssh-ptys/ssh-target-reassignment.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.test.ts
  • src/main/persistence/tracking-repos/worktree-metadata-normalization.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-board-projection.ts
  • src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts
  • src/renderer/src/components/sidebar/worktree-unambiguous-id-index.test.ts
  • src/renderer/src/components/sidebar/worktree-unambiguous-id-index.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktree-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktrees-meta.ts
  • src/renderer/src/store/slices/worktrees/metadata/worktree-meta-persist.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@nwparker
nwparker merged commit b241a68 into stablyai:main Aug 27, 2026
57 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
* fix(workspaces): add collision-safe worktree identity

* fix(workspaces): read worktree metadata per host and repair ambiguous identities

The canonical identity store landed write-only: getWorktreeMetaForHost had no
production callers while setWorktreeMetaForHost kept the legacy projection only
for the first known owner, so a second host's edits persisted and were never
read back. Wire the listing paths through host-qualified reads.

An ambiguous alias was also unrecoverable — reads returned undefined and writes
threw forever, and the throw escaped the detected-worktree loop, emptying the
whole repo's sidebar. Fail open onto the most recently active instance instead.

- collapse ambiguous aliases deterministically and persist the repair
- reclaim identity rows in the metadata GC so they cannot outlive their locator
  or resurrect onto a worktree recreated at the same path
- drop every host's rows when a locator is removed outright, not just the owner's
- honour an explicit instanceId so the stale-lineage rotation guard still works
- scope a rename to the moving host; other hosts keep their own locator
- prefer the project host setup matching the repo's own execution host, so a
  repoId registered on two hosts no longer stamps the wrong one durably
- reject an unencoded `|` in a host id, the invariant the alias delimiter needs
- drop the never-populated hostGeneration from the canonical key

* fix(workspaces): close remaining identity review gaps

* fix(workspaces): close remaining review gaps

* fix(workspaces): address review and CI regressions

* test(workspaces): update host-qualified metadata expectations

* fix(workspaces): preserve ambiguous identity records

* fix(workspaces): snapshot metadata during listing

* test(workspaces): mirror listing metadata snapshot in windows fixture

* fix(workspaces): preserve identity routing for metadata writes

* fix(workspaces): scope stale metadata cleanup by host

* fix(workspaces): rekey identities on SSH readoption

* fix(workspaces): fail closed for ambiguous board ids

* perf(workspaces): snapshot metadata across catalog listing

* fix(workspaces): retain neighboring manual order updates

* test(workspaces): cover ambiguous board id index

* fix(persistence): harden host-qualified worktree metadata

* refactor(shared): split project host setup lookup

* refactor(workspaces): simplify host-qualified metadata

(cherry picked from commit b241a68)
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(workspaces): add collision-safe worktree identity

* fix(workspaces): read worktree metadata per host and repair ambiguous identities

The canonical identity store landed write-only: getWorktreeMetaForHost had no
production callers while setWorktreeMetaForHost kept the legacy projection only
for the first known owner, so a second host's edits persisted and were never
read back. Wire the listing paths through host-qualified reads.

An ambiguous alias was also unrecoverable — reads returned undefined and writes
threw forever, and the throw escaped the detected-worktree loop, emptying the
whole repo's sidebar. Fail open onto the most recently active instance instead.

- collapse ambiguous aliases deterministically and persist the repair
- reclaim identity rows in the metadata GC so they cannot outlive their locator
  or resurrect onto a worktree recreated at the same path
- drop every host's rows when a locator is removed outright, not just the owner's
- honour an explicit instanceId so the stale-lineage rotation guard still works
- scope a rename to the moving host; other hosts keep their own locator
- prefer the project host setup matching the repo's own execution host, so a
  repoId registered on two hosts no longer stamps the wrong one durably
- reject an unencoded `|` in a host id, the invariant the alias delimiter needs
- drop the never-populated hostGeneration from the canonical key

* fix(workspaces): close remaining identity review gaps

* fix(workspaces): close remaining review gaps

* fix(workspaces): address review and CI regressions

* test(workspaces): update host-qualified metadata expectations

* fix(workspaces): preserve ambiguous identity records

* fix(workspaces): snapshot metadata during listing

* test(workspaces): mirror listing metadata snapshot in windows fixture

* fix(workspaces): preserve identity routing for metadata writes

* fix(workspaces): scope stale metadata cleanup by host

* fix(workspaces): rekey identities on SSH readoption

* fix(workspaces): fail closed for ambiguous board ids

* perf(workspaces): snapshot metadata across catalog listing

* fix(workspaces): retain neighboring manual order updates

* test(workspaces): cover ambiguous board id index

* fix(persistence): harden host-qualified worktree metadata

* refactor(shared): split project host setup lookup

* refactor(workspaces): simplify host-qualified metadata
@nwparker nwparker mentioned this pull request Nov 1, 2026
11 tasks done
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