Skip to content

Timeout and cancellation effects #227

@aallan

Description

@aallan

Add timeout and cancellation effects to the effect system.

Motivation

Agent workloads constantly need bounded execution: limiting API calls to N seconds, cancelling in-flight work when a parent task completes, racing multiple operations and returning the first result. These compose naturally as algebraic effects.

Proposed effects

fn fetch_with_timeout(@String -> Result<@String, @String>)
  effects(<Http, Timeout>)
{
  Timeout.with_deadline(5000, fn(-> Result<@String, @String>) effects(<Http>) {
    Http.get(@String.0)
  })
}
  • Timeout.with_deadline(ms, thunk) — run thunk with a wall-clock deadline
  • Timeout.cancel() — cancel the current operation
  • Effect handlers at the host level enforce actual time limits via wasmtime fuel/epoch interruption

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    C9C9 — Language designenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions