Skip to content

fix(atlas): use worktree path for git verification when available (fixes #2229)#2669

Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
MoerAI:fix/atlas-worktree-verification
Mar 24, 2026
Merged

fix(atlas): use worktree path for git verification when available (fixes #2229)#2669
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
MoerAI:fix/atlas-worktree-verification

Conversation

@MoerAI
Copy link
Copy Markdown
Contributor

@MoerAI MoerAI commented Mar 18, 2026

Summary

  • Use worktree path instead of main repo path when Atlas verifies subagent work

Problem

When subagents work in git worktrees, Atlas verifies their work using ctx.directory (main repo). Since changes exist only in the worktree directory, Atlas incorrectly reports fabricated results. This affects worktree-based Atlas verification flows.

Fix

Read boulder state first and resolve a verification directory: use boulderState.worktree_path when it is non-empty, otherwise fall back to ctx.directory. Use that resolved directory for collectGitDiffStats.

Changes

File Change
src/hooks/atlas/tool-execute-after.ts Use worktree-aware verification directory for git diff stats collection

Fixes #2229


Summary by cubic

Atlas now verifies subagent work against the active git worktree path, preventing false fabrication reports when changes live in a worktree. Falls back to the repo path when no worktree is set. Fixes #2229.

  • Bug Fixes
    • Resolve the verification directory by reading Boulder state and using worktree_path when present; otherwise use ctx.directory.
    • Pass the resolved directory to collectGitDiffStats in src/hooks/atlas/tool-execute-after.ts.

Written for commit 4723319. Summary will update on new commits.

@MoerAI
Copy link
Copy Markdown
Contributor Author

MoerAI commented Mar 18, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4723319eef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +69 to +71
const worktreePath = boulderState?.worktree_path?.trim()
const verificationDirectory = worktreePath ? worktreePath : ctx.directory
const gitStats = collectGitDiffStats(verificationDirectory)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fix Atlas's actual verification path, not just the summary

When worktree_path is set, this only switches the pre-rendered fileChanges block over to the worktree. The verifier Atlas is told to run immediately afterwards still says git diff --stat in Phase 1 (src/hooks/atlas/system-reminder-templates.ts:54), and Atlas continuations are still sent with query.directory: ctx.directory (src/hooks/atlas/boulder-continuation-injector.ts:62). In worktree-based sessions that means the summary here can look correct, but the real verification step still inspects the main checkout and reports no changes, so the false "fabricated results" flow from #2229 can still happen.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Safe logic change that correctly resolves the verification directory using worktree_path with a proper fallback to ctx.directory, fixing a reported bug with no regressions.

@code-yeongyu code-yeongyu added the triage:bug-fix PR: Bug fix label Mar 24, 2026
@code-yeongyu code-yeongyu merged commit 23d8b88 into code-yeongyu:dev Mar 24, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:bug-fix PR: Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Agents get confused when working with worktrees

2 participants