Skip to main content

dpm_model/run/
heads.rs

1//! Where a run store's feeds stand, read in one transaction.
2
3use crate::LineageId;
4use serde::{Deserialize, Serialize};
5
6/// The positions of a run store's durable facts.
7///
8/// A run's view is built from three kinds of durable fact, and each is tracked on its own: the
9/// lifecycle transitions and the bounded activity, which are feeds with cursors, and the operations
10/// linked to a run afterwards, which are an invalidation count. A consumer holds each separately,
11/// because lifecycle facts are never pruned while activity is bounded, a link changes a run's view
12/// without being either, and none of them moves when the project's operation history does. Two
13/// readings with equal positions in one epoch describe the same run facts.
14#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
15pub struct RunFeedHeads {
16    /// The lineage the run store is bound to, absent while no run store exists. Feed cursors are
17    /// meaningful only within one epoch: a restore forks the run store to a new lineage, and its
18    /// sequences continue from the backup, not from the store it was copied from.
19    #[serde(default, skip_serializing_if = "Option::is_none")]
20    pub epoch: Option<LineageId>,
21    /// Newest lifecycle feed sequence, zero when the feed is empty.
22    pub lifecycle_head: u64,
23    /// Newest activity feed sequence ever assigned, zero when the feed is empty.
24    pub activity_head: u64,
25    /// Highest activity sequence retention has removed; a cursor below it has a gap.
26    pub activity_pruned_through: u64,
27    /// How many operations were ever linked to a run in this epoch.
28    ///
29    /// Links are append-only and each distinct operation is linked once, so the count only grows
30    /// and a replayed link does not move it. It is an invalidation token, not a feed: it says that
31    /// some run's linked operations changed, not which, and a consumer that sees it change reads
32    /// the runs it displays again. It promises no order of links and no resumable position.
33    #[serde(default)]
34    pub link_count: u64,
35}