Skip to content

Realm _atomic rejects the advertised remove operation #5665

Description

@christse

Problem

The public AtomicOperationType includes remove:

export type AtomicOperationType = 'add' | 'update' | 'remove';

but Realm.validate() rejects every operation other than add and update with a 422 validation error. BoxelCLIClient.delete() exists, but it is an immediate standalone request and cannot participate in a coordinated multi-file atomic commit.

This blocks the Realm Program / Realm Script capability from safely providing shell-equivalent fs.remove() and fs.move(). Implementing those with direct deletes would violate preview mode and all-or-nothing commit semantics.

Evidence

  • packages/runtime-common/atomic-document.ts: AtomicOperationType includes remove.
  • packages/runtime-common/realm.ts: atomic validation only accepts add and update.
  • packages/realm-server/tests/atomic-endpoints-test.ts: asserts unsupported operations are rejected.
  • packages/boxel-cli/src/lib/boxel-cli-client.ts: delete() is standalone while atomicOperation() forwards to _atomic.

Expected behavior

POST <realm>/_atomic should support a remove operation with the same authorization, realm write lock, validation, indexing, invalidation, notification, and rollback guarantees as add/update.

Once available, Realm Script can implement:

  • realm.fs.remove(path) as a staged atomic remove;
  • realm.fs.move(from, to) as an atomic add/update + remove;
  • preview diffs that represent deletes and moves without mutating the Realm.

Acceptance criteria

  • _atomic accepts { op: 'remove', href } without data.
  • Missing-resource behavior is defined and tested (prefer a 404 conflict-style failure over silent success unless existing Realm semantics say otherwise).
  • Mixed add/update/remove batches are all-or-nothing under the Realm write lock.
  • Successful removal triggers the normal index invalidation and Realm notifications.
  • BoxelCLIClient.atomicOperation() can submit the operation without a special-case workaround.
  • Integration tests cover remove-only, move-shaped add+remove, mixed-operation rollback, authorization failure, and concurrent writes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions