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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright 2023 Developers of the reconcile project.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Provides the [`Reconcilable`] trait.
use Hash;
use DeserializeOwned;
use ;
use crateTimestamp;
/// Values stored in a map to be synced by the [`ReconcileStore`](crate::reconcile_store::ReconcileStore)
/// have to be [`Reconcilable`] to ensure safe conflict handling.
/// Last-write-wins keyed on a [`Timestamp`].
///
/// Because [`Timestamp`] is a **total order** `(wall_ms, counter, node_id)`, `reconcile` is `max`
/// over that order: it is commutative, associative and idempotent, so every replica
/// converges to the same value (Strong Eventual Consistency). Two *distinct* writes can
/// never share a `Timestamp` (the same node bumps the counter, different nodes differ on
/// `node_id`), so the equal-timestamp branch only fires for identical values. See the
/// [`clock`](crate::clock) module for why the previous physical-clock scheme was unsafe.
/// Marks values that may represent a deletion (a *tombstone*).
///
/// The reconciliation engine uses this to decide which applied updates require
/// causal-stability tracking before the corresponding key can be garbage-collected.
/// See the tombstone-resurrection discussion on
/// [`ReconcileStore`](crate::reconcile_store::ReconcileStore).
/// A timestamp-less projection of a value, used by lightweight read-only mirrors
/// ([`ReconcileMirror`](crate::mirror::ReconcileMirror)) and by the value-only
/// *projection* tree a dated store maintains to answer them.
///
/// Its [`Hash`] is **value-only by construction**: it wraps just the [`Option<V>`] payload, with no
/// [`Timestamp`], so two replicas that agree on the logical value compute the *same* per-element
/// fingerprint regardless of when (or on which node) each last wrote it. A live value is
/// `ValueOnly(Some(v))`; a tombstone is `ValueOnly(None)`.
///
/// This is deliberately a *separate* type from the dated `(Timestamp, Option<V>)`: the dated value keeps
/// its timestamp-inclusive `Hash` (required by the engine's `version_hash` for the
/// causal-stability acks), so a single value-only hash never replaces it.
;
/// A dated value that can be projected to its timestamp-less [`ValueOnly`] form.
///
/// The dated store maintains a parallel value-only *projection* tree so it can reconcile with
/// dateless mirrors over the existing range-diff protocol without exposing timestamps. The
/// projection is kept in sync wherever the dated map mutates (insert, reconcile, GC removal).
///
/// The associated [`Projected`](Projectable::Projected) type carries exactly the bounds the
/// projection tree and the value-only wire channel need, so the reconciliation engine only has to
/// add a single `Projectable` bound. Note it deliberately does **not** require `PartialEq`: the
/// value-only path decides equality on fingerprints, never on the projected values themselves.