Skip to content

fix: only treat whole lines as SEARCH/REPLACE markers - #546

Merged
codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
r0h1tb:fix/diff-separator-line-anchored
Oct 25, 2026
Merged

codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
r0h1tb:fix/diff-separator-line-anchored

Conversation

@r0h1tb

@r0h1tb r0h1tb commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

The standard SEARCH/REPLACE pattern matches =======\n and >>>>>>> REPLACE anywhere in the response, not only as whole lines. So a SEARCH section containing a banner comment (# =========================, common in generated code) is cut at that comment. The truncated SEARCH text matches nothing, and apply_diff skips the block without an error. A comment containing >>>>>>> REPLACE ends the replacement early in the same way.

The delimiter validation from #494 already reads markers as whole lines and allows trailing whitespace and CRLF on them. Extraction still needed an LF right after SEARCH and =======, so a CRLF response, or one with a space after a marker, was rejected as an unmatched delimiter.

Standard blocks are now extracted from the same whole-line markers the validation uses, with the same two error messages. Custom diff_patterns and the config default are unchanged.

Tests: new cases for a banner comment and marker text inside code lines, a CRLF response, and trailing whitespace on marker lines; all 4 fail on main. test_crlf_marker_is_recognised expected a CRLF response to be rejected; it now expects it to parse. A differential run of the old and new extractors over 20,000 random responses without those shapes gave identical results. Full suite 900 → 904 passed, 8 skipped; the 17 errors are the integration tests that need a live LLM, same on main. Black passes.

The standard diff pattern matched "=======\n" and ">>>>>>> REPLACE"
anywhere, so a SEARCH section containing a banner comment such as
"# =========" was cut at that comment and the block silently failed to
apply, and a comment containing ">>>>>>> REPLACE" ended the replacement
early. The delimiter validation already reads markers as whole lines
(allowing trailing whitespace and CRLF), but extraction still needed LF
right after each marker, so such responses were rejected as unmatched.

Extract standard blocks from the same whole-line markers the validation
uses. Custom diff patterns are unchanged.
@codelion
codelion merged commit 5153a7d into algorithmicsuperintelligence:main Oct 25, 2026
5 checks passed
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.

2 participants