feat(wassette): unload-component now should delete files on Disk#81
feat(wassette): unload-component now should delete files on Disk#81
Conversation
thomastaylor312
left a comment
There was a problem hiding this comment.
One minor nit where I agree with copilot.
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the unload_component API to make it the symmetric reverse operation of load_component by deleting component files from disk. The changes remove the redundant uninstall_component function and update unload_component to handle both runtime state cleanup and file removal.
- Modified
unload_componentto return aResultand delete component, policy, and metadata files from disk - Removed the separate
uninstall_componentfunction to eliminate API confusion - Updated all call sites to handle the new error-returning signature
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/wassette/src/lib.rs | Core implementation changes: added file deletion logic to unload_component, removed uninstall_component, and added helper method for consistent file removal |
| crates/mcp-server/src/components.rs | Updated MCP server handler to handle new error-returning unload_component signature with proper error responses |
| tests/transport_integration_test.rs | Updated test cleanup to handle new Result return type |
| tests/grant_permission_integration_test.rs | Updated test cleanup to handle new Result return type |
| tests/file_integration_test.rs | Updated test cleanup to handle new Result return type |
crates/wassette/src/lib.rs
Outdated
| self.remove_file_if_exists(&policy_path, "policy file", id) | ||
| .await?; | ||
|
|
||
| let metadata_path = self.plugin_dir.join(format!("{id}.policy.meta.json")); |
There was a problem hiding this comment.
The metadata file path construction is duplicated across unload_component and detach_policy_from_component. Consider extracting this into a helper method like get_component_metadata_path to maintain consistency and reduce code duplication.
| let metadata_path = self.plugin_dir.join(format!("{id}.policy.meta.json")); | |
| let metadata_path = self.get_component_metadata_path(id); |
crates/wassette/src/lib.rs
Outdated
| component_file.display() | ||
| )) | ||
| .component_policies | ||
| .remove(id); |
There was a problem hiding this comment.
The policy registry cleanup logic is duplicated between unload_component and detach_policy_from_component. Consider extracting this into a helper method to reduce code duplication and ensure consistent cleanup behavior.
Note: See the diff below for a potential fix:
@@ -703,11 +712,7 @@
self.components.write().await.remove(id);
self.registry.write().await.unregister_component(id);
- self.policy_registry
- .write()
- .await
- .component_policies
- .remove(id);
+ self.cleanup_policy_registry_for_component(id).await;
let component_file = self.component_path(id);
self.remove_file_if_exists(&component_file, "component file", id)
|
@Mossaka I have been spelunking. Here is one suggestion: Policy Registry Cleanup Ordering: In // Remove files first, then clean up memory on success
let component_file = self.component_path(id);
self.remove_file_if_exists(&component_file, "component file", id).await?;
// ... other file removals
// Only cleanup memory after all files are successfully removed
self.components.write().await.remove(id);
self.registry.write().await.unregister_component(id);
self.policy_registry.write().await.component_policies.remove(id);The same would apply to |
Done |
Currently, unload-component API only deletes the runtime state of the Wassette server, but it doesn not touch the files on the Disk. There is a separate API called uninstall-component. However, this is not a symmetric to load-component that users would expect. This commit deletes the unused uninstall-component function and modifies the unload-componnet API to be able to delete the wasm and co-located policy files on Disk. Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
…er func Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
…ure file removal before memory cleanup Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
7ce8fb9 to
4695802
Compare
…component function Signed-off-by: Aaron Wislang <aaron.wislang@microsoft.com>
|
@Mossaka thank you for fixing the conflict. I've tested the functionality and it's working great. Just pushed the change to make lint happy and will merge momentarily. |
Currently, unload-component API only deletes the runtime state of the Wassette server, but it doesn not touch the files on the Disk. There is a separate API called uninstall-component. However, this is not a symmetric to load-component that users would expect. This commit deletes the unused uninstall-component function and modifies the unload-componnet API to be able to delete the wasm and co-located policy files on Disk.
Closes #78
Signed-off-by: Jiaxiao Zhou duibao55328@gmail.com