Skip to content

fix: preserve multiple edits targeting the same file - #8

Open
harshitethic wants to merge 2 commits into
mainfrom
fix/preserve-multiple-edits-per-file
Open

harshitethic wants to merge 2 commits into
mainfrom
fix/preserve-multiple-edits-per-file

Conversation

@harshitethic

Copy link
Copy Markdown
Owner

Problem

apply_edits() validated every edit against the file's original contents and staged a complete replacement for each edit. When two valid edits targeted the same file, the later staged write was also based on the original file and could overwrite the earlier edit.

Fix

  • keep one staged current version per file
  • apply same-file edits sequentially to that staged content
  • keep validation atomic: files are still written only after all edits validate
  • report the number of edits applied rather than the number of distinct files
  • add a regression test proving two edits to one file both survive

This fixes silent loss of model-generated edits without changing the edit JSON contract.

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.

1 participant