Repository navigation
fix(ffi): preserve warning severity + robust include handling in load_source - #1463
Conversation
…_source Addresses Copilot review on #1462 (the load_source pipeline collapse): 1. Warning severity dropped. `ledger_error_to_ffi` hardcoded `severity: "error"`. Now that load_source routes through the full pipeline, plugin *warnings* (e.g. the `unrealized` plugin's gain/loss notices) flow through `ledger.errors` and were surfacing to FFI consumers as errors. Map `ErrorSeverity::Warning` → wire `"warning"`. 2. Glob include paths errored. The previous empty-VFS-stub approach used the literal include path as the key, which cannot match a glob pattern (`[ab].bean` won't match the literal file `[ab].bean`), producing a `GlobNoMatch` parse-phase error that broke the "list includes, don't resolve, don't error" contract. Replace stubbing with a targeted filter that drops parse-phase resolution failures (file-not-found / glob no-match) for declared include paths — uniform across literal and glob includes, and narrow enough never to mask a real syntax error. 3. Fatal-fallback error misclassified. The fatal load/process fallback built a default (parse-phase) `Error`; a fatal process/plugin failure would then be classified as a parse error and suppress `ledger.validate`/`query`. Tag it `validate`. Tests in `tests/load_regular_plugins.rs` cover warning-severity preservation and glob-include suppression. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📊 Benchmark Results
vs main branch (2026-06-20)
What do these numbers mean?
|
There was a problem hiding this comment.
Pull request overview
This PR fixes regressions in the rustledger-ffi-wasi string-load surface (load_source) after it was collapsed onto the canonical loader pipeline, ensuring FFI consumers receive accurate severity/phase metadata and that include directives behave consistently without a real filesystem.
Changes:
- Preserve
LedgerErrorwarning severity in the FFI wire errors (Warning→"warning"), instead of hardcoding"error". - Make
load_sourcerobust to unresolvedincludedirectives (including globs) by suppressing include-resolution failures for declared includes while still listing them in the DTO. - Tag fatal fallback failures as
"validate"phase to avoid incorrectly suppressing validation/query behavior downstream, and add regression tests covering warnings + glob-includes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/rustledger-ffi-wasi/src/helpers.rs | Preserves warning severity in ledger_error_to_ffi, retags fatal fallback as validate-phase, and filters include-resolution errors for string-loaded ledgers. |
| crates/rustledger-ffi-wasi/tests/load_regular_plugins.rs | Adds regression tests ensuring warnings remain warnings and glob includes don’t surface resolution errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot on #1463: the loader renders paths via Path::display(), which uses backslashes on Windows, while declared include paths use forward slashes. Normalize both sides to / before matching so the include-resolution error filter works regardless of platform separator. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Good catch — fixed. The filter now normalizes path separators to |
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
What
Follow-up to #1462 (the
load_sourcepipeline collapse), addressing Copilot's review — its comments landed just after the auto-merge, so they're handled here.Warning severity dropped (most impactful).
ledger_error_to_ffihardcodedseverity: "error". Withload_sourcenow routing through the full pipeline, plugin warnings — e.g. theunrealizedplugin's gain/loss notices — flow throughledger.errorsand were surfacing to FFI consumers as errors. Now mapsErrorSeverity::Warning→ wire"warning".Glob include paths errored. The empty-VFS-stub approach keyed on the literal include path, which can't match a glob (
[ab].bean≠ literal file[ab].bean) →GlobNoMatchparse error, breaking the "list, don't resolve, don't error" contract. Replaced stubbing with a targeted filter that drops parse-phase resolution failures (file-not-found / glob-no-match) for declared include paths — uniform for literal and glob, and narrow enough never to mask a real syntax error.Fatal-fallback error mis-tagged. The fatal load/process fallback built a default (parse-phase)
Error; a fatal process/plugin failure would then suppressledger.validate/query. Now taggedvalidate.Tests
tests/load_regular_plugins.rs(now 5 tests):load_source_preserves_warning_severity—unrealizednotice surfaces aswarning, noterror.load_source_glob_include_does_not_error— unresolved glob include produces no error.Verify
All 8
rustledger-ffi-wasisuites +rustledger-ffi-componentpass;cargo clippy --all-features --all-targetsandcargo fmt --checkclean.🤖 Generated with Claude Code