Skip to content

fix(ssh): relinking a stopped managed server keeps the project groups it holds, and later moves don't re-send them - #30608

Merged
nwparker merged 6 commits into
mainfrom
nwparker/relink-full-catalog
Oct 19, 2026
Merged

nwparker merged 6 commits into
mainfrom
nwparker/relink-full-catalog

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​296 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​292
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49

ELI5

When you move an SSH host's projects onto a managed Orca server, the server becomes the owner of those projects and their groups. If you later stop that server and reconnect, or move a few more projects onto it, Orca compares what this desktop remembers with what the server holds. For project groups, that comparison was incomplete. The desktop's old copy of a group could be sent again over the server's newer one, and the server refused the move.

What Changed

Before

  • Moving a project group, renaming it on the server (or leaving it empty there), then stopping and reconnecting the server failed with orcad_migration_project_group_id_conflict. The reconnect only spotted groups the server held when one of its projects sat inside them.
  • After a reconnect like that worked, adding a folder to that group on the desktop and pressing Move again sent the desktop's old version of the group and failed with the same conflict.

After

  • Reconnecting reads the server's own list of project groups. Any group the server holds under the same id, on its own machine, is linked to the server's copy and not sent again, even when it is empty. A group the server keeps for a different host doesn't count, whether the group is marked with connectionId or executionHostId. The group list now keeps executionHostId, which it used to drop.
  • Later moves treat every group the server got from an earlier move or link as the server's. A new folder or project placed in one of those groups points at the server's group, and the desktop's stale copy isn't sent.
  • A move that an older build started and was interrupted still resumes with exactly the groups its saved manifest sent.

Mechanism

  • orcad-server-project-groups.ts (new): projectGroupsHeldByServer is the identity rule for groups: same id, on the server's own machine. serverHeldProjectGroups returns exactly that set once the server's group list has been read. The old search through server projects and their parent groups now runs only when no group list was read.
  • orcad-migration-repository-link.ts: the relink now starts when the server holds a group, not only a project or folder, and it reads the server's group list whenever the move contains groups.
  • orcad-migration-delta-plan.ts: groups that were moved or linked are passed as server-owned groups, which are never sent again. The exception is any group an interrupted older-build manifest already sent, so resuming that manifest still matches its record.

Folder workspaces: the review also reported that a folder whose comment was edited on the server failed to relink. Current main already handles this, because a folder is matched by id and folder path (#30017). This PR adds a regression test for it.

Why

Each kind of thing is matched to the server's catalog by its own rule: projects by id and path on the server's machine, folders by id and folder path, and groups by id on the server's machine. For anything the server holds, the server's copy wins. Groups were the kind with no rule of their own; they were only inferred from the projects inside them. That left out empty groups and groups changed on the server. It also counted parent groups the server never had, or kept for another host. Matching against the server's own group list is exact evidence, which keeps the rule simple.

Alternatives considered:

  • Merging the desktop's group definition into the server's: this would overwrite changes made on the server, which owns these groups after a move.
  • Keeping the parent-group search alongside the group list: two reviews found cases where it records groups the server doesn't hold as the server's (a parent created on the desktop after the move, or a same-id parent kept for another host). That later blocks moves, or hides a real conflict.

ref-oss check (run after the third review round, as the review rule requires): the design is confirmed, and the approach did not change. Each kind (projects, folder workspaces and project groups) has its own identity rule, and all three are relinked against the server's catalog, with the server authoritative for what it holds. Groups were the kind that was missing. Following that design, round 5 dropped the remaining inference of groups from parent chains when the server's group list is available.

Known limitations (low severity; they fail visibly and lose no data):

  • Reconnect journals written by builds since fix(ssh): reconnecting a stopped managed host keeps the server's project groups #29962 may list a parent group as the server's when the server never had it. If a later move puts a new project in that parent, the server refuses the move (orcad_delta_refused_by_server) and the host stays marked as changed. Moves have no access to the server's group list, so they can't tell these apart.
  • An empty parent group that was deleted on the server comes back on reconnect, as deleted empty groups already did on main.

Linked Issue

No issue. This comes from internal SSH-hardening review findings #8 and #9; it follows up #29586 and #29962.

Visual Proof

N/A. No UI change. The fix is in the main-process migration planner.

Testing

  • Automated tests added/updated
  • New tests run against real stores, in orcad-migration-repository-link.test.ts and orcad-migration-delta-move.test.ts: an empty group renamed on the server, nested groups whose parent was renamed, a later folder or project in a renamed or imported group, a group the server deleted (refused, not brought back), a same-id group kept for another host, an interrupted older-build delta, and a folder edited on the server. The group tests fail on main; the folder test passes on main.
  • orcad-server-project-groups.test.ts: the identity rule, including a foreign parent, a parent the server lacks, and executionHostId. orcad-migration-catalog-client.test.ts checks that executionHostId survives parsing.
  • All 27 migration test files (263 tests) pass in a single worker. The full "static analysis and typecheck" job passed locally, including its ratchets.
  • Docker managed-orcad SSH e2e lane: see the run linked in the comments.
  • Manually tested on a real host: not done. A stopped-then-reconnected managed server with groups edited on the server can't be set up in isolation outside the Docker lane.

Review

  • Codex (gpt-6.1-sol, high): rounds 1 to 4 findings fixed in the earlier commits. Round 5 had two P2 findings, both fixed: a foreign-host parent was linked through the parent-group search, and executionHostId was dropped from the server's group list. The final run was clean.
  • Opus: one medium finding, fixed: a parent group the server never had was recorded as the server's, so later moves were refused. The re-review was clean apart from the two known limitations above.

Agent skill upstream boundary

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

Notes

Mixed versions: no wire change. The group list reads one more optional field. A journal written by an older build resumes exactly as that build recorded it. SSH-only flow; folder workspaces covered; no platform-specific code.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…ater moves reference them

Relinking found server-held groups only through the rows in them, so an empty group renamed on the
server was re-imported and refused. Delta moves re-exported a linked group whenever a new row sat in
it, so a group renamed on the server refused the next Move. Both now leave the server's group as is.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: ffb98c19-1a62-4e5e-a290-125927260e88
📥 Commits

Reviewing files that changed from the base of the PR and between b331710 and bc2c28a.

📒 Files selected for processing: 10
  • src/main/ssh/orcad-migration-catalog-client.test.ts
  • src/main/ssh/orcad-migration-delta-move.test.ts
  • src/main/ssh/orcad-migration-delta-move.ts
  • src/main/ssh/orcad-migration-delta-plan.ts
  • src/main/ssh/orcad-migration-repository-link.test.ts
  • src/main/ssh/orcad-migration-repository-link.ts
  • src/main/ssh/orcad-server-folder-workspaces.ts
  • src/main/ssh/orcad-server-project-groups.test.ts
  • src/main/ssh/orcad-server-project-groups.ts
  • src/shared/folder-workspace-execution-host.ts

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

📝 Walkthrough

The migration catalog now carries optional execution-host metadata for project groups. Server-held project groups are included in reconversion linking, with host ownership and group ancestry taken into account. Delta planning uses a resumed migration manifest to distinguish its project groups from server-owned groups. Tests cover reconversion, server-side group edits and deletions, and retrying an interrupted delta move.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to bc2c2

The reviewed relinking and delta-resume paths show no established merge-blocking risk. Merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the SSH relinking and later delta-move behavior addressed by the changes.
Description check Passed The description follows the template and fully explains the behavior, mechanism, rationale, testing, limitations, and review status. It states that no linked issue exists, but the maintainer exception…
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.
Full details: Description check

Explanation

The description follows the template and fully explains the behavior, mechanism, rationale, testing, limitations, and review status. It states that no linked issue exists, but the maintainer exception may apply.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nwparker

Copy link
Copy Markdown
Contributor Author

Docker managed-orcad SSH lane (both shards) passed on bc2c28a: https://github.com/stablyai/orca/actions/runs/39212773938

@nwparker
nwparker merged commit f7ce68f into main Oct 19, 2026
68 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