Module Contract Guide

This guide documents the contract qip expects for modules, and how it passes input in and reads output back.

Quick Model

Run Mode Contract

In qip run, modules can export pointer/cap values as either:

qip accepts both styles.

Required input exports:

Optional output exports:

Required function:

If output_ptr + output cap are not exported, qip falls back to printing Ran: <run_return_value>.

WebAssembly Module Contract

input_utf8_cap / input_bytes_cap

Use input_utf8_cap for UTF-8 text input and input_bytes_cap for binary input.

output_utf8_cap / output_bytes_cap / output_i32_cap

Use output_utf8_cap for UTF-8 text output, output_bytes_cap for binary output, and output_i32_cap for i32[] output.

If output exports are omitted, the return value of run is used as the result.

If output exports are present, the return value of run is used as the output size.

Optional Content Type Metadata

Run modules may optionally export content type metadata for friendlier composition and host Content-Type selection.

Rules:

Input/Output Semantics

Input:

Output:

Capacity units:

Memory Layout Recommendations

Image Mode Memory

For qip image / RGBA filters:

Tile byte size:

tile_bytes = tile_span * tile_span * 4 channels * 4 bytes(float32)

Where:

If any stage exports calculate_halo_px with halo > 0, host uses the full-image float32 pipeline for all stages in the contiguous image block.

See also: IMAGE.md.

Practical Checklist