Repository navigation
fix(renderer): resolveOwner refuses folder and project-group twins instead of guessing this computer - #30009
Conversation
…guous; deprecate the runtime-owner aliases
…t folder delete refuses
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
af4146ca-d154-49a8-b39d-9a8568c4c932
📒 Files selected for processing: 9
src/renderer/src/lib/resolve-owner.test.tssrc/renderer/src/lib/resolve-owner.tssrc/renderer/src/lib/runtime-owner-alias-golden.test-fixture.tssrc/renderer/src/lib/runtime-owner-alias-golden.test.tssrc/renderer/src/lib/runtime-owner-alias-matrix.test-fixture.tssrc/renderer/src/lib/worktree-runtime-owner-index.tssrc/renderer/src/lib/worktree-runtime-owner.tssrc/renderer/src/store/host-twin-isolation.test.tssrc/renderer/src/store/host-twin.test-fixture.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| * their unqualified lookups collapse a twin to "no row" before any host fallback runs. | ||
| */ | ||
| function isFolderTwin(state: WorktreeOperationRouteState, folderWorkspaceId: string): boolean { | ||
| const folder = resolveIndexedFolderWorkspaceOwner(state.folderWorkspaces, folderWorkspaceId) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- diff target ---'
git diff --unified=80 573388796704a74fbf24625f91f0cfc7e2d4a181 b4749efb5799507d2f8c47e4fe9716b74c923931 -- src/renderer/src/lib/resolve-owner.ts
printf '%s\n' '--- target references and definitions ---'
rg -n -F --glob '*.{ts,tsx}' -e 'resolveIndexedFolderWorkspaceOwner' -e 'resolveIndexedProjectGroupOwner' -e 'isFolderTwin' -e 'resolveWorktreeOperationRouteResult' -e 'function resolveOwner' -e 'const resolveOwner' src/renderer/src
printf '%s\n' '--- target file ---'
nl -ba src/renderer/src/lib/resolve-owner.ts | sed -n '1,240p'
printf '%s\n' '--- relevant resolver definitions ---'
rg -l -F --glob '*.{ts,tsx}' -e 'resolveIndexedFolderWorkspaceOwner' -e 'resolveIndexedProjectGroupOwner' src | while read -r f; do
echo "### $f"
nl -ba "$f" | sed -n '1,280p'
done
printf '%s\n' '--- route resolver definitions ---'
rg -l -F --glob '*.{ts,tsx}' -e 'resolveWorktreeOperationRouteResult' src | while read -r f; do
echo "### $f"
nl -ba "$f" | sed -n '1,360p'
doneRepository: stablyai/orca
Length of output: 42052
🏁 Script executed:
set -eu
printf '%s\n' '--- diff target ---'
git diff --unified=80 573388796704a74fbf24625f91f0cfc7e2d4a181 b4749efb5799507d2f8c47e4fe9716b74c923931 -- src/renderer/src/lib/resolve-owner.ts
printf '%s\n' '--- references ---'
rg -n -F --glob '*.{ts,tsx}' -e 'resolveIndexedFolderWorkspaceOwner' -e 'resolveIndexedProjectGroupOwner' -e 'isFolderTwin' -e 'resolveWorktreeOperationRouteResult' -e 'function resolveOwner' -e 'const resolveOwner' src/renderer/src || test $? -eq 1
printf '%s\n' '--- target ---'
nl -ba src/renderer/src/lib/resolve-owner.ts | sed -n '1,260p'
printf '%s\n' '--- resolver files ---'
rg -l -F --glob '*.{ts,tsx}' -e 'resolveIndexedFolderWorkspaceOwner' -e 'resolveIndexedProjectGroupOwner' src | while read -r f; do
echo "### $f"
nl -ba "$f" | sed -n '1,320p'
done
printf '%s\n' '--- route files ---'
rg -l -F --glob '*.{ts,tsx}' -e 'resolveWorktreeOperationRouteResult' src | while read -r f; do
echo "### $f"
nl -ba "$f" | sed -n '1,400p'
doneRepository: stablyai/orca
Length of output: 42275
🏁 Script executed:
set -eu
printf '%s\n' '--- indexed owner resolver ---'
nl -ba src/renderer/src/lib/worktree-runtime-owner-index.ts | sed -n '1,370p'
printf '%s\n' '--- operation route resolver ---'
nl -ba src/renderer/src/lib/worktree-operation-route.ts | sed -n '1,330p'
printf '%s\n' '--- relevant types and catalog helpers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'type FolderWorkspace' -e 'interface FolderWorkspace' -e 'type ProjectGroup' -e 'interface ProjectGroup' -e 'executionHostId' -e 'projectGroupId' src/renderer/src/shared src/shared src/renderer/src | head -200Repository: stablyai/orca
Length of output: 42384
🏁 Script executed:
set -eu
printf '%s\n' '--- unqualified route branch ---'
nl -ba src/renderer/src/lib/worktree-operation-route.ts | sed -n '220,360p'
printf '%s\n' '--- folder runtime owner helpers ---'
nl -ba src/renderer/src/lib/folder-workspace-runtime-owner.ts | sed -n '1,300p'
printf '%s\n' '--- execution host derivation ---'
nl -ba src/shared/execution-host.ts | sed -n '180,285p'Repository: stablyai/orca
Length of output: 20846
🏁 Script executed:
nl -ba src/renderer/src/lib/worktree-operation-route.ts | sed -n '350,395p'Repository: stablyai/orca
Length of output: 1359
Reject folder IDs with conflicting inherited hosts.
Two unstamped folder rows with the same ID can have different project groups. The folder index compares only each folder row’s own effective host, so both rows resolve as local and the index returns the first row. isFolderTwin then checks only that row’s project group.
The unqualified route uses the same selected row and can resolve the operation to one host instead of returning ambiguous. Compare the effective inherited host of every matching folder row before selecting an owner, or enforce an equivalent catalog invariant.
| const calls = vi.mocked(window.api.runtimeEnvironments.call).mock.calls | ||
| expect(calls.map(([request]) => request.method)).not.toContain('folderWorkspace.delete') | ||
| const after = [fixture.local, fixture.remote].map((s) => projectHostTwinState(fixture, s)) | ||
| expect(after.map((state, i) => changedHostTwinState(before[i], state))).toEqual([[], []]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Compare the unstamped folder row directly.
For 'folder group local+ssh', projectHostTwinState excludes the folder row from both host snapshots because the row has no executionHostId. If deletion changes that row while returning false and making no API call, this assertion still passes. Snapshot folderWorkspaces before deletion and assert that it remains unchanged.
ELI5
The same folder workspace, or the project group a folder inherits its machine from, can be published by two hosts at once (for example this computer and an SSH host). When nothing says which copy the user means, Orca's owner lookup guessed this computer. Folder edits, deletes, file writes and git actions could then reach the wrong machine. Now the lookup answers "ambiguous", and those actions refuse instead of guessing.
What Changed
src/renderer/src/lib/resolve-owner.tsresolveOwner(the existing host-aware owner lookup, which keeps the server and the SSH target behind it) now returnsambiguousfor a folder workspace when no host is named and either:missing, whichfile-owner-runtime-target.tsmapped to this computer.A caller that names the host (
hostId, or the active workspace's selected host) resolves exactly as before. A folder that names its own host or SSH connection is unaffected.worktree-runtime-owner-index.ts: unqualified folder and project-group lookups now reportambiguousseparately frommissing. The existing lookups are rebuilt on top of them, with the same results.getRuntimeEnvironmentIdForWorktree/resolveRuntimeOwnerForWorktreeare marked@deprecated → resolveOwner, with no code change. A 76-case golden matrix captured on main pins their mapping.Twin suite: adds a "folder in a twin project group" kind. A folder delete that names no host now refuses for folder twins and project-group twins, and touches neither copy (it failed before this change for the project-group twin).
Callers audited (all 19
resolveOwner/runtimeTargetForWorkspaceOwnercall sites): none now falls back to local where it didn't before. These now refuse where they used to act locally:One pre-existing local fallback remains: the board's Linear status sync (
use-workspace-board-task-status-sync.ts:135,?? { kind: 'local' }). It behaves as before and is logged for the next PR (1a.3).Why
The design called for a typed owner result that keeps the host and the transport and reports twins.
resolveOwneralready is that (#27275). A first draft of this PR added a second resolver alongside it. That would have been a parallel implementation, so it was dropped in favour of fixing the two folder gaps in the existing one. Refusing on ambiguity follows the SSH rule that loss of attribution is never evidence the work is local.Linked Issue
N/A (maintainer; SSH hardening design, tracker row 1a.1)
Visual Proof
N/A: no UI change. In the twin cases only, actions that used to hit this computer now refuse.
Testing
resolve-owner.test.ts: new rows cover a folder twin with no host named, the same twin with a host named, a project-group twin with an unstamped folder, a stamped folder in a twin group, and a legacy folder that names its own SSH connection. Each runs with all three Active Server settings. The twin rows fail before the fix.runtime-owner-alias-golden.test.ts: deprecated aliases equal the main-captured golden over 76 cases.host-twin-isolation.test.ts: the no-host folder delete refuses and touches neither twin. This fails before the fix for the project-group twin.Unit folders around and importing the changed files (
src/renderer/src/{lib,store,hooks,runtime}plus thesidebar,right-sidebar,native-chatandautomationscomponents): 2737 files and 25,603 tests pass.Local copy of the "static analysis and typecheck" job: pass.
Live verify: none. This is a renderer-only resolver change, and the twin cases are covered by store-level tests. Reproducing it live needs one folder published by two hosts at once, which no current host set-up does without the twin state these tests build.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Codex (
gpt-6.1-sol, high) round 1 found a P2: a legacy folder that names its own SSH connection was refused. That is fixed, and round 2 was clean.Agent skill upstream boundary
Notes
No wire or on-disk change. Folder workspaces are the focus, and git worktrees are unchanged. Mixed versions are unaffected, since this is renderer-only.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)