aion/awl/runtime

The generic run shell and literal-list indexing hoisted out of every generated AWL module (AWL-BC-0, hoist-only).

run is the engine entry point’s body: it reproduces the three-stage decode/execute/encode case tree with the exact failure strings the emitter used to inline. Each generated module keeps a three-line run/1 wrapper (the engine invokes it by name) that forwards to this function with the module’s own codecs and execute.

Values

pub fn index(
  items: List(a),
  index: Int,
  label: String,
) -> Result(a, error.AwlError)

Literal-only list indexing; out of range is a step failure carrying the source-anchored label the emitter built.

pub fn run(
  raw_input: dynamic.Dynamic,
  input_codec: codec.Codec(input),
  output_codec: codec.Codec(output),
  execute: fn(input) -> Result(output, error.AwlError),
) -> Result(String, String)

Decode the raw engine input to a string, decode it with input_codec, run execute, and encode the outcome with output_codec. Failure strings are byte-identical to the code the emitter used to inline.

A failure is returned as the AwlError codec’s OWN encoding (the {"tag":…} JSON object), exactly like workflow.entrypoint encodes a definition’s typed error. The engine records that text as the run’s failure details, and an awaiting parent decodes it back with the same aion/awl/error codec it already holds — so typed kinds such as AwlVisitsExceeded survive the parent-child boundary instead of leaking the raw error record (whose term-to-JSON image is a list, which the codec’s object decoder can never accept).

Search Document