Repository navigation
fix(diff-edit): reject conflicting blocks during validation - #2248
Merged
akramcodez merged 1 commit intoNov 18, 2026
Merged
Conversation
aliberk1
requested review from
addyCooks,
akramcodez and
will-lamerton
as code owners
November 16, 2026 09:42
Contributor
|
nc-review could not produce a verdict this run (agent exit |
Member
|
Thanks @aliberk1, merged! Appreciate the clean fix and the regression specs. |
8 of 18 tasks
Mahdi-Hasan
added a commit
to Mahdi-Hasan/nanocoder
that referenced
this pull request
Nov 26, 2026
Block 2 is matched in block 1's output, so block 1's fitted lines must be CRLF. A second test checks that a fitted replacement which repeats block 2's search is rejected by the ordered dry run from Nano-Collective#2248.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #2235.
validateBlockschecked each SEARCH against the original file, whileapplyBlockschecked the content after each earlier replacement. The reportedone -> two,two -> THREEedit therefore passed validation but failed during execution: the second search had become ambiguous.Validation now also dry-runs
applyBlocksand returns the prepared content. Execution and the VS Code preview use that returned content instead of applying the blocks a second time. An edit that removes or duplicates a later search now fails validation with the same block-numbered error as execution, before any write.This takes the issue's rejection option: the existing distinct-original-range contract stays in place, rather than introducing chained-edit semantics that would also require changing original-range preview and visibility handling.
Type of Change
Changeset
@nanocollective/nanocoder.Testing
Automated Tests
X=1/Y=2swap, and an earlier edit that removes a later search. Each checks validation, execution, and unchanged file contents.pnpm test:allsuite (not run; followed AGENTS.md's preference for focused specs).Checks run on Linux, Node 24.22.3, pnpm 11.0.9:
Biome reported only the existing informational schema-version mismatch (2.5.0 config vs 2.5.13 CLI). I also ran the original validation/application helpers against all three regression inputs to confirm validation accepted them while application threw, then verified the corrected helpers reject them during validation.
Manual Testing
No live model/provider or VS Code session was exercised; this is shared file-edit validation logic covered by local tests.
Checklist
AI assistance: implemented and tested with OpenCode using OpenAI GPT-6 Astra.