Repository navigation
feat: dedup + format-loaded on the component import surface - #1765
Merged
Merged
Conversation
Closes the two gaps a rustfava ingest backend would hit immediately (walked the fava import flow end-to-end against 3.5.0 before cutting the release): - importer.dedup(candidates, existing) -> list<bool> flags duplicate entries via the canonical rustledger_ops::dedup::is_duplicate — the same fuzzy matcher 'rledger extract --existing' filters with, so the review UI and the CLI agree on what counts as a duplicate. Per-candidate conversion keeps flags aligned with input order even when a candidate fails conversion. - format.format-loaded(entries) renders LOADED directives (extract output, session entries) to canonical beancount text, with the loaded->input down-conversion inside the component — previously only input-directive could be formatted, forcing hosts to reshape directives themselves to save extracted entries. Both land in the still-unreleased 3.5.0. Parity suite (21 tests) passes against the rebuilt wasip2 component, now exercising the full extract -> dedup -> format-loaded loop. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the rustledger-ffi-component WASI component surface (WIT world) to close the “extract → review → save” import UX loop for hosts by adding (1) duplicate-flagging over the component boundary and (2) formatting for loaded directives.
Changes:
- Add
importer.dedup(candidates, existing) -> list<bool>backed byrustledger_ops::dedup::is_duplicate. - Add
format.format-loaded(entries: list<directive>) -> result<string, string>to renderimporter.extract/session-loaded directives without host reshaping. - Add native/unit and parity-suite coverage for the extract → dedup → format-loaded loop.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/rustledger-ffi-component/wit/world.wit | Adds format-loaded and importer.dedup to the public WIT surface. |
| crates/rustledger-ffi-component/src/lib.rs | Wires new WIT methods to conversion/ops helpers in the component guest impls. |
| crates/rustledger-ffi-component/src/convert.rs | Implements format_loaded and import_dedup, plus a unit test for the host loop. |
| crates/rustledger-ffi-component-tests/tests/parity.rs | Extends component parity tests to exercise dedup + format-loaded over the boundary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📊 Benchmark Results
vs main branch (2026-07-12)
What do these numbers mean?
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The version gate is right: 3.5.0 landed on main in #1764, so this PR's interface additions need their own minor. API_VERSION tracks it (parity-enforced). Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Redesigns the 3.6.0 additions per the WIT design review before anything ships: - dedup moves from importer.dedup(candidates, existing) to session.dedup(candidates). One move fixes three findings: the host no longer re-marshals the full ledger per import (the exact pattern the session resource exists to kill); the held side's conversion-drop policy is the documented, info()-observable from-entries one instead of a silent comparison-set shrink; and the implementation uses the batch canonical find_fuzzy_duplicates, which precomputes held keys once instead of rebuilding every key per candidate. - extract-result.warnings becomes list<error> (severity "warning", phase "extract") — the structured diagnostic record every other surface uses, so line/field attribution is additive later rather than a record-shape break. - format-loaded errors now name the failing entry index, so a host can exclude one bad entry instead of losing the whole batch. - WIT dedup doc corrected: the matcher requires the SAME date (plus amount and text similarity) — "date proximity" promised behavior the canonical does not have. - format_loaded rustdoc version tag fixed (3.6.0, not 3.5.0). - The parity dedup guard now checks a fuzzy near-miss (reworded narration) against the NATIVE matcher's verdict, not just degenerate identity/empty inputs; extract warnings assert message parity plus severity/phase. Remaining design debt (options-less entries surfaces) is tracked in issue #1766 rather than patched piecemeal here. Co-Authored-By: Claude Fable 5 <[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.
Pre-release gap check on the 3.5.0
importerinterface (#1764): I walked the rustfava ingest flow end-to-end and found two things a backend would hit immediately. Both land in the still-unreleased 3.5.0.importer.dedup(candidates, existing) -> list<bool>— fava's extract modal flags entries already in the ledger; without this the host would re-implement fuzzy dedup in Python against the canonical. Delegates torustledger_ops::dedup::is_duplicate, the same matcherrledger extract --existinguses, so the review UI and CLI agree. Per-candidate conversion keeps flags aligned with input order.format.format-loaded(entries)— the extract flow ends with writing entries into the ledger file, butformat-entriesonly acceptsinput-directivewhileextractreturns loadeddirective. The loaded→input down-conversion now happens inside the component (the same onesession.from-entries/query-entriesuse).Deliberately deferred to 3.6: ML category suggestions (needs a trained-model story; UI works without it).
Testing: unit test covering the extract → dedup → format-loaded loop; parity suite (21 tests) green against the rebuilt wasip2 component, now exercising the new surface end-to-end; clippy/fmt clean.
🤖 Generated with Claude Code