…inks (#2495)
* fix(extract): dedup against --existing as a scoped multiset with id links
`extract --existing` treated the existing ledger as a set: one existing
transaction suppressed every identical new row, so two identical
purchases on one day lost one silently. It compared only the first
posting's number, so other accounts and currencies matched, and it
ignored the `^ofx-` id links the OFX importer emits.
`rustledger_ops::dedup::find_import_duplicates` replaces the per-row
`is_duplicate`:
- existing transactions are a multiset; each absorbs at most one new row
- matching is scoped to the importer's account posting and its commodity
- a shared `^ofx-`/`^csv-` id link is decisive; different ids in one
namespace mean two transactions
- passes run id, then exact text, then fuzzy text, so weak evidence
cannot claim an entry strong evidence needed
- existing keys are computed once and bucketed by date, account,
commodity and amount: 50k x 50k goes from 550-804 s to 1.6 s
The CLI lists every skipped row on stderr with its reason.
The CSV importer gains `transaction_id_column`, emitting `^csv-<id>`
links through the same sanitizer as OFX FITIDs (now shared in ops).
Closes #2421
Closes #2422
Closes #2387
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* chore: regenerate cargo-vet exemptions
* fix(extract): harden import dedup found in adversarial review
- An id link match now also needs the same account, commodity and
amount: the sanitizer maps `a b` and `a:b` to one link, and such a
collision must not drop a different transaction.
- A ledger entry that splits the account leg over several postings is
matched on its net movement per commodity as well.
- A new transaction that never touches the importer account (a WASM
importer may post elsewhere) falls back to the unscoped first-posting
key instead of escaping dedup.
- Pin that a transfer already booked from the other account's statement
is a duplicate (main compared the first posting and re-imported it).
- `session.dedup` semantics changed, so the component contract moves to
3.13.0, following the #2415 precedent of bumping for a semantic change.
- Docs, roadmap and README describe the id-plus-amount rule.
Refs #2421
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* fix(extract): make import dedup order-independent and reimport-safe
Property tests (new crates/rustledger-ops/tests/import_dedup_properties.rs)
found two invariant failures:
- Re-importing a statement whose rows have no payee or narration added
every row again: empty text never matched. Identical empty text now
counts as identical in the exact pass.
- Which rows survived depended on file order: the greedy fuzzy pass let
an earlier row claim the entry a later one needed. Rows are visited,
and candidates offered, in a canonical content order, so the kept set
is a function of the contents alone.
The properties pin: a re-import adds zero rows; drops never exceed
existing entries and each rests on the same money; permuting either
side keeps the same rows; a half-then-whole import is idempotent.
Refs #2421
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* fix(extract): flag money-only dedup matches and harden the matcher
- A match where neither side has a payee or narration is reported as
`DuplicateReason::AmountOnly`, counted separately and flagged on stderr
("-- check: nothing but the date and amount ties these together"):
two different description-less rows on one day for one amount are
indistinguishable, so the user should see such skips.
- The split-leg net uses checked_add, so a crafted ledger whose net
overflows Decimal no longer panics the import.
- Ranks are computed once per transaction and borrowed, instead of
allocating in every sort comparison; `DuplicateReason` is
`#[non_exhaustive]`; `ID_LINK_PREFIXES` is private (nothing outside
needs it); `id_link` docs describe the id-plus-money rule.
- Docs note that text is not Unicode normalized (NFC vs NFD differ).
Refs #2421
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* fix(extract): bound the skip report and warn on a partly broken --existing
- A full re-import listed every skipped row: 50,000 lines on stderr.
The report now lists at most 20 rows of each kind (ordinary, flagged
money-only, so flagged rows never hide behind ordinary ones) and counts
the rest; the summary line keeps the full counts.
- An --existing ledger with parse or include errors was used silently,
so duplicates in the part that failed to load were re-imported without
a word. extract now warns, naming the first error.
- Pin that CRLF CSVs yield clean ^csv- links.
Refs #2421
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* fix(importer): check the transaction id column up front and warn on repeats
- A `transaction_id_column` the header lacks failed every row with the
same context-free warning, then reported "no transactions were
extracted". It now fails once: `transaction_id_column "Id" is not a
column of this file (its columns: ...)`.
- Ids repeating within one statement (a category or date column picked
by mistake) made id dedup match an equal-money row on any date. One
warning now names how many ids repeat, with an example and its rows.
Refs #2387
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* fix(importer): refuse misconfigured transaction id columns up front
- An index past the last column failed every row with a context-free
warning; it is now one error naming the key and the column count.
- A name differing from a header only in case or surrounding spaces
gets a "did you mean" hint.
- The same column as one the importer already reads (`amount_column`,
`date_column`, ...) is refused: those values are not unique per
transaction, and id dedup trusts an equal id with equal money as the
same transaction on any date.
Refs #2387
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* docs(extract): make the Monzo and CSV Options examples work as written
Followed literally, the Monzo `transaction_id_column` example had no
account, currency or columns, so it failed on the date and never
produced the output shown; it is now a complete entry whose output
matches the doc byte for byte. The CSV Options block repeated
`date_column` and `amount_column`, a TOML error when copied; the
name-based alternatives are commented out.
Refs #2387
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* docs(dedup): bring the roadmap, CHANGELOG numbers and doc examples up to date
- The roadmap row for stable source ids still described dedup as keyed
on first-posting amount and fuzzy text, and proposed consuming ids as
remaining work; it now records what shipped and what remains (an id
convention for WASM importers, #2251).
- The CHANGELOG performance entry quoted 1.6 s / 1.8 s from before the
review rounds; re-measured: 0.76 s (import alone 0.43 s), 0.37 s for a
full re-import, 101 s for main on an idle machine.
- import-architecture.md now says an id match needs the same money.
- Runnable doctests for `find_import_duplicates` and `id_link`, and the
component test asserts each `session.dedup` claim in the WIT doc
(multiset, commodity scope, id link with equal money).
Refs #2421
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
* docs(dedup): drop comments describing the pre-#2421 matcher
The existing-ledger loader doc named `first_posting_amount`, a function
that no longer exists, and the dedup module doc and the component's
`SessionState::dedup` doc described an id-link match without the
same-money condition.
Refs #2421
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]>
Co-authored-by: rustledger-bot[bot] <257329324+rustledger-bot[bot]@users.noreply.github.com>
The decision (#2408)
Beancount's semantics end to end, plus a migration warning. Chosen after the analysis in this session.
options_validate_leaf_account(is_valid_leaf) and joined ontoname_equitybyget_previous_accounts/get_current_accounts. Defaults areOpening-Balances,Earnings:Previous,Conversions:Previous,Earnings:Current,Conversions:Current.account_unrealized_gainsis a leaf too, under the income root (doctor.py).rledger checkrejected beancount's form with E7002 (option "account_previous_balances" "Anfang";bean-checkexits 0);docs/reference/options.mddocumented the full-name form, which beancount reads asEquity:Equity:…;Equity:Equity:Earnings:CurrentandEquity:Equity:Conversions:Currentin its committed snapshots, because itstree.pyjoins the root on, as fava does.What changes
"Anfang"(beancount's form)error[E7002]Equity:Anfang"Equity:Anfang"(rustledger's old documented form)Equity:AnfangEquity:Equity:Anfang, as in beancount, pluswarning[E7010]:... resolves to "Equity:Equity:Anfang"; write "Anfang" for Equity:Anfangname_equity "Eigenkapital"Eigenkapital:Opening-Balances(since #2410)"bad leaf"E7002E7002previous_*_account/current_*_accountreturn the full name;rustledger_loader::resolve_leaf_account;is_valid_leafruns the canonical account lexer onAssets:<leaf>.name_*can follow the account options. It is raised in the loader's post-parse pass, the LSP's single-file path and wasm'svalidate_option_tuples. Loads with option warnings are never cached, so a cached load cannot hide it.API_VERSION3.12):ledger-optionscarries the leaves, as beancount's options map does, documented inworld.wit.account-current-conversionsis always present (Conversions:Currentwhen unset), because a host falling back to its own full-name default would double it. In-process consumers (BQL summaries,session.clamp) resolve throughresolve_leaf_account.Equity:Equity:Opening-Balances. TheMetaValue/CostNumberlayout tripwires advance theirFIXTURE_VERSIONonly; their fixture bytes and hash are unchanged, confirming no directive layout moved.options.mdgets an account-name options section with a table; the configuration table and a new E7010 entry inerrors.mdare updated.Tests
test_is_valid_leaf(beancount'sis_valid_leafcases);a_rooted_account_option_resolves_like_beancount_and_warns: resolution, E7010 as a warning (not an error),name_equityset after the option, and defaults/leaves raising nothing.set_summary_accounts_are_leaves_under_the_equity_rootpins bean-query 0.2.0's resolution of both forms (Equity:Anfang, andEquity:Equity:Anfangfor the full-name value).name_equity "Eigenkapital"with leavesGewinn/Anfang. It had writtenEigenkapital:Anfangwith no rename, which beancount reads asEquity:Eigenkapital:Anfang.Anfangchecks clean,Equity:Anfanggiveswarning[E7010],bad leafgiveserror[E7002].-D warningsare clean. The WIT version gate passes.Downstream
Moving to a release with this change, rustfava's
tree.pyneeds no change: it already joins the root, and now getsEquity:Earnings:Current. Its committedEquity:Equity:*snapshots will update, and itsoptions.pyfallback defaults (full names) become dead, since every key is now always exported. I'll file that as a rustfava issue linking this PR.Closes #2408
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr