Skip to content

surface hand batch child deletes in optimistic prune plan#389

Open
lovasoa wants to merge 1 commit into
masterfrom
ophir.lojkine/optimistic-prune-batch-deletes
Open

surface hand batch child deletes in optimistic prune plan#389
lovasoa wants to merge 1 commit into
masterfrom
ophir.lojkine/optimistic-prune-batch-deletes

Conversation

@lovasoa

@lovasoa lovasoa commented May 28, 2026

Copy link
Copy Markdown
Owner

surface hand batch child deletes in optimistic prune plan

optimisticPrunePlanForAuthoritativeMessage() only invalidated optimistic state for top-level DELETE/CLEAR. But getMutationType() returns BATCH whenever _children is present, so child deletes inside hand-tool selection batches (deleteSelection()) were never surfaced. A peer deleting an item via hand selection while this client held pending optimistic writes for it would leave stale state that could later resurrect.

This adds a BATCH branch that walks _children, collecting every child DELETE id into invalidatedIds and treating a child CLEAR as reset. Top-level handling is unchanged.

Tested:

$ node --test test-node/optimistic_journal.test.js
# 10 tests, 10 pass, 0 fail

The 2 new tests cover a hand batch with child deletes (mixed with an UPDATE) and a child clear. npm run lint and npm run typecheck are clean.

optimisticPrunePlanForAuthoritativeMessage only handled top-level
DELETE/CLEAR. Hand selection deletes are sent as a BATCH of child
delete messages, so peer deletes left stale optimistic state.

Now inspect batch _children: collect child DELETE ids and treat a
child CLEAR as reset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant