Files
PaperClipAI/server
e53cce2257 fix: accept nested git worktree folders for local adapters (#7957)
## 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

- Fixes: #7956

## 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`](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

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] 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
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: zocomputer <help@zocomputer.com>
Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>
2026-12-04 11:01:45 -08:00
..