Repository navigation
fix(core): tags and links are a sorted, deduplicated set - #2565
Merged
Merged
Conversation
Transaction, Document and Note hold tags and links as rustledger_core::SortedSet (TagSet / LinkSet), whose every constructor sorts and dedups, so the parser, pushtag, plugin conversion back and the FFI input can no longer build an unsorted or duplicated list. PRINT and BQL now match bean-query; meta.hash is order-independent. pushtag also tags document and note entries, as beancount 3 does. Bumps the loader cache to v38 and the wasm cache to v34. Closes #2545 Closes #2544 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
…-set # Conflicts: # CHANGELOG.md
Contributor
📊 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! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…-set # Conflicts: # CHANGELOG.md
The 30 corpus files whose parsed tags or links were unsorted, duplicated, or pushed onto a document or note now parse to the set (#2545, #2544). The new hashes match the ones CI reported. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Member
Author
Review loop
Converged after round 2. Required checks green on |
This was referenced Oct 10, 2026
…-set # Conflicts: # CHANGELOG.md # crates/rustledger-wasm/src/cache.rs
robcohen
added a commit
that referenced
this pull request
Oct 11, 2026
…FI (#2588) 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 Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the decision on #2545 (option B) and #2544.
What was wrong
SELECT tagsgavetrip, trip, foodwhere bean-query givesfood trip;PRINTwrote source order where beancount's printer sorts;meta.hashhashed#a #band#b #adifferently. Every path that built an entry decided for itself whether to dedup (the parser skipped a pushed tag already written, but kept one written twice; plugins could return anything).pushtagapplied to transactions only; beancount 3 also applies it todocumentandnote. (rledger'sNotealready carries tags since note silently discards its tags and links: parsed, accepted, and never stored #2160, and written tags ondocument/notelines already parse.)What changed
rustledger_core::SortedSet<T>(sorted_set.rs), withTagSet/LinkSetaliases. Its storage is private; every way to build or change one —from_iter,From<Vec>,From<[T; N]>,insert,extend,for_each_mut, serdeDeserialize— sorts and dedups. Reads go throughDeref<Target = [T]>.Transaction,DocumentandNotetags/linksare nowTagSet/LinkSet, so the invariant holds by type on every path: parser (red and green conversion), pushtag, entries converted back from plugins (from_wrapper), the FFI input (input_entry_to_directive), JSON. The order isOrdon the text = byte order = code-point order, which is how Python sortsstr.apply_inherited_stateunions the pushtag stack into transactions, documents and notes.meta.hash(ffi-wasi/src/hash.rs) needed no code change: it hashes the set, so it is now order-independent. One-timemeta.hashchange for rustfava: entries whose tags or links were not already sorted and unique (and documents/notes inside apushtagblock, which gain the pushed tag) hash differently once. An entry whose tags and links were already sorted and unique, outside anypushtagthat newly reaches it, hashes unchanged. The WIT and plugin wire staylist<string>, now always sorted.for_each_mut(and now also internsNotetags/links, which it skipped).ops/fingerprint.rsandcore/extract.rskeep their own sort/dedup: they are not made redundant by the invariant.fingerprinthashes the plugin-wireTransactionData(plainVec<String>an importer or plugin fills), andextract_tags/extract_linkstake the union across directives and metadata values.rledger formatis unaffected: it rewrites source text from the CST, so written order (duplicates included) is kept. Pinned bytags_and_links_keep_written_order.tests/baselines/parser-corpus.manifest: regenerated for the 30 corpus files whose parsed tags/links change (intentional drift; hashes match CI).CACHE_VERSION: loader 37 → 38, wasm 33 → 34 (pin reconciled). The archived layout is unchanged (the set archives its backingVec), but old blobs hold unsorted/duplicated tags and untagged pushtag'd documents/notes.### Breaking): the field types changed;.push→insert,vec![..]→.into()/collect().How tested
crates/rustledger-ffi-wasi/tests/tags_links_set_properties.rs(proptest, across paths): parser + pushtag (transaction, document and note each hold exactly the sorted union of written and pushed tags), plugin round trip with arbitrary order/duplicates, FFI input, andmeta.hashinvariant under written order.sorted_setunit + property tests (every constructor and mutator yields a strictly increasing list of the distinct inputs).tags_and_links_keep_written_order(formatter).SortedSet's normalization disabled, all 4 cross-path properties fail; with pushtag restricted to transactions again,parsed_entries_hold_the_setfails. (The formatter test is a guard that the formatter does NOT change; it passes before and after by design.)document/note:SELECT type, tags, links FROM #entries,SELECT date, tags, linksandPRINTagree on tags and links for every entry (food trip/aa zz,alpha trip zeta/l1 l2on document and note). RemainingPRINTdifferences are §16's existing layout rows.cargo test --workspace --all-features: all pass exceptpython_plugin_wasi::host_time_budget_applies_to_python_plugins, a wall-clock 3-second CPython budget that timed out under a machine load average of ~55 on 8 cores (unrelated to this change; CI will show). Clippy workspace-D warnings,cargo doc -D warningsfor core/parser/loader/ffi-wasi/plugin.Follow-ups, not in this PR: the plugin WIT
noterecord and FFIInputEntry::Note/ WITnote-dircarry no tags or links (documented gaps from #2160), so a note a plugin modifies loses its tags, which this PR makes more visible since pushtag now tags notes.Closes #2545
Closes #2544
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr