Documentation
¶
Overview ¶
Package clonegen publishes a monotonic "clone generation" token readers can poll to detect that a sandbox was resumed from a snapshot — i.e. that it is a clone. Shared between in-guest toolboxd (file + HTTP endpoint) and the WASM driver's checkpoint fencing (§4.8).
Index ¶
Constants ¶
const DefaultPath = "/run/aerolvm/clone-generation"
DefaultPath is the well-known in-guest file pollers read. It lives on tmpfs (/run) so reads are cheap and the value never outlives a boot.
Variables ¶
var RandRead = rand.Read
RandRead is the entropy source for randomToken. Tests may replace it.
Functions ¶
This section is empty.
Types ¶
type Generation ¶
type Generation struct {
// contains filtered or unexported fields
}
Generation holds the current generation token. Safe for concurrent use.
func New ¶
func New(path string, logger *slog.Logger) *Generation
New seeds an initial token and writes it to path. The initial token is the baseline an in-guest process records at startup; it stays put until Bump rotates it, so a sandbox that is never cloned correctly reports "no clone." The file write is best-effort — a guest without a writable /run still serves the token over HTTP.
func (*Generation) Bump ¶
func (c *Generation) Bump(resumedAtUnixNs int64)
Bump rotates the token and records the resume time. Nil-safe.
func (*Generation) Current ¶
func (c *Generation) Current() (token string, resumedAt int64)
Current returns the token and the last resume time. Nil-safe: a nil receiver reports the baseline "never cloned" state instead of panicking.