Repository navigation
refactor(renderer): one owner adapter for the deprecated-resolver folds, pinned by an acceptance table - #30451
Conversation
…ds, pinned by an acceptance table resolveOwnerWithLegacyFallback answers as resolveOwner for a named host and for rows that carry a host stamp, and keeps the deprecated answer (single focused runtime included) for missing and unstamped rows. A full-owner acceptance table pins all matrix cases and asserts the only changes from the deprecated resolver are the designed ones: twins and contested SSH hosts become ambiguous, and a stale hub stamp routes through the server that names the target.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
33579dca-e12f-407e-b8ea-c07b64cde6e8
📒 Files selected for processing: 6
config/focus-setting-read-baseline.txtsrc/renderer/src/lib/resolve-owner-acceptance.test-fixture.tssrc/renderer/src/lib/resolve-owner-acceptance.test.tssrc/renderer/src/lib/runtime-owner-alias-golden.test-fixture.tssrc/renderer/src/lib/runtime-owner-alias-matrix.test-fixture.tssrc/renderer/src/lib/worktree-runtime-owner.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.
| function hasHostEvidence(state: WorktreeRuntimeOwnerState, workspaceId: string): boolean { | ||
| const scope = parseWorkspaceKey(workspaceId) | ||
| if (scope?.type === 'folder') { | ||
| const folder = findFolderWorkspaceOwner(state, scope.folderWorkspaceId) | ||
| return Boolean( | ||
| folder && | ||
| (hasRowHost(folder) || | ||
| state.projectGroups?.some( | ||
| (group) => group.id === folder.projectGroupId && hasRowHost(group) | ||
| )) | ||
| ) | ||
| } | ||
| const repoId = getRepoIdFromWorktreeId(workspaceId) | ||
| const isStampedCopy = (row: Parameters<typeof isStampedWorktreeRow>[0] & { id: string }) => | ||
| row.id === workspaceId && isStampedWorktreeRow(row) | ||
| return Boolean( | ||
| state.worktreesByRepo?.[repoId]?.some(isStampedCopy) || | ||
| state.detectedWorktreesByRepo?.[repoId]?.worktrees.some(isStampedCopy) || | ||
| state.repos?.some((repo) => repo.id === repoId && hasRowHost(repo)) | ||
| ) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '225,300p' src/renderer/src/lib/worktree-runtime-owner.ts
rg -n 'parseWorkspaceKey|getRepoIdFromWorktreeId|worktree:|resolveRoute' src/renderer/src/lib/resolve-owner.ts src/renderer/src/lib/worktree-operation-route.ts src/renderer/src/lib/worktree-runtime-owner.tsRepository: stablyai/orca
Length of output: 4928
🏁 Script executed:
set -e
printf '%s\n' '--- workspace scope parser ---'
rg -n -C 12 -F -- 'export function parseWorkspaceKey' src/shared src
printf '%s\n' '--- worktree ID helper ---'
rg -n -C 12 -F -- 'function getRepoIdFromWorktreeId' src
printf '%s\n' '--- resolve-owner routing and resolver ---'
sed -n '1,220p' src/renderer/src/lib/resolve-owner.ts
printf '%s\n' '--- runtime owner relevant definitions ---'
sed -n '1,230p' src/renderer/src/lib/worktree-runtime-owner.ts
printf '%s\n' '--- operation route scoped handling ---'
sed -n '240,315p' src/renderer/src/lib/worktree-operation-route.ts
printf '%s\n' '--- adapter callers and scoped test cases ---'
rg -n -C 5 -F -e 'resolveOwnerWithLegacyFallback' -e 'worktree:' src/renderer/src/lib src/renderer/src -g '*.ts' -g '*.tsx' || test "$?" -eq 1Repository: stablyai/orca
Length of output: 45660
🏁 Script executed:
set -e
printf '%s\n' '--- parser and ID helpers ---'
sed -n '1,70p' src/shared/workspace-scope.ts
sed -n '1,75p' src/shared/worktree/id.ts
printf '%s\n' '--- route implementation symbols ---'
rg -n -F -e 'export function resolveWorktreeOperationRouteResult' -e 'function resolveWorktreeOperationRouteResult' -e 'export function resolveActiveWorkspaceRoute' -e 'function resolveActiveWorkspaceRoute' src/renderer/src/lib src/shared
printf '%s\n' '--- route implementation ---'
sed -n '250,330p' src/renderer/src/lib/worktree-operation-route.ts
printf '%s\n' '--- deprecated resolver and changed adapter ---'
rg -n -F -e 'export function resolveRuntimeOwnerForWorktree' -e 'export function resolveOwnerWithLegacyFallback' src/renderer/src/lib/worktree-runtime-owner.ts
sed -n '60,150p' src/renderer/src/lib/worktree-runtime-owner.ts
sed -n '235,300p' src/renderer/src/lib/worktree-runtime-owner.ts
printf '%s\n' '--- exact adapter references and focused tests ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -- 'resolveOwnerWithLegacyFallback' src || test "$?" -eq 1
rg --files src | rg 'resolve-owner|runtime-owner|worktree-operation-route' | head -80Repository: stablyai/orca
Length of output: 18546
🏁 Script executed:
set -e
printf '%s\n' '--- active and explicit route handling ---'
sed -n '75,155p' src/renderer/src/lib/worktree-operation-route.ts
sed -n '210,290p' src/renderer/src/lib/worktree-operation-route.ts
rg -n -C 8 -F -e 'export function resolveExplicitWorktreeOperationRouteResult' -e 'function resolveExplicitWorktreeOperationRouteResult' src/renderer/src/lib
printf '%s\n' '--- indexed worktree lookup ---'
rg -n -C 12 -F -e 'export function resolveIndexedWorktreeOwner' -e 'function resolveIndexedWorktreeOwner' src/renderer/src/lib/worktree-runtime-owner-index.ts
printf '%s\n' '--- acceptance tests and fixture scoped IDs ---'
sed -n '1,120p' src/renderer/src/lib/resolve-owner-acceptance.test.ts
rg -n -C 5 -F -e 'worktree:' -e 'WorkspaceOwnerRef' src/renderer/src/lib/resolve-owner-acceptance.test-fixture.ts src/renderer/src/lib/resolve-owner-acceptance.test.ts src/renderer/src/lib/resolve-owner.test.ts src/renderer/src/lib/worktree-operation-route.test.tsRepository: stablyai/orca
Length of output: 15991
🏁 Script executed:
set -e
printf '%s\n' '--- indexed lookup complete function ---'
sed -n '192,245p' src/renderer/src/lib/worktree-runtime-owner-index.ts
printf '%s\n' '--- explicit route complete function ---'
sed -n '31,115p' src/renderer/src/lib/worktree-operation-catalog-route.ts
printf '%s\n' '--- fixture ID construction and scoped references ---'
rg -n -C 4 -F -e 'worktreeId:' -e 'worktreeWorkspaceKey' -e 'worktree:' src/renderer/src/lib/runtime-owner-alias-matrix.test-fixture.ts src/renderer/src/lib/resolve-owner-acceptance.test-fixture.ts src/renderer/src/lib/resolve-owner-acceptance.test.ts
printf '%s\n' '--- all exact adapter references outside generated/vendor paths ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -- 'resolveOwnerWithLegacyFallback' src/renderer/src | cut -d: -f1-3Repository: stablyai/orca
Length of output: 7169
Normalize scoped worktree keys before owner resolution.
parseWorkspaceKey accepts worktree:<id>, but this adapter passes the scoped value unchanged. For worktree:repo::/path, the repo lookup derives worktree:repo, while the indexes contain repo::/path under repo repo. Both owner lookups can therefore miss the canonical remote row, and the adapter can return self@local.
Suggested fix
export function resolveOwnerWithLegacyFallback(
state: WorktreeRuntimeOwnerState,
ref: WorkspaceOwnerRef
): ExecutionHostOwnerMatch<HostAuthority> {
- const match = resolveOwner(state, ref)
+ const scope = parseWorkspaceKey(ref.workspaceId)
+ const normalizedRef =
+ scope?.type === 'worktree' ? { ...ref, workspaceId: scope.worktreeId } : ref
+ const match = resolveOwner(state, normalizedRef)
const hostNamed =
Boolean(ref.hostId) ||
- (state.activeWorktreeId === ref.workspaceId && Boolean(state.activeWorkspaceExecutionHostId))
+ (state.activeWorktreeId === normalizedRef.workspaceId &&
+ Boolean(state.activeWorkspaceExecutionHostId))
if (
hostNamed ||
match.kind === 'ambiguous' ||
- getFloatingWorkspaceOperationRoute(ref.workspaceId) ||
- (match.kind === 'resolved' && hasHostEvidence(state, ref.workspaceId))
+ getFloatingWorkspaceOperationRoute(normalizedRef.workspaceId) ||
+ (match.kind === 'resolved' && hasHostEvidence(state, normalizedRef.workspaceId))
) {
return match
}
- const legacyEnvironmentId = getRuntimeEnvironmentIdForWorktree(state, ref.workspaceId)
+ const legacyEnvironmentId = getRuntimeEnvironmentIdForWorktree(
+ state,
+ normalizedRef.workspaceId
+ )… rule Clean-code pass: one namedHostForOwnerRef for both resolvers, floating counts as host evidence, and the acceptance test drops non-null assertions.
ELI5
Orca has an old way and a new way of answering "which machine owns this workspace?". 57 files still use the old way. Before moving them, this PR adds the single helper they will all move to, plus a table test that pins its exact answer for every workspace shape we know about. Nothing calls the helper in production yet, so nothing changes for users.
What Changed
New
resolveOwnerWithLegacyFallbackinsrc/renderer/src/lib/worktree-runtime-owner.ts, next to the deprecated resolvers it replaces, so the deprecated-importer ratchet doesn't grow.resolveOwnerdoes. Twins and servers contesting one SSH host therefore stayambiguousinstead of reading as this computer.New
resolve-owner-acceptance.test.tswith a hand-reviewed fixture. It pins the full owner (endpoint and place) for all 76 matrix cases, plus probes:It also asserts that the adapter differs from the deprecated resolver only in the designed cases: folder and group twins, git twins, reconnect rivals or contested hosts, and the stale hub stamp.
conflict-repo::wtjoins the matrix's ordinary ids, and the deprecated-resolver golden gains its 3 legacy values (unchanged behaviour).The focus-read baseline for
worktree-runtime-owner.tsgoes 6 → 7 with an annotation. The adapter is the legacy focus path the folds move onto. fix(renderer): a created or lineage-refreshed worktree replaces only its own host's copy #30447 removes one reader elsewhere, and deleting the deprecated pair (round-3 F8) takes this file below 6.Why
This is F0 of the SSH-hardening round 3 design (
round3-design.md§2, §5, §6), which went through four adversarial Opus rounds and five Codex rounds.The earlier attempts were rejected for these reasons:
resolveOwner: it differs from the deprecated resolver in ways nobody had decided. Missing rows read as "refuse" or "local", which breaks setup terminals and teardown of row-less local terminals. Unstamped rows also lose the spawn-time server guess, so a close could land on a different machine than the one the shell was started on.resolveOwner: that would break its "never reads focus" contract and pull every caller into the focus-read ratchet.One adapter with a pinned table makes each later fold a mechanical, reviewable swap.
Wire impact: none (renderer only).
Linked Issue
None (internal hardening; maintainer PR).
Visual Proof
N/A: no production caller yet, so no UI or behaviour change.
Testing
resolve-owner-acceptance.test.ts, the alias golden andresolve-owner.test.ts: 168 tests pass.Unit tests, single worker:
src/renderer/src/lib,src/renderer/src/store/terminalsandsrc/renderer/src/store/slices. 1,113 files, 11,267 tests, all passed.Full local pr.yml static job: 0 failures.
The managed-orcad Docker lane is dispatched on this head; the link is added when it finishes.
Codex review (
gpt-6.1-sol, high): no findings.I manually tested these changes locally
Automated tests added/updated, or explained why not below