Skip to content

fix(ffi-wasi): accept Document.tags/links via RPC input (closes #1213) - #1216

Merged
robcohen merged 1 commit into
mainfrom
fix/ffi-input-doc-tags-1213
May 28, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/ffi-input-doc-tags-1213

Conversation

@robcohen

Copy link
Copy Markdown
Member

Summary

The output wire shape of Document.tags / Document.links was fixed for both bindings in #1212, but the FFI-WASI input side was still missing the fields entirely. InputEntry::Document had no tags / links slots and the converter hardcoded empty vectors — so callers using entry.create / entry.createBatch could never attach tags or links to Document directives via JSON-RPC.

  • Add tags: Vec<String> and links: Vec<String> with #[serde(default)] to InputEntry::Document. Backward-compatible: legacy payloads without the fields continue to deserialize cleanly.
  • Populate Document.tags / Document.links in the converter using the same .iter().map(|x| x.clone().into()) pattern Transaction already uses.
  • Two regression tests: a round-trip with tags+links populated, plus a legacy-payload guard that asserts the new fields default to empty.

Mirrors InputEntry::Transaction's shape exactly. Surfaced during the #1212 deep review; one of the two #1144-induced plumbing gaps (the other is #1214 on the plugin-wrapper side).

Test plan

  • cargo test -p rustledger-ffi-wasi — 58/58 pass (was 56; +2 new tests)
  • cargo clippy -p rustledger-ffi-wasi --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean

Closes #1213.

🤖 Generated with Claude Code

The output wire shape of `Document.tags` and `Document.links` was
fixed for both bindings in #1212, but the FFI-WASI input side was
still missing the fields entirely. `InputEntry::Document` had no
`tags` / `links` slots, and the converter at line 542 hardcoded
`Vec::new()` -- so callers using `entry.create` / `entry.createBatch`
to construct Document directives could never attach tags or links,
even though the core type and the output wire shape both support
them.

Mirror the `InputEntry::Transaction` shape:

- Add `tags: Vec<String>` and `links: Vec<String>` with
  `#[serde(default)]` to `InputEntry::Document`. The default-empty
  serde behavior keeps the wire backward-compatible -- a payload
  without the new fields still deserializes cleanly.
- Update the converter to populate the core `Document.tags` and
  `Document.links` via the same `.iter().map(|t| t.clone().into())`
  pattern Transaction already uses.

Add two regression tests:

- `document_tags_and_links_round_trip_1213` -- a Document payload
  with tags + links round-trips through the bridge and arrives on
  the core `Document` with both fields populated.

- `document_tags_and_links_default_to_empty_1213` -- a legacy
  payload without `tags`/`links` fields still converts cleanly,
  producing empty vectors. Backward-compat guard for pre-#1213
  clients in the wild.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner May 28, 2026 09:04
Copilot AI review requested due to automatic review settings May 28, 2026 09:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the rustledger-ffi-wasi JSON-RPC input plumbing for Document directives by allowing callers to provide tags and links (matching the core Document type and aligning with InputEntry::Transaction’s shape).

Changes:

  • Added tags: Vec<String> and links: Vec<String> (both #[serde(default)]) to InputEntry::Document for backward-compatible deserialization.
  • Updated the InputEntry → core Directive::Document conversion to populate Document.tags / Document.links from RPC input.
  • Added regression tests covering (1) tags/links round-trip via RPC input and (2) legacy payloads defaulting to empty vectors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Tool Time Memory
rustledger 33.1ms ± 1.1ms 25.3 MB
beancount 873.2ms ± 5.9ms 50.7 MB
Comparison 26.4x faster 2.0x less

vs main branch (2026-05-28)

Metric main this PR Change
Time 29.7ms 33.1ms +11.4% 🔴
10K transactions · 5 runs, 2 warmup · hyperfine
What do these numbers mean?
  • Time: Wall-clock time to parse and validate the ledger (± std dev)
  • Memory: Peak resident set size (RSS)
  • vs main: Compared to latest nightly benchmark on main branch

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100%
Full AST Match 100%
Total Files 791
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

@robcohen
robcohen merged commit 869fb9f into main May 28, 2026
32 checks passed
@robcohen
robcohen deleted the fix/ffi-input-doc-tags-1213 branch May 28, 2026 11:01
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.

ffi-wasi: InputEntry::Document drops tags/links on the RPC input side

2 participants