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
use std::collections::BTreeSet;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use crate::value_objects::{
BudgetAccountId, CeremonyContext, CeremonyDeadline, CeremonyDefinitionDigest, CeremonyId,
CeremonyLineage, CeremonyName, CeremonySuccession, CeremonyVersion, StateDeadline, StateId,
StepId,
};
/// A ceremony was opened.
///
/// Carries what `CeremonyInstance::start` and `start_bound` take and
/// everything they derive from the definition — the initial state and
/// the steps that get a pending record — so a fold can open the same
/// instance without the definition in hand. The ids repeat the
/// envelope's on purpose: the payload is meant to stand alone.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CeremonyInstanceStarted {
pub ceremony_id: CeremonyId,
pub definition_name: CeremonyName,
pub definition_version: CeremonyVersion,
pub initial_state: StateId,
/// Every step the definition declares, each opened as pending.
pub step_ids: BTreeSet<StepId>,
pub context: CeremonyContext,
/// The published definition's digest when the ceremony was started
/// from one; absent for a definition supplied for the run.
pub bound_definition: Option<CeremonyDefinitionDigest>,
/// Durable parent identity for a spawned ceremony. Never sourced from context.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub lineage: Option<CeremonyLineage>,
/// Which ceremony this one succeeds, sealed in the predecessor
/// before this opening was appended. Treated exactly as `lineage`:
/// durable provenance, never read out of context, and skipped when
/// absent so openings that predate successions keep their bytes.
///
/// Boxed because an opening is already the widest fact a stream
/// holds and every other event of the enum pays for its size.
/// Nothing on the wire changes: a box serializes as what it holds.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub succession: Option<Box<CeremonySuccession>>,
/// Shared root ledger for this ceremony tree. Children inherit this exact account.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub budget_account_id: Option<BudgetAccountId>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ceremony_deadline: Option<CeremonyDeadline>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub state_deadline: Option<StateDeadline>,
#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
}