Repository navigation
test: compare every diagnostic surface with rledger check on the corpus - #3055
Merged
Merged
Conversation
…eck does The LSP built its plugin context only when the ledger had a `plugin` line, so `option "documents"` alone never ran document discovery (an implicit synth plugin in the loader's `run_plugins`), in a single file or in a loaded ledger. With a `plugin` line, a single file's source map named a stand-in path in /tmp, so a relative documents directory resolved there rather than next to the file. A document filed under an account no directive names, which `check` warns about, was missing from the editor. The plugin context is now built when there are plugins or documents roots, and a single file's source map names the buffer's own path. Found by the cross-surface drift guard added in the next commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A new test crate, rustledger-surface-parity-tests, runs every ledger of the corpus (tests/compatibility/files, tests/fixtures, tests/regressions, the loader's and the CLI's test ledgers, and the surface_agreement cases) through `rledger check --format json` in-process, WASM (validateSource, ParsedLedger, validateMultiFile, Ledger.fromFiles, the last two also from their caches), the FFI component (validate, load, validate-file, load-file) and the LSP (all_diagnostics, and the real server through the protocol harness for a ledger with includes). The diagnostics, normalized to (file, line, code, message, severity), must be identical, compared whole. The booked directives must be those of the validating load check runs, and the FFI query / query-file must answer as `rledger query`. Legitimate differences are an allowlist of exact (file, code, line) items, each entry naming its reason, and an entry that no longer applies fails the test. One entry is open, not a decision: check codes load errors E0001-E0005, while the loader's canonical renderer codes them LOAD. To call each surface natively, WASM gains a hidden `surface_probe` module whose functions run the exports' bodies (validateSource and validateMultiFile are split into a Rust core and the JsValue wrapper), and the FFI component gains an rlib target and a hidden `surface_probe` re-exporting the functions its exports delegate to. 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?
|
The document discovery test joined "docs/Expenses/Gone/..." as one string, so on Windows the expected path had forward slashes where the discovered one has backslashes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
robcohen
added a commit
that referenced
this pull request
Nov 27, 2026
…rface differences #3055's corpus includes crates/rustledger/tests, so it now runs the upstream-check cases. Six hit existing classes (no disk for document roots, load errors coded LOAD, the LSP's E8006 for an unsupported plugin), and one is new and OPEN: a check_closing balance is at <check_closing>, 0 in check and in the ledger file on every other surface. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 27, 2026
…rface differences #3055's corpus includes crates/rustledger/tests, so it runs the upstream-check cases. Five hit existing classes (no disk for document roots, a file map's own words for a load error, the LSP's E8006 for an unsupported plugin), and one is new and OPEN: a check_closing balance is at <check_closing>, 0 in check and in the ledger file on every other surface. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 27, 2026
…st drift (#3054) * test(compat): table every check beancount reports, and guard it against drift ops/validation.py one function at a time. This does that walk for every module and leaves a guard behind. - crates/rustledger/tests/fixtures/upstream-checks/enumerate.py lists every check the installed beancount can report, from its source (ast): each error-tuple construction (module.function + message template), each raise in ops/parser/plugins/loader, each plugin module, each deprecated option. 126 for beancount 3.2.3, plus one manual row (gpg decryption). - checks.toml gives each a status: 96 covered, 2 deliberate deviations, 24 not applicable (dead code, unreachable, beancount tooling), 5 missing. - Each covered row names a small ledger in cases/. upstream_checks_test runs it through rledger check and bean-check and asserts the lines each tool reports the row's code/message on, so "covered" means the same lines, or the row's note says how they differ. Missing and deviation rows are pinned the same way, so a fix cannot leave the table stale. - The drift guard compares enumerate.py's output with the table's ids, both ways, so a beancount upgrade that adds, removes or rewords a check goes red and names it. It introspects rather than hashing the scanned files: a hash goes red on any docstring edit and does not say which check changed. - The Python half runs in the python-gated-cargo-tests job (skip marker already in its grep); the rledger half runs in every cargo test. - compatibility.md gains section 20: AVERAGE booking and {*} merging, which beancount 3.2.3 refuses and rledger implements (ADR 0007). - docs/reference/upstream-checks.md documents the table and how to update it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(compat): pin the upstream-check case ledgers in the parse-error parity manifest The case ledgers are tracked .beancount files, so the parse-error-parity job compares them. All match but grammar-duplicate-merge ({*, *}, a missing row, bc-only until the follow-up fix). beancount's deprecation error for allow_deprecated_none_for_tags_and_links joins NOT_PARSE_ERRORS beside allow_pipe_separator's: rledger reports option errors when it loads. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(compat): accept E8005 for a Python module name in a build without the Python runtime The slim release build (no default features) reports a Python module name as E8005, runtime not compiled in, where the default build reports E8004. A row's code may now list alternatives (E8004|E8005); each is still an exact assertion on the line. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(surface-parity): admit the upstream-check case ledgers' known surface differences #3055's corpus includes crates/rustledger/tests, so it runs the upstream-check cases. Five hit existing classes (no disk for document roots, a file map's own words for a load error, the LSP's E8006 for an unsupported plugin), and one is new and OPEN: a check_closing balance is at <check_closing>, 0 in check and in the ledger file on every other surface. 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
A drift guard for the "surface X doesn't do what
rledger checkdoes" bug class (#2937, #2946, #2952, #2971, #2857, ...), plus the first divergence it found.New crate
rustledger-surface-parity-tests(tests/surface_parity.rs). Every ledger of a shared corpus goes through every surface, each called natively as Rust:rledger check --format json, in-process throughcmd::check::run_with_writervalidateSource,ParsedLedger(+ restored from its cache),validateMultiFile,Ledger.fromFiles(+ restored from its cache)validate,load,validate-file,load-file;query,query-fileall_diagnosticsfor a ledger with no includes; the real server through the protocol harness (lsp_protocol/harness.rs) for a ledger with includes, collecting what it publishes for every fileCorpus:
tests/compatibility/files,tests/fixtures(parse, booking, validation, plugin, include and option errors, lima-tests),tests/regressions, the loader's and CLI's test ledgers, and the hand-writtensurface_agreementcases. That is 349 ledgers, 18 of them with includes.Assertions:
(file, line, code, message, severity)and must be identical, compared as whole sorted lists, with no substring matching. Normalization is limited to representation: a missing location becomes line 0 (check's<given path>:1stand-in is told apart by passing the entry as<dir>/./<entry>), and an in-memory<string>is named as the entry file. The LSP's fixed message layout (<message> (<date>)pluscontext:/hint:lines) is parsed exactly, back into the validator's message.ParsedLedger/Ledger(fresh and from cache) and FFIload/load-filemust match the validating loadcheckruns, fingerprinted by kind, date, posting accounts, units and costs.query/query-filemust giverledger query --format json's rows on every error-free ledger (104 ledgers).Allowlist. Legitimate differences are listed in
ALLOWED/ALLOWED_BOOKING. Each entry names its surfaces, the exact(file, code, line)items it removes, and a reason. An entry that no longer applies fails the test, so a fixed divergence forces its entry out. The entries:documentsroots (E7006, discovery), relativedocumentpaths.validate-fileconfines includes by default.load-fileis run withallow-unrestricted-includesand agrees withcheck.To make the surfaces callable natively. WASM gains a hidden
surface_probemodule;validateSource/validateMultiFileare split into a Rust core plus theJsValuewrapper, so the probe runs the exports' own bodies. The FFI component gains anrlibtarget and a hiddensurface_probethat re-exports the functions its exports delegate to. Three doc comments were reshaped for the lint that now applies to them.Fix (separate commit): the LSP now runs document discovery for
option "documents"ascheckdoes. Before, it built the plugin context only when there was apluginline, in single-file mode and in multi-file mode, sodocumentsalone never ran discovery. With apluginline, a single file's source map named/tmp/rustledger-lsp-buffer.beancount, so a relative documents directory resolved under/tmp. Regression test:test_document_discovery_runs_as_check_runs_it.Why
Each earlier fix in this class came with a hand-written case. This test is the differential half: it covers inputs nobody wrote a case for, so a re-derivation that drifts goes red in the normal test job.
Open divergence (not fixed, needs a decision)
checkrenders the loader'sLoadErrors itself (cmd/check.rs). It uses the codesrledger explaindocuments (E0001 unreadable include, E0002 include cycle, E0004 duplicate include, E0005 glob without a match), its own wording ("failed to read included file ..."), and its own placement: a duplicate include goes on line 1 of the duplicated file. Every other surface takes these errors fromrustledger_loader::process, the canonical renderer, which codes every oneLOADand gives a duplicate include no line. Making them agree means either moving the E000x mapping intoprocess, which changes the wire code for WASM, the FFI and the LSP (LOADis asserted in LSP and WASM tests and listed inexplain), or makingcheckemitLOAD, which drops the documented codes and--exclude-rules E0002. That choice is the maintainer's, so these cases are an allowlist entry marked OPEN, which will fail once either side changes.How to test
The crate is a workspace member, so CI's
cargo nextest run --workspace --all-featuresruns it. It takes about 6 s warm, and up to about 15-25 s on a first run, when the Python-plugin fixtures compile the plugin runtime. To check that the guard can fail: revert the LSP commit and the test reportsdoc_discovery_unknown.beancount: lsp disagrees with rledger check.No cached output changes (the WASM changes are refactors), so there is no cache version bump.
🤖 Generated with Claude Code