Table of Contents

Struct PageBaseHeader

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

The fixed 16-byte header at the start of every storage page: role flags, block type, format/change revisions, a CRC32C checksum, and a seqlock-style modification counter for torn-page detection. Laid out sequentially with 4-byte packing and kept at exactly 16 bytes so page-layout offsets stay stable.

public struct PageBaseHeader
Inherited Members

Fields

ChangeRevision

The Change Revision is incremented every time the Page is written to disk.

public int ChangeRevision

Field Value

int

Flags

Combination of one to many flags

public PageBlockFlags Flags

Field Value

PageBlockFlags

FormatRevision

Revision number specific to the Page Block Type, to support basic versioning.

public short FormatRevision

Field Value

short

ModificationCounter

Seqlock-style modification counter for torn-page detection. Even values indicate the page is quiescent; odd values indicate an in-progress modification. Readers compare before/after to detect torn writes.

public int ModificationCounter

Field Value

int

Offset

Byte offset of this header within a page — always 0 (the header sits at the page start).

public static readonly int Offset

Field Value

int

PageChecksum

CRC32C checksum of the page contents, excluding this field itself. Zero is the sentinel for a page that has not yet been checksummed. Computed via Crc32CUtil.ComputeSkipping(pageSpan, PageChecksumOffset, PageChecksumSize).

public uint PageChecksum

Field Value

uint

PageChecksumOffset

Byte offset of PageChecksum within the page header.

public const int PageChecksumOffset = 8

Field Value

int

PageChecksumSize

Size in bytes of PageChecksum (for CRC skip region).

public const int PageChecksumSize = 4

Field Value

int

PairGenerationOffset

Byte offset of the A/B slot-pairing generation counter (CK-05). 0 = "not a pair slot" (every normal page). Protected pages (the meta pair; segment-directory twins in C2) stamp a monotonic ulong here; the higher valid generation among a pair's two slots is the current one. CRC-covered (it is outside the 8–11 skip region).

The offset is 40 — the first 8-aligned slot free on every page type, which CK-05 requires (the same offset is read/written uniformly regardless of what header the page otherwise carries). The page header zone packs: [0,16) PageBaseHeader; [16,32) LogicalSegmentHeader on a directory page (so offsets 16–31 are NOT free there — they are the directory's map/raw chain pointers + kind + twin index); [32,36) ChunkBasedSegmentHeader on a chunk-segment directory page. The intersection of the free regions — meta [16,64), plain-dir [32,64), chunk-dir [36,64) — first hits an 8-aligned slot at 40. Accessed by offset rather than a struct field so sizeof(PageBaseHeader) stays 16 and no dependent layout shifts.

public const int PairGenerationOffset = 40

Field Value

int

Size

Size of the header in bytes.

public static readonly int Size

Field Value

int

Type

Block Type

public PageBlockType Type

Field Value

PageBlockType

Methods

ReadPairGeneration(ReadOnlySpan<byte>)

Reads the CK-05 pair generation (PairGenerationOffset) from a page image.

public static ulong ReadPairGeneration(ReadOnlySpan<byte> page)

Parameters

page ReadOnlySpan<byte>

Returns

ulong

WritePairGeneration(Span<byte>, ulong)

Writes the CK-05 pair generation (PairGenerationOffset) into a page image.

public static void WritePairGeneration(Span<byte> page, ulong generation)

Parameters

page Span<byte>
generation ulong