Skip to content
DocumentationExecution
On this page

Page resources

Open Markdownllms.txtView source

Last updated

Execution

Execution owns how bounded work runs: tasks, threads, scheduling, cancellation, deadlines, signals, queues, backpressure, supervision, and resource budgets. It does not own application operations, workflow meaning, or provider selection.

Structured concurrency is the default

Every task belongs to a scope with an owner, children, completion policy, and cleanup path. A parent cannot report completion while silently abandoning child work. Detached work requires a durable owner such as a job, workflow, service, or explicitly retained host process.

Cancellation is a request propagated through the scope. Each boundary declares whether it can stop before dispatch, interrupt execution, drain, or merely stop waiting. Dropping a handle is never interpreted as rollback.

Time is typed

Deadlines, timers, leases, retry schedules, wall timestamps, and monotonic durations use their applicable time authorities. Distributed wall clocks carry uncertainty. Leases and fences do not rely on untrusted wall time alone.

Simulation replaces time and entropy with exact providers. Simulated results remain visibly non-production evidence.

Capacity is finite

Tasks declare or acquire CPU, memory, thread, blocking, accelerator, I/O, queue, and concurrency budgets. Schedulers enforce priorities and fairness within their authority domain.

Backpressure begins at bounded queues and propagates through streams and calls. When propagation is impossible, the contract chooses rejection, shedding, sampling, spill, or bounded loss. Unbounded buffering is never a hidden default.

Failure has a parent

Panic, process exit, lost worker, deadline, cancellation, resource exhaustion, and provider defects have distinct dispositions. Supervision policy chooses restart, escalate, degrade, quarantine, or terminate, with attempt budgets and effect safety checked before repetition.

A runtime crash does not erase effect intent. Durable operations and workflows resume through their owning journals and histories.

Runtimes are replaceable

A single-thread executor, work-stealing runtime, real-time loop, Wasm host, language runtime, OS process, batch scheduler, or distributed worker pool may realize selected execution contracts. Each profile states scheduling, cancellation, isolation, resource, timing, failure, and observation guarantees.

Portable computation is a separate contract. Code is not considered portable merely because a scheduler can send bytes to another machine.

Example

Illustrative structured concurrency bounds children and waits for completion:

let mut scope = ctx.execution().scope();
scope.spawn_bounded(validate(batch)).await?;
let results = scope.join_all().await?;

Follow Manage resources and execution.

Canonical owner: Execution.