Skip to content

fix(persistence): repo writes take the row's identity, never a bare id - #30616

Merged
nwparker merged 2 commits into
mainfrom
nwparker/r4-update-repo-host-target
Oct 19, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/r4-update-repo-host-target

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​314 $\color{#cf222e}{\Huge{\mathbf{−}}}$​238 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​66 $\color{#cf222e}{\Huge{\mathbf{−}}}$​56 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10

ELI5

The same project can be registered twice with the same id: once on this computer and once on an SSH host (or a paired server). Saving a change to "this project" used to look the project up by id alone, so a change meant for one copy could land on the other. Now every save is handed the exact project row it is about, including which machine it lives on, so it can only change that row.

What Changed

  • Before: the main-process store's updateRepo(id, updates, hostId?) took the host as an optional third argument. When a caller left it out, the store wrote the first row with that id. Several callers had already looked up the right row and then passed only repo.id: project-host setup (runtime controller and desktop IPC handler), the folder-to-Git upgrade watch, both clone paths, project registration's host adoption and the fork backfill. Where the same id existed on two hosts, those writes could rename, re-type or re-stamp the wrong copy.
  • After: updateRepo(target, updates) takes RepoHostTarget = Pick<Repo, 'id' | 'connectionId' | 'executionHostId'>, the same shape setResolvedRepoGitUsername already uses. The store works out the host from the target with getRepoExecutionHostId, and findRepoRowForHostScopedWrite no longer has its "no host: take the first match" branch. Every caller now passes the row it resolved. A caller that has only an id no longer compiles.
  • The one boundary that only has an id: the desktop repos:update IPC. The renderer sends no hostId for unstamped local rows, and the issue-source preference write never sends one. With a hostId, the handler addresses that host directly. Without one, it keeps today's first-match row, resolved once at the boundary (store.getRepo). The wire is unchanged.

There are no user-visible changes on a single-host setup. With twin rows, edits now stay on the copy they were made for.

Why

This is round 4 decision D-A: write APIs take the row's identity fields, never a bare id.

  • Why not a required hostId: a caller can still fill it from a first-match lookup, which is the bug.
  • Why not a branded composite key everywhere: that means re-keying stored maps, which changes persisted and wire formats that mixed versions can't absorb (round 1 D7).

Passing the row also means there is only one place that derives the host from the two legacy fields.

Linked Issue

Round 4 SSH hardening, slice R4-2 (decision D-A), following #30584 (findings 2 and 3). No GitHub issue.

Visual Proof

N/A. This is a main-process persistence API change with no UI.

Testing

  • pnpm tc is clean. A bare-id or three-argument updateRepo call is now a type error.

  • tests/e2e typecheck ratchet: OK.

  • The 71 unit files that touch updateRepo pass, run with --maxWorkers=1.

  • New and rewritten tests:

    • persistence-update-repo.test.ts: with the SSH twin stored first, a write handed the local row lands on the local row.
    • repo-update-host-guard.test.ts: a target with no host fields means the local row, not the first same-id row; an SSH row is addressable through connectionId alone.
  • Call expectations now assert the host through repoTarget(id, hostId) (src/main/persistence/repo-host-target-matcher.test-fixture.ts), so a write to the wrong twin fails them.

  • I ran the full "static analysis and typecheck" job steps locally.

  • Not live-verified on an SSH host. The change is in-process only and changes no wire format.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

  • Codex (gpt-6.1-sol, high) found one issue: tests/e2e/folder-upgrade-identity-persistence.unit.test.ts still used the string form. It is fixed and was re-reviewed.
  • An adversarial Opus review found no regressions. It also flagged an older, separate issue: twin repo-backed project-host setups share a setup id (repo.id), so updateProjectHostSetup({ setupId }) can't tell twins apart. Fixing that needs an optional hostId on the update arguments, so it is left as a follow-up.

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

  • SSH: this is the point of the change. Writes can no longer cross from one twin to another.
  • Folder workspaces: the folder-to-Git upgrade watch and the clone-into-folder paths are covered.
  • Wire: no IPC or RPC shape changed.

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)

nwparker and others added 2 commits October 19, 2026 00:18
updateRepo(target, updates) now takes Pick<Repo,'id'|'connectionId'|'executionHostId'>
(RepoHostTarget) and resolves the host from it, so a caller that holds the row can no
longer drop its host and write a same-id sibling on another host. The id-only callers
(project host setup controller and IPC handler, folder-to-Git upgrade watch, both
clone paths, registration adoption, fork backfill) pass the row they resolved.

Co-Authored-By: Claude <[email protected]>
@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: 9192afbb-b304-4f65-88cb-355222a2ea49
📥 Commits

Reviewing files that changed from the base of the PR and between c68c84f and ae61506.

📒 Files selected for processing: 46
  • src/main/automations/automation-worker-durability.test.ts
  • src/main/folder-repo-git-conversion.ts
  • src/main/ipc/folder-repo-git-upgrade-lifetime.test.ts
  • src/main/ipc/folder-repo-git-upgrade.test.ts
  • src/main/ipc/folder-repo-git-upgrade.ts
  • src/main/ipc/repos-local-add-and-project-setup.test.ts
  • src/main/ipc/repos-local-clone-lifecycle.test.ts
  • src/main/ipc/repos-remote-test-harness.ts
  • src/main/ipc/repos/project-host-setup-handlers.ts
  • src/main/ipc/repos/repo-clone-lifecycle.ts
  • src/main/ipc/repos/repo-update-handler.ts
  • src/main/managed-server/lifecycle/orcad-runtime-conversion.test.ts
  • src/main/persistence-initial-load.test.ts
  • src/main/persistence-jira-project.test.ts
  • src/main/persistence-orcad-repository-cache-reimport.test.ts
  • src/main/persistence-repo-lifecycle.test.ts
  • src/main/persistence-update-repo.test.ts
  • src/main/persistence-worktree-visibility.test.ts
  • src/main/persistence/loading-store/repo-lifecycle-operations.ts
  • src/main/persistence/repo-host-target-matcher.test-fixture.ts
  • src/main/persistence/tracking-repos/project-host-setup-update.ts
  • src/main/persistence/tracking-repos/repo-update-host-guard.test.ts
  • src/main/persistence/tracking-repos/repo-update-operations.ts
  • src/main/repo-backfill-wsl-move.test.ts
  • src/main/repo-git-remote-avatar-refresh.test.ts
  • src/main/repo-git-remote-identity-enrichment.test.ts
  • src/main/repo-git-remote-identity-enrichment.ts
  • src/main/runtime/acknowledged-terminal-tab-retirement.test.ts
  • src/main/runtime/orca-runtime-test-fixtures.spec.ts
  • src/main/runtime/orca-runtime-tests/repository-project-operations-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/repository-project-operations.spec.ts
  • src/main/runtime/repo-icon-fork-backfill.test.ts
  • src/main/runtime/runtime-project-host-setup-controller.test.ts
  • src/main/runtime/runtime-project-host-setup-controller.ts
  • src/main/runtime/runtime-remove-project-host-scope.spec.ts
  • src/main/runtime/runtime-repository-clone-controller.ts
  • src/main/runtime/runtime-repository-fork-backfill.ts
  • src/main/runtime/runtime-repository-registration-controller.ts
  • src/main/runtime/runtime-repository-settings-controller.ts
  • src/main/runtime/runtime-rpc-worktree-store-fixtures.ts
  • src/main/runtime/terminal-list-payload-size.test.ts
  • src/main/ssh/orcad-migration-cutover-coordinator.test.ts
  • src/main/ssh/orcad-migration-delta-move.test.ts
  • src/main/ssh/orcad-migration-repository-link.test.ts
  • src/shared/repo-host-identity.ts
  • tests/e2e/folder-upgrade-identity-persistence.unit.test.ts

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

📝 Walkthrough

The updateRepo API now accepts a repository target that can include its execution-host identity. Persistence uses that target to select the matching row, and the repos:update handler restricts folder-repository lookup to the target’s execution host. Production call sites, tests, and store mocks have been updated to use the target-based call shape.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to ae615

This change makes repository updates target the exact row on the right host, which prevents writes landing on a same-ID repo elsewhere. Single-host setups should see no behavior change, and no merge-blocking issue was identified.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 46 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Inconclusive The description is detailed and covers the change, rationale, testing, scope, and checklist. However, it states “No GitHub issue” despite the template requiring an issue link for outside contributors,… Add a link to the relevant issue, or confirm that the author is a maintainer covered by the template's issue-link exception.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the primary change: repository writes now use row identity instead of a bare repository ID.
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 is detailed and covers the change, rationale, testing, scope, and checklist. However, it states “No GitHub issue” despite the template requiring an issue link for outside contributors, and contributor status is not provided.

Resolution

Add a link to the relevant issue, or confirm that the author is a maintainer covered by the template's issue-link exception.

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

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