Problem
The generate_patch() function in src/mcp.rs creates a synthetic commit (git add -A + git commit), runs git format-patch, then resets it (git reset HEAD~1). If the process is killed (OOM, SIGKILL) between commit and reset, the synthetic commit persists in the agent's working directory (not a worktree), potentially confusing subsequent agent invocations.
Suggested Fix
Consider a lighter alternative that avoids committing:
- Use
git stash --include-untracked before the merge-base diff, then git stash pop
- Or pass
--cached + unstaged diffs separately to avoid modifying git history
Context
The current implementation handles soft errors correctly (the reset runs before propagating format-patch errors, and the SHA is included in error messages). This issue is specifically about hard process kills that bypass cleanup. Low probability but worth a FIXME note if the synthetic-commit approach stays.
Identified in PR #155 review.
Problem
The
generate_patch()function insrc/mcp.rscreates a synthetic commit (git add -A+git commit), runsgit format-patch, then resets it (git reset HEAD~1). If the process is killed (OOM, SIGKILL) between commit and reset, the synthetic commit persists in the agent's working directory (not a worktree), potentially confusing subsequent agent invocations.Suggested Fix
Consider a lighter alternative that avoids committing:
git stash --include-untrackedbefore the merge-base diff, thengit stash pop--cached+ unstaged diffs separately to avoid modifying git historyContext
The current implementation handles soft errors correctly (the reset runs before propagating format-patch errors, and the SHA is included in error messages). This issue is specifically about hard process kills that bypass cleanup. Low probability but worth a FIXME note if the synthetic-commit approach stays.
Identified in PR #155 review.