cc-lb-plugin-conformance 0.2.0

In-process conformance harness for cc-lb wasmtime plugin authors. Verifies plugin ABI and wire fingerprint matches host.
docs.rs failed to build cc-lb-plugin-conformance-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: cc-lb-plugin-conformance-0.1.3

cc-lb-plugin-conformance

cc-lb-plugin-conformance is a development dependency for cc-lb wasm plugin authors. It loads a compiled plugin through the same inspection, admission, and runtime path used by the host, then runs boundary smoke tests for the exported hook.

Use it in plugin crates to catch ABI, metadata, wire version, and layout fingerprint drift before uploading the wasm artifact.

Add as a Dev-Dependency

[dev-dependencies]
cc-lb-plugin-conformance = "0.2"

Build the plugin for wasm32-unknown-unknown before running the test:

cargo build --release --target wasm32-unknown-unknown

ConformanceSuite::from_wasm(bytes)

ConformanceSuite::from_wasm(bytes) inspects the artifact and infers the hook kind when the wasm exports exactly one supported hook.

use cc_lb_plugin_conformance::ConformanceSuite;

let wasm = std::fs::read(
    "target/wasm32-unknown-unknown/release/my_plugin.wasm",
)?;

let suite = ConformanceSuite::from_wasm(&wasm);

Use for_filter, for_shape, or for_observe instead when a single wasm artifact exports multiple hooks.

assert_recognisable_by_current_host()

assert_recognisable_by_current_host() runs the current host admission path:

  • compile the wasm module with wasmtime
  • verify required exports and import restrictions
  • parse plugin and hook metadata
  • verify declared wire versions are supported
  • verify embedded layout fingerprints match the current host
  • run the canonical runtime probe for each declared hook

This is the static gate to run in CI whenever the plugin or host crates change.

run()

run() builds a live wasmtime runtime, registers the plugin, and exercises the hook boundary with canonical sample payloads.

It verifies allocator exports, hook exports, rkyv encode/decode round-trips, and observe variant handling. It does not verify plugin business semantics such as routing policy or URL rewriting; keep those assertions in your own tests.

Sample Test

use cc_lb_plugin_conformance::ConformanceSuite;

fn wasm_bytes() -> Vec<u8> {
    std::fs::read(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/target/wasm32-unknown-unknown/release/my_plugin.wasm"
    ))
    .expect("build plugin wasm first")
}

#[test]
fn plugin_is_recognisable_by_current_host() {
    let wasm = wasm_bytes();
    ConformanceSuite::from_wasm(&wasm)
        .with_plugin_name("my-plugin")
        .assert_recognisable_by_current_host();
}

#[test]
fn plugin_passes_boundary_smoke() {
    let wasm = wasm_bytes();
    ConformanceSuite::from_wasm(&wasm)
        .with_plugin_name("my-plugin")
        .run();
}

Links

License

Licensed under the workspace license.