Skip to content

fix(worktree): skip retirement backfill on every non-local host - #15023

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/retirement-backfill-runtime-host
Aug 17, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/retirement-backfill-runtime-host

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

ELI5

Follow-up to #14350. When Orca first learns which workspace names are already spent, it scans your computer's folders. For a workspace that actually runs on a different machine, it was still scanning this one — so it wrote down the wrong list of used names.

What Changed

One guard in ensureRetiredWorktreeNamesBackfilled:

-if (isFolderRepo(repo) || repo.connectionId) {
+if (isFolderRepo(repo) || getRepoExecutionHostId(repo) !== LOCAL_EXECUTION_HOST_ID) {

Plus two tests: a runtime-owned repo is skipped, and a plain local repo still backfills (so the skip is scoped, not blanket).

Why

getRepoExecutionHostId returns executionHostId when it is set, falling back to connectionId only when it is not. A runtime-owned repo carries executionHostId with no connectionId, so the old guard read it as local. The scan then walked this machine's workspace directory and agent-transcript buckets, and merged the result under the runtime host's namespace. Two ways that is wrong:

  • Under-retirement (the one that matters): names genuinely spent on the runtime host are never discovered, so a pre-existing workspace there can still have its name reissued — the original bug fix(worktree): never reissue a generated workspace name #14350 set out to fix.
  • Over-retirement: names from this machine get retired against the runtime host, burning pool entries that were never used there.

Scope is bounded: retirement at create time was already correct for these repos, because it records the name the host actually created. Only the one-time historical seed was wrong.

Raised by CodeRabbit on #14350 (🗄️ Data Integrity, Major) and left unresolved at merge. I verified the claim against merged main rather than taking it on faith — getRepoExecutionHostId at src/shared/execution-host.ts:150-159 confirms the precedence.

Why not the other connectionId checks in this module: the remaining three (getRetirementProbePath, getRemoteRetirementNamespaceKey, and its two readers) select SSH-specific path computation, where connectionId is the correct discriminator rather than a general "is remote" test. Deliberately unchanged. Whether runtime-owned repos should also get the shared-namespace treatment that SSH repos get — so a re-added runtime repo recovers its retirements — is a separate design question, noted below.

Linked Issue

Follow-up to #14350 (STA-4189).

Fixes #

Visual Proof

N/A — no UI change. This only affects which names the host seeds into its registry.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Two tests in src/main/worktree-name-retirement.test.ts:

  • "skips a runtime-owned repo, which has no connectionId but is still not local" — asserts nothing is merged and the returned collision key is null.
  • "still backfills a plain local repo, so the skip is scoped to non-local hosts" — guards against over-correcting into a blanket skip.

Red-before-green verified. I reverted the guard to the merged version and confirmed the runtime test fails on expect(merged).toEqual([]), then restored the fix and confirmed it passes. Without that check the test would pass either way, since the local scan finds nothing when the fixture directory is empty.

Verified locally: 78 tests pass across the retirement and suggestion suites; tsc --noEmit clean on the node project; oxlint and oxfmt clean.

Platforms: developed and tested on macOS. The change is a host-id comparison with no platform-specific behavior.

Review

  • Cross-platform: no path handling changed.
  • Remote SSH: behavior unchanged — SSH repos were already skipped via connectionId, and are still skipped via the host id.
  • Runtime-owned repos: now skipped. Strictly better than scanning the wrong machine; their create-time retirement is unaffected.
  • Local repos: unchanged, and pinned by a test.
  • Performance: strictly less work — one fewer directory scan for non-local repos.
  • Backwards compatibility: no persisted-format or wire change.

Known gaps

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 240bfa9d-8dad-4bd2-a3e5-ada7396db3dd

📥 Commits

Reviewing files that changed from the base of the PR and between 2fdaa10 and 5cea4a47fb1b36f5cde24b9f73a3816ec2412b30.

📒 Files selected for processing (2)
  • src/main/worktree-name-retirement.test.ts
  • src/main/worktree-name-retirement.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change updates ensureRetiredWorktreeNamesBackfilled to determine repository locality from getRepoExecutionHostId(repo). Non-local repositories, including runtime-owned repositories without a connectionId, are excluded from backfill. Folder repositories remain excluded. Tests verify that runtime-owned repositories produce no merged names or collision key, while local repositories continue to backfill retired names.

Merge Risk: ⚪ Minimal · up to 5cea4

The change limits retirement backfill to local repositories while preserving local behavior, with targeted tests for both cases; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the worktree retirement change and the non-local host behavior.
Description check ✅ Passed The description covers the change, rationale, tests, scope, known gap, and checklist, but the required Fixes issue field is blank.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/retirement-backfill-runtime-host branch 2 times, most recently from 5cea4a4 to 3d3c4dd Compare August 17, 2026 06:34
The backfill guard tested repo.connectionId, but a runtime-owned repo
carries executionHostId with no connectionId, so it read as local. The
scan then walked this machine's workspace and agent-transcript
directories and filed the result under the runtime host's namespace —
retiring names never used there while missing the ones that were.

Guard on the execution host id instead. Ongoing retirement was already
correct for these repos; only the one-time historical seed was wrong.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/retirement-backfill-runtime-host branch from 3d3c4dd to e10cfa9 Compare August 17, 2026 06:40
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review summary

I reviewed the two-file change in src/main/worktree-name-retirement.ts and src/main/worktree-name-retirement.test.ts, including the backfill host guard, its runtime-owned/local regression coverage, and the unchanged create-time retirement path. The checkout and PR metadata agree on head e10cfa9d64a20153c94c2cfd7848bd719d6d008f and base 77ef6bb9eeba7e049e5acaa657f5b00b358f6f30.

Verified locally:

  • npx vitest run --config config/vitest.config.ts worktree-name-retirement worktree-name-suggestion: 4 files passed, 78/78 tests passed.
  • npx tsc --noEmit -p config/tsconfig.node.json: passed.
  • npx tsc --noEmit -p config/tsconfig.tc.web.json: passed.
  • npx oxlint src/main/worktree-name-retirement.ts src/main/worktree-name-retirement.test.ts: passed with no findings.
  • Mutation check: I temporarily changed the guard back to isFolderRepo(repo) || repo.connectionId. The retirement-focused run then failed exactly the runtime-owned regression (1 failed, 48 passed), observing merged === ["nautilus"] where the test expects []. I restored the execution-host guard afterward and confirmed the worktree diff was empty.
  • Full main-process suite on the PR head: 2,141 files passed, 29 skipped; 22,434 tests passed, 136 skipped; zero failures.
  • The same full main-process suite on the exact base commit: 2,141 files passed, 29 skipped; 22,432 tests passed, 136 skipped; zero failures.

The previously reported 10 PTY-environment failures did not reproduce in either full run, so I cannot independently confirm their prior file locations or pre-existing status. Current head and base were both green under the same command; latest CI should remain the reference for platform-specific coverage.

Verdict: no blocking findings; this is ready to merge. The execution-host comparison correctly prevents a runtime-owned repo without a connectionId from being scanned as local, while the companion test confirms plain local backfill still occurs. Create-time retirement remains unchanged and records the name before any remote-namespace handling.

This review made no changes to the fix. git diff 817c2ebd27 -- src/main/worktree-name-retirement.ts src/main/worktree-name-retirement.test.ts is empty, confirming the two changed files are identical to the pre-review commit after all verification.

@brennanb2025
brennanb2025 merged commit 7fad71e into main Aug 17, 2026
45 checks passed
brennanb2025 added a commit that referenced this pull request Aug 17, 2026
Resolves an import-union conflict in worktree-name-retirement.ts. Main's #15023
gates the backfill on the execution host id rather than connectionId; this branch
adds a runtime-owned guard on the namespace write. Both apply.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…lyai#15023)

The backfill guard tested repo.connectionId, but a runtime-owned repo
carries executionHostId with no connectionId, so it read as local. The
scan then walked this machine's workspace and agent-transcript
directories and filed the result under the runtime host's namespace —
retiring names never used there while missing the ones that were.

Guard on the execution host id instead. Ongoing retirement was already
correct for these repos; only the one-time historical seed was wrong.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…lyai#15023)

The backfill guard tested repo.connectionId, but a runtime-owned repo
carries executionHostId with no connectionId, so it read as local. The
scan then walked this machine's workspace and agent-transcript
directories and filed the result under the runtime host's namespace —
retiring names never used there while missing the ones that were.

Guard on the execution host id instead. Ongoing retirement was already
correct for these repos; only the one-time historical seed was wrong.
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