pub struct HeadState {
pub namespace_id: NamespaceId,
pub content_store_id: ContentStoreId,
pub fork_basis: Option<ForkBasis>,
pub seq: ChangeSeq,
pub head_commit_id: CommitId,
pub writer_epoch: WriterEpoch,
pub writer: Option<WriterBlock>,
pub next_inode_id: InodeId,
pub visible_wal_tip: Option<WalSegmentPointer>,
pub recent_segments: Vec<WalSegmentPointer>,
pub state: NamespaceState,
}Expand description
Carries the authoritative visibility, allocation, and fencing state of a namespace.
Fields§
§namespace_id: NamespaceIdNamespace whose live history this head governs.
content_store_id: ContentStoreIdImmutable content store in which the namespace publishes file bytes. Minted at creation; a fork target carries its source’s, sharing the content keyspace copy-on-write.
fork_basis: Option<ForkBasis>Provenance and pre-first-flush basis of a fork target; absent for a created namespace. Immutable for the namespace’s life.
seq: ChangeSeqGreatest visible logical commit sequence.
head_commit_id: CommitIdCommit id assigned to seq, or the fixed genesis id at sequence zero.
writer_epoch: WriterEpochCurrent fencing generation; a publisher holding any other epoch is rejected.
writer: Option<WriterBlock>Non-authoritative record of the most recent epoch acquisition.
next_inode_id: InodeIdFirst namespace-scoped inode identity available for allocation.
visible_wal_tip: Option<WalSegmentPointer>Accepted tip of the visible WAL chain, or None before the first commit.
recent_segments: Vec<WalSegmentPointer>Bounded newest-first accelerator over the visible chain, always including the tip; rewritten by the commit CAS. Chain links remain the only history authority — any disagreement resolves in favor of the chain, and this array never protects anything from GC.
state: NamespaceStateLifecycle state. Absent means active, on read and on write, so the field appears only in deleted heads.
Implementations§
Source§impl HeadState
impl HeadState
Sourcepub fn initial(
namespace_id: NamespaceId,
content_store_id: ContentStoreId,
) -> Self
pub fn initial( namespace_id: NamespaceId, content_store_id: ContentStoreId, ) -> Self
Constructs the active sequence-zero head with the root inode already reserved.
Sourcepub fn ensure_successor_identity(
&self,
successor: &HeadState,
) -> Result<(), HeadIdentityDrift>
pub fn ensure_successor_identity( &self, successor: &HeadState, ) -> Result<(), HeadIdentityDrift>
Checks that successor carries this head’s immutable identity
forward verbatim.
The head is the only durable home of the namespace’s content store and fork provenance, so every publication that rewrites the head must copy them unchanged. Publishers call this before the compare-and-swap: a drifting successor is a construction bug, not a state to persist.