Repository navigation
fix(wasm): run Early validation over the stream as written, so an E3002 on a transaction that books is reported - #3027
Merged
Merged
Conversation
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❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
robcohen
force-pushed
the
fix/wasm-early-validation
branch
4 times, most recently
from
November 25, 2026 23:23
f74363b to
aacc656
Compare
…02 on a transaction that books is reported (#3001) WASM validateSource and ParsedLedger, and the FFI component's source surfaces (validate, load, batch), load without validation and validate the load themselves. They ran the Early phase over the booked directives, where booking had already filled elided amounts in, so an E3002 on a transaction booking still books (an elided posting beside a cost-bearing one, two fully elided postings beside a second currency, an elided `Assets:B USD` beside a fully elided posting) was missing there while rledger check and bean-check report it. The loader gains LoadOptions::retain_pre_booking_directives, which keeps the exact stream its Early phase runs on (sorted, synth plugins applied, unbooked) in Ledger::pre_booking_directives. The WASM and FFI single- source loads set it and run Early over that stream, Late over the booked one, as process() does. A refused transaction still has one E3002 (#2998). Surface-agreement case covering the issue's three inputs (CLI, loader, WASM, FFI, LSP), plus a native ParsedLedger/validateSource test mixing them with a refused transaction. WASM cache 130 -> 131; loader cache unchanged. Closes #3001 Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
fix/wasm-early-validation
branch
from
November 26, 2026 00:39
aacc656 to
845db06
Compare
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 single-source surfaces (
validateSource,ParsedLedger) and the FFI component's source surfaces (validate,load,batch) load without validation and then validate the load themselves. They ran validation's Early phase over the booked directives. By then booking had filled the elided amounts in, so anE3002on a transaction that booking still books never showed up on those surfaces.rledger checkand bean-check 3.2.3 both report it.The issue's three inputs, with lines checked against bean-check 3.2.3:
rledger checkAssets:B 10 USD/Assets:C HOOL {2 USD}/Assets:CAssets:A 1 USD/Assets:B 2 EUR/Assets:C/Assets:DAssets:DAssets:A 1 USD/Assets:B USD/Assets:CAssets:BHow
The fix reuses the loader's own pipeline (
sort → synth-plugins → Early → book → regular-plugins → Late → finalize) and does not rebuild it on the WASM/FFI side:LoadOptions::retain_pre_booking_directiveskeeps a copy of the exact streamprocess()hands to Early (sorted, synth plugins applied, not booked) inLedger::pre_booking_directives. It defaults to off, so other loads pay nothing.load_and_booksets the option, andrun_validationruns Early overProcessedLedger::pre_booking. Late still runs over the booked stream minusbooking_refused, as before. Both phases now get the same streams the validating loader gives them.ffi_wasi::helpers::load_sourcesets the option too.semantic_validation_errorsruns Early overLoadResult::pre_booking_directives.validateMultiFile,Ledger.fromFiles, the FFI*-filesurfaces) already validate through the loader and needed no change.E3002. The compat(validate): two amount-less postings in one currency are one error, on the second posting's line #2998 restating-BOOKhandling is unchanged.CACHE_VERSIONgoes from 130 to 131, because theParsedLedgerpayload's findings move. The loader cache is unchanged: parsed output did not change.Breaking
E3002(andvalid: false) where these surfaces used to report nothing.LoadOptions,Ledgerandffi_wasi::helpers::LoadResulteach gain a public field, and none of them is#[non_exhaustive]. CHANGELOG has a Breaking entry and a Fixed entry.How to test
cargo test -p rustledger-loader --all-features --test surface_agreement_test: the newSurfaceCasewith the three inputs runs on the CLI, loader, WASM, FFI and LSP surfaces.cargo test -p rustledger-ffi-component report_the_shared_findings: fails on main, passes here.cargo test -p rustledger-wasm e3002_on_a_transaction_that_books_is_a_finding: a native test that puts the three inputs beside a refused transaction. It checks thatParsedLedgerlists the refusedE3002inparse_errorsand the three others as validation findings, and that thevalidateSourceview gives each of the four once. It fails without the fix.cd crates/rustledger-wasm && wasm-pack test --node -- --test wasm_surface_agreementpasses.cargo test -p rustledger-wasm -p rustledger-validate -p rustledger-loader --all-features, the FFI crates,rustledger-lsp,cargo build -p rustledger-wasm --target wasm32-unknown-unknown, and clippy-D warningson the changed crates.Closes #3001
🤖 Generated with Claude Code