Skip to content

fix(component): host-path mapping, typed-value shape, field defaults - #171

Merged
robcohen merged 1 commit into
mainfrom
fix/component-engine-fidelity
Jun 17, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/component-engine-fidelity

Conversation

@robcohen

Copy link
Copy Markdown
Member

Three correctness fixes for the opt-in component backend, found by running Fava's full test suite through it for the first time (RUSTFAVA_RUSTLEDGER_BACKEND=component). They are independent of making the component the default (tracked separately) — each is a real bug in the component path today.

Fixes

  1. load_full leaks WASI guest paths. The component sees files under the /work pre-open mount, so returned directives carried meta.filename = "/work/<file>.beancount". Fava opens that path to edit entries → FileNotFoundError. Now mapped back to real host paths (filenames + includes).

  2. custom typed values used the wrong shape. The generic marshaller emitted {value_type, value: {type: ...}}, but rustledger's TypedValue serializes as {type, value} (amount un-nested as {number, currency}) — which Fava's RLCustomValue.from_raw reads. This broke budget / fava-option / extension parsing. Fixed in both directions (_marshal + the _unmarshal inverse for the clamp/filter round-trip).

  3. Omitted required fields became None. directives_to_json omits fields the loader fills (e.g. the meta hash); the JSON-RPC engine relies on serde defaults. _default_for now supplies type-appropriate zeros ("" / 0 / False) instead of None (which wasmtime rejects).

Impact

Running the full suite through the component went from 114 failures → 21 (and 164 fixture-setup cascade errors → 0) with these three fixes plus the already-merged cost-number kind fix (#170).

Tests

Regression tests for each: load_full returns host paths; custom typed values use the JSON-RPC shape; custom directives survive the clamp round-trip. ruff + mypy clean; component unit tests green.

🤖 Generated with Claude Code

Three fidelity fixes so the component engine matches the JSON-RPC engine's
output when exercised beyond the load/query/clamp happy path (found by running
Fava's full suite through the component for the first time):

- load_full: map WASI guest paths (the `/work` pre-open mount) in returned
  `meta.filename` and includes back to real host paths. Fava opens these to
  edit entries, so a `/work/...` path failed with FileNotFoundError.

- typed-value: `custom` directive args now marshal to the JSON-RPC
  `{type, value}` shape (amount un-nested), which Fava's `RLCustomValue` reads;
  the inverse `_unmarshal` handles them for the clamp/filter round-trip. The
  generic record marshalling emitted `{value_type, value: {type: ...}}`, which
  broke budgets / fava-options / extension parsing.

- _default_for: supply type-appropriate defaults ("" / 0 / False) for WIT
  fields `directives_to_json` omits (e.g. the meta hash), matching the
  JSON-RPC engine's serde defaults instead of passing None (which wasmtime
  rejects).

These are correctness fixes for the opt-in component backend, independent of
making it the default (tracked separately). Adds regression tests for each.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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