Skip to content

feat(component): ComponentSession handle over the WIT resource session#175

Merged
robcohen merged 1 commit into
mainfrom
feat/component-session-engine
Jun 17, 2026
Merged

feat(component): ComponentSession handle over the WIT resource session#175
robcohen merged 1 commit into
mainfrom
feat/component-session-engine

Conversation

@robcohen

Copy link
Copy Markdown
Member

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 a ComponentSession that 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.
  • Each session owns its own wasmtime store/instance (the resource handle is bound to them): a file session keeps its WASI pre-open, sessions don't contend on a shared store, and file sessions map /work guest paths back to host paths in info().

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 _unmarshal for clamp — the root of the shape-drift bug class. clamp here runs on the held core directives, so cost basis survives with no WIT→core→WIT round-trip.

Scope

Engine capability + tests only. Wiring Fava's loader/query/filters to hold and reuse a session (the part that deletes _entries_to_source and the clamp dict path) is the next step in #173. ruff + mypy clean; 16 component tests pass (incl. new open_session_* tests covering query/filter/clamp on a held ledger and host-path resolution).

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>
@robcohen robcohen merged commit 7cbf404 into main Jun 17, 2026
29 checks passed
@robcohen robcohen deleted the feat/component-session-engine branch June 17, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant