enhance(reapply-patches): post-merge verification to catch dropped hunks (#1775)
* feat(reapply-patches): post-merge verification to catch dropped hunks Add a post-merge verification step to the reapply-patches workflow that detects when user-modified content hunks are silently lost during three-way merge. The verification performs line-count sanity checks and hunk-presence verification against signature lines from each user addition. Warnings are advisory — the merge result is kept and the backup remains available for manual recovery. This strengthens the never-skip invariant from PR #1474 by ensuring not just that files are processed, but that their content survives the merge intact. Closes #1758 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * enhance(reapply-patches): add structural ordering test and refactor test setup (#1758) - Add ordering test: verification section appears between merge-write and status-report steps (positional constraint, not just substring) - Move file reads into before() hook per project test conventions - Update commit prefix from feat: to enhance: per contribution taxonomy (addition to existing workflow, not new concept) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,21 @@ git -C "$CONFIG_DIR" log --oneline --no-merges -- "{file_path}" | grep -v "gsd:u
|
||||
Each matching commit represents an intentional user modification. Use the commit messages and diffs to understand what was changed and why.
|
||||
|
||||
4. **Write merged result** to the installed location
|
||||
|
||||
### Post-merge verification
|
||||
|
||||
After writing each merged file, verify that user modifications survived the merge:
|
||||
|
||||
1. **Line-count check:** Count lines in the backup and the merged result. If the merged result has fewer lines than the backup minus the expected upstream removals, flag for review.
|
||||
2. **Hunk presence check:** For each user-added section identified during diff analysis, search the merged output for at least the first significant line (non-blank, non-comment) of each addition. Missing signature lines indicate a dropped hunk.
|
||||
3. **Report warnings inline** (do not block):
|
||||
```
|
||||
⚠ Potential dropped content in {file_path}:
|
||||
- Missing hunk near line {N}: "{first_line_preview}..." ({line_count} lines)
|
||||
- Backup available: {patches_dir}/{file_path}
|
||||
```
|
||||
4. **Track verification status** — add to per-file report: `Merged (verified)` vs `Merged (⚠ {N} hunks may be missing)`
|
||||
|
||||
5. **Report status per file:**
|
||||
- `Merged` — user modifications applied cleanly (show summary of what was preserved)
|
||||
- `Conflict` — user reviewed and chose resolution
|
||||
@@ -253,4 +268,5 @@ Ask user:
|
||||
- [ ] User modifications identified and merged into new version
|
||||
- [ ] Conflicts surfaced to user with both versions shown
|
||||
- [ ] Status reported for each file with summary of what was preserved
|
||||
- [ ] Post-merge verification checks each file for dropped hunks and warns if content appears missing
|
||||
</success_criteria>
|
||||
|
||||
Reference in New Issue
Block a user