Summary
Before each EXECUTE attempt in retry loop, snapshot worktree state. On validation failure, revert to clean state before next attempt — prevents executor from inheriting broken code.
Current State
runPipeline() loops EXECUTE↔VALIDATE with previousError text only
- No state cleanup between retries — executor starts from dirty state of failed attempt
Plan
- Create
src/core/snapshot.ts:
createSnapshot(repoPath): string — lightweight git tag
restoreSnapshot(repoPath, ref): void — git checkout + clean
cleanupSnapshot(repoPath, ref): void — remove tag
- In
runPipeline(), snapshot before retry loop, restore on failure
- Cleanup on success or final failure
Files
src/core/snapshot.ts (NEW)
src/core/pipeline.ts
Summary
Before each EXECUTE attempt in retry loop, snapshot worktree state. On validation failure, revert to clean state before next attempt — prevents executor from inheriting broken code.
Current State
runPipeline()loops EXECUTE↔VALIDATE withpreviousErrortext onlyPlan
src/core/snapshot.ts:createSnapshot(repoPath): string— lightweight git tagrestoreSnapshot(repoPath, ref): void—git checkout+ cleancleanupSnapshot(repoPath, ref): void— remove tagrunPipeline(), snapshot before retry loop, restore on failureFiles
src/core/snapshot.ts(NEW)src/core/pipeline.ts