call module

This block is part of the webassembly group and was last modified in core v15.0.3.

call module v15.0.3

Runs one export of a WebAssembly module with a JSON input and answers its JSON output: rules with loops, recursion or search that a block graph cannot be (pricing or tax rules, validators, simulations, a board game's legal moves).

In pins 7
  • module file required v15.0.3

    The .wasm file: a file pin (an uploaded or stored file of this app) or a path in the app's files.

  • export value required v15.0.3

    The export to call: a callable export of a rual_json_v1 module, or the name a command module receives as its argument.

  • input value v15.0.3

    Any value; sent as JSON. Empty sends null.

  • seed value v15.0.3

    Feeds the module's random numbers. Same seed, same numbers. A wired seed that is empty is refused.

  • now number v15.0.3

    The time the module reads, in milliseconds since 1970. Without it the module reads 1970.

  • timeout ms number v15.0.3

    Wall-clock budget, default 100, at most 5000.

  • memory mb number v15.0.3

    Memory cap in MiB, default 16, at most 256.

Out pins 5
  • output value v15.0.3

    The module's answer, decoded.

  • success condition v15.0.3
  • error value v15.0.3

    A fixed code when the call did not answer.

  • error detail object v15.0.3

    The module's own error object, the trap's kind, or the message.

  • duration ms number v15.0.3

    How long the call took.

Calls export of the WebAssembly module in the module file with input written as JSON, and decodes the module's JSON answer onto output (numbers as float64). Sandboxed and deterministic: the module sees its input, the seed and now, and nothing of the host : no files, network, environment or arguments (a command module gets only the export name), a wall clock fixed at now (ms since the epoch; the epoch without the pin), a monotonic clock that advances only as the module reads it, and random_get fed from the seed's stream (zeros without the pin). The same module bytes, export, input, seed and now give the same output on every node; NaN bit patterns from float arithmetic are not canonicalised. Every call gets a fresh instance: nothing carries from one call to the next. Two ABIs, detected from the module: rual_json_v1 (exports memory, rual_alloc(size i32) -> i32 and each callable export as (ptr i32, len i32) -> i64 returning ptr<<32|len of UTF-8 JSON; a reactor's _initialize runs first) and wasi_command (a WASI _start: the export name is argv[1], input on stdin, answer on stdout, exit code not 0 is an error). Only wasi_snapshot_preview1 imports are provided. input is a value, not JSON text: the text "[1]" is sent as the JSON string "[1]"; nothing is null. A seed or now pin that resolves to nothing is refused (EMPTY_SEED, EMPTY_NOW) rather than run unseeded. Limits: timeout_ms (default 100, at most 5000; never past the run's own deadline) interrupts even a tight loop; memory_mb (default 16, at most 256) caps linear memory; input and output 1 MiB each; module 16 MiB. On failure success=false, output empty and error one of: MODULE_NOT_FOUND, MODULE_INVALID, MODULE_TOO_LARGE, MODULE_LIMIT (it declares more locals, tables, table entries, functions or the like than the runner admits), EXPORT_NOT_FOUND, ABI_UNSUPPORTED, INPUT_TOO_LARGE, INPUT_NOT_JSON, OUTPUT_TOO_LARGE, OUTPUT_NOT_JSON, MEMORY_LIMIT, TIMEOUT, TRAP, WASM_BUSY (no slot on this node within the timeout), MODULE_ERROR, EMPTY_SEED, EMPTY_NOW, LIMIT_OUT_OF_RANGE, WASM_NOT_ENABLED. error_detail: with MODULE_ERROR the module's own error object (an answer {"error": {"code": …, "message": …}} and nothing else, or {exit_code, stderr} for a command that exited non-zero); with TRAP {trap, message} where trap is the kind (unreachable, out_of_bounds_memory_access, integer_divide_by_zero, stack_overflow, abi_violation, …); else {message}. duration_ms is wall time and is not deterministic. No flow pins: it runs when its output is read. Pure computation: it runs in simulations.

webassembly
wasm
rule engine
module

Version history

Introduced in v15.0.3.


Back to webassembly Return to the main group to view all sub-groups Back to modules Return to the group to view all blocks within this group