Skip to content

feat(tools): ✨ capture and diff a golden baseline - #302

Open
robertodr wants to merge 1 commit into
mainfrom
split/01-baseline-tool
Open

feat(tools): ✨ capture and diff a golden baseline#302
robertodr wants to merge 1 commit into
mainfrom
split/01-baseline-tool

Conversation

@robertodr

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Summary

First of five PRs carved out of #226. Adds a standalone tool that captures a golden baseline of Majorana propagation results and diffs a later run against it, so the refactors that follow can be shown to be byte-inert rather than asserted to be.

tools/capture-baseline.py walks every tests/data/*.msgpack fixture, runs every (cutoff_type, cutoff) combination through MajoranaPropagator, and records the evolved term set and energies to a labelled directory under .baseline-capture/. A later capture is compared byte-wise, or with --compare --tol when a change is expected to preserve values but not accumulation order.

No library code is touched; nothing in the build or the test suite depends on this.

Changes

  • tools/capture-baseline.py: capture and diff driver, MPI-aware, one directory per label.
  • justfile: capture-baseline LABEL='golden' and diff-baseline AGAINST='golden'.
  • .gitignore: ignore .baseline-capture/**.
  • docs/content/docs/testing.mdx: new "Golden baselines" section covering both recipes.

Checklist

  • Tests added or updated to cover the changes
  • Documentation updated (docstrings, docs/, CONTRIBUTING.md) if needed
  • CHANGELOG / release notes updated if applicable

The tool is itself a test instrument and has no unit tests; it is exercised by running it.

AI/LLM disclosure

  • I used the following tool to help write this PR description: ClaudeCode (claude-opus-5)
  • I used the following tool to generate or modify code: ClaudeCode (claude-opus-5)

@github-actions

Copy link
Copy Markdown

Docs preview: https://pr-302.monoprop-docs.pages.dev

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.70%. Comparing base (665508e) to head (fb9454e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #302   +/-   ##
=======================================
  Coverage   97.70%   97.70%           
=======================================
  Files          14       14           
  Lines         742      742           
  Branches       98       98           
=======================================
  Hits          725      725           
  Misses         12       12           
  Partials        5        5           
Flag Coverage Δ
cpp 97.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@robertodr
robertodr disabled the stack merge August 29, 2026 14:58
A refactor that must not move a term is checked against a captured baseline
rather than by reading the diff. capture-baseline.py propagates every msgpack
fixture at a spread of cutoffs and cutoff types plus a few native qubit
problems, and dumps each run's term count, its full (monomial indices,
coefficient) set and its expectation value.

Terms are dumped in the engine's own returned order and `just diff-baseline` is
a byte-wise diff, because that order runs from SplitmixHash through probe order,
MPI owner routing and insertion order into floating-point accumulation order --
a silent reorder is the regression this exists to catch. `--compare --tol` is
the other mode, for a change that reorders on purpose: term set and count exact,
coefficients and energies to a relative tolerance.

Assisted-by: ClaudeCode:claude-opus-5
@robertodr
robertodr force-pushed the split/01-baseline-tool branch from bafd43b to fb9454e Compare August 29, 2026 14:59
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci documentation Improvements or additions to documentation tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants