Proposing and voting
Everything a federation decides is a change of its policy: who the parties are, the keys
they vote with, who writes where, a checkpoint. A party proposes a version, the parties
vote, and once two thirds of them back it, it is written. The rules are the design's
(federation.md, The policy,
Changing the policy). A party's node list and
its key set are its own to write, without a vote
(common-changes.md).
Writing a version
The changes made most have a command each, which writes the version from the current
one and proposes it: propose admit, remove, give, take, keys, nodes,
checkpoint and revision (common-changes.md). With --print,
each writes the version to standard output instead, to change further and propose as a
file.
A version is the whole policy, not a change to it. To write one by hand, begin from the
current one, as a node shows it, with number and changes set and its checkpoint
left out, as below:
continuum-party --node http://tv:secret@localhost:3000 next > next.json
What each field holds, to change (common-changes.md has recipes
for the changes made most):
number: one more than the current version's.changes: the current version's hash.keys: every party's keys, with theirsince. A party let in, or whose keys the version names anew (replaced, or the same named anew), has this version's number as itssince; every other keeps thesinceit had, and its keys unchanged. A party left out is no party any more.nodes: every party's node list, with itssince, likewise. The version letting a party in names its list anew, empty where it gives it no nodes. Otherwise a version names a list anew only where its party can't write its own, with a key the current version names for it: a party adds and takes off its nodes by itself (common-changes.md).rules: in order, the first matching a path deciding who writes there (writing-and-reading.md, Places).checkpoint, only where the version moves the store to a checkpoint: the heads. Otherwise leave it out, though the current version names one: its heads are behind, and a version naming them again is never written.revision, the revision of the federation the version follows, by its ID, left out for the base revision: the current version's, or a later one (next --revision,upgrades.md, Moving to a revision).
Party names are 1 to 64 of A-Z a-z 0-9 . _ @ -; a version names up to 96 parties; a
party has up to 16 keys and 64 nodes; a rule's path is a path as a write's is, its first
segment literal and not _continuum, ** last only, {party} once at most, and its
writer a party of the version, "{party}" where the path holds it, or false. A version
breaking any of that is none, and a party's client backs none; where two thirds pass it
all the same, nodes stop at the version event writing it, until their operators have them
drop it (when-things-go-wrong.md,
A node stopped).
Proposing
continuum-party --node http://tv:secret@localhost:3000 --key tv.key --record tv.record \
propose next.json
# version 4 on 3:
# adds rule 1: names/r/wiki -> lass
# Propose it? [y/N] y
# c41e… taken
# proposal 8d02…
The client says what the version does to the current one, as show says it of a
proposal (Following a vote), and asks before it signs, where its
input and its errors are a terminal; asked nothing, as in a script, it goes on. It
proposes nothing that changes the current version only by its number. With --yes, it
votes true on it too, as vote 8d02… yes does (Voting, below), asking once
for both: a party whose node votes for it by itself votes through that node instead.
The client proposes only a version it would back: one changing the current one as a
version must (its number, changes, and each since), whose checkpoint, where it names
one, names no more than 64 heads and none of the heads of the current version's
checkpoint, as such a version is never written. It says why it doesn't propose one
otherwise. The proposal is on the current version, and its hash is the version's: the node
shows it under that hash (proposals in GET /events/counts), with the events proposing
it that a vote may build on: of a checkpoint, those above its heads. Several parties
proposing the same version make one proposal. The key a party proposes and votes with is
one the current version names for it, not one of its key set: the client checks that
before it signs, and records nothing otherwise.
A proposal lapses, with the votes on it, once its version isn't current any more: when another proposal on it passed.
Voting
continuum-party --node http://tv:secret@localhost:3000 --key tv.key --record tv.record \
vote 8d02 yes
A proposal is named by its hash, or by a prefix of it, four digits or more, that no other
proposal on the current version starts with: the client says which proposals a prefix
names where it names several. On a terminal, it marks the shortest such prefix in bold
wherever it shows a proposal's hash (proposals, propose). Heads given to fork are
named so too, among the heads the node shows.
The client votes by the party's record, never by what a node shows, and writes the record before it sends the vote. It casts no vote that would make its party vote twice:
- never
trueandfalseon one proposal, nor the same vote twice; - nothing on the version current when the record began, as a vote sent before may be held back somewhere;
trueonly for a version changing the current one, whose checkpoint names none of the current checkpoint's heads;- one
trueat a time: anothertrueon the same version only once the proposal the party backed is dead. The client fetches the votes that made it so from the node, keeps them in the record beside the newtrue, and builds thetrueon them, so that the first is dead at its history too: the proposal it backs next may have been proposed at a history holding its firsttrue. A checkpoint'strueit builds on the proposal alone, and says when it may be refused so: where the nays came after the heads the checkpoint names, back the one proposed after.
A true holds the party until its proposal passes or is dead, and only other parties'
nays make it dead. Where ending it would take every party yet to vote, or more, and those
are a third of the parties or fewer, the client says so before it casts the true
(Warning: this `true` binds tv until the proposal passes, …): one of them staying
quiet binds the party on this version for good, unless the proposal passes.
A party votes from one client, with one record: two clients backing two proposals at once
is voting twice, and shows (federation.md,
Changing the policy). Before it casts, the
client holds the record against the votes of its party the node shows on the current
version, and says nothing where they agree:
- a vote the node shows that the record lacks refuses the vote: another record votes for
the party, or this one was begun anew, and casting beside it may be voting twice;
restore(below) takes it into the record; - a vote the record holds that the node doesn't show yet is said: on its way, or held back where it was put;
- the party's nodes the node hasn't heard from in five minutes are said, as a vote put
through one of them may not have reached it, and so are the parties none of whose nodes
it heard from lately, where they are a third of those with nodes or more: a part of the
swarm may be cut off, its votes not here (
heardinGET /events/counts).
It then waits five seconds (--wait SECONDS, 0 not at all), asks the node again, and
casts only where nothing came meanwhile: a vote cast elsewhere just before arrives first.
A vote cast elsewhere at the same moment, or held back by a cut, it can't see: one place
votes for a party. A party whose node votes
for it by itself votes by hand only through that node, which keeps its one record:
continuum-party --node http://tv:secret@localhost:3000 vote 8d02… yes --through
A party that lost its record begins a new one at a node (continuum-party init); it
casts nothing on the current version, and votes again from the next one. Or it restores
one, best effort: restore takes the party's votes on the current version, as the node
holds them, into the record, a new one where there is none (with --party), which then
casts on the current version by them:
continuum-party --party tv --record tv.record restore
# took 1 vote of tv on version 3 into tv.record, as the node holds them; one on its way
# from elsewhere isn't among them
A vote held back somewhere, or still on its way, isn't among them: restore where the node
hears from every party's nodes, and give a vote cast before the loss time to arrive. What
the party signs again after a move (again) a restored record doesn't know, nor the nays
that freed its earlier true, which its old record kept. A party that never voted may
begin its record from the root (init --root), and casts on every version.
Counting support first
A true isn't taken back, and binds while its proposal can pass. Parties that want to
know who would back a proposal before anyone is bound can say so by plain writes, which
bind nobody and count for nothing in the votes. The version gives each party a place for
it, by a rule:
{"path": "intents/{party}/**", "writer": "{party}"}
and each party writes there, by the proposal's hash, whether it would back it:
continuum-party --node http://tv:secret@localhost:3000 --key tv.key --record tv.record \
write intents/tv/8d02… true
Anyone reads them at values in GET /events/counts:
curl -s -u tv:secret localhost:3000/events/counts \
| jq '.values | with_entries(select(.key | test("^intents/[^/]+/8d02")))'
Once two thirds of the parties wrote true, each backs it. A party's write there is its
word, not its vote: it may write false later, or vote otherwise. It doesn't help with
parties that stay quiet: they write nothing either.
Passing and dying
A proposal passes once at least two thirds of its version's parties voted true
(3·yes ≥ 2·parties), and is dead once so many voted false that the rest can't
pass it (3·(parties − no) < 2·parties):
| parties | true to pass |
false to kill |
|---|---|---|
| 2 | 2 | 1 |
| 3 | 2 | 2 |
| 4 | 3 | 2 |
| 5 | 4 | 2 |
| 6 | 4 | 3 |
| 7 | 5 | 3 |
| 9 | 6 | 4 |
Every party counts, quiet ones too: a version naming parties that never vote makes every
decision harder. Once a node holds a proposal passed, it writes the version, and every
node takes it: .version.number in GET /events/counts is its number then.
A true binds its party while its proposal can still pass. Of nine parties, five back X,
two prefer Y and two never vote: X needs one more, and can't die, as that takes four
nays; the five back nothing else on this version. Votes that split pass nothing, three
for one proposal and three for another of six: a false on the proposal you won't back
kills it the sooner, and frees its backers for another.
Following a vote
GET /events/counts names each proposal on the current version with the events
proposing it (proposals) and the votes on it (votes), each by its ID; the parties
voting true (yes) and false (no); whether it passed (passed) and whether it is
dead (dead), as the node reads its votes; and why no party's client backs it (none),
where it is no version this node reads, none changing the current one, or one naming the
heads of the current one's checkpoint, else null:
curl -s -u tv:secret localhost:3000/events/counts | jq .proposals
# {"8d02…":{"dead":true,"no":["lass"],"none":null,"passed":false,
# "proposals":["c41e…"],"votes":["5a77…","e019…"],"yes":["tv"]}}
The client shows a proposal in words before anyone votes on it (show, and proposals
for all of them): whether it passed or is dead, who voted what and how many more true
pass it, who proposed it, and what its version does, not its JSON. That is the parties
it lets in or takes out, with their keys by fingerprint (as ssh-keygen -l gives them)
and their nodes; the keys and node lists it names anew; the rules it adds or drops, where
they are among the rules; the checkpoint it moves the store to, and what moving there
refuses of what the node took; the revision it moves to, and the nodes not known to know
it. And the places holding a value whose writer it changes (who writes): admitting a
party named as a segment of a place is, or changing the rules or their order, moves who
writes there, rules unchanged in the first case, and what was written there counts no
more once it passes. Where no client backs it, it says why, by the federation it knows:
continuum-party --node http://tv:secret@localhost:3000 show 8d02
# 8d02…: can still pass, 1 more `true` passing it (3 of 4); true: tv, lass; false: nobody
# proposed by tv: version 2 on 1
# lets makefu in: 1 key (ssh-ed25519 SHA256:IDPEVCc1gUXL…); 1 node (continuum:e2a8f0c1d9b3…)
# adds rule 1: names/r/wiki -> lass
# who writes names/r/wiki: tv -> lass
vote says the same before it casts anything, then its warnings, and, on a terminal,
asks before it casts: answer y to cast, anything else to cast nothing. In a script,
with no terminal, it asks nothing.
A node's dashboard shows them so too, and where the node votes for its party by itself,
votes through it (dashboard.md,
Federation).
GET /events/{id} shows a proposing event, the version it proposes in proposal, and
a vote, signed by its party. A node lacking some votes reads a proposal as neither passed
nor dead where another reads it dead; no vote takes either back. A dead proposal stays
listed until a version passes on the current one, and a passed one is written at once;
then every proposal on the version before lapses. A party's client decides its votes by
the votes it checks itself, never by what a node says of them; the parties' records keep
their votes.
