Closed
RCA: orchestrator spawn workspace conflict on fresh install (#1922)#2016
Conversation
Copilot
AI
changed the title
[WIP] Fix workspace conflict during orchestrator spawn on fresh install
RCA: orchestrator spawn workspace conflict on fresh install (#1922)
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root-cause analysis only — no code changes. The reporter sees
AO found an older orchestrator workspace for "<project>_<hash>" but could not safely reuse it automaticallyon a completely freshao start, even though no prior worktree, branch, or session metadata exists.Root cause
First-run
autoCreateConfigproduces two divergent project identities for the same repo:packages/cli/src/commands/start.ts:574-592) is written in the legacy wrappedprojects:format, keyed bybasename(cwd)(e.g.feat-reviewer-agent-flow).registerProjectInGlobalConfig→generateExternalId,packages/core/src/global-config.ts:773-790, 49-54) rebrands the same project to<basename>_<sha10>(e.g.feat-reviewer-agent-flow_24136efca8).autoCreateConfigthen returnsloadConfig(outputPath)against the wrapped local yaml.applyWrappedLocalStorageKeys(packages/core/src/config.ts:84-121) does not rename the key, so the CLI's subsequentensureOrchestratorruns withprojectId = '<basename>'and creates the worktree at~/.agent-orchestrator/projects/<basename>/worktrees/<sessionPrefix>-orchestratoron branchorchestrator/<sessionPrefix>-orchestrator.The dashboard loads from the canonical global config and only ever sees
<basename>_<sha10>. The wrapped local yaml also makes the project show up as degraded (loadLocalProjectConfigDetailedreturnsold-format). "Fix Config" callsrepairWrappedLocalProjectConfig, which rewrites the yaml flat — but does not move the worktree or session metadata.When the user then clicks "Spawn Orchestrator":
findManagedWorkspace(packages/plugins/workspace-worktree/src/index.ts:414-451) buildsallowedPathsrooted at…/projects/<basename>_<sha10>/worktrees/….git worktree list --porcelainfinds the existing worktree on branchorchestrator/<sessionPrefix>-orchestrator, but at the basename path.allowedPaths→ throws"outside AO-managed worktree directories".classifySpawnError(packages/web/src/app/api/orchestrators/route.ts:15-32) rewrites the message and interpolates the hashed id, producing the reported text.The conflict is structural (both ids derive deterministically from the repo path/origin), not a race.
findManagedWorkspaceis behaving correctly — the bug is upstream, in the auto-create flow producing two ids.Why the issue's hypotheses were close but not quite right
ensureOrchestratorduringao start.Suggested fix directions (not implemented; awaiting direction)
autoCreateConfigwrites a flat local yaml (matching the post-repair format). Eliminates the degraded state and the basename key fromconfig.projects. Smallest surgical fix.autoCreateConfigreloads vialoadConfig(getGlobalConfigPath())afterregisterProjectInGlobalConfigso the rest ofao startuses the hashed id.applyWrappedLocalStorageKeysto rename the local key to the registered hashed id when the global registry already knows the project.repairWrappedLocalProjectConfigmigrate any worktrees/sessions under the basename project dir to the hashed project dir (only needed to recover already-corrupted installs).(1) addresses the root cause. (1)+(4) together also recover users already affected.
Note on delivery
The instructions asked me to post the RCA as a comment on #1922. Both
gh issue commentand the GitHub REST API returned 403 from this sandbox, and the available MCP tools only exposereply_to_commentfor PR review threads. The full analysis lives in commitc3f541e's PR body and can be pasted to the issue by a maintainer.