aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation
Commit message (Collapse)AuthorAgeFilesLines
* node: votes it casts by itself, for its partytv21 hours1-6/+208
| | | | | | | | | | | | | | | | | | | | | | A node may vote and propose for its party by itself, by its operator's rules (`docs/federation.md`, Votes a node casts by itself; `federation::vote`): * `--store-vote-key`: the party's key it signs with, an OpenSSH private key file, one the party's version names, kept on the node; * `--store-vote-record`: its party's one record of its votes, which it votes by, written before each vote is sent, begun where there is none on the version current then; * `--store-follow`, `--store-follow-any`: the parties it follows, by default only on a version that only moves to a checkpoint; * `--store-propose-events`, `--store-propose-every`: when it proposes a checkpoint, once it holds so many events beyond its checkpoint, or so long after its store moved there; * `--store-held-for` (10 minutes): how long it holds an event before it holds it for a while, for the heads it proposes and the voters' rule. Its store keeps when, by the node's own clock, it took each event, and when it moved to its checkpoint. Whenever the worker reads the store, the node decides what to sign (`Holding::act`), records it, writes the record, offers it to its store, and puts it into the document (`held::write`). A vote by hand through the node, by the record and the voters' rule, is `Holding::vote_by_hand`.
* federation: what a node voting by itself decidestv21 hours2-0/+514
| | | | | | | | | | | | | | | | | | | | | | | | | A party may have one of its nodes vote and propose for it, by rules its operator sets (`docs/federation.md`, Votes a node casts by itself): `federation::vote::decide`, from the node's store, how long it held each event, and its party's record. * Following: `true` on a proposal on the current version where a party it follows voted `true`, `false` where one voted `false`; by default only on a version that only moves to a checkpoint, a `true` as a `false`. * Proposing a checkpoint: once so many events are held beyond its checkpoint, or so long after the store moved there, a version that only moves to a checkpoint at the heads of what it held for a while, at which the current version is current; only where nothing that can still pass is proposed on the current version, but a proposal it wouldn't back that nobody backs but its proposer. It backs what it proposes. It keeps to what a party's client keeps to (`Record::may_vote`), one `true` at a time; and by the voters' rule (`vote::backs_checkpoint`) backs a version naming a checkpoint only where it changes nothing of the current one but its number, what it changes and its checkpoint, and its heads leave out nothing it held for a while before it was proposed. A party that has a node vote by itself votes by hand only through that node, which keeps its one record: `vote::by_hand` decides such a vote by the record and, with a `true`, by the voters' rule.
* store: what heads leave outtv21 hours1-0/+41
| | | | | | | A voter backs a checkpoint only where everything it held for a while before it was proposed is among its heads, in their history, or above them (`docs/federation.md`, Checkpoints): `Store::left_out` names, of events a store took, those a checkpoint at given heads leaves out.
* docs: what of the federation is builttv22 hours1-3/+4
| | | | | | | The federation's design says what of it is built: the store in a swarm's document, members by the federation and the store at a node's API, as the store's design says; and a party's client, which signs its party's events, votes by its record, signs again what a move refused, and names a party that voted twice.
* continuum-party: a party's client of a federationtv22 hours2-0/+460
| | | | | | | | | | | | | | | | | | | | | | A second binary, behind the `federation` feature: a party's client, which signs its party's events with one of its keys (`--key`, an OpenSSH private key file), puts them through a node's API (`--node`, its user and password in the URL, or `--token`), and keeps its party's record (`--record`), by which it votes, written before a vote is sent (`federation::party`, run by `continuum::party`): * `init PARTY` begins a record of `PARTY` on the version current now; * `write PATH VALUE`, `keys KEY...`, `nodes NODE...` and `propose FILE` sign events on the node's heads, recorded, and put; * `vote PROPOSAL yes|no` votes on the proposal of that hash on the current version, by the record: with a `true`, the votes on its party's earlier proposal, from the node, checked, kept as the nays that freed it; * `again` signs again, of the latest event it signed at each place, its key set and its node list, what the node refuses as not above its checkpoint's heads, or as built on one it refuses; * `twice RECORD...` names, from the records of parties' clients, a party that voted twice. The feature brings reqwest along, the client's HTTP.
* federation: what a party's client decides bytv22 hours2-0/+639
| | | | | | | | | | | | | | | | | | | | A party's client signs its party's events with one of its keys, read from an OpenSSH private key file, unencrypted (`client::signing_key`), and keeps its party's record (`client::Record`): the votes it cast, each as signed, with the versions they are on; with each `true`, the votes that made its party's earlier proposal on that version dead, as signed; and the events it signed besides. The record begins on the version current then, and casts nothing on it; it is written whole or not at all. It votes by its record, never by what a node shows (`docs/federation.md`, Changing the policy): never `true` and `false` on one proposal, nor the same twice; a `true` only for a version changing the current one, and one at a time, its earlier `true` on a proposal the votes given make dead, each checked from itself and its version, which it keeps. It signs again, of the latest event it signed at each place, its key set and its node list, what a move refused (`Record::again`). And over the records parties' clients keep, it names a party that voted twice (`client::voted_twice`): its `true` and `false` on one proposal, or its `true` on two of one version, neither dead by all the votes. JSON is taken as the federation takes it (`client::json`).
* api: what counts names the proposals on the current version, and their votestv22 hours1-0/+49
| | | | | | | A party's client votes by the record it keeps, and keeps the votes that made its party's earlier proposal dead; it reads them from a node, and checks them itself, as each is signed. `GET /events/counts` names the proposals on the current version, by their hash, each with the events proposing it and the votes on it, by ID (`State::ballots`).
* federation: events made, as a party's client makes themtv22 hours2-48/+87
| | | | | | | What makes a signed event (`event::signed`) and what each does (`write`, `keys`, `nodes`, `proposal`, `vote`), and a version event (`event::version_event`), move from the tests' harness into `federation::event`, for a party's client to make them as the tests do: the harness makes its events through them.
* federation: events offered to a node's store, and its operator's dropstv22 hours2-2/+84
| | | | | | | | | | A node's store takes events from elsewhere than its document too: one put at its API is offered to it first (`Holding::offer`), to say what became of it. Its operator has it drop events it took after its checkpoint, with everything built on them (`Holding::drop_taken`), and takes them back (`Holding::allow`), the document's events then offered again (`docs/store.md`, A node's own). After each, what the node keeps of its own is written to its file where it changed, and the members are as the store reads now.
* topology: neighbours among the members of a node's own party, and of parties ↵tv23 hours1-0/+23
| | | | | | | | | | named A node of a swarm holding a store keeps some of its neighbours among the members of its own party and of the parties its operator names (`--store-neighbour-parties`), so that a party listing many nodes can't be all of them (`docs/store.md`, Members): its neighbours by the shared graph among those members alone, each as its entry names it, which every node of its party computes alike, with those among all members.
* peer: in a swarm holding a store, its members onlytv23 hours1-0/+23
| | | | | | | | | | | | A node of a swarm holding a store syncs with its members only (`docs/store.md`, Members): the nodes its store names, each with the party its handshakes name, as the store reads now. A handshake from any other goes unanswered, and what the node had with it ends, as with a banned node; so does what it had with a member at its next message, once the store names it no more (`swarm::peer::members`). The party a handshake names is kept with the peer. While a node holds no store yet, joining, it can't tell, and takes everyone of its swarm: its seeds, which take it only where its party lists it. A node says whether it is a member itself, as its store reads, when that changes.
* federation: the members a node's store namestv23 hours1-2/+34
| | | | | | | | The fold names the members, each with its group: for the federation, the nodes each party lists, each as its party's (`docs/store.md`, Members). A node keeps them as its store reads now, apart from the store, so that whoever asks doesn't wait while the store takes events: `Holding::member` tells whether a node, of a party, is one, or that the node holds no store and can't tell; `Holding::members` lists them.
* node: the party a node of a swarm holding a store is oftv23 hours1-9/+23
| | | | | | | | | A node's group is its operator's, in its configuration (`docs/store.md`, Members): `--store-party NAME`, which `--store-root` and `--store-id` need, a party's name as the federation spells one. The node keeps it with its store (`Holding::party`), to name it in its entry and its handshakes. The options of a node of a swarm holding a store (`--store-file`, `--store-checkpoint`, `--store-party`) set without either are refused together.
* federation: a pinned checkpoint, found in the documenttv24 hours1-12/+127
| | | | | | | | | | | Once a store moved to a checkpoint, a node reading it from the root could take what was grown anew from the root since, by keys of versions long replaced: so its operator pins the checkpoint (`--store-checkpoint`, by its ID), and the node reads its store from there whenever it starts (`docs/store.md`, Pinned checkpoints). It finds it in its document: at heads a proposal's version names, built from their history read from the root, as any node builds the checkpoint it moves to (`Store::checkpoint_at`), the one whose ID is pinned. Until the document holds it, the node holds no store, and says so once.
* store: the checkpoint at heads a store holds, as it builds one moving theretv24 hours1-10/+33
| | | | | | `checkpoint_at` builds the checkpoint at heads the store took, its bytes and the events it keeps, as the store does moving to a checkpoint, which now goes through it: so a node can build one at heads it reads, to tell whether it is the one its operator pins.
* federation: events put againtv24 hours1-7/+174
| | | | | | | | | | | | A node puts again, in changes of its own, every event its store holds that its document lacks (`docs/store.md`, What the store takes from the document): one it took from the document it left, at a drop or a rejoin, or from a change it refused, whose events the store is offered as from anywhere (`Holding::look`, every few seconds, of the changes screening keeps). It puts each after its dependencies, what the checkpoint keeps first, then what the store took after it in the order taken, up to 1 MiB of events a change, once a wait of its own has passed: random, between one and ten seconds after the document first lacked them, so that not every node puts the same, and none another node put meanwhile, as it looks again when it writes.
* federation: the store read from the documenttv24 hours2-0/+380
| | | | | | | | | | | | | | | | A node of a swarm holding a store holds the store, read from its document (`docs/store.md`, What the store takes from the document): `federation::held`. Whenever the document changes, a worker reads the events it holds that the store wasn't offered from it, under the document's lock, and offers them to the store without it, each taken as from anywhere: once its dependencies are held, judged at its history. Another document (a drop, a rejoin) is read as it comes, the store going on. The node reads its store anew from its document whenever it starts, from the root, by what is its own of it: the events it refused by what it took before, and those its operator had it drop, which it keeps in a file (`--store-file`), written whenever that changes, so that a store read anew in another order refuses what it refused before. A file that doesn't read stops the node from starting; without one, a restart may take what it refused.
* store: a store read anew refuses what its node refused of its owntv24 hours1-0/+54
| | | | | | | | A node refuses some events by what it took before (the federation: a second version changing the one it reads), and others as its operator has it drop them; read anew, its store would take events in another order, and so maybe the other one. `own` lists what the store refused so, and `refusing` has a store starting out refuse them from the start, whatever order the events then come in (`docs/store.md`, A node's own).
* store: a fold names itselftv24 hours3-0/+8
| | | | | | A swarm holding a store names its fold in its policy, `{"version": 2, "store": "<fold>"}`: the fold's name is a constant of the fold, `federation` for the federation and `test` for the fold made for the store's tests.
* federation: fixed bytes of events, versions, roots and sizestv25 hours2-0/+127
| | | | | | | | | | | Vectors (`docs/federation-tests.md`, Fixed bytes) for a write and its signature and ID, the first version of two parties and its hash, the root it makes and its ID, a version event, an event whose value holds names that UTF-16 units sort otherwise than bytes, and events at federation 1's sizes and just past them: 256 KiB, 32 segments of 255 bytes, 64 nodes, integers to 2⁵³. Each value was computed apart from this code, by a script of its own: JCS by hand, Ed25519 by another library, and the signature's blob as OpenSSH's `PROTOCOL.sshsig` describes it, as `ssh-keygen -Y sign` makes it. Checking one against `ssh-keygen` itself is left to whoever has it at hand.
* federation: properties over generated federationstv25 hours2-0/+576
| | | | | | | | | | | | | | | | | | | | | Three to five parties write in their namespaces, change their key sets and node lists, propose versions and checkpoints on what they last caught up with, vote, and write the versions that pass; honest ones back one proposal on a version, an adversary votes as it likes and signs as another party with its own key, or where it may not write. Over such histories: * the store judges every event, and reads, as the model does, offered the same events in the same order, with an adversary and without; * what builds on a refused event is refused; * honest parties read the same whatever order the events come in, checkpoints and all; * after a checkpoint, what the store took the model takes, reading the whole history but for what the store refused as not above it, and the two read the same; the version naming the checkpoint is taken; * every version a store takes was backed by two thirds of the parties of the version it changes, in its history; * without a party voting twice, no two versions change one. A failing history is cut down and printed.
* federation: the model, a second reading of the federationtv25 hours2-0/+532
| | | | | | | | | | | The model (`docs/federation-tests.md`, The harness) reads the federation as `docs/federation.md` says, as plainly as it can: every event judged at its history read anew from the root, the version current there the highest-numbered written one, keys, key sets, node lists, votes, passing and dead, version events and the heads a version may name each worked out from that history alone; a node's own, the first of two versions changing one; and what counts read from everything taken. It keeps nothing but which events it took, and makes no checkpoint: slow and short, it is what the fold is checked against. A test takes it through a version passing, offered last event first.
* federation: the JCS test asks escapes JCS doesn't write, as escapestv26 hours1-2/+4
| | | | | | Two of the strings `json_written_otherwise_is_none` takes for none, an escaped U+2028 and an escaped `A`, stood in the file as the characters themselves, which JCS writes as they are: the test took them for none, and they read. They are built as escapes now.
* federation: a test for each attack marked unittv26 hours2-0/+1184
| | | | | | | | | | | | | | | | Each row of `docs/federation.md`'s attacks marked unit that the fold and the store in memory answer has its test, named by its row (`federation_attack_12`), with events made for it by the harness: keys that aren't their party's, bytes that are none, events of another federation or a fork, writes where a party held or holds no place, key sets and keys stolen or dropped, votes cast twice, at once, split, or at a history from before, versions that are none or written again late, two versions changing one in every order, forks and roots, checkpoints, events not above their heads, and heads a version may not name. `every_row_marked_unit_has_its_test` reads the table and this file, and checks that every row marked unit has its test, or waits for a later stage (what a node, a party's client or a tool does, and what a node tells of a fork), and that no test names a row that isn't there.
* federation: the federation as the store's foldtv26 hours3-1/+947
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Federation` is the store's fold for `docs/federation.md`. The state judging reads is the state of an event's history, which the store builds from the checkpoint and that history alone; so the version current there is the state's, the highest-numbered one written, and a history holding two versions of one number is refused. * A signed event's party is a party of the version current at its history. A write is signed by a key among its party's (those of its key set that counts, else those its version names) where a rule gives its party the place; a key set, node list, proposal or vote by a key its version names. * A vote is on the version current at its history, for a proposal proposed on it; a `true` only where every other proposal its party backs on that version is dead. Passing and dead go by the parties voting each way, a party with both counting for both. * A version event writes a proposal on the version current at its history, passed there, which is a version changing that one; one naming a checkpoint names heads after the current checkpoint at which it is current too, none in another's history, the version event above them. A node keeps a version event only where it changes the version it reads, or writes one it took. * What counts is read by the current version: of each party's writes at a place it may write, signed by a key among its party's, and of its key sets and node lists written under a version at least their `since`, the latest, then the lowest ID. A checkpoint keeps what counts at its heads and the proposals and votes on the version current there; a fork's root what counts at its heads by its version; the members are the nodes each party's node list names. Tests take a federation through writes, a key set, a proposal passing, one yes at a time, two versions changing one, a checkpoint and a node starting from it, and a fork. Events are read with their signature checked once, where they are judged.
* federation: events and checkpoints as bytes, and a harness that signs themtv26 hours3-0/+610
| | | | | | | | | | | | | | `Event::read` reads an event and says what makes one none (`docs/federation.md`, Events): bytes that aren't the JCS of the JSON they read as, larger than 256 KiB, with no dependency or more than 64, not ascending, or a field missing or more; and of a signed event, a party that is no party's name, a key or signature that doesn't read back to itself or doesn't hold, a path, key set, node list or vote spelled otherwise. A proposal is taken whatever it holds, named by its hash; a version event names a hash. `Checkpoint` reads and writes `{"at", "keeps", "version"}`, a root among them, which is no event. The tests' harness (`docs/federation-tests.md`, The harness) makes parties with keys from seeds, signs each kind of event as the design says, and spells versions out.
* federation: versions, their rules, and the paths they matchtv26 hours2-0/+539
| | | | | | | | | | | | | | | `Version::read` reads a version by itself, and says what makes one none (`docs/federation.md`, The policy): a field missing or more but for `checkpoint`, another federation, a number and `changes` that don't go together, keys and node lists not of the same parties, a party's name, its keys (one to 16, spelled as keys, none twice in the version) and its node list (up to 64 node IDs, none twice), checkpoint heads, and rules (a literal first segment and not `_continuum`, `{party}` once at most, `**` last only, a writer that is a party of it, `"{party}"` where the path holds `{party}`, or `false`; a path as a write's may be). `changes_validly` asks whether it changes another: one past its number, its hash, and each `since` its own number or the other's with the same keys, or node list. `writer` gives who writes at a path, by the first rule that matches; `only_moves_on` whether it changes nothing but its number, what it changes and its checkpoint.
* federation: keys, node IDs and signatures, each spelled one waytv26 hours2-0/+148
| | | | | | | | | | | A key is `ssh-ed25519`, one space, and its base64, padded and canonical, with no comment, its 32 bytes an Ed25519 public key; a node ID is spelled as continuum spells it, its key one too; and a signature is the SSHSIG blob of version 1 for the namespace `continuum-federation`, hashed with `sha512`, its reserved field empty, its key the event's, in base64, padded and canonical, unarmored, checked by continuum's strict check (`access::sshsig::verify_blob`) and read back to what `ssh-keygen` writes around it. `keys::sign` makes one, for clients and tests. Tests show each spelled otherwise taken for none.
* federation: JSON written one waytv26 hours2-0/+452
| | | | | | | | | | An event is the JCS encoding (RFC 8785) of a JSON object, within the limits federation 1 sets (`docs/federation.md`, Events). `jcs::read` gives the JSON bytes are only where they are what JCS writes of it: names sorted by their UTF-16 units and none twice, no whitespace, strings escaped as ECMAScript escapes them; and, beyond JCS, numbers only integers from −2⁵³ to 2⁵³, strings only whole Unicode characters, and objects and arrays nested up to 32 deep. Tests show what reads back and what is none, the order of names by UTF-16 units that byte order gets wrong, and the depth.
* store: a fork refuses what the store it came from builds on what its root keepstv26 hours1-1/+2
| | | | | | | The test of forks expected an event the store it came from took after the fork's heads to wait in the fork, but it builds on the put the fork's root keeps, which comes before the root, its one head: the fork refuses it, not above its root, as it refuses an event built on what a checkpoint keeps.
* store: the fold says how large an event may be, and the document judges by ittv26 hours3-1/+14
| | | | | | | | The document took any bytes that hash to their key, while the fold bounds events (the federation: 256 KiB): one change of any size filled every node until the next remake. How large an event may be is a question of the change alone, so the fold says it (`Fold::LARGEST`), the document refuses a change putting a larger one, and the store takes such bytes as none.
* federation: groups that parted come together as parties come in, not by mergestv27 hours3-61/+27
| | | | | | | | | | | | | A merge, a fork at heads of several stores, named every party's keys anew, so that a party wrote its key set again before anything a key of its set signed counted there; and kept each side's values side by side, so that a value a party replaced on one side came back where the other side's write had the lower ID. Letting the other side's parties in, by a version or a fork naming them, who sign again what they keep as a party's client signs again what a move refused, does the same with nothing new. So a fork is at heads of one store: the fold makes its root from that store's state, and the store from its own heads (`Store::fork`). Merges' rows go, those after them move up, and Roads not taken says why, with merging in place.
* store: properties over generated historiestv27 hours3-0/+444
| | | | | | | | | | | | | | | | | | | | Two to four writers, each knowing what it wrote and what was written when it last caught up with the others, write the test fold's events on one or two events they know. Eras and cuts are numbered by their history, each number written once, or, for some properties, as often as it comes. A store offered them is checked against the whole history, read from the root with nothing forgotten: * it holds the same whatever order the events come in: every order putting each after what it builds on, for up to six events; some shuffled beyond; and backwards, where every event waits until the first comes; * it judges every event as the whole history does, the store's own refusals aside; * what builds on a refused event is refused; * what it took is above its checkpoint's heads, the cut naming the checkpoint among it, and it reads as its checkpoint and what it took, and as its whole history; * a node starting from its checkpoint holds what it holds. A failing history is cut down, events taken out with what builds on them for as long as it still fails, and printed.
* store: the test fold judges a cut by the checkpoint current at its historytv27 hours1-23/+83
| | | | | | | | | | | | | | | | A cut names heads above those the latest cut of its history names, and holding that cut, or, where its history holds none after the checkpoint the state starts from, heads after that checkpoint or its own; as federation.md has a version name heads after the checkpoint current at its history, at which that one is current too. It judged them by the checkpoint the store holds, which isn't the one current at the history of a cut taken in the same offer as the cut before it, before the store moves. A cut is above its heads as store.md says, each of its dependencies one of them or above them, so that moving to them refuses none of what named them. Of a checkpoint's heads, whose history a state starting from it doesn't hold, it takes none as built on another, nor on what the checkpoint keeps: starting from a checkpoint at two heads, one of them kept, it took the other as built on it, and refused the cut naming them.
* store: what is above some heads names nothing before themtv27 hours1-0/+9
| | | | | | | | | An event above some heads has each of its dependencies among them or above them, not only them all in its history. The store holds after its checkpoint only events whose dependencies are its heads and the events after them, and so it holds every event above them: one naming an event before them as well is refused by a node that moved, and never taken by one starting from the checkpoint, which never held what it names. Tests show it for an event offered after the move and one taken before it.
* store: forks and mergestv27 hours1-0/+87
| | | | | | | | The fold makes a fork's root from the states at heads of one store, or of several, which merges them, and what makes the fork; the store gives it the states, and the events the root keeps, from the stores holding them. A node holding those heads checks a root by building it. A fork and the stores it came from take nothing of each other: what each writes after builds on what the other doesn't hold.
* store: moving to a checkpoint, and starting from a pinned onetv27 hours2-8/+235
| | | | | | | | | | | | | Once the fold names heads of a later checkpoint (events after the store's, none in another's history), the store builds the checkpoint at them, keeps what the fold keeps, forgets what came before them, and refuses every event not above them, with what waits on such an event. What it forgot is held as accounted for: brought again, it is held, and an event built on it isn't above the heads. A store starts from a checkpoint its operator pins, its events building on the heads the checkpoint was built at. A node starting from a checkpoint must judge the event that named it as every node does; the fold for the tests counts the heads of the checkpoint a state starts from as after the checkpoint current at them, so that it does.
* store: a node's own refusals, and its operator's dropstv27 hours1-0/+126
| | | | | | | | | | Where its history takes an event but the fold has the node refuse it by what it took before (the federation's second version changing one), the store refuses it as its own. An operator may have the node drop events taken after its checkpoint, with everything built on them, and refuse them from then on; what the checkpoint keeps, or holds by ID, isn't dropped, as every event after it builds on that. The operator takes either back by allowing it, and what was refused for being built on it, to be offered again. The fold for the tests shows both with its eras.
* store: a store held in memory, and a fold for its teststv27 hours3-0/+803
| | | | | | | | | | | | | | | A store starts from its root, with the events the root keeps, and holds the events taken after it. An event offered is taken once the store holds its dependencies, where it is above the store's heads (built on an event after them, or on all of them) and the fold takes it at its history: the state its history reads as, folded from the checkpoint. An event waits for what it builds on, and is taken when that comes; one built on a refused event, or whose bytes are none of the fold's, is refused, with what waits for it. The fold made for the tests judges by history (a put refused where its key is locked), reads by what counts (a key's latest put, then the lowest ID), refuses by what a node took before (two eras of one number), and moves to checkpoints (cuts), as the federation does, so that the later stages' tests have something to exercise.
* federation: the feature, and the store's foldtv27 hours2-0/+129
`federation`, a feature of its own, builds what `docs/federation.md` and `docs/store.md` design, stage by stage; without it continuum builds and behaves as it does. The aliases build with it, and `docs/development.md` says so. Its first part is the store's: an event's ID, the SHA-256 of its bytes written as 64 lower-case hex digits and read back only so, and the `Fold` trait as `docs/store.md` gives it. The trait reads a checkpoint's parts too, the heads it was built at and the events it keeps, which a node taking a pinned checkpoint needs; the design names it. Nothing uses either yet, but a test.