Skip to main content

SuperpositionState

Struct SuperpositionState 

Source
pub struct SuperpositionState { /* private fields */ }
Expand description

Tracks an entity’s superposition state during migration.

Provides observational semantics on top of the mechanical MigrationState from L5.

Implementations§

Source§

impl SuperpositionState

Source

pub fn new(origin_hash: u64, source_head: CausalLink) -> Self

Create a new superposition state when migration begins.

Source

pub fn advance(&mut self, migration_phase: MigrationPhase)

Advance the phase based on migration progress.

Source

pub fn source_advanced(&mut self, new_head: CausalLink)

Record that source has processed more events since snapshot.

Source

pub fn target_replayed(&mut self, new_head: CausalLink)

Record that target has replayed events.

Source

pub fn target_caught_up(&self) -> bool

Whether the target has caught up to the source.

Source

pub fn collapse(&mut self)

Collapse the superposition (routing switches to target).

Source

pub fn resolve(&mut self)

Mark migration as fully resolved.

Source

pub fn continuity_proof(&self) -> ContinuityProof

Generate a continuity proof spanning the migration.

Proves that the chain is intact from the source’s snapshot point through the target’s current head.

Hash convention. ContinuityProof::verify_against computes compute_parent_hash(event.link, event.payload) for the event at from_seq / to_seq — i.e. the forward hash of the event AT that sequence. A CausalLink’s parent_hash field is the forward hash of the previous event (event at sequence - 1). So when we use head.parent_hash as the proof’s hash, we must point from_seq / to_seq at head.sequence - 1 — that’s the event whose forward hash equals head.parent_hash.

The match-on-min/max pattern below picks the head whose seq matches the from/to anchor, so that proofs spanning a target-behind-source case never mix identities (using target’s seq with source’s parent_hash would produce a proof that could never verify).

Note: head events with sequence == 0 (genesis) have no previous event, so the proof anchors at seq=0 and the hash is the link’s parent_hash (typically zero / a genesis sentinel). verify_against will fail for such proofs unless the verifier holds the genesis event — by design, since you can’t prove continuity of a genesis-only chain.

Source

pub fn phase(&self) -> SuperpositionPhase

Get the current phase.

Source

pub fn origin_hash(&self) -> u64

Get the origin hash.

Source

pub fn source_head(&self) -> &CausalLink

Get the source head.

Source

pub fn target_head(&self) -> &CausalLink

Get the target head.

Source

pub fn replay_gap(&self) -> u64

Events the target still needs to replay.

Trait Implementations§

Source§

impl Debug for SuperpositionState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more