Skip to content

edit tool: fuzzy replacer chain silently overwrites previous edits in same file #32559

Closed

Description

Description

The fuzzy replacer chain in edit.ts (BlockAnchorReplacer, WhitespaceNormalizedReplacer, IndentationFlexibleReplacer, ContextAwareReplacer) allows stale edits to silently overwrite previous changes to the same file.

Concrete example

  1. File contains: return calculate()
  2. Edit 1 succeeds: return calculate() becomes return calculate() + 1
  3. Edit 2 proposes oldString return calculate() which is stale
  4. BlockAnchorReplacer matches the already-modified content at 81.8% similarity (threshold 65%) and applies Edit 2 silently reverting Edit 1

Root causes

  • Fuzzy thresholds too permissive: 0.65 Levenshtein similarity, 50% line-match
  • No staleness check before fuzzy matching
  • Replacer chain degrades to loose matching instead of failing

Related issues

Related to but distinct from:

Additional design notes

  • Lock map never evicts entries
  • No built-in undo
  • Double diff not cached

Activity

  1. github-actions commented on Jun 16, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If this is not covered by either of the above, please clarify how it differs so maintainers can track it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions