Module wasm

Module wasm 

Source
Expand description

proxy-wasm host (DW-055).

This module implements a proxy-wasm ABI host on top of wasmtime, allowing dwara to run community Kong/Envoy proxy-wasm filters unmodified. The host compiles unconditionally in the OSS build (there are no cargo features for it): dataplane::plugin_dispatch (DW-157) drives it on the live request path for routes that reference plugins.

§Architecture

  • abi — proxy-wasm ABI constants and header map serialization.
  • host — the wasmtime host: engine, linker (ABI imports), plugin module, and per-request instance.

§Phase contract (§9.3)

dwara’s request pipeline calls plugin phase callbacks at defined points. Each plugin declares which phase(s) it hooks. The phases relevant to HTTP filters are:

  1. request_headers — after route resolution, before authn.
  2. request_body — after authn/authz/rate-limit, before upstream.
  3. response_headers — after the upstream responds, before masking.
  4. response_body — after masking, before compression.

A plugin can short-circuit the request by calling proxy_send_http_response (returns a local response instead of forwarding to the upstream). The host catches this and returns the stored response immediately.

§Fuel and epoch preemption (decision 4; §9.3)

Each plugin instance gets a fuel budget (PluginLimits::fuel). wasmtime consumes fuel on every operation; exhaustion traps the plugin, which the host converts to a 500. Memory is capped via wasmtime’s ResourceLimiter. Time caps use epoch interruption.

§Done-when

A community Kong/Envoy proxy-wasm filter runs unmodified. The test suite includes a minimal proxy-wasm filter compiled from Rust source that exercises the core ABI surface (header inspection, response short-circuit, body modification).

Re-exports§

pub use abi::deserialize_header_map;
pub use abi::serialize_header_map;
pub use abi::ACTION_CONTINUE;
pub use abi::ACTION_END_STREAM;
pub use callout::perform_callout;
pub use callout::CalloutError;
pub use callout::CalloutRequest;
pub use callout::CalloutResponse;
pub use callout::CALLOUT_BODY_CAP_BYTES;
pub use callout::CALLOUT_TIMEOUT_MAX_MS;
pub use callout::CALLOUT_TIMEOUT_MIN_MS;
pub use callout::MAX_CALLOUT_ROUNDS;
pub use host::LocalResponse;
pub use host::PendingCallout;
pub use host::PhaseResult;
pub use host::PluginContext;
pub use host::PluginInstance;
pub use host::PluginLimits;
pub use host::PluginMetric;
pub use host::PluginMetricType;
pub use host::PluginModule;
pub use host::WasmEngine;
pub use lifecycle::LoadError;
pub use lifecycle::LoadedPlugin;
pub use lifecycle::PluginHealth;
pub use lifecycle::PluginLifecycle;
pub use lifecycle::ValidationError;
pub use runner::PhaseOutcome;
pub use runner::PluginInstances;
pub use runner::PluginRunner;
pub use source::resolve_sources;
pub use source::SourceError;
pub use source::SourceResolutions;
pub use source::DEFAULT_CACHE_DIR;

Modules§

abi
proxy-wasm ABI constants and types (DW-055).
adapter
The WASM-to-unified-chain adapter (DW-119).
callout
Plugin HTTP callout transport (DW-167, issue #285).
host
proxy-wasm host implementation (DW-055).
lifecycle
Plugin lifecycle (DW-056).
runner
Plugin runner — the integration layer between the proxy pipeline and the proxy-wasm host (DW-055).
source
Registry plugin source resolution (DW-165).