@sema-agent/core
Version:
Stateless, task-oriented AI agent core
352 lines (351 loc) • 32.6 kB
TypeScript
import { type NoticeRoute } from "../leg-identity.js";
import { type AgentDefinition, type EngineNotice, type ModelRef, type ModelRoles, type RunnerDeps, type TaskEvent, type TaskResult, type TaskSpec, type TaskStream } from "../types.js";
import type { Model } from "../../internal/llm.js";
import { type CheckpointToken, type ResumeOutcome } from "../checkpoint-store.js";
import { type CompactSessionRequest, type CompactSessionResult } from "../auto-compaction.js";
import { type DrainOptions, type DrainReceipt } from "../runner-drain.js";
import { type TaskOutcome } from "../task-outcome.js";
import { type SwappableDeps } from "../swappable-deps.js";
import { type SideQuerySpec, type SideQueryResult } from "../side-query.js";
import type { SessionStore } from "../session.js";
import { type ForgetMcpFailureRequest, type ForgetMcpFailureResult } from "../mcp-connection-pool.js";
import { type SessionAddress, type SessionCompletionLane, type TaskNotificationSink } from "../task-notification.js";
import { type ContextSettings, type ContextWindowOverlay } from "../context-settings.js";
import type { ResumeRun, ResumeTaskConfig, RunInternals, RunnerSelfSeat } from "./contracts.js";
export type { ResumeTaskConfig } from "./contracts.js";
import { type ResumeConfigQuestion, type ResumeConfigVerdict } from "../resume-config-judge.js";
import { type TaskStartVerdict } from "../task-start-judge.js";
import type { PlaintextOrigins } from "@sema-agent/primitives";
import type { SessionChanges, SessionChangesRequest } from "../session-changes.js";
import { type InstructionPreviewResult } from "../instruction-preview.js";
import type { RewindFilesRequest, RewindFilesResult } from "../file-history-store.js";
import type { RewindConversationRequest, RewindConversationResult } from "../rewind-conversation.js";
import { type PeerDeclarationHold, type PeerDeclarations } from "../peer-seat.js";
/**
* A stateless task runner. Holds shared deps (the external brain, model catalog) and an
* in-memory session store so that passing a `sessionId` continues a prior conversation.
*/
export declare class Runner implements RunnerSelfSeat {
private deps;
readonly sessions: SessionStore;
/** Per-sessionId serialization so two tasks never mutate one session concurrently. */
private sessionLocks;
/** The lock's tail: the session writes this Runner's legs issued that have not settled — a session's next holder starts after them. */
private readonly sessionWrites;
/** The session-lock seats every out-of-run verb (`rewindFiles`, `compactSession`, `rewindConversation`) is lent — ONE reading of "busy": a leg holds or awaits the lock, or a write issued to the session has not settled. */
private readonly verbLockSeats;
/** Per-session read-file-state seats (CC parity: readFileState is session-scoped;
* sema's map stays per-task, so the session scope lives here). A bounded CACHE, never an
* authority: a durable resume's checkpoint seed wins on its leg, and a miss (cross-process,
* evicted) falls back to the transcript-replay rung. See {@link SessionReadFileStates}. */
private readonly sessionReadStates;
private readonly sessionModeSeats;
/** What each session learned about fast mode in this process (cooldown, refusals, the latched beta) — see {@link SessionFastModeSeats}. */
private readonly sessionFastModeSeats;
/** What each session's prompt holds in this process (the elapsed-time clock) — see {@link SessionPromptSeats}. */
private readonly sessionPromptSeats;
/** The MCP pools of the process's session trees — one table every Runner reads: one pool per tree root's address, remembering a failed connection attempt ({@link processSessionMcpPools}). */
private readonly sessionMcpPools;
/** This Runner's view of the session route (frames parked between legs, the live lanes a frame is routed to): the state is the table of {@link sessions} ×
* `deps.mailboxStore` every Runner of the process over that pair reads ({@link sessionRouteTableOf}); bounded + drop-disclosing, not checkpointed. */
private readonly pendingSessionNotifications;
/** Parent effective-policy inheritance (same-process resume convenience): checkpoint token → the OPAQUE
* `parentConstraints` the suspended leg ran under. Registered by `runTaskStream`'s result hook whenever a
* run spawned WITH `internals.inheritedGate.parentConstraints` ends `suspended` (process-local closures
* parked while the park is live — the same lifecycle posture as the subagent retain ledger's
* `internalsSnapshot`). `resumeStream` consults it when the caller supplied no constraints, so a
* same-process `runner.resume()` on a delegated child's checkpoint runs under the live chain; a
* CROSS-process resume (registry miss — a different Runner/process) rebuilds the chain from the row's record
* (`revivalParentConstraints`, constraint-layers.ts) and refuses pre-CAS what it cannot rebuild.
* Retention: entries are kept across an `env_failed` reopen (the same token is retried), evicted on an
* observed `already_resolved` and by the FIFO cap — an evicted entry only ever degrades to the rebuild
* (or its refusal), never fail-open. */
private readonly parentConstraintRegistry;
/** Same-process suspended-env reap handles by token: the fence contract is
* "only the expire WINNER destroys the paused env", and the terminal resume-preflight arm
* (resumeStream) can now BE that winner — without this registry the losing stream-side
* reapSuspended returned early and the paused env this process holds leaked forever. Registered
* when a suspend publishes its reap handle; retired when the stream's own reap runs, when the
* resumed leg settles and its row is not coming back (a row its compensation brought back, or
* may have, keeps it — the ORIGINAL stream's closure stays the reaping owner, deliberately; the
* leg's other resources read the same answer), and when the terminal arm wins. Bounded by live
* suspended streams (the closures hold the same handles). */
private readonly suspendedEnvReaps;
/** SAME-RUNNER claims for {@link suspendedEnvReaps}, one PER ATTEMPT: a token is held from the moment an
* in-process actor ATTEMPTS its settling CAS (the terminal preflight's or the void verb's expire; a resume's
* resolve) until that actor's duty decision closes its own claim (never another's). The losing stream-side
* reap preserves a record ONLY while a local claim is in flight — a CROSS-Runner settlement
* leaves no local claim, so the loser retires the record (drops the strong ref; physical cleanup
* belongs to the winning owner, unprovable from here) instead of retaining env handles without
* bound in a long-lived Runner. A stale claim's failure direction is retention (the status quo),
* never a wrong destroy. */
private readonly locallyClaimedTokens;
private static readonly PARENT_CONSTRAINT_REGISTRY_CAP;
private readonly drainSeats;
/** The lanes' LIVE view of `deps` ({@link RunnerDepsSeat}): a getter, never a captured object, because
* `swapDeps` replaces the object and a rung reading after its own await must see the replacement. */
private readonly depsSeat;
constructor(deps: RunnerDeps);
/** Fire `RunnerDeps.onTaskOutcome` through the single swallow-guarded chokepoint
* ({@link emitTaskOutcome}: mechanical-tier only, throwing sink never breaks the caller). Public so
* thin compositions OVER the Runner (`runGoal`) can emit at their terminal state without reaching
* into private deps. */
emitTaskOutcome(outcome: TaskOutcome): void;
/** Announce a composition's own fact on `RunnerDeps.onNotice` (read at the call: `swapDeps` replaces the deps): {@link RunnerSelfSeat.emitNotice}. */
emitNotice(notice: EngineNotice, route?: NoticeRoute): void;
/** Whether a child this Runner runs can be placed in another tree: {@link RunnerSelfSeat.canRerootChild}. */
canRerootChild(): boolean;
/** A completion addressed to a tree's root, through this Runner's route: {@link RunnerSelfSeat.sessionCompletionLane}. */
sessionCompletionLane(root: SessionAddress, unkept?: TaskNotificationSink): SessionCompletionLane;
/** A hold of `declared`'s references on this Runner's peer seat: {@link RunnerSelfSeat.holdDeclarations}. A seat member that throws reaches `onError`. */
holdDeclarations(declared: PeerDeclarations, sessionId?: string): PeerDeclarationHold;
/** The deployment agent catalog (RunnerDeps.agents/builtinAgents), exposed READ-ONLY
* so the Agent-tool lane (`createSubagentTool`) defaults to the SAME registry the workflow lane
* consumes (single source; the types.ts "pass the same array" follow-on made structural). The array
* is a fresh copy — a caller mutating it never rewrites this Runner's own deps; the definitions
* themselves are the shared objects (frozen by convention, same as gateBaseline's posture). */
get agentCatalog(): {
agents?: AgentDefinition[];
builtinAgents?: boolean;
models?: Record<string, Model>;
roles?: ModelRoles;
};
/** The deployment's per-model context-window overlay as declared ({@link RunnerDeps.contextSettings}); a fresh
* read every call, the overlay objects frozen at their gate. */
get contextSettings(): ContextSettings | undefined;
/** The overlay a leg on `ref` reads RIGHT NOW — the one lookup ({@link contextOverlayFor}, tier aliases
* followed) against the seat and catalog in force, so a `swapDeps` reaches legs already running. */
contextOverlayOf(ref: ModelRef | undefined): ContextWindowOverlay | undefined;
/** The deployment-level gating baseline, exposed READ-ONLY so thin
* assemblers over the Runner (`runSpec`) can COMPOSE with it. The task-level engine semantic for the policy is a
* WHOLE-SLOT override (`spec.toolPolicy ?? deps.toolPolicy` — prepare-task), so any assembler that sets
* `spec.toolPolicy` without folding this in silently shadows the deployment baseline. (The mods bus needs no
* baseline: its two seats run side by side, so an assembler's task registrations never shadow `deps.mods`.)
* Getter only — nothing here is writable from outside. */
get gateBaseline(): {
toolPolicy?: RunnerDeps["toolPolicy"];
};
/** Acquire the lock for a sessionId; returns a release fn. The one lock every leg holds on its session, from the moment it
* knows the id to the leg's end (through `holdSessionLock` in `streamLeg`, one per leg). A resumed leg knows its id at the
* ladder: `resumeLadder` takes the lock before the claim and hands the hold to the leg it starts. */
private acquireSessionLock;
/**
* Hot-swap the deployment seats a running Runner may change without a restart — the ONE door for every
* hot-swappable seat (the closed set {@link SWAPPABLE_DEP_SEATS}, each seat's meaning beside it), and the ONLY sanctioned way to
* change any of them after construction. It replaces the former `swapModels` verb (retired, no alias):
* one verb per seat restated the same laws with a list of verbs as the only record of what is swappable.
*
* The laws, stated once (see the vocabulary module for the seat-by-seat meaning):
* - **Screened first, written once — atomic.** The candidate is screened whole
* ({@link screenSwappableDeps}: the key set is the closed one, at least one seat, `tiers` rides with
* `models`, each seat's own value gate — both face seats through the very `assertContainmentFaceValue` every
* prepare door applies) and the catalog is tier-expanded on the candidate (an illegal binding throws
* exactly like the constructor's boot error) BEFORE the deps object is replaced. On any throw the
* current deps stay in force, byte-identical.
* - **In-flight legs keep their snapshot.** A running task read `this.deps` at its prepare and holds
* that object: its `Model`, its resolved read face, everything. The swap changes what FUTURE prepares
* (and auto-sourced agents' string refs — {@link agentCatalog} copies per read) resolve. Same-name
* redirects never re-route or re-price a task mid-run; a read-face change never re-fences a mounted
* band; the divergence window is exactly the in-flight legs' lifetime, by design.
* - **Presence is the instruction.** A key present on the candidate is replaced (an explicit
* `undefined` clears an optional seat: `tiers: undefined` ⇒ no bindings, a face seat `undefined` ⇒ the
* engine default); a key absent is kept. `tiers` omitted beside `models` ⇒ the current bindings are
* re-applied over the new catalog.
* - **Announced per seat.** `config.models_swapped` (models/tiers counts and the candidate's `generation` — key
* material only, never the catalog itself) and
* `config.read_face_swapped` / `config.write_face_swapped` (`{ from, to, occurrenceId }`, the seat's
* previous and new value, `null` = no declaration) — the table {@link SWAP_SEAT_NOTICE} binds every
* seat to its line.
*/
swapDeps(next: SwappableDeps): void;
/** one-shot brain-routed utility query (see {@link runSideQuery} for the full contract):
* preserves system/multi-turn messages/tool DEFINITIONS, routes through the deployment's brain with
* the same model resolution as tasks, returns real usage/model. No session, no tool execution, no
* policy gate, no run accounting — caller-trusted; the result's `account` is its engine-priced line for the host's session account. */
sideQuery(spec: SideQuerySpec): Promise<SideQueryResult>;
/** The out-of-run code-only rewind, no model call and no session entry — the contract is {@link rewindSessionFiles}'s (refused while a leg of this Runner holds or awaits the session's lock, or a write issued to it has not settled). */
rewindFiles(request: RewindFilesRequest): Promise<RewindFilesResult>;
/** What changed in a session's files, read outside any run — the contract is {@link readSessionChanges}'s (no lock: a leg running on the session does not refuse it; no gate, no frame, no write). */
readSessionChanges(request: SessionChangesRequest): Promise<SessionChanges>;
/** Pre-run instruction-file manifest preview via the lane's single first-load reading (zero model calls, session/read-state writes, or notices; coded refusal on bad specs). */
previewInstructions(spec: TaskSpec, internals?: RunInternals): Promise<InstructionPreviewResult>;
/** The plain-http admission list in force (minted at `new Runner` from `RunnerDeps.plaintextOrigins` and the posture; frozen), written on every model call. */
get plaintextOrigins(): PlaintextOrigins;
/** The out-of-run manual compaction, no run and no user turn — the contract is {@link compactIdleSession}'s (the one pass every lane runs; refused while a leg of this Runner holds or awaits the session's lock, or a write issued to it has not settled, and while the session is parked at a pending checkpoint). */
compactSession(request: CompactSessionRequest): Promise<CompactSessionResult>;
/** The out-of-run conversation rewind, no model call and no run — the contract is {@link rewindSessionConversation}'s (the landing a run's `resumeAt` + `resumeAtMode: "before"` makes; refused while a leg of this Runner holds or awaits the session's lock, or a write issued to it has not settled, and while the session is parked at a pending checkpoint; `dryRun` judges the same and writes nothing). */
rewindConversation(request: RewindConversationRequest): Promise<RewindConversationResult>;
/** The out-of-run recovery of an MCP server: the session forgets — for the principal the request names and this Runner's peer seat — its failed connection attempt at `server`, so its next message dials it (nothing is dialed now; no lock, no session entry — {@link forgetSessionMcpFailure}). In a live run, `TaskStream.reconnectMcpServer` dials now. */
forgetMcpFailure(request: ForgetMcpFailureRequest): ForgetMcpFailureResult;
/** Run a task and stream live events; await `.result()` for the final TaskResult. `resume` (internal)
* drives a durable resume through the same loop instead of a fresh objective prompt.
* `internals` (internal) is a TRUSTED run-scoped channel for live per-task state the
* Runner cannot see from `spec` (today: a `runRepairLoop` attempt's live `repairBundle`) — NOT a
* `TaskSpec` field; undefined on the public path.
* **Eager:** the task starts executing the moment this stream is constructed (fire-and-forget), NOT lazily
* on first iteration — you do NOT need to pull events for the run (and its `finish()`/env teardown) to
* happen. Iterating just observes events (the buffer is backpressure-free); `.result()` awaits completion. */
runTaskStream(spec: TaskSpec, resume?: ResumeRun, internals?: RunInternals): TaskStream;
/** The leg behind `runTaskStream`. `resumeHold` is the session lock a resume's ladder took before its claim: the leg
* adopts it as its one hold (the same session id, released by the leg's own release) instead of taking another. */
private streamLeg;
/**
* The run body as ONE driver method: `runLocked`'s signature, the lane order, and the two assemblies
* the driver keeps (the harness handlers, the turn boundary). The lanes' products are threaded under the names they hand
* back; the two continuations the S6 driver spelled as private methods (`runSeatLanes` / `runAssembliesAndLegs`, joined by
* a `RunSeatsHandoff` re-spelling of two lanes' Results) are the `next` closures of the two async lanes they follow — the
* notification lane's (R0) and the attachment seats' (R3) — because a closure sees what the lanes before it bound, so
* nothing is re-spelled and nothing is re-destructured. Neither this method nor either closure is `async`: each lane's
* own promise IS this method's, so a prepare that throws reaches the run IIFE's catch / finally (the failure backstop,
* the session lock's release) on the tick it did, and each successor is entered on the tick its lane's last await
* resolved on (the S6 TICKS pin holds unchanged: no first host read moved off the tick the one-function body read it on).
*/
private runLocked;
/** Run a task to completion and return a machine-readable result. */
runTask(spec: TaskSpec, internals?: RunInternals): Promise<TaskResult>;
/**
* Resume a task suspended at a durable approval gate. The token came back as
* `TaskResult.checkpointToken` from a `status:"suspended"` run; `outcome` carries the human/external
* decision (`allow`/`deny`, with an optional `updatedInput` arg rewrite or `reason`); `taskConfig`
* **re-supplies** the same tools / model / policy the task ran with (a token cannot reconstruct tool
* implementations or the hand band — the session stores neither).
*
* Flow (§2.1): `get` the checkpoint → validate the outcome arm matches the gate (council #3) → **atomic
* CAS `resolve`**. *Winning the CAS is the sole trigger to execute the pending action* — so a double /
* concurrent resume of the same token loses the CAS and is rejected (`checkpoint.already_resolved`),
* never re-running the side-effecting tool. The winner rewinds the session to the suspension point,
* resolves the gated call (execute on `allow`, inject a denial on `deny`), closes the rest of the
* suspended batch as deferred, and re-enters the run loop with a continuation — returning a normal
* {@link TaskResult} (which may itself be `suspended` again with a fresh token).
*
* v1 serves only the `human`/`policy_ask` gate (F4). A `task_done` checkpoint (1C Path A) is not
* resumable here — the caller orchestrates that one and reads its handle directly.
*
* **🔒 Authorization boundary — token-as-auth, scope is store-level
* isolation, NOT caller authorization.** `resume` is TOKEN-AS-AUTH: whoever presents a valid, still-`pending`
* checkpoint token resolves it. The scope passed to the store CAS is the checkpoint's OWN `cp.scope` (read
* off the row), so the store's scope-WHERE is store-level multi-tenant DATA isolation (one tenant's reaper /
* mis-scoped resolve can't touch another's row) — it does **not** verify that THIS CALLER is authorized for
* that scope. Authorizing the operator's principal against the checkpoint (the "tenant-B holding tenant-A's
* token must not resolve it" property) is the **caller's** responsibility: the BFF / supervisor service mints
* the principal, scopes the approval inbox to it, and only calls `resume` for a checkpoint that principal
* owns. The token's secrecy + single-use HMAC binding (D-G) is what keeps it from reaching the wrong tenant.
* A direct (non-BFF) client is BLOCKED until D-G's cryptographic principal binding — never trust a
* client-supplied principal/scope here.
*
* @throws {@link CheckpointError} `not_found` (no store / unknown token), `gate_mismatch` (outcome arm
* ≠ gate, or an unsupported gate), `invalid_outcome` (decision-action binding failed — boundCallId/
* boundInputHash mismatch, or a deny reason with a `</system-reminder>` tag), `reopen_revote` (an
* env_failed re-resume supplied a decision ≠ the persisted winner), `reopened_concurrently` (the
* optimistic-concurrency `rev` changed under a concurrent resolve/reopen — re-resume against current
* state), `unsupported_version` (checkpoint newer than this worker / remote handle with no factory),
* `already_resolved` (lost the CAS — idempotent no-op), `walltime_axis_retired` (pre-CAS: the
* persisted ledger carries the retired wall-clock budget axis — a worker of the previous release can
* still finish it), `resume_aborted` (the caller's signal was already aborted at entry, or aborted
* during the resume — before the claim the checkpoint stays pending; after it, `detail.unstartedRow: "reopened"` says the claim was
* reversed (pending again), and without it the code does not say which state the row is in — read it), `reopen_failed` (an aborted
* resume could not prove its claim reversed — `detail.unstartedRow` is `"declined"` (the store refused: read the row) or `"unknown"`
* (the reopen failed in flight: state unprovable)), `config_refused` (pre-CAS: the re-supplied
* config or a mode the row recorded is one prepare would refuse — `detail.code` is prepare's own code,
* `detail.field` says whether the config or the row carries it; the checkpoint stays pending and
* unchanged). Each code's full contract is on {@link CheckpointError.code}.
*/
resume(token: CheckpointToken, outcome: ResumeOutcome, taskConfig: ResumeTaskConfig,
/** Same TRUSTED run-internals seam as {@link resumeStream} — the convenience wrapper
* FORWARDS it (it used to silently drop a 4th arg, so a cross-process re-supply through resume()
* looked wired but always failed `resume.parent_constraint_missing`). */
internals?: RunInternals): Promise<TaskResult>;
/**
* Streaming form of {@link resume}: runs the identical pre-CAS guards + atomic CAS, then returns the live
* {@link TaskStream} of the resumed run (its events + `result()`) instead of draining it to a final
* {@link TaskResult}. Use this when the resumed segment's tool/turn events must reach an event sink for
* observability parity with the original `runInBackground` stream (service [15]); `resume()` is the
* convenience wrapper that drains it. The guards + CAS run FIRST, so this rejects with the same
* {@link CheckpointError}s as `resume` *before* any stream is returned (winning the CAS is still the sole
* trigger to execute the pending action — a lost CAS rejects, never returns a re-running stream). The session's lock is
* taken before the async guards and held through the CAS into the resumed leg: while another leg or a session verb holds
* the session, this waits (the checkpoint pending), and while this holds it, the session reads busy to those verbs.
*
* **Eager (like {@link runTaskStream}):** once this resolves, the resumed run is already executing — the
* pending action runs exactly once and the run-loop tail's `teardownOwnedEnv` tears down the
* rebuilt remote env even if you never iterate the stream. So abandoning the returned stream is safe (no leak,
* no hang); it only means you
* don't observe the resumed segment's events.
*/
resumeStream(token: CheckpointToken, outcome: ResumeOutcome, taskConfig: ResumeTaskConfig,
/** the TRUSTED run-internals seam, symmetric with {@link runTaskStream} — a resume leg
* otherwise has no `onForwardEvent`席位, so a subagent's task_progress ticks (child-isolated stream,
* only exit = the forward sink) were unreachable on resume. Deployment-owned, never a TaskSpec field.
* Parent effective-policy inheritance CONTRACT: a checkpoint whose `state.inheritedGate.
* requiresParentConstraint` is true was suspended under inherited OPAQUE parent-policy constraints
* (live ToolPolicy/onAsk closures — non-serializable). The chain the resumed leg runs under comes from ONE function
* (`revivalParentConstraints`, constraint-layers.ts): the chain handed here (`internals.inheritedGate.parentConstraints`),
* else the live one this Runner registered at the spawn (`parentConstraintRegistry`), else REBUILT layer by layer from the
* row's record (each entry's `kind`: an installation from this Runner's and the leg's `mods`, a `taskPolicy` from
* `internals.rootPolicy`, a `deploymentPolicy` from `RunnerDeps.toolPolicy`). A layer it cannot rebuild rejects pre-CAS with
* `resume.parent_constraint_unrebuildable` (the checkpoint stays pending) — never a silent resume with the ancestors' gate
* dropped. A handed or rebuilt chain's LENGTH must match the checkpoint's recorded `parentConstraintCount` and its digest
* the recorded one (`resume.parent_constraint_mismatch` otherwise). A handed screening entry (issue #33) is an installation
* `{ installation: await admitModChain(…), hookEnv, kind: "installation", …regime }`. The DATA half (ancestorRules/shellGate) rides the checkpoint itself and needs no
* re-supply; on the resumed leg the CHECKPOINT snapshot is the trust floor — live internals may only
* TIGHTEN it (per-entry rev-monotonic ancestorRules replacement, max-rank shellGate fold), never
* displace it wholesale. TRUST BOUNDARY: `internals` is the DEPLOYMENT trust channel (the same tier as
* `inheritedSkillGrants` and every other RunInternals field) — the library caller is trusted to
* re-supply the genuine chain; a caller able to invoke resumeStream already holds full Runner
* authority, so constraint substitution here is outside the enforced threat model (the count check
* catches shape MISTAKES, not a untrusted trusted caller). */
internals?: RunInternals): Promise<TaskStream>;
/** Yield what this Runner holds now and hand back one receipt (contract: {@link DrainReceipt}, `runner-drain.ts`). A bad `waitMs` throws `RangeError` at the call. */
drain(opts: DrainOptions): Promise<DrainReceipt>;
/**
* The resume's config rungs, asked as a value — by a host that writes something of its own before it calls the resume. The same functions the ladder calls
* at those rungs, in its order, over the deps and session store THIS Runner holds, so the answer is the claim path's own. `{ ok: true }`, or the
* `checkpoint.config_refused` the resume would give (`code`, `field`, `reason?`, `message`). Pure; only the config question is answered (the row's own
* verdict is `checkpointRowRefusal`'s). See `resume-config-judge.ts`.
*/
judgeResumeConfig(question: ResumeConfigQuestion): ResumeConfigVerdict;
/**
* The doors a fresh run passes before its session is acquired, asked as a value by a host that writes before it calls `runTaskStream` — the function
* prepare runs first and the two prepare judges a handed-on spend seat with, over THIS Runner's deps and session store (`task-start-judge.ts`): the run's own `failed` terminal, or `{ ok: true }`. What the
* entry's spec reads throw at the call (a spec that is no object, an `actor` its snapshot cannot read) is thrown the same way; NOT asked: the entry's door
* on the internals bag (KL-4525-c: a retired member such as `onStatusEvent`, the `onLegFrame` seat, a bag that is no object). `ok: true` is no pass
* and no receipt to keep ({@link TaskStartVerdict}). Acquires no session, takes no lock, mints no environment, calls no store verb, writes no host sink.
*/
judgeTaskStart(spec: TaskSpec, internals?: RunInternals): TaskStartVerdict;
/**
* Void a verification gate's VERIFIER card — the pause `VerificationOutcome.verifierPause` hands back — and unpin the verifier
* session it held: the cancel a host that will not decide the card takes, instead of leaving it to the reaper. The card is
* read first: only one whose `CheckpointState.compositionLeg` records a `verify` leg is voided (any other is refused,
* `resume.composition_mismatch`, nothing settled). Voiding is the single-shot expire CAS — the row ends `expired`, the same end
* an expiry gives it (a later resume of the token is refused as after one, `checkpoint.already_resolved`; the gate's result the
* caller holds is untouched), with the same duty (the paused env this process holds destroyed, the parked-constraint entry evicted) —
* and then the session is UNPINNED, the end state a resumed run's terminal leaves (not released: its transcript stays the
* session store's to evict). Resolves `true` when this call voided the card, `false` when another settler already had (a
* resume won, the reaper or an earlier void expired it) — its winner owns the unpin; an expired row's env this process holds is
* still destroyed (whoever expired it), and calling again answers `false`.
* @throws {@link CheckpointError} `not_found` (no store wired / unknown token), `resume.composition_mismatch` (not a verifier's card),
* `checkpoint.void_unpin_failed` (voided, but the session's unpin threw or wedged: still pinned).
*/
voidVerifierPause(token: CheckpointToken): Promise<boolean>;
/**
* The resume decision ladder after admission (E3–E10), driving the eight `resume-*` lanes in
* the order the one-function ladder had: the review / park twins, the approval twin and its bindings, the
* checkpoint screen, the internals-and-config rungs, then the session lock and the window entrance under it,
* then the three async rungs after it — apply, preflight, claim — each entering the next in its own last
* continuation, and the post-claim hand-off to the resumed leg. Every rung throws its typed refusal pre-CAS;
* the first `return` is the leg's stream.
*/
private resumeLadder;
/**
* The ladder's POST-CLAIM rung (E11), the driver's own: the post-consume hook, the answering
* face minted from the decide's answer, the resumed leg's spec (identity continuity, the existing-session
* requirement, the stripped pre-aborted preempt signal), the reopen compensation and the execution-record
* verb bound to the row, the two post-CAS abort re-checks, and the hand-off to the leg (`streamLeg`) with the plain
* twin and the ladder's session hold. Entered in the claim rung's last continuation, so its first statement runs on
* the tick the win was read.
*/
private resumeHandoff;
}
/** Convenience: one-shot run with explicit deps (creates a throwaway Runner; delivers a construction refusal as a failed TaskResult rather than throwing synchronously). */
export declare function runTask(spec: TaskSpec, deps: RunnerDeps): Promise<TaskResult>;
export type { TaskEvent, TaskStream };