feat(component): ComponentSession handle over the WIT resource session#175
Merged
Conversation
Phase 2 foundation for the boundary redesign (rustfava #173). Wraps the rustledger `resource session` (shipped in v0.16.3): `open_session(source)` / `open_session_file(path)` return a `ComponentSession` that holds the booked ledger inside the component, and `info`/`query`/`filter`/`clamp` run against the held ledger server-side — no source re-parse, no directive list shuttled across the FFI. Each session owns its own wasmtime store/instance (the resource handle is bound to them), so a file session keeps its WASI pre-open and sessions don't contend on a shared store; file sessions map `/work` guest paths back to host paths in `info()`. This is the engine capability; wiring Fava's loader/query/filters to hold and reuse a session (replacing `_entries_to_source` + the clamp dict round-trip) is the next step. Tests cover query/filter/clamp on a held ledger and host- path resolution for file sessions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 18, 2026
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.
Phase 2 foundation for the boundary redesign (#173). Wraps rustledger's
resource session(shipped in v0.16.3, rustledger beancount#1421).What
RustledgerComponentEngine.open_session(source)/open_session_file(path, …)return aComponentSessionthat holds the booked ledger inside the component.session.info()/query(q)/filter(begin, end)/clamp(begin, end)run against the held ledger server-side — no source re-parse, no directive list marshalled across the FFI per call./workguest paths back to host paths ininfo().Why
This is the engine capability that lets Fava stop re-parsing source for queries (
_entries_to_source) and stop round-tripping directive lists through_unmarshalfor clamp — the root of the shape-drift bug class.clamphere runs on the held core directives, so cost basis survives with noWIT→core→WITround-trip.Scope
Engine capability + tests only. Wiring Fava's
loader/query/filtersto hold and reuse a session (the part that deletes_entries_to_sourceand the clamp dict path) is the next step in #173. ruff + mypy clean; 16 component tests pass (incl. newopen_session_*tests covering query/filter/clamp on a held ledger and host-path resolution).