mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-27 08:00:17 +00:00
fix: init WASM runtime eagerly regardless of tools directory existence (#401)
* fix: init WASM runtime eagerly regardless of tools directory existence The WASM tool runtime was only created at startup when both `wasm.enabled` and `wasm.tools_dir.exists()` were true. This meant that if the tools directory didn't exist yet (e.g. fresh deploy with `--no-onboard`), the runtime was set to None and passed to the ExtensionManager. Extensions installed later via the web UI would then fail with "WASM runtime not available" because the runtime could not be retroactively created. The Wasmtime engine initialization has no dependency on the tools directory — it only configures the compiler and starts an epoch ticker thread. The directory is only needed later when loading .wasm modules. Remove the directory check so the runtime is available for post-startup extension activation. Co-Authored-By: Claude Opus 4.6 <[email protected]> * test: add regression tests for WASM runtime eager init - runtime.rs: test_runtime_creation_without_tools_dir confirms the Wasmtime engine initialises without a tools directory on disk - manager.rs: test_activate_wasm_tool_with_runtime_passes_runtime_check verifies activation gets past the runtime check when a runtime is provided (fails on missing file, not missing runtime) - manager.rs: test_activate_wasm_tool_without_runtime_fails_with_runtime_error verifies the original error when no runtime is available Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: use idiomatic Result-to-Option conversion for WASM runtime init Address PR review feedback: replace match block with .map(Arc::new).map_err(|e| warn!(...)).ok() chain. Co-Authored-By: Claude Opus 4.6 <[email protected]> * style: fix formatting in extension manager tests Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3362081192
commit
7b883a02c0
@@ -347,4 +347,18 @@ mod tests {
|
||||
assert_eq!(limits.memory_bytes, 5 * 1024 * 1024);
|
||||
assert_eq!(limits.fuel, 500_000);
|
||||
}
|
||||
|
||||
/// The WASM runtime (Wasmtime engine) must initialise successfully even
|
||||
/// when no tools directory exists on disk. The engine only configures the
|
||||
/// compiler and epoch ticker — loading modules from a directory is a
|
||||
/// separate step. Regression test for a bug where the runtime was gated
|
||||
/// on `tools_dir.exists()`, causing extensions installed after startup
|
||||
/// (e.g. via the web UI) to fail with "WASM runtime not available".
|
||||
#[test]
|
||||
fn test_runtime_creation_without_tools_dir() {
|
||||
let config = WasmRuntimeConfig::for_testing();
|
||||
// Runtime should succeed even though no tools directory exists.
|
||||
let runtime = WasmToolRuntime::new(config).expect("runtime should init without tools dir");
|
||||
assert!(runtime.config().fuel_config.enabled);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user