Structures

TwoPSet

A GSet can record every beacon the hikers find, but it cannot remove one. The hikers add a second GSet for permanent removals. Together, those two grow-only sets form a TwoPSet.

Add a second GSet

Each notebook has an additions GSet and a removals GSet. The additions GSet records every beacon name a hiker has received. The removals GSet records every name that a hiker knows is permanently retired. Both pages only grow, and the hikers merge each page by union.

Alice finds that the old Eagle Creek beacon is gone, so she writes Eagle Creek in the removals GSet. Her additions GSet still contains the name, but her visible list is empty. Bob and Carol still show Eagle Creek until they receive her removal record.

That retained removal record is a tombstone. It prevents a delayed or repeated addition record from making the retired beacon visible again.

A TwoPSet is composed of those two GSets. A value is visible only when it appears in additions and does not appear in removals.

The name means two-phase set. Each beacon name can move from never added, to present, to permanently removed. Eagle Creek cannot return after the second phase, but the hikers can still add other beacon names to their notebooks.

Notebook Additions Removals Visible list
AliceEagle CreekEagle Creekempty
BobEagle CreekemptyEagle Creek
CarolEagle CreekemptyEagle Creek
Each hiker computes the visible list from the two sets in that notebook.
TwoPSet = additions GSet + removals GSet
members = additions - removals

After the hikers exchange records, every notebook contains Eagle Creek in both sets. All three visible lists are empty. A delayed addition cannot erase the retained removal.

Three field notebooks

Race retirement against replacement

Alice retires Eagle Creek while Bob reports the same name again. The permanent tombstone must win at all three notebooks.

Merge rule Union additions and removals; removal wins forever.

Alice

Eagle Creek is active

Visible beacon list

Eagle Creek

Checkpoint note Removals page: Eagle Creek

Bob

Eagle Creek is active

Visible beacon list

Eagle Creek

Checkpoint note Additions page: Eagle Creek

Carol

Eagle Creek is active

Visible beacon list

Eagle Creek

Checkpoint note No note in this race

Trail relay No ordering decision 0 records shared

Mechanism evidence No retirement tombstone yet.

  1. No records shared yet.

Enable JavaScript to run the demo. The starting state and expected result remain in the lesson.

Eagle Creek is active. Race Alice's retirement against Bob's replacement report.

Bob finds the replacement

The next morning, Bob finds a new beacon at Eagle Creek. Its name is the same, so his notebook adds Eagle Creek again. The name was already in his additions, and Alice's removal record still excludes it after merge.

This is the cost of permanent removal. A TwoPSet cannot distinguish two installations that use the same value. The next set gives every add its own identity, so Alice can remove the old beacon while Bob's new beacon survives.

Sources and implementation

Watershed's TwoPSet kernel stores additions and permanent removals as two grow-only sets.