Skip to content

chore(parser): pin includes/plugins/warnings/bom/alignment in green-red parity - #1738

Merged
robcohen merged 3 commits into
mainfrom
chore/green-red-parity-tuple
Jul 10, 2026
Merged

robcohen merged 3 commits into
mainfrom
chore/green-red-parity-tuple

Conversation

@robcohen

@robcohen robcohen commented Jul 9, 2026

Copy link
Copy Markdown
Member

What

Adds the five uncompared ParseResult observables — includes, plugins, warnings, has_leading_bom, and alignment — to both green/red parity guards: the fuzz_green_eq_red differential fuzz target and the parse_green_eq_red_corpus test.

Why

Phase-1 correctness sweep, green/red family (the cheap follow-up to #1737). The parity guards compared six fields (directives, errors, options, comments, account/currency occurrences) and skipped the rest. Today the skipped fields come from the shared top-level walk, so the green path cannot diverge on them — but that invariant was unpinned. If the green fast path ever expands to touch includes/plugins/warnings/BOM handling/alignment, a divergence there would ship with zero differential coverage. Now it trips the fuzzer and the corpus test instead.

How

Same field list added to both comparison sites, cross-referenced in comments so they stay in sync. alignment compares via PartialEq in the fuzz target (it derives Eq); everything else via the existing Debug-string convention.

Testing

  • parse_green_eq_red_corpus green with the extended 11-field tuple.
  • One-off differential sweep (scratch test, not committed): all 322 repo .beancount/.bean fixtures through parse vs parse_red_only with the extended tuple — zero divergences, as expected.
  • The fuzz crate compiles (cargo check on its manifest); clippy/fmt clean.

🤖 Generated with Claude Code

…ed parity

The fuzz_green_eq_red differential target and its corpus-test sibling
(parse_green_eq_red_corpus) compared six ParseResult fields —
directives, errors, options, comments, and the two occurrence lists —
leaving includes, plugins, warnings, has_leading_bom, and alignment
uncompared. Today those come from the shared top-level walk, so the
green path cannot diverge on them; but that invariant was unpinned,
and a future green expansion touching any of them would ship without
differential coverage.

Add the five remaining observables to both comparison sites (same
field list in both, cross-referenced). Verified against the corpus
test and a one-off differential sweep of all 322 repo .beancount
fixtures with the extended tuple — zero divergences, as expected.

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

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

Pins additional ParseResult observables into the project’s green-vs-red parser parity guards, ensuring future expansions of the green path can’t silently diverge on these outputs without being caught by the differential corpus test and fuzz target.

Changes:

  • Extends parse_green_eq_red_corpus parity comparison tuple to include includes, plugins, warnings, has_leading_bom, and alignment.
  • Extends fuzz_green_eq_red differential fuzz target with assertions for the same additional fields.
  • Updates the fuzz crate’s Cargo.lock to reflect newer rustledger-core / rustledger-parser versions.

Reviewed changes

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

File Description
crates/rustledger-parser/src/cst/green.rs Adds remaining ParseResult observables to the green/red corpus parity tuple.
crates/rustledger-parser/fuzz/fuzz_targets/fuzz_green_eq_red.rs Adds assertions for includes/plugins/warnings/BOM/alignment parity in the fuzz target.
crates/rustledger-parser/fuzz/Cargo.lock Refreshes fuzz lockfile to updated internal crate versions.

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

@github-actions

github-actions Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Tool Time Memory
rustledger 35.6ms ± 4ms 23.4 MB
beancount 914ms ± 14.7ms 50.6 MB
Comparison 25.7x faster 2.2x less

vs main branch (2026-07-10)

Metric main this PR Change
Time 33.7ms 35.6ms +5.6% 🟡
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

@github-actions

github-actions Bot commented Jul 9, 2026 •

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

robcohen and others added 2 commits July 10, 2026 02:42
Debug-string comparison stays only for warnings (ParseWarning has no
PartialEq); everything else in the new parity fields compares
directly — clearer failures and no formatting work in the fuzz hot
path.

Co-Authored-By: Claude Fable 5 <[email protected]>
@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!

@robcohen
robcohen merged commit 2d3eeaa into main Jul 10, 2026
53 of 54 checks passed
@robcohen
robcohen deleted the chore/green-red-parity-tuple branch July 10, 2026 09:47
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