aboutsummaryrefslogtreecommitdiffstats
path: root/docs/guides/federation/remakes.md
blob: ef602669d487609ddcdd0043b847566b6c746719 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Remakes under a federation

A remake moves a swarm to a new document, for Automerge's sake only: the store needs
none, and its events stay what they are. A federated swarm takes compactions only. How a
remake runs is as in any swarm ([`remakes.md`](../../remakes.md)); this guide says what is
otherwise. The rules are the store's ([`store.md`](../../store.md), Remakes).

## Proposing one

```sh
curl -u tv:secret -X POST -H 'Content-Type: application/json' \
  --data '{"kind": "compact"}' localhost:3000/admin/remakes
```

Any other kind is refused (`400`: `a swarm holding a store takes compactions only`).
Every user a node lets in may propose one there. The electorate is the members whose
alive stamp is recent, as in any swarm, but only those the store names as members, with
the party their entries name: another node's entry counts for nothing. The acks tell an
honest coordinator when to commit, and bind nobody.

## The snapshot

Every node builds the snapshot itself, from the base it holds: the store as it reads the
document up to the base, from the document's checkpoint, by its own refusals and drops.
It holds the checkpoint the store reached there (where it isn't the root) at
`_continuum/checkpoint`, the events that checkpoint keeps and those after it, and of
continuum's protocol data what a compaction carries, but the entries of nodes that
aren't members. What that checkpoint forgot, and events nobody takes, leave the
document here. A node reading its store anew starts at the document's checkpoint.

Nodes that read the store differently at the base, the sides of keys that voted twice,
build different snapshots, and part here.

## After the switch

A node puts again what the new document lacks: what it holds beyond the base, and, where
it moved to a later checkpoint since the base, what the old document holds that the new
one's store needs to reach that checkpoint (`Of the document left, events to put again`,
`Put again events the document lacked`). It replays no events: they are put again as they
were.

## Two epochs for one

Of two epochs decided for one, by a coordinator that wrote two decisions or by remakes
decided at once, a node follows the one with the lower ID, and a node on the other
rejoins it.

## Rejoining

A node that was away, lacks the base, or is on the higher of two epochs rejoins, but only
an epoch whose snapshot holds its document's checkpoint, one it builds from that
document, one its operator pins (`--store-checkpoint`), or, to an empty document, the
root; and only one with its swarm's policy. A made-up epoch can withhold events from a
node and keep it apart from the others, but make it take nothing it wouldn't. A node
that can't follow the others' epoch, as its snapshot holds a checkpoint it can't build,
follows it once its operator pins that checkpoint
([`checkpoints.md`](checkpoints.md), Nodes that weren't there).

## Without remakes

A swarm that never remakes holds what one that remakes all the time holds; its document
only grows. Nothing in the federation waits on a remake.