Repository navigation
fix(persistence): report a discarded cross-host repo update instead of failing silently - #23379
Conversation
…f failing silently `Store.updateRepo` takes an optional `hostId` that must be the row's own `executionHostId` stamp. When it is anything else the lookup matches no row and the method returns `null` — the same value a deleted row returns — so the write is dropped with no error, no log, and no failing test. #22421 shipped exactly that: identity enrichment addressed the probe host (`local`) instead of a `runtime:` row's stamp, and every write was discarded for a full release. Resolve the row through `findRepoRowForHostScopedWrite`, which logs once when the id exists but only under other host stamps, naming the requested host and the stored ones. The guard itself is unchanged: a matching host still writes, and a client-local probe still cannot repair a peer's row.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe repository update operations state type is narrowed to include only Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Host-mismatched updates are now logged without changing which repository rows can be updated. No actionable merge risk remains after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The update still accepts and rejects the same repository writes. A rejected cross-host update now records repository and host identifiers in an error log; no introduced access-control bypass was established, but the handling of those logs is not known. 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.
✅ No new issues found.
Reviewed changes
- Extracted host-scoped row lookup —
updateRepo's inlinefindbecomesfindRepoRowForHostScopedWrite(repos, id, hostId), returning the sameRepo | undefinedin every case. - Added the missing failure signal — when the id exists only under other host stamps, the new branch emits one
console.errornaming the repo id, requested host, and stored stamps; a genuinely missing row stays silent. - Narrowed the dependency type —
RepoUpdateMutationOperations.stateis nowPick<PersistedState, 'repos' | 'projectGroups'>, matching what the class actually reads. - New test coverage — 5 tests pin the mismatch log, silence on missing rows, host-match writes, cross-host isolation, and the no-host path.
I verified the return-value equivalence against the old predicate (including that !hostId reduces to hostId === undefined for this non-empty ExecutionHostId union), confirmed the sole production construction site (loading-store/repo-lifecycle-operations.ts:251) satisfies the narrowed state type, and ran the new test file locally (5 passed). The mismatch test would fail without the production change, since no log is emitted pre-change.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Orca can track the same project on more than one machine — your laptop, an SSH box, a paired remote. Each stored project row remembers which machine it belongs to, and when code saves a change to one of those rows it has to say which machine's row it means.
If it names the wrong machine, the save is thrown away. Until now that happened completely quietly: the code that asked for the save got back the exact same answer it would get if the project had been deleted, so it had no way to tell "you named the wrong machine" from "that project is gone". A bug like that can sit in a shipped release without anyone noticing.
Now, when a save is thrown away because the machine named didn't match, Orca writes an error to the log saying which machine was asked for and which one the project is actually on. Nothing else about the behaviour changes — the same saves succeed and the same saves are refused as before.
What Changed
Store.updateRepo(id, updates, hostId)looks up the row to write by id and — when a third argument is given — by that row's own execution-host stamp. If no row satisfies both, it returnsnull.Before:
nullmeant two different things with no way to tell them apart. Either no row with that id existed, or a row existed but under a different host stamp than the caller named. In the second case the caller's write silently evaporated.After: the lookup moves into a named function,
findRepoRowForHostScopedWrite. The returned value is unchanged in every case. What is new is that when the id does exist but only under other host stamps, it logs oneconsole.errornaming the repo id, the host that was requested, and the host stamps actually on file. A genuinely missing row logs nothing, so the message only ever appears when a real write was dropped.The guard's decision is untouched: a matching host still writes, a non-matching host still refuses, and a write aimed at one host still leaves another host's row with the same id alone. There is no signature change and no call site changed, so nothing that currently reads the
nullreturn behaves differently.A second, smaller change in the same file: the internal dependency type for this class now asks for only the two pieces of persisted state it reads (
reposandprojectGroups) instead of the whole state object. That is what lets the new test build the class directly without a type assertion.Why
This is the mechanism behind a bug that shipped in v1.4.214 (#22421, fixed in #23300). Git-remote-identity enrichment addressed
updateRepoby the host it had just probed —local— rather than by the stamp on the row it was repairing, which wasruntime:<env>. No row matched, every write returnednull, and the caller treated that as "nothing to do". Projects never resolved their remote identity and stale avatars never repaired, for a whole release, with no error in any log and no failing test.The underlying shape is a bug generator rather than a one-off: an optional argument that silently turns a write into a no-op, reporting failure with the same value it uses for a routine, expected outcome.
Alternatives considered:
{ ok: true, repo } | { ok: false, reason }). The most informative option, but there are 16 production call sites and only 2 pass a host. Changing all 16 is not a small, focused diff; changing only the 2 leaves two parallel APIs for one operation.repos:updateIPC handler, so a throw crosses into the renderer as a rejectedinvoke. Several renderer flows treat a falsy result as a graceful "no update" and run rollback logic on it (imported-worktrees-card-actions.ts,new-external-worktrees-inbox-actions.ts). The renderer's repo list can also lag the main-process store, so this path is reachable without any bug, and turning it into a rejection would be a real behaviour change.Storeinterface — too large for a targeted fix.Logging keeps the diff to one production file and zero call-site changes while still ending the silence. Both current host-passing callers pass the row's own stamp correctly, so this does not fire in normal use; it fires exactly when a user-visible or background write is being thrown away.
Linked Issue
Fixes #
Follow-up hardening for #22421 / #23300; no separate issue.
Visual Proof
N/A— no UI or interaction change. The only new observable output is aconsole.errorline in the main-process log on a path that a correct caller never reaches.Testing
New file:
src/main/persistence/tracking-repos/repo-update-host-guard.test.ts(5 tests).Before the change (production file reverted, test file kept): 1 failed, 4 passed. The failure is the new case —
After the change: 5 passed. The 4 tests that pass both before and after are there deliberately — they pin the behaviour that must not move (host match writes, missing row returns
nullsilently, a cross-host write leaves the other host's row alone, and the no-host-argument path is unchanged).The mismatch test reproduces #22421's exact shape: a row stamped
runtime:env-1addressed withlocal.Gates, all run locally on macOS:
pnpm test src/main/persistence/tracking-repos/ src/main/repo-git-remote-identity-enrichment.test.ts src/main/repo-git-remote-avatar-refresh.test.ts— 150 passed, 1 skippedpnpm tc:node— cleanpnpm run check:code-quality:changed— 0 new findings across 2 changed filesoxlint src/main/persistence/tracking-repos/— cleanoxfmt --checkon both changed files — cleanPlatforms: this is host-agnostic in-memory persistence logic with no filesystem, process, or path behaviour, so it is not platform-specific. SSH and paired-runtime rows are covered by the tests (
ssh:peer,runtime:env-1host stamps) rather than by a live remote, since the code under test never reaches a host.AI Disclosure
Review
Worth a reviewer's attention:
console.error, matching the[persistence] …convention already used in this directory. If the team would rather this were a warning, or routed through telemetry, say so — the call is in one place.writeIdentitychecks the current row's stamp and then callsupdateRepowith that same stamp synchronously, with noawaitbetween, so a mismatch is unreachable on that path.Caller census behind the "why", for confidence that nothing else is broken today: 16 production call sites reach
Store.updateRepo; 14 pass no host and are unaffected. The 2 that pass one —src/main/repo-git-remote-identity-enrichment.ts:151andsrc/main/ipc/repos/repo-update-handler.ts:222— both pass the row's own stamp (the latter via the renderer, which derives it from a row it holds). No caller is currently repeating #22421's mistake.One adjacent observation, deliberately left alone as out of scope:
Store.getRepo(id, hostId)has the same optional-guard shape, and several no-hostupdateRepocallers resolve a repo that may exist on more than one host and then write by bare id, which picks the first matching row. Neither is a regression and neither is in the repo-row update path this PR touches.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
local,ssh:<target-id>,runtime:<env-id>) — no paths, tokens, or account identifiers.max-linesbudget touched.find, as before. The extrafilterthat builds the host list runs only on the failure branch, after afindhas already missed.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)