Skip to content

feat(ci): randomized nightly synthetic corpus with an absolute differential gate - #1754

Merged
robcohen merged 3 commits into
mainfrom
feat/synthetic-differential
Jul 10, 2026
Merged

robcohen merged 3 commits into
mainfrom
feat/synthetic-differential

Conversation

@robcohen

Copy link
Copy Markdown
Member

What

Turns the compat workflow's synthetic generation into a real differential testing harness: fresh random seed and 10× the corpus every night, with an absolute gate that fails on ANY rledger-vs-Python verdict disagreement — plus one-command reproduction.

Why

Two structural gaps made the existing setup a fixed corpus in disguise:

  1. Fixed seed — --seed 12345 --count 50 on every run means the "synthetic" corpus never explores a new ledger shape. Every hard bug of the recent review (Correct balances and balsheet reports for reductions in holdings #1726's netting class, fix(validate): catch postings dated before their account's open #1742's use-before-open, the compound-cost class) was a shape no fixture had.
  2. Baseline-relative gating only — the regression gate compares against the previous run's results, so a divergence on a never-before-seen file (which every fresh synthetic file is) fails nothing. The run stays green while rledger and Python disagree.

How

  • Schedule runs: seed = github.run_id, count = 500. PR/push runs: unchanged (12345/50, deterministic and baseline-comparable).
  • Reproduction: workflow_dispatch gains synthetic_seed/synthetic_count; the chosen seed + exact replay command land in the step summary of every run.
  • Absolute gate: synthetic_match != synthetic_total (outputs the comparison script already emits) → red, with the divergent file list (parsed from the results JSONL, CWD/tmp both handled) and the seed.
  • Artifacts: the generated corpus uploads on failure (synthetic-corpus-seed-<seed>, 30-day retention), so the exact divergent inputs survive even without a replay.

Validated locally

Generator accepts arbitrary seeds (27 files at seed 987654 = 7 edge-case collections + 20 random), and a full differential pass of that corpus — rledger check vs bean-check 3.2.3 per file — agrees on all 27.

Follow-up (out of scope here)

Generator richness: the synthetic generator's directive coverage (costs, pads, multi-currency) bounds what the harness can find; deepening it multiplies this PR's value and is the natural next step.

🤖 Generated with Claude Code

…ential gate

The compat workflow generated 50 synthetic files with a FIXED seed
(12345) every run — just another fixed corpus. And the only failure
gate was baseline-relative (files that matched before and mismatch
now), which is structurally blind to a divergence on a
never-before-seen file: exactly what a fresh synthetic file is.

Now:
- nightly (schedule) runs generate 500 files from a FRESH seed
  (github.run_id); PR/push runs keep 12345/50 for deterministic,
  baseline-comparable results;
- workflow_dispatch gains synthetic_seed/synthetic_count inputs, and
  the chosen seed lands in the step summary with the exact reproduce
  command — a nightly divergence is one dispatch away from replay;
- a new ABSOLUTE gate fails the run when any synthetic file's check
  verdict disagrees with Python (synthetic_match != synthetic_total,
  outputs the comparison script already emitted), printing the
  divergent files and the seed;
- on failure the generated corpus uploads as an artifact
  (synthetic-corpus-seed-<seed>, 30 days).

Validated locally: generator accepts arbitrary seeds (27 files at
seed 987654), and a full differential pass of that corpus through
rledger check vs bean-check 3.2.3 agrees on every file.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 10, 2026 17:32
@robcohen
robcohen requested a review from a team as a code owner July 10, 2026 17:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the compat.yml workflow’s “synthetic” generation into a true nightly differential-testing harness by randomizing the seed and scaling the corpus size on scheduled runs, while adding an absolute gate that fails CI on any rledger-vs-Python synthetic verdict mismatch and provides a reproduction path.

Changes:

  • Adds workflow_dispatch inputs to reproduce nightly synthetic divergences via explicit synthetic_seed / synthetic_count.
  • Chooses seed/count dynamically: scheduled runs use github.run_id and 500 files; PR/push runs remain deterministic (12345/50).
  • Adds an absolute synthetic divergence gate plus an artifact upload of the generated corpus on relevant failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/compat.yml Resolved
Comment thread .github/workflows/compat.yml Resolved
Comment thread .github/workflows/compat.yml Resolved
Comment thread .github/workflows/compat.yml Resolved
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100%
Full AST Match 100%
Total Files 811
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

- dispatch inputs enter only via env and are validated numeric before
  use — inline ${{ inputs.* }} in run: is a shell-injection vector;
- outputs/summary written via quoted printf;
- the divergence lister errors clearly when the results jsonl is
  absent instead of raising bare StopIteration;
- the corpus artifact uploads only when the synthetic gate itself
  tripped, not on any late-step failure.

Co-Authored-By: Claude Fable 5 <[email protected]>
robcohen added a commit that referenced this pull request Jul 10, 2026
…nt sync (#1756)

* fix(ci): channel-only rust-toolchain.toml — kill the implicit component sync

The file listed components/targets, so rustup implicitly synced them on
the first cargo invocation of EVERY CI job — a transactional install
that intermittently fails on hosted runners ("detected conflict:
bin/cargo-clippy", #1754 twice, while identical runs pass: per-runner
dice roll). CI jobs already declare components/targets explicitly via
dtolnay inputs; with the file channel-only the sync has nothing to do
and the class is dead. Non-nix dev setup documented in the file.

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs: pin the dev setup hint to the toolchain (review)

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
@robcohen
robcohen merged commit e6f80db into main Jul 10, 2026
38 checks passed
@robcohen
robcohen deleted the feat/synthetic-differential branch July 10, 2026 20:56
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.

2 participants