Repository navigation
feat(host): upgrade plugin contract to codeint:plugin@0.2.0 - #205
Merged
Merged
Conversation
Upgrade wit/language.wit and wit/metric.wit to codeint:plugin@0.2.0, adding function name and cognitive-complexity fields, external(string) and builtin resolution variants, declared-dependencies, and entry-points. Bind 0.2.0 in crates/model and crates/plugin-host, detect incompatible WIT contract versions (such as 0.1.0) with an actionable IncompatibleContractVersion error, add compiling 0.2.0 stubs across all five built-in Language plugins, update the sample Wasm Plugin and sandbox probes, add 0.2.0 contract and 0.1.0 rejection tests, and update Plugin documentation. Closes #190
Comment on lines
+216
to
+233
| } | ||
|
|
||
| impl WasmLanguagePlugin { | ||
| pub(crate) fn from_verified_bytes( | ||
| name: String, | ||
| path: &Path, | ||
| bytes: &[u8], | ||
| limits: PluginLimits, | ||
| ) -> Result<WasmLanguagePlugin, PluginHostError> { | ||
| let (engine, instance_pre) = compile_sandboxed_component(&name, path, bytes)?; | ||
| let ticker = EpochTicker::start(engine.clone()); | ||
| let pre = bindings::LanguagePluginPre::new(instance_pre).map_err(|error| { | ||
| PluginHostError::Instantiate { | ||
| name: name.clone(), | ||
| path: path.to_path_buf(), | ||
| reason: error.to_string(), | ||
| } | ||
| })?; | ||
| let mut store = new_limited_store(&engine, limits); | ||
| let bindings = pre | ||
| .instantiate(&mut store) | ||
| .map_err(|error| map_host_trap(&name, path, None, limits, &store, error))?; | ||
| arm_call_deadline(&mut store, limits); | ||
| let extensions = bindings | ||
| let mut component = instantiate_sandboxed_component( | ||
| &name, | ||
| path, | ||
| bytes, | ||
| limits, | ||
| LANGUAGE_CONTRACT, | ||
| bindings::LanguagePluginPre::new, | ||
| |pre, store| pre.instantiate(store), | ||
| )?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades the
codeintPlugin WIT contract fromcodeint:plugin@0.1.0tocodeint:plugin@0.2.0acrosswit/,crates/model,crates/plugin-host, all five built-in Language plugins (compiling stubs), the sample Wasm Plugin, sandbox probes, and Plugin documentation—adding functionname,cognitive-complexity,external(string)/builtinresolutions,declared-dependencies, andentry-pointsin one coordinated bump (foundational for Specs #173 and #175), with hardened hostcall-fuel amplification bounds, return-value contract validation, and dual-version component support.Closes #190
Tier
Tier 3 from the tier check: modifies
crates/plugin-host/**and upgrades the WebAssembly Plugin WIT contract to0.2.0.Task
Ticket #190 (Parent Spec #173, shared foundation for Spec #175):
codeint:plugin@0.2.0with optional functionname,cognitive-complexity,external(string)/builtin,declared-dep/dep-kind,declared-dependencies, andentry-pointscrates/modelandcrates/plugin-hostto bind0.2.0, reject legacy0.1.0-only Wasm Plugins with an actionable error, support dual-version0.1.0+0.2.0components, enforce hostcall fuel + lifted-size caps, and validate returned entry points and declared dependenciests,rust,python,php,dart) and the sample Wasm Plugin to compile and pass workspace tests greendocs/plugins.md,crates/model/HOW-TO.md, andcrates/plugin-host/HOW-TO.mdforcodeint:plugin@0.2.0Fail-first test
crates/plugin-host/tests/load.rs(rejects_v0_1_0_language_plugin_with_actionable_version_mismatch_error,rejects_v0_1_0_metric_plugin_with_actionable_version_mismatch_error,rejects_canonical_abi_aliased_string_amplification_bomb,rejects_invalid_entry_points_and_declared_dependencies_from_wasm_plugin)0.1.0 Language plugin must be rejected by 0.2.0 host/0.1.0 Metric plugin must be rejected by 0.2.0 host)Checks
cargo test --workspace --lockedcargo clippy --workspace --all-targets -- -D warningscargo fmt --checkcodeint diff fce5585lefthookpre-commit and commit-msgcargo run --package xtask -- merged-result)Safety proof
Linker), checked statically for the required0.2.0export before executing any guest code, bounded in both linear memory and Canonical ABI hostcall-fuel lifting byPluginLimits::memory_mb, interrupted on timeout via epoch ticks, and validated on all returned repository paths and declared dependencies.crates/plugin-host/tests/load.rsexercises real compiled Wasmtime components (legacy-v0-1-0-language,legacy-v0-1-0-metric,dual-version-language, memory/loop/trap/aliased-string/traversal probes) underPluginLimits, andcrates/plugin-host/src/limits/tests.rs+crates/model/src/tests.rsverify budget and path validation invariants.interrogate: Round 1 found 5 verified issues (silent trap/timeout swallowing on new exports, Canonical ABI aliased-string amplification, missing path/name contract validation, dual-version0.1.0+0.2.0false rejection, TS?/#suffix and empty specifier handling). All 5 were fixed with dedicated regression tests in0edb700; freshinterrogatererun + Independent Review confirmed PASS with 0 remaining verified findings, andmain(e4528d1) merged cleanly at0be31afwith 0 conflicts and 0codeint diffregressions.Runtime evidence
Compiled Wasmtime
wasm32-wasip2component probes and sample Plugins were loaded and executed throughcodeint-plugin-hostand thecodeintCLI on revision0edb700(cargo test --workspace --lockedandcodeint diff fce5585both exited 0 with zero regressions).Gaps