Severity: P2 (provenance miss → silent staging accumulation)
Source: Phase 1 code review (adversarial)
Problem
In match_edit_to_diff (hook.rs around line 573):
exact_window_match_str filters empty lines from the needle, which causes blank-line-bearing edits to fail strategies A and B.
- Strategy C (line-range proximity overlap) requires 50% overlap. A
Write tool call where the agent rewrote a 50-line file but only 3 lines actually changed has capture range [1, 50] and added range e.g. [27, 29] — overlap = 3, captured_len = 50, 3*2 < 50 → no match.
Result: such edits stay staged for the 14d TTL and may mis-attach to a future unrelated commit whose diff happens to add the same content.
Suggested fix
Two parts (both substantial):
- Handle blank lines in the needle/haystack matching — either preserve them, or use a structural LCS-style approach.
- For
Write tool, derive a tighter capture range than [1, file_line_count]. Track which lines actually differ from the prior content (compare before vs after) at staging time and store only the changed ranges.
Why deferred
Match-strategy redesign overlaps with U9 (history-rewrite handling) which will rework the same code paths. Better grouped there.
Related
Severity: P2 (provenance miss → silent staging accumulation)
Source: Phase 1 code review (adversarial)
Problem
In
match_edit_to_diff(hook.rs around line 573):exact_window_match_strfilters empty lines from the needle, which causes blank-line-bearing edits to fail strategies A and B.Writetool call where the agent rewrote a 50-line file but only 3 lines actually changed has capture range[1, 50]and added range e.g.[27, 29]— overlap = 3, captured_len = 50,3*2 < 50→ no match.Result: such edits stay staged for the 14d TTL and may mis-attach to a future unrelated commit whose diff happens to add the same content.
Suggested fix
Two parts (both substantial):
Writetool, derive a tighter capture range than[1, file_line_count]. Track which lines actually differ from the prior content (comparebeforevsafter) at staging time and store only the changed ranges.Why deferred
Match-strategy redesign overlaps with U9 (history-rewrite handling) which will rework the same code paths. Better grouped there.
Related