Skip to content

feat(host): upgrade plugin contract to codeint:plugin@0.2.0 - #205

Merged
avidianity merged 4 commits into
mainfrom
feat/190-plugin-contract-0-2-0
Nov 23, 2026
Merged

avidianity merged 4 commits into
mainfrom
feat/190-plugin-contract-0-2-0

Conversation

@avidianity

@avidianity avidianity commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Upgrades the codeint Plugin WIT contract from codeint:plugin@0.1.0 to codeint:plugin@0.2.0 across wit/, crates/model, crates/plugin-host, all five built-in Language plugins (compiling stubs), the sample Wasm Plugin, sandbox probes, and Plugin documentation—adding function name, cognitive-complexity, external(string) / builtin resolutions, declared-dependencies, and entry-points in 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 to 0.2.0.

Task

Ticket #190 (Parent Spec #173, shared foundation for Spec #175):

  • Upgrades WIT package to codeint:plugin@0.2.0 with optional function name, cognitive-complexity, external(string) / builtin, declared-dep / dep-kind, declared-dependencies, and entry-points
  • Updates crates/model and crates/plugin-host to bind 0.2.0, reject legacy 0.1.0-only Wasm Plugins with an actionable error, support dual-version 0.1.0+0.2.0 components, enforce hostcall fuel + lifted-size caps, and validate returned entry points and declared dependencies
  • Updates all five built-in Language plugins (ts, rust, python, php, dart) and the sample Wasm Plugin to compile and pass workspace tests green
  • Updates docs/plugins.md, crates/model/HOW-TO.md, and crates/plugin-host/HOW-TO.md for codeint:plugin@0.2.0

Fail-first test

  • 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)
  • Before the change: failed (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)
  • After the change: passed (all plugin-host load, conformance, sandbox probe, and workspace tests green)

Checks

Check Result
cargo test --workspace --locked passed
cargo clippy --workspace --all-targets -- -D warnings passed
cargo fmt --check passed
codeint diff fce5585 passed (0 regressions)
lefthook pre-commit and commit-msg passed
Merged-result check (cargo run --package xtask -- merged-result) passed

Safety proof

  • Safety fact: Every external WebAssembly Plugin is verified by SHA-256 before compilation, linked with zero host capabilities (empty Wasmtime Linker), checked statically for the required 0.2.0 export before executing any guest code, bounded in both linear memory and Canonical ABI hostcall-fuel lifting by PluginLimits::memory_mb, interrupted on timeout via epoch ticks, and validated on all returned repository paths and declared dependencies.
  • Proof: crates/plugin-host/tests/load.rs exercises real compiled Wasmtime components (legacy-v0-1-0-language, legacy-v0-1-0-metric, dual-version-language, memory/loop/trap/aliased-string/traversal probes) under PluginLimits, and crates/plugin-host/src/limits/tests.rs + crates/model/src/tests.rs verify 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-version 0.1.0+0.2.0 false rejection, TS ?/# suffix and empty specifier handling). All 5 were fixed with dedicated regression tests in 0edb700; fresh interrogate rerun + Independent Review confirmed PASS with 0 remaining verified findings, and main (e4528d1) merged cleanly at 0be31af with 0 conflicts and 0 codeint diff regressions.

Runtime evidence

Compiled Wasmtime wasm32-wasip2 component probes and sample Plugins were loaded and executed through codeint-plugin-host and the codeint CLI on revision 0edb700 (cargo test --workspace --locked and codeint diff fce5585 both exited 0 with zero regressions).

Gaps

  • Deferred coverage: none
  • Pre-existing failures: none
  • Environmental failures: none

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),
)?;
@github-actions github-actions Bot added the tier-3 Tier 3 from the tier check label Nov 23, 2026
@avidianity
avidianity merged commit 9171c0d into main Nov 23, 2026
13 of 14 checks passed
@avidianity
avidianity deleted the feat/190-plugin-contract-0-2-0 branch November 23, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tier-3 Tier 3 from the tier check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codeint:plugin@0.2.0 WIT contract, model, plugin-host, and sample Wasm Plugin upgrade

2 participants