Repository navigation
feat(parity): name parse-error mismatches by category key through ptadiff - #3056
Merged
Merged
Conversation
…diff The parse-error parity harness now runs through pta-standards' differential package (ptadiff, tooling/differential), pinned by commit in the manifest (`#@ptadiff-rev`), and names every mismatch with ptadiff's beancount `shape` category key: which side reports more on the first line the two disagree on, that side's error kinds, the line's kind, and the line's token shape from beancount's black-box lexer (lex_iter_string). - parse_error_lines gains `--jsonl`, ptadiff's JSON-lines protocol; the harness talks to rledger through it, and runs beancount in ptadiff's forked workers (same crash capture as before) - a new `gen` input source: 12000 inputs from ptadiff's seeded G1-G3(b) generators, pinned like the fuzz and matrix inputs (`#@generators`, `#@inputs gen`, per-input pins), identical across runs, worker counts and Python versions - the manifest pins each category key's count over the fixed sources (`@ categories`, next to the symptom buckets); a changed count is a stale pin, and a different ptadiff revision, key or generator sample is a coverage error. Every existing pin is unchanged - the report adds the category table, with the ten largest categories' examples minimized by ptadiff's key-preserving minimizer (`--minimize`); `--categories-json` writes it for the CI artifact - a token-level drift test (`cst::bc_lexer_drift`) compares BcLexer with beancount 3.2.3's lex_iter_string, token name and byte span, over the tracked ledgers, fuzz regressions, pinned fuzz corpus, stray-character matrix and generator sample (123833 inputs, all agree), run in the python-gated-cargo-tests job with skips turned into failures Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…dards#73) The tooling/differential tree is identical to the feature-branch commit it replaces, so no count changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
robcohen
added a commit
that referenced
this pull request
Nov 27, 2026
…_lexer_drift The drift test from #3056 compared BcLexer, the recovery model's port of beancount's lexer, with lex_iter_string. Point it at the oracle's reference lexer, written from pta-standards' clean-room LEXICAL.md, which the remaining recovery code is being replaced with: 123,833 pinned inputs agree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 27, 2026
…_lexer_drift The drift test from #3056 compared BcLexer, the recovery model's port of beancount's lexer, with lex_iter_string. Point it at the oracle's reference lexer, written from pta-standards' clean-room LEXICAL.md, which the remaining recovery code is being replaced with: 123,833 pinned inputs agree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 27, 2026
…RROR_ORACLE (#3061) * feat(parser): a table-driven beancount error oracle, behind RLEDGER_ERROR_ORACLE Replace the hand-modeled bison recovery step by step with beancount's own grammar. This adds the pieces, off by default: - scripts/gen-beancount-lalr-tables.py compiles pta-standards' clean-room, MIT-licensed beancount.y (vendored at 1463db773ac5, hash-checked) with the flake's bison 3.8.2 into cst/oracle/beancount/tables.rs; a new CI job regenerates and diffs them. - cst/oracle/beancount/lr.rs replays yacc.c's semantics over the tables: default reductions, error shift and yyerrstatus 3, discard, a lexer YYerror entering recovery without a report, YYMAXDEPTH 10000, EOF abort. No recursion, no panics, linear time; slots plus a reduction trace. - cst/oracle/beancount/lexer.rs: beancount's tokenization written from LEXICAL.md only. - cst/oracle/mod.rs: the format-neutral ReferenceOracle / reconcile / DeviationOverlay seam; ten named overlays for the documented deliberate differences, each citing a new compatibility.md section. - scripts/compat-beancount-oracle-drift.py (in the parity job) holds the model to beancount itself: 122,917 of 122,917 inputs agree on tokens and syntax errors. With RLEDGER_ERROR_ORACLE=1 the parity harness matches 119,952 of 123,304 inputs where main matches 119,048, with no regression. The oracle runs only when rledger's own parse reports an error, so a clean ledger pays nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(parser): check the error oracle's lexer, not BcLexer, in cst::bc_lexer_drift The drift test from #3056 compared BcLexer, the recovery model's port of beancount's lexer, with lex_iter_string. Point it at the oracle's reference lexer, written from pta-standards' clean-room LEXICAL.md, which the remaining recovery code is being replaced with: 123,833 pinned inputs agree. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The parse-error parity harness (
scripts/compat-parse-error-parity.py) now runs through pta-standards' new differential package,ptadiff(rustledger/pta-standards#73). The manifest pins ptadiff by commit (#@ptadiff-rev). The harness now names every mismatch with a category key, not just a symptom bucket.Batch protocol.
parse_error_lines --jsonlspeaks ptadiff's JSON-lines protocol ({id, text}in,{id, errors: [{line, code, msg}]}out). The harness talks to rledger through it and runs beancount in ptadiff's forked workers, with the same crash capture as before. The framed mode stays forscripts/bom-combination-matrix.py.Category key. ptadiff's beancount
shapekey is built from four parts, all taken from the first line the two sides disagree on:lex_iter_string.It uses no beancount grammar tables. The key is pluggable, so a parser-state key from the clean-room grammar can replace it later.
New
geninput source. 12,000 inputs from ptadiff's seeded G1–G3(b) generators. They are pinned like the fuzz and matrix inputs (#@generators,#@inputs gen, per-input pins). The sample is identical across runs, worker counts (--jobs 3vs 16) and Python 3.11/3.13.Per-category pins. The manifest's new
@ categoriessection, next to the symptom buckets, pins each key's count over the fixed sources (fuzz, matrix, gen).--check.Report. The job summary gains the category table, with the ten largest categories' examples minimized by ptadiff's key-preserving minimizer (
--minimize 10). The full table is uploaded as an artifact (--categories-json).BcLexer drift test. New test
cst::bc_lexer_drift(rustledger-parser) comparesBcLexerwith beancount 3.2.3'slex_iter_string, token name and byte span, over:All 123,833 inputs agree. It runs in
python-gated-cargo-testsin its own beancount==3.2.3 + ptadiff venv, withRLEDGER_BC_LEXER_DRIFT_REQUIRE=1turning skips into failures, and its skip marker is added to the job's grep.Bc::Otherdid not need splitting: eachOthertoken's text names exactly one beancount token, so the test maps it.Why
This is phase 1 of the parser plan: turn parse mismatches into named, countable categories, so the remaining work can be picked by group size instead of by symptom.
Top categories (all sources, 3,830 mismatches in 540 keys)
impl-fewer|oracle:lex:token+syn:INDENT|indented|INDENT error(orphan-INDENT double count)"\t\ufeff"impl-more|impl:P0012|top|^ error"\^A\r2"impl-more|impl:P0012|top|DATE error"2229-1-7B\r!"impl-more|impl:P0012|indented|CAPITAL error"2305-2-3*\n\tG\tO+"impl-fewer|oracle:lex:token+syn:NUMBER|top|NUMBER error"2\u0667\ufeff"The top 10 keys cover 34.5% of mismatches, and the top 50 cover 69%.
Before merging
This PR pins ptadiff to
2b844dc, a commit on pta-standards'feat/differential-toolingbranch. Once rustledger/pta-standards#73 merges, re-pin#@ptadiff-revto the merge commit. The squash merge changes the SHA, and the branch commit stops being fetchable once the branch is deleted. Then run--update: the counts should not change, only the rev line.How to test
Locally:
cargo clippy --workspace --all-features --all-targets -- -D warningsis clean, andcargo test -p rustledger-parser -p rustledger-loaderpasses.🤖 Generated with Claude Code