core/src/infra/extension/README.md
Status: Basic structure integrated, compiling successfully
This module provides Spacedrive's WebAssembly-based extension system, enabling secure, sandboxed plugins.
manager.rs - PluginManager for loading/unloading WASM modules (Wasmer integration)host_functions.rs - Skeleton for host_spacedrive_call() and host_spacedrive_log()permissions.rs - Capability-based security with rate limitingtypes.rs - Extension manifest format and typeswasmer = "4.2"
wasmer-middlewares = "4.2"
Key Insight: ONE generic host function reuses the entire Wire/Registry infrastructure.
// WASM extensions import:
extern "C" {
fn spacedrive_call(method, library_id, payload) -> result;
}
// Host function routes to existing registry:
host_spacedrive_call()
↓
RpcServer::execute_json_operation() // EXISTING!
↓
LIBRARY_QUERIES/ACTIONS.get() // EXISTING!
↓
Operation::execute() // EXISTING!
Result: Zero code duplication. WASM extensions use same operations as CLI/GraphQL/daemon clients.
1. WASM Memory Interaction (host_functions.rs)
2. Full Wire Bridge (host_functions.rs)
RpcServer::execute_json_operation()3. Extension Operations (core/src/ops/)
ai.ocr - OCR operationai.classify_text - AI classificationcredentials.store/get - Credential managementvdfs.write_sidecar - Sidecar file operations4. Test WASM Module
spacedrive_call() to test integration5. Extension SDK (separate crate)
spacedrive-sdk Rust cratespacedrive_call()Implement WASM Memory Helpers
read_string_from_wasm()write_json_to_wasm()Complete host_spacedrive_call()
execute_json_operation()Create Test WASM Module
spacedrive_call() with test payloadAdd Extension Operations
ai.ocr (Tesseract integration)credentials.store/getvdfs.write_sidecarBuild Extension SDK
spacedrive-sdk crate// In Spacedrive Core
let mut plugin_manager = PluginManager::new(core.clone(), plugins_dir);
plugin_manager.load_plugin("finance").await?;
// Extension (WASM) calls:
let result = spacedrive_call(
"query:ai.ocr",
library_id,
json!({ "data": pdf_bytes, "options": { "language": "eng" } })
);
# Check compilation
cd core && cargo check
# Run tests (once implemented)
cd core && cargo test extension
# Load test plugin (once implemented)
cargo run --bin spacedrive extension load ./plugins/test-plugin
wasm_alloc(size: i32) -> *mut u8{ "error": "message" }spacedrive_call()Last Updated: October 2025 - Initial integration