Skip to content

fix(rustledger): complete the v0.19.0 upgrade — host-side GPG decryption (WIT 3.2.0) - #219

Merged
robcohen merged 3 commits into
mainfrom
chore/rustledger-0.19
Jul 2, 2026
Merged

robcohen merged 3 commits into
mainfrom
chore/rustledger-0.19

Conversation

@robcohen

@robcohen robcohen commented Jul 2, 2026

Copy link
Copy Markdown
Member

Completes #218, which bumped RUSTLEDGER_VERSION to v0.19.0 but didn't adapt to the release's breaking FFI change (rustledger#1667, WIT 3.2.0). As of #218, a fresh install that downloads the v0.19.0 component cannot instantiate it:

component imports instance `rustledger:ledger/[email protected]`, but a matching
implementation was not found in the linker

v0.19.0 delegates decryption of encrypted ledgers to the host: the component imports rustledger:ledger/[email protected] with decrypt: func(ciphertext: list<u8>) -> result<string, string> and calls it on .gpg/.asc inputs.

Changes

  • component engine: _WIT_VERSION → 3.2.0; the wasmtime linker now defines the host interface, implementing decrypt with the system gpg --batch --decrypt (keyring + gpg-agent) — mirroring rustledger's native loader semantics. Failures surface as the WIT err case, so hosts without usable keys still fail cleanly.
  • vendored component refreshed to the v0.19.0 release asset (sha256-verified) — it was still v0.18.0.
  • tests: encrypted-ledger suite rewritten for the new capability — adds an end-to-end round-trip (throwaway keyring → encrypt → load through the component → entries produced) plus direct err-branch coverage (gpg missing, non-UTF-8 plaintext); api_version assertion 3.1 → 3.2.

Net effect

Encrypted ledgers now load end-to-end on the default component backend — previously detect-only with a clean failure.

Validation

560 passed, 1 skipped (pre-existing), 100% branch coverage maintained; component smoke: instantiates, api_version 3.2, loads plaintext + encrypted ledgers.

🤖 Generated with Claude Code

robcohen added 3 commits July 2, 2026 03:38
…T 3.2.0)

rustledger v0.19.0 makes the FFI component delegate decryption of encrypted
ledgers to the host (rustledger#1667, WIT 3.2.0): the component now imports
`rustledger:ledger/[email protected]` with a single
`decrypt: func(ciphertext: list<u8>) -> result<string, string>` and calls it
when it detects a `.gpg`/`.asc` input.

- engine: RUSTLEDGER_VERSION -> v0.19.0; vendored component refreshed from the
  release asset (sha256-verified).
- component engine: _WIT_VERSION -> 3.2.0; the linker now defines the host
  interface, implementing `decrypt` with the system `gpg --batch --decrypt`
  (keyring + gpg-agent), mirroring rustledger's native loader semantics.
  Errors surface as the WIT `err` case, so hosts without usable keys still
  fail cleanly.
- tests: encrypted-ledger suite rewritten for the new capability — adds an
  end-to-end round-trip (throwaway keyring, encrypt, load through the
  component, entries produced) plus direct err-branch coverage (gpg missing,
  non-UTF-8 plaintext); component api_version assertion 3.1 -> 3.2.

Encrypted ledgers now load end-to-end on the default component backend —
previously they were detect-only with a clean failure.

560 passed, 100% branch coverage maintained.
…directly

The end-to-end round-trip needs a system gpg (absent on macOS CI runners —
FileNotFoundError). Skip it cleanly when gpg is not installed, and cover
_host_decrypt's ok/gpg-failure branches with monkeypatched units so the 100%
branch-coverage gate holds on gpg-less platforms too.
shutil.which found gpg on the runner's full PATH but the subprocess env
restricted PATH to /usr/bin:/bin, hiding Homebrew's gpg on macOS —
FileNotFoundError despite the skip guard. Resolve the absolute gpg path once
(skip when absent) and invoke it directly; inherit PATH for gpg's own helpers.
@robcohen
robcohen merged commit f0c48ae into main Jul 2, 2026
22 of 24 checks passed
@robcohen
robcohen deleted the chore/rustledger-0.19 branch July 2, 2026 14:59
robcohen added a commit that referenced this pull request Jul 2, 2026
Closes #220. The bot auto-merged v0.19.0 as a version-string chore despite the
release carrying a breaking FFI change (feat(ffi)!, WIT 3.1.0 -> 3.2.0 with a
new mandatory host import), leaving main unable to instantiate the component
until #219.

The bump workflow now:
- downloads the release's FFI component, verifies its sha256, and refreshes
  the vendored artifact (previously the bot only edited the version string
  and left the vendored wasm stale);
- extracts the component's actual WIT package version with wasm-tools and
  compares it against _WIT_VERSION in component_engine.py. ANY difference
  (minor bumps can add mandatory imports, as 3.2.0 did) or a conventional-
  commit breaking marker in the release notes (`!:` / BREAKING CHANGE) marks
  the bump as needs-review;
- needs-review bumps open as a DRAFT PR with no auto-merge and a checklist
  (new imports to bind, tests to run), with the mechanical _WIT_VERSION bump
  pre-applied; clean bumps keep today's auto-merge behaviour.

Gate logic validated against the real v0.19.0 artifacts: matched-WIT ->
auto path; the v0.19.0 release notes trip the breaking grep; the exact #218
scenario (bindings 3.1.0 vs component 3.2.0) -> held for review.
robcohen added a commit that referenced this pull request Jul 2, 2026
…#223)

Closes #220. The bot auto-merged v0.19.0 as a version-string chore despite the
release carrying a breaking FFI change (feat(ffi)!, WIT 3.1.0 -> 3.2.0 with a
new mandatory host import), leaving main unable to instantiate the component
until #219.

The bump workflow now:
- downloads the release's FFI component, verifies its sha256, and refreshes
  the vendored artifact (previously the bot only edited the version string
  and left the vendored wasm stale);
- extracts the component's actual WIT package version with wasm-tools and
  compares it against _WIT_VERSION in component_engine.py. ANY difference
  (minor bumps can add mandatory imports, as 3.2.0 did) or a conventional-
  commit breaking marker in the release notes (`!:` / BREAKING CHANGE) marks
  the bump as needs-review;
- needs-review bumps open as a DRAFT PR with no auto-merge and a checklist
  (new imports to bind, tests to run), with the mechanical _WIT_VERSION bump
  pre-applied; clean bumps keep today's auto-merge behaviour.

Gate logic validated against the real v0.19.0 artifacts: matched-WIT ->
auto path; the v0.19.0 release notes trip the breaking grep; the exact #218
scenario (bindings 3.1.0 vs component 3.2.0) -> held for review.
@rustledger-bot rustledger-bot Bot mentioned this pull request Jul 2, 2026
3 tasks
robcohen added a commit that referenced this pull request Jul 2, 2026
…227)

* test(holdings): regression for the cost_date aliased ORDER BY (#190)

The Holdings query orders by cost_date, a raw column aliased in SELECT.
rustledger dropped the hidden sort column for that shape and every Holdings
render 500'd (rustledger#1627, fixed in rustledger#1631, shipped v0.17.0;
delivered to rustfava by the v0.19.0 upgrade in #219). Pins the exact issue
repro — two cost-dated lots of the same commodity — so a future engine or
query-layer change can't silently rebreak the report.

Closes #190

* test(holdings): narrow query-result types for mypy

execute_query_serialised returns QueryResultTable | QueryResultText and row
values are a wide union — assert the table case and isinstance-narrow the
inventory cell before reading lots.
robcohen added a commit that referenced this pull request Aug 21, 2026
Two defects in the same PR body, both found reviewing #284.

1. The "why this is held" line lost its values.

`${{ steps.gate.outputs.reasons }}` was interpolated into an unquoted
heredoc. A `${{ }}` expression is pasted into the script text before
bash parses it, so the backticks inside the reason string were parsed as
command substitution: their contents were executed and replaced with the
empty output. #284's body reads

    - WIT package version changed:  ->  (host bindings in  likely need changes)

losing precisely the two versions and the filename the reviewer needs.
`set -euo pipefail` does not catch it, because the substitution's exit
status is never examined — it fails silently.

Fixed by passing the values through `env:` and referencing them as shell
variables. A variable's value is not re-scanned for substitutions, so
backticks in it stay literal; the escaped static backticks elsewhere in
the heredoc were never affected. This is also the standard remedy for
the script-injection surface that `${{ }}`-into-`run` carries.

Verified by executing the step with the env the workflow supplies: the
body now renders the versions and the filename. The same harness run
against the pre-fix step reproduces the blanked line exactly, so the
check can report dirty as well as clean.

2. The body claimed a vendored artifact that has never existed.

It advertised "refreshed the vendored component (sha256-verified)". The
download step did `cp component.wasm
src/rustfava/rustledger/rustledger_ffi_component.wasm`, added by
#219/#220 to stop a committed artifact going stale — but that path is
gitignored (.gitignore:52) and absent from add-paths, so it was never
once committed: `git log --all` on the path is empty. The cp wrote into
the runner's workspace and was discarded.

#243 had already settled the question the other way round: committing
the wasm shipped ~6 MB of unconsumed sdist weight per release, so the
component is downloaded at runtime against the pinned version instead
(#286). Removed the dead cp rather than resurrect vendoring, and made
the body describe what actually happens. The download and sha256
verification stay — the WIT gate reads component.wasm from the
workspace.

Also corrected the checklist's "wasm-tools component wit the vendored
file", which pointed at a file that is never there.

No functional change to what the bot commits.
@rustledger-bot rustledger-bot Bot mentioned this pull request Sep 4, 2026
3 tasks
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