-
Notifications
You must be signed in to change notification settings - Fork 17
engine2: expose Vensim MDL file support #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Code Review: Vensim MDL Support in engine2 APISummaryThis PR adds Vensim MDL file support to the engine2 public API by exposing Strengths1. Excellent Feature Detection PatternThe implementation correctly handles optional Vensim support through runtime feature detection:
2. Comprehensive Test CoverageThe test suite in
3. Graceful Degradation in NewProject.tsxThe UI code properly falls back to xmutil conversion when direct Vensim support is unavailable, making it future-proof. 4. Consistent API DesignThe Issues & RecommendationsCritical IssuesNone identified. Minor Issues1. Inconsistent Variable Declaration Style (src/app/NewProject.tsx:145)Location: Changed from Recommendation: Either change both to 2. Test File Path AssumptionLocation: The test throws an error if the teacup.mdl file doesn't exist. While this follows the repository's testing philosophy of "failing loudly," it might be helpful to verify this file exists in the test setup or CI. Recommendation: Verify that 3. Error Message SpecificityLocation: The error message is clear, but could mention how users might enable Vensim support (rebuild instructions). Current: 'simlin_project_open_vensim is not available: libsimlin was built without Vensim support. ' +
'Rebuild with the "vensim" feature enabled to import MDL files.'Suggestion: This is actually quite good! No change needed. Code Quality ObservationsPositive Patterns:
Follows Repository Conventions:
Performance ConsiderationsNo performance concerns identified. The feature detection is a simple function property check, which is negligible overhead. Security ConsiderationsNo security issues identified. The FFI boundary properly validates null pointers and buffer lengths in the Rust implementation. Architecture NotesThe implementation correctly:
VerdictAPPROVED ✓ This is high-quality code that follows best practices and repository conventions. The implementation is clean, well-tested, and properly handles edge cases. The only suggestion is the minor variable declaration consistency in NewProject.tsx, which is cosmetic. Suggested Follow-upConsider documenting the Vensim feature flag in the build documentation so users know how to enable it for their WASM builds (outside scope of this PR). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74192a2b95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/engine2/src/index.ts
Outdated
| // Vensim support check (for direct use without Project class) | ||
| export { hasVensimSupport } from './internal/import-export'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard hasVensimSupport before WASM init
The newly exported hasVensimSupport is a sync re-export of the internal helper, which calls getExports() and throws when WASM hasn’t been initialized yet. That means a consumer who calls this “availability check” before ready() (e.g., to decide whether to use MDL import or a fallback) will get a runtime exception instead of a boolean. Consider either making this export async and calling ensureInitialized, or documenting/renaming it so callers know they must initialize first.
Useful? React with 👍 / 👎.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #192 +/- ##
==========================================
- Coverage 76.16% 76.14% -0.03%
==========================================
Files 45 45
Lines 15256 15256
==========================================
- Hits 11620 11616 -4
- Misses 3636 3640 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add Project.openVensim() and Project.hasVensimSupport() static methods to the engine2 public API. These methods wrap the underlying libsimlin FFI functions and provide proper error handling when Vensim support is not available (e.g., when WASM is built without the vensim feature). The hasVensimSupport() check is only exposed via the async Project.hasVensimSupport() method, which ensures WASM is initialized before checking. This prevents runtime exceptions if called before initialization. Updated NewProject.tsx to use direct Vensim import when available, falling back to the xmutil MDL-to-XMILE conversion when not. This makes the code future-proof for when the browser WASM build might include Vensim support. Added comprehensive unit tests for the new Vensim APIs that properly handle both cases: when Vensim support is available and when it is not.
74192a2 to
1dc8ad1
Compare
Code ReviewThis PR adds Vensim MDL file support to the engine2 public API. Overall, the implementation is solid and follows good practices. Here are my findings: ✅ Strengths
|
Add Project.openVensim() and Project.hasVensimSupport() static methods
to the engine2 public API. These methods wrap the underlying libsimlin
FFI functions and provide proper error handling when Vensim support is
not available (e.g., when WASM is built without the vensim feature).
The hasVensimSupport() function is also exported directly from the
module for cases where users want to check availability without using
the Project class.
Updated NewProject.tsx to use direct Vensim import when available,
falling back to the xmutil MDL-to-XMILE conversion when not. This
makes the code future-proof for when the browser WASM build might
include Vensim support.
Added comprehensive unit tests for the new Vensim APIs that properly
handle both cases: when Vensim support is available and when it is not.