Skip to content

fix: accept nested git worktree folders for local adapters - #7957

Open
tiangao88 wants to merge 7 commits into
paperclipai:masterfrom
tiangao88:akp/codex-nested-git-worktree-validation
Open

tiangao88 wants to merge 7 commits into
paperclipai:masterfrom
tiangao88:akp/codex-nested-git-worktree-validation

Conversation

@tiangao88

@tiangao88 tiangao88 commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Thinking Path

  • Paperclip is the open source app people use to manage AI agents for work.
  • Local adapters such as codex_local need workspace validation before launching agent runs.
  • The validator became too strict by requiring .git metadata directly inside the adapter cwd.
  • Git itself treats subdirectories of a repository as valid worktree paths, and Codex can operate from those nested folders.
  • Paperclip project folders can be configured as subdirectories inside a larger Git worktree.
  • This pull request aligns Paperclip validation with Git's own worktree detection.
  • The benefit is fewer false workspace_validation_failed errors while still rejecting folders outside any Git worktree.

Linked Issues or Issue Description

What Changed

  • Replace direct cwd/.git metadata checking with git -C <cwd> rev-parse --is-inside-work-tree.
  • Add regression coverage for a workspace-linked issue whose adapter cwd is nested inside a parent Git worktree.
  • Clean up the temporary Git fixture created by that regression test.
  • Preserve rejection behavior for folders that are not inside any Git worktree.

Verification

  • pnpm --filter @paperclipai/server exec vitest run src/__tests__/heartbeat-workspace-session.test.ts
  • pnpm --filter @paperclipai/server typecheck

Local validation results:

  • heartbeat-workspace-session.test.ts: 107 tests passed.
  • Server typecheck passed.

Risks

  • Low risk. This changes validation from a stricter direct .git file check to Git's own worktree detection.
  • Requires git to be available for git-sensitive local adapter validation. These adapters already require Git-compatible workspaces.
  • Still fails closed for missing, invalid, or non-git workspace paths.

For core feature work, check ROADMAP.md first and discuss it in #dev before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See CONTRIBUTING.md.

Model Used

Codex, GPT-5.5, with repository inspection, shell execution, local runtime validation, and focused test execution.

Checklist

  • I have included a thinking path that traces from project context to this change
  • I have specified the model used (with version and capability details)
  • I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work
  • I have searched GitHub for duplicate or related PRs and linked them above
  • I have either (a) linked existing issues with Fixes: # / Closes # / Refs # OR (b) described the issue in-PR following the relevant issue template
  • I have run tests locally and they pass
  • I have added or updated tests where applicable
  • If this change affects the UI, I have included before/after screenshots
  • I have updated relevant documentation to reflect my changes
  • I have considered and documented any risks above
  • All Paperclip CI gates are green
  • Greptile is 5/5 with no open P2s, recommendations, or follow-ups
  • I will address all Greptile and reviewer comments before requesting merge

@greptile-apps

greptile-apps Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no blocking issue remains.

Summary

This PR lets local adapters use folders nested inside a Git worktree.

  • Local adapters accept folders nested inside Git worktrees.

No new actionable issues were found. Tests and typecheck were not run during this review.

Reviews (6) · Last reviewed commit: "Merge master and preserve nested Git wor..." · Reviewed by Greptile

zocomputer added 2 commits June 11, 2026 08:13
…t-worktree-validation

# Conflicts:
#	server/src/__tests__/heartbeat-workspace-session.test.ts
@greptile-apps

greptile-apps Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@greptile-apps

greptile-apps Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P2 The error message still references .git metadata even though the validation logic now uses git rev-parse --is-inside-work-tree . A folder that is a nested subdirectory of a git repo has no .git entry but is still a valid workspace - the old phrasing will mislead users who see this error. server/src/services/heartbeat.ts:1098 ▶

    The error message still references .git metadata even though the validation logic now uses git rev-parse --is-inside-work-tree. A folder that is a nested subdirectory of a git repo has no .git entry but is still a valid workspace - the old phrasing will mislead users who see this error.

          "missing_git_metadata",
          `Issue ${issue.identifier ?? issue.id} expected a git workspace for ${input.adapterType}, but "${effectiveCwd}" is not inside any git work tree.`,
    

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@commitperclip

commitperclip Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Hey @tiangao88! Before this PR can be reviewed, a few things need attention:

Informational:

  • This branch carries commits by zocomputer. Squash-merging drops that authorship unless the squash message carries their trailers, and nothing else will notice if it does not. Add to the squash body when merging:

    Co-Authored-By: zocomputer <help@zocomputer.com>
    

Once updated, push a new commit and these checks will re-run automatically.

— commitperclip

This branch has not been deployed

No deployments
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.

Codex local rejects nested git worktree project folders

1 participant