Skip to main content

@flow-state-dev/orchestration/task-board

Classes​

StaleTaskClaimError​

Thrown by the start gate when the claim this dispatch names is no longer the row's current claim.

Superseded, expired and re-routed all land here rather than each getting a name of its own: what this dispatch must do about any of them is the same — stop, write nothing, leave the row to be recovered. A named error rather than a silent return: a request that stops because its claim was superseded is a correct outcome, but one that stops with no trace is indistinguishable from one that never ran.

Extends​

  • Error

Constructors​

Constructor​
new StaleTaskClaimError(taskId, detail): StaleTaskClaimError;
Parameters​
taskId​

string

detail​

string

Returns​

StaleTaskClaimError

Overrides​

Error.constructor

Properties​

cause?​
cause?: unknown;
Inherited from​

Error.cause

code​
readonly code: "stale-task-claim" = "stale-task-claim";
message​
message: string;
Inherited from​

Error.message

name​
name: string;
Inherited from​

Error.name

stack?​
stack?: string;
Inherited from​

Error.stack

taskId​
readonly taskId: string;

TaskBoardRecorderFailureError​

The error a run fails with once its reports are in.

Its own class so the error recorder can recognise it when it arrives as a rescued error and refuse to let onError swallow it — the dispatch gate's whole raise travels that path.

Extends​

  • Error

Constructors​

Constructor​
new TaskBoardRecorderFailureError(reports): TaskBoardRecorderFailureError;
Parameters​
reports​

readonly RecorderFailureReport[]

Returns​

TaskBoardRecorderFailureError

Overrides​

Error.constructor

Properties​

cause?​
cause?: unknown;
Inherited from​

Error.cause

code​
readonly code: "task-board-recorder-failure" = "task-board-recorder-failure";
message​
message: string;
Inherited from​

Error.message

name​
name: string;
Inherited from​

Error.name

reports​
readonly reports: readonly RecorderFailureReport[];
stack?​
stack?: string;
Inherited from​

Error.stack


TaskBoardReportFailureError​

The board could not even report that it had failed to record something.

Its own class because its containment rule is the opposite of every other failure here: a recorder failure waits for the drain's tail so the siblings finish first, but a report that could not be delivered is fatal where it happens. There is nothing left to defer to — the deferral works by leaving the report on the stream for the tail to find, and that is exactly what just did not happen. Every recorder rethrows this on sight, whatever onError says and whatever site it is composed at.

Extends​

  • Error

Constructors​

Constructor​
new TaskBoardReportFailureError(report, cause): TaskBoardReportFailureError;
Parameters​
report​

RecorderFailureReport

cause​

unknown

Returns​

TaskBoardReportFailureError

Overrides​

Error.constructor

Properties​

cause?​
cause?: unknown;
Inherited from​

Error.cause

code​
readonly code: "task-board-report-failure" = "task-board-report-failure";
message​
message: string;
Inherited from​

Error.message

name​
name: string;
Inherited from​

Error.name

report​
readonly report: RecorderFailureReport;
stack?​
stack?: string;
Inherited from​

Error.stack


TaskEndsForGoodError​

Thrown when the next attempt would end the same way. The recorder ends the row on this attempt, under the worker's claim, so the worker writes no ending of its own. ending defaults to errored.

It speaks only for taskId, the row its thrower holds: a recorder holding another row (a board nested inside the worker rethrows its worker's error on onError: "fail") reads it as an ordinary failure.

Extends​

  • Error

Constructors​

Constructor​
new TaskEndsForGoodError(message, options): TaskEndsForGoodError;
Parameters​
message​

string

options​
ending?​

"errored" | "cancelled"

taskId​

string

Returns​

TaskEndsForGoodError

Overrides​

Error.constructor

Properties​

cause?​
cause?: unknown;
Inherited from​

Error.cause

ending​
readonly ending: "errored" | "cancelled";
message​
message: string;
Inherited from​

Error.message

name​
name: string;
Inherited from​

Error.name

stack?​
stack?: string;
Inherited from​

Error.stack

taskId​
readonly taskId: string;

UnknownTaskLedgerError​

Thrown by a gate served by many ledgers when a dispatch names a ledger its resolver does not answer for. Decided before any row is read, so nothing was written; the sender's attempt fails through its ordinary error path.

Extends​

  • Error

Constructors​

Constructor​
new UnknownTaskLedgerError(
entry,
taskId,
ledgerId
): UnknownTaskLedgerError;
Parameters​
entry​

string

taskId​

string

ledgerId​

string

Returns​

UnknownTaskLedgerError

Overrides​

Error.constructor

Properties​

cause?​
cause?: unknown;
Inherited from​

Error.cause

code​
readonly code: "unknown-task-ledger" = "unknown-task-ledger";
entry​
readonly entry: string;
ledgerId​
readonly ledgerId: string;
message​
message: string;
Inherited from​

Error.message

name​
name: string;
Inherited from​

Error.name

stack?​
stack?: string;
Inherited from​

Error.stack

taskId​
readonly taskId: string;

Interfaces​

ApplyReplanOptions​

Properties​

capability?​
capability?: DefinedCapability<any, any, string, Record<string, PresetDef<any>>, undefined, undefined, undefined, undefined, undefined>;

Board capability for backing-aware collection resolution. When provided, the block declares it in uses and reads/writes the board's tasks through ctx.cap.<capability.name>.tasks() — correct for request, resource, or custom-stateKey backings. Omit for the legacy name-based request reconstruction (== null-guarded).

maxAttemptsPerTask​
maxAttemptsPerTask: number;

Default maxAttempts to stamp on tasks that don't carry one.

name​
name: string;

Pattern/board name (also the default request collection id).

sequencerStateSchema?​
sequencerStateSchema?: ZodTypeAny;

Sequencer state schema the block declares so its ctx.sequencer.state.goal read is typed against the caller's real container (decoupled from the patterns-owned planAndExecuteStateSchema). Defaults to a permissive passthrough carrying an optional goal — enough for the gap-fill read; consumers with richer state (goalSeekLoop's merged container, P&E's own schema) pass it so no state field is stripped.

taskContext?​
taskContext?: TaskContextSupply;

Per-task context supply for replanned tasks. The replan loop re-enters the board directly, bypassing the planning-entry enricher, so this applies the same gap-fill here: unless false, a replanned task without context gets the goal copied in. A custom-block taskContext also uses the deterministic goal-fill on the replan path (re-running a custom enricher mid-loop is a documented fast-follow). Default "goal".


DispatchingAssignee​

One assignee that dispatches: its assignee name and the address it carries.

Properties​

dispatch​
dispatch: object;
action​
readonly action: string | TaskEntryChoice;

The entry name — flow.task.actions[action] — or a choice among declared entry names, made per row (see TaskEntryChoice).

flowKind?​
readonly flowKind?: string | TaskFlowTarget;

The flow the entry lives on, when it is not this one. Same skip as an internal cross-flow address: defineFlow cannot see the other flow's map, so the seam resolves it. A function is looked up per task (see TaskFlowTarget) and is always cross-flow.

session​
readonly session: TaskSessionPolicy<any>;
state?​
readonly state?: Readonly<Record<string, unknown>> | TaskStateTarget;

The initial state each task's child session is created with: a fixed object, or looked up per task (see TaskStateTarget). A child that already exists keeps its own.

type​
readonly type: "task";
wait?​
readonly wait?: boolean;

Whether the board's drain waits on a row it hands over. Absent follows the board's mode: a plan board waits, a delegation board doesn't. A board refuses one that contradicts its mode.

kind​
kind: "named" | "uniform" | "floor" | "newSession";

Where the dispatcher sat: a named assignee, the uniform workers block, the defaultWorker fallback, or a plan board's newSession, which takes the rows filed session: "new". What every reader branches on.

label​
label: string;

assignee:<name>, uniform, floor or newSession — the readable form, for refusals. Never branched on.

name​
name: string;

The assignee's name — the row's assignee, which the dispatch is addressed by. Empty when the dispatcher sat at a uniform or floor assignee.


GoalSeekLoopConfig​

Properties​

activeStatusMessage?​
activeStatusMessage?: string;

Forwarded to the OUTER sequencer so a re-expressed pattern keeps its public status emission (executeBlock emits activeStatusMessage before the block runs).

afterDrain?​
afterDrain?: BlockDefinition<any, any, any, any>;

Runs as a .tap immediately AFTER each drain, BEFORE the judge. (A failed or cancelled row's dependents need no step here: the board cancels them on that row's ending.)

board​
board: TaskBoardHandle<any, any, any>;

The drain substrate. MUST be request- or resource-backed (rejected at construction otherwise). goalSeekLoop mounts board.drain as the loop target.

finalize?​
finalize?:
| SequencerDefinition<any, any, undefined, undefined>
| BlockDefinition<any, any, any, any>;

Synthesizer over the settled-board projection (goalSeekLoop projects the board before invoking it). Omit to return that projection raw.

inputSchema?​
inputSchema?: ZodTypeAny;

Input schema forwarded to the OUTER sequencer verbatim, so a re-expressed pattern keeps its public block metadata (and survives GeneratorTool wrapping). Omit for z.unknown().

judge​
judge: JudgeSlot;

Evaluated after afterDrain → Verdict. MANDATORY.

maxAttemptsPerTask?​
maxAttemptsPerTask?: number;

Forwarded to the lifted createApplyReplan for replanned-task defaults.

maxIterations​
maxIterations: number;

MANDATORY hard backstop = total drains. A finite positive integer (validated with Number.isSafeInteger(n) && n > 0). Threaded to loopBack as maxIterations - 1 jumps (the drain runs once before the first jump).

name​
name: string;

Name for the loop's outer sequencer and its internal block-name prefix.

onError?​
onError?: "skip" | "fail";

Judge-error posture. "skip" (default): a judge throw / malformed verdict lands as { done, "judge-error" }. "fail": it propagates as a request error. Only scopes the judge (and replanner) rescue — a seed/board.drain failure always propagates.

replanner?​
replanner?: BlockDefinition<any, any, any, any>;

Runs on a replan verdict with no inline tasks array; its emitted { tasks } then flow through the add step. Its output is shape-validated and rescue-wrapped like the judge.

seed?​
seed?:
| SequencerDefinition<any, any, undefined, undefined>
| BlockDefinition<any, any, any, any>;

Produces the initial tasks (the "plan"). Writes via the board accessor before the drain, so it REQUIRES request/resource backing. Accepts a sub-sequencer because the patterns' seeds are multi-step. Optional when tasks are pre-seeded.

stateSchema?​
stateSchema?: ZodTypeAny;

Extra state fields merged into the loop's own single loop-owner state container (ctx.self ≡ ctx.sequencer for a sequencer). Required for P&E parity so its re-expressed blocks read/patch goal/status. The loop's own fields carry the goalSeekLoop prefix so they never collide with a caller field.

taskContext?​
taskContext?: TaskContextSupply;

Forwarded to the lifted createApplyReplan for replanned-task context.


JudgeInput​

Input to an inline-fn judge: the resolved collection ref plus the raw drain result. Built inside the judge wrapper (never placed on the chain — a live ref would not survive a structured-clone step boundary). A block or sub-sequencer judge instead receives the raw drain result and reads the board from ctx (what the built-in patterns do).

Properties​

collection​
collection: TaskCollectionRef;
drainResult​
drainResult: unknown;

RecorderFailureReport​

The report's payload, as it appears on the emitted item's value.

Properties​

collectionId​
collectionId: string;
error​
error: string;

The announcement failure's message, verbatim.

recorder​
recorder: RecorderKind;
runId?​
runId?: string;

The drain run this belongs to, when there is one. Entries accumulate on the per-REQUEST item buffer and a request can drain a board more than once, so the tail filters on this rather than on collection id — a second batch must not inherit the first one's failure. Absent for a settlement with no batch around it (the dispatch gate), which raises immediately and never filters.

taskId​
taskId: string;
verdict​
verdict: RecorderWriteVerdict;

RecorderFailureWiring​

How a settlement site reports a recorder failure.

Both recorders are composed in two places — the inline drain, and the gate around a task dispatched to a child run — and the difference between them is entirely about when the run is allowed to fail.

Properties​

onRecorderFailure?​
onRecorderFailure?: "defer" | "raise";

"defer" reports and returns, leaving the drain's tail to fail the run once every sibling has finished. "raise" throws here instead.

"raise" is the default, and deferring is what has to be asked for. Deferring only works because something downstream reads the report and fails the run; a recorder composed without a tail — these blocks are exported, and taskBoard() is not the only way to reach them — would otherwise report into a stream nobody checks and return successfully, leaving that caller quieter than it was before any of this existed, where the announcement's rejection simply propagated. That is this issue's own defect, reintroduced one caller over. So the only site that defers is the one that can name what will pick the report up.

runId?​
runId?: (ctx) => string | undefined;

This drain run's stamp, read at failure time. Reports accumulate on the per-REQUEST item buffer and a request can drain the same board more than once, so the tail filters on this rather than on collection id — a second batch must not inherit the first one's failure. Omitted where there is no batch.

Parameters​
ctx​

BlockContext

Returns​

string | undefined


RecordErrorOptions​

Properties​

collection​
collection: (ctx) => Promise<TaskCollectionRef<unknown, unknown>>;
Parameters​
ctx​

TaskBoardWorkerBodyContext

Returns​

Promise<TaskCollectionRef<unknown, unknown>>

name​
name: string;
onError​
onError: "skip" | "fail";

Failure policy. "skip" swallows after writing the failure. "fail" rethrows so the worker sequencer fails — propagates up through .forEach, surfacing on the board's parent.

recorderFailure?​
recorderFailure?: RecorderFailureWiring;

Recorder-failure reporting for this settlement site.


RecordSuccessOptions​

Properties​

collection​
collection: (ctx) => Promise<TaskCollectionRef<unknown, unknown>>;
Parameters​
ctx​

TaskBoardWorkerBodyContext

Returns​

Promise<TaskCollectionRef<unknown, unknown>>

name​
name: string;
recorderFailure?​
recorderFailure?: RecorderFailureWiring;

Recorder-failure reporting for this settlement site.


TaskBoardAcrossSessions​

A board read across every session its owner has: one store query a page. Read-only.

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

Methods​

list()​
list(query?): Promise<TaskBoardAcrossSessionsPage<TInput, TOutput>>;

One page of every session's rows, ordered by session, then by task id. Pass the previous page's next as after for the next one. where.taskId reads the one row with that id in each session that holds one, answered by the row's key in the store's query.

Parameters​
query?​
after?​

string

where?​

{ taskId: string; }

where.taskId​

string

Returns​

Promise<TaskBoardAcrossSessionsPage<TInput, TOutput>>


TaskBoardConfig​

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

Properties​

boardId?​
boardId?: string;

Explicit, stable identifier for this board. Required when any assignee holds a task dispatcher (dispatcher({ action, session })), optional otherwise.

A dispatched row's child session is keyed on this value together with the assignee and the row, so it lands in a persisted key. It cannot be derived from name (unique per flow, not per session) or from collectionId (the literal "factory-supplied" for every factory board), which is why it is declared rather than inferred.

Renaming it is a breaking re-key: live child sessions keyed on the old value are orphaned.

claimOrder?​
claimOrder?: TaskBoardClaimOrderInput;

Claim order for ready-task selection. Either a ClaimOrder instance or a string naming one of the standard claim orders ("fifo", "priority"). Default: "fifo". Neither claims a task with unmet deps: the substrate's admission rule gates on them.

collection?​
collection?:
| TaskBoardRequestCollectionSpec
| TaskBoardSequencerCollectionSpec
| DefinedTaskCollection
| TaskBoardCollectionFactory<TInput, TOutput>;

Where the collection lives — a once-chosen internal detail. Optional; an omitted collection is request-backed with collectionId = name. One of:

  • TaskBoardRequestCollectionSpec (default) — tasks on ctx.request. Survives re-entry across board.drain invocations and adds from sibling or outer steps before the drain. Omit collection entirely to get this.
  • DefinedTaskCollection (defineTaskCollection) — durable, resource-backed tasks that outlive the request. The board registers and resolves it for you; consumers touch only board.capability.
  • TaskBoardSequencerCollectionSpec — explicit opt-in; tasks on the board's own sequencer state. Single-invocation; per-call state.
  • TaskBoardCollectionFactory<TInput, TOutput> — caller-supplied (ctx) => collection for externally-managed / custom stores.
concurrency?​
concurrency?: number;

Maximum parallel workers. Default: 4. The pattern spawns exactly this many worker sequencers via .forEach({ maxConcurrency }).

defaultWorker?​
defaultWorker?: AnyTaskAssignee;

Optional default worker — the board's floor. Registry path only: wired as the worker router's fallback, it runs any task whose assignee is unknown or absent. Omit it and a registry miss still fails the task per onError exactly as before; declared workers are never routed through it (reached only on a genuine miss). Blackboard and the patterns leave it unset.

flowPolicy?​
flowPolicy?: TaskFlowPolicy;

Per-board flow policy. Decides which prior-task observations a soon-to-dispatch worker sees on TaskWorkerInput.priorWork. Default: flowPolicy.declaredDepsOnly(). Pattern factories like planAndExecute pin richer defaults (recentTrajectory({ n: 8 })).

idlePollMs?​
idlePollMs?: number;

Sleep duration when a worker's claim returns null. Bounds the busy-wait cost while waiting for new pending tasks. Default: 50ms.

initialTasks?​
initialTasks?: readonly TaskInit<TInput>[];

Tasks seeded into the collection at board start. Optional.

maxEnqueuedTasks?​
maxEnqueuedTasks?: number | null;

Maximum tasks that may be added while others are still pending. Default 100. Checked at creation against the resulting pending count, so it refreshes as tasks drain — this bounds a single up-front fan-out burst, not concurrent pending (a retry, unblock, resume, or reclaim re-pends without passing the cap). null is explicitly unbounded; omitting it reapplies the default.

Applies ONLY when the board constructs its own collection — the declarative request/sequencer forms. Passing it alongside a supplied collection (a DefinedTaskCollection or a factory) is a construction error: that collection carries whatever caps it was built with, and a board cannot retrofit limits onto a collection it did not construct.

IMPORTANT — the bound holds for writers that go through this board's collectionFactory or capability. It is closed over by the resolved TaskCollectionRef, and getOrCreateTaskCollection never caches, so a writer that resolves the SAME ledger into its own ref enforces nothing and can insert past the bound. Such a writer must be handed board.caps.

maxIterations?​
maxIterations?: number;

Per-worker loopBack safety cap. Each worker exits after this many iterations even if the board is non-empty. Circuit-breaker for pathological enqueue cycles. Default: 10_000.

maxTotalRetries?​
maxTotalRetries?: number | null;

Cumulative failure retries this board may authorize, across every task. Default 50. null is explicitly unbounded; same supplied-collection rule as maxEnqueuedTasks.

The creation caps above count only new tasks, and a retry re-runs one that already exists — so a failing task keeps spending while both of them sit still. This is the one number that bounds that. At the bound a failing task settles terminal errored rather than re-pending, and the board's completion item reports terminationReason: "retry-budget-exhausted".

0 is legal and means "run every task once, never retry". Only failure retries count — unblock and reclaim also re-pend a task and do not consume the budget. See tasks/collection/task-caps.ts for the full semantics, including why the budget is spent at authorization.

maxTotalTasks?​
maxTotalTasks?: number | null;

Maximum tasks the board may ever hold, terminal ones included. Default 500. Never refunded by draining, so it is the backstop against a drain-then-re-enqueue runaway. null is explicitly unbounded; same supplied-collection rule as maxEnqueuedTasks.

For how far the count persists (it is derived from the ledger, so it lasts exactly as long as the ledger — which differs by backing, and does NOT simply reset on resume), see the lifetime section in tasks/collection/task-caps.ts.

mode?​
mode?: TaskBoardMode;

Whether the drain waits on its rows. The author's choice, checked against the assignees when the board is built:

  • "plan" (default): the drain waits on every row. A row runs inline, in the drain, or, through a dispatcher({ action, session }) assignee or newSession, in another session that the drain waits on until the row ends. A dispatcher that says wait: false is refused.
  • "delegation": every row is handed to another session through a dispatcher({ action, session }) assignee, and the drain waits on none of them; the session that works a row settles it. An assignee that runs inline is refused, and so is a board with no dispatcher.

goalSeekLoop refuses a delegation board: its judge would rule while the rows still run.

name​
name: string;

Name for this task board. Used as the outer sequencer name and as a prefix for every internal block name (must be globally unique inside a flow if you have multiple boards).

newSession?​
newSession?: TaskDispatcherBlock;

A plan board's way to run a row in a session of its own: a dispatcher({ action, session }). A row filed session: "new" is handed to it under its own assignee, and the drain waits on it until it ends, as it waits on every row; every other row runs in workers. A row filed with no session runs inline. A delegation board refuses it: it hands every row over already.

onError?​
onError?: "skip" | "fail";

Worker-failure policy. Default: "skip".

  • "skip": capture error on the failing task via fail, siblings continue.
  • "fail": the worker sequencer rethrows after writing fail, the parent forEach rejects, the board fails.

Fails the offending task only — siblings concurrently in-progress are unaffected because each worker tracks its own currentClaim in worker state.

onIdle?​
onIdle?: "wait" | "complete" | "complete-or-blocked";

Termination behavior when the worker pool is idle.

  • "complete-or-blocked" (default): exit when the collection drains, OR when no in-flight worker is active and no pending task is claimable. The final task-board-meta item's terminationReason field distinguishes "all-completed" from "blocked-by-failures".
  • "complete": exit only when no pending or in_progress tasks remain. The former default; preserved for boards that wait on an external pump to mark deps complete.
  • "wait": never auto-exit; defer to shouldExit. Long-running session-scoped boards.
shouldExit?​
shouldExit?: (collection) => boolean;

Predicate for onIdle: 'wait' — return true to terminate the loop. Evaluated once per iteration in checkBoard. Ignored in onIdle: 'complete' and onIdle: 'complete-or-blocked' modes.

Parameters​
collection​

TaskCollectionRef

Returns​

boolean

toolCache?​
toolCache?: boolean | TaskBoardToolCacheConfig;

Per-board tool-result memoization. Enabled automatically when any worker tool declares cacheable; pass false to disable, or an object to tune. The cache is bound to a single board run — it's torn down whether the board completes or errors, so cross-run leakage stays impossible by construction.

workers​
workers:
| TaskWorker<TInput, TOutput>
| TaskAssigneeRegistry;

Worker(s) to dispatch tasks to. A single uniform worker runs every claimed task; a registry routes by task.assignee. Workers are standard BlockDefinitions consuming the substrate's TaskWorkerInput shape.

On a mode: "delegation" board, a registry value is a dispatcher({ action, session }) block — an assignee that dispatches: the stamped address is type: "task", the row is dispatched to the task entry the dispatcher names, and the flow that declares that entry owns the worker. The board runs the dispatch through its own claim gate, so the child settles the same row this drain claimed.


TaskBoardHandle​

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

TName​

TName extends string = string

TReach​

TReach extends boolean = false

Properties​

backing​
backing: TaskBoardBacking;

The board's once-chosen storage backing. Lets a consumer such as goalSeekLoop reject an unsupported backing at construction (it requires a re-enterable request/resource board) instead of waiting for a runtime capability throw. Additive and always populated.

boardId?​
boardId?: string;

The board's declared boardId, or undefined when it declared none. Always present on a board with a dispatcher assignee — that is what assertDispatchBoardSupported enforces.

capability​
capability: DefinedCapability<TName, TaskBoardAccessor<TInput, TOutput, TReach>>;

Capability exposing the board's tasks at ctx.cap.<name> (the board name verbatim; hyphenated names via bracket access, e.g. ctx.cap["my-board"]). Add to any block's uses array and call the sugar directly — ctx.cap.<name>.createTask({...}), .listTasks(...), .tasks() for the full ref.

A board on a durable, session-scoped collection also names another session's board, ctx.cap.<name>.at({ session }), and reads every session's at once, ctx.cap.<name>.acrossSessions() (TaskBoardReach). No other board has them, by type.

Backing-aware: the request default (and resource backing) let sibling and outer blocks read/mutate the board; the sequencer opt-in additionally auto-declares the board's tasks slot via targetStateSchemas and throws if used from outside the board's subtree (state must be in scope). Factory- backed boards defer entirely to the user's factory.

Carries the board's TInput/TOutput AND its name literal, so a consumer doing ctx.cap.<name>.createTask({ input }) type-checks the payload against the board's task input rather than unknown, and only the actual <name> key is exposed on ctx.cap (a wrong key is a compile error, not a runtime undefined).

caps​
caps: TaskCapOptions;

The board's resolved creation caps — defaults applied, validated. Empty ({}) when the caller supplied the collection, since the board then applies none.

Surfaced because the caps live in a ref's closure and getOrCreateTaskCollection never caches, so a SECOND ref over the same ledger enforces nothing. Any writer that resolves this board's collection itself — rather than through collectionFactory or capability — must pass these, or it silently writes past the bounds the board advertises. That is what patterns' planner-seed and event-record paths do; see the note on TaskBoardConfig.maxEnqueuedTasks.

collectionId​
collectionId: string;

Stable identifier for the collection — matches data.collectionId on emitted task-change items.

dispatchers​
dispatchers: readonly DispatchingAssignee[];

The assignees holding a task dispatcher, in declaration order. Empty on every board that declares no dispatcher assignee.

drain​
drain: SequencerDefinition<any, any>;

The composed drain sequencer — the block that runs the board's tasks. Plug into a parent flow or sequencer.

Only when collection opts into { backing: "sequencer" }: the parent sequencer's stateSchema MUST include a Record<string, Task> slot at [stateKey] (default "tasks") — taskBoardStateSchema declares the canonical shape. The default (request) and durable (resource) backings put tasks off the parent sequencer, so no such slot is required.

hasIdlessInitialTasks​
hasIdlessInitialTasks: boolean;

Whether the board's own initialTasks seed carries any task without a stable id. An idless initial task is re-added on every drain re-entry (createSeedCollection only dedups stable ids), so a multi-drain consumer must reject such a board up front. false when there are no initial tasks or all carry ids.

mode​
mode: TaskBoardMode;

The board's declared mode: "plan", whose drain runs and waits on every row, or "delegation", whose drain hands every row off and waits on none. A consumer that needs every row ended when the drain returns, such as goalSeekLoop, refuses a delegation board on this.


TaskBoardRequestCollectionSpec​

Request-scoped collection spec — the default backing.

Tasks live on ctx.request so the collection survives every block boundary, including multiple invocations of board.drain from a parent sequencer's outer loop and adds from a sibling or outer step before the board drains. Both backing and collectionId are optional: an omitted collection (or an object with neither field) is request-backed with collectionId defaulting to the board name.

The capability built for this backing does NOT declare targetStateSchemas and reaches the collection from any block in the request, not just blocks under board.drain's subtree.

Properties​

backing?​
backing?: "request";
collectionId?​
collectionId?: string;

Stable collection id. Defaults to the board name.

stateKey?​
stateKey?: string;

Top-level field on ctx.request.state holding the Record<id, Task>. Defaults to collectionId so multiple boards in one request stay namespaced without manual setup.


TaskBoardSequencerCollectionSpec​

Sequencer-state-backed collection spec — explicit opt-in. Wires getOrCreateTaskCollection({ backing: "state", state: <board-state-ref> }) at runtime. The outer sequencer's stateSchema must include a Record<string, Task> slot at [stateKey] (default "tasks") — taskBoardStateSchema is the canonical shape.

Single-invocation only: sequencer state is per-invocation and won't survive across board.drain calls. For re-entry across an outer loop, use the default request backing; for a board whose tasks outlive the request, use a DefinedTaskCollection (defineTaskCollection).

Properties​

backing​
backing: "sequencer";
collectionId​
collectionId: string;
stateKey?​
stateKey?: string;

TaskBoardToolCacheConfig​

Per-board tool-cache tuning. All fields optional.

Properties​

defaultScope?​
defaultScope?: "session" | "request" | "run";

Default scope for tools that don't specify one. Default "run".

defaultTtl?​
defaultTtl?: number;

Default TTL (ms) for cacheable tools that don't specify one.

enabled?​
enabled?: boolean;

Default true when any tool in the board's worker(s) declares cacheable.

maxEntries?​
maxEntries?: number;

Max entries before LRU eviction. Default 5000.


TaskEndRules​

What else holds a task open at a request's end, beside its own request (rule 6).

Properties​

filedWorkKeepsOpen?​
filedWorkKeepsOpen?: (ctx, task, ledger) => Promise<boolean>;

Whether work the task filed still holds it. Default: a row on the task's own ledger it filed (filedByTask) that is open or still owes its ending (filedWorkKeepsOpen).

Parameters​
ctx​

BlockContext

task​

Task

ledger​

TaskCollectionRef

Returns​

Promise<boolean>

steerTurn?​
steerTurn?: object;

The internal entry, on the task session's own flow, that runs one more turn for a steer no request of the attempt took. The check starts it in the running session, with a wake owed for it first, and the entry admits its request for the task. Absent: a steer that lands after a request's last model call waits for the attempt's next request, if any, and the task settles without it.

entry​
readonly entry: string;

TaskLedgersOptions​

Properties​

allowSessionState?​
allowSessionState?: boolean;

Accept an entry whose blocks keep session state. Refused by default, as on a board's entry, because a dispatch under a shared session policy (per-worker, a key) runs several rows in one child session. Set it when the entry is handed tasks one session per task, or when its session state is the entry's own, the same shape for every task.

endRules?​
endRules?: TaskEndRules;

What else holds a task open at a request's end. See TaskEndRules.

name​
name: string;

Names the assembled blocks and the binding, so a refusal says which entry it came from.

onError?​
onError?: "skip" | "fail";

The worker-failure policy, as on a board. Default "skip".

resolve​
resolve: (ledgerId, ctx, partition, taskId) => Promise<
| TaskCollectionRef<unknown, unknown>
| undefined>;

The ledger a dispatch's tasks are read from, by the id the dispatch carries (boardId on the envelope), or undefined when this entry takes no tasks from it.

The id is untrusted. It travels on the envelope, so the resolver must answer only for ledgers the running context may read: resolve against ctx, never a process-wide map of every ledger. The row re-read on the returned ledger is what authorizes the run, exactly as on a board's gate.

partition is the partition the dispatch names, present when the sending board's ledger keeps one set of rows per partition (partitionBy): resolve the ledger at it (getOrCreateTaskCollection({ ..., partition })). It is read at the running user's scope, so it reaches only that user's rows, and a ledger resolved at any other partition is refused before a row is read.

taskId is the row the dispatch (or the claim being settled) names, so a resolver can answer for a ledger only when that row is one the running session may take: it is untrusted too, and the row it names is re-read and checked on the returned ledger.

Parameters​
ledgerId​

string

ctx​

BlockContext

partition​

string | undefined

taskId​

string

Returns​

Promise< | TaskCollectionRef<unknown, unknown> | undefined>

uses?​
uses?: readonly DefinedCapability<string, Record<string, (...args) => any>, string, Record<string, PresetDef<any>>, undefined, undefined, undefined, undefined, undefined>[];

Declarations the resolved ledgers need in scope (their resources).


TaskRequestAdmissionOptions​

What taskRequestAdmission is built from.

Properties​

answerCounts​
readonly answerCounts: boolean;

Whether this entry's answer can be the task's result (a woken turn's can; the check entry's, which runs no turn, can't).

endRules?​
readonly endRules?: TaskEndRules;

What else holds the task open, as on the gate.

find​
readonly find: (ctx) => Promise<
| {
ref: TaskCollectionRef;
row: Task;
}
| undefined>;

The task this request is for, and the ledger it is on, read from server-set state only. Answer only for a row this request may act for: one whose run link names the running session. undefined admits nothing.

Parameters​
ctx​

BlockContext

Returns​

Promise< | { ref: TaskCollectionRef; row: Task; } | undefined>

name​
readonly name: string;

Names the block.


TaskToolActionsBoard​

What taskToolActions reads off a board handle. Structural, so this module does not import the task-board barrel.

Properties​

backing​
readonly backing: string;
capability​
readonly capability: DefinedCapability;

Composed by each action, so the board's ledger is installed with it.

collectionId​
readonly collectionId: string;

VerdictMapping​

Mapping from a bring-your-own decision shape to a Verdict. decision maps the source to the loop's three-way decision; reason/tasks derive the rest (a default reason is injected per decision when reason is omitted, so a legacy decision-only source like { decision: "complete" } is never treated as malformed).

Type Parameters​

TSource​

TSource

Properties​

decision​
decision: (source) => "continue" | "replan" | "done";
Parameters​
source​

TSource

Returns​

"continue" | "replan" | "done"

reason?​
reason?: (source) => string;
Parameters​
source​

TSource

Returns​

string

tasks?​
tasks?: (source) => TaskInit[] | undefined;
Parameters​
source​

TSource

Returns​

TaskInit[] | undefined


WaitOnTaskOptions​

How one wait is made.

Properties​

deadlineMs?​
readonly deadlineMs?: number;

How long to wait, in ms from the call. The host's default when unset.

key​
readonly key: string;

What this wait is recorded under with the request (runOnce): the same on every replay of the call that waits. A tool call's logical id for getTask; the row, its attempt and the round for a drain.

message?​
readonly message?: string;

Shown wherever the parked request is listed.

ownBoard?​
readonly ownBoard?: true;

The waiting request is the board's own drain, waiting on a row it handed to another session: it waits on any row it handed over, so there is no filer check, and the request's own row is the task it works, never the row its drain claimed.

step?​
readonly step?: string;

The model step this wait belongs to, for a model's tool call: one wait per step. Omitted for a drain, which is no model step.

waitAgain?​
readonly waitAgain?: boolean;

At the deadline, take the slot again and go on waiting, rather than return the task as it stands: a drain never moves past a running row. Each round is a check-in at the host's default deadline, and counts the chain again before it parks, unless ownBoard is set.


WorkerClaimReader​

The part of a block context a claim is bound to: the request it runs in. BlockContext satisfies it; so does a bare object in a unit harness.

Properties​

request?​
readonly request?: object;
identity?​
readonly identity?: object;
identity.id?​
readonly id?: string;
incarnation?​
readonly incarnation?: string;

Type Aliases​

JudgeSlot​

type JudgeSlot =
| BlockDefinition<any, any>
| SequencerDefinition<any, any>
| ((input, ctx) => Verdict | Promise<Verdict>);

The judge slot. A full block or sub-sequencer whose output maps to a Verdict (via mapToVerdict or by emitting the shape directly), or an inline fn returning a complete Verdict. Bring-your-own — goalSeekLoop ships no per-dialect judge factories.


MidwayAsk​

type MidwayAsk =
| {
ok: true;
questions: readonly string[];
}
| {
ok: false;
reason: "no-claim" | "not-supported" | AskDeclineReason;
};

What askMidway answers: the questions' ids once asked, or why not.


RecorderKind​

type RecorderKind = "complete" | "fail" | "cancel";

Which recorder hit this: a completion, a failure, or the cancel the claim gate writes when a person stopped the request working the task.


RecorderWriteVerdict​

type RecorderWriteVerdict = "committed" | "undetermined";

What the board could establish about the write it could not announce.

  • committed — the write landed. The work is saved; only the announcement failed.
  • undetermined — the board cannot tell whether it landed. Never collapsed into either neighbour: collapsing restores the confident wrong answer the write record exists to remove, and it is the permanent answer for every custom store, so the collapse would be silent and total.

A write that demonstrably committed nothing produces no verdict and no report — it is routine, and takes the path it always took.


TaskAssignee​

type TaskAssignee<TIn, TOut> =
| TaskWorker<TIn, TOut>
| TaskDispatcherBlock;

What a board assignee holds: a worker that runs inline, or a task dispatcher that dispatches.

Type Parameters​

TIn​

TIn = unknown

TOut​

TOut = unknown


TaskAssigneeAddress​

type TaskAssigneeAddress = Extract<DispatchAddress, {
type: "task";
}>;

The address a dispatcher({ type: "task" }) assignee carries: its entry and session policy.


TaskAssigneeRegistry​

type TaskAssigneeRegistry = Record<string, AnyTaskAssignee>;

A worker registry whose values may also be task dispatchers.

Deliberately not parameterized by the board's TInput/TOutput: TaskWorkerRegistry is not either, because registry workers are heterogeneous — each declares its own payload schema and the board's generics describe the collection, not every route.


TaskBoardAccessor​

type TaskBoardAccessor<TInput, TOutput, TReach> = TReach extends true ? TaskBoardCapabilityAccessor<TInput, TOutput> & TaskBoardSessionReach<TInput, TOutput> : TaskBoardCapabilityAccessor<TInput, TOutput>;

What ctx.cap.<name> reads for a board: the board's accessor, with the reach when the board has it.

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

TReach​

TReach extends boolean = false


TaskBoardAcrossSessionsEntry​

type TaskBoardAcrossSessionsEntry<TInput, TOutput> = object;

One row of a board read across sessions: the session whose board holds it, and the row as stored.

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

Properties​

session​
readonly session: string;

The session's id, as ctx.cap.<name>.at({ session }) takes it.

task​
readonly task: Readonly<Task<TInput, TOutput>>;

TaskBoardAcrossSessionsPage​

type TaskBoardAcrossSessionsPage<TInput, TOutput> = object;

One page of TaskBoardAcrossSessions.list.

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

Properties​

entries​
readonly entries: readonly TaskBoardAcrossSessionsEntry<TInput, TOutput>[];
next?​
readonly next?: string;

An opaque cursor, while more rows may remain. A page can be short, even empty, while it is set.


TaskBoardBacking​

type TaskBoardBacking = "request" | "resource" | "sequencer" | "factory";

The board's once-chosen storage backing, surfaced on the handle so a consumer can classify it without re-deriving from the collection config. Mirrors the four discriminants the capability distinguishes: request/resource are re-enterable (survive board.drain re-entry); sequencer is single-invocation; factory is caller-opaque.


TaskBoardCapabilityAccessor​

type TaskBoardCapabilityAccessor<TInput, TOutput> = object;

Capability accessor — what consumers see at ctx.cap.<boardName>.

Generic in the board's task payload types: taskBoard<TInput, TOutput>(...) threads TInput/TOutput through the handle to here, so createTask type-checks the payload and the query methods return Task<TInput, TOutput>. Without the threading a mismatched createTask({ input }) would compile silently.

tasks() returns the full TaskCollectionRef. The sugar methods delegate to that ref: createTask/createTasks mutate; getTask/listTasks/countTasks wrap the ref's synchronous reads (they're async only because resolving the ref is). Every method re-resolves the ref, so reads always reflect the latest committed state.

A closed object of function-typed properties satisfies defineCapability's TFns extends Record<string, (...args) => any> constraint on its own — no & Record<string, …> intersection, which would re-widen every method back to (...args: any[]) => any and erase exactly the payload checking above.

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

Properties​

countTasks​
countTasks: (filter?) => Promise<number>;

Count tasks, optionally filtered.

Parameters​
filter?​

TaskFilter

Returns​

Promise<number>

createTask​
createTask: (task) => Promise<Task<TInput, TOutput>>;

Add one task.

Parameters​
task​

TaskInit<TInput>

Returns​

Promise<Task<TInput, TOutput>>

createTasks​
createTasks: (tasks) => Promise<Task<TInput, TOutput>[]>;

Add several tasks.

Parameters​
tasks​

TaskInit<TInput>[]

Returns​

Promise<Task<TInput, TOutput>[]>

getTask​
getTask: (id) => Promise<TaskHandle<TInput, TOutput> | undefined>;

Read one task by id (undefined if absent).

Parameters​
id​

string

Returns​

Promise<TaskHandle<TInput, TOutput> | undefined>

listTasks​
listTasks: (filter?) => Promise<TaskHandle<TInput, TOutput>[]>;

List tasks, optionally filtered.

Parameters​
filter?​

TaskFilter

Returns​

Promise<TaskHandle<TInput, TOutput>[]>

tasks​
tasks: () => Promise<TaskCollectionRef<TInput, TOutput>>;

The board's full TaskCollectionRef — the escape hatch for the whole API.

Returns​

Promise<TaskCollectionRef<TInput, TOutput>>


TaskBoardClaimOrderInput​

type TaskBoardClaimOrderInput = ClaimOrder | "fifo" | "priority";

Accepted shapes for the Task Board's claimOrder config: either a ClaimOrder instance, or a string naming one of the substrate's standard claim orders.


TaskBoardCollectionFactory​

type TaskBoardCollectionFactory<TInput, TOutput> = (ctx) => MaybePromise<TaskCollectionRef<TInput, TOutput>>;

Caller-supplied factory — full control. Receives the worker's BlockContext.

Type Parameters​

TInput​

TInput

TOutput​

TOutput

Parameters​

ctx​

BlockContext

Returns​

MaybePromise<TaskCollectionRef<TInput, TOutput>>


TaskBoardMode​

type TaskBoardMode = "plan" | "delegation";

"plan" (the default): every row runs in the drain, which waits on every one. "delegation": every row is handed to another session, and the drain never waits on one.


TaskBoardReach​

type TaskBoardReach<TCollection> = TCollection extends DefinedTaskCollection<infer TScope> ? [TScope] extends ["session"] ? true : false : false;

Whether a board on TCollection reaches other sessions' boards: only a defineTaskCollection whose scope is declared literally "session". A user- or org-scoped ledger is one board for the owner, a request, sequencer or factory board has none in another session the board could find, and a scope the type doesn't name is not proven to be per session.

Type Parameters​

TCollection​

TCollection


TaskBoardSessionReach​

type TaskBoardSessionReach<TInput, TOutput> = object;

What a board kept per session adds to its accessor: another session's board by naming it, and every session's at once. Only a board on a durable, session-scoped collection has them (TaskBoardReach).

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

Properties​

acrossSessions​
acrossSessions: () => TaskBoardAcrossSessions<TInput, TOutput>;

The board in every session the owner has, read-only (ctx.resources.acrossSessions()).

Returns​

TaskBoardAcrossSessions<TInput, TOutput>

at​
at: (target) => TaskBoardCapabilityAccessor<TInput, TOutput>;

The board in another of the owner's sessions, as that session's own accessor reads and writes it. A session the owner doesn't hold answers every verb as one nobody holds (SessionNotFoundError), as ctx.resources.at does. Naming the running session answers its own board.

Parameters​
target​

TaskBoardSessionTarget

Returns​

TaskBoardCapabilityAccessor<TInput, TOutput>


TaskBoardSessionTarget​

type TaskBoardSessionTarget = object;

The session ctx.cap.<name>.at names: its id, as ctx.resources.at takes it.

Properties​

session​
readonly session: string;

TaskContextSupply​

type TaskContextSupply = "goal" | false | BlockDefinition<any, any>;

How each task's context is populated when the planner/replanner didn't supply one. "goal" (default) copies the (synthesized) goal into every gap-task — free, deterministic. false leaves context empty. A BlockDefinition runs a custom enricher (used on the seed path only; the replan path always uses the deterministic goal-fill — see below).

The canonical home for this type: it moves here with the lifted createApplyReplan; @flow-state-dev/patterns re-exports it so callers that import it from planning-entry keep working.


TaskDispatcherBlock​

type TaskDispatcherBlock = BlockDefinition<any, any, TaskDispatchInput, DispatchHandle>;

The block dispatcher({ type: "task" }) builds: its input is the claim envelope.


TaskDispatchInput​

type TaskDispatchInput = z.infer<typeof taskDispatchInputSchema>;

TaskWaitRefusal​

type TaskWaitRefusal =
| "wait_unavailable"
| "wait_deadline_out_of_range"
| "wait_not_filer"
| "wait_on_conversation_result"
| "wait_already_pending"
| "wait_taken"
| "wait_on_plan_step"
| "wait_too_deep";

Why a wait was refused, before anything was written. A model reads the message.


TaskWaitResult​

type TaskWaitResult =
| {
arrivesAsNotice?: true;
delivered?: true;
ended: boolean;
ok: true;
task: Task;
}
| {
error: TaskWaitRefusal;
message: string;
ok: false;
}
| {
error: "wait_ended_the_request";
message: string;
ok: false;
};

What waitOnTask came to.

Union Members​

Type Literal​
{
arrivesAsNotice?: true;
delivered?: true;
ended: boolean;
ok: true;
task: Task;
}

The task once it ended (ended: true), or as it stands at the deadline (ended: false, still running). The caller returns it as getTask would, except with arrivesAsNotice: the filer's onTaskSettled had already taken the ending's notice, which is the filer's one hearing of it, so the caller answers arrivesAsNoticeAnswer instead.

arrivesAsNotice?​
readonly arrivesAsNotice?: true;
delivered?​
readonly delivered?: true;

This answer is the filer's one hearing of the ending, in place of its notice.

ended​
readonly ended: boolean;
ok​
readonly ok: true;
task​
readonly task: Task;

Type Literal​
{
error: TaskWaitRefusal;
message: string;
ok: false;
}

Type Literal​
{
error: "wait_ended_the_request";
message: string;
ok: false;
}

The request is over: a person stopped it while it waited, or its own task was cancelled. It ends with no further model call; nothing reads this.


TurnCancel​

type TurnCancel =
| Awaited<ReturnType<TaskCollectionRef["cancel"]>>
| {
outcome: "declined";
reason: "no-claim";
};

What cancelFromTurn answers: the board's write, or that the request holds no claim to cancel with.


Verdict​

type Verdict =
| {
decision: "done";
reason: string;
}
| {
decision: "continue";
reason: string;
}
| {
decision: "replan";
reason: string;
tasks?: TaskInit[];
};

A judge's verdict after one drain. Three-way (mirrors P&E's evaluator), because replan and continue must NOT collapse: continue re-drains existing in-flight work with no new tasks; replan adds work (inline tasks, or via the replanner slot when absent). Collapsing them would either fire the replanner on ordinary continues or skip it on replans.

Variables​

noteTaskAnswer​

const noteTaskAnswer: BlockDefinition;

After the turn whose answer is the task's result: note it for the check at the request's end. Passes nothing on; a .tap().


SPEND_TICK_MS​

const SPEND_TICK_MS: 2000 = 2000;

How often a request admitted for a task writes what it has spent so far onto the row, while that changes.


taskDispatchInputSchema​

const taskDispatchInputSchema: z.ZodObject<{
assignee: z.ZodString;
attempt: z.ZodNumber;
boardId: z.ZodString;
createdAt: z.ZodNumber;
incarnationId: z.ZodOptional<z.ZodString>;
partition: z.ZodOptional<z.ZodString>;
payload: z.ZodUnknown;
taskId: z.ZodString;
turn: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
assignee: string;
attempt: number;
boardId: string;
createdAt: number;
incarnationId?: string;
partition?: string;
payload?: unknown;
taskId: string;
turn?: number;
}, {
assignee: string;
attempt: number;
boardId: string;
createdAt: number;
incarnationId?: string;
partition?: string;
payload?: unknown;
taskId: string;
turn?: number;
}>;

What a task dispatch carries: the claim's identity and the worker's input.

Every field is server-derived at dispatch — the board supplies them from the ticket it minted off the row it claimed. attempt, createdAt and incarnationId say which claim this dispatch believes it is running; assignee names the assignee the board routed the row to. The entry's gate decides whether all of that is still true: verified, never trusted.


taskWorkerInputSchema​

const taskWorkerInputSchema: z.ZodObject<{
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
data: z.ZodEffects<z.ZodString, string, string>;
filename: z.ZodOptional<z.ZodString>;
mediaType: z.ZodString;
type: z.ZodLiteral<"file">;
}, "strip", z.ZodTypeAny, {
data: string;
filename?: string;
mediaType: string;
type: "file";
}, {
data: string;
filename?: string;
mediaType: string;
type: "file";
}>, "many">>;
attempts: z.ZodNumber;
context: z.ZodOptional<z.ZodString>;
deps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
feedback: z.ZodOptional<z.ZodString>;
followUpOf: z.ZodOptional<z.ZodString>;
goal: z.ZodString;
input: z.ZodOptional<z.ZodUnknown>;
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
priorWork: z.ZodOptional<z.ZodUnknown>;
sealed: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
steers: z.ZodOptional<z.ZodArray<z.ZodObject<{
by: z.ZodOptional<z.ZodString>;
from: z.ZodEnum<["filer", "user", "board", "service"]>;
message: z.ZodString;
question: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
by?: string;
from: "board" | "filer" | "service" | "user";
message: string;
question?: string;
}, {
by?: string;
from: "board" | "filer" | "service" | "user";
message: string;
question?: string;
}>, "many">>;
taskId: z.ZodString;
title: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
attachments?: object[];
attempts: number;
context?: string;
deps?: Record<string, unknown>;
feedback?: string;
followUpOf?: string;
goal: string;
input?: unknown;
metadata?: Record<string, unknown>;
priorWork?: unknown;
sealed?: Record<string, unknown>;
steers?: object[];
taskId: string;
title?: string;
}, {
attachments?: object[];
attempts: number;
context?: string;
deps?: Record<string, unknown>;
feedback?: string;
followUpOf?: string;
goal: string;
input?: unknown;
metadata?: Record<string, unknown>;
priorWork?: unknown;
sealed?: Record<string, unknown>;
steers?: object[];
taskId: string;
title?: string;
}>;

Input contract handed to every worker. The board's packWorkerInput (or any pattern) packs the claimed task's salient fields into this shape so workers don't depend on the substrate's Task type directly.

This Zod object is also the declared inputSchema workers reuse (re-exported as taskWorkerInputSchema from @flow-state-dev/orchestration/task-board) — a declared schema is a FILTER, so a field the substrate packs but this object omits reaches no worker that declares it. TaskWorkerInput below is inferred from this object, so the two cannot drift apart the way they once did (priorWork packed by the board, stripped before any schema-declaring worker could read it).

Functions​

askMidway()​

function askMidway(
ctx,
ledger,
questions
): Promise<MidwayAsk>;

Ask questions midway, from the turn holding the task's claim: the collection's one write opens them on the row, drops its lease and ends the turn unsettled, and this request stops renewing that lease. What the turn did stands (its writes, messages and last checkpoint); the next turn starts from the brief, that checkpoint and the answers, on the same attempt, once the user has answered every one (or a deadline the host set passes).

The claim is the one this request holds (the gate's or an admission's, server-set), never one from input, so only the turn holding the current ticket asks. The model's tool calls this.

After the question is opened, a ledger that declares onMidwayQuestion is told the row's open midway questions, read from the committed row, so its filer hears them; a replay whose ask is declined tells them again, and the declaration's implementer dedupes per hold (Workforce by message id). Only this turn's questions are told: a decline for any other reason tells nothing. The telling runs inline, before this returns.

Once per request for the same turn and questions (ctx.runOnce): a durable turn that resumes from a stop replays the code before it, and that replay gets the first ask's answer back rather than opening the questions twice.

Parameters​

ctx​

BlockContext

ledger​

TaskCollectionRef

The board the task is on, as the request resolves it.

questions​

readonly object[]

Returns​

Promise<MidwayAsk>


cancelFromTurn()​

function cancelFromTurn(
ctx,
ledger,
reason
): Promise<TurnCancel>;

Cancel the task from the turn holding its claim, when what it worked toward was closed by a person and another attempt would end the same way (its pull requests were closed without merging). The claim is the one this request holds, server-set, as waitExternally's is, so only the turn holding the current ticket cancels; a later turn's claim declines it. Once the row ends this request stops renewing its lease, and the check at the request's end finds the row no longer its claim's and writes nothing.

Parameters​

ctx​

BlockContext

ledger​

TaskCollectionRef

The board the task is on, as the request resolves it.

reason​

string

Returns​

Promise<TurnCancel>


canHoldWait()​

function canHoldWait(ctx): boolean;

Whether the running request's host can hold a wait: durable execution (the resume is wired), a durability sweeper that resumes a wait at its deadline (RequestHost.hasWaitSweeper), and wakes (RequestHost.waits, present only where they are kept). Read off the server's request host, never from input. Every wait checks it before anything is written.

Parameters​

ctx​

object

Returns​

boolean


createApplyReplan()​

function createApplyReplan(options): BlockDefinition<ZodObject<{
tasks: ZodArray<ZodObject<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, "passthrough", ZodTypeAny, objectOutputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, ZodTypeAny, "passthrough">, objectInputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, ZodTypeAny, "passthrough">>, "many">;
}, "passthrough", ZodTypeAny, objectOutputType<{
tasks: ZodArray<ZodObject<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, "passthrough", ZodTypeAny, objectOutputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[..., ...]>>;
}, ZodTypeAny, "passthrough">, objectInputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[..., ...]>>;
}, ZodTypeAny, "passthrough">>, "many">;
}, ZodTypeAny, "passthrough">, objectInputType<{
tasks: ZodArray<ZodObject<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, "passthrough", ZodTypeAny, objectOutputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[..., ...]>>;
}, ZodTypeAny, "passthrough">, objectInputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[..., ...]>>;
}, ZodTypeAny, "passthrough">>, "many">;
}, ZodTypeAny, "passthrough">>, ZodObject<{
decision: ZodDefault<ZodEnum<["continue", "replan", "complete"]>>;
}, "strip", ZodTypeAny, {
decision: "complete" | "continue" | "replan";
}, {
decision?: "complete" | "continue" | "replan";
}>, objectOutputType<{
tasks: ZodArray<ZodObject<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, "passthrough", ZodTypeAny, objectOutputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, ZodTypeAny, "passthrough">, objectInputType<{
dependencies: ZodOptional<ZodArray<ZodString, "many">>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodOptional<ZodString>;
input: ZodOptional<ZodUnknown>;
maxAttempts: ZodOptional<ZodNumber>;
priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>;
}, ZodTypeAny, "passthrough">>, "many">;
}, ZodTypeAny, "passthrough">, {
decision: "continue";
}>;

Build the apply-replan handler. The input may carry the evaluator's pre-baked tasks OR the replanner's output; either way we expect a tasks: TaskInit[] array.

Parameters​

options​

ApplyReplanOptions

Returns​

BlockDefinition<ZodObject<{ tasks: ZodArray<ZodObject<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, "passthrough", ZodTypeAny, objectOutputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, ZodTypeAny, "passthrough">, objectInputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, ZodTypeAny, "passthrough">>, "many">; }, "passthrough", ZodTypeAny, objectOutputType<{ tasks: ZodArray<ZodObject<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, "passthrough", ZodTypeAny, objectOutputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[..., ...]>>; }, ZodTypeAny, "passthrough">, objectInputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[..., ...]>>; }, ZodTypeAny, "passthrough">>, "many">; }, ZodTypeAny, "passthrough">, objectInputType<{ tasks: ZodArray<ZodObject<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, "passthrough", ZodTypeAny, objectOutputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[..., ...]>>; }, ZodTypeAny, "passthrough">, objectInputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[..., ...]>>; }, ZodTypeAny, "passthrough">>, "many">; }, ZodTypeAny, "passthrough">>, ZodObject<{ decision: ZodDefault<ZodEnum<["continue", "replan", "complete"]>>; }, "strip", ZodTypeAny, { decision: "complete" | "continue" | "replan"; }, { decision?: "complete" | "continue" | "replan"; }>, objectOutputType<{ tasks: ZodArray<ZodObject<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, "passthrough", ZodTypeAny, objectOutputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, ZodTypeAny, "passthrough">, objectInputType<{ dependencies: ZodOptional<ZodArray<ZodString, "many">>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodOptional<ZodString>; input: ZodOptional<ZodUnknown>; maxAttempts: ZodOptional<ZodNumber>; priority: ZodOptional<ZodUnion<[ZodNumber, ZodString]>>; }, ZodTypeAny, "passthrough">>, "many">; }, ZodTypeAny, "passthrough">, { decision: "continue"; }>


createRecordError()​

function createRecordError(options): BlockDefinition<ZodUnknown, ZodUnknown, unknown, {
error: string;
recorded: "errored" | "cancelled";
}>;

Builds the rescue-path recorder. Wired into the worker body as .rescue([{ block: recordError }]).

Reading currentClaim (per-worker state) is the key correctness property: each worker only knows its own claimed task, so a thrown error here writes fail only to that one task — never to siblings' concurrently-claimed work. Presenting the same claim is what makes that property hold at the substrate too, rather than resting on this block reading the right slot.

Parameters​

options​

RecordErrorOptions

Returns​

BlockDefinition<ZodUnknown, ZodUnknown, unknown, { error: string; recorded: "errored" | "cancelled"; }>


createRecordSuccess()​

function createRecordSuccess(options): BlockDefinition<ZodUnknown, ZodTypeAny, unknown, void>;

Builds the success-path recorder. Wired into the worker pipeline as .tap(recordSuccess) — no output is produced, the upstream worker output flows through unchanged.

Parameters​

options​

RecordSuccessOptions

Returns​

BlockDefinition<ZodUnknown, ZodTypeAny, unknown, void>


currentWorkerClaim()​

function currentWorkerClaim(ctx): TaskClaimTicket | undefined;

The claim ticket of the worker whose async chain this call is running in, or undefined outside a claimed-worker scope — a coordinator, a directly-wired consumer, a board resolved by hand.

ctx is the reader's own context. A ticket stamped in another request reads as undefined: a turn a worker resumed or handed work to is not that worker.

Read by taskTools so a model-facing write presents ownership without the model ever seeing a token: the model still names a task id, and the substrate refuses when that id is not the one the caller holds. undefined means no ownership question is asked, which is the correct posture for a coordinator settling a task it never claimed.

Parameters​

ctx​

WorkerClaimReader

Returns​

TaskClaimTicket | undefined


goalSeekLoop()​

function goalSeekLoop(config): SequencerDefinition<any, any>;

Build a goalSeekLoop sequencer. See the module doc for the assembly and preconditions.

Parameters​

config​

GoalSeekLoopConfig

Returns​

SequencerDefinition<any, any>


mapToVerdict()​

function mapToVerdict<TSource>(source, mapping): Verdict;

Adapt an existing decision shape to a Verdict, injecting a default reason when the source omits one. Pure helper — patterns bring their own judge and map its output through this rather than goalSeekLoop shipping per-dialect factories.

Type Parameters​

TSource​

TSource

Parameters​

source​

TSource

mapping​

VerdictMapping<TSource>

Returns​

Verdict


taskBoard()​

function taskBoard<TInput, TOutput, TName, TCollection>(config): TaskBoardHandle<TInput, TOutput, TName, TaskBoardReach<TCollection>>;

Build a Task Board pattern instance. See module doc for the pipeline semantics and termination rules.

Type Parameters​

TInput​

TInput = unknown

TOutput​

TOutput = unknown

TName​

TName extends string = string

TCollection​

TCollection extends | TaskBoardRequestCollectionSpec | TaskBoardSequencerCollectionSpec | DefinedTaskCollection | TaskBoardCollectionFactory<TInput, TOutput> | undefined = | TaskBoardRequestCollectionSpec | TaskBoardSequencerCollectionSpec | DefinedTaskCollection | TaskBoardCollectionFactory<TInput, TOutput> | undefined

Parameters​

config​

TaskBoardConfig<TInput, TOutput> & object

Returns​

TaskBoardHandle<TInput, TOutput, TName, TaskBoardReach<TCollection>>


taskLedgers()​

function taskLedgers(options): TaskBinding;

A task entry's own source: take tasks from any ledger resolve answers for, read per dispatch, instead of from the one board that dispatches to it.

Pass the result as the entry's from (task: { actions: { work: { block, from: taskLedgers({ name, resolve }) } } }). defineFlow then gates the entry with no board in the flow: each dispatch's ledger id is resolved, an id the resolver does not answer for is refused before any row is read, and then every check a board's gate runs (row, attempt, identity, status, assignee, lease, run link) runs on that ledger. A sender's board dispatches under its boardId, so a board over a shared ledger dispatches under the ledger's id for a resolver keyed on ledger ids to find it.

Parameters​

options​

TaskLedgersOptions

Returns​

TaskBinding


taskRequestAdmission()​

function taskRequestAdmission(options): BlockDefinition<ZodUnknown, ZodTypeAny, unknown, void>;

Admit a request for a task that is waiting, as the head of its entry: .tap(taskRequestAdmission({ ... })), first in the entry's sequencer, and .tap(noteTaskAnswer) after the turn whose answer counts. The request then holds the task's claim (its tools write as the worker, reportProgress included), renews its lease, and checks the task at its end.

A task that is not waiting (no keptOpenBy, and no turn owed for its answered questions) is left to the request working it, and this request is admitted for nothing. Nor is one whose owed turn another claim took first: whichever claims first wins (D3).

Parameters​

options​

TaskRequestAdmissionOptions

Returns​

BlockDefinition<ZodUnknown, ZodTypeAny, unknown, void>


taskToolActions()​

Call Signature​

function taskToolActions(board, roster?): Record<string, ActionConfig>;

A durable board's task tools as a flow actions map, named <tool>_<suffix> (taskToolSuffix). Spread it into defineFlow's actions to let a caller — a person in the DevTool, an app's own screen — change a task from outside the run that works it.

Each action runs the same block a model's tool does, so every rule in the field table holds for a screen as for a model: a move the task cannot make comes back as { ok: false, error } naming the rule, and writes nothing. None of them claims, drains or settles the board, and reportProgress has no action. An action holds no claim: its cancel lands on a row a worker holds, and that worker's later result is declined. The engine refuses a session to another user, so an action acts as the signed-in user.

Two forms:

  • taskToolActions(board, roster?) — a taskBoard() handle. Its rows are reached through the board's own resolver, and each action composes the board's capability, so the flow need not declare the collection again.
  • taskToolActions(collectionId, resolve, roster?) — for a caller that resolves a durable ledger itself, to fence each action to its own session.

Pass a roster and the actions check assignees the way the model's tools do: createTask and updateTask refuse one the roster does not name, with the same unknown_assignee answer, and write nothing. It may be a function of the running context, read per call (AssigneeRosterSource), for a board whose team changes while it is in use. Without one, any assignee is accepted, as before.

Pass { dispatches: true } for a board that starts a ready row at once (TaskToolsOptions.dispatches): createTask_<suffix> then starts the row it files. No action waits: an action has no request to park, so getTask_<suffix> refuses wait by name.

These are public actions: anyone who can call the flow can call them.

The qualifier is not injective: a.b and a_b both give a_b. A flow that spreads two boards' actions whose ids qualify alike gets one set of names, and the later spread replaces the earlier. Give such boards distinct ids.

Parameters​
board​

TaskToolActionsBoard

roster?​

AssigneeRosterSource

Returns​

Record<string, ActionConfig>

Throws​

When the board's backing is not resource. A request- or sequencer-backed ledger is gone when the request that filed its rows ends, so a later action could never find them.

Call Signature​

function taskToolActions(
collectionId,
resolve,
roster?,
options?
): Record<string, ActionConfig>;

A durable board's task tools as a flow actions map, named <tool>_<suffix> (taskToolSuffix). Spread it into defineFlow's actions to let a caller — a person in the DevTool, an app's own screen — change a task from outside the run that works it.

Each action runs the same block a model's tool does, so every rule in the field table holds for a screen as for a model: a move the task cannot make comes back as { ok: false, error } naming the rule, and writes nothing. None of them claims, drains or settles the board, and reportProgress has no action. An action holds no claim: its cancel lands on a row a worker holds, and that worker's later result is declined. The engine refuses a session to another user, so an action acts as the signed-in user.

Two forms:

  • taskToolActions(board, roster?) — a taskBoard() handle. Its rows are reached through the board's own resolver, and each action composes the board's capability, so the flow need not declare the collection again.
  • taskToolActions(collectionId, resolve, roster?) — for a caller that resolves a durable ledger itself, to fence each action to its own session.

Pass a roster and the actions check assignees the way the model's tools do: createTask and updateTask refuse one the roster does not name, with the same unknown_assignee answer, and write nothing. It may be a function of the running context, read per call (AssigneeRosterSource), for a board whose team changes while it is in use. Without one, any assignee is accepted, as before.

Pass { dispatches: true } for a board that starts a ready row at once (TaskToolsOptions.dispatches): createTask_<suffix> then starts the row it files. No action waits: an action has no request to park, so getTask_<suffix> refuses wait by name.

These are public actions: anyone who can call the flow can call them.

The qualifier is not injective: a.b and a_b both give a_b. A flow that spreads two boards' actions whose ids qualify alike gets one set of names, and the later spread replaces the earlier. Give such boards distinct ids.

Parameters​
collectionId​

string

resolve​

TaskCollectionResolver

roster?​

AssigneeRosterSource

options?​

Pick<TaskToolsOptions, "dispatches">

Returns​

Record<string, ActionConfig>

Throws​

When the board's backing is not resource. A request- or sequencer-backed ledger is gone when the request that filed its rows ends, so a later action could never find them.


waitExternally()​

function waitExternally(
ctx,
ledger,
wait
): Promise<MidwayAsk>;

Wait on something outside the board, from the turn holding the task's claim: the collection's awaitExternal opens one external wait on the row (actor: "system"), drops its lease and ends the turn unsettled, and this request stops renewing that lease, as askMidway does for a question. A steer that answers the wait (a person's line, a delivered message) owes the same attempt one more turn.

Nobody is told: an external wait is no question for the filer, and the Inbox lists only a person's holds.

Once per request for the same turn and wait (ctx.runOnce), as a question is.

Parameters​

ctx​

BlockContext

ledger​

TaskCollectionRef

The board the task is on, as the request resolves it.

wait​

ExternalWait

Returns​

Promise<MidwayAsk>


waitGateId()​

function waitGateId(collectionId, taskId): string;

The stem of the gate a waiting request parks on: the board and the row. A wait adds its own nonce after #, so the gate names one wait; read a row's gate from row.wait.gateId, never by rebuilding it.

Parameters​

collectionId​

string

taskId​

string

Returns​

string


waitOnTask()​

function waitOnTask(
ctx,
collection,
taskId,
options,
checked?
): Promise<TaskWaitResult>;

Wait on taskId on collection until it ends or the deadline passes (see the module header). Every refusal comes before anything is written. Must run as a block with a stable identity on a durable host.

Parameters​

ctx​

BlockContext

collection​

TaskCollectionRef

taskId​

string

options​

WaitOnTaskOptions

checked?​

CheckedWait

What checkWait returned for this same task and key, when the caller checked first: the checks don't run again.

Returns​

Promise<TaskWaitResult>