Skip to content

[Feature]: Add conditional text updates for shared memory files #4165

Closed as not planned

Description

@ningmao-hlyz

Is your feature request related to a problem? Please describe.

Memory appends through a configured filesystem read the file, concatenate the new entry, then upload the whole result. The lock belongs to one WorkspaceManager. Two managers or replicas can read the same version and both return from append successfully while the later upload replaces the other entry.

On a4306d63, this can be reproduced with two WorkspaceManager instances sharing one RemoteFilesystem backed by InMemoryStore. Seed memory/probe.md with seed\n, pause both filesystem reads after they return that snapshot, then let each manager append a distinct line. The final file contains the seed and one line. The model is not involved.

Describe the solution you'd like

Expose optional conditional UTF-8 file reads and updates through filesystem routes, then use them for memory appends:

  • Distinguish a missing file from an empty file; a stale expected value returns a conflict.
  • Preserve the exact key used by ordinary file IO, including workspace-relative memory paths.
  • Support local writers across JVMs and stores with atomic versioned writes.
  • Preserve overlay reads from lower layers before the first upper-layer write; progress files can opt out of inheritance.
  • Bound conflict retries and report exhaustion. Keep legacy append behavior for backends without this optional capability, without claiming concurrent-write guarantees there.

The operation covers cooperating appenders. It does not make shell edits, whole-file saves or archive moves part of the same transaction.

Describe alternatives you've considered

A lock on one manager cannot coordinate another instance or replica. Reusing uploadFiles would change its existing snapshot replacement contract; a separate optional capability keeps that behavior available.

Additional context

The current read/merge/upload path is in WorkspaceManager.java.

Target: 2.1.0-SNAPSHOT at a4306d63 (#4154), Java 17. The reproduction uses the real in-process store and filesystem, with a barrier controlling the read interleaving; it does not exercise a network store.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions