Resume fails at implement: gitExclude dirties .gitignore + assertCleanWorkingTree throws #52

Closed
opened 2026-07-30 04:29:41 +00:00 by david · 0 comments
Owner

Problem

pi-loop fails at implement stage with "working tree is not clean" during resume, despite resume explicitly trusting the current working tree state.

Log

INFO [setup] resuming from existing run (skipping to implement)
WARN [setup] working tree has uncommitted changes; resume trusts the current state
INFO [setup] setup complete
INFO [implement] implementing
ERROR [implement] stage failed (git): working tree is not clean

Root Cause

Two independent problems converge on the same error:

  1. gitExclude modifies .gitignore, dirtying the tree. createRunContext() calls cleanPiLoopGitignore() which removes .pi-loop/ from .gitignore. Since .gitignore is tracked, this makes the tree dirty.
  2. assertCleanWorkingTree() throws unconditionally during resume. Resume from implement has uncommitted code changes from the previous partial LLM run — exactly the state resume is designed to handle, but the preflight still rejects it.

Fix

Remove both gitExclude and assertCleanWorkingTree entirely. Rely on .pi-loop/ being in the target repo's .gitignore for exclusion.

Files to change

File Change
src/run/services/gitExclude.ts Delete
src/run/services/gitExclude.test.ts Delete
src/run/services/runDirectory.ts Remove cleanPiLoopGitignore import and call
src/run/index.ts Remove cleanPiLoopGitignore export
src/shared/git/services/captureDiff.ts Remove :(exclude).pi-loop from DIFF_PATHSPEC
src/shared/git/services/gitState.ts Remove assertCleanWorkingTree function
src/shared/git/services/gitState.test.ts Remove assertCleanWorkingTree tests
src/shared/git/index.ts Remove assertCleanWorkingTree export
src/implement/services/runImplementStage.ts Remove assertCleanWorkingTree import and call
src/implement/services/runImplementStage.test.ts Update/remove dirty-tree test
AGENTS.md Update .pi-loop/ gitignore documentation
IMPLEMENTATION_PLAN.md Update diff capture references

Implementation plan

See docs/fix-remove-gitexclude-plan.md.

## Problem pi-loop fails at implement stage with "working tree is not clean" during resume, despite resume explicitly trusting the current working tree state. ### Log ``` INFO [setup] resuming from existing run (skipping to implement) WARN [setup] working tree has uncommitted changes; resume trusts the current state INFO [setup] setup complete INFO [implement] implementing ERROR [implement] stage failed (git): working tree is not clean ``` ### Root Cause Two independent problems converge on the same error: 1. **`gitExclude` modifies `.gitignore`, dirtying the tree.** `createRunContext()` calls `cleanPiLoopGitignore()` which removes `.pi-loop/` from `.gitignore`. Since `.gitignore` is tracked, this makes the tree dirty. 2. **`assertCleanWorkingTree()` throws unconditionally during resume.** Resume from implement has uncommitted code changes from the previous partial LLM run — exactly the state resume is designed to handle, but the preflight still rejects it. ### Fix Remove both `gitExclude` and `assertCleanWorkingTree` entirely. Rely on `.pi-loop/` being in the target repo's `.gitignore` for exclusion. ### Files to change | File | Change | |------|--------| | `src/run/services/gitExclude.ts` | Delete | | `src/run/services/gitExclude.test.ts` | Delete | | `src/run/services/runDirectory.ts` | Remove `cleanPiLoopGitignore` import and call | | `src/run/index.ts` | Remove `cleanPiLoopGitignore` export | | `src/shared/git/services/captureDiff.ts` | Remove `:(exclude).pi-loop` from `DIFF_PATHSPEC` | | `src/shared/git/services/gitState.ts` | Remove `assertCleanWorkingTree` function | | `src/shared/git/services/gitState.test.ts` | Remove `assertCleanWorkingTree` tests | | `src/shared/git/index.ts` | Remove `assertCleanWorkingTree` export | | `src/implement/services/runImplementStage.ts` | Remove `assertCleanWorkingTree` import and call | | `src/implement/services/runImplementStage.test.ts` | Update/remove dirty-tree test | | `AGENTS.md` | Update `.pi-loop/` gitignore documentation | | `IMPLEMENTATION_PLAN.md` | Update diff capture references | ### Implementation plan See `docs/fix-remove-gitexclude-plan.md`.
david 2026-07-30 04:29:41 +00:00
  • closed this issue
  • added the
    bug
    resume
    labels
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-loop#52
No description provided.