PtcRunner.Kernel.SourceIntern (PtcRunner v0.15.0)

Copy Markdown View Source

Interns exact source binaries by qualified SHA-256 during package preparation.

Identical bytes reuse one BEAM binary across workflow and mission catalogs. A hash collision with different bytes fails closed rather than aliasing two sources together.

Summary

Functions

Interns source and returns the canonical binary for that qualified hash.

Replaces each component's source with the interned binary for those bytes.

Returns an empty intern table.

Types

t()

@type t() :: %PtcRunner.Kernel.SourceIntern{
  entries: %{required(binary()) => binary()}
}

Functions

intern(intern, source)

@spec intern(t(), binary()) :: {:ok, binary(), t()} | {:error, :source_hash_collision}

Interns source and returns the canonical binary for that qualified hash.

When the hash is new, source itself becomes the interned binary. When it already maps to equal bytes, the previously interned binary is returned so catalogs share one refc binary. Distinct bytes under the same hash fail.

intern_components(intern, components)

@spec intern_components(t(), [PtcRunner.Kernel.Component.t()]) ::
  {:ok, t(), [PtcRunner.Kernel.Component.t()]}
  | {:error, :source_hash_collision}

Replaces each component's source with the interned binary for those bytes.

new()

@spec new() :: t()

Returns an empty intern table.