Implement Morphir Extension System with Extism + JSON-RPC#7
Implement Morphir Extension System with Extism + JSON-RPC#7DamianReeves merged 3 commits intomainfrom
Conversation
Move all crates into crates/ subdirectory for better organization: - crates/morphir - CLI binary - crates/morphir-models - IR model definitions Update workspace Cargo.toml to use glob pattern for member discovery.
morphir-daemon: - Workspace management (create, open, close, discover projects) - Configuration parsing for morphir.toml - Project state tracking - Foundation for JSON-RPC daemon service morphir-wit-extension: - WASM Component Model runtime using wasmtime - Extension types and capabilities (Frontend, Backend, Transform, Analyzer) - Extension loading and lifecycle management - Foundation for WIT interface implementations
Replace wasmtime-based morphir-wit-extension with new Extism-based extension system providing: New crates: - morphir-extension-sdk: SDK for building WASM plugin extensions - JSON-RPC 2.0 protocol types - Extension traits (Frontend, Backend, Validator, Transform) - export_extension! macro for easy extension creation - Host function imports for daemon communication - morphir-gleam-binding: Gleam language frontend/backend extension - Parses Gleam source to Morphir IR - Generates Gleam code from Morphir IR - morphir-wasm-binding: WASM/WAT backend extension - Generates WASM binary from Morphir IR - Generates WAT text format for debugging morphir-daemon extensions module: - Extism plugin loader (file, URL, GitHub sources) - Extension container with JSON-RPC dispatch - Extension registry for discovery and lifecycle - Host functions exposed to plugins - Virtual path system for sandboxed filesystem Removed: - morphir-wit-extension (replaced by new system) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via: Supported
Please update your commit message(s) by doing |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42ef6dd0e8
ℹ️ 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".
| artifacts: vec![], | ||
| diagnostics: vec![types::Diagnostic { | ||
| severity: types::DiagnosticSeverity::Error, | ||
| code: None, | ||
| message: "Backend not implemented".to_string(), |
There was a problem hiding this comment.
Invoke Backend trait instead of hardcoded error result
The JSON-RPC dispatch path for generate always constructs a GenerateResult with success: false and the message “Backend not implemented” without ever calling Backend::generate on the extension type. Because __dispatch_request routes all generate calls here, any extension that implements Backend will still always return an error, so backend extensions can never run. This needs to call the trait implementation (or otherwise detect/support implemented traits) rather than returning a fixed error payload.
Useful? React with 👍 / 👎.
| // For now, just log - actual memory management would need extism's memory APIs | ||
| debug!("get_workspace_info called, returning: {:?}", info); | ||
|
|
||
| // In a real implementation, we'd allocate memory in the plugin and return a pointer | ||
| outputs[0] = Val::I64(0); |
There was a problem hiding this comment.
Return workspace info via Extism memory, not
0
The host-side morphir_get_workspace_info implementation serializes WorkspaceInfo but discards the JSON and always returns Val::I64(0). In the SDK, this host function is imported as returning Json<WorkspaceInfo>, which expects a pointer to valid serialized data; returning 0 means the JSON cannot be read and get_workspace_info() will always fail. This breaks host/extension communication for workspace metadata unless you allocate/write the JSON into plugin memory and return the proper pointer (or use Extism’s helper APIs).
Useful? React with 👍 / 👎.
Summary
morphir-wit-extensionwith new Extism-based extension systemmorphir-extension-sdkcrate with SDK for building WASM plugin extensionsmorphir-gleam-bindingcrate with Gleam language frontend/backend extensionmorphir-wasm-bindingcrate with WASM/WAT backend extensionextensionsmodule tomorphir-daemonwith Extism plugin runtimeArchitecture
New Crates
morphir-extension-sdkmorphir-gleam-bindingmorphir-wasm-bindingKey Dependencies Added
extism(1.7) - WASM plugin runtimeextism-pdk(1.2) - Plugin development kitreqwest(0.12 with rustls) - HTTP client for downloading extensionswasm-encoder(0.220) - WASM binary generationTest plan
cargo checkpasses for all crates🤖 Generated with Claude Code