fix(tools): guard replayed JSON value patches - #84278
Open
KCAYAAI wants to merge 2 commits into
Open
Conversation
KCAYAAI
marked this pull request as draft
August 12, 2026 04:13
KCAYAAI
force-pushed
the
fix/patch-replay-before-similarity
branch
from
August 12, 2026 04:15
c3e9b24 to
fc865a8
Compare
KCAYAAI
marked this pull request as ready for review
August 12, 2026 04:21
Contributor
fix(tools): guard replayed JSON value patches Targeted fix for a real false-positive class; the exact-equality + single-property constraints are the right conservative shape. Observations:
|
Keep replayed JSON value-patch guard on current main.
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.
Summary
block_anchororcontext_awarecan reinterpret a target value as a larger propertypatchfile-I/O regressions for the production JSON replay and the selected-candidate false-positive classRoot cause
The merged generic already-applied detector runs only after
fuzzy_find_and_replace()returns no match. In the incident shape, a stale JSON string value reachedcontext_aware, which selected the enclosing JSON property. The JSON validator prevented the destructive write, but the patch failed instead of recognizing the replay.An earlier draft used
new_string in selected_candidateas replay proof. Independent adversarial review showed that was too broad: a legitimate block replacement can retain the target phrase as unchanged context. This revision fails closed unless the full file is valid JSON and the selected candidate parses as exactly one property with a complete string value equal tonew_string.Why this placement and scope
Precise strategies still run first. The no-op guard runs only after a similarity strategy selects a candidate, and only for the narrow JSON scalar-string incident shape. This preserves legitimate normalized edits while preventing
block_anchororcontext_awarefrom expanding an already-landed JSON value edit into a larger mutation.This differs from #56570, which checks target presence before every matcher. That whole-file approach can skip a valid edit when the same target text exists elsewhere. It also differs from substring containment inside a selected candidate, which can skip a valid block contraction when the target is merely retained context.
Tests
git diff --checkreplace_all=FalseandTrueSeparate pre-existing behavior
V4A patch mode can report an unchanged replay under
files_modified. The same behavior reproduces onorigin/main, so it is not introduced or expanded here and remains outside this replace-mode fix.Closes #18426