# AWL children, waits and failure

Child and subflow contracts, durable waits, sleeps and failure handlers.

A child workflow has its own run. A subflow is declared inside this document. Wait and sleep preserve progress durably; a failure handler declares what to do when fallible work fails.

## Children and subflows

- `child`: Declares a separate durable workflow this one may call and await. Arguments: form: declaration; positions: top-level.
- `spawn`: Starts a child workflow without waiting for it, so it can bind no result. Arguments: form: statement; positions: step-body.
- `subflow`: Declares an inline reusable graph with typed parameters and exactly one outcome, compiled into this workflow. Arguments: form: declaration; positions: top-level.


An ordinary child call waits and binds the result. Spawn starts without waiting and cannot bind a result. The child must be deployed with a matching contract. A subflow's invocation is the sole statement of a top-level step and may bind its outcome. It cannot sit inside a fork, loop, failure handler or substep. Subflows can nest but cannot recurse.

## Wait and sleep

- `wait`: Waits for a declared signal and binds it; a `timeout` makes that binding optional, because expiry is absence. Without one, the wait also guards a flow loop it sits on: no `max N visits` is needed. Arguments: form: statement; positions: step-body.
- `sleep`: Sleeps for a duration on a durable timer. Arguments: form: statement; positions: step-body.


A signal wait uses a declared receive contract. A timed wait handles its timeout path. Sleep creates a durable timer and releases execution capacity while waiting.

## Failure handling

- `on`: Opens a step failure handler, or names a signal that arms a workloop in its header. Arguments: form: statement; positions: workloop-header, step-body.


An on-failure block receives errors from the fallible operations it guards. Keep the handler inside the compiler's supported statement set: an untimed wait is accepted, while a loop, fork, timed wait or child spawn in that block is refused during bytecode compilation.

The [reference overview](/aion/reference/awl/#compiler-boundaries) lists every additional bytecode compilation restriction.
