| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
| |
The same events put by the same writer make the same change, so that a
document built of them in a test is the same bytes on every run.
|
| |
|
|
|
|
|
|
|
|
|
| |
A compaction's snapshot in a swarm holding a store holds the store as the
node reads it from the document at the base, by its own refusals and its
operator's drops (`docs/store.md`, Remakes): the checkpoint it reaches
there, where it isn't the root, at `_continuum/checkpoint`; the root, the
events that checkpoint keeps and those after it, each at its ID; and of the
entries, the members'. What the checkpoint forgot, events nobody takes, and
the entries of nodes that aren't members stay behind (`Holding::at_base`,
`events::snapshot`, `Host::holding`).
|
| |
|
|
|
|
|
|
| |
A remake's snapshot holds the store's checkpoint at `_continuum/checkpoint`
where it isn't the root (`docs/store.md`, What the document holds), and
none of what came before it. A node reading its store anew from such a
document starts there, with what the checkpoint keeps; one pinning a
checkpoint finds it there too, where it can't build it from the events.
|
| |
|
|
|
|
|
| |
Automerge encodes the hashes of a sync message sorted, and asserts so: the
hashes asked for that changes waiting in screening lack were added after
those Automerge asks for, unsorted, and the heads a peer last said that we
hold were taken as the peer's `have` as they came. Both are sorted now.
|
| |
|
|
|
|
|
|
|
|
|
| |
Messages taken as delivered and lost, more of them than still count as
sent, leave a peer lacking changes we take it to have. Asking for the
first of them, it got that one alone, and asked for the next once that
arrived, a change per round trip; or, asking for our heads alone, the last
of them again and again. When a peer needs a change in the history of the
heads we share that no longer counts as sent, the session answers as if
it had said it has nothing since the latest heads it said that we hold
(`lost_beyond_sent`): everything since goes in one message.
|
| |
|
|
|
|
|
|
|
|
| |
Screening keeps a change whose dependencies haven't come from Automerge,
waiting, so Automerge never learns what it lacks: our next message asks for
the peer's heads alone, and the peer, forgetting having sent those, sends
them again, and what they build on only as far as it still counts it as
sent. So the session asks for what changes waiting build on and the
document lacks too (`Waiting::lacking`, `SyncSession::lacks`), as Automerge
asks for what the changes it holds back lack.
|
| |
|
|
|
|
|
|
|
|
|
| |
for byte
A change of a swarm holding a store naming no node is taken where it is one of those
founding the swarm (`events::is_founding`): built from the root its document holds and
the events the root keeps, those at its history and those it puts, by the fold
(`access::holding`). A change of the genesis change's writer waits for no signature,
as every node builds it and nobody signs it (`screen::built_by_every_node`); judged, it
is refused unless it is one of them.
|
| |
|
|
|
|
|
|
|
|
|
| |
it keeps
A fork's root keeps events (`docs/store.md`, On Automerge): they follow its genesis
change in changes of the same writer, built the same way, filled in the order of their
IDs, events going into a change until their bytes there reach 1 MiB, the next event
beginning the next change (`events::founding`). A swarm holding a store starts from all
of them (`events::started`, given the events the root keeps; none for a federation's
root).
|
| |
|
|
|
|
|
|
|
| |
Each row of `docs/store.md`, Attacks, marked unit has its test,
`store_attack_<row>`: where it is judged (`access::holding`, `access::token`), where
the store held in memory meets it (`federation::store::memory`), and where a node reads
its store from its document (`federation::held`). Tests that checked a row already take
its name; a check reads the doc's rows and fails on a unit row without its test, but for
rows 21 and 22, which the remakes bring.
|
| |
|
|
|
|
| |
Automerge writes no put of the value a key holds already, so the test can't have a node
write one: it judges such a change made by hand, a put of the event's bytes at its key,
at a history holding it.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Every node judges a change of a swarm holding a store by what it writes, at its history
(`docs/store.md`, What a change writes), in place of rules by path: `access::holding`.
It writes events, each at `_continuum/events/<ID>` the bytes whose SHA-256 that is, no
larger than the fold allows (the federation's 256 KiB), at a key held nowhere at the
change's history; and its node's entry, with the member list's map where there is none.
Everything else is refused, as closed: values outside `_continuum`, the policy, the
swarm's ID, users, bans, the topology, remakes and their acks. Nothing deletes or
replaces an event. A change names its node; the genesis change's writer names none, so
no change under it is taken but the genesis change.
In a swarm not holding a store, a change writing a policy naming one is refused: a swarm
holds a store from its genesis change, or not at all.
The inspector tells a put of bytes apart (`Action::PutBytes`), with the bytes, for the
events' check. All of it behind the `federation` feature.
|
| |
|
|
|
|
|
|
|
|
|
| |
`{"version": 2, "store": "<fold>"}` at the policy's place is a swarm holding a store of
that fold (`docs/store.md`, What the document holds). Behind the `federation` feature, a
node reads it as `Policy::Store` where the fold is one it has (`federation`) and nothing
else is written there: changes judged, and signed, as required; not strict. Its `store`
reads so only where it is a string, as `values` of a strict policy. A swarm holds a store
from its genesis change only, so `--bootstrap-policy` takes none.
Without the feature, a policy of version 2 stays one the node doesn't know.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
A swarm holding a store starts from its genesis change, which every node builds from the
store's root alike, so that one root makes one swarm (`docs/store.md`, What the document
holds). `document::events` builds it: it writes the policy naming the fold, the swarm's
ID (the root's) and the root at its ID, as bytes, each making the maps on its way, under
the writer made of the root ID's first 16 bytes, at time 0, without a message.
`is_genesis` tells such a change by building it again from the root it holds; `started`
is a document holding it, written to under a writer of its own; `ids` and `bytes` read
the events a document holds at `_continuum/events`. All of it behind the `federation`
feature.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A node judges what it receives once anything is at the policy's place
(`Screening::policed`), as a read shows it. But a read shows the newest
of the values written at once at a key, merging maps only where that one
is a map: a string written at `_continuum/access` beside the map holding
the policy, and newer, hides it. So the policy's place read as empty,
a change putting `"signed"` into the hidden policy went unjudged where
it came alone, and deleting the string left a strict policy no change
was refused for.
Whether anything is at the policy's place is asked of every map of each
key on the way to it, read or not (`store::held_anywhere`), as
`store::by_seq` walks them. A swarm with nothing there is screened as
before.
|
| |
|
|
|
|
|
| |
`signs_values` marks, for its thread, that the policy is being read, so
that the reading doesn't ask itself again; a panic within it left the
mark, and that thread read every strict place by Automerge's order from
then on. The mark is now taken off when the reading returns or unwinds.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A swarm turns strict only at its start or through a strict remake, and
a change writing a strict policy where the policy isn't strict is
refused, found by its operations: `"signed"` put at the policy's
`values`, or an envelope asking for it put at its place. But the policy
was read in plain JSON, where an Automerge text reads as a string, and
writing a text is no such operation: `{"$text": "signed"}` at `values`,
through the typed API, turned a swarm strict that nothing refused, with
a time before it nothing closes.
The policy is read in typed JSON now (`store::read_plain_as`): what
continuum writes there reads as it is, plain JSON or an envelope, and a
text, a counter or bytes as itself, tagged; a setting that isn't a
string makes a policy no node knows (`policy::read`), as a version it
doesn't know does. So no text turns a swarm strict, and the operations
`rules::turns_strict` asks of are the only ways to. A policy holding none of these reads
as before.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A strict policy written into a running swarm left a time before it:
changes written there, beside the turn, were refused by the nodes that
took the turn first and taken by the others where they came first (a
signed policy that isn't strict, among them, unseated the turn there);
and a remake whose base preceded the turn had every switching node
replay the turn as one of its own, each refusing the others'.
A change writing a strict policy where the policy at its history isn't
strict (`"signed"` at its `values`, or an envelope there asking for
signed values) is now refused, in every swarm. A swarm turns strict at
its start (`--bootstrap-policy`) or through a strict remake, each its
epoch's first change: no change of a strict epoch is from before its
policy, and the rule for the time before goes, with the walk that found
the changes that turned a swarm strict and what kept them
(`before_strict`, `turned_strict`, `Reads::strict_now`,
`Reads::turned_now`, `store::writers`, `store::made`,
`changes::in_history`). The strict swarm's simulation starts strict.
access.md says so, and that a strict swarm can't move to a policy its
nodes don't know by writing it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Whether values are ordered by `seq` (`signs_values`) read the policy's
place itself, the first value alone and a map by Automerge's choice of
each field, while the policy as judged (`policy::of`) read it through
the store, which orders by `seq` only where `signs_values` says so, and
merges every map there. They parted: a signed policy that isn't strict
beside a newer plain one that is read as not strict for the one and
strict for the other, and two maps, the newer without the field asking
for signed values, the other way round.
`signs_values` now asks `policy::of`, and the store orders the policy's
own place by `seq` wherever any value there asks for signed values, and
what is within the policy as written, so the two are one reading.
Asked from within that reading, it answers false rather than ask again.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Every change judged under a policy that isn't strict, in a strict
document, walked back to the changes that turned it strict, each step
reading every change the document holds. Only changes from the time
before reach it in an honest swarm, but a member can send crafted ones
at an old history, each costing every node a walk.
The changes are now read once per walk (`store::made`), and what the
walk finds is kept for the document's heads (`Reads::turned_now`), as
whether its policy is strict is.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Whether values are read by `seq` went by whether any value at the
policy's place asks for signed values, not by what the policy reads as.
Where the place holds two, they part: a signed policy that isn't strict
read before a plain one that is, or two maps, the newer not strict. Such
a swarm judged as not strict and read by `seq`.
Now the policy's own place is read by `seq` where any value there asks
for signed values, so an older policy put back beside a strict one
can't undo it; every other place is read by `seq` only where the policy
that read shows is strict (`policy::read`, which `policy::of` reads
with). A swarm whose policy doesn't read as strict reads every place as
Automerge has it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A change written under a policy that isn't strict was refused, in a
strict document, unless it was in the history of the change that wrote
the policy value the document read now. So the policy written again by
a node that held a change from before, taken beside the strict policy,
put that change in the new writer's history: that node kept it, every
other node refused it, and the new policy with it, and the node was cut
off.
Now the reference is the change that turned the swarm strict: one that
wrote a strict policy where the policy at its history wasn't, found by
following back the writes of what the policy holds
(`store::writers`). A change written under a policy that isn't strict is
refused where such a change is beside it, neither in its history nor
built on it. A policy written again, strict over strict, names the same
change.
One turning the swarm strict beside it is refused like any other. Of
two at once neither is preferred: any rule choosing one, the lower hash
say, would let a change made later to look as old take the place of the
one every node took, and every node would drop it with all that was
built on it. So two members turning a swarm strict at once split the
nodes that took one from those that took the other; access.md says to
turn it from one.
|
| |
|
|
|
|
|
|
| |
Where the policy asks for signed values, a place's value is chosen by
`seq`, but conflict reports still called the choice `newestWins`, and
the code and the architecture still said "newest" of what a read
shows. A report names it `highestSeq`; the rest says "the one a read
shows".
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A swarm turned strict by writing the policy into it kept the time
before open: a change whose history lacks the policy's change is
judged by the policy then, none or one that isn't strict, needs no
signature there, and is taken whenever it comes, from any member. With
values read by `seq`, an envelope planted at that time with the
highest `seq` there is can never be followed: a ban, a user, a
declaration, for good.
Once a document's policy is strict, a change written under one that
isn't is refused, received or held, unless it is in the history of the
change that wrote the policy the document reads (`store::written_by`).
A node that holds one beside that change, taken before it came, is
told so by any peer that refused it (REFUSALS), judges it again, now
refuses it too, and drops it with what builds on it, as for any change
it took unjudged. A swarm strict from its genesis change has no such
time; one whose policy isn't strict judges as before.
|
| |
|
|
|
|
|
|
|
|
| |
Where the policy asks for signed values, a place's value is chosen by
`seq`, but two readers still took Automerge's own choice: an increment
found the counter beside an envelope a read showed (answering the
counter), and `inspect::placed`, which the API's checks go by, walked
through whatever Automerge chose. Both now take the value a read shows
(`store::shown`). A list's items keep Automerge's choice, as before:
no signed value is one, and reading a list whole goes by it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The order by `seq` sat in `store::candidates`, which every swarm reads
through: in a swarm that isn't strict, a string shaped like an
envelope, written at the same time as a plain value or a map, was read
first. What a swarm without a strict policy reads must not change for
signed values.
The order now applies only where the policy asks for signed values
(`"values": "signed"`), as any value at the policy's place says, read
as written (`signs_values`), so the policy's own reading doesn't go
round. Elsewhere `candidates` is newest first, as always. It is looked
at only where a place holds several values and one is an envelope.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Three parts read an envelope three ways: the store's order took any
string with the prefix whose meta held a `seq`, its reads any whose
value decoded, the checks only one with four parts and a meta of
exactly its fields. A string that the first two took and the checks
refused was read first, read as the registry's or the policy's value,
and treated as nothing by the check of the next write there.
`document::signed` reads an envelope the one way: four parts, the
value JSON, the meta exactly its six fields (one more, or one twice,
and it isn't one), no newline in either, the signature decoding. The
store's order, its plain reads, the checks, the API and the users API
all go by it. What isn't one in every respect is a plain string,
wherever it is read.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A member could put a user's older signed value back beside a newer
one: a change made with dependencies from before both is judged where
the place was empty, so the older envelope (`prev` empty) is taken;
and of values written at once, the one read was the one with the
highest operation, which whoever writes the change steers. A revoked
capability, a lifted ban or an earlier policy came back that way,
signed by whoever signed it then.
An envelope is now `cv2.<value>.<meta>.<signature>`: the value as its
user wrote it, and apart from it what continuum adds (swarm, path,
user, at, seq, prev), the signature over the value's line and the
meta's. `seq` is one more than that of the envelope it replaces, 0
where it replaces none; every node checks it with `prev`.
Of the values a place holds, written at once, signed ones are read
before any other, the highest `seq` first, of equal ones the lower
digest (`store::candidates`): reads, snapshots and writes all go by
it. An older envelope beside a newer one changes nothing.
`application/continuum-signed` is the value's line, the meta's, then
the signature; `scripts/continuum-signed` writes and checks it so.
The wire version goes up: nodes must agree on what a place's value is.
|
| |
|
|
|
| |
`no_mark` typed at 0 to 4 into a text of three characters: splicing at 4
is past its end. It types at 0 to 3.
|
| |
|
|
|
|
|
|
|
|
|
| |
Screening asked of every operation naming an element that the element was
inserted as a value or an object, inserting or not. In a document that
took a mark before marks were refused, a transaction typing right after it
inserts after the mark's begin or end, and was refused: every node refused
the change of the node that typed, and all it wrote after.
An element is written at only where a value or an object was put; an
insert may follow any element of that list, as transactions insert.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Twice, crafting changes by hand missed some that pass screening's checks
and break Automerge; a program generating them found three more kinds.
This test does the same: on documents three honest writers wrote at once
(maps, a list, a text, a counter), changes of one to four operations of
every kind, at random places, naming as replaced nothing, what is there,
or any operation. Each that passes the checks is applied, given back by
its hash, saved and loaded, taken by a peer that lacks it, written after
by an honest node, and saved and loaded again; nothing of that may fail
or panic. The run is seeded, the seed named where it fails, and
CHANGES_GENERATED sets how many documents (60 by default) for a longer
run.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Screening took marks in a text, checking that a mark's end comes at its
begin or after it, by walking the elements each is inserted after back to
the text's head: up to 22 s for one change of 9 KB. And it took a value
put at a mark's begin or end, replacing it: sound until an honest node
edits that text, then the node panics at its next sync or append, and its
save doesn't load.
Continuum's store writes no marks. A change with a mark's begin or end is
now refused, and the walk is gone. An element written at is one a value
or an object was inserted as.
|
| |
|
|
|
|
|
|
|
|
| |
Screening took a table for a map. A table made is sound, but Automerge
panics applying a change that puts a value into one, made by that change
or a later one, and applying isn't caught where it panics. Transactions
make a table and can't write into it; continuum's store makes none.
A change making a table is refused, and so is one writing into a table
the document holds.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Screening took as replaced any operation made at that object and key
without inserting: a deletion, an increment, a mark. A transaction names
only what holds a value there: a counter incremented and put over names
its put alone, a key put again after its deletion names nothing.
Automerge takes a value put again naming its deletion, at a map's key or
a list's element, and then gives back another change under its hash: a
save that doesn't load, a sync that fails. A deletion naming a deletion
panics as it is given back. An increment naming a deletion does the
same as a put.
What an operation names as replaced now put a value or made an object.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Screening asked what an operation isn't: a deletion replacing nothing, a
value put at a list's head without inserting, a mark ended but right after
its begin. Others pass that Automerge's transactions never write, and
Automerge takes them and breaks: an element written over naming as replaced
the element inserted after it (an inserted element's key is the element it
follows, its place is itself), an insert replacing something, a deletion or
an increment inserted, an increment at a list's head, a mark ended ahead of
its begin or at the head, a mark in a list. Giving such a change back
panics or gives another change under its hash, and the save doesn't load.
Each operation is now asked to be one transactions write
(`document::changes::unwritten`): inserted, a value, an object or a mark's
begin or end into a list or a text, replacing nothing; at a list's element,
never its head, without inserting, replacing what is at that element; at a
map's key, never inserted, a deletion or an increment replacing something;
a mark's begin with its end as the next operation, both inserted. A value
replaced at a list's element is the element itself or written at it, not an
element inserted after it. Marks are only in a text, and a mark's end is at
its begin or at an element after the begin's: their places follow from the
elements each is inserted after, back to the text's head, as the change's
history holds them.
The document the tests write now has counters in a list and a map, an
element written over, and marks over a span, the whole text, none of it, and
across what was deleted and inserted since; and each case above is a test.
|
| |
|
|
|
|
|
|
|
| |
`what_transactions_never_write_is_refused` checked changes built on
the insert against a document without the deletion the insert builds
on. Such a change isn't ready, and nothing is asked of it: the honest
insert passed for that reason, and the two crafted from it weren't
refused. Each is checked now against a document that holds what it
builds on.
|
| |
|
|
|
|
|
|
|
|
|
| |
Automerge 0.12.0 takes some changes that name nothing wrong, and then
can't give them back: a deletion that replaces nothing, a value put
at a list's head without being inserted, a mark ended where no mark
began right before it. Giving the change back panics, the save
doesn't load, and a sync to a peer that lacks it panics: one member
stops every node it reaches.
Those are refused with the other checks (`changes::Written`).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Screening checks that a change is one Automerge writes
(`changes::Written`) before it looks for forks and judges the rules,
and the checks recorded what a change made as soon as it passed them.
A fork of a change the document holds has its actor and counters: if
it was checked first in a batch, and refused as forged after, its
record stood in for that change's operations, outside the history of
the next. An honest change writing into what the real one made was
then refused, for good. Anyone could make such a fork, its hash
ground to sort first.
What a change made is recorded once screening takes it
(`Written::taken`), and an operation named is looked for in the batch
and in the document, whichever the change's history holds.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
A node switched to a fresh actor whenever a peer showed it a change of
its own actor that it didn't hold, signed or not. So any peer made a
node start a writer at will, by sending a copy of its last change with
another value: and every writer costs every node memory in proportion
to the document's history.
Copies of a node's data directory hold its key, and sign their
changes with it; a stranger can't. A twin switches the node only where
a signature by the node's own key of it is kept or waiting. Unsigned,
it is refused as forged as before, and nothing switches.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A change is refused before Automerge sees it unless it is one
Automerge writes (`document::changes::Written`). Three things about
that, each of which let a crafted change through or parted nodes:
* An operation a change names (the object written into, a list's
element, an operation replaced) must be made in the change's own
history, or before in the change itself, not anywhere in the
document. Else a node that holds the operation takes the change and
one that doesn't yet refuses it for good: nodes part by the order
changes reach them.
* And it must be what it is named as: an object of the kind written
into, an element of that list, an operation at the place written.
A change that replaces an operation elsewhere marks an unrelated
value gone, and Automerge then gives back another change under its
hash and saves a document that doesn't load; one that writes into
an operation that made no object makes it panic.
* A change that isn't its actor's first must have the one before it
among its dependencies, as a transaction puts it there. A gap in an
actor's numbers makes Automerge panic.
What the document holds at the changes this one builds on is read
there where it can be (a map's key, an object held by a map's key);
else the operation's own change is decoded and the history walked
back to it, no further than the operation's counter. So operations on
a list's elements cost a walk each.
Decoding a change can panic too (an operation naming an actor its
change doesn't list): caught, and the change refused as one whose
bytes aren't Automerge's.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Automerge 0.12.0 applies a change that lists an actor none of its
operations names, or whose first operation is numbered below its
dependencies' or near 2^32. It then gives back another change than
the one it was given and saves a document that doesn't load, or
panics at the next write. A member sending one stops the nodes that
take it.
Every change from elsewhere is looked at before Automerge sees it
(`document::changes::Written`, from `access::screen::apply`, with or
without a policy), and refused like one breaking a rule unless:
* encoded again, it has the hash it came with;
* its first operation is numbered one after the highest of its
dependencies, 1 without any, as a transaction at the document's
heads numbers it;
* every operation it names (an object, a list's element, an
operation replaced) is its own, or was made before it, in the
document or by a change of the batch looked at before.
|
| |
|
|
|
|
|
|
|
|
| |
The document file's first line names its format; each record's first
byte its kind. A version that doesn't know a kind refuses the file, as
it does a format it doesn't know. With the Closed and Opened records,
the format is continuum-document/3, so a version knowing only 2 refuses
a file it can't read by its first line. Files of 2 are read as of 3:
the same records, Closed and Opened where a version knowing them wrote
them.
|
| |
|
|
|
|
|
|
|
|
|
| |
The document file's format names itself in its first line
(continuum-document/2) and each record's kind in its first byte. A
record of a kind the reading version doesn't know makes the file
unusable: the node doesn't start on it unless told to move it aside
(--force badDocumentFile). lifecycle.md says so: a file one version
wrote is read only by versions knowing every kind of record in it. The
format's comment names the Opened record a node appends as it starts on
the file, which undoes the clean stop's mark.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A node receiving a change of the actor it writes as, one it doesn't
hold, writes on as a fresh actor (another node writes as it, from a copy
of its files). Where the other node made it at a seq this node made a
change at too, the change was taken to Automerge, which refuses the
whole batch (duplicate seq): the message failed, and with it everything
else it carried. Signatures::forks found it forged only where a
signature verified a change of the actor at that seq, and this node
signs its own latest change only as it sends it.
forks now also finds a change forged where its actor is the one the
document writes as and the document's latest change of it
(get_last_local_change) is at its seq or later. apply_bytes switches to
the fresh actor after judging the batch, not before, so the check still
sees the actor; also where judging fails.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A received signature of a change the document doesn't hold yet waits for
it (Pending), checked once the change comes. A delta's signatures come
before its changes, so they wait for the whole download. Kept one per
change, the last that came, a member could send a signature that
doesn't verify for a change it knows is on its way and put the honest
one aside: the writer then went unvouched for until its changes came
again with their signatures.
Pending now keeps up to three different signatures of a change
(CANDIDATES): the first that came, and the latest others. Ed25519
signatures are deterministic, so every honest copy is the same bytes and
counts once: one sent first stays, one sent after stays unless more
others follow it. Once the change comes, offer and vouch_batch check
them in turn, the first that came first, up to the first valid one,
within the bound on invalid signatures (MAX_INVALID). MAX_PENDING counts
signatures, not changes.
|
| |
|
|
|
|
|
|
|
|
|
| |
Received signatures of changes the document doesn't hold yet wait for
them, up to 65536 (MAX_PENDING). Each Signatures::offer, one per
received sync message, looked up every waiting one's change to find
those that came meanwhile.
The pending signatures now remember the document's heads at the last
look (Pending::scanned, Pending::arrived): while they stand, the
document holds nothing more, as it only grows, and offer looks up none.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A sync message carries up to 65536 signatures (MAX_PER_MESSAGE), and the
receiver checks, under the document's write lock, each one of a held
change that would vouch for more of its actor's changes than the one
before: about 30 µs each. A member sending that many signatures that
don't verify cost the receiver about two seconds of writes per message.
Signatures::offer and vouch_batch now stop checking after 64 found
invalid (MAX_INVALID) and drop the rest unchecked, with a warning. A node
forwards only signatures it verified, so an honest peer sends none.
offer counts those a message brings apart from those that waited for
their changes, which came from any peer. Signatures::vouch says which it
found (Vouched): more vouched for, nothing more, or invalid.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
At start, a node on a document file appends an Opened record before it
writes anything, so that a Closed record before it no longer says the
file holds every change of the actor it names. It does so now before
deciding which actor to write as, and DocumentFile::open says whether it
could: where the append fails (the disk full, permissions), the file
still ends with Closed, and later appends likely fail too. A crash, or a
clean stop whose last append failed (close then sees the file behind and
writes no mark), would leave that Closed standing for a run the file
never got. So with --keep-actor, the node writes on as the actor of
before only where the file was marked as opened; else it writes as a
fresh actor and warns.
|
| |
|
|
|
|
|
|
|
|
|
| |
How many writers (Automerge actors) the document's changes have matters: a writer is a
node's run (each start, rejoin or drop makes one, a start keeping the one of before with
`--keep-actor` after a clean stop), and every transfer of the whole history carries a
signature for each. `/admin/stats` now says it (`document.writers`, and
`document_writers` for Prometheus), counted from the changes' metadata alongside the
saved size's measurement in the background (at least a minute apart), as that takes
time proportional to the document too; an export, which measures the size alone, keeps
the count of before. The dashboard's figures show it with the rest.
|