diff options
| author | tv <tv@krebsco.de> | 2026-11-15 16:49:08 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-15 16:49:08 +0000 |
| commit | 90ad9e632520d3bbc22562c0fd4db2584ef2a92c (patch) | |
| tree | 64c48d846b7dabb42d3b6b3f1938a0c299f8ea58 /src/document | |
| parent | f751f411e954001c124afa1e3591d10094df15d7 (diff) | |
store: a signed value chosen by seq is named so
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".
Diffstat (limited to 'src/document')
| -rw-r--r-- | src/document/store.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/document/store.rs b/src/document/store.rs index 9afb5d3..bc50535 100644 --- a/src/document/store.rs +++ b/src/document/store.rs @@ -206,7 +206,7 @@ fn op_order(id: &ObjId) -> (u64, Option<&ActorId>) { enum Resolved { /// Concurrent maps presented as one. Newest first; `[0]` is canonical for writes. Maps(Vec<ObjId>), - /// Any other value: the newest concurrent candidate. + /// Any other value: the concurrent candidate a read shows (`candidates`). Other(Value<'static>, ObjId), } @@ -1222,8 +1222,7 @@ fn parent_for_write(doc: &mut impl Transactable, parents: &[String]) -> Result<P /// Adds `by` to the counter at `path`, creating one with `by` where there is nothing /// (in a map: a list's items are only incremented); returns its value then. Increments /// of one counter on several nodes add up, where writes of numbers would leave one. -/// Anything else there (the newest of concurrent values, as a read resolves them) is -/// `NotACounter`. +/// Anything else there (of concurrent values, the one a read shows) is `NotACounter`. pub(crate) fn increment_path( doc: &mut impl Transactable, path: &[String], @@ -1273,7 +1272,7 @@ fn counter_at(doc: &impl ReadDoc, parent: &ObjId, prop: Prop) -> Result<i64, Sto } } -/// Casts what is at `path` (the newest of concurrent values, as a read resolves them) to +/// Casts what is at `path` (of concurrent values, the one a read shows) to /// `to` (`typed::cast`, timestamps to and from strings in `timestamps`), written as a /// write of the cast value would be (`write_val_path`); returns where that changed the /// type. Already `to`: nothing changes. Nothing there: `NotFound`; no cast possible: @@ -1454,7 +1453,7 @@ pub(crate) fn delete_path_pruning( /// Copies the merged view of `src` into `dst` as fresh objects. /// /// * Conflicts collapse exactly as reads resolve them: concurrent maps merge, everything -/// else keeps the newest candidate. +/// else keeps the candidate a read shows (`candidates`). /// * Automerge types survive: text stays text, counters stay counters (normalized to /// their current value), bytes, timestamps and floats are copied bit-exact. /// * Map keys are visited in sorted order and list elements in order, so two documents @@ -1672,6 +1671,9 @@ fn scalar_to_json(scalar: ScalarValue, form: JsonForm) -> Result<JsonValue, Stor pub(crate) enum Resolution { MergedMaps, NewestWins, + /// A signed value, by its `seq`, where the policy asks for signed values + /// (`candidates`). + HighestSeq, } #[derive(Debug, Serialize)] @@ -1764,6 +1766,12 @@ impl ConflictLog { ancestor: self.in_ancestors, resolution: if merged { Resolution::MergedMaps + } else if all + .first() + .is_some_and(|(value, _)| signed_order(value).is_some()) + && signs_values(doc) + { + Resolution::HighestSeq } else { Resolution::NewestWins }, |
