Repository navigation
feat: session carries ledger options over the WIT boundary (3.7.0) - #1805
Conversation
Closes the #1766 design debt for the query surface: every entries-accepting function ran with default ledger options because the contract had no way to carry them alongside an entry list. - WIT 3.7.0 adds session.from-entries-with-options(entries, options): the session becomes the canonical options carrier, so query builds its account classifier from the ledger own name-* roots (the L5 POSSIGN/ACCOUNT_SORTKEY note) and info() echoes what was provided; new entry-consuming methods inherit the held options for free. - from-entries keeps its shape and documents the default; the builder.query-entries/filter/clamp free functions are doc-soft-deprecated in favor of the session. - format-loaded documents honestly that display-precision and render-commas are not honored ANYWHERE yet (the rendering pipeline has no precision machinery, CLI included) - options-aware rendering stays tracked in #1766 rather than shipping a session.format that ignores the options it advertises. - API_VERSION 3.7 in lockstep (parity test + wit-version-gate). - Tests: SessionState unit tests pin the POSSIGN sign flip under renamed roots and the info() echo; a wasmtime parity test drives the same observable through the real component boundary. Scope notes recorded on #1766: ops::clamp hardcoding of Equity:Opening-Balances is a GLOBAL pre-existing gap (CLI included), not an entries-surface asymmetry, and needs an ops-level config. Part of #1766.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📊 Benchmark Results
vs main branch (2026-07-18)
What do these numbers mean?
|
There was a problem hiding this comment.
Pull request overview
Extends the rustledger:ledger WIT/component embedding surface so a session reconstructed from host-held entries can retain and use the originating ledger options (notably renamed name_* account roots), fixing entries-based query behavior to match load-time classification semantics across the WIT boundary.
Changes:
- Bumped WIT package to
rustledger:[email protected]and runtimeAPI_VERSIONto3.7, addingsession.from-entries-with-options(entries, options). - Implemented the new session constructor in the component guest and plumbed options into
SessionStatesosession.queryclassifies with ledger-specific roots. - Added unit + component-boundary parity tests covering POSSIGN behavior under renamed roots and
info()option echoing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/rustledger-ffi-component/wit/world.wit | WIT 3.7.0 bump; adds from-entries-with-options and clarifies default-options behavior for entries-based surfaces. |
| crates/rustledger-ffi-component/src/lib.rs | Bumps API_VERSION to 3.7 and exposes the new GuestSession::from_entries_with_options entrypoint. |
| crates/rustledger-ffi-component/src/convert.rs | Adds options-carrying SessionState::from_entries_with_options, wires options into session.query, and adds unit tests for renamed-root classification + info() echo. |
| crates/rustledger-ffi-component-tests/tests/parity.rs | Adds a wasmtime parity test that drives the renamed-root POSSIGN observable through the real component boundary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
- parity test fixture: the backslash-newline continuations stripped posting indentation, making the ledger unparsable - the sole end-to-end test failed whenever the component wasm existed (verified by building the wasm and running it; the local pass was the skip path). Rebuilt with concat! and real indentation; both branches now assert errors-empty, use first()/expect, and assert the POSITIVE value alongside the negative (drift-guard rule) - from_entries_with_options sanitizes host options: empty name-* roots fall back to defaults (a zero-initialized guest record would silently break every classification); duplicates documented as host-owned - WIT and rustdoc scope the "canonical carrier" claim to what the held options DO today (classification + info echo); booked-time options cannot re-apply and clamp/rendering do not consume options yet - API_VERSION doc history gains the 3.7 entry; README steers held-entry queries at from-entries-with-options instead of the soft-deprecated query-entries
|
Deep review (21 agents, adversarial verification): 9 findings, all addressed in f8f8f95. The merge-blocker: the parity test's fixture used backslash-newline string continuations, which strip posting indentation — the ledger was unparsable and the sole end-to-end test of The rest:
Component + parity suites green (parity run against the built wasm this time), clippy/doc clean. |
Copilot review: debug-substring contains("-100") also matches -1000
and passes vacuously on non-numeric cells; both the unit and parity
tests now pattern-match query-value::number and assert_eq the exact
value. API_VERSION history was already updated in f8f8f95.
What
Closes the #1766 design debt for the query surface: entries-accepting functions ran with default ledger options because the contract had no way to carry them.
session.from-entries-with-options(entries, options)— the session becomes the canonical options carrier.queryclassifies accounts with the ledger's ownname-*roots (the L5POSSIGN/ACCOUNT_SORTKEYnote in convert.rs),info()echoes what was provided, and future entry-consuming methods inherit the held options for free.from-entrieskeeps its shape and documents the default; thebuilder.query-entries/filter/clampfree functions are doc-soft-deprecated in favor of the session.API_VERSION→ 3.7 in lockstep (enforced by the parity test + wit-version-gate).SessionStateunit tests pin the POSSIGN sign flip under renamed roots and theinfo()echo; a wasmtime parity test drives the same observable through the real component boundary.Deliberate scope reductions (recorded on #1766)
session.formatis not added: the rendering pipeline has nodisplay-precision/render-commasmachinery anywhere (CLI included), so it would ignore the options it advertises — exactly the debt WIT contract: entries-accepting surfaces classify/render with default ledger options #1766 describes, one layer deeper.format-loaded's docs now state this honestly.ops::clamp'sEquity:Opening-Balanceshardcoding turned out to be a global pre-existing gap (all callers, CLI included), not an entries-surface asymmetry — it needs an ops-level config, tracked separately.How to test
cargo test -p rustledger-ffi-component -p rustledger-ffi-component-tests. rustfava adoption (passing its load-time options into the filtered-query path) rides the next release train together with the ingest backend.Part of #1766.
🤖 Generated with Claude Code
https://claude.ai/code/session_013gJH7uBBF9Xw9et9QFRcsU