Skip to main content

Module sequence

Module sequence 

Source
Expand description

Monotonic event sequence numbers that survive restarts.

PhyCloud uses the provenance sequence_num and boot_epoch to tell replayed data from new data, so the counter must never go backwards. With a state file, SequenceCounter reserves numbers ahead of use: it records a high-water mark reserve numbers beyond the last one issued, and only writes again once those are used up. A crash therefore skips at most reserve numbers but never reuses one, and SequenceCounter::close records the exact next number so a clean restart leaves no gap. The Python SDK implements the same scheme and file format ({"next_sequence": N}).

Without a state file the counter lives in memory and restarts from 1; the random boot epoch still tells a receiver that the agent restarted. This is for development and tests. A TPM NV counter replaces the file in hardware signers.

Structs§

SequenceCounter
Hands out increasing sequence numbers, starting at 1.

Constants§

DEFAULT_RESERVATION
Numbers reserved per state-file write.