Spectre.Stack.Value (Spectre v0.3.0)

Copy Markdown View Source

Portability checks and identity helpers for stack entry values.

Stack definitions must be immutable data: no PIDs, ports, references or functions at any depth. These helpers enforce that constraint and derive deterministic digests and entry identifiers from portable values.

Summary

Functions

Hashes value into a deterministic lowercase hex digest.

Returns value unchanged, raising ArgumentError when it is not portable.

Extracts the identifier of a stack entry: its :id field when present, otherwise the entry itself.

Returns true when value contains no PID, port, reference, function or improper list at any depth.

Returns true when id is a portable atom, binary, integer or tuple.

Functions

digest(value)

@spec digest(term()) :: String.t()

Hashes value into a deterministic lowercase hex digest.

The same value always produces the same digest, so digests can detect stack definition changes across restarts.

ensure_portable!(value, label)

@spec ensure_portable!(term(), String.t()) :: term()

Returns value unchanged, raising ArgumentError when it is not portable.

label names the offending value in the error message.

entry_id(entry)

@spec entry_id(term()) :: term()

Extracts the identifier of a stack entry: its :id field when present, otherwise the entry itself.

portable?(value)

@spec portable?(term()) :: boolean()

Returns true when value contains no PID, port, reference, function or improper list at any depth.

valid_id?(id)

@spec valid_id?(term()) :: boolean()

Returns true when id is a portable atom, binary, integer or tuple.