Skip to content

feat(plugin)!: effective_date moves a marked posting correctly or reports it - #2536

Merged
robcohen merged 15 commits into
mainfrom
fix/effective-date-open-order
Oct 9, 2026
Merged

robcohen merged 15 commits into
mainfrom
fix/effective-date-open-order

Conversation

@robcohen

@robcohen robcohen commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

The native effective_date plugin now follows robcohen's rule: a posting marked effective_date is either moved correctly or reported, never silently dropped or half-applied. The output is also the same on every run.

Breaking

  • Prefixes match whole account components. A prefix matches when the account equals it or continues with :; a prefix written with its own trailing : also counts.

    • Expenses:Car no longer takes Expenses:Cards:Fee.
    • The most specific matching prefix wins, whatever the config order. Before, as upstream, the last match in config order won, so a general prefix listed after a specific one shadowed it.
  • Only the leading prefix is renamed. Prefix Income used to turn Income:Interest:Income into Assets:Hold:Income:Interest:Assets:Hold:Income (upstream's str.replace).

  • A marked posting the plugin cannot move is an error, and the whole transaction stays as written. The error names the account and points at the entry. It fires when:

    • no prefix matches the posting;
    • its effective_date is not a date (e.g. a quoted string);
    • its amount is elided;
    • the date equals the transaction's own date.

    A posting no prefix matched used to stay in place silently while its sibling postings moved. test_effective_date_unconfigured_prefix_unchanged is replaced by test_effective_date_unconfigured_prefix_is_reported_and_entry_kept, which adds a covered sibling that must not move either.

Fixed

  • Deterministic output.
    • The synthesized opens were emitted in HashSet order, and the config was a HashMap. They are now sorted, as upstream (sorted(new_accounts)), and the config keeps its order.
    • Links number the entries moved in this run (edate-<yymmdd>-<n>, no wraparound). They used to come from a process-wide counter mod 4096: they changed on every LSP or FFI reload and collided after 4,096 entries.
    • A test runs process() twice in one process and compares the outputs byte for byte; 5,000 moved entries get 5,000 distinct links.
  • The config is read as ast.literal_eval reads it. The reader is the new py_literal.rs, pinned by 61 configs each classified by running Python.
    • A config literal_eval rejects is an error and changes nothing. It used to fall back silently to the default config.
    • A falsy literal ({}, None) means the default config, as upstream.
  • The new entry keeps the transaction's payee, tags, links and metadata, plus original_date, and the moved posting keeps its metadata, effective_date included. Both were checked against the beancount 3.2.3 oracle, which does exactly this. rledger used to drop the transaction's metadata and links.

Oracle comparison (beancount 3.2.3 + beancount_reds_plugins)

  • Same as upstream: on a three-prefix config, every posting, holding account, synthesized open (names, date, order) and the new entry's metadata, links and tags.
  • Different, by design: the cases above (Expenses:Cards:Fee, Expenses:Car:Gas with the general prefix listed after the specific one, Income:Interest:Income, unmatched / non-date / elided postings), and the link format. Each is listed in docs/reference/compatibility.md under "Plugin Differences".

Routing (checked on main after #2525)

  • Every module-style spelling runs this native plugin, because the registry matches on the last dotted segment: beancount_reds_plugins.effective_date.effective_date, effective_date, foo.bar.effective_date.
  • python: with a module name gives E8004, and the plugin is not applied.
  • A direct .py path to the upstream file reaches the Python sandbox and fails on the missing beancount_reds_plugins package.
  • So no spelling silently switches implementations.

Every new test fails on the code before it. The CHANGELOG entry is under Breaking, with the fixed parts noted.

🤖 Generated with Claude Code

https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr

…onfig

The native effective_date plugin had two kinds of hash-order output:

- The holding-account `open`s it synthesizes were emitted in `HashSet`
  order, all on one date. PRINT and #entries therefore listed them
  differently from run to run over the same ledger. A sweep of the
  compatibility corpus, three runs each, found this file and no other.
  The upstream plugin emits `sorted(new_accounts)`; so does this one now
  (BTreeSet).
- The holding-accounts config was a `HashMap`. When two configured
  prefixes matched one account (`Expenses`, `Expenses:Car`), the winner
  was random, and `find_holding_account` and `find_account_prefix`
  iterated separately, so the prefix replaced could differ from the one
  the holding account was chosen for. The config is now a list in config
  order (a repeated key keeps its first position, as a Python dict
  literal does), the last matching prefix wins as upstream, and one
  lookup returns both.

Both tests fail on the previous code (the second repeats 32 times so a
lucky hash order cannot pass it).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Shape rustledger beancount Speedup RSS (rledger / beancount)
simple 34.3ms ± 1.5ms 563.1ms ± 2.7ms 16.4x 51.1 MB / 50.1 MB
investment 53.3ms ± 0.3ms 2126.0ms ± 7.1ms 39.9x 57.2 MB / 58.1 MB
fifo 51.4ms ± 0.4ms 11996.2ms ± 64.5ms 233.4x 59.5 MB / 57.8 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 34.5ms ± 1.4ms 34.3ms ± 1.5ms -0.8% ✅ within noise 51.1 MB → 51.1 MB (-0.0%)
investment 53.2ms ± 0.3ms 53.3ms ± 0.3ms +0.3% ✅ within noise 57.3 MB → 57.2 MB (-0.1%)
fifo 51.5ms ± 0.4ms 51.4ms ± 0.4ms -0.1% ✅ within noise 55.2 MB → 59.5 MB (+7.8%)

A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: simple 0.9ms, investment 0.2ms, fifo 0.3ms), and is at least 5%.
10,000 transactions per shape · 20 runs, 3 warmup · hyperfine

What do these numbers mean?
  • simple — Two-posting transfers, one currency. The historical workload — keep as the floor, not as the benchmark.
  • investment — Cost specs, per-unit prices and lot reductions. Exercises booking and inventory, which simple leaves at 0.3%.
  • fifo — Bare {} reductions against a FIFO account — how FIFO sells are normally written. The other four shapes reach the ordered-selection path twice in 2k transactions between them, so it was effectively unprofiled until it turned out to be quadratic (plan_ordered scans every lot per reduction: FIFO ledgers are quadratic (8.8s at 20k transactions) #2083).
  • vs base: the PR and the base-branch commit it is built on, built and measured in the same job
  • RSS: peak resident set size, a single sample — reported without a verdict because there is no spread to test it against
  • A shape with no beancount column is one bean-check reports errors on; it is timed for rledger only

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.62617% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ledger-plugin/src/native/plugins/effective_date.rs 98.69% 10 Missing ⚠️
...rustledger-plugin/src/native/plugins/py_literal.rs 98.54% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 179 masked)
Full AST Match 100%
Total Files 819
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

robcohen and others added 2 commits October 9, 2026 03:15
A review against the upstream plugin (beancount_reds_plugins 3.2.3
oracle, multi-prefix config) found two silent behaviors where upstream
raises:

- A config that does not parse fell back to the default config, which
  moved postings to holding accounts nobody had configured. It is now an
  error and the plugin changes nothing, as with upstream's `literal_eval`
  failure. The parser now accepts what the Python dict literal accepts:
  either quote style, and `later` before `earlier` (before, such a valid
  config silently became the default). An empty dict is still the default
  config.
- An `effective_date` equal to the transaction's own date was routed
  through a holding account and back on the same day. Upstream reports
  "Effective and actual dates are identical" and leaves the entry as
  written; so does this now.

A posting that no configured prefix matches is still kept as written,
without an error, as the existing
`test_effective_date_unconfigured_prefix_unchanged` pins. Upstream raises
KeyError there and applies nothing at all.

The multi-prefix oracle comparison agrees on every posting and on the
synthesized opens' names, date (the ledger's first entry) and sorted order.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
@robcohen

robcohen commented Oct 9, 2026 •

Copy link
Copy Markdown
Member Author

Review pass

Compared against the upstream plugin: beancount_reds_plugins with beancount 3.2.3 as the oracle, on a three-prefix config (Expenses, Expenses:Car, Income) and on edge-case ledgers.

Agrees with upstream:

  • Every posting matches, including:
    • the last matching prefix wins (Expenses:Car:Gas goes to Assets:Hold:Car:Gas);
    • the holding-account name is built with account.replace(prefix, hold);
    • earlier vs later is decided by effective_date > entry date.
  • The synthesized opens match: names, date (the ledger's first entry, a 1990 commodity included), and sorted order.

Found and fixed (6ebce3e), each with a test that fails on the previous head:

  • Unparseable config. It silently fell back to the default config, moving postings to holding accounts nobody configured. Upstream's literal_eval raises. It is now an error and the plugin changes nothing.
    • The parser now also reads double quotes and later before earlier. Before, such a valid config silently became the default.
    • {} is still the default config, as upstream.
  • Effective date equal to the entry date. Upstream reports "Effective and actual dates are identical" and leaves the entry alone. rledger routed the posting through a holding account and back on the same day. It now matches upstream.
  • Both errors show up the same way in check, query and report.

Divergences kept on purpose:

  • No prefix matches a posting. Upstream crashes (KeyError: '') and applies nothing at all. rledger keeps the posting as written, which test_effective_date_unconfigured_prefix_unchanged pins.
  • Order among same-date opens. Upstream's synthesized opens sort before the user's opens of the same date. Here they sort after, from the general ordering of plugin-inserted entries, which this PR doesn't change.

CHANGELOG category: Fixed, not Breaking. A config without overlapping prefixes produces the same entries as before. Only the new errors change results, and both are inputs upstream rejects.

Review pass 2

Config parser, found and fixed (524d6eb). Round 4's two regexes disagreed with ast.literal_eval:

  • They read 'Ex\x70enses' as the prefix Ex\x70enses.
  • They rejected adjacent strings, r/u prefixes, triple quotes and a parenthesized dict.
  • They made None, [] and 0 errors, where upstream's if not holding_accts treats them as the default config.

A new native/plugins/py_literal.rs reads the Python literal grammar: strings with prefixes, escapes and implicit concatenation, numbers, None/True/False, dicts, lists, tuples and sets, comments, trailing commas, and Python's line rules. parse_config then applies upstream's semantics:

  • an empty string or a falsy literal is the default config;
  • in a dict, extra keys are ignored, and a repeated key keeps its first position and its last value;
  • anything else is an error. Upstream fails only when a posting reaches a malformed entry; this reports it up front.

the_config_reads_as_literal_eval_reads_it holds 61 configs, each classified by running Python's literal_eval. It fails on the round-4 parser. Known gaps, all rejected here and all things nobody writes in a holding-account config: \N{...} escapes, complex numbers, arithmetic between literals.

Same-date error: checked, nothing to fix. It is reported at the transaction's own file and line, as upstream reports it at entry.meta, with severity error.

Interaction with #2525, tested on main 899ee96 and on this branch merged with it:

  • Every module-style spelling runs the native plugin: beancount_reds_plugins.effective_date.effective_date, effective_date, foo.bar.effective_date. The registry matches on the last dotted segment.
  • python: with a module name gives E8004 ("not supported by module name"), and the plugin is not applied.
  • A direct .py path to the upstream file reaches the Python sandbox and fails on ModuleNotFoundError: beancount_reds_plugins.
  • So no spelling silently switches implementations.
  • One pre-existing finding, not changed here: because of last-segment matching, any module whose name ends in .effective_date (say myco.plugins.effective_date) runs this native plugin instead.

The no-matching-prefix behavior is unchanged and waits on robcohen's decision.

Review pass 3 (robcohen's decision implemented, 0da2913 + 8d3f713)

  • Matching: component boundaries, a trailing-: prefix counted, and the most specific prefix wins in any order.
  • Rename: only the leading prefix is replaced.
  • Atomic per entry: an unmatched posting, a non-date value, an elided amount or an identical date each produce an error naming the account at the entry's location, and the whole transaction is left as written.
  • Links: per run, deterministic, no wraparound. Two in-process runs give byte-identical output, and 5,000 entries get 5,000 links.
  • New entry: keeps the transaction's metadata, tags and links plus original_date, and the moved posting keeps effective_date. I checked the oracle first: upstream does exactly this.

Oracle runs on the multi-prefix ledger plus a new one per case match upstream wherever the rules agree, and show exactly the documented divergences wherever they don't. Each new test fails on the previous head; the replaced unconfigured-prefix test included.

My own review pass on the result found two things, both fixed:

  • A prefix written with a trailing : ('Expenses:', which upstream's startswith matches) stopped matching under the boundary rule. It now matches; tested and mutation-checked.
  • A comment about upstream's non-date handling sat on the wrong match arm.

The divergences are documented in compatibility.md under "Plugin Differences", in its own section so it won't collide with #2530's §16. The CHANGELOG entry is now under Breaking.

Review pass 4 (round 5's new code, reviewed as fresh; da06234)

Found and fixed:

  • Hostile nesting crashed the process. A config of 100,000 [ overflowed the stack and aborted rledger check, because py_literal recursed without a limit. It now stops at 200 levels, as Python does ("too many nested parentheses"). This was never on main, which used the regex parser.
  • Tokenizer differences from literal_eval. A 72-literal table classified by Python 3.13 found these, now fixed and pinned:
    • --1 was accepted;
    • 1__0, 0__0 and 1_ were accepted;
    • 1j was rejected;
    • bytes literals treated \u as an escape and accepted a raw non-ASCII character.
  • Links shifted on unrelated edits. They are now numbered per date. Adding an unrelated transaction, or a moved one on another date, changes no link. A moved entry added earlier on the same date renumbers the later ones of that date; this is documented in compatibility.md.

Checked, nothing to fix:

  • Raw vs non-raw escapes; \x, \u, \U and octal (including \400); unknown escapes keep their backslash; comments and # inside strings; line continuations inside strings and at the top level.
  • A bytes prefix is rejected as a key ("a prefix must be a string"). Upstream fails with TypeError when a posting reaches it.
  • 'Expenses:' does not match the root Expenses, the same as upstream's startswith.
  • Atomic errors: there is one error per bad posting, naming the account, at the entry's file and line. A kept entry leaves no holding-account opens behind; that is now pinned, and the pin passes on the previous head too.

Known gap, still rejected: \N{...} escapes.

Follow-up for the coordinator, not filed: the native registry matches a plugin by the last dotted segment of its name, so a user module called myco.plugins.effective_date runs this native plugin instead.

Review pass 5 (fuzzing, differential vs Python, surfacing; ab5e29b)

Found and fixed:

  • Repeated prefix keys. A differential test over 20,000 generated configs, each classified by Python 3.13's ast.literal_eval, found one disagreement. A repeated prefix key was validated at every occurrence, so a malformed value that a later duplicate replaces made the whole config an error. Python builds the dict first (first position, last value), so the replaced value is never read. Fixed; after the fix all 20,000 agree.
    • 500 of the cases are frozen in tests/fixtures/effective_date/configs.json, with the generator next to them, and checked by a test that fails on the previous head.
    • The fixture's randomly split strings trip the typos hook, so .typos.toml excludes the file. The pre-commit typos hook now passes --force-exclude so that exclusion also covers files prek passes.
  • Numbers. 0x followed by a million digits overflowed u128 and was rejected, while Python's based integers are unbounded. Now accepted. A decimal integer over 4,300 digits is now rejected, matching Python's int-conversion limit; an all-zero one is still accepted.

Checked, nothing more found:

  • Proptests over 4,096 strings drawn from the grammar's alphabet, and over arbitrary Unicode: no panics.
  • Megabyte-scale inputs each parse in milliseconds, so time is linear in length: line continuations, long strings and comments, 500,000 items, 199 mixed nesting levels, long numbers. The test fails on the previous head for the number cases.
  • Surfacing: the depth error and the config errors read identically in check, query and report.
  • LSP: it runs the native plugin. A new protocol test opens a hostile config and an unclosed one, and requires a diagnostic while the server keeps answering. On the round-5 parser that test aborts with a stack overflow, so a hostile config would have killed an editor's language server.

Review pass 6 (convergence check; fa57578)

Found and fixed: line continuations. I ran the differential with 10 new seeds × 20,000 configs (200,000 total) against Python 3.13. Two disagreed, both a backslash continuation near the end of the text.

  • Python accepts a continuation followed by anything, even a lone line break, a space or a comment, and rejects one only at the very end of the text. py_literal had required a token to follow it.
  • Fixed, and five oracle cases joined the hand table. The three accepted ones fail on the previous head.
  • After the fix, all 200,000 agree.

Checked, nothing found:

  • Prefix order after merging duplicate keys: it no longer matters anywhere. With matching on component boundaries, two different prefixes that both match one account have different lengths, so "most specific" never ties. The synthesized opens are sorted, and errors don't depend on order. Keeping a repeated key's first position is now cosmetic, kept only to mirror Python's dict.
  • Number edges, each checked against Python and now pinned by a test:
    • the 4,300-digit limit counts digits only, not a leading +/- or underscores, and applies only to decimal integers;
    • 0_0, 0x__f (rejected), 0b_ (rejected), 0o_7, -0x0, +0b0;
    • a leading zero on a long non-zero integer is rejected.
  • The typos change: I ran prek run typos --all-files on main with the hook as it is, on main with --force-exclude added, and on this branch. All three report the same 166 findings (pre-existing fixture hits), so the flag changes no finding.
    • With explicit file lists, --force-exclude only drops binary files: wasm, png, pdf and fuzz-regression binaries. Typos skips those as binary anyway, and the hook's types: [text] doesn't pass most of them.
    • Its only real effect is to make .typos.toml's new exclusion of the generated fixture apply at commit time. I'm keeping it.

Convergence loop (rounds 9–11; final head d90a2c7)

Each round: a fresh review of the previous round's changes plus one area of the PR not re-read since round 5; the differential against Python 3.13's ast.literal_eval with 10 new seeds × 20,000 configs; and the full plugin and rustledger test suites.

Round Area re-read Differential Found Fixed in
9 effective_date move logic 0 / 200,000 \r\n and lone \r were not read as \n, as Python reads them. A continuation written \<CR><LF> was rejected. e1a3df5 (8 oracle cases; 3 fail before the fix)
10 error paths, compat docs, CHANGELOG 1 / 200,000 Top-level indentation is checked in Python's eval mode ( # c\n {}, {}\n are errors) and py_literal ignored it. The CHANGELOG's "rather than a stack overflow" was untrue of main. compatibility.md didn't list the errors rledger raises up front or the \N{NAME} gap. d90a2c7 (43 oracle cases; 20 fail before the fix)
11 links 0 / 200,000 nothing —

Round 11 found nothing in review, had 0 disagreements, and passed both suites (plugin 364, rustledger 947), so the loop stops there. The generator now also emits CR and CRLF line breaks, and configs.json was regenerated from it. Required checks are green on d90a2c7.

robcohen and others added 5 commits October 9, 2026 05:26
Round 4's config reader was two regexes. Against Python 3.13
`ast.literal_eval` it accepted and rejected the wrong things. It took
`'Ex\x70enses'` as the prefix `Ex\x70enses`, where Python reads
`Expenses`. It rejected valid literals: adjacent strings, `r`/`u`
prefixes, triple quotes, a parenthesized dict. And it made falsy values
like `None`, `[]` and `0` errors, where upstream's `if not holding_accts`
treats them as the default config.

New `native/plugins/py_literal.rs` reads the Python literal grammar a
config uses:

- strings, with prefixes, escapes, triple quotes and implicit
  concatenation;
- numbers, `None`, `True` and `False`;
- dicts, lists, tuples and sets;
- comments, trailing commas, and Python's line rules (a line break ends
  a top-level expression; a backslash continuation needs a token after
  it).

parse_config applies upstream's semantics on top:

- an empty config string, or a falsy literal, is the default config;
- a dict maps prefix -> {earlier, later}, extra keys ignored, a repeated
  key keeps its first position and its last value;
- anything else is an error. Upstream fails only when a posting reaches
  a malformed entry (KeyError/TypeError); this reports it up front.

The new test holds 61 configs, each classified by running literal_eval.
It fails on the round-4 parser.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
…orts it

robcohen's rule for #2536: a posting marked `effective_date` is either
moved correctly or reported, never silently dropped or half-applied.

- Prefixes match on account-component boundaries (`account == prefix`,
  or `prefix:` starts it; a prefix written with a trailing `:` counts),
  and the most specific matching prefix wins whatever the config order.
  Upstream's raw `startswith` let `Expenses:Car` take
  `Expenses:Cards:Fee`, and its last-match rule let a general prefix
  listed after a specific one shadow it.
- Only the leading prefix is replaced in the holding-account name.
  Upstream's `str.replace` turned `Income:Interest:Income` into
  `Assets:Hold:Income:Interest:Assets:Hold:Income`.
- A marked posting the plugin cannot move is an Error naming the account
  at the entry's location, and the whole transaction is left as written.
  This covers no matching prefix, a non-date value, an elided amount, and
  an identical date. A posting with no matching prefix used to stay in
  place silently while its siblings moved.
  `test_effective_date_unconfigured_prefix_unchanged` becomes
  `..._is_reported_and_entry_kept`, with a covered sibling that must not
  move.
- Links number the entries moved in this run (`edate-<yymmdd>-<n>`), not
  a process-global counter mod 4096. The same ledger gives byte-identical
  output when processed twice in one process, and 5,000 entries get
  5,000 links.
- The new entry keeps the transaction's payee, tags, links and metadata,
  plus `original_date`. The moved posting keeps its metadata,
  `effective_date` included. Both were checked against the beancount 3.2.3
  oracle, which does exactly that.

Every new test fails on the previous head. The deliberate divergences
from upstream are documented in compatibility.md ("Plugin Differences").
The CHANGELOG entry moves to Breaking, with the fixed parts noted.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
@robcohen robcohen changed the title fix(plugin): effective_date is deterministic: sorted opens, ordered config feat(plugin)!: effective_date moves a marked posting correctly or reports it Oct 9, 2026
robcohen and others added 2 commits October 9, 2026 06:52
… edits

Round-6 review of round 5's new code, with fixes:

- Nesting depth. A config of 100,000 `[` overflowed the stack and
  aborted the process; the parser recursed without limit. It now stops at
  200 levels, as Python's parser does ("too many nested parentheses"),
  and reports an error. Main never had this: it used the regex parser.
- Tokenizer parity. A second oracle table of 72 literals, each
  classified by Python 3.13's `ast.literal_eval`, found and pinned these
  disagreements, now fixed:
  - `--1` was accepted (one unary sign, directly on a number, as Python);
  - `1__0`, `0__0` and `1_` were accepted (an underscore must sit between
    digits or right after a base prefix);
  - `1j` was rejected;
  - in bytes literals, `\u` was treated as an escape and a raw non-ASCII
    character was accepted.

  `\N{...}` stays a documented gap. A bytes literal as a prefix is
  rejected; upstream would raise TypeError on first use.
- Links now number moved entries per date. Adding an unrelated
  transaction, or a moved one on another date, leaves every link as it
  was; only a moved entry added earlier on the same date renumbers the
  later ones of that date. Documented in compatibility.md.
- New pinning test: a kept entry leaves no holding-account opens behind
  while a sibling entry in the same run is moved, and `'Expenses:'` does
  not match the root `Expenses`, as upstream's `startswith` does not.
  This test also passes on the previous head.

Every other new test fails on the previous head; the depth test aborts
the process there.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
…erated cases

Round 7 on #2536: fuzzing, a differential test against Python, and how
errors surface.

- Differential test. A generator draws configs from a small grammar:
  every quote style and prefix, escapes, implicit concatenation,
  comments, line continuations, trailing commas, repeated and extra keys,
  non-string values, plus random mutations. Each config is classified by
  Python 3.13's `ast.literal_eval`. On 20,000 drawn configs it found one
  real disagreement, now fixed: a repeated prefix key was validated per
  occurrence, so a malformed value that a later duplicate replaces made
  the whole config an error. Python builds the dict first (first
  position, last value), so the replaced value is never read. 500 of the
  cases are frozen in tests/fixtures/effective_date/configs.json, with
  the generator beside them, and checked by
  `the_config_reads_as_literal_eval_reads_it_on_generated_configs`. That
  test fails on the previous head.
- Numbers. Based integers are unbounded in Python, but
  `0x` + a million digits overflowed u128 and was rejected; validity and
  zero-ness are now read from the digits. A decimal integer over 4300
  digits is rejected, as Python's int-conversion limit rejects it, unless
  it is all zeros.
- No panic and linear time. Proptests draw 4,096 grammar-alphabet
  strings and arbitrary Unicode, asserting no panic. A table of
  megabyte-scale inputs (continuations, long strings and comments,
  500,000 items, 199 mixed nesting levels, long numbers) must each parse
  in seconds; it fails on the previous head for the number cases.
- Surfacing. Config errors and the depth error read the same in check,
  query and report. The LSP runs the native plugin: a new protocol test
  opens a hostile config and an unclosed one, and requires the error as a
  diagnostic with the server still answering. On the round-5 parser that
  test aborts with a stack overflow, which would have taken down an
  editor's language server.

The fixture's strings are split and mutated at random (keys split mid-word), so
.typos.toml excludes it, and the pre-commit typos hook gains
--force-exclude so that exclusion also applies to the files prek passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
robcohen and others added 3 commits October 9, 2026 13:08
… Python

Round 8 on #2536, a convergence check.

The differential generator ran 10 new seeds x 20,000 configs (200,000
total) against Python 3.13's `ast.literal_eval`. Two disagreed, both a
backslash continuation near the end of the text (`...}\<newline><newline>`).
py_literal accepted a continuation only if a token followed it. Python
accepts one followed by anything at all, even a lone line break, a space
or a comment, and rejects one only at the very end of the text. The
cases `{}\<nl><nl>`, `{}\<nl># c`, `{}\<nl> ` (now accepted) and
`{}\<nl>\<nl>`, `[1,\<nl>` (still rejected) join the hand table; the
accepted three fail on the previous head. After the fix, all 200,000 agree.

Also pinned: number edges, each checked against Python. The 4300-digit
limit counts digits only, not a leading `+`/`-` or underscores, and
applies to decimal integers only. Also `0_0`, `0x__f`, `0b_`, `0o_7`,
`-0x0`, and a leading zero on a long non-zero integer. All passed already;
the test is a pin.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Round 9 on #2536.

Python reads `\r\n` and a lone `\r` as `\n` everywhere in the source,
inside strings too. py_literal did not, so a continuation written
`\<CR><LF>` was rejected, and a CR inside brackets was taken for
something other than whitespace. Configs from CRLF ledgers or Windows
editors can carry these when they reach the plugin directly; through
`rledger check` the loader already hands over LF, and an end-to-end CRLF
ledger agrees with beancount 3.2.3. The source is now normalized before
tokenizing. Eight cases from the Python oracle join the hand table; three
of them fail on the previous head.

The generator now emits CR and CRLF line breaks too, and configs.json is
regenerated from it (seed 2536, N 500, classified by Python 3.13).
10 new seeds x 20,000: 0 disagreements.

Re-read this round: the effective_date move logic (atomic plan-then-apply,
opens only for entries that moved, the new entry's metadata and links,
locations) found nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
… mode does

Round 10 on #2536.

- Differential, 10 new seeds x 20,000: one disagreement. ` # c\n {...}` is
  an IndentationError in Python. `literal_eval` strips spaces and tabs
  from the start of the text only; every later line holding a token must
  not be indented. A form feed resets the count, a continuation keeps
  counting, and blank or comment lines may be indented. An indented last
  line with no line break is also an error (`{}\n  `). py_literal ignored
  indentation entirely. It now reads each top-level line's indentation
  the same way. 43 oracle cases join the hand table; 20 of them fail on
  the previous head. After the fix, the 200,000 agree.
- Docs, re-read this round:
  - The CHANGELOG said nesting input is "an error rather than a stack
    overflow". Main never overflowed (it fell back to the default config),
    so it now says the reader follows Python's 200-level limit.
  - compatibility.md now lists every config error rledger reports up front
    (missing `earlier`/`later`, a non-string account, a truthy non-dict)
    and the one grammar gap (`\N{NAME}`).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
…g generator

literal_eval only yields builtin literals, whose truth test never raises,
so the except branch CodeQL flagged could not run. Output is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
@robcohen
robcohen merged commit 001cca9 into main Oct 9, 2026
54 of 55 checks passed
@robcohen
robcohen deleted the fix/effective-date-open-order branch October 9, 2026 18:17
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.

2 participants