Repository navigation
fix(plugin)!: carry a note's tags and links through plugins and the FFI - #2588
Conversation
A note's tags and links (its own and, since #2565, a pushtag block's) had no place in the plugin wire's NoteData, the component's note-dir and input-note, or the FFI's InputEntry::Note, so a note passing through any plugin or the FFI came back without them. All of them carry tags and links now, as documents do, as does the WASM build's JSON note. Structs cross the plugin wire as MessagePack arrays, so a version-1 guest cannot decode the longer note: ABI_VERSION is 2 and a version-1 WASM plugin or importer is refused at load. The component contract moves to 3.14.0 and the plugin WIT sketch to beancount:[email protected]. The Python compat layer's Note gains beancount 3's tags and links, and a document keeps its path through a Python plugin: the layer read it from the key holding the entry's source file and wrote it back under one the host rejects, so any Python plugin returning a ledger with a document failed. Closes #2573 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…links # Conflicts: # crates/rustledger/tests/plugin_conformance.rs
Review loop
The loop converged at round 1. The required checks are green on d766791. Downstream rustfava shows the expected |
|
Decision (robcohen): bump the plugin ABI 1 → 2 (option A, as implemented). An old guest is refused at load with a clear rebuild message. A crates.io reverse-dependency check ( 🤖 Generated with Claude Code |
…links # Conflicts: # CHANGELOG.md
…rance-rounding CHANGELOG: main's file plus this PR's entries. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
NoteData gained tags and links in #2588. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* fix(plugin)!: native validation plugins report as beancount's do The plugins rledger has both natively and in Python reported the same ledger differently depending on which ran. The native check_commodity, leafonly, coherent_cost, onecommodity, unique_prices, commodity_attr and noduplicates now match beancount 3: its messages, as errors, at the entries beancount names. check_commodity is an error, not a warning, and reads the config ignore map; leafonly reports each parent once at its open; coherent_cost catches a currency held with and without cost; onecommodity reads its config, opt-out, costs and balances; unique_prices allows agreeing repeats; commodity_attr reads tuples. The python: built-ins match too. A conformance case holds each pair to bean-check's output. Deliberate divergences, documented: leafonly ignores a note, document, close or custom on a parent; noduplicates names the duplicate instead of printing Python reprs; set-joined lists are in a stable order. Closes #2539 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr * test(plugin): give the leafonly alignment test's note its tags and links NoteData gained tags and links in #2588. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
* fix(ffi)!: hash a note's tags and links in meta.hash Notes carry tags and links since #2588, but compute_directive_hash left both out of a note's digest, so two notes differing only in tags or links shared an identity. Hash them exactly as a document's are: the tag and link counts always, then each element length-prefixed. Every note's meta.hash changes, untagged ones included (decided on #2598). Closes #2598 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr * docs(ffi): date note tags and links to #2185 in the hash comments Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
What
A note's tags and links now survive every boundary they used to be dropped at:
rustledger_plugin_types::NoteData)tags,linksfields; conversion both ways inrustledger-pluginABI_VERSION1 → 2note-dir,input-note)tags,links; contract 3.13.0 → 3.14.0,API_VERSION3.14InputEntry::Note)tags,links(serde(default), so old payloads still parse)DirectiveJson::Note)tags,links, left out when empty; bindings regeneratedbeancount:[email protected],noterecord gains themNotehas beancount 3'stags/links(default empty, so 4-field construction still works)Documents (the issue asked to check them too): the wire already carried their tags. Checking them turned up a separate bug in the Python compat layer: it read a document's file name from
filename, the key that holds the entry's source file, so a plugin saw the ledger's path as the document's. It also wrote the name back underfilename, which the host does not read as the path, so any Python plugin that returned a ledger holding adocumentfailed withdata did not match any variant of untagged enum OutputEntry. Fixed by usingpath.Why the ABI bump
Every struct crosses the plugin wire as a MessagePack array, and
rmp_serderejects an array longer than the struct (LengthMismatch). A version-1 guest handed a version-2 note would trap mid-run on the first note.ABI_VERSION's own doc says to bump it for a changedPluginInputshape, and with the bump a version-1 plugin or importer is refused at load with the existing clear mismatch error. Version-1 guests need a rebuild against the newrustledger-plugin-types. The hand-written WAT test guests now advertise 2.Another option was to keep version 1 and leave the new fields off the wire when they are empty. Old guests would then keep working on ledgers without tagged notes, and trap on the first one with them. I chose the documented policy instead; it is easy to switch if you prefer that.
How tested (each fails without the fix)
plugin_conformance::tags_and_links_survive_a_plugin_round_trip: ledger withpushtag+ a tagged/linked note and document, run through (a) the conformance WASM guest in a newrebuildmode that returns every directive asModify(so each crosses the wire both ways), (b) a Python passthrough plugin that also reports the document's path. Asserts tags/links viaSELECT type, tags, links FROM #entries, that the plugin ran, and that the path came through. Without the fix: WASM leg losesntag; with only the compat fix reverted, the Python leg fails on the document path.convert::tests::test_roundtrip_note_tags_and_links_2573(plugin conversion both legs).tags_links_set_propertiesproptests extended to notes for the plugin round trip and the FFI input (plugin_output_is_normalized,ffi_input_is_normalizedfail without the fix).rustledger-ffi-componentnote_tags_and_links_round_trip:note-dirout, back in via the loaded-directive path and viainput-note.RLEDGER_REQUIRE_*set), all green apart frompython_plugins_back_to_back_after_a_timeout. That 2-second-budget case failed while four other builds loaded the machine, and it fails the same way on the unrelated fix(plugin): hand a Python plugin its inputs on stdin, never on disk #2587. clippy--workspace --all-features --all-targets -D warnings, fmt, andcargo doc -D warningsfor the five changed library crates are clean.Not changed:
compute_directive_hashstill leaves a note's tags out ofmeta.hash, as before. Including them would change every note's hash, and rustfava pins those hashes, so that needs its own decision.Closes #2573
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr