Skip to main content

check_dispatch

Function check_dispatch 

Source
pub fn check_dispatch(
    coordinator: &mut dyn LeaseCoordinator,
    state: &SyncState,
    agent_id: &str,
    run_id: &str,
    device_id: &str,
    epoch: u64,
) -> Result<FenceDecision, LeaseError>
Expand description

Run the dispatch fence for one leased run at the point of effect.

state is the caller’s folded SyncState (checkpoint base + journal tail — e.g. crate::session::SyncSession::state); it supplies the fence-independent committed-run oracle. coordinator is the linearizable lease register; LeaseCoordinator::current is the “am I still epoch N?” read. The oracle read comes first so an already-committed run is declined even by a caller that legitimately holds the current lease (idempotency dominates liveness — the whole point of a keep-all oracle).

Returns FenceDecision::Proceed iff no prior commit exists AND the caller device_id holds the current lease at epoch. Any other outcome means do not perform the side effect.