Skip to content

@usine/executor

The usine scoped Worker contract with local, exe.dev, and SSH adapters.

The serializable location and RunSpec of an Attempt checkout. Owning this record does not grant access to live resources or credentials.

  • Schema.Class

new AttemptWorkspace(…args): AttemptWorkspace

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

AttemptWorkspace

readonly spec: RunSpec

readonly worker: string & Brand<"WorkerName">

readonly worktree: string & Brand<"WorktreePath">


The repository, revision, and Agent task assigned to a Worker for one Attempt’s checkout.

  • Schema.Class

new CheckoutRequest(…args): CheckoutRequest

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

CheckoutRequest

readonly agent: Agent

readonly attemptId: string & Brand<"AttemptId">

readonly maxAttemptMinutes: Option<number>

Maximum minutes of live Attempt execution, or none for no timer; preparation and resource cleanup are outside this budget.

readonly maxAttemptTokens: Option<number>

Maximum consumed tokens across the parent and every child, or none for no token ceiling; operator Holds never pause this ceiling.

readonly maxChildren: number & Brand<"ChildSessionBudget">

readonly parentEffort: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"

readonly parentModel: Option<string & Brand<"ModelId">>

readonly payload: Json

readonly reattach: boolean

The Attempt outlived an orchestrator restart and its parent task is still live: preparation takes over the checkout it already has instead of creating one, and launch reattaches to the running parent.

readonly repository: string & Brand<"RepositoryName">

readonly resume: Option<SalvagePushed>

The previous Attempt’s pushed salvage to check out instead of the bare revision.

readonly revision: string & Brand<"RepositoryRevision">

readonly salvageRef: string & Brand<"SalvageRef">

Where the Worker pushes this Attempt’s unfinished work if the Attempt ends without success.

readonly task: string & Brand<"AttemptTask">

readonly worker: string & Brand<"WorkerName">


Mints renewable repository-scoped credentials for an Attempt.

  • Context.ServiceClass

readonly Service: object

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

readonly issue: (repository, attemptId) => Effect.Effect<WorkerCredential, CredentialUnavailableError>

Parameter Type
repository RepositoryName
attemptId AttemptId

Effect.Effect<WorkerCredential, CredentialUnavailableError>


A Worker could not obtain access to the repository assigned to an Attempt.

  • Schema.Class

new CredentialUnavailableError(…args): CredentialUnavailableError

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

CredentialUnavailableError

readonly cause: unknown

readonly message: string

readonly repository: string & Brand<"RepositoryName">


Prepares isolated checkouts, runs Attempts on a Worker, and releases their resources (ADR 0006).

  • Context.ServiceClass

readonly Service: object

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

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

Stops preparation and releases partial resources, or cancels the live parent task with a grace period before forced termination. A canceled prepared Attempt cannot launch. Repeated cancellation after release is a no-op.

Parameter Type
attemptId AttemptId

Effect.Effect<void, ExecutorError>

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

Delivers an attributed operator action to the active Attempt’s live session.

Parameter Type
attemptId AttemptId
intervention Intervention

Effect.Effect<void, AttemptFailure>

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

Whether the Attempt’s parent task survived an orchestrator restart and can be reattached: it still runs, or it reported success before its checkout was harvested.

Parameter Type
attemptId AttemptId

Effect.Effect<boolean, AttemptFailure>

readonly kind: WorkerKind

readonly outcome: (attemptId) => Effect.Effect<Option.Option<Result.Result<StepResult, AttemptFailure>>, AttemptFailure>

The result an Attempt’s finished parent task left in durable storage before an orchestrator restart: the harvested result, or the parent’s failure. None when nothing was stored, or when isLive says the Attempt is reattached instead.

Parameter Type
attemptId AttemptId

Effect.Effect<Option.Option<Result.Result<StepResult, AttemptFailure>>, AttemptFailure>

readonly preflight: (worker, brains) => Effect.Effect<void, ExecutorError>

Verifies Git and each rostered brain where the Worker runs children; never installs tools or logs in.

Parameter Type
worker WorkerName
brains ReadonlyArray<BrainSpec>

Effect.Effect<void, ExecutorError>

readonly prepare: (request) => Effect.Effect<PreparedAttempt, ExecutorError, Scope.Scope>

Verifies the assigned brain before acquiring the Attempt in the caller’s scope. Clone, fetch, and lock waits remain interruptible; partial preparation releases everything already acquired before reporting failure. Each request identifies a fresh Attempt, or a live one to reattach when reattach is set.

Parameter Type
request CheckoutRequest

Effect.Effect<PreparedAttempt, ExecutorError, Scope.Scope>

readonly recover: <E>(attempt, record) => Effect.Effect<void, E | ExecutorError>

Reconciles an old checkout before new Attempts start; records its salvage before releasing any work.

Type Parameter
E
Parameter Type
attempt AttemptRecovery
record (salvage) => Effect.Effect<void, E>

Effect.Effect<void, E | ExecutorError>


A Worker operation failed before its requested work completed.

  • Schema.Class

new ExecutorOperationError(…args): ExecutorOperationError

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

ExecutorOperationError

readonly cause: unknown

readonly message: string

readonly operation: "launch" | "preflight" | "prepare" | "cancel" | "cleanup"


A verify-only preflight found a Worker capability missing or incompatible.

  • Schema.Class

new WorkerCapabilityError(…args): WorkerCapabilityError

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

WorkerCapabilityError

readonly capability: "gateway" | "machine" | "toolchain" | "harness-login" | "credentials"

readonly cause: unknown

readonly message: string

readonly worker: string & Brand<"WorkerName">


A repository-scoped Worker credential and the instant at which it stops authorizing requests.

  • Schema.Class

new WorkerCredential(…args): WorkerCredential

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

WorkerCredential

readonly expiresAt: Utc

readonly value: Redacted<string>

One prepared Attempt with a scoped checkout and repository access. Use it within the scope that prepared it. Closing that scope stops any active session before removing the checkout and releasing credentials, including when launch never starts.

readonly launch: (io) => Effect<StepResult, InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure>

Runs this Attempt once, recording channel activity through io. Completion, failure, or interruption releases its resources before returning. Cleanup failures are logged without replacing the agent’s outcome or retrying its work. Reusing an Attempt after launch or release fails with an infrastructure error.

Parameter Type
io Sink

Effect<StepResult, InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure>

readonly workspace: AttemptWorkspace

Checkout metadata suitable for inspection or serialization; contains no credentials.

ExecutorError = typeof ExecutorError.Type

A readiness, access, or lifecycle failure reported by a Worker operation.


ExecutorOperation = typeof ExecutorOperation.Type

The Worker operation that failed during readiness checks or an Attempt’s lifecycle.


WorkerCapability = typeof WorkerCapability.Type

A prerequisite a Worker must satisfy before it can accept Attempts. gateway is the Gateway in front of the Worker’s machine: its admin API answers the orchestrator, and the machine reaches it.


WorktreePath = typeof WorktreePath.Type

One Attempt’s disposable checkout directory.

const ExecutorError: Schema.Union<readonly [typeof ExecutorOperationError, typeof CredentialUnavailableError, typeof WorkerCapabilityError]>

A readiness, access, or lifecycle failure reported by a Worker operation.


const ExecutorOperation: Schema.Literals<readonly ["preflight", "prepare", "launch", "cancel", "cleanup"]>

The Worker operation that failed during readiness checks or an Attempt’s lifecycle.


const logPreflightFailure: <A, R>(effect) => Effect.Effect<A, ExecutorError, R>

Logs every preflight refusal so a missing capability is explainable from logs alone.

Type Parameter
A
R
Parameter Type
effect Effect.Effect<A, ExecutorError, R>

Effect.Effect<A, ExecutorError, R>


const WorkerCapability: Schema.Literals<readonly ["machine", "toolchain", "harness-login", "credentials", "gateway"]>

A prerequisite a Worker must satisfy before it can accept Attempts. gateway is the Gateway in front of the Worker’s machine: its admin API answers the orchestrator, and the machine reaches it.


const WorktreePath: Schema.brand<Schema.NonEmptyString, "WorktreePath">

One Attempt’s disposable checkout directory.