Conversation
The V2 edit leaf matched oldString with a single literal indexOf scan and hard-failed on anything inexact. V1's replace() already handled the common near-miss cases with nine ordered strategies; this ports the lenient ones as pure synchronous helpers and consults them only after exact matching returns zero. Adds line-trimmed, block-anchor, whitespace-normalized, indentation-flexible, escape-normalized, trimmed-boundary and context-aware matching, each bounded to the region oldString describes. An ambiguous candidate is skipped rather than guessed, so it still surfaces a multiple-matches error. The tool schema is unchanged, permission ordering is unchanged, and writes still go through writeIfUnchanged so stale-read protection is preserved. Clears the deferred fuzzy-parity TODOs in tool/edit.ts and tool/builtins.ts.
Fixes anomalyco#41872: replace() committed the first byte-unique candidate from a strategy, so two candidates that normalize to the same oldString but differ in bytes bypassed the multiple-match safeguard. Resolve a whole strategy before committing and dedupe by span rather than matched bytes. Fixes anomalyco#45199: block-anchor scored two blank lines as 0 instead of 1, so any block with enough blank lines could never clear the similarity threshold no matter how similar the rest was. Blank lines are an exact match. Both tests assert the old behavior fails, so they pin the fixes rather than the surrounding logic.
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Owner
Author
|
READY_UPSTREAM Exact-head gate passed:
Post this fork leaf's fail → pass → restore evidence upstream with local |
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.
Tip leaf (fork-only) — CLEAN
Maps to work-order issue #182. Upstream origin anomalyco#51707 (not touched / not promoted).
What: Port fuzzy edit matching to the V2 edit tool and correct two fuzzy matching defects (whitespace-equivalent candidates; blank-line block scoring).
Commit:
7f1c5947a00f5d7b2ffe96b42f698614976a4e2eOrigin tip SHA:
d0c92be03cf7bbd810006378a85d85f93a3cfb38Proof: fail→pass on
packages/core/test/tool-edit.test.ts(GREEN 18 / NEG 4 fail / RESTORE 18).github_writes_origin: 0. Codex promote parked.