test: pin the display-precision fallback's cost/balance/price arms directly - #262
Merged
Merged
Conversation
…rectly rustledger WIT 3.8+ engines ship options.display_precision (rustledger#1766, rustledger#1808), so integration tests running against such a component no longer reach the fallback's cost/balance/price tracking arms and the 100% coverage gate trips in rustledger's downstream job. Pin those arms with a direct unit test so the fallback stays covered and correct for engines that predate the field, regardless of which engine the suite runs against.
robcohen
added a commit
to rustledger/rustledger
that referenced
this pull request
Jul 18, 2026
…ield directly The declarations-only export broke rustfava for real (2 test failures, not just coverage): its loader treats a non-empty display_precision as THE per-currency precision map and only falls back to local inference when the field is empty — so a partial declarations map starved every undeclared currency. The de-facto wire contract since the tracker era is the full resolved map, and that is also what a rendering embedder actually wants. display_precision is again resolved_precisions(): fixed declarations where present, canonical inference otherwise, every observed currency listed. The rustfava-side coverage for its now-bypassed fallback lands in rustledger/rustfava#262.
robcohen
added a commit
to rustledger/rustledger
that referenced
this pull request
Jul 19, 2026
…on (WIT 3.8.0) (#1808) * feat: session.format renders held entries with ledger display precision (WIT 3.8.0) The #1766 format surface: `session.format` renders the HELD directives to canonical beancount text honoring the ledger's per-currency display precision, built from the held entries plus the held options. - rustledger-core: `DisplayContext::from_directives` is now THE canonical builder (moved verbatim from the loader): amount-scan inference, then `option "display_precision"` overrides, then commodity `precision:` metadata. New `resolved_precisions()` exports the per-currency answer for the wire. The loader's `build_display_context` delegates. - rustledger-ffi-wasi: `PrecisionTracker` deleted — it was a re-derivation of DisplayContext inference that OVERWROTE the option-derived `display_precision`, so the user's explicit option never crossed the boundary, and the two load paths disagreed (`load_source` shipped inference-only, `load_file` option-only). `build_ledger_options` now takes the ledger's DisplayContext and ships the canonical resolution. - rustledger-ffi-component: WIT 3.8.0 + API_VERSION 3.8; `session.format` builds the context via `from_directives` and renders through the same `canonicalize_directives` path as the free format interface. Integer metadata now crosses the wire as `number`, not `text` — as text, a session round-trip turned `precision: 4` into `precision: "4"`. Part of #1766. * fix: ship declared precisions across the boundary, not inference The rustfava CI job caught the first cut shipping RESOLVED precisions (inference frozen as fixed entries for every observed currency), which starved rustfava's documented undeclared-currency fallback (its tests passed; only its 100% coverage gate tripped). Shipping inference as declarations was also semantically wrong: it would pin a consumer's precision against later entry-set changes, and inference is derivable from the entries themselves wherever they travel. `ledger-options.display-precision` now carries DECLARATIONS only — `option "display_precision"` entries plus commodity `precision:` metadata, precedence-resolved by the canonical DisplayContext (`declared_precisions()` replaces `resolved_precisions()`). `session.format` behavior is unchanged: its `from_directives` stage-1 scan re-infers from the held entries, so undeclared currencies land on the same mode the loader would pick. * fix: restore resolved precisions on the wire; rustfava consumes the field directly The declarations-only export broke rustfava for real (2 test failures, not just coverage): its loader treats a non-empty display_precision as THE per-currency precision map and only falls back to local inference when the field is empty — so a partial declarations map starved every undeclared currency. The de-facto wire contract since the tracker era is the full resolved map, and that is also what a rendering embedder actually wants. display_precision is again resolved_precisions(): fixed declarations where present, canonical inference otherwise, every observed currency listed. The rustfava-side coverage for its now-bypassed fallback lands in rustledger/rustfava#262.
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.
rustledger WIT 3.8+ engines ship
options.display_precision(rustledger#1766, implemented in rustledger#1808) — the "planned FFI field" the fallback's guard comment anticipates. Against such a component, integration tests no longer reach_compute_display_precision's cost/balance/price tracking arms, and the 100% coverage gate trips in rustledger's downstreamrustfava tests against PR componentjob.This pins those arms with a direct unit test (cost per-unit and total shapes, number-less cost, balance and price-directive amounts, repeat-currency accumulation, and a non-tracked entry type), so the fallback stays covered and correct for engines that predate the field — regardless of which engine the suite runs against.
Verified locally: full suite at 100.00% coverage and 666 passed against the rustledger#1808 debug component.
Once rustfava requires a 3.8+ engine, the fallback (and this test) can be deleted outright — the engine-provided field supersedes it, and the local re-derivation has known drift from the canonical inference (per-unit-first cost sampling where rustledger core samples total-first).
🤖 Generated with Claude Code
https://claude.ai/code/session_013gJH7uBBF9Xw9et9QFRcsU