Skip to content

@usine/durable/attempt-runtime

What the parent said when it finished. Commits and pull requests are harvested by the executor afterwards.

  • Schema.Class

new AttemptReport(…args): AttemptReport

Parameter Type
…args [props: object, options?: MakeOptions]

AttemptReport

readonly message: string


One Attempt’s parent to run: its RunSpec, plus the checkout the parent and its children work in.

  • Schema.Class

new AttemptRequest(…args): AttemptRequest

Parameter Type
…args [props: object, options?: MakeOptions]

AttemptRequest

readonly cwd: string

Absolute path of the Attempt’s worktree on the machine its children run on.

readonly environment: object

The only process environment the parent’s children and every command they run may see: the Worker’s allowlisted variables plus the Attempt’s single-repo credential configuration (ADR 0011). The orchestrator’s own environment, which holds the App private key, is never inherited. On a RemoteShell host the variables are exported on top of the remote machine’s own environment.

[key: string]: string

readonly host: LocalProcess | RemoteShell

Where the parent’s children run.

readonly spec: RunSpec

readonly worker: string & Brand<"WorkerName">


Runs an Attempt’s Pi parent as a durable task in the orchestrator process.

execute is idempotent per Attempt id: the first call creates the task and its parent conversation, a later call (after an orchestrator restart) finds them in storage and waits for the same work. Everything the parent and its children do reaches io as attempt channel envelopes in order, so the transcript and the run drawer keep working unchanged.

  • Context.ServiceClass

readonly Service: object

The service’s operations: what yield* AttemptRuntime returns.

readonly cancel: (attemptId) => Effect.Effect<void, AttemptFailure>

Cancels the Attempt: aborts the task bottom-up (children, then the parent conversation) and settles execute.

Parameter Type
attemptId AttemptId

Effect.Effect<void, AttemptFailure>

readonly execute: (request, io) => Effect.Effect<AttemptReport, AttemptFailure>

Creates or reattaches the Attempt’s parent task, records its activity through io, and waits for its report.

Parameter Type
request AttemptRequest
io Sink

Effect.Effect<AttemptReport, AttemptFailure>

readonly finished: (attemptId) => Effect.Effect<Option.Option<FinishedAttempt>, AttemptFailure>

What the Attempt’s parent task left once it finished and execute relayed its terminal envelope, kept after that envelope so an orchestrator that stopped before recording the Attempt’s outcome can still finish it. None while the task runs or before the relay, after cancel, and when the Attempt has no task.

Parameter Type
attemptId AttemptId

Effect.Effect<Option.Option<FinishedAttempt>, AttemptFailure>

readonly intervene: (attemptId, intervention) => Effect.Effect<void, AttemptFailure>

Applies an operator action to the live parent or one of its children; the result is recorded through the Attempt’s sink.

Parameter Type
attemptId AttemptId
intervention Intervention

Effect.Effect<void, AttemptFailure>

readonly isLive: (attemptId) => Effect.Effect<boolean, AttemptFailure>

Whether the Attempt is still open in durable storage, so a restart reattaches instead of starting over. Stays true until execute has relayed the terminal envelope, even when the task itself finished earlier. A canceled task is never live.

Parameter Type
attemptId AttemptId

Effect.Effect<boolean, AttemptFailure>

readonly recordResult: (attemptId, result) => Effect.Effect<void, AttemptFailure>

Keeps the Attempt’s harvested result with its durable record, so finished returns it once the parent’s report is relayed.

Parameter Type
attemptId AttemptId
result StepResult

Effect.Effect<void, AttemptFailure>

readonly request: (attemptId) => Effect.Effect<Option.Option<StoredRequest>, AttemptFailure>

The request the Attempt’s task was created with, read back for a reattachment; none when the Attempt has no task.

Parameter Type
attemptId AttemptId

Effect.Effect<Option.Option<StoredRequest>, AttemptFailure>


The parent task ended with a failure.

  • Schema.Class

new ParentFailed(…args): ParentFailed

Parameter Type
…args [props: object, options?: MakeOptions]

ParentFailed

readonly failure: InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure


The parent reported success, and no harvested result was recorded: the Attempt’s checkout still has to be harvested.

  • Schema.Class

new ParentReported(…args): ParentReported

Parameter Type
…args [props: object, options?: MakeOptions]

ParentReported

readonly report: AttemptReport


The executor recorded the Attempt’s harvested result with recordResult.

  • Schema.Class

new ResultRecorded(…args): ResultRecorded

Parameter Type
…args [props: object, options?: MakeOptions]

ResultRecorded

readonly result: StepResult


What durable storage keeps of an Attempt’s request: what identifies its work. The child host and the environment describe the process that runs the Attempt, so each execute call supplies them afresh.

  • Schema.Class

new StoredRequest(…args): StoredRequest

Parameter Type
…args [props: object, options?: MakeOptions]

StoredRequest

readonly cwd: string

Absolute path of the Attempt’s worktree on the machine its children run on.

readonly spec: RunSpec

readonly worker: string & Brand<"WorkerName">

FinishedAttempt = typeof FinishedAttempt.Type

What durable storage keeps of an Attempt whose parent task finished and relayed its terminal envelope.

const FinishedAttempt: Schema.Union<readonly [typeof ParentReported, typeof ResultRecorded, typeof ParentFailed]>

What durable storage keeps of an Attempt whose parent task finished and relayed its terminal envelope.