Repository navigation
chore: pin CostNumber wire parity across all five mirrors - #1740
Merged
Merged
Conversation
CostNumber crosses process boundaries through five hand-written mirrors unified only by convention: core serde, plugin-types CostNumberData, wasm CostNumberJson, ffi-wasi InputCostNumber (all kind-tagged JSON), and the WIT cost-number variant (positional). Each JSON mirror pinned its own shape against its own literals — nothing asserted the shapes are THE SAME, the compound variant was entirely unpinned in the core and wasm mirrors, and the WIT lowering/raising had no tests at all (sweep finding W1). Add: - rustledger-wasm/tests/cost_number_wire_parity.rs — one canonical fixture set (all four variants, values chosen to pin scale preservation: "5.00" stays "5.00") that every JSON mirror is held to: core/plugin/wasm serialize to it byte-identically; plugin and ffi-wasi ingress (Deserialize-only) accept it; core round-trips it. Native-only test with plugin-types + ffi-wasi as cfg(not(wasm32)) dev-deps. - ffi-component unit tests for the WIT mirror, both directions: cost_number_from_core lowers every core variant to the same-named WIT arm with scale-preserved string payloads, and input_cost_number raises every WIT arm to the matching InputCostNumber variant. A new CostNumber variant now forces non-exhaustive-match updates at exactly these pinned sites. - cross-references between the per-crate pin tests and the new parity suite so the next person finds the full picture. No production code changes. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Pins and verifies wire-format parity for the CostNumber family across the project’s five “mirror” representations (core/plugin/wasm/ffi-wasi JSON mirrors + ffi-component WIT mirror), by centralizing parity fixtures and adding bidirectional WIT mapping tests.
Changes:
- Added a canonical fixture-driven parity test in
rustledger-wasmto ensure all JSON mirrors serialize/deserialize the same shapes for allCostNumbervariants. - Added
rustledger-ffi-componentunit tests to pin core↔WIT lowering and WIT↔FFI ingress raising forcost-number. - Updated dev-dependencies / lockfiles and supply-chain metadata to support the new test-only coverage.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| supply-chain/imports.lock | Updates publisher import record for crossbeam-epoch (version/date). |
| supply-chain/config.toml | Removes no-longer-needed crossbeam-epoch exemptions. |
| crates/rustledger-wasm/tests/cost_number_wire_parity.rs | New cross-mirror JSON parity fixture suite (core/plugin/wasm serialize; plugin/ffi-wasi deserialize; core round-trip). |
| crates/rustledger-wasm/Cargo.toml | Adds host-only dev-deps (rustledger-plugin-types, rustledger-ffi-wasi) for the parity test. |
| crates/rustledger-plugin-types/tests/cost_number_wire_format.rs | Adds cross-reference comment to the new parity suite / WIT tests. |
| crates/rustledger-ffi-component/src/convert.rs | Adds WIT cost-number lowering/raising unit tests and imports. |
| Cargo.lock | Reflects added host-only dev-dependency edges for rustledger-wasm. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📊 Benchmark Results
vs main branch (2026-07-10)
What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
zip() truncates to the shortest iterator; a variant dropped from any mirror list would have silently shrunk the parity guarantee. Co-Authored-By: Claude Fable 5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
robcohen
added a commit
that referenced
this pull request
Jul 11, 2026
…needs them (#1758) The parity-test dev-deps (#1740) used workspace inheritance, which bakes a version requirement into the published package's dev-deps — cargo publish of rustledger-wasm then fails whenever the sibling isn't on crates.io at that exact version yet (broke the v0.21.0 publish: the script orders wasm before ffi-wasi). Path-only dev-deps are stripped at publish, which is exactly right for test-only siblings. Verified: parity test still runs; cargo publish --dry-run packages clean. Co-authored-by: Claude Fable 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
Pins wire-format parity for the
CostNumberfamily across all five hand-written mirrors. Test-only — no production code changes.Why
Phase-1 correctness sweep, finding W1 (marshaling family).
CostNumbercrosses process boundaries through five mirrors unified only by convention:rustledger_core::CostNumberserde (kind-tagged JSON)rustledger_plugin_types::CostNumberData(plugin wire + Python shim)rustledger_wasm::types::CostNumberJson(TypeScript clients)rustledger_ffi_wasi::InputCostNumber(builder ingress, Deserialize-only)cost-numbervariant (component model, positional)Each JSON mirror pinned its own shape against its own literals, so a crate could change its pin and shape "consistently" without noticing the other four exist. Concretely: nothing asserted the shapes are the same, the
compoundvariant was entirely unpinned in the core and wasm mirrors, and the WIT lowering/raising (cost_number_from_core/input_cost_number) had no tests at all.How
rustledger-wasm/tests/cost_number_wire_parity.rs— one canonical fixture set covering all four variants (values chosen to also pin scale preservation:"5.00"must not collapse to"5"). Every JSON mirror is held to it in one place: core/plugin/wasm must serialize to it byte-identically; plugin and ffi-wasi ingress must accept it; core must round-trip it. Hosted in the wasm crate (already the one with native-onlyserde_json), withplugin-types+ffi-wasiascfg(not(wasm32))dev-dependencies — test-only, nothing enters the wasm32 build.InputCostNumbervariant. A futureCostNumbervariant now forces non-exhaustive-match updates at exactly these pinned sites.The registry's alternative — a shared lower/raise helper — doesn't fit here: the mirrors deliberately differ in value type (Decimal vs String) and capability (ingress-only vs bidirectional), so the contract is best enforced by fixture, not by code sharing.
Testing
New suites green (2 parity tests × 4 variants × 4 JSON mirrors; 2 WIT-direction tests); full plugin-types/wasm/ffi-component suites green; clippy
--all-features --all-targets -D warnings+ fmt clean.🤖 Generated with Claude Code