Skip to content

test(ffi): corpus-driven CLI↔FFI parity sweep - #1680

Merged
robcohen merged 1 commit into
mainfrom
chore/corpus-parity
Jul 1, 2026
Merged

robcohen merged 1 commit into
mainfrom
chore/corpus-parity

Conversation

@robcohen

@robcohen robcohen commented Jul 1, 2026

Copy link
Copy Markdown
Member

Implements improvement idea #2 — the hand-written parity.rs cases each pin one behavior; the v0.17→v0.19 bug class was drift on inputs nobody wrote a case for. This sweeps every self-contained .beancount in the repo through both surfaces (native load_source + the component load export, own bindgen! harness incl. the 3.2.0 host.decrypt import), diffing per-entry (kind, date) plus the silent-green invariant: the native path's errors must appear as a message-level prefix of the component's (load appends #1663's validation errors; phase can't separate the sets — native tags booking/process errors validate too).

Maiden run honesty

The first sweep flagged 9 files — all turned out to be an artifact of a phase-based filter in the test, not product bugs. With the correct prefix invariant: 287/287 files identical locally (more in CI when compat fixtures are fetched). The corpus is clean — and now stays that way by construction.

Skips (include-using / non-UTF-8 / >200 KB) are counted + printed, with a minimum-corpus-size assert so a broken walker can't pass vacuously. Runtime ~3s.

🤖 Generated with Claude Code

Feed every self-contained .beancount in the repo (287 compared locally; more in
CI when compat fixtures are fetched) through BOTH the native load path
(rustledger_ffi_wasi::helpers::load_source) and the component load export,
diffing per-entry (kind, date) and asserting the native errors appear as a
message-level PREFIX of the component errors (the component appends the #1663
semantic-validation errors; phase cannot separate the sets since native tags
booking/process errors validate too). This is the silent-green invariant:
nothing the native path reports may vanish through the component.

The hand-written parity.rs cases each pin one behavior; the v0.17-v0.19 bug
class was drift on inputs nobody wrote a case for — this sweeps the corpus
wholesale. Skips include-using / non-UTF-8 / >200KB files (counted, printed,
guarded by a minimum-corpus-size assert). Runtime ~3s.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner July 1, 2026 21:29
Copilot AI review requested due to automatic review settings July 1, 2026 21:29

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

Adds a corpus-driven integration test to continuously verify parity between the native “load source” pipeline and the WASI Preview 2 component-model load export, preventing unnoticed drift on real-world ledger inputs across the repo.

Changes:

  • Introduce corpus_parity.rs, a repo-wide sweep over .beancount fixtures comparing directive stream shape and enforcing the “native errors are a prefix of component errors” invariant.
  • Add rustledger-core as a dependency of rustledger-ffi-component-tests to discriminate native directive kinds/dates.
  • Update Cargo.lock accordingly.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/rustledger-ffi-component-tests/tests/corpus_parity.rs New corpus sweep parity test between native load and component load.
crates/rustledger-ffi-component-tests/Cargo.toml Adds rustledger-core dependency needed by the new test.
Cargo.lock Locks the additional dependency.

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

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100%
Full AST Match 100%
Total Files 792
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

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Tool Time Memory
rustledger 31.3ms ± 0.3ms 23.6 MB
beancount 876.1ms ± 10.2ms 50.6 MB
Comparison 28x faster 2.1x less

vs main branch (2026-07-01)

Metric main this PR Change
Time 36.5ms 31.3ms -14.2% 🟢
10K transactions · 5 runs, 2 warmup · hyperfine
What do these numbers mean?
  • Time: Wall-clock time to parse and validate the ledger (± std dev)
  • Memory: Peak resident set size (RSS)
  • vs main: Compared to latest nightly benchmark on main branch

@robcohen
robcohen merged commit 6fc662d into main Jul 1, 2026
87 of 91 checks passed
@robcohen
robcohen deleted the chore/corpus-parity branch July 1, 2026 22:08
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