mixle.ppl.provenance module

Reproducible artifacts for the PPL surface: a provenance header for a fitted RandomVariable.

The estimator path has mixle.inference.fit_with_provenance(); this is its PPL counterpart. It times a rv.fit(...) (any how – EM / MAP / MCMC / VI / …), then builds a Header from the fitted model’s lowered distribution (rv.dist), so the header gets the concrete schema and final log-likelihood alongside the data hash, training settings, timing, resources, and environment. The explicit result object is authoritative; this function never mutates the fitted object to attach metadata.

class PPLFitResult(fitted, header)[source]

Bases: NamedTuple

Explicit fitted-object and provenance pair.

A named tuple preserves the historical fitted, header = ... unpacking contract while avoiding optional, failure-prone mutation of fitted.

Parameters:
fitted: Any

Alias for field number 0

header: Any

Alias for field number 1

fit_with_provenance(rv, data, *, seed=None, **fit_kw)[source]

Fit a PPL random variable and return an explicit provenance result.

One pre-fit snapshot (see _replayable_data()) is used for both the fit and the hash, and the snapshot is fingerprinted before the fit runs and again when the header is built. Those two fingerprints must agree: if the fit edits its input in place the header would otherwise report a hash of records the fit never saw, and a provenance header that silently describes the wrong dataset is worse than one that refuses to be built. The extra hash is one SHA-256 pass over the snapshot and no extra memory. Mutation inside a record object is deliberately still detected by this check but not prevented – the snapshot is shallow (MXR-080-1897).

seed=None has the deterministic effective seed 0; otherwise the exact non-negative integer seed initializes the RandomState passed to rv.fit. Supplying a separate rng is rejected so the recorded state cannot disagree with the state used.

Parameters:
Return type:

PPLFitResult