zip

Pair this value with other into a LatticeProduct, combining both states into a single coordination-free snapshot.

The product is monotone by construction: componentwise join of two semilattices is itself a semilattice. The combined value can be embedded, transported, and merged exactly like any other CoordinationFree value, with both states kept in sync.

Return

a coordination-free LatticeProduct of this and other.

Parameters

other

the second coordination-free value.

Type Parameters

B

the second lattice type.

Samples

val r1 = ReplicaId("r1")
val r2 = ReplicaId("r2")

// Each peer carries its own (events seen, net score) snapshot.
val peerA: CoordinationFree<LatticeProduct<GCounter, PNCounter>> =
    CoordinationFree(GCounter.of(r1 to 3L))
        .zip(CoordinationFree(PNCounter.ZERO.piece(PNCounter.ZERO.increment(r1, 100L).delta)))

val peerB: CoordinationFree<LatticeProduct<GCounter, PNCounter>> =
    CoordinationFree(GCounter.of(r2 to 7L))
        .zip(CoordinationFree(PNCounter.ZERO.piece(PNCounter.ZERO.increment(r2, 200L).delta)))

// After merging: GCounter sums, PNCounter sums.
val merged = peerA.embroider(peerB)
check(merged.state.first.value == 10L)   // 3 + 7
check(merged.state.second.value == 300L) // 100 + 200

// Idempotent: absorbing the same peer again changes nothing.
check(merged.embroider(peerA).state == merged.state)