Skip to main content

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 at slot zero.
20    Empty(Audience),
21    /// Preserve this audience's committed prefix and apply only subsequent slots.
22    Current(Audience),
23}
24/// Files retained by a loaded snapshot.
25pub struct LoadedSnapshot {
26    /// Snapshot identity.
27    pub id: SnapshotId,
28    /// Fixed file paths in its rows and losses.
29    pub files: BTreeSet<(DeviceId, ObjectId)>,
30}
31/// Complete checked input for an atomic reload. Sync derives the administrative
32/// projection from the original signed history carried by the store snapshot
33/// and retained slots. Each readable audience reaches `target` before commit.
34pub struct SnapshotReload<R, W> {
35    /// Starting snapshot or empty prefix for every readable audience.
36    pub snapshots: Vec<SnapshotSource<R>>,
37    /// Consecutive slots after the earliest snapshot through the fixed target.
38    pub slots: Vec<IncomingSlot<W>>,
39    /// Greatest selected coverage or required applied slot when loading began.
40    pub target: u64,
41    /// Authenticated membership and keys at the target.
42    pub state: StoreState,
43    /// Provider work required by the authenticated state at the fixed target.
44    pub provider_access: Vec<crate::ProviderAccessChange>,
45    /// Counted admin changes introducing cut-offs, including compacted history.
46    pub cutoffs: Vec<(Slot, StoreChange)>,
47    /// Activated schema and reset snapshot coverage at the target.
48    pub boundaries: Vec<BoundaryCoverage>,
49    /// Initiating operation's transition committed with the rows.
50    pub operation: Option<OperationUpdate>,
51    /// Authentication of other members' write evidence.
52    pub authorship: std::sync::Arc<dyn crate::Authorship>,
53}
54
55#[cfg(test)]
56#[path = "snapshot_reload_tests.rs"]
57pub(crate) mod tests;