Cotal TypeScript packages
    Preparing search index...

    Interface EffectContext

    interface EffectContext {
        attempt: number;
        key: StepKey;
        requestId: string;
        resume?: Readonly<Record<string, unknown>>;
        signal: CancelSignal;
        bind(external: Readonly<Record<string, unknown>>): Promise<void>;
    }
    Index
    attempt: number

    Which attempt of this step EffectContext.requestId names, counted from 0.

    Only an escalating checkpoint ever exceeds 0, and it is the interpreter, not the handler, that decides whether to hop. A handler reads this for tracing and for the far side's own idempotency bookkeeping; it must not treat a non-zero attempt as licence to retry, because the attempt that is open is the only one it has been asked to complete.

    key: StepKey

    The key of the step being performed. Handlers use it for tracing, never for lookup.

    requestId: string

    base64url(sha256(runId, stepKey, inputHash, attempt)), on the pending entry BEFORE this handler was called. SUBMIT UNDER IT, idempotently: a resumed run reissues the same id and the far side recognises it rather than creating a second goal. This is the identity that makes an effect recoverable; EffectContext.bind carries facts the handler LEARNS and is never what recovery keys on, because a crash before the handler learned them leaves none.

    resume?: Readonly<Record<string, unknown>>

    Present when a previous attempt at this step started but never settled, carrying whatever it passed to EffectContext.bind. The handler must RE-BIND to that resource and await its terminal, not issue a fresh action: the goal already exists, the checkpoint token is already minted, and issuing a second one is how a crash turns into a duplicate side effect. A step inside once is never re-dispatched with it: it holds (spec/cotal-lang.md §7.8).

    signal: CancelSignal
    • Declare the external resource this effect just created, BEFORE awaiting its terminal.

      This is what makes a crash mid-effect recoverable: the pending journal entry points at a real thing, so a resumed run re-binds to it and awaits its outcome instead of issuing a second action. Idempotency then comes from the layer underneath (a goal's bind fingerprint, a checkpoint's one-use settle fact, a work item's lease).

      Parameters

      • external: Readonly<Record<string, unknown>>

      Returns Promise<void>