Skip to content

Require deliberate, reviewable golden master updates (#330) - #399

Merged
squid-protocol merged 2 commits into
mainfrom
feat/329-golden-crucible-pytest
Jul 25, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
feat/329-golden-crucible-pytest

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Part 4 (final) of the golden-crucible cleanup (#328/#329 done via #395/#397/#398).

Nothing previously stopped a contributor from making a failing crucible-audit diff "pass" by copying fresh output over tests/golden_master_audit.json / _zero_dep_audit.json. A green check meant either "matches the accepted snapshot" or "was just silently re-blessed" -- indistinguishable from the CI result alone.

  • tests/tools/update_golden_master.py: the one sanctioned update path. Regenerates output for whichever mode matches the current environment, prints the full diff against the existing fixture before touching anything, and requires interactive y/N confirmation (--yes available for scripted use, but the diff is always shown regardless).
  • .github/workflows/golden-master-guard.yml: non-blocking -- writes a GITHUB_STEP_SUMMARY callout on any PR touching either fixture file, so it's never invisible in a large diff. Flags for reviewer attention rather than gating merge.
  • CONTRIBUTING.md: documents the update path and the requirement to explain why in the PR description.

Test plan

  • Injected an artificial drift into golden_master_audit.json, ran the script: diff summary printed correctly, n left the file untouched, y wrote the corrected output
  • Restored the real fixture, confirmed golden_diff.py still reports parity (deterministic hash match)
  • No-drift case: script correctly reports "Nothing to do" without prompting
  • flake8, dead_key_audit.py --ci, full pytest tests/ (866 passed, 1 deselected, 1 pre-existing xfail) all clean
  • New workflow YAML parses cleanly

Adds tests/test_golden_crucible.py: runs the real `galaxyscope` CLI entry
point against the language-crucible corpus and diffs the result against
whichever golden master fixture matches the current environment (reuses
the same zero_dependency_mode detection galaxyscope.py itself uses), via
golden_diff.py's comparison functions imported as a library rather than
shelled out to.

Opt-in via a new `golden_crucible` pytest marker, excluded from the
default `pytest tests/` run through pyproject.toml's addopts (it needs
the language-crucible corpus checked out locally -- LANGUAGE_CRUCIBLE_PATH
env var, or a sibling `../language-crucible` directory by default -- and
takes real wall-clock time). Skips cleanly with a clear message if the
corpus isn't present, rather than failing.

golden-crucible.yml now runs `pytest -m golden_crucible` instead of
duplicating the "run galaxyscope, diff against golden master" logic
directly in the workflow, so there's one implementation instead of two
that could drift apart.

Verified: both full-precision and zero-dependency modes pass locally
against the fixtures from #395/#397; the CI workflow YAML parses cleanly;
866 passed, 1 deselected (this new test, correctly excluded from the
default run), 1 pre-existing xfail; flake8 and dead_key_audit clean.
Nothing previously stopped a contributor from making a failing
crucible-audit diff "pass" by just copying fresh output over
tests/golden_master_audit.json / _zero_dep_audit.json -- a green check
would then mean either "matches the last accepted snapshot" or "was just
silently re-blessed," indistinguishable from the CI result alone.

- tests/tools/update_golden_master.py: the one sanctioned update path.
  Regenerates output for whichever mode matches the current environment,
  prints the full diff against the existing fixture before touching
  anything, and requires interactive y/N confirmation (skippable with
  --yes for scripted use, but the diff is always shown either way).
  No-op with a clear message if there's no actual drift.
- .github/workflows/golden-master-guard.yml: non-blocking -- writes a
  GITHUB_STEP_SUMMARY callout on any PR that touches either fixture file,
  so it's never invisible in a large diff. Doesn't block merge; the point
  is reviewer visibility, not enforcement.
- CONTRIBUTING.md: documents the update path and that PRs touching the
  fixture must explain why in the description.

Verified: tested both the abort path (diff shown, 'n' leaves the file
untouched) and the accept path (diff shown, 'y' writes it) against an
artificially-injected drift, then restored the real fixture and confirmed
golden_diff.py still reports parity. flake8, dead_key_audit, full test
suite (866 passed, 1 deselected, 1 pre-existing xfail), and the new
workflow's YAML all clean.
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit c6fd307 into main Jul 25, 2026
25 checks passed
@squid-protocol
squid-protocol deleted the feat/329-golden-crucible-pytest branch July 25, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant