Linora

0401. Sync client: full rebase of pending ops, per-key shadows with seq, tail settlement

Status: Accepted (2026-11-27). Refines the client side of 0019; server behaviour in ADR 0202.

Context

ADR 0019 sketched the client as “canonical + pending”: shadows for property writes, and a revert/re-apply of pending structural ops only. Building it against the convergence simulation (real ScanBatch + StructIndex, disconnects, reloads, undo) showed four gaps in that sketch:

  1. Re-applying only structural ops clobbers later property writes and loses a SET that rides with a PARENT_INDEX.
  2. A pending DELETE’s inverse is a copy of the subtree taken when it was applied. Remote edits under that subtree, made directly or under nodes our own pending undo restored, are missing from the copy, so reverting it rebuilds a stale canonical state.
  3. A prediction of rejection can become wrong later (a remote RESTORE brings the target back), so drop-on-rebase is not final.
  4. After a reconnect, the server replays our own committed batches in the tail as BROADCAST, and dedupe ACKs carry the original, older seq.

Decision

Alternatives

Consequences

Remote structural batches and in-flight deletes cost O(pending ops) (normally a frame’s worth). The convergence sim (20K ops, 5 clients) is byte-identical on every seed swept so far. A small residue of extra rejections in rare undo/restore interleavings is rolled back correctly and tracked as a follow-up.