Skip to main content

PLUGIN_WIT

Constant PLUGIN_WIT 

Source
pub const PLUGIN_WIT: &str = "// trace:v1 id=impl.crates-scc-plugin-api-src-plugin-wit work=WORK-SI-MMMJA4G6 implements=PLAN-SI-SYKFPBEC\n//! WIT interface for SCC WASM Component Model plugins (spec \u{a7}14).\n//!\n//! This file is the versioned ABI contract. A conforming host exposes the\n//! `scc:host/*` imports; a conforming plugin exports `manifest`, `register`,\n//! and `invoke-hook`. The JSON schemas for request/response are the same\n//! `PluginRequest`/`PluginResponse` shapes the process-plugin transport\n//! speaks over stdio, so one plugin implementation targets both runtimes.\n\npackage scc:plugin@1.0.0;\n\n/// Host capabilities offered to every plugin. A call fails with\n/// `permission-denied` unless the plugin\'s manifest grants the matching\n/// permission (spec \u{a7}21); grants are checked by the host, never the guest.\ninterface host {\n    /// Invoke a registered engine operation from inside a plugin.\n    /// `operation` is any operation id (`ranking.seed`, `graph.query`,\n    /// `acme.other-plugin-op`, \u{2026}); `input` is the operation\'s JSON input.\n    invoke-operation: func(operation: string, input: string) -> result<string, string>;\n\n    /// Namespaced plugin state (spec \u{a7}23). Keys are scoped to the calling\n    /// plugin id; blobs address large values by content hash.\n    state-get: func(key: string) -> result<option<string>, string>;\n    state-put: func(key: string, value: string) -> result<_, string>;\n    state-delete: func(key: string) -> result<_, string>;\n    state-scan: func(prefix: string) -> result<list<string>, string>;\n\n    /// Append-only diagnostic log (surfaced via `plugins.doctor`).\n    log-diagnostic: func(level: string, message: string);\n}\n\n/// What a plugin contributes: operation hooks and custom operations.\ninterface types {\n    /// A single extension registration.\n    record extension-registration {\n        /// Extension-point id: `rank-feature`, `reranker`, `seed-provider`,\n        /// `candidate-provider`, `edge-weight`, `similarity`,\n        /// `blend-profile`, `context-section`, `renderer`, `exporter`,\n        /// `evidence-provider`, `resolver`, `operation`, \u{2026}\n        extension-type: string,\n        /// Extension instance id, namespaced by the plugin\n        /// (e.g. `acme.security-risk`).\n        id: string,\n        /// Numeric priority: lower runs first; ties break by plugin id.\n        priority: s32,\n        /// Run after these extension ids (DAG edges; cycles are startup errors).\n        after: list<string>,\n        /// Run before these extension ids.\n        before: list<string>,\n    }\n\n    record plugin-manifest {\n        id: string,\n        name: string,\n        version: string,\n        api: string,\n        operations: list<string>,\n        /// Declared extension registrations (spec \u{a7}17).\n        extensions: list<extension-registration>,\n        deterministic: bool,\n    }\n\n    record hook-request {\n        /// Extension-point id being invoked.\n        extension-type: string,\n        /// Extension instance id.\n        extension-id: string,\n        /// JSON operation input (schema depends on the extension point).\n        input: string,\n    }\n\n    record hook-response {\n        /// JSON output; absent on error.\n        output: option<string>,\n        /// Error message; absent on success.\n        error: option<string>,\n    }\n}\n\nworld scc-plugin {\n    import host;\n    export manifest: func() -> types::plugin-manifest;\n    export register: func() -> list<types::extension-registration>;\n    export invoke-hook: func(request: types::hook-request) -> types::hook-response;\n}\n";
Expand description

WIT interface definition for the WASM Component Model host (spec §14). Checked in as the versioned ABI contract: any runtime implementing this world (wasmtime-based or otherwise) hosts scc-plugin.wit plugins. The JSON shapes (PluginRequest/PluginResponse) are identical to the process-plugin wire protocol, so a plugin written against these schemas runs on either runtime unchanged.