Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Regenerating Goldens

Audience: Pulse internals contributors after a legitimate change to anything a golden pins: a descriptor / manifest generator, the generated book pages, a format fixture or an external-oracle grid.

The descriptor goldens live in descriptor/testdata/ (manifest, payload schema, predict, inspect, explain, recommend). Each file ends with a // golden-hash: <sha256> line; TestGoldensNotHandEdited verifies the hash against the file’s body. Hand-editing a golden file flips the hash and fails the gate. The sections below cover the goldens kept elsewhere and how each is regenerated.

When regeneration is justified

You should regenerate after:

  • Adding or removing a registered operator (the manifest enumerates every entry).
  • Changing the capability shape for an existing operator.
  • Renaming an error code (the manifest carries the canonical list).
  • Updating the format_version (rare — additive changes do not bump the version).
  • Any other change that legitimately changes the deterministic manifest output.

If you cannot articulate which deterministic output changed, the golden update is probably wrong and the underlying generator is emitting non-deterministic content (e.g. iterating a map without sorting). Fix that first.

The regenerate flow

go test ./descriptor/ -run 'Test.*Golden' -update

The -update flag asks the test runner to rewrite the goldens with the current generator output. The generator stamps a fresh // golden-hash: <sha256> line at the end of every regenerated file.

Then verify the gate accepts the new hashes:

go test ./descriptor/ -run TestGoldensNotHandEdited

If the gate still fails after -update, the cause is usually one of:

  • The hash trailer is missing from a golden you added by hand — the generator only stamps files it owns.
  • An extra blank line or comment was added by editor configuration before the final hash line — the hash is computed over the body before the trailer.
  • The generator emits map iteration without a sort — non-determinism itself.

Per-feature-profile goldens

Beside the full-registry manifest.json and payload-schema.json, each fixture feature profile under descriptor/testdata/profiles/ (minimal, survey-crosstab, empty) pins its instance’s self-description: manifest.<fixture>.json (the --json envelope around Pulse.Manifest) and payload-schema.<fixture>.json (Pulse.PayloadSchema byte for byte), written by TestProfileManifestGolden and TestProfilePayloadSchemaGolden. Both match Test.*Golden, so the regenerate command above rewrites them too, and they sit at the top of testdata/ where TestGoldensNotHandEdited checks their hashes. The profile inputs themselves live in the profiles/ subdirectory, which the gate skips because they are hand-written.

Regenerate them whenever a change moves what an instance offers or how it describes it: a feature added to or removed from the feature table, a change to a fixture profile, a capability block or schema root that gating omits, or prose the hidden-name scrub redacts. The manifest goldens also carry the skill list, so a skill-pack edit churns them like manifest.json.

The generated Analysis Guide

The book’s “Analysis Guide” part — every page under docs/src/guide/ plus the docs/src/SUMMARY.md entries between the <!-- docgen:summary begin --> and <!-- docgen:summary end --> lines — is generated by pulse docs export from the default instance: the Purpose and Interpretation registries, the glossary and intents, every operator’s ComponentSchema, the embedded skills, and the Components intro in internal/docgen/components_intro.md. It is committed so the published book needs no Go toolchain, and TestDocsGeneratedCurrent (root package) fails the moment a source edit lands without it.

Regenerate after any edit to those sources:

make docs

make docs runs make docs-generate, then mdbook build docs. docs-generate runs, with PULSE_LABEL_TABLES_DIR, PULSE_RANGE_TABLES_DIR, PULSE_LOOKUP_TABLES_DIR, PULSE_POPULATIONS_DIR, PULSE_TEMPLATES_DIR and PULSE_FEATURE_PROFILE cleared (so a local .env cannot change the output):

  1. go run ./cmd/pulse docs export --out docs/src/guide;
  2. go run ./internal/tools/docsummary, which splices the export’s SUMMARY.md into the book’s (title line dropped, paths prefixed guide/);
  3. TestCLIReferenceCurrent -args -update-cli-reference (internal/cli), which rewrites the command and flag reference from the command tree;
  4. TestDocsCoverageCurrent -args -update-coverage (internal/cli), which rewrites the documentation coverage matrix.

On a current tree it changes nothing. Each of the three pages has its own currency test; go test . -run TestDocsGeneratedCurrent -update rewrites only docs/src/guide/ and the SUMMARY.md span, without building the book.

Commit everything the export wrote, the .pulse-docs-export marker included: it lists the files the export owns, so the next export deletes a page that no longer renders. Never hand-edit docs/src/guide/ — the next make docs overwrites it and the gate fails until it does. Edit the source and regenerate.

Never hand-edit a golden

The gate exists to catch the case where a contributor edits a golden to make a test pass instead of fixing the underlying drift in the generator. If a golden diff surprises you in code review, that is a red flag — ask the contributor to show the generator change that justifies the new hash.

The 0x01 format golden is a compatibility fixture, not a snapshot

encoding/testdata/format_v1.pulse is a synthetic 0x01 cohort that every build must still read — and that the current writer must still reproduce byte-for-byte for the same schema and rows. It exists because old cohorts stay readable forever. A failure there is a backward-compatibility break, not a stale golden: do not run go test ./internal/encoding/ -run TestFormatV1Golden -update to make it pass. The -update flag exists only to create the file; to cover more of the 0x01 surface, add a second fixture rather than rewriting this one, so the bytes an earlier binary wrote stay under test.

Shard-archive fixtures are generator-pinned snapshots

testdata/sharding/*.pulse are produced by internal/shardfixtures (go run ./testdata/sharding/build_fixtures.go writes them) and TestShardFixtures_MatchGenerator fails when the committed bytes and the generator disagree. Unlike the 0x01 golden these are snapshots of the CURRENT writer, so a deliberate writer change moves them. Regenerate with go test ./internal/shardfixtures/ -update (or the build_fixtures.go command), then git add -f them (*.pulse is gitignored). The two JSON envelopes beside them are pinned to live CLI output by TestShardingSnapshots_MatchCLIOutput (go test ./internal/cli/ -run TestShardingSnapshots -update).

Example fixture CSVs are generator-pinned and portable

The generated CSVs under internal/examples/fixtures/ come from package fixtures (gen.go): math/rand/v2 PCG streams, normal draws from detmath.NormFloat64, exponentials from detmath.Exp and every multiply-add barriered as float64(x*y), so the generator writes the same bytes on every architecture. Both cross-arch scans cover it, and TestFixtures_RegenerateByteIdentical regenerates every CSV in memory and byte-compares it with the committed file, so CI’s amd64 run proves the bytes committed on arm64. Hand-built CSVs (all_types, card_issuers, tier_migrations, plan_history*, warehouse_orders) are not generated.

A deliberate generator change moves the CSVs and everything that reads them. Regenerate in this order, each through its own path, and commit them together:

go run ./internal/examples/fixtures/cmd/genfixtures
go test -count=1 ./internal/integration -run 'TestExamples_StoryGoldens$' -update
go test -count=1 ./internal/integration -run 'TestFittedState_ExamplesGolden$' -update-fitted-examples
make docs

Then re-read every changed story’s _meta.interpretation: its prose quotes the story golden in words (“about a fifth”, “the interval spans zero”), and no test checks that the words still match the figures.

R reference goldens are an external oracle, not a snapshot

internal/processing/testdata/reference/*.json hold R’s values for the shared distribution primitives (Student t, chi-square, the noncentral chi-square CDF, F, normal CDF and quantile, the limiting Kolmogorov survival, the studentized range). They are written by scripts/reference/gen_reference.R and carry the R and package versions that produced them; make reference runs the script (needs Rscript plus the jsonlite package) and appends the // golden-hash: footer that the processing package’s TestGoldensNotHandEdited checks. CI never runs R.

The TestReferenceOracle_* tests in internal/processing and internal/statdist (the Student-t family’s one implementation) hold every primitive to a relative 1e-10 of those values. A failure there means the Go primitive is wrong, not that the golden is stale: fix the primitive, never regenerate to match it. Regenerate only to change the grid (edit the script, run make reference, commit script and goldens together). The studentized-range and Student-t quantile references are refined in R beyond the stock ptukey() / qtukey() / qt() because those are less accurate than the oracle needs; the script’s header explains why.

The public optimize package keeps its own oracles beside it: optimize/testdata/gen_optimize.R writes least_squares.json (minpack.lm) and minimize.json (nloptr SLSQP), and make reference-optimize runs it and appends the footer that TestOptimize_OracleGoldensHashed checks. The script refuses any R or package version but the pinned ones. TestOptimize_*Matches* hold the solvers to 1e-6 relative, at least 50 times the measured disagreement. As above, a failure means the solver is wrong.

The public mcmc package’s diagnostics are held to ArviZ, not R: mcmc/testdata/gen_diagnostics.py generates seeded fixture chains, computes rhat(method="rank"), ess(method="bulk") and ess(method="tail") with the pinned arviz-stats 1.3.3, NumPy 2.5.4 and SciPy 1.18.1, and writes chains and references together to diagnostics.json. PYTHON=<venv>/bin/python3 make reference-mcmc runs it and appends the footer that TestMCMC_OracleGoldensHashed checks; the script’s header has the venv install line. CI never runs Python. TestMCMC_*MatchesArviZ hold RHat, ESSBulk and ESSTail to 1e-9 relative.

The compose sweep’s mode de is held to SciPy’s differential_evolution (rand1bin, constant F, CR, Latin-hypercube init, deferred updating, no polish) on 2-D Rosenbrock over 20 seeds: scripts/reference/scipy/gen_sweep_de.py (PEP 723, pinned NumPy 2.3.3 and SciPy 1.16.2) writes internal/sweep/testdata/de_oracle.json with its footer, and make reference-sweep-de runs it under uv run. The two engines draw from different random streams, so the trajectories cannot match: the heavy TestDE_MatchesScipyOracle pins the outcome — every seed within 1e-3 of the optimum on both sides, the median best values within two decades.

Mode bo is held to scikit-optimize’s gp_minimize (a Latin-hypercube initial design, EI with xi = 0 over 1000 candidates and 5 polishes, one point a round) on Branin over 20 seeds: scripts/reference/scipy/gen_sweep_bo.py (PEP 723, pinned NumPy 2.3.3, SciPy 1.16.2, scikit-learn 1.7.2 and scikit-optimize 0.10.2) writes internal/sweep/testdata/bo_oracle.json with its footer, and make reference-sweep-bo runs it under uv run. The trajectories cannot match (different streams; skopt polishes by L-BFGS-B, bo by SLSQP), so the heavy TestBO_MatchesSkoptOracle pins the outcome — every seed within 0.05 of the optimum value on both sides, the median best values within 0.005.

The Gaussian-process surrogate behind mode bo (internal/gp) is held to scikit-learn’s GaussianProcessRegressor (normalize_y, alpha 1e-10, ConstantKernel * Matern(nu=2.5) ARD + WhiteKernel) on fixed designs: scripts/reference/scipy/gen_gp.py (PEP 723, pinned NumPy 2.3.3, SciPy 1.16.2 and scikit-learn 1.7.2) writes internal/gp/testdata/gp_oracle.json with its footer, and make reference-gp runs it under uv run. At fixed hyperparameters TestGP_MatchesSklearnAtFixedHyper holds the log marginal likelihood, its gradient and the posterior to 1e-9 relative (a categorical dimension’s tied length scale against the sum of sklearn’s per-column gradient entries). The two ML-II optimisers differ (SLSQP here, L-BFGS-B there), so TestGP_FitMatchesSklearn pins the optimum, not the path: the LML within 1e-9, each hyperparameter within 1e-4 in log space, the posterior mean within 1e-6 and its variance within 1e-5 relative. Its cross-architecture bits ride the gp.* rows of the internal/fingerprint golden (go test -count=1 ./internal/fingerprint -run TestFingerprint_Golden -update on the arm64 dev host, never by hand).

Publish the check. The book’s How Pulse is validated page lists, per operator, the external reference, tolerance and test file behind it. It is generated from validationRegistry in internal/descriptor/validation_registry.go, which Explain’s operator mode (pulse explain OP, pulse_explain {operator}) also returns, so the book and the engine cannot disagree. When you add, tighten or remove a reference check, update the operator’s row in the same PR and run make docs. The gates fail on an inferential built-in with no row, on a cited test file that does not exist, and on one that does not exercise the operator. A cited file must name it, by wire name or by a types constant spelling it (OverlayKindChiSqRow), or read a golden under its package’s testdata/ that does. A runner reading a table, or a kernel oracle, may instead reach it through a file cited beside it in the same reference and package that names it: the runner uses a name that file declares, and the kernel oracle calls a function that file also calls.

NIST StRD certification

testdata/strd/ vendors the 31 NIST Statistical Reference Datasets verbatim, pinned by SHA256SUMS (TestStRD_FixturesIntact). strd_reference_test.go runs each one through the public API and records the digits achieved (log relative error) in testdata/strd/lre.json. TestStRD_DigitsMatchRecord fails on any change, better or worse. After an intended accuracy change, run go test -run TestStRD_DigitsMatchRecord -update. That rewrites the record and its byte-identical copy internal/descriptor/strd_lre.json, which the book’s NIST table is rendered from and Explain’s operator mode (pulse explain OP) returns per operator. Then run make docs and review the digits in the diff. TestStRD_AccuracyFloors holds lower- and average-difficulty sets at 7 digits or more.

The oracle scripts

gen_reference.R writes the primitives, then source()s one script per oracle family — grep -n 'source(' scripts/reference/gen_reference.R lists them in run order. Each script writes its <name>.json through the shared write_golden() and is runnable on its own:

R_LIBS_USER=<lib> Rscript scripts/reference/gen_<name>.R internal/processing/testdata/reference

then append the // golden-hash: footer as the Makefile’s reference target does. Regenerate the one golden your change moves this way rather than rerunning all of make reference.

The script header is the contract. Each header names the operator and R functions it pins, the pinned package versions (the script refuses any other) and how the figures are self-checked; read it before editing a case. The Go test that holds the operator to the golden, and its tolerance, are on the How Pulse is validated page (or grep -rln '<name>.json' --include='*_test.go' .). The rules every script follows:

  • The golden is the exact answer, not the stock function’s stop. Where an R fitter stops early (IRLS deviance tests, BFGS, uniroot, theta.ml), the script polishes to the fixed point (Newton on the analytic gradient, a refit from the optimum) and keeps the stock function’s figure beside it as r_*, cross-checked at a looser tolerance.
  • Every figure is re-derived. A script re-computes each figure from its closed form (or a second route, such as lm.fit on an augmented design or the KKT conditions) and stops on a mismatch.
  • Frequency weights equal the expansion. A frequency-weighted case is asserted equal to its rep()-expanded fit.
  • New cases never move old ones. A block added later draws under its own seed after every existing case and adds keys only, so a rerun leaves existing rows unchanged (or moves their last digits, well inside every tolerance).
  • A failure means the operator is wrong. Fix the Go side; regenerate only to change the cases.

The matrix-operator scripts’ fixtures live in internal/processing/testdata/reference/fixtures/ as a CSV (citation header, %.17g cells, empty = null) plus a .pulse twin that make reference writes with go run ./internal/tools/refcohorts: the vendored attitude (Chatterjee & Price 1977) and mtcars (Henderson & Velleman 1981) from R’s datasets package, each with two seeded weight columns appended, and seeded synthetic fixtures likert_ties, nulls (listwise vs pairwise), weighted (zero-weight rows), nonpsd_pairwise, heywood, reversed_items and two_factor (a proper two-factor fit under every weight kind, so weighted Bartlett factor scores are pinned on real values). No GPL-package data. mv_fixtures.json records each fixture’s source, citation, seed and CSV md5; the internal/tools/refcohorts tests fail when a CSV drifts from that record or a .pulse drifts from its CSV.

The statsmodels oracles (scripts/reference/statsmodels/, PEP 723 pins) write testdata/statsmodels/*.json for the GLM residual kinds and OLS influence measures; make reference-statsmodels runs them under uv run.

The R toolchain

make reference refuses any R but 4.6.1 (2026-06-24) and any package version but the pinned one, so every package below must be installed at exactly that version. Every script header repeats its own pins; this is the whole list in one place.

PackageVersionUsed by
jsonlite2.0.0every golden (gen_reference.R)
Matrix1.7-5 / 1.7-61.7-5: nearest-PD repair, gen_singularity.R rank (gen_multivariate.R pins it; a recommended package, ships with most R builds). 1.7-6: the version marginaleffects resolves, pinned and recorded by gen_margins.R. The two pins exclude each other, so regenerate the multivariate goldens and margins.json under separate library setups (R_LIBS_USER)
nnet7.3-21REG_MULTINOMIAL (gen_multinomial.R; gen_margins.R’s multinomial_cases; gen_nested.R’s multinomial_cases, anova.multinom; the weighted reference reg_reference.R); a recommended package — install it into the user library where the R build omits it
MASS7.3-66REG_GLM negative binomial (gen_glm_nb.R: glm.nb, theta.ml, negative.binomial; anova.negbin in gen_nested.R; a recommended package — install it into the user library where the R build omits it); REG_ORDINAL (gen_ordinal.R: polr, stepAIC; anova.polr in gen_nested.R); REG_MULTINOMIAL modifiers (gen_multinomial.R: stepAIC)
brant0.3.0the REG_ORDINAL Brant test (gen_ordinal.R); from the Posit noble binary repo
ordinal2026.7-26the REG_ORDINAL nominal test (gen_ordinal.R: clm, nominal_test); with its import ucminf 1.2.3 (pinned; compiles Fortran, so install both with the workaround below)
psych2.6.9reliability, KMO / Bartlett, minres / principal-axis / ML factor analysis, factor scores
car3.1-5VIF (MAT_COLLINEARITY, and the regression collinearity block in gen_vif.R; with carData 3.0-6); the multinomial term_tests (gen_multinomial.R: linearHypothesis, Anova)
ppcor1.1partial correlation
perturb2.10collinearity diagnostics (archived on CRAN; needs gdata)
corpcor1.6.10cor2pcor; a Hotelling dependency
Hotelling1.0-8TEST_HOTELLING_T2 (gen_multivariate_tests.R)
biotools4.3TEST_BOX_M
GPArotation2026.8-2oblimin rotation (gen_rotation.R, gen_factor.R)
sandwich3.1-3robust covariance (gen_robust_vcov*.R), marginal effects (gen_margins.R), the nested-model Wald test (gen_nested.R), the REG_ORDINAL sandwich cross-check (gen_ordinal.R)
marginaleffects1.0.0marginal-effects cross-check (gen_margins.R); from the Posit binary repo, with its imports insight 1.7.0, data.table 1.18.6.1, generics 0.1.4 and Matrix 1.7-6 (pinned; see the Matrix row; the golden records each)
lavaan0.7.3MAT_SEM / ATTR_SEM_SCORE reference fits (internal/sem/testdata/gen_lavaan.sh, its own runner, each fixture recording the release) and the SEM nested comparison (gen_sem_compare.R: lavTestLRT, standard and satorra.bentler.2001); with its imports pbivnorm 0.6.0, quadprog 1.5.8, numDeriv 2016.8-1.1, mnormt 2.1.2 and MASS (the row above) — the versions the goldens were generated with; the scripts check lavaan’s alone
lmtest0.9-40robust covariance tests; nested-model waldtest / lrtest (gen_nested.R, with zoo 1.9-1)
pROC1.19.1AGG_AUC rank-sum AUC and DeLong interval (gen_auc.R)
mpath0.4-2.28penalized REG_GLM negative binomial (gen_glm_nb_penalty.R: glmregNB); with its imports pscl 1.5.9, bst 0.3-24, WeightSVM 1.7-16 and doParallel 1.0.17 (pinned, recorded in the golden); compiles Fortran, so install it with the workaround below
plm2.6-7panel covariance cross-check (gen_robust_vcov_panel.R: vcovNW, vcovSCC on a pooling plm); with its imports bdsmatrix 1.3-7, collapse 2.1.9, maxLik 1.6-10 and miscTools 0.6-30 (pinned, recorded in the golden; collapse compiles C/C++); zoo, nlme, Formula, Rdpack, lmtest resolve from the rows above or the R build
glmnet5.1penalised REG_GLM / REG_OLS (gen_glm_penalty.R, gen_ols_penalty.R) and REG_MULTINOMIAL (gen_multinomial_penalty.R); thresh / maxit through control
nnls1.6REG_OLS bounds.nonnegative (gen_ols_nnls.R); compiles Fortran, so install it with the workaround below
nortest1.0-4Shapiro-Francia (nortest::sf.test), the TEST_SHAPIRO_WILK oracle (gen_test_outputs.R, gen_post_tests.R)
Kendall2.2.2Mann-Kendall cross-check for TEST_TREND (gen_test_outputs.R); it computes in single precision, so the 1e-10 oracle is base R
pwr1.3-0no generator uses it yet; internal/processing/test_effect_size_test.go cites pwr::ES.h in a comment only, so it is installed for cross-checks, not for make reference
Hmisc5.3-0probability-weight quantiles (internal/service/testdata/weight_reference/hmisc_quantile.R); compiles Fortran, so install it with the workaround below
minpack.lm1.2-4optimize.LeastSquares (optimize/testdata/gen_optimize.R, make reference-optimize) and REG_MMM_HILL (gen_mmm_hill.R, make reference; gen_mmm_hill_adstock.R, make reference-mmm-hill-adstock; on Linux it installs from the Posit noble binary repo); links gfortran, so install it with the workaround below
nloptr2.2.1optimize.Minimize, NLOPT_LD_SLSQP (optimize/testdata/gen_optimize.R, make reference-optimize)
lme42.0-6TEST_ANOVA_RM incomplete: "mixed" (gen_test_anova_rm_mixed.R: lmer(y ~ cond + (1 | subj), REML = TRUE), the cross-check fit)
lmerTest3.2-1TEST_ANOVA_RM incomplete: "mixed" (gen_test_anova_rm_mixed.R: anova(m, ddf = "Satterthwaite"), kept as r_lmertest_* beside the closed-form REML / Satterthwaite golden; pure R, installs from CRAN source), with its import numDeriv 2016.8-1.1

ICSNP, MVTests and MVN do NOT build on R 4.6.1; nothing needs them. The scripts compute what they would (the unequal-covariance Hotelling test, Mardia’s statistics) as closed forms in base R, each cross-checked as its comment says. The weighted-reference generator (internal/service/testdata/weight_reference/) needs only base R plus Hmisc 5.3.0 and nnet 7.3-21 from this list, installed into the same user library; its README covers it, along with its Python pins and the --check mode.

Install the pins into the user library (remotes::install_version fetches the exact version even after CRAN moves on):

Rscript -e 'r <- "https://cloud.r-project.org"; l <- Sys.getenv("R_LIBS_USER");
  dir.create(l, recursive = TRUE, showWarnings = FALSE)
  install.packages("remotes", lib = l, repos = r)
  pins <- c(psych = "2.6.9", car = "3.1-5", ppcor = "1.1", corpcor = "1.6.10",
            gdata = "3.0.1", Hotelling = "1.0-8", biotools = "4.3",
            GPArotation = "2026.8-2", sandwich = "3.1-3", lmtest = "0.9-40", pROC = "1.19.1",
            glmnet = "5.1", nortest = "1.0-4", Kendall = "2.2.2", pwr = "1.3-0",
            Hmisc = "5.3-0", MASS = "7.3-66", ucminf = "1.2.3", ordinal = "2026.7-26",
            pscl = "1.5.9", bst = "0.3-24", WeightSVM = "1.7-16", doParallel = "1.0.17",
            mpath = "0.4-2.28", bdsmatrix = "1.3-7", collapse = "2.1.9",
            miscTools = "0.6-30", maxLik = "1.6-10", plm = "2.6-7",
            numDeriv = "2016.8-1.1", lme4 = "2.0-6", lmerTest = "3.2-1")
  for (p in names(pins)) remotes::install_version(p, pins[[p]], lib = l, repos = r, upgrade = "never")
  install.packages(paste0(r, "/src/contrib/Archive/perturb/perturb_2.10.tar.gz"),
                   lib = l, repos = NULL, type = "source")'

Homebrew Fortran workaround. Packages with Fortran code (Hmisc, and any dependency that compiles Fortran) fail to link on Homebrew R 4.6.1 with library 'emutls_w' not found: R’s recorded FLIBS names a gcc target directory that does not exist (R CMD config FLIBS reports aarch64-apple-darwin27; Homebrew gcc 16 installs aarch64-apple-darwin23). Write a TEMPORARY Makevars naming the real directory and point R_MAKEVARS_USER at it for the install only — never commit it, and keep it out of ~/.R/Makevars:

GCC=$(brew --prefix gcc)/lib/gcc/current
TRIPLE=$(ls "$GCC/gcc"); VER=$(ls "$GCC/gcc/$TRIPLE")
printf 'FLIBS = -L%s/gcc/%s/%s -L%s/gcc -L%s -lemutls_w -lheapt_w -lgfortran -lquadmath\n' \
  "$GCC" "$TRIPLE" "$VER" "$GCC" "$GCC" > /tmp/Makevars.pulse
R_MAKEVARS_USER=/tmp/Makevars.pulse Rscript -e '...the install line...'

A rerun of make reference on this toolchain is byte-identical (no clock, no unseeded RNG): git status must show only the goldens your change meant to move.

The Stan toolchain

REG_MMM_BAYES’s posterior is cross-checked against Stan, not make reference: scripts/reference/gen_mmm_bayes_stan.R samples the model written independently in scripts/reference/mmm_bayes.stan (Pulse’s scaling and default priors, one case per adstock kernel × saturation curve cell — 4 × 3 — plus two with a lift test in the likelihood, rows simulated, seeded and stored) and writes internal/regmmm/testdata/mmm_bayes_stan.json; make reference-stan runs it (about fifteen minutes) and appends the footer. TestMMMBayes_PosteriorMatchesStan (heavy, internal/regmmm) fits the stored rows through the operator and holds every coefficient’s posterior mean and each channel’s ROI within its case’s stated tolerance (stanCellZ, keyed by case name; 4.5 combined Monte Carlo standard errors in every case) of Stan’s. The program’s lift block is inert with no test (T = 0). The script refuses any version but R 4.6.1, cmdstanr 0.9.0, CmdStan 2.40.0, posterior 1.7.1 and jsonlite 2.0.0, and stops unless the Stan run mixed (R-hat < 1.01, bulk ESS > 2000, at most 0.5% divergent transitions). Install:

Rscript -e 'install.packages("cmdstanr", repos = c("https://stan-dev.r-universe.dev", getOption("repos")))'
Rscript -e 'remotes::install_version("posterior", "1.7.1", repos = "https://cloud.r-project.org", upgrade = "never")'
Rscript -e 'cmdstanr::install_cmdstan(version = "2.40.0")'

To add a model cell (a curve, a hierarchy), extend the Stan program’s data switches and append a case to the script’s cases list: the Go test reads every case generically (give the new case a stanCellZ row).

The geo-hierarchical model (params.geo) has its own pair, so neither golden moves when the other is regenerated: scripts/reference/gen_mmm_bayes_geo_stan.R samples scripts/reference/mmm_bayes_geo.stan (the non-centred partial pooling, HalfNormal(0.5) scales, default priors) on two stored three-geo × two-channel panels — curves shared and per_geo_curves — and writes internal/regmmm/testdata/mmm_bayes_geo_stan.json; make reference-stan-geo runs it (about thirty minutes) on the same toolchain and self-checks and appends the footer. TestMMMBayes_GeoPosteriorMatchesStan (heavy) holds every coefficient (per-geo terms, population values, every τ), each channel’s population ROI μ and its all-geo and per-geo ROI within 4.5 combined Monte Carlo standard errors of Stan’s.