Skip to content

Adopt session.from-entries for the filtered-query path (wire-free BQL after first query per filter) #249

Description

@robcohen

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

  1. RustledgerComponentEngine gains open_session_entries(entries_json) calling [static]session.from-entries (same pattern as the existing open_session/open_session_file).
  2. 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)).
  3. 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).
  4. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions