Svelixir.Baseline (svelixir v0.11.0)

Copy Markdown

Provenance and drift checking for the checked-in generator baselines.

Every function is pure over a directory — nothing here shells out to a generator, so the drift check runs offline on every commit and 100% coverage never depends on having phx_new installed.

This module must NOT share a normaliser with Svelixir.Hash. They require opposite semantics: the manifest hash ignores an added comment (a # credo:disable-for-next-line must not lock a project out of updates), while a comment added to a baseline IS drift.

Summary

Functions

A single digest over the whole tree.

Replaces phx.new's four crypto:strong_rand_bytes values with placeholders.

Reads the provenance record.

Maps every relative path under dir to the sha256 of its normalised bytes.

Functions

digest(dir)

@spec digest(Path.t()) :: binary()

A single digest over the whole tree.

normalise_secrets(source)

@spec normalise_secrets(binary()) :: binary()

Replaces phx.new's four crypto:strong_rand_bytes values with placeholders.

Anchors on the key name, never on a bare length match: the alphabet is unpadded base64, so values contain + and / and may start with /.

read!(path)

@spec read!(Path.t()) :: %{otp: map(), web: map()}

Reads the provenance record.

tree(dir)

@spec tree(Path.t()) :: %{required(Path.t()) => binary()}

Maps every relative path under dir to the sha256 of its normalised bytes.