Repository navigation
chore: exclude 4 Unicode-account-start files from compat suite - #772
Merged
Merged
Conversation
The compatibility test suite currently reports ~98-99% match rate across 784 real-world beancount files. The remaining 1-2% gap is 4 specific files that fail for exactly one reason: they contain account segments starting with non-ASCII characters. rustledger's lexer enforces the beancount v3 spec rule that every account segment must begin with an ASCII uppercase letter (or ASCII digit for sub-segments). Unicode letters ARE permitted in subsequent positions within a segment, e.g. `Förra-årets-resultat` parses fine because it starts with `F`, and `Banque-Épargne` is similarly fine. The strict rule applies only to the FIRST character of each colon-delimited segment. Python beancount is more permissive and accepts Unicode at segment starts too. This is a deliberate and documented divergence — the pta-standards conformance suite asserts the stricter rule, and rustledger's lexer has dedicated tests pinning the behavior. See issues #572, #736, and #739 for the full history and rationale. The 4 files: - `double-entry-generator/example_hxsec_example-hxsec-output.beancount` CJK at sub-segment start: `Assets:Hxsec:Positions:沪深300`. - `fava-portfolio-returns/src_fava_portfolio_returns_test_ledger_unicode.beancount` Emoji in segment: `Assets:CORP✨` (U+2728 is Symbol, not Letter). - `ledger2beancount/tests_accounts.beancount` Accented Latin capital at sub-segment start: `Expenses:École` and `Expenses:École-républicaine`. - `pinto-reports/example.beancount` Swedish BAS chart of accounts with 6 segments starting with `Å` or `Ö` (e.g. `Liabilities:2069:Årets-resultat`). None of these represent mainstream usage patterns. They're either test fixtures that deliberately exercise edge cases (fava-portfolio- returns/test/ledger/unicode.beancount, ledger2beancount's own account-names test suite) or charts of accounts that use non-Latin scripts at segment starts. Affected users can work around the limitation via ASCII-prefixed segment names or the `name_*` options for root-segment renaming. After this PR the compat report will read 100% across all metrics, with the understanding that "the gap" is exactly "4 files we deliberately reject per spec." This is honest — previously the mystery 1-2% invited speculation about hidden bugs; now the exclusions document the specific cases and point at the design decision that caused them. All 4 exclusion patterns have been verified: 1. Verified against the fetch script's `$name/$safename` format 2. Substring-matched against the expected full paths 3. Specific enough that they won't cross-match unrelated files 4. Upstream source paths verified via `gh api contents` 5. TOML parses cleanly via tomllib Does not change any code. Does not relax the parser rule. Just documents the known limitations in the same place the existing 4 exclusions live (decimal precision, forecast plugin, unrealized plugin). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the compatibility suite’s exclusions list to document and intentionally exclude 4 real-world fixtures that diverge due to rustledger’s stricter beancount v3 account-segment rules (ASCII-uppercase/digit segment starts, Unicode letters allowed only after ASCII start, symbols/emoji rejected).
Changes:
- Added 4 new
[[exclusions]]entries for known Unicode/symbol account-name incompatibilities. - Added detailed TOML comments and per-file rationale/workarounds to make the remaining compat gap explicit.
💡 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 |
Three inline comments, all about the accuracy of the explanatory
prose in the exclusions-file comment blocks. All legitimate — the
original wording conflated two unrelated things:
1. The account-segment start-character rule (the actual rule
being enforced and documented in these exclusions)
2. Account root-type localization via `name_*` options (a
different feature — issue #572)
Fixes:
1. **Section header was too narrow.** I called the new section
"Unicode-at-account-segment-start exclusions" but the
`Assets:CORP✨` (fava-portfolio-returns) exclusion fails for a
different reason: the emoji `✨` is in Unicode category `So`
(Symbol, Other), not `L` (Letter), so it's rejected *anywhere*
in the segment body, not specifically at the start. Renamed
the section to "Non-ASCII account name exclusions" and split
the explanation into two enumerated rules:
- Rule 1: segment start must be ASCII
- Rule 2: segment body must be ASCII digits, hyphens, or
Unicode letters — no symbols or emoji anywhere
Then documented which of the 4 files exercises which rule.
2. **Intro paragraph mentioned `name_*` as a workaround.** It
doesn't apply: `name_*` options rename the ROOT segment type
(`Assets` → `Activos`), but all 4 exclusions fail on SUB-segments,
not root segments. Replaced the `name_*` suggestion with an
accurate workaround (rename the offending sub-segment to start
with ASCII) and explicitly noted that `name_*` does not help
with sub-segment localization.
3. **`pinto-reports/example.beancount` details suggested `name_*`.**
Same issue as #2, but in the per-file details block. The Swedish
chart of accounts has ASCII root segments (`Liabilities`, `Income`,
`Expenses`) and accented sub-segments (`Årets-resultat` et al.),
so `name_*` renaming does nothing. Replaced with the accurate
workaround.
No code changes. TOML still parses cleanly (8 exclusions total, 4
pre-existing + 4 new). Functional behavior of the exclusions is
unchanged — the compat bot already shows Check Compatibility at
100% and Total Files dropped from 784 to 780, confirming the 4
new patterns match their intended files.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
robcohen
disabled auto-merge
April 11, 2026 21:53
robcohen
enabled auto-merge
April 11, 2026 21:53
robcohen
added this pull request to the merge queue
Apr 11, 2026
This was referenced Apr 11, 2026
Closed
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.
Summary
The compatibility test suite currently reports ~98-99% match across 784 real-world beancount files. This PR investigates and documents the remaining gap, then marks the affected files as deliberate exclusions so the report will read 100% across all metrics.
Zero code changes. This is purely an exclusions-file update with detailed rationale in TOML comments.
The gap
Earlier in this session (while investigating PR #771's compat output) I asked why those 4 files fail. The answer is the same for all of them:
rustledger's
Token::Accountlexer regex enforces the beancount v3 spec rule that every account segment must start with an ASCII uppercase letter (or ASCII digit for sub-segments). Unicode letters ARE permitted in subsequent positions within a segment — e.g.Förra-årets-resultatparses fine because it starts withF. Python beancount is more permissive and accepts Unicode at segment starts too.This is a deliberate and documented divergence settled in issues #572, #736, and #739. The pta-standards conformance suite depends on the stricter behavior. rustledger's lexer has dedicated unit tests pinning it (
test_tokenize_account_unicode,test_tokenize_account_unicode_letters_after_ascii_start).The 4 files, diagnosed
double-entry-generator/example_hxsec_example-hxsec-output.beancountAssets:Hxsec:Positions:沪深300fava-portfolio-returns/src_fava_portfolio_returns_test_ledger_unicode.beancountAssets:CORP✨ledger2beancount/tests_accounts.beancountExpenses:École-républicaine,Expenses:Écolepinto-reports/example.beancountÅrets-resultat,Öres-och-kronutjämning, and 4 moreWhat does not fail (verified against
pinto-reports/example.beancount): lines likeFörra-årets-resultatparse cleanly becauseFis ASCII at the segment start; theöandåmid-segment are in\p{L}and are permitted. This confirms the rule is specifically about the first character of each colon-delimited segment.Why not fix the parser?
name_*options to rename root segments.Why exclude rather than ignore?
Previously the compat output was "98-99% with a mystery 1-2% gap." That invited speculation about hidden bugs. After this PR the output will be "100% with 8 documented deliberate exclusions." Readers who want to understand the gap can read
exclusions.toml, where each entry lives alongside detailed TOML comments that:This is the same pattern the existing exclusions use (decimal precision >28 digits, removed v2 plugins).
Verification
tomllib— 8 exclusions total, 4 pre-existing + 4 new.gh api contentsagainst the upstream repos.safenamevalues computed perfetch-compat-test-files.sh'str '/' '_'rule and matched against the expectedtests/compatibility/files/<subdir>/<safename>paths.if pattern in rel_path, and each pattern is specific enough that it won't cross-match any other file in the corpus.rledger checkon all 4 files from therelease-plz-2026-04-11T20-44-43Zbranch (with the 0.12.0 version bump already applied). Error codes match the CI output exactly: P0012×4 (hxsec), P0012×1 (fava unicode), P0006×2 + P0012×3 (tests_accounts), P0012×6 (pinto-reports example).Files changed
tests/compatibility/exclusions.toml— +95 lines, 4 new[[exclusions]]entries with detaileddetails = """..."""blocks.Related
name_*options), Parser still accepts 5 invalid inputs after PR #708 and #726 claimed fix #736 (account root phase), Parser rejects valid Unicode characters in account names #739 (Unicode account rejection)crates/rustledger-parser/src/logos_lexer.rs→test_tokenize_account_unicode,test_tokenize_account_unicode_letters_after_ascii_starttests/compatibility/exclusions.toml(decimal precision, forecast plugin, unrealized plugin)