Structures · Coordination

Complexity Expert

PactMap

Keep the current plan until everyone connected at the proposal approves the replacement or leaves.

A proposal has two completed seals and one empty seal position below a raised stamp; its closure notice remains folded.

Three hikers agree on one plan

TaskManager let the ranger pick one hiker. Here, every hiker must agree. The accepted plan sends hikers out by the north gate. Alice proposes ridge-pass instead, and every notebook keeps north-gate until each hiker who was connected when the proposal arrived has signed off or left.

Every notebook continues to show north-gate as the accepted plan. The ridge-pass proposal waits beside it. Who must agree depends on who was connected when the proposal arrived, and only one shared order can fix that moment. So the ranger numbers the proposal and copies the connected roster into its signer list.

A proposal does not replace the accepted plan. Once the ranger numbers it and fixes the signer list, each hiker can send one signoff. The plan changes only when the signer list is empty.

From a proposal to an accepted value

  1. Keep the accepted value. Reads continue to return north-gate while a replacement waits.
  2. Number one proposal. The proposal records ridge-pass and copies the connected roster into a signer list: Alice, Bob, and Carol.
  3. Remove each signer. A signoff removes its author from the signer list. A hiker who leaves the roster is removed too.
  4. Settle when the list is empty. The pending value becomes the accepted plan when no signers remain.

Run the conflict

Keep the accepted plan visible while signoffs and roster changes clear a pending replacement.

Approve the closure plan

Keep the current plan readable while every required hiker reviews its replacement.

Agreement ruleEveryone on the signer list must sign or leave

Accepted

This is the readable value.

  • north-gate

Pending proposal

One proposal per key.

  • No proposal pending.

Signer list

Copied from the roster when the ranger numbers the proposal.

  • No signoffs required.

Alice

Agreement statusConnected

Bob

Agreement statusConnected

Carol

Agreement statusConnected

Run the worked example

Alice proposes ridge-pass. Alice and Bob sign. Carol leaves the roster, which clears the last signoff.

Enable JavaScript to run the agreement. The expected result remains in the lesson.

Ready: north-gate is accepted.

Read the result

North-gate remains readable while ridge-pass is pending. Alice and Bob sign off. When Carol leaves the roster, the signer list is empty, so ridge-pass becomes the accepted plan.

Agreement covers only who was connected

PactMap gives unanimity among the hikers connected when the proposal was numbered. It does not wait for hikers who join later, and a hiker who leaves cannot block the change forever. Each key can hold only one pending proposal, and every step needs the ranger station.

To compare every structure you have met, read CRDT, DDS, and OT, which sets the three ways shared data can agree side by side.

Sources and implementation

Sources: Watershed's pact_map_kernel.

Implementation: The demo calls pact_map_kernel.set, pact_map_kernel.apply_set, pact_map_kernel.apply_accept, pact_map_kernel.remove_member, pact_map_kernel.pending, and pact_map_kernel.get through the Gleam toolkit. The displayed client records and shared view come from those kernel results.