Skip to content

feat(component): route queries through query-entries; wire get_engine#176

Merged
robcohen merged 1 commit into
mainfrom
feat/component-query-entries
Jun 17, 2026
Merged

feat(component): route queries through query-entries; wire get_engine#176
robcohen merged 1 commit into
mainfrom
feat/component-query-entries

Conversation

@robcohen

Copy link
Copy Markdown
Member

Reroutes the rustfava query path to the component's typed query-entries (rustledger v0.16.4, beancount#1423) and wires the engine selector so the component backend is reachable end-to-end. JSON-RPC stays the default (RUSTFAVA_RUSTLEDGER_BACKEND=component opts in) — no behavior change on the default path; this fixes the component path (part of #173).

What

  • engine: RUSTLEDGER_VERSION → v0.16.4; component_engine.query_entries marshals a directive set in and calls builder.query-entries.
  • query_shell: RLConnection.execute queries the directive set directly via query_entries when the engine supports it, instead of re-rendering the filtered entries to beancount source (_entries_to_source) and re-parsing — the latter produced text the parser rejected (the query crashes). JSON-RPC keeps the source path, so _entries_to_source stays until that surface is dropped.
  • routing: backend.get_engine selector (JSON-RPC default); load/query/filter/is_encrypted now go through it so the component backend is actually exercised.

Why

Fava queries filtered entry subsets. A full-ledger session can't serve that; the right primitive is the typed entry-set query-entries (symmetric with clamp/filter), so the subset crosses the WIT contract faithfully with no source re-render. See the #173 discussion.

Impact

Running the full suite via the component (RUSTFAVA_RUSTLEDGER_BACKEND=component) eliminates the query-crash class. Remaining failures are snapshot diffs + a few inventory/tree shape issues (tracked in #173 for the next pass). The default JSON-RPC path is unchanged.

Tests / checks

New query_entries engine test (matches source query); component tests green; mypy clean. The default path is unaffected so the JSON-RPC-backed CI passes.

Note: the routing touches loader.py/query.py/filters.py, which carry pre-existing ruff debt (function-level imports, long comment lines). This change adds none (loader/query/filters violation count unchanged vs main).

Reroutes the rustfava query path to the component's typed `query-entries`
(rustledger v0.16.4, beancount#1423) and wires the engine selector so the component
backend is reachable end-to-end. JSON-RPC stays the default
(`RUSTFAVA_RUSTLEDGER_BACKEND=component` opts in) — no behavior change on the
default path; this fixes the component path.

- engine: `RUSTLEDGER_VERSION` -> v0.16.4; `component_engine.query_entries`
  marshals a directive set in and calls `builder.query-entries`.
- query_shell: `RLConnection.execute` queries the directive set directly via
  `query_entries` when the engine supports it, instead of re-rendering the
  filtered entries to beancount source (`_entries_to_source`) and re-parsing —
  the latter produced text the parser rejected (the query crashes). JSON-RPC
  keeps the source path (no `query-entries`), so `_entries_to_source` stays
  until that surface is dropped.
- routing: `backend.get_engine` selector (JSON-RPC default); load/query/filter/
  is_encrypted now go through it so the component backend is actually used.

Running the full suite via the component drops the query-crash class entirely
(remaining failures are snapshot diffs + a few inventory/tree shape issues,
tracked in #173). Default JSON-RPC path is unchanged.

Note: routing touches loader/query/filters, which carry pre-existing ruff debt
(function-level imports, long comment lines); this change adds none.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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