Context
rustledger's stateful session (rustledger#1421, from this repo's #173 design) has zero adopters here: our query endpoint runs against filtered entries (g.filtered.entries_with_all_prices), and until now a session could only be built from source or a file path. So every BQL query ships the full filtered directive list over the wire (builder.query-entries) and re-converts it — per query.
rustledger#1755 adds session.from-entries(list<directive>) -> session (WIT 3.4.0): pay the marshaling once per directive set, then query runs against directives held inside the component.
Proposed adoption
RustledgerComponentEngine gains open_session_entries(entries_json) calling [static]session.from-entries (same pattern as the existing open_session/open_session_file).
RLConnection caches one ComponentSession keyed on the identity of the entries sequence it was constructed with (fava constructs a connection per request but the filtered entries object is cached by fava's g.filtered layer — verify the identity survives across requests for an unchanged filter; if not, key on (ledger mtime, filter string)).
execute() uses session.query(query_string) when a cached session matches; falls back to query_entries otherwise (and always for engines without 3.4.0 — probe once via the WIT version in util.types or hasattr).
- Invalidate the cache on ledger reload (
load_file) and filter change.
Notes from the contract
- Conversion-failing directives are dropped (mirrors
query-entries); survivor count observable via info().entries.
- Held entries carry no ledger options — keep consulting load-time
info() for options.
Requires a rustledger release carrying WIT 3.4.0 (component pin bump).
Context
rustledger's stateful
session(rustledger#1421, from this repo's #173 design) has zero adopters here: our query endpoint runs against filtered entries (g.filtered.entries_with_all_prices), and until now a session could only be built from source or a file path. So every BQL query ships the full filtered directive list over the wire (builder.query-entries) and re-converts it — per query.rustledger#1755 adds
session.from-entries(list<directive>) -> session(WIT 3.4.0): pay the marshaling once per directive set, thenqueryruns against directives held inside the component.Proposed adoption
RustledgerComponentEnginegainsopen_session_entries(entries_json)calling[static]session.from-entries(same pattern as the existingopen_session/open_session_file).RLConnectioncaches oneComponentSessionkeyed on the identity of the entries sequence it was constructed with (fava constructs a connection per request but the filtered entries object is cached by fava'sg.filteredlayer — verify the identity survives across requests for an unchanged filter; if not, key on(ledger mtime, filter string)).execute()usessession.query(query_string)when a cached session matches; falls back toquery_entriesotherwise (and always for engines without 3.4.0 — probe once via the WIT version inutil.typesor hasattr).load_file) and filter change.Notes from the contract
query-entries); survivor count observable viainfo().entries.info()for options.Requires a rustledger release carrying WIT 3.4.0 (component pin bump).