{"record":{"id":"6e1c712e9582bd65","repo":"coleam00/Archon","slug":"warning-reusing-existing-worktree-at-existingen","errorCode":null,"errorMessage":"Warning: Reusing existing worktree at ${existingEnv.working_path}. --from ${options.fromBranch} was not applied (worktree already exists).","messagePattern":"Warning: Reusing existing worktree at (.+?)\\. --from (.+?) was not applied \\(worktree already exists\\)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":2612,"sourceCode":"    configureIsolation(async (repoPath: string) => {\n      const repoConfig = await loadRepoConfig(repoPath);\n      return repoConfig?.worktree ?? null;\n    });\n\n    const provider = getIsolationProvider();\n\n    // Check for existing worktree (only when explicit --branch)\n    const existingEnv = options.branchName\n      ? await isolationDb.findActiveByWorkflow(codebase.id, 'task', options.branchName)\n      : undefined;\n\n    if (existingEnv && (await provider.healthCheck(existingEnv.working_path))) {\n      if (options.fromBranch) {\n        getLog().warn(\n          { path: existingEnv.working_path, fromBranch: options.fromBranch },\n          'worktree.reuse_from_branch_ignored'\n        );\n        console.warn(\n          `Warning: Reusing existing worktree at ${existingEnv.working_path}. ` +\n            `--from ${options.fromBranch} was not applied (worktree already exists).`\n        );\n      }\n      if (flagBase) {\n        warnBaseOverrideOnReuse(existingEnv.working_path, flagBase);\n      }\n      // Validate base branch before reuse (warning-only — non-blocking)\n      try {\n        const repoConfig = await loadRepoConfig(codebase.default_cwd);\n        const rawBase = repoConfig?.worktree?.baseBranch?.trim();\n        // Four-level fallback: --base override → repo config → codebase default →\n        // git auto-detect. Mirrors WorktreeProvider and executeWorkflow, so the\n        // reuse check validates against the base this dispatch actually asked\n        // for instead of reporting a mismatch nobody requested.\n        let configuredBase: git.BranchName;\n        if (flagBase) {\n          configuredBase = git.toBranchName(flagBase);","sourceCodeStart":2594,"sourceCodeEnd":2630,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L2594-L2630","documentation":"Warning from the run precheck in packages/cli/src/commands/workflow.ts:2612, logged as 'worktree.reuse_from_branch_ignored'. When a run reuses an existing healthy worktree, a `--from <branch>` flag cannot be applied because source selection happens only at worktree creation. The run continues using the existing worktree's source.","triggerScenarios":"Running `archon workflow run <wf> --from other-branch` when an environment already exists at the working path and passes `provider.healthCheck`; `options.fromBranch` is truthy so the warning is emitted.","commonSituations":"Re-running a workflow intending to restart from a different source branch, but an old worktree for the same branch name still exists; scripted runs that always pass `--from`.","solutions":["Complete/remove the existing worktree first (`bun run cli complete <branch> --force`) and re-run with `--from`.","Or drop the `--from` flag if reusing the existing source is acceptable.","Verify which commit the existing worktree is on (`git -C <worktree> log -1`) before continuing."],"exampleFix":"// before: existing worktree wins, --from ignored\narchon workflow run fix --from origin/main\n// after\nbun run cli complete feat/fix --force\narchon workflow run fix --from origin/main","handlingStrategy":"validation","validationCode":"// Skip --from if an environment already exists for the branch\nconst existing = await envStore.findByBranch(branch);\nif (existing && fromBranch) throw new Error('complete the existing worktree first');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `archon isolation complete <branch>` before switching source branches.","Make re-run scripts idempotent: reuse when the worktree exists, create with --from when it does not.","Confirm the worktree HEAD matches the intended source before long runs."],"tags":["cli","git-worktree","flags","reuse"],"backgroundTag":"flag-ignored-on-reuse","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}