Skip to content

fix(rust): reject overlapping exact Edit matches - #6859

Merged
M4n5ter merged 1 commit into
apache:rust-previewfrom
kesonm:sklil/fix-rust-edit-6858
Nov 15, 2026
Merged

M4n5ter merged 1 commit into
apache:rust-previewfrom
kesonm:sklil/fix-rust-edit-6858

Conversation

@kesonm

@kesonm kesonm commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Rust Edit accepted overlapping exact matches as unique and modified the first span. For example, replacing two consecutive item lines in a three-line repetition succeeded despite two possible starting positions.

Compare the first and last exact-match positions so overlapping matches are rejected before writing. The existing fuzzy path uses the same uniqueness approach. Regression coverage invokes the real file executor for repeated lines, banana/ana, repeated ASCII, and multibyte text, verifies unchanged bytes on rejection, and preserves a unique self-overlapping-pattern control.

Fixes #6858
Refs #5589 (the earlier TypeScript report)

Verification

  • The new regression failed against the unmodified Rust implementation, which returned success instead of the uniqueness error.
  • cargo test --offline -p maka-fs-tools: 28 passed (7 unit tests, 21 integration tests), no failures. Existing exact, fuzzy, file-read/write, patch, and workspace behavior tests remain passing.
  • cargo fmt --all -- --check: passed; stable rustfmt reports warnings for repository nightly-only formatting options.
  • cargo clippy --offline -p maka-fs-tools --all-targets --no-deps -- -D warnings: passed, including compilation/type checking of all targets.
  • git diff --check: passed.

Full dependency linting without --no-deps is blocked by an existing clippy::needless_update at plugins/agent/provider-protocol/src/chat_completions/response.rs:87, outside this change. Installed nextest 0.9.143 is below the repository's required 0.9.145, so the crate suite was run with Cargo's test runner instead; the version guard was not bypassed. Full workspace and Desktop UI suites were not run for this focused file-tool change.

Test output:

test edit::overlapping_exact_matches_are_rejected_without_writing ... ok
test result: ok. 7 passed; 0 failed
test result: ok. 21 passed; 0 failed

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex prepared the fix, regression tests, and PR description at kesonm's request, and ran the listed checks. kesonm is the human contributor of record.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/S Under 100 readable lines label Nov 13, 2026
@M4n5ter

M4n5ter commented Nov 15, 2026

Copy link
Copy Markdown
Member

Clean fix, thanks for the contribution!

@M4n5ter
M4n5ter merged commit 3579915 into apache:rust-preview Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/S Under 100 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants