Files
raykholo 53a76b23f9 Plugins: sandboxed WebAssembly host with permissions and no network, phase 1 of the plugin RFC (#1221) (#15112)
* Add an explicit native Wasm command plugin runtime

* Document the plugin test workflow in English

* Report plugin execution causes and explicit fuel budgets

* Allow explicit user plugin resource ceilings

* Document the persistent isolated plugin test profile

* Require the Wasmtime 48.0.8 security fixes

Raise the minimum native runtime version and update its locked Cranelift and
Wasmtime dependencies for RUSTSEC-2026-0422, RUSTSEC-2026-0423 and
RUSTSEC-2026-0424. Preserve the existing plugin resource defaults and approval flow.

* claim: #1221 phase 1

* Plugins: share host contracts and reject unused network imports

Split plugin manifests, permissions, limits, typed errors, entry schemas and
the PluginHost trait into craft-plugin. Put the Wasmtime sandbox in
craft-plugin-wasm, with no dependencies on SolidCraft crates and no WASI
or network linker. SolidCraft supplies its command catalog and transactions,
and the UI routes namespaced plugin calls through the existing worker.

Inspect a component's imports before instantiating it (bounded).
Refuse sockets, HTTP and fetch imports even when Wasmtime would elide an
unused import. Keep net manifest requests forbidden and report typed errors.

Exercise WAT components against a tiny independent app and SolidCraft. Cover
file reads and writes without grants, swallowed denials, granted reads,
runaway fuel exhaustion, traps and rollback, network refusal, read-only
entries, exact approval and one-step undo/redo. Attribute the shared fixture.

Checked:
- cargo test -p craft-plugin-wasm: 11 passed
- cargo test -p solidcraft-engine --features plugins plugin: 16 passed
- cargo check -p solidcraft-ui-egui --all-targets: passed
- cargo clippy -p craft-plugin -p craft-plugin-wasm -p solidcraft-engine --all-targets --features solidcraft-engine/plugins -- -D warnings: passed
- cargo xtask layers: passed, 35 crates
- cargo xtask lists: passed
- cargo fmt -p craft-plugin -p craft-plugin-wasm -p solidcraft-engine -p solidcraft-ui-egui -p xtask -- --check: passed

Full-suite and remaining platform checks are left to CI after push.
Refs #1221, phase 1; design review remains required before phase 2.

* Plugins: model.mesh is an export in the mesh-decisions check

The plugin command hands a plugin a bounded copy of a body's display
tessellation; it decides nothing about the model. It joins the check's list
of display and export functions.

* Cargo.lock: the plugin crates follow the workspace version (0.40.1)

* Kernel cases: the plugin commands name where they are tested

model.mesh, plugin.inspect, plugin.list and plugin.run take no kernel case
(the folder takes no new ones); each EXEMPT line names the engine's plugin
test file.

* Plugins: enforce command authority, file scopes and per-run consent

Stage granted file writes until successful execution and app commit.
Check caller scopes for every file path and default command effects to edit.
Preserve inspection identity, preflight complete scripts and clean up accepted sketch exits.
Correct plugin schemas, preference drafts, fixture identifiers and runtime documentation.
Add regressions in the existing engine, runtime, UI and CLI test files.
Restore package-folder mismatch diagnostics and initialise consent-test catalogs.

* Plugin tests: keep a test-only command out of the icon audit

* Plugins: a link inside a granted folder is never followed

File authorization looks at a path as the plugin spells it, so a visible
symbolic link to a hidden folder (public -> .hidden) made
public/secret.txt readable, and let staged writes land in the hidden
folder, when no caller scope was set. Every file access now checks each
part of the requested path inside the granted folder and refuses a link
(or a Windows junction), for reads, writes and staged publication alike.
A plugin cannot create links itself: it only writes new regular files.

Test: a visible link to a hidden folder, and a file link to a hidden
file, are refused for reads and writes, nothing is staged through them,
and a plain file beside them still reads.

* Show plugin entry fuel use in CLI debug logs

* Plugin runtime README: links inside a granted folder are refused

* Plugins: main's new operations-panel tests build the Answer job with no inspection

main added two tests in control_job.rs that construct `Work::Answer` as a
unit value; on this branch the variant carries `inspection`.

* Designs keep plugin data under plugins/<plugin-id>/ untouched

A design container reserves plugins/<plugin-id>/ for a plugin's own files
(plugin_data, base64 by <plugin-id>/<path>, in a plain JSON design). They are
kept and saved back byte for byte whether or not the plugin is installed, and
opening a design never needs a plugin. One pending format file; the io design
tests cover save/open with the namespace and without the plugin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Plugins 0.1.0: craft:plugin@0.1.0, manifest capabilities, every MCP command

- The WIT package is craft:plugin@0.1.0; today's surface is the commands@0.1
  capability (engine -> commands, exported command -> entry). ui, viewport,
  formats and storage arrive later as their own versioned interfaces; 0.x may
  break between minors.
- plugin.json lists "capabilities": ["commands@0.1"] instead of runtime.api.
  The host refuses an unknown or newer capability at load with a typed,
  plain message ("needs commands 0.2; update SolidCraft or the plugin"), and a
  component importing another interface version before instantiation.
- The hard-coded command allowlist is gone: every command in the MCP catalog
  can be listed. Sensitive groups (file, doc, app, plugin) are refused unless
  the manifest requests them in permissions.command_groups and the user
  grants them; a granted file or doc command sees only the granted folders.
- Remove the stray REVIEW_REPORT.md; update docs and the test guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Plugins 0.1.0: cargo fmt

---------

Co-authored-by: kenos <crono2srv@gmail.com>
Co-authored-by: Brennen Herbruck <brennen.herbruck@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 21:18:11 +00:00
..

craft-plugin-wasm

App-independent Wasmtime component execution for craft-plugin. The app supplies commands through PluginHost; this crate has no SolidCraft or CAD dependency.

Public API and lifecycle

  • run(host, manifest, component, entry, params) uses default runtime options.
  • run_with_options(...) also accepts RuntimeOptions { stack_bytes }.
  • Both return (host, Result<serde_json::Value>), including on failure. The owned host must implement PluginHost + 'static because Wasmtime stores own their host data.

Each invocation compiles a component and creates a fresh store. After preparation, the runtime begins the app transaction, instantiates the component and calls its requested entry. Preparation failures return the host without starting a transaction. Guest failures request rollback; a successful JSON result requests commit_transaction.

Granted file writes are staged, and reads in that invocation can see staged content. A guest failure or failed app commit discards staged writes without replacing targets. After app commit, the runtime publishes writes in call order. Publication across several files is not atomic: an error can leave the app committed and some files changed. The returned error reports that possibility; this is not an unconditional rollback guarantee.

The caller owns approval and must enforce HostLimits::check before calling run. The runtime validates the runtime declaration and applies its requested budgets; it does not obtain user consent or install packages.

Sandbox and targets

Native execution is provided on x86-64 and AArch64. On other architectures, including browser wasm32, functions return the supplied host and HostError::Trap explaining that execution is unsupported. There is no browser execution backend.

The WIT imports app commands, logging, progress, cancellation, named files and a clock. No WASI is linked. Commands are intersected with the host catalog; read entries cannot invoke commands marked edit, and a command in a sensitive group needs that group requested by the manifest and granted by the host. A component importing another version of the craft:plugin interfaces is refused before instantiation with HostError::UnsupportedCapability. File access requires matching approved grants and PluginHost::authorize_file_path approval for each complete path. A symbolic link (or Windows junction) anywhere in a requested path inside a granted folder is refused, not followed. There is no ambient filesystem access. Wall time requires clock permission. Requests for net and reserved socket, HTTP and fetch imports are refused.

Fuel, epoch interruption and store limits bound guest execution. Defaults are 10,000,000 fuel, 64 MiB memory and 5000 ms. One linear memory is allowed; memory64 is disabled. Components are capped at 16 MiB and JSON parameters/results at 1 MiB each. RuntimeOptions defaults to a 512 KiB stack and accepts 64 KiB..64 MiB. Compilation and app-native command work are outside guest fuel accounting. The deadline cannot forcibly interrupt an arbitrary native host call.

Validation

From the repository root, cargo test -p craft-plugin-wasm exercises original synthetic components, transactions, traps, limits, file scope and staged writes on supported native targets. cargo xtask shared also checks isolated shared-crate builds and tests. See the runtime reference for full limits and app policy.