Repository navigation
perf(parser): green posting flags + metadata conversion (PR2) - #1595
Merged
Merged
Conversation
Extends the green conversion path to posting flags and metadata, shrinking the red fallback set: - meta_value: typed MetaValue from a META_ENTRY green node (string > number/ amount > date > account > currency > bool > tag/link > none, with the same present-but-unparseable fall-through as red), reusing number_meta_value. - convert_meta_entries: META_ENTRY children -> Metadata, used for BOTH per-posting and transaction-level metadata. - convert_simple_posting: posting flag (first non-ws token before account, via posting_flag_char matching PostingFlag::cast/flag_char_from_posting) + per- posting metadata. convert_transaction: transaction-level metadata. Now bails to red only on arithmetic/multi-amount postings + direct-child comments + deprecated pipe. parse_green_eq_red_corpus extended with all 13 MetaValue types, posting-flag variants, and flag+cost+price+meta combined; green byte-identical to red. clippy --all-targets clean, 284 tests.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs main branch (2026-06-25)
What do these numbers mean?
|
Contributor
There was a problem hiding this comment.
Pull request overview
Extends the parser’s “green-tree” transaction conversion path (cst/green.rs) to handle posting flags and metadata (both transaction-level and per-posting), further reducing cases that must fall back to the slower red-node conversion path while preserving byte-identical output equivalence.
Changes:
- Add green-tree metadata extraction (
meta_value,convert_meta_entries) to produce typedMetaValueandMetadatamaps consistent with the red conversion logic. - Add green-tree posting-flag detection to populate
Posting::flagwithout forcing a red fallback. - Expand the
parse_green_eq_red_corpusdifferential test cases to cover posting flags and all supported metadata value types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/rustledger-parser/src/cst/green.rs | Implements green-path conversion for posting flags + directive/posting metadata; updates green-vs-red equivalence corpus. |
| crates/rustledger-parser/src/cst/convert.rs | Exposes number_meta_value to allow green conversion to reuse the red-path numeric-meta discriminator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Addresses review: convert_simple_posting / convert_transaction collected metadata via a separate convert_meta_entries pass over node.children() AND the main loop — a double walk on the hot path even for metadata-free postings. Replace with meta_entry_kv (key+value for one entry) folded into the existing loop, so the parent's children are walked once. Update the convert_transaction doc (it now converts txn-level metadata; no longer a red-fallback trigger).
This was referenced Jun 25, 2026
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.
What
PR 2 of the lossless-CST-tax removal. Extends the green transaction conversion (shipped in #1594, −16% load) to posting flags and metadata (per-posting and transaction-level), shrinking the set of transactions that fall back to the red path.
After #1594 the green path bailed to red on flags/metadata. Now it handles them, so the only remaining fallbacks are arithmetic/multi-amount postings, direct-child comments, and the deprecated
|— all genuinely rarer shapes.How — same proven pattern (walk green, reuse text parsers, oracle + fuzz)
meta_value— typedMetaValuefrom aMETA_ENTRYgreen node, mirroringmeta_value_from_entryexactly: priority string > number/amount > date > account > currency > bool > tag/link > none, with the same present-but-unparseable fall-through (a malformed string falls through to number, etc.). Reuses the sharednumber_meta_value(Int-vs-Number discriminator) and the minus-sign rule.convert_meta_entries—META_ENTRYchildren →Metadata, used for both per-posting and transaction-level metadata.posting_flag_charmatchingPostingFlag::cast+flag_char_from_posting(note: posting flags excludetxn, unlike transaction flags).Verification
clippy --all-targets -D warningsclean.parse_green_eq_red_corpusextended: all 13MetaValuetypes (string / int / negative-int / decimal / amount / date / account / currency / TRUE / FALSE / tag / link / none), posting-flag variants (!,*,#, letter), transaction-level metadata, and flag+cost+price+meta combined — all byte-identical to red.fuzz_green_eq_reddifferential fuzz target (from perf(parser): green-tree transaction conversion with red fallback (-16% load) #1594) now also exercises these paths.Performance note
The synthetic profiling workload has no flags/metadata, so its −16% (from #1594) is unchanged — those transactions were already green. This PR's value is coverage: real ledgers with posting metadata / flags now get the green path instead of red fallback. A metadata-heavy workload measurement is added below.
🤖 Generated with Claude Code
Measured win on a metadata-heavy workload
10k transactions, each with a transaction-level meta key + a posting-level meta key (the shape real ledgers use). On #1594 every such posting fell back to red; now it's green:
So this is more than coverage — it's a −16.3% load reduction on ledgers that use metadata, on top of #1594's −16% for plain transactions.