Skip to main content

sectorsync_core/
handoff.rs

1//! Two-phase entity owner handoff primitives.
2
3use crate::entity::EntityRecord;
4use crate::ids::{EntityHandle, EntityId, OwnerEpoch, StationId, Tick};
5
6/// In-memory transfer payload for a two-phase owner handoff.
7#[derive(Clone, Debug, PartialEq)]
8pub struct HandoffTransfer {
9    /// Entity being transferred.
10    pub entity_id: EntityId,
11    /// Source owner station.
12    pub source_station: StationId,
13    /// Target owner station.
14    pub target_station: StationId,
15    /// Owner epoch observed at the source before transfer.
16    pub source_owner_epoch: OwnerEpoch,
17    /// Owner epoch that target will use after commit.
18    pub target_owner_epoch: OwnerEpoch,
19    /// Tick at which source prepared the transfer.
20    pub prepared_at: Tick,
21    /// Tick after which old source ghost can be discarded.
22    pub source_ghost_expires_at: Tick,
23    /// Authoritative entity state captured for transfer.
24    pub entity: EntityRecord,
25}
26
27/// Handles produced by committing a two-phase handoff.
28#[derive(Clone, Copy, Debug, PartialEq, Eq)]
29pub struct HandoffCommitHandles {
30    /// Source station handle after it has been downgraded to a ghost.
31    pub source_ghost: EntityHandle,
32    /// Target station handle after it has become authoritative owner.
33    pub target_owner: EntityHandle,
34}