Repository navigation
fix(worktrees): resolve id: worktree selectors by path equivalence (#16243) - #16494
Conversation
…tablyai#16243) The renderer can only address a workspace by id (toRuntimeWorktreeSelector always emits id:<repoId>::<path>), and the runtime matches that id byte for byte while a path: selector has always compared through normalizeRuntimePathForComparison. A stored id that spells its path differently from `git worktree list` therefore resolves for the CLI and answers selector_not_found for the UI, which reads that as a stale local mirror, calls forgetLocal, reports success, and lets the row return on the next catalog refresh: a silent delete. These tests fail on both resolution sites -- the fleet `id:` branch of resolveWorktreeSelector and the scoped resolveScopedWorktreeIdRow a host-qualified removal takes -- and pin what must stay closed: an exact repo id (STA-4343), host qualification, dot segments neither selector canonicalizes, and a refusal rather than a guess when two rows spell one path. 13 failing, 35 passing.
…tablyai#16243) worktreeIdComparisonKey names one repo, one filesystem location, and one folder-workspace instance, folding exactly the path spellings normalizeRuntimePathForComparison already folds for a path: selector -- and nothing more, so dot segments stay unresolved for both shapes. Both id: resolution sites consult it only after an exact match finds nothing: the fleet branch of resolveWorktreeSelector and resolveScopedWorktreeIdRow, which a host-qualified removal takes. runtimeWorktreeIdsEqual now derives from the same key so the runtime has one normalizer rather than a parallel one. Not a pure refactor at that last site: runtimeWorktreeIdsEqual used to normalize-compare ids that parse but carry an empty repoId or an empty path ('::/p', or 'repo::' against 'repo::/'), and worktreeIdComparisonKey returns null for those, so across its call sites (PTY identity, refresh, mutation queue) such ids now compare byte-exact instead. That narrows matching rather than widening it, no real worktree carries such an id, and it is the behavior stablyai#15616 guarantees for malformed ids -- but it is a behavior delta, not just a tidy-up. Perf (stablyai#14399): the exact match is still tried first and still wins outright, so a resolvable id costs exactly what it did before. Neither site adds a scan -- the fleet branch re-filters the array it had already listed, the scoped lookup re-filters the single owning repo's projected rows -- so an explicit id still never scans every repo. Fail-closed behavior is unchanged: the repo id compares exactly (STA-4343), host qualification is untouched, the folder-workspace instance suffix stays part of the path, and a scoped lookup with two equivalent rows refuses instead of guessing. The bare unprefixed selector branch keeps byte-exact id matching, since only the id: shape reaches a renderer caller. Shares src/shared/worktree/id.ts with the open stablyai#15616, which introduces worktreeIdComparisonKey for the same divergence in lineage pruning and authoritative-scan purging; this adopts that helper rather than adding a second one. Complementary to the open stablyai#16295, which makes the miss visible; this removes the miss.
oxfmt --check flagged both new test files and oxlint's unicorn/no-useless-fallback-in-spread flagged the store mock; the full lint and format gates now match the pre-change baseline.
…ablyai#16243) Review found two axes the first pass left unproven at the two id: resolution sites. Both are the invariants the open stablyai#15616 guarantees for the shared worktreeIdComparisonKey it introduces for stablyai#15598, so violating either here would break a contract a sibling PR depends on. Windows: stablyai#15598's whole defect is that one checkout is recorded under both `D:\Agentic\game2` and `D:/Agentic/game2`. The fleet branch, the scoped removal lookup, and the key itself now each resolve the backslash spelling against the forward-slash spelling git reports, and fold drive-letter case -- while a backslash inside a POSIX path stays a filename character and a POSIX root stays case-sensitive, exactly as normalizeRuntimePathForComparison already decides for a path: selector. Malformed ids keep exact matching at both sites: an id with no repo boundary or an empty path still refuses, and the scoped lookup still refuses it without scanning. Four of these fail without the production change (three fleet/removal Windows cases and the scoped one); the malformed-id and POSIX-backslash cases are invariant guards that hold either way. Verified: 58 passed in the three files; 18 fail with the production hunks reverted; orca-runtime.test.ts and worktree-teardown-unstopped-pty.test.ts green (1270 passed | 1 skipped); pnpm tc:node clean.
…efusal (stablyai#16243) The Windows backslash spelling now rides the ID_SPELLINGS rows, so it is driven through both id: sites -- resolveWorktreeSelector and the scoped removal target -- and compared against what the same workspace's path: selector resolves, rather than only through worktreeIdComparisonKey. That is the spelling stablyai#15598/stablyai#15616 found in the wild and the one the owner's Windows client produces. The fleet path's ambiguity refusal had no test: two same-repo rows spelling one directory, an id: matching neither exactly, must reject selector_ambiguous. It is the fail-closed guard on a delete-capable resolver, and the property a later refactor is most likely to turn into a silent pick. Also records two limits at the source instead of leaving them to be rediscovered: a UNC or WSL root never folds into a drive-letter location (while Windows' two WSL UNC aliases do name one location), and a folder-workspace id keeps a trailing slash placed before the ::workspace:<uuid> suffix, so that spelling stays exact-match-only. Neither behavior changes here. The file docblock overclaimed parity. path: collapses duplicate same-host registrations to the first row while a folded id: refuses them; the contract this file pins is path-spelling parity, not dedup parity, and the divergence is deliberate because this resolver also serves delete. Non-vacuity, verified by temporarily reverting the production hunks: neutralizing both id: fallbacks turns 10 of these tests red, including both new Windows rows and the ambiguity refusal (it degrades to selector_not_found). Making the fleet fallback pick the first folded match instead of collecting all of them turns the ambiguity test red on its own. The remaining cases -- malformed ids, dot segments, the POSIX backslash, the folder-workspace slash -- pass against the pre-fix code too: they guard against future widening rather than proving this fix. Drops the two Windows cases the ID_SPELLINGS row subsumes. The drive-letter case test asserted only the Windows half its name promised; it now also pins that a POSIX root does NOT fold case, since an unconditional lowercase would merge /data/Foo with /data/foo on the platform CI runs on. Fixture paths use the upstream-attested /srv/projects prefix (and a neutral plugin-host leaf) instead of a local install root; the spelling variations the tests exist to pin -- doubled separator, dot segment, trailing slash, uppercase POSIX, cafe NFC/NFD, and the Windows D: rows -- are unchanged in form.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. (1 skipped: 1 too large.) Full details: Description checkExplanation The description covers all template sections, explains the change and rationale, documents testing and platform impact, provides visual proof as N/A, and includes the linked issue reference. The deliberate omission of a closing keyword is clearly justified. 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.
🧹 Nitpick comments (1)
src/main/runtime/worktree-rm-id-selector-path-spelling.test.ts (1)
1-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce the test header. Replace the issue history and implementation details with a one-line test scope note. As per coding guidelines,
**/*.{ts,tsx,js,jsx}says: “DO NOT: be verbose, explain the obvious, walk through the code.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ada703e9-f7e8-4889-8726-fd68b8b5202f
📒 Files selected for processing (6)
src/main/runtime/orca-runtime.tssrc/main/runtime/repo-worktree-row-resolution.test.tssrc/main/runtime/repo-worktree-row-resolution.tssrc/main/runtime/worktree-rm-id-selector-path-spelling.test.tssrc/shared/worktree/id.test.tssrc/shared/worktree/id.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
@LesleyMurfin Thank you for the thorough investigation and for putting this PR together — we missed it initially. We have since confirmed that it addresses a distinct, reproduced We will also review your other open PRs and work to get the ready ones merged. Thanks again for the careful scope, fail-closed behavior, and coverage here. |
…tablyai#16243) (stablyai#16494) * test(worktrees): cover id: selector path-spelling parity with path: (stablyai#16243) The renderer can only address a workspace by id (toRuntimeWorktreeSelector always emits id:<repoId>::<path>), and the runtime matches that id byte for byte while a path: selector has always compared through normalizeRuntimePathForComparison. A stored id that spells its path differently from `git worktree list` therefore resolves for the CLI and answers selector_not_found for the UI, which reads that as a stale local mirror, calls forgetLocal, reports success, and lets the row return on the next catalog refresh: a silent delete. These tests fail on both resolution sites -- the fleet `id:` branch of resolveWorktreeSelector and the scoped resolveScopedWorktreeIdRow a host-qualified removal takes -- and pin what must stay closed: an exact repo id (STA-4343), host qualification, dot segments neither selector canonicalizes, and a refusal rather than a guess when two rows spell one path. 13 failing, 35 passing. * fix(worktrees): resolve id: worktree selectors by path equivalence (stablyai#16243) worktreeIdComparisonKey names one repo, one filesystem location, and one folder-workspace instance, folding exactly the path spellings normalizeRuntimePathForComparison already folds for a path: selector -- and nothing more, so dot segments stay unresolved for both shapes. Both id: resolution sites consult it only after an exact match finds nothing: the fleet branch of resolveWorktreeSelector and resolveScopedWorktreeIdRow, which a host-qualified removal takes. runtimeWorktreeIdsEqual now derives from the same key so the runtime has one normalizer rather than a parallel one. Not a pure refactor at that last site: runtimeWorktreeIdsEqual used to normalize-compare ids that parse but carry an empty repoId or an empty path ('::/p', or 'repo::' against 'repo::/'), and worktreeIdComparisonKey returns null for those, so across its call sites (PTY identity, refresh, mutation queue) such ids now compare byte-exact instead. That narrows matching rather than widening it, no real worktree carries such an id, and it is the behavior stablyai#15616 guarantees for malformed ids -- but it is a behavior delta, not just a tidy-up. Perf (stablyai#14399): the exact match is still tried first and still wins outright, so a resolvable id costs exactly what it did before. Neither site adds a scan -- the fleet branch re-filters the array it had already listed, the scoped lookup re-filters the single owning repo's projected rows -- so an explicit id still never scans every repo. Fail-closed behavior is unchanged: the repo id compares exactly (STA-4343), host qualification is untouched, the folder-workspace instance suffix stays part of the path, and a scoped lookup with two equivalent rows refuses instead of guessing. The bare unprefixed selector branch keeps byte-exact id matching, since only the id: shape reaches a renderer caller. Shares src/shared/worktree/id.ts with the open stablyai#15616, which introduces worktreeIdComparisonKey for the same divergence in lineage pruning and authoritative-scan purging; this adopts that helper rather than adding a second one. Complementary to the open stablyai#16295, which makes the miss visible; this removes the miss. * chore(worktrees): satisfy oxfmt and oxlint on stablyai#16243 tests oxfmt --check flagged both new test files and oxlint's unicorn/no-useless-fallback-in-spread flagged the store mock; the full lint and format gates now match the pre-change baseline. * test(worktrees): pin Windows spellings and malformed-id exactness (stablyai#16243) Review found two axes the first pass left unproven at the two id: resolution sites. Both are the invariants the open stablyai#15616 guarantees for the shared worktreeIdComparisonKey it introduces for stablyai#15598, so violating either here would break a contract a sibling PR depends on. Windows: stablyai#15598's whole defect is that one checkout is recorded under both `D:\Agentic\game2` and `D:/Agentic/game2`. The fleet branch, the scoped removal lookup, and the key itself now each resolve the backslash spelling against the forward-slash spelling git reports, and fold drive-letter case -- while a backslash inside a POSIX path stays a filename character and a POSIX root stays case-sensitive, exactly as normalizeRuntimePathForComparison already decides for a path: selector. Malformed ids keep exact matching at both sites: an id with no repo boundary or an empty path still refuses, and the scoped lookup still refuses it without scanning. Four of these fail without the production change (three fleet/removal Windows cases and the scoped one); the malformed-id and POSIX-backslash cases are invariant guards that hold either way. Verified: 58 passed in the three files; 18 fail with the production hunks reverted; orca-runtime.test.ts and worktree-teardown-unstopped-pty.test.ts green (1270 passed | 1 skipped); pnpm tc:node clean. * test(worktrees): pin Windows id: spelling folds and fleet ambiguity refusal (stablyai#16243) The Windows backslash spelling now rides the ID_SPELLINGS rows, so it is driven through both id: sites -- resolveWorktreeSelector and the scoped removal target -- and compared against what the same workspace's path: selector resolves, rather than only through worktreeIdComparisonKey. That is the spelling stablyai#15598/stablyai#15616 found in the wild and the one the owner's Windows client produces. The fleet path's ambiguity refusal had no test: two same-repo rows spelling one directory, an id: matching neither exactly, must reject selector_ambiguous. It is the fail-closed guard on a delete-capable resolver, and the property a later refactor is most likely to turn into a silent pick. Also records two limits at the source instead of leaving them to be rediscovered: a UNC or WSL root never folds into a drive-letter location (while Windows' two WSL UNC aliases do name one location), and a folder-workspace id keeps a trailing slash placed before the ::workspace:<uuid> suffix, so that spelling stays exact-match-only. Neither behavior changes here. The file docblock overclaimed parity. path: collapses duplicate same-host registrations to the first row while a folded id: refuses them; the contract this file pins is path-spelling parity, not dedup parity, and the divergence is deliberate because this resolver also serves delete. Non-vacuity, verified by temporarily reverting the production hunks: neutralizing both id: fallbacks turns 10 of these tests red, including both new Windows rows and the ambiguity refusal (it degrades to selector_not_found). Making the fleet fallback pick the first folded match instead of collecting all of them turns the ambiguity test red on its own. The remaining cases -- malformed ids, dot segments, the POSIX backslash, the folder-workspace slash -- pass against the pre-fix code too: they guard against future widening rather than proving this fix. Drops the two Windows cases the ID_SPELLINGS row subsumes. The drive-letter case test asserted only the Windows half its name promised; it now also pins that a POSIX root does NOT fold case, since an unconditional lowercase would merge /data/Foo with /data/foo on the platform CI runs on. Fixture paths use the upstream-attested /srv/projects prefix (and a neutral plugin-host leaf) instead of a local install root; the spelling variations the tests exist to pin -- doubled separator, dot segment, trailing slash, uppercase POSIX, cafe NFC/NFD, and the Windows D: rows -- are unchanged in form. * docs(worktrees): trim the id: selector test header and document the comparison key (stablyai#16243) (cherry picked from commit de6fe8b)
…tablyai#16243) (stablyai#16494) * test(worktrees): cover id: selector path-spelling parity with path: (stablyai#16243) The renderer can only address a workspace by id (toRuntimeWorktreeSelector always emits id:<repoId>::<path>), and the runtime matches that id byte for byte while a path: selector has always compared through normalizeRuntimePathForComparison. A stored id that spells its path differently from `git worktree list` therefore resolves for the CLI and answers selector_not_found for the UI, which reads that as a stale local mirror, calls forgetLocal, reports success, and lets the row return on the next catalog refresh: a silent delete. These tests fail on both resolution sites -- the fleet `id:` branch of resolveWorktreeSelector and the scoped resolveScopedWorktreeIdRow a host-qualified removal takes -- and pin what must stay closed: an exact repo id (STA-4343), host qualification, dot segments neither selector canonicalizes, and a refusal rather than a guess when two rows spell one path. 13 failing, 35 passing. * fix(worktrees): resolve id: worktree selectors by path equivalence (stablyai#16243) worktreeIdComparisonKey names one repo, one filesystem location, and one folder-workspace instance, folding exactly the path spellings normalizeRuntimePathForComparison already folds for a path: selector -- and nothing more, so dot segments stay unresolved for both shapes. Both id: resolution sites consult it only after an exact match finds nothing: the fleet branch of resolveWorktreeSelector and resolveScopedWorktreeIdRow, which a host-qualified removal takes. runtimeWorktreeIdsEqual now derives from the same key so the runtime has one normalizer rather than a parallel one. Not a pure refactor at that last site: runtimeWorktreeIdsEqual used to normalize-compare ids that parse but carry an empty repoId or an empty path ('::/p', or 'repo::' against 'repo::/'), and worktreeIdComparisonKey returns null for those, so across its call sites (PTY identity, refresh, mutation queue) such ids now compare byte-exact instead. That narrows matching rather than widening it, no real worktree carries such an id, and it is the behavior stablyai#15616 guarantees for malformed ids -- but it is a behavior delta, not just a tidy-up. Perf (stablyai#14399): the exact match is still tried first and still wins outright, so a resolvable id costs exactly what it did before. Neither site adds a scan -- the fleet branch re-filters the array it had already listed, the scoped lookup re-filters the single owning repo's projected rows -- so an explicit id still never scans every repo. Fail-closed behavior is unchanged: the repo id compares exactly (STA-4343), host qualification is untouched, the folder-workspace instance suffix stays part of the path, and a scoped lookup with two equivalent rows refuses instead of guessing. The bare unprefixed selector branch keeps byte-exact id matching, since only the id: shape reaches a renderer caller. Shares src/shared/worktree/id.ts with the open stablyai#15616, which introduces worktreeIdComparisonKey for the same divergence in lineage pruning and authoritative-scan purging; this adopts that helper rather than adding a second one. Complementary to the open stablyai#16295, which makes the miss visible; this removes the miss. * chore(worktrees): satisfy oxfmt and oxlint on stablyai#16243 tests oxfmt --check flagged both new test files and oxlint's unicorn/no-useless-fallback-in-spread flagged the store mock; the full lint and format gates now match the pre-change baseline. * test(worktrees): pin Windows spellings and malformed-id exactness (stablyai#16243) Review found two axes the first pass left unproven at the two id: resolution sites. Both are the invariants the open stablyai#15616 guarantees for the shared worktreeIdComparisonKey it introduces for stablyai#15598, so violating either here would break a contract a sibling PR depends on. Windows: stablyai#15598's whole defect is that one checkout is recorded under both `D:\Agentic\game2` and `D:/Agentic/game2`. The fleet branch, the scoped removal lookup, and the key itself now each resolve the backslash spelling against the forward-slash spelling git reports, and fold drive-letter case -- while a backslash inside a POSIX path stays a filename character and a POSIX root stays case-sensitive, exactly as normalizeRuntimePathForComparison already decides for a path: selector. Malformed ids keep exact matching at both sites: an id with no repo boundary or an empty path still refuses, and the scoped lookup still refuses it without scanning. Four of these fail without the production change (three fleet/removal Windows cases and the scoped one); the malformed-id and POSIX-backslash cases are invariant guards that hold either way. Verified: 58 passed in the three files; 18 fail with the production hunks reverted; orca-runtime.test.ts and worktree-teardown-unstopped-pty.test.ts green (1270 passed | 1 skipped); pnpm tc:node clean. * test(worktrees): pin Windows id: spelling folds and fleet ambiguity refusal (stablyai#16243) The Windows backslash spelling now rides the ID_SPELLINGS rows, so it is driven through both id: sites -- resolveWorktreeSelector and the scoped removal target -- and compared against what the same workspace's path: selector resolves, rather than only through worktreeIdComparisonKey. That is the spelling stablyai#15598/stablyai#15616 found in the wild and the one the owner's Windows client produces. The fleet path's ambiguity refusal had no test: two same-repo rows spelling one directory, an id: matching neither exactly, must reject selector_ambiguous. It is the fail-closed guard on a delete-capable resolver, and the property a later refactor is most likely to turn into a silent pick. Also records two limits at the source instead of leaving them to be rediscovered: a UNC or WSL root never folds into a drive-letter location (while Windows' two WSL UNC aliases do name one location), and a folder-workspace id keeps a trailing slash placed before the ::workspace:<uuid> suffix, so that spelling stays exact-match-only. Neither behavior changes here. The file docblock overclaimed parity. path: collapses duplicate same-host registrations to the first row while a folded id: refuses them; the contract this file pins is path-spelling parity, not dedup parity, and the divergence is deliberate because this resolver also serves delete. Non-vacuity, verified by temporarily reverting the production hunks: neutralizing both id: fallbacks turns 10 of these tests red, including both new Windows rows and the ambiguity refusal (it degrades to selector_not_found). Making the fleet fallback pick the first folded match instead of collecting all of them turns the ambiguity test red on its own. The remaining cases -- malformed ids, dot segments, the POSIX backslash, the folder-workspace slash -- pass against the pre-fix code too: they guard against future widening rather than proving this fix. Drops the two Windows cases the ID_SPELLINGS row subsumes. The drive-letter case test asserted only the Windows half its name promised; it now also pins that a POSIX root does NOT fold case, since an unconditional lowercase would merge /data/Foo with /data/foo on the platform CI runs on. Fixture paths use the upstream-attested /srv/projects prefix (and a neutral plugin-host leaf) instead of a local install root; the spelling variations the tests exist to pin -- doubled separator, dot segment, trailing slash, uppercase POSIX, cafe NFC/NFD, and the Windows D: rows -- are unchanged in form. * docs(worktrees): trim the id: selector test header and document the comparison key (stablyai#16243)
Partially addresses #16243 — deliberately no closing keyword; see Linked Issue.
ELI5
Deleting a workspace from the sidebar did nothing, while deleting the same workspace from the CLI
worked. The UI can only ask for a workspace by its id, and the runtime matched that id letter for
letter — so if the id spelled the folder path even slightly differently from what
git worktree listreports (a trailing slash, a doubled slash, a Mac-composed accent), the runtime said "no such
workspace". The UI read that as "this row is stale junk", quietly forgot it locally, reported success,
and the row came back on the next refresh. A
path:selector never had this problem, because it hasalways compared paths through a normalizer. This PR makes an
id:selector compare its path the sameway
path:already does — and nothing more.What Changed
src/shared/worktree/id.ts: addsworktreeIdComparisonKey(worktreeId)— the canonical comparisonform of an id: repo id exact, path folded through the existing
normalizeRuntimePathForComparison, folder-workspace instance suffix kept as part of the path.Returns
nullfor malformed ids so callers keep exact matching for them.src/main/runtime/orca-runtime.ts: theid:branch ofresolveWorktreeSelectortries the exactmatch first and consults the comparison key only when nothing matched exactly.
src/main/runtime/repo-worktree-row-resolution.ts:resolveScopedWorktreeIdRow— the lookup ahost-qualified removal takes — does the same, and accepts an equivalent row only when there is
exactly one.
src/main/runtime/orca-runtime.ts: the pre-existing privateruntimeWorktreeIdsEqualnow derivesfrom the same key, so the runtime has one normalizer instead of a parallel one. Its ~25 PTY- and
session-identity callers are unchanged.
No renderer, CLI, or owner-routing changes. Six files, +473/-10, in six commits: the parity tests
(committed red), the production fix, an oxfmt/oxlint fixup on the new tests, then two review-driven
test commits — Windows spellings and malformed-id exactness, then the
ID_SPELLINGSWindows row, thefleet
selector_ambiguousrefusal, UNC/WSL key cases and the folder-workspace slash pin. The sixthanswers review feedback on this PR: it trims the test header to the one-line, why-not-how form
AGENTS.mdasks for and adds short why-first JSDoc toworktreeIdComparisonKeyandresolveWorktreeSelector, so the two comparison entry points explain themselves at the call site.Why
The mechanism
The renderer cannot address a workspace by path.
toRuntimeWorktreeSelector(
src/renderer/src/runtime/runtime-worktree-selector.ts) always emitsid:<repoId>::<path>, sent atdispatch-worktree-removal.ts. The runtime resolvedid:by exact string equality, while thepath:branch a few lines below has always compared through
normalizeRuntimePathForComparison. Anypath-spelling divergence between the stored id and the scan therefore yielded
selector_not_foundfor the UI and a clean removal for the CLI. The renderer's removal path reads
selector_not_foundasa stale local mirror, calls
forgetLocal, and returnsok: true— no toast, and the row returns onthe next catalog refresh.
Regression origin
b82a8791f5— perf(runtime): resolve an explicit worktree id without scanning every repo (#14399),2026-08-14, first tag v1.4.186 — made
id:the only selector kind not matched across the fleet,resolving it by exact equality with no fallback.
64de8dd637— (STA-4343) (#15013), 2026-08-17 —then routed removal through that scoped resolver, turning a scoped miss into a hard
selector_not_found.Live before/after
A/B against one variable: the same CLI, built from this branch, drove two runtimes on separate
ports with separate
--user-data-dirs and their own throwaway repo and worktree — the installedreleased 1.4.188 binary, and an
orcadruntime built from this branch(
node config/scripts/build-orcad.mjs+tsc -p config/tsconfig.cli.json). Only the runtime versiondiffers between the two columns.
show id:<repo>::<path>ok: trueok: trueshow id:<repo>::<path>/selector_not_foundok: true, resolving to the canonical idshow path:<path>/ok: trueok: trueshow id:<foreign-repo>::<path>selector_not_found(correct)selector_not_found(still refuses)rm id:<repo>::<path>/selector_not_found, and the worktree was still there afterwards — a follow-upshowof the exact id returnedok: trueremoved: true, and a follow-upshowof the exact id returnsselector_not_found, so it really wentrm path:<path>/removed: trueremoved: truerm id:<repo>::<path>removed: trueremoved: truerm id:<foreign-repo>::<path>selector_not_foundselector_not_foundThe two columns differ in exactly the two trailing-slash
id:rows.worktree showmissed on thesame input
worktree rmdid, so this is the shared selector resolver, not something specific toremoval.
Dot-segment spellings (
id:<repo>::<path>/.,id:<repo>::/srv/projects/./workspaces/…) were not part of thisA/B. They were refused on 1.4.188 when first probed and they are still refused here, by both
id:and
path:— see dot segments below. This PR does not fix them and does not claim to.The field report that started this — a Windows client 1.4.188 paired to a Linux headless
orca serve, where the sidebar delete silently no-oped and the CLI delete worked — matches thebeforecolumn. Theafterartifact is the Nodeorcadruntime bundle: it executes the samesrc/main/runtimecode path a desktop client's runtime does, but it is not a packaged or signedclient build.
What stays fail-closed
confirmed — the STA-4343 boundary.
still refuses; the scoped resolver's
owners.length !== 1guard is unchanged.::workspace:<uuid>instance suffix stays part of thecompared path, so sibling sessions in one directory never merge. Scope note: the parity this
delivers is for plain worktree ids. In a folder-workspace id, a trailing slash placed before
the instance suffix (
<repo>::/a/b/::workspace:<uuid>) does not fold, becausetrimRuntimePathTrailingSlashonly trims at end-of-string — that spelling keeps exact-match-onlybehaviour. It fails closed rather than matching the wrong workspace, and widening it is the same
out-of-scope normalizer change as dot segments.
nullratherthan guessing, and the fleet path rejects
selector_ambiguous. Pinned by refuses a folded id whentwo same-repo rows spell one directory in
worktree-rm-id-selector-path-spelling.test.ts— threereported rows, two of them spelling one directory (
/srv/projects/workspaces/plugin-hostand/srv/projects//workspaces/plugin-host), and a trailing-slash id matching neither exactly.This is a deliberate remaining asymmetry with
path:, which dedupes equivalent rows on one host andresolves:
id:keeps refusing, because this resolver is the one a destructive delete goes throughand picking a winner there means deleting a workspace the caller never confirmed. Adopting
path:'sdedupe for
id:is out of scope.normalizeRuntimePathForComparisondoes not resolve/./,so
id:andpath:still agree on refusing it. The contract here is parity withpath:, notuniversal path canonicalization — widening the normalizer would change every path comparison in the
app and is deliberately out of scope.
selector resolves; the destructive-delete gate runs after resolution. A provider-visible PTY that
cannot be proven stopped still blocks a non-forced delete — pinned by
src/main/runtime/worktree-teardown-unstopped-pty.test.ts(e.g. names the blocking PTYs and theescape hatch when one is still live, still fails closed on a sweep-level failure without force),
which passes unchanged. If anything, this makes that gate reachable in cases where the delete
previously never got that far. Relevant to the open test(worktree): lock fail-closed invariant behind the #9197 selector_not_found swallow #11073, which strengthens that same
invariant; nothing here routes around it.
Performance (#14399 preserved)
The exact match is tried first and still wins outright, so a resolvable id costs exactly what it does
today. Neither site adds a scan: the fleet branch re-filters the array it had already listed, and the
scoped lookup re-filters the single owning repo's already-projected rows. An explicit
id:stillnever scans every repo.
Relationship to open PRs
throw errorin the renderer's removal path so the miss fails visibly. Itdoes not change resolution. The two are complementary: fix(worktrees): fail visibly when runtime removal misses a live workspace (#16243) #16295 surfaces the miss, this removes it. No
overlapping files.
worktreeIdComparisonKeyinsrc/shared/worktree/id.ts— the samefile, the same helper name — and applies it to
getRemovedWorktreeIdsAfterAuthoritativeScanandpruneLineageForMissingRepoWorktreesfor the same class of divergence ([Bug]: Duplicate worktreeMeta entries differing only by path separator force-kill a live agent pane when a child worktree is created #15598). This PR andfix(worktrees): stop separator-variant worktree ids purging live checkouts #15616 will therefore conflict in that file, whichever lands second. We chose fix(worktrees): stop separator-variant worktree ids purging live checkouts #15616's name
deliberately instead of adding a competing helper, and comparing the two diffs directly confirms
the choice: fix(worktrees): stop separator-variant worktree ids purging live checkouts #15616's implementation of the helper is byte-identical to this one — same null
guard, same key construction. The conflict is therefore a doc comment citing a different issue, not
a design disagreement. Resolution is mechanical: keep one definition and let both sets of callers
use it. Happy to rebase on top of fix(worktrees): stop separator-variant worktree ids purging live checkouts #15616 if you would rather land that first — say the word and
this becomes a call-site-only diff. What must not happen is two normalizers with different names
doing the same folding.
Checked against upstream tip
bc98655a39before opening:worktreeIdComparisonKeydoes not exist insrc/shared/worktree/id.tsyet, and no fix for #16243 has landed, so this is still needed.What this does not explain
#16243 contains two different observations, and this PR only accounts for one of them. The
difference matters, so here it is plainly.
The reporter and the first confirmer show a delete that never reached the runtime. The OP's
runtime trace grew by three
git.execlines with noworktree.removespan, where a successfulremoval on that same host emits
worktree.remove,worktree.remove.trash_renameandworktree.remove.branch_delete. The macOS confirmer went further: in one instrumented ~90-secondsession, a UI create reached the runtime and did 4.2 s of real
git worktree addwork, and the twoUI deletes seconds later produced not one line of runtime trace, while the CLI then removed the
same workspace with the expected spans. A selector miss cannot produce that: resolution happens
inside the runtime, so a miss requires the call to arrive. For those two reports, the delete was
never dispatched, and this PR does not fix that.
The third report is the one this PR fixes. A Windows client against a Linux headless
orca serve, both 1.4.188, captured the selector shapes directly against the runtime: the exactid:form removed the workspace, the same path with a trailing slash answeredselector_not_found,and the
path:form of that same trailing-slash path resolved. That is the asymmetry the A/B abovereproduces and this change removes.
So this closes one mechanism in that thread and leaves the other open. Nobody captured the selector
string the OP's or the confirmer's clients sent, and their traces argue their failures were something
else — most likely a renderer-side dispatch failure, which is a different fix in a different process.
#16243 should stay open until the non-dispatch reports are explained, which is why the reference
below is deliberately not a closing keyword.
Linked Issue
Partially addresses #16243.
Written without a closing keyword on purpose, so merging this cannot auto-close an issue whose other
reported mechanism is still unexplained (see What this does not explain). One consequence worth
naming so it does not read as an oversight: GitHub's Linked issues sidebar populates only from a
closing keyword, so it is intentionally empty here — the relationship lives in this reference and in
the cross-link on #16243's own timeline. Once the zero-runtime-trace reports are accounted for,
whoever closes #16243 can do it deliberately rather than have a merge do it silently, and adding the
keyword then is the right move.
Visual Proof
N/A— backend selector resolution only. There is no new or altered UI surface; the user-visibledifference is that a delete which silently no-oped now completes. #16295 is the PR that changes what
the UI says when a selector misses.
Testing
Written test-first: the tests were committed red, then the production change turned them green.
Reproduce (a reviewer can run all of this):
pnpm lintandoxfmt --checkwere not clean when the fix was first committed: oxlint flaggedunicorn(no-useless-fallback-in-spread)in one new test, and both new test files were unformatted.That is what the third commit fixes, so the green lint result above holds at the tip of the branch,
not at the fix commit.
oxfmt --checkreports the same 34 pre-existing offenders as the base commit —this branch adds none.
Guard tests specifically re-run and green, unmodified:
src/main/runtime/orca-runtime.test.ts(including rejects a qualified removal when only another host has persisted ownership and its
no-fleet-scan assertion),
worktree-teardown-unstopped-pty.test.ts,worktree-teardown.test.ts,repo-worktree-resolution-scan.test.ts,worktree-scan-admin-fingerprint-gate.test.ts,runtime-rpc-worktree-queries.test.ts,worktree-lineage-pruning.test.ts.Non-vacuity, and what it does not cover. Two neutralization experiments, production files
restored byte-identical after each:
id:fallbacks — i.e. restore pre-fix behaviour — and 10 tests inworktree-rm-id-selector-path-spelling.test.tsgo red, including both new Windows rows and theambiguity refusal.
goes red on its own.
Stated plainly because a reviewer would work it out anyway: four cases pass against pre-fix code
too — malformed ids, dot segments, the POSIX backslash, and the folder-workspace mid-id slash pin.
Those are guards against widening the comparison, not evidence that this fix does anything. Only the
first bullet's ten are.
Platforms: this is platform-independent path comparison, and the spellings it folds — POSIX, Windows
drive and UNC, WSL aliases — are the ones
normalizeRuntimePathForComparisonalready folds forpath:. Exercised on Linux (unit suites and the live runtime above); the reported scenario is aWindows client against a Linux headless runtime over SSH.
Windows spellings are covered as a first-class axis, not by inference (#15598's defect class): the
comparison key, the fleet branch, and the scoped removal lookup each resolve a
repo::D:\Agentic\game2\battle-coreid against theD:/Agentic/game2/battle-corespelling gitreports. The support is
isWindowsAbsolutePathLike(src/shared/cross-platform-path.ts:6,/^[A-Za-z]:[\\/]/), which gates separator folding and lowercasing at that module's lines 48 and 56.The sites inherit
normalizeRuntimePathForComparison's guarantees, including its deliberaterestraint. Pinned by name in
src/shared/worktree/id.test.ts: folds Windows separator anddrive-letter case, as
path:already does and keeps a UNC or WSL root distinct from a drive-letterlocation; and at runtime level, folds drive-letter case only for Windows paths, never for a POSIX
path and does not fold a backslash inside a POSIX path, where it is a valid filename character.
The case-fold test asserts both halves its name promises: a Windows-rooted path folds case
(
d:/agentic/game2/battle-coreresolves against theD:/Agentic/game2/battle-corerow) while aPOSIX-rooted one does not (
/SRV/projects/workspaces/plugin-hostrefuses withselector_not_found). No production change was needed for that second half — POSIX case folding wasdeliberately never introduced, because lowercasing would merge
/srv/Foowith/srv/fooon Linux,where they are two directories. The
fold is gated on platform semantics, not applied blindly.
All four invariants #15616 claims for the shared key hold here, tested at both sites and then
re-checked live on an isolated runtime against two real git repos with real worktrees:
a trailing slash; an
rmattempted that way refused, and A stayed resolvable afterwards.and never to each other.
src/shared/worktree/id.test.ts—returns null for ids with no repo boundary so callers keep exact matching:
repo-a,repo-a::and a bare
/srv/workspaces/pluginall key tonull— and at both entry points byit.each('keeps exact matching for a malformed id with %s'), coveringshowManagedWorktreeandresolveWorktreeRemovalTarget.repo-worktree-row-resolution.tsreturnsnullon a null key andorca-runtime.tsleaves the empty exact-match candidate set alone. Live, all four malformed shapesrefuse, and the scoped lookup refuses without scanning.
asserted, per the case-fold test above.
The other three invariants are pinned by never merges different repos, workspaces, or folder
sessions in the same file — distinct repo, distinct path, distinct
::workspace:<uuid>instance.At the function level, against the real bundled source:
D:\Agentic\game2\battle-core,D:/Agentic/game2/battle-coreandd:/agentic/game2/battle-coreall fold to one key — so thisinherits #15616's separator, drive-letter and
drive-case guarantees — two folder instances of the same folder keep distinct keys, and dot segments
are not folded, which is exactly why the
/./spellings still refuse.selector and leaves the worktree in place, a runtime built from this branch removes it. Linux
host; the artifact was the Node
orcadruntime bundle, not a packaged desktop client, so aclient-side regression is covered by tests rather than by a live client build.
AI Disclosure
Written with AI agents throughout — investigation, the tests, the fix, and the live probes — driven by
xAI Grok 4.5 inside Orca's own agent harness. Every number, command, and matrix row in this PR was
produced by running it, not by asking a model to predict it. What this does not explain and the
unchanged and intended dot-segment note are there because those checks did not come out in this
change's favour.
Review
refusal on ambiguity, so no id can now resolve a workspace on a host or repo the caller did not
name. No new I/O, process, or external input; the destructive-delete gate is untouched and runs
after resolution.
normalizeRuntimePathForComparison, which is whatpath:already uses on all three platforms, soid:andpath:cannot diverge per-OS.or published content change, so a new client against an old host and an old client against a new
host both behave exactly as they do today (an old host keeps failing the divergent id; nothing
breaks). SSH repos take the same
listRepoWorktreesForResolutionpath as before, and perf(runtime): resolve an explicit worktree id without scanning every repo #14399'sbuildResolvedWorktreeFromIdfallback is preserved.::workspace:<uuid>suffix stays inside the compared path, so twosessions in one directory stay two workspaces.
agent, provider, or Git command is involved, and no Git version boundary is crossed.
identically; only previously-failing ids now resolve.
Agent skill upstream boundary
Notes
The one behavioural widening a reviewer should weigh: an
id:whose path spelling differs from thescan now resolves instead of failing. That is the point of the change, and it is fenced by an exact
repo id, unchanged host qualification, an ambiguity refusal, and no change to dot-segment handling.
Author
No X account.
Checklist
N/Awith reasonpnpm lintandpnpm typecheckpass locally at the tip of the branch; thesrc/main/runtimeand
src/shared/worktreesuites pass locally.pnpm buildwas not run locally — CI covers it.