Repository navigation
fix(wasm)!: report multi-file errors as rledger check and the FFI do - #2971
Merged
Merged
Conversation
The multi-file WASM surfaces (validateMultiFile, validateWithHost, parseMultiFile, Ledger, queryMultiFile, queryWithHost) diverged from rledger check, the FFI and the single-source surfaces three ways: - A parse error's message was prefixed with its file path, which is already in the error's file field (#2961). load_errors_to_errors now maps parse errors through the loader's parse_errors_to_ledger_errors and places them with the new ledger_error_to_wasm. - A loader error (validation finding, booking error, include LOAD error) had a null end and no hint, because From<LedgerError> cannot locate the end and dropped the hint (#2964). From now copies the hint, and ledger_error_to_wasm locates the end of source_span with SourceMap::locate; every surface holding the load's SourceMap converts through it. - queryMultiFile / queryWithHost refused on a parse error before process, so no Ledger existed and no option diagnostic was listed (#2960). They now take the parse errors out and process the rest, as Ledger.fromFiles does, and list Ledger::query_option_errors beside them. The parse_error_mapping_parity drift guard now compares every field, the end included, and adds two tests: validateSource, validateMultiFile and Ledger.fromFiles place every finding at the same start and end on the same ledgers, and the multi-file surfaces keep E8001's hint. The queryMultiFile skip and the prefix stripping in the wasm-pack tests are gone. WASM cache v109 (v108 is held by #2970). Closes #2960 Closes #2961 Closes #2964 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?
|
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 |
… hints as they are - CHANGELOG: the dropped file prefix on multi-file parse error messages moves under Breaking (rustfava unaffected; mcp-server formatErrors no longer names the file twice), with a Fixed bullet pointing to it. - CHANGELOG: multi-file hints match rledger check, a LOAD error carries none, and validateSource still differs on E2001 (#2972); in a parse-error refusal, queryMultiFile/queryWithHost now report other load errors as LOAD, where they were code-less parse-phase errors. - validate_with_filesystem stays pub: pub(crate) in the private api module trips clippy::redundant_pub_crate; say so in a comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 13, 2026
WASM cache: main holds v107 (#2969), #2970 holds 108 and #2971 holds 109, so this PR moves from 106 to 110. The v107 note now says v106 was held here and never released; loader cache stays 73. 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
WASM's multi-file surfaces (
validateMultiFile,validateWithHost,parseMultiFile,Ledger(fromFiles,getErrors,query),queryMultiFile,queryWithHost) now report errors the wayrledger check, the FFI component and the single-source surfaces (validateSource,ParsedLedger) do.#2961: path prefix on parse error messages
load_errors_to_errorsbuilt each parse error fromparse_error_fieldsand then wrote<path>:in front of the message, even though the path is already infile. It now maps parse errors through the loader's canonicalrustledger_loader::parse_errors_to_ledger_errors(the function behind the FFI) and places them with a newhelpers::ledger_error_to_wasm. The message is the parser's text unchanged.parse_error_fieldsstays only for the single-source surfaces, which have noLoadErrororSourceMap. The paired comments on both sides are updated.#2964: null ends and missing hints on loader findings
From<LedgerError> for Errorsethint: None, and it could not locate the end without the load'sSourceMap.Fromnow copieshint, so the multi-file surfaces give a finding or booking error the hintrledger check --format jsongives it (E8001's documents-folder hint among them). E2001 has none there, as incheck;validateSourcegives it one throughvalidation_error_to_wasm's hint, note, context fallback, a pre-existing difference now tracked in WASM validateSource gives E2001 a hint that rledger check and the multi-file surfaces do not #2972. ALOADerror never carries a hint: the loader gives it none, andcheckadds its include-cycle hint itself (crates/rustledger/src/cmd/check.rs).ledger_error_to_wasm(LedgerError, &SourceMap)builds onFromand adds the end ofsource_span, located infile_idthrough the canonicalSourceMap::locate. The end stays null when there is no span or start, or when the file id is a placeholder.SourceMapnow converts through it:reported_ledger_errors(which now takes the map),parseMultiFile, and the booking errors of the single-sourceload_and_book.load_errors_to_errors's include-site arm also locates throughSourceMap::locate.#2960:
queryMultiFilelists no option diagnostics on a source that fails to parsequery_with_filesystemrefused on a blocking load error beforeprocess, so noLedgerexisted. It now does whatLedger.fromFilesdoes: it takes the parse errors out (take_parse_errors), runsprocessover whatever parsed, refuses onparse_blocks_queries || ledger.blocks_queries(), and lists parse errors, then ledger errors, thenLedger::query_option_errors. In that refusal, other load errors are now reported byprocessasLOAD, the same as on the path without a parse error, where they were code-lessphase: parseerrors.Tests
parse_error_mapping_parity(crates/rustledger-wasm/src/helpers.rs):load_errors_to_errorsand single-sourceparse_errors_to_wasm. The prefix stripping is gone.test_multi_file_findings_are_placed_as_validate_source_places_them: on the same ledgers (BOM plus balance, unbalanced transaction with multi-byte account, E4003 booking error, parse error plus a finding),validateSource,validateMultiFileandLedger.fromFilesgive every finding the same code, severity, start and end.test_multi_file_surfaces_keep_a_loader_findings_hint: E8001's documents-folder hint reachesvalidateMultiFileandLedger.fromFiles.wasm_error_columns.rsexpects the real ends onvalidateMultiFileand now coversLedger(fresh and from cache) too.wasm_query_option_errors.rsdrops the prefix rewrite and thequeryMultiFileskip, so therefused-booking-method-with-parse-errorcase now runs throughqueryMultiFile.wasm_surface_agreement.rsdropsMULTI_FILE_PREFIX.Cache
WASM
CACHE_VERSION109: aLedgerarchives its errors and aParsedLedgerarchives its booking errors. 108 is held by #2970 and 106 by #2931. The loader cache is unchanged at 73.How to test
Gates run locally:
cargo fmt --all --check,cargo clippy --workspace --all-features --all-targets -- -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --all-features --no-deps,cargo test -p rustledger-wasm -p rustledger-loader,wasm-pack test --node.Breaking (WASM wire output, as in #2946 and #2969): a host that matched on the prefixed parse-error message text must drop the prefix. The CHANGELOG lists it under
### Breaking, with a Fixed bullet pointing to it. rustfava is unaffected, since it embeds the FFI component, not WASM;packages/mcp-server'sformatErrorsbenefits, as it no longer names the file twice (file:line:col: file: message). No Rust public type changed.Closes #2960
Closes #2961
Closes #2964
🤖 Generated with Claude Code