Skip to content

Multiple eca__edit_file calls to the same in parallel can be harmful #621

Description

@zikajk

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

Please avoid AI slops, be concise, and focus on what matters for this issue.

Describe the bug
This is how agent described the problem when it encountered it:

after two eca__edit_file calls to the same file sent in one message, the file ends up
mangled (2026-09-13: run.sh got a duplicated tail with both the new and old `exec` line, plus a
partial duplicated line mid-file). Intermittent: batching sometimes works.
Cause: the second edit is applied against a stale snapshot, or the pair interleaves.
Fix: send same-file edits one per message; or prefer a single eca__write_file with the full
content, or one edit whose original spans all changes (net paren/line change of zero avoids the
editor's bracket auto-fixer reverting a change). Different files in one message are fine.

We should make the edit system smarter (or at least fail to avoid this).

Activity

  1. added theissue type on Oct 7, 2026
  2. mikemikimike commented on Oct 25, 2026

    @mikemikimike
    Contributor

    Implemented in #668.

    Same-file edits now serialize the full read/match/retry/write operation while different files remain concurrent. Regression tests cover path aliases, cancellation, failed writes, stale overlapping edits, and rollback snapshots.

    clojure -M:test passed with 1,062 tests and 6,578 assertions. All nine PR checks passed, including unit and JVM integration tests on Windows, macOS, and Linux, plus GraalVM and Nix builds.

  3. mikemikimike commented on Oct 29, 2026

    @mikemikimike
    Contributor

    Updated PR #668 to serialize all built-in filesystem mutations on canonical paths. edit_file, write_file, and move_file now avoid same-path races, while different files remain concurrent; multi-path moves acquire locks in a stable order. Added regression coverage for write-then-edit ordering. All unit, JVM integration, GraalVM, and Nix checks are passing: #668

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions