SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Docs: RFCs 0001 (Craft bridge) and 0002 (plugins) (#13194)
bherbruckba43d2798f7d
diff --git a/docs/mcp.md b/docs/mcp.mdindex cb8b31ac7e..3a83af4d03 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -11,7 +11,7 @@ ordinary `execute` tool: `render.preflight`, `render.start`, `render.status`,in the session until explicit PNG export. See [render jobs](render-jobs.md).For sandboxed plugins and parametric timeline-features that also use `run(command, args)`, see [plugins.md](plugins.md). Desktop MCP in this+features that also use `run(command, args)`, see [RFC 0002](rfcs/0002-plugins.md). Desktop MCP in thisdocument remains the reference implementation today.## Start itdiff --git a/docs/plugins.md b/docs/plugins.mdindex 06981ff692..edc7be55d4 100644--- a/docs/plugins.md+++ b/docs/plugins.md@@ -1,142 +1,3 @@-# Plugins (design)+# Plugins-Design companion to [#1221](https://github.com/bherbruck/solidcraft/issues/1221): sandboxed-WebAssembly plugins with a WIT interface, the same `run(command, args)` JSON as-[MCP](mcp.md) and the [control protocol](control-protocol.md).--This document adds **parametric timeline features**: a generic host-owned feature shell that-plugins fill with parameters, display metadata, and rebuild logic, without a second timeline-model or a private geometry API.--## Goals (unchanged from #1221)--- Sandboxed by default: manifest permissions, fuel/memory limits on desktop, broker enforcement on web.-- Any language that compiles to Wasm components; Rust first.-- **One command surface:** plugins change the model only through engine commands (undoable, journaled).-- Versioned WIT world (`solidcraft:[email protected]`).--## Two plugin shapes--| Shape | Timeline | Rebuild | Milestone |-|-------|----------|---------|-----------|-| **One-shot** | Optional; often no persistent feature | N/A | 1 (first ship) |-| **Parametric** | One **`Plugin` feature row** per plugin instance | Host calls plugin on param/timeline rebuild | 2 |--One-shot plugins call `execute(params)` once; they may emit ordinary native features (sketch,-extrude, …) inside that transaction. Parametric plugins still use `run()` inside rebuild; the-difference is that the document **records** a single feature whose params the user edits later.--## Generic feature shell (host-owned)--Add one variant to the parametric document (name illustrative):--```text-FeatureKind::Plugin {- plugin_id: String, // "gear_generator"- api_version: u32, // matches WIT world- params: Value, // JSON owned by the plugin schema- display: PluginDisplay, // timeline + browser presentation- provenance: PluginProvenance, // optional: manifest hash, build id-}-```--**`PluginDisplay`** (stored in the file, not recomputed from plugin code at open):--| Field | Role |-|-------|------|-| `label` | Primary timeline / browser text |-| `icon_id` | Host icon registry name (same system as [`feature_icon`](https://github.com/bherbruck/solidcraft/blob/main/crates/ui-egui/src/workspace.rs)) |-| `tooltip` | Hover text, `inspect` type string |-| `type_name` | short feature type name for power users |--The timeline renders **any** `Plugin` feature through one code path: read `display`, draw icon +-label, wire suppress/rename/delete/reorder like built-in features. No per-plugin egui in milestone 2.--Optional later: **`parameter_schema()`** in WIT returns `{ id, label, kind, min, max, … }` so the-host renders sliders and dimension rows without custom UI per plugin.--## WIT entry points (phase 2 additions)--Milestone 1 (#1221): `manifest()`, `execute(params) -> result<string, string>`.--Milestone 2 parametric:--| Export | Purpose |-|--------|---------|-| `evaluate(params, ctx) -> result<string, string>` | Rebuild: plugin runs `run()` commands; result is success JSON or error |-| `parameter_schema() -> string` | Optional JSON schema for generic parameter UI |-| `fallback_policy() -> string` | Declares missing-plugin behaviour (see below) |--`ctx` is host-provided read-only hints (configuration name, units, feature id); plugins must not- rely on it for correctness.--Inside **`evaluate`**, the plugin uses the same **`run(command, args)`** import as one-shot mode.-The host applies commands to the current eval context (or a scratch session merged by the host).-No second registry of geometry ops.--## Rebuild flow--```text-Timeline rebuild reaches FeatureKind::Plugin- -> load plugin (wasmtime desktop / broker web) if permitted + present- -> evaluate(stored params)- -> plugin calls run("sketch.line", …), run("solid.extrude", …), …- -> host merges geometry like any native feature- -> errors surface on the feature row like native eval errors-```--Param changes (parameter panel, `parameters.change`, config switch) re-run **`evaluate`** for-affected plugin features only when dependencies say so (same invalidation rules as native features).--## Missing plugin and API drift--Manifest declares **`fallback_policy`**:--| Policy | Behaviour |-|--------|-----------|-| `recorded_mesh` | Optional B-rep or mesh blob stored beside params; open works, edit disabled without plugin |-| `recorded_script` | Stored list of native commands; rebuild without plugin if every command is built-in |-| `suppress_with_warning` | Feature suppressed; user sees clear message |-| `error_on_rebuild` | Hard fail on eval (strict teams) |--Shared design files should prefer a policy that **opens safely** (`recorded_mesh` or-`recorded_script`). CI for plugins (#1221) should include: uninstall plugin, reopen file, assert-document still opens and policy matches manifest.--## Icons and metadata--Plugins declare allowed **`icon_id`** values in `manifest()`; the host rejects unknown ids. Icons-stay in the app registry so untrusted plugins cannot inject arbitrary raster assets into the tree-without a reviewed icon pack.--**Rename** by the user updates the feature user label; **`display.label`** remains the default from-creation unless the plugin updates it via a host callback (optional future).--Command naming: prefer **`plugin_id.function`** in `run()` or registered command aliases to avoid-collisions ([#1221 discussion](https://github.com/bherbruck/solidcraft/issues/1221)).--## Group header variant (lighter-weight v2a)--Before full **`evaluate`**, a stepping stone: one-shot plugin creates a **feature folder** whose-header carries `PluginDisplay` metadata while children are ordinary native features. Rebuild does-not need the plugin until the user edits plugin-owned params on the header. Migrates cleanly to-full `FeatureKind::Plugin` when `evaluate` lands.--## Where the code lives--Plugin **document model and eval** stay in SolidCraft (`crates/doc`, `crates/engine`).--## Phasing--1. WIT + wasmtime host + one-shot `execute` + permissions tests (#1221 milestone 1).-2. `FeatureKind::Plugin` + `PluginDisplay` + timeline generic row + `evaluate` + fallback policy.-3. Web broker runs same WIT; parametric features offline only if plugin module cached and policy- allows.-4. Parameter schema UI, cloud-signed plugin index, inspector extensions.--## Tests (parametric)--- Create plugin feature, change param, rebuild, measure geometry (oracle or bbox).-- Undo/redo across plugin eval.-- Remove plugin binary, reopen design, assert fallback policy.-- Icon id from manifest appears on timeline (scenario or screenshot harness).+Moved to [RFC 0002: Plugins](rfcs/0002-plugins.md).diff --git a/docs/rfcs/0001-craft-bridge.md b/docs/rfcs/0001-craft-bridge.mdnew file mode 100644index 0000000000..8363604728--- /dev/null+++ b/docs/rfcs/0001-craft-bridge.md@@ -0,0 +1,130 @@+# RFC 0001: Craft bridge, handing work between Craft apps++| | |+|---|---|+| Status | Draft, open for comment |+| Started | 2026-11-07 |+| Apps | SolidCraft, CamCraft, PCBCraft |+| Discussion | the pull request that adds this file, then an issue per phase |++Nothing here is built yet.++## 1. Goals and non-goals++**Goals**+- One button: "Send to CamCraft" opens the current design in CamCraft, ready to set up.+- Round trips that stay linked: edit the model in SolidCraft, and CamCraft sees the new revision, re-finds its picked faces and regenerates or marks paths stale.+- The same for PCBCraft: board outline, holes and parts go to SolidCraft; the enclosure's outline and mounting points go back.+- Nothing is lost quietly. A reference that no longer resolves is reported by name.++**Non-goals**+- No merged app and no shared process. Each app runs and ships on its own.+- No shared file format. `.sc`, `.camproj` and PCBCraft's project stay as they are. The bridge adds one small exchange format between them.+- No editing another app's data. Each item has one owner app.++## 2. What crosses the bridge++One **exchange file**, `*.craftx`: a ZIP like the `.sc` container, with parts addressed by SHA-256 and a manifest.++| Part | Content | Notes |+|---|---|---|+| `manifest.json` | `format: "craft-exchange/1"`, source app and version, `source_id` (permanent design id), `revision`, content hash, units, the parts it has | Required. Readers ignore parts they don't know. |+| `bodies/<n>.record` | Exact B-rep as a solidcore-record body file | Preferred geometry. CamCraft can read it once its Solidcore milestone (M12.1) lands. |+| `bodies/<n>.step` | STEP of the same body | Fallback any app reads today. |+| `mesh/<n>.bin` | Triangles, plus a per-triangle face index | For apps that cut or display meshes. CamCraft slices meshes today. |+| `faces.json` | Per body: each face's index → persistent name, `exact` flag, surface type, aliases (names it also answers to after a merge). Edges the same way (`<face A>\|<face B>`). | The key to surviving edits. |+| `params.json` | Exposed parameters: name, value, unit, expression (read-only) | So CAM can show "wall = 3 mm", and PCB can drive SolidCraft parameters later. |+| `meta.json` | Material, part number, stock hint (box or offset), colour per face | Taken from design and component metadata. |+| `board.json` | PCB only: outline, cutouts, holes with names, part placements and heights, keep-outs | Defined with PCBCraft. |++**Stable ids.** SolidCraft already names every face and edge from kernel history (`F2:top`, `F4:side:l4`, `F2:top#[…]` for pieces, `F5:blend:<edge>` for rounds). `model.faces` reports them, with `exact: false` where a name was found by geometry. The exchange carries these strings as given. Receivers treat them as opaque strings. CamCraft picks today are facet-geometry hashes; a linked model would also store the face name, which survives an added hole where a facet hash may not.++## 3. Transport++| Option | Desktop | Browser (wasm) | Good for | Weak at |+|---|---|---|---|---|+| **A. Exchange file + file watching** | Yes. Write beside the design, watch for changes. | Same-origin apps can share OPFS. No watching, so poll or use the `BroadcastChannel` below. | Durable, works with either app closed, easy to debug | Update waits for a save |+| **B. Control channel session** (SolidCraft's existing loopback socket, token file, `control.subscribe` → `design.changed`) | Yes, already shipped | No sockets. The same messages can go over `postMessage` or `BroadcastChannel` between same-origin tabs. | Instant change notice, handshake | Both apps must run |+| **C. MCP** | Yes (stdio) | No | Agents driving both apps | Made for agent to app, not app to app. No events between apps. |+| **D. Launcher / "open in"** (start the other app with a path; later a registered file type or `camcraft://open?path=`) | Yes | `window.open` the other app's URL with the file in shared OPFS, or hand it over with `postMessage` | The button | Carries no updates by itself |++**Recommendation: A + D now, B as a speed-up.** The exchange file is the contract and the only thing an app must read. The button writes it and launches the other app with its path; live linking watches that file. A running app may also take a control-channel notice for faster updates. MCP stays for agents.++## 4. Linking and change propagation++- **A link** in the receiving project is `{source_id, path hint, revision, content hash}`. `source_id` is the permanent id. The path is only a hint, as in PCBCraft's file rules and SolidCraft's Insert Design links.+- **Change detection**: the exchange file's hash differs from the linked one → there's a new revision. Taking it can be automatic or one click; the receiver decides.+- **Re-resolving references** (each receiver does this, with the same outcomes SolidCraft uses for linked designs):++| Outcome | Meaning | Receiver does |+|---|---|---|+| exact | the name is there | keeps the pick |+| merged | another face answers to it as an alias | keeps it, notes the merge |+| split | several pieces carry the name | uses all pieces, or asks the user if that changes the meaning |+| by geometry | the name only matched on an `exact: false` face | keeps it, flags "check this" |+| missing | gone | **marks the operation broken, naming the face and where it was. It keeps the old path for viewing, refuses to post it, and asks the user to re-pick. Never dropped quietly.** |++- **Who owns what** (one owner per item; the other side holds a read-only linked copy, and Break Link turns it into its own editable copy):++| Item | Owner | Others get |+|---|---|---|+| Part geometry, parameters, face names | SolidCraft | CamCraft, PCBCraft (read) |+| Setups, stock, WCS, tools, toolpaths, posts | CamCraft | Nothing yet (maybe stock and as-machined bodies later) |+| Board outline, holes, part placement and heights | PCBCraft | SolidCraft (a linked body and sketch, like an inserted design) |+| Enclosure-driven outline and mount points | SolidCraft | PCBCraft (read, shown as a constraint it can accept) |++To change something you don't own, "Edit in SolidCraft" (or the owner app) opens the source.++## 5. The SolidCraft side++Every step is a command with input and output schemas. Programmatic calls never open dialogs.++| Command | Does |+|---|---|+| `bridge.export {path?, bodies?, parts?: [record, step, mesh], mesh_tolerance?}` | Writes a `.craftx` and returns `{path, revision, hash, faces, warnings}`. Refuses with `BadParams` on a design with feature errors or no bodies, saying why. |+| `bridge.send {app, bodies?}` | Exports, then launches `app` with the path. If the app isn't found, it returns an error that names the setting to fix. No file picker. |+| `bridge.links` | Lists the targets this design exports to and the exchanges it has inserted, each with revision, `changed` and missing references. |+| `bridge.auto {target, on}` | Rewrites the exchange on every save. |+| `file.insert_exchange {path}` | Brings in a PCBCraft board (or any `.craftx`) as a linked component. It reuses Insert Design's link, Update Links and Break Link machinery and face matching. |+| `component.update_links` | Also covers inserted exchanges. Reports joint and reference errors as it does today. |++Face names, `model.faces`, linked-design face matching, design metadata and `control.subscribe` already exist.++**Format additions** (one file per change in `crates/doc/src/format/pending/`):+- `design-source-id.rs`: a permanent random id for each design, made on first save. Older designs get one when next saved. A copy made with Save As gets a new one.+- `bridge-targets.rs`: the export targets (`app`, path hint, auto on or off).+Inserted exchanges ride the existing Import feature link fields. An older release warns, opens what it can and keeps the rest. Another app's private data, if ever stored in a design, goes under its own reverse-DNS metadata key, which SolidCraft already preserves.++**UI**: a "Send to CamCraft" button, and later "Send to PCBCraft". It changes the default ribbon, so the owner decides where it goes before it merges.++## 6. A contract any Craft app can implement++- **Read**: `craft-exchange/1`. A reader reads the parts it knows, warns about the rest, and never refuses a file for a newer minor version.+- **Versioning**: `craft-exchange/<major>`. Minor additions are new optional parts or fields. Only a major bump may change meaning. The manifest lists `requires` (the parts a reader must understand to use the file safely) separately from `parts`.+- **Capabilities**: strings with versions, e.g. `brep.solidcore-record/1`, `step/ap214`, `mesh/1`, `faces.names/1`, `params/1`, `meta/1`, `board/1`. A writer includes what it can. A reader takes the best it supports, preferring record, then STEP, then mesh.+- **Live session (optional)**: `bridge.hello {app, version, protocol: [1], capabilities}` gets the same answer back. Both use the highest common protocol and the capabilities they share. After that come `exchange.changed {source_id, revision, hash, path}` notices and `exchange.request {source_id}` asking for a fresh export. On desktop these go over the control channel. In the browser they go over `BroadcastChannel`, with the same JSON.+- **Launch**: each app accepts `--open <file.craftx>` (or a file path argument). A running instance should take the file over instead of starting a second window.+- **Units and frames**: millimetres, in the source design's world frame; the manifest carries the display unit. The receiver places bodies (WCS, component placement).++## 7. Phases++| Phase | Delivers | Who |+|---|---|---|+| 0 | Agree on this contract and the manifest | Both authors |+| 1 | **Send to CamCraft**: `bridge.export` (STEP, mesh, face table) plus launching CamCraft with the path. CamCraft imports the STEP as it does today. | SolidCraft. CamCraft only needs a path argument. |+| 2 | CamCraft reads `faces.json`: picks store face names, and re-sending updates the same model (its existing UpdateModel and stale marking), with the outcome table above | CamCraft |+| 3 | Live: `bridge.auto` + file watching. CamCraft either marks paths stale or regenerates; it never posts on its own. Plus a control-channel notice for running apps. | Both |+| 4 | Exact B-rep through solidcore-record, once CamCraft moves to Solidcore | Both |+| 5 | PCBCraft: board → SolidCraft via `file.insert_exchange`, and enclosure outline → PCBCraft, once PCBCraft has boards | PCBCraft, SolidCraft |+| 6 | Browser: shared OPFS, `BroadcastChannel`, `window.open` hand-off between same-origin web builds | All |++## 8. Open questions for CamCraft's author++1. **Would CamCraft store our face and edge names on its picks, next to its facet-hash ids, and re-resolve by name first?** That one choice decides whether CAM setups survive model edits.+2. Does `camcraft-ui` accept a file path at launch, and can a running window take a second file instead of opening a new one?+3. Should a linked model update automatically and mark paths stale, or regenerate them too, and with what confirmation?+4. Should stock and material come from SolidCraft (a stock hint in `meta.json`), or stay CamCraft-only?+5. Where should the exchange file live: beside the `.sc`, beside the `.camproj`, or copied into the project, as CamCraft keeps facets today?+6. Is there anything CamCraft wants to send back, such as the as-machined body for drawings, or fixture bodies for assemblies?+7. What's the timing for Solidcore (M12.1), so we know when to put the B-rep record first?+8. Would CamCraft add the optional live session over a socket, or is watching the file enough?diff --git a/docs/rfcs/0002-plugins.md b/docs/rfcs/0002-plugins.mdnew file mode 100644index 0000000000..b0552f7a16--- /dev/null+++ b/docs/rfcs/0002-plugins.md@@ -0,0 +1,143 @@+# RFC 0002: Plugins, sandboxed WebAssembly extensions++| | |+|---|---|+| Status | Draft, open for comment |+| Started | 2026-10-14 (when #1221 opened) |+| Apps | SolidCraft |+| Discussion | [#1221](https://github.com/tangency-labs/solidcraft/issues/1221) |+| Related | [#4980](https://github.com/tangency-labs/solidcraft/pull/4980) (draft WIT proposal, `solidcraft:[email protected]`), [#4933](https://github.com/tangency-labs/solidcraft/pull/4933) (plugin commands in Utilities) |++This RFC replaces `docs/plugins.md` and folds in what the 37 comments on #1221 settled. Only the Preferences page exists today. No plugin runs.++## 1. Goals and non-goals++**Goals**+- Drop in a file and get a new command, importer, exporter or sketch tool, without rebuilding the app.+- Sandboxed by default. A plugin can do only what its manifest asks and the user allows. A crash or a hang cannot take down the app or the model.+- Any language that compiles to a WebAssembly component. Rust first.+- One command surface. Plugins change the model only through the engine commands that MCP and the control channel already use, so every edit is undoable and journaled. No private geometry API.+- A plugin built for API 1 keeps loading after app updates.++**Non-goals**+- Not a way to override core commands. Overrides would make a model behave differently depending on what is installed.+- Not where core features go. CAM, for example, stays in-tree (#1153); plugins add vendor posts, niche strategies and importers on top.+- No plugin-to-plugin calls. If plugins ever cooperate, it goes through host events, and a failing listener never fails the caller.++## 2. The WIT contract++World `solidcraft:[email protected]`. The interface stays thin: a few typed functions plus the JSON command set, so the WIT stays small while the commands keep growing.++| Host import | Notes |+|---|---|+| `run(command, args) -> result<string, string>` | The engine commands, JSON in and out, exactly as over MCP. Filtered by the plugin's permissions. |+| `log`, `progress` | Always available. |+| `read-file`, `write-file` | Only inside folders the user granted. |+| `fetch` | Only with the `net` permission, only to origins named in the manifest, made by the host. |++| Export | Notes |+|---|---|+| `manifest() -> string` | JSON: id, name, version, kind, permissions, parameters. |+| `execute(params) -> result<string, string>` | A command or one-shot feature. |+| `import(...)` / `export(...)` | File formats. See below. |++**Settled in the comments**+- Plugin commands are namespaced `plugin_id.function`. They appear in `list_commands` and the Assistant's tool list with their parameter docs.+- Importers need the file name, not just bytes (the extension picks the format), and return a design plus a loss report. Assemblies need read access to the input's folder, granted as a permission. #4980 streams the input to keep each host call small.+- A trap fails that one call ("the importer failed on this file") and the next call gets a fresh instance.+- Entries declare `effect: read | edit`. A `read` entry is limited to query commands, so the agent chat can run it without asking.+- Entry inputs should be schemas built from the same field types as the command contracts (#2829), so one declaration gives a native dialog, strict MCP checks and generated tests. A one-line `params` doc is accepted until 1.0.++**Permissions** sit in the manifest, are shown on an approval screen, and are approved before any plugin code runs. A change to what was approved stops the plugin until the user approves again. A code-only update never adds an entry or surface silently.++| Permission | Grants |+|---|---|+| (none) | `run`, `log`, `progress` |+| `files` | Named folders, read or write |+| `net` | Named `https` origins. On the web build, only through a host-approved fetch. |+| `clock` | Wall clock. Without it, it reads a fixed epoch. |++## 3. Runtime and sandbox++| Item | Decision |+|---|---|+| Runtime | wasmtime on desktop, with the component model |+| CPU | Fuel or epoch interruption; the loop is stopped and the call fails |+| Memory | A per-plugin limit; a configurable stack (a real decoder needed about 16 MiB, wasmtime's default is 512 KiB) |+| WASI | None unless a permission grants a narrow slice |+| Failure | A fresh instance per call after a trap. The design and undo stack are untouched. |++**Binary-size trade-off.** wasmtime with Cranelift adds several MB to the app. wasmi is much smaller but runs core modules, not components. Options are wasmtime with Winch or Pulley, or accepting the size. Not decided.++**Component size.** #4980 caps components at 16 MiB. A real converter measured 28 MB (built for size) to 42 MB. Compiling happens in the app's process with no sandbox limit on the compiler, and the project forbids `unsafe`, so compiled code cannot be cached (`Component::deserialize` is `unsafe`). One plugin per format avoids most of this.++Rhai was proposed instead. The comments favour one runtime, WebAssembly, for isolation and language choice.++## 4. Plugin kinds++| Kind | Timeline | When |+|---|---|---|+| One-shot command | Optional. It may emit ordinary native features inside one undo step. | First |+| Importer / exporter | None. Opens as a new unsaved design. | First |+| Parametric feature | One `Plugin` feature row per instance, rebuilt when parameters change | Later |+| Panels, overlays, workspaces | Host-drawn from a declared schema | Later, see questions |++**Parametric features** (from `docs/plugins.md`). A host-owned `FeatureKind::Plugin` row stores `plugin_id`, `api_version`, the plugin's JSON `params`, and a `PluginDisplay` (label, icon id from the app's registry, tooltip, type name), all recorded in the file. The timeline draws any such row through one code path. On rebuild the host calls `evaluate(params, ctx)`, which uses the same `run` import, and merges the result like a native feature. An optional `parameter_schema()` lets the host draw sliders and dimension rows.++**SolidCraft never refuses to open a file.** Every parametric plugin declares a recorded fallback, so a design opens without the plugin:++| Fallback | Behaviour without the plugin |+|---|---|+| `recorded_script` | Replays a stored list of native commands, when every command is built in |+| `recorded_mesh` | Shows a stored B-rep or mesh; editing is disabled |+| `suppress_with_warning` | Feature is suppressed with a clear message |+| `error_on_rebuild` | Hard error; for strict teams only |++Shared designs should use one of the first two. A plugin's output should come from native features (sketches, extrudes, holes), so it works without the plugin. If a plugin cannot reach its goal that way, core is missing a building block. Opening a design never downloads or runs a missing package. Each instance keeps its plugin revision until the user updates it, and the update is undoable.++Design metadata under `plugin.<id>` survives a missing, disabled or newer plugin. Plugin store data is read additively across versions, and the first call after an update is told the previous version.++## 5. Distribution and signing++- **Now:** a folder per plugin, `{data}/plugins/<id>/plugin.json`.+- **Next:** Install Plugin from a file or GitHub release. An Add-on Manager lists tools, versions and permissions, with enable, disable and remove.+- **Later:** a curated index. Anyone can sideload. To be listed, a plugin must be open source and signed. The comments favour GitHub Releases as the artifact source and keeping packages independent of one host.+- **Tools:** `solidcraft-cli plugin check <dir>` validates the manifest and schemas; `plugin test <dir>` runs every entry on the real host; `--plugin-dev <dir>` loads an unapproved folder, marked as dev, and reloads on change. The `plugin.json` schema is generated from the host's types.++## 6. Web build++wasmtime does not run in the browser tab. Options are jco-transpiled components, or desktop-only plugins at first. The same WIT world and manifest should serve both, with the same permission checks before `run` reaches the engine. Parametric features offline on the web need the module cached, so only plugins whose fallback allows it. Network access on the web goes through a host-approved fetch, never the page's own.++## 7. What exists today++**Built**+- Preferences > Plugins (`crates/ui-egui/src/plugins.rs`, #2718): lists `{data}/plugins/<id>/plugin.json` folders, searches them, and turns each off. Turned-off ids are saved in `disabled_plugins`. Folders that are not plugins are listed with the reason.+- The manifest it reads has only `id`, `name`, `version` and `description`. It is checked and capped at 16 KiB.++**Not built**+- No wasmtime, no WIT file, no host, no example plugin, no permissions, no signing, no install flow (#4330 was closed), no `Plugin` feature kind. Nothing in the folder is loaded or run.+- #4980 is an open draft of the WIT and a gear pilot, and is not merged.++## 8. Phases++| Phase | Delivers |+|---|---|+| 1 | WIT, a wasmtime host with fuel and memory limits, `execute`, permissions in the manifest, tests: no file access without a grant, a runaway loop is stopped, a crash leaves the model untouched, undo works |+| 2 | Spur-gear example plugin, author guide, `plugin check` and `plugin test`, importers and exporters |+| 3 | `FeatureKind::Plugin`, `evaluate`, recorded fallbacks, generic timeline row |+| 4 | Install from file or GitHub, Add-on Manager, parameter schema dialogs |+| 5 | Web host on the same WIT |+| 6 | Curated, signed index; panels and overlays if agreed |++## 9. Open questions++1. **Wasmtime size and component limit.** Accept the binary growth, and raise the 16 MiB limit after measuring compile memory?+2. **Plugin UI.** Declarative panels, viewport overlays, then workspaces (the slicer-as-a-tab case). Or should such tools live in-tree?+3. **Defaults.** Are newly installed plugins on or off until approved?+4. **Local network.** May a plugin reach a companion service on the user's machine, entered by the user? Starting a print also needs a confirmation level above `edit`.+5. **Extending core commands.** Data-driven extension points, such as thread standards in the Hole dialog, later. Never overrides.+6. **Signing and the index.** What signs, who hosts the index, and who reviews listings?+7. **Web.** jco, or desktop only?+8. **Result annotations.** Text a plugin adds to command results can steer a model, so it needs its own threat model.+9. **Recorded macros.** A plugin kind or a core feature?+10. **Version numbers.** #4980 uses `0.1.0` until the interface settles; this RFC says `1.0.0`.diff --git a/docs/rfcs/README.md b/docs/rfcs/README.mdnew file mode 100644index 0000000000..f46a5550cb--- /dev/null+++ b/docs/rfcs/README.md@@ -0,0 +1,10 @@+# RFCs++Proposals for changes that cross apps or repositories, or that need agreement before code. Each RFC is one file, `NNNN-short-name.md`, numbered in order, with a status table at the top: Draft, Accepted, Rejected or Replaced.++A Draft is discussed in the pull request that adds it. Once accepted, the work is tracked in issues and the RFC links to them. An RFC records the decision; it is not a promise of a date.++| RFC | Title | Status |+|---|---|---|+| [0001](0001-craft-bridge.md) | Craft bridge: handing work between Craft apps | Draft |+| [0002](0002-plugins.md) | Plugins: sandboxed WebAssembly extensions | Draft |