coven_database/snapshot_reload.rs
1//! Authenticated inputs installed at one fixed store slot.
2use crate::{BoundaryCoverage, IncomingSlot, OperationUpdate, StoreState};
3use coven_format::admin::{SnapshotId, StoreChange};
4use coven_foundation::id_source::{DeviceId, MemberId, ObjectId};
5use coven_merge::{Audience, Slot};
6use std::collections::BTreeSet;
7
8/// One readable audience's starting prefix.
9pub enum SnapshotSource<R> {
10 /// A stored snapshot selected from authenticated history.
11 Stored {
12 /// Expected object identity.
13 id: SnapshotId,
14 /// Its staged records, from a body that authenticated (§16.2).
15 input: R,
16 /// Member whose key signed the body.
17 author: MemberId,
18 },
19 /// History starts empty after the slot given: slot zero, or a floor's `at`
20 /// for a circle the floor leaves unnamed because it holds no part (§16.4).
21 Empty(Audience, u64),
22 /// Preserve this audience's committed prefix and apply only subsequent slots.
23 Current(Audience),
24}
25/// Files retained by a loaded snapshot.
26pub struct LoadedSnapshot {
27 /// Snapshot identity.
28 pub id: SnapshotId,
29 /// Fixed file paths in its rows and losses.
30 pub files: BTreeSet<(DeviceId, ObjectId)>,
31}
32/// Complete checked input for an atomic reload. Sync derives the administrative
33/// projection from the original signed history carried by the store snapshot
34/// and retained slots. Each readable audience reaches `target` before commit.
35pub struct SnapshotReload<R, W> {
36 /// Starting snapshot or empty prefix for every readable audience.
37 pub snapshots: Vec<SnapshotSource<R>>,
38 /// Consecutive slots after the earliest snapshot through the fixed target.
39 pub slots: Vec<IncomingSlot<W>>,
40 /// Greatest selected coverage or required applied slot when loading began.
41 pub target: u64,
42 /// Authenticated membership and keys at the target.
43 pub state: StoreState,
44 /// Provider work required by the authenticated state at the fixed target.
45 pub provider_access: Vec<crate::ProviderAccessChange>,
46 /// Counted admin changes introducing cut-offs, including compacted history.
47 pub cutoffs: Vec<(Slot, StoreChange)>,
48 /// Activated schema and reset snapshot coverage at the target.
49 pub boundaries: Vec<BoundaryCoverage>,
50 /// Initiating operation's transition committed with the rows.
51 pub operation: Option<OperationUpdate>,
52 /// Audiences the slots made readable, or the floor holds, below this
53 /// device's breaking version, which have no start here: each is gated and
54 /// waits for its rebuild, with the device's migration marker queued for
55 /// it (§18.3). The slot beside each is the one its rows are counted
56 /// through: the coverage of the snapshot the load leaves unloaded.
57 pub rebuilds: Vec<(Audience, u64)>,
58 /// Authentication of other members' write evidence.
59 pub authorship: std::sync::Arc<dyn crate::Authorship>,
60}
61
62#[cfg(test)]
63#[path = "snapshot_reload_tests.rs"]
64pub(crate) mod tests;