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
impl SuperpositionState
Sourcepub fn new(origin_hash: u64, source_head: CausalLink) -> Self
pub fn new(origin_hash: u64, source_head: CausalLink) -> Self
Create a new superposition state when migration begins.
Sourcepub fn advance(&mut self, migration_phase: MigrationPhase)
pub fn advance(&mut self, migration_phase: MigrationPhase)
Advance the phase based on migration progress.
Sourcepub fn source_advanced(&mut self, new_head: CausalLink)
pub fn source_advanced(&mut self, new_head: CausalLink)
Record that source has processed more events since snapshot.
Sourcepub fn target_replayed(&mut self, new_head: CausalLink)
pub fn target_replayed(&mut self, new_head: CausalLink)
Record that target has replayed events.
Sourcepub fn target_caught_up(&self) -> bool
pub fn target_caught_up(&self) -> bool
Whether the target has caught up to the source.
Sourcepub fn continuity_proof(&self) -> ContinuityProof
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.
Sourcepub fn phase(&self) -> SuperpositionPhase
pub fn phase(&self) -> SuperpositionPhase
Get the current phase.
Sourcepub fn origin_hash(&self) -> u64
pub fn origin_hash(&self) -> u64
Get the origin hash.
Sourcepub fn source_head(&self) -> &CausalLink
pub fn source_head(&self) -> &CausalLink
Get the source head.
Sourcepub fn target_head(&self) -> &CausalLink
pub fn target_head(&self) -> &CausalLink
Get the target head.
Sourcepub fn replay_gap(&self) -> u64
pub fn replay_gap(&self) -> u64
Events the target still needs to replay.