flow/run/resume

Source: src/flow/run/resume.ts

resumeFlow: a run carried on from its run directory, as deep as its journal goes.

It runs what the snapshot holds, never the flow files on disk, checked again at both stages with the scripts the run started with, on the input and the settings it started with. Only timeoutMs may be given again. The subagents are fresh, since no conversation is kept: each reads its reads:, its ledger and the tree. The same journal goes on, under the same lock, and the run’s branch must be where HEAD is: a resume checks it, and never switches to it.

latestResumable

function

export function latestResumable(runsDir: string, cwd: string): Resumable | undefined { /* … */ }

The newest run under runsDir started in cwd that a resume would take, newest by directory name, which a run directory’s timestamp makes its age ({@link newestRunFirst}). When none would, the newest run of cwd and why; nothing when cwd started none there. A directory holding no snapshot holds no run, and one that no longer reads or checks cannot be resumed by this version anyway.

Resumable

type

export type Resumable = { readonly ok: true; readonly runDir: string; readonly from: string } | { readonly ok: false; readonly runDir: string; readonly refused: string };

The run a resume would take, and the visit it picks up from; or the newest run, and why it cannot.

Resumed

type

export type Resumed =
	| (FlowResult & { readonly from: string; readonly changed?: string })
	| { readonly ok: false; readonly refused: string }
	| { readonly ok: false; readonly faults: readonly Fault[] };

How a resume ended: as the run did, with the visit it picked up from and a line saying which flow files changed on disk since it started; or refused before anything ran, with why, or with the faults of a check.

resumeFlow

function

export async function resumeFlow(runDir: string, options: ResumeFlowOptions): Promise<Resumed> { /* … */ }

Resumes the run in runDir. Throws when the directory holds no snapshot: it holds no run.

ResumeFlowOptions

type

export type ResumeFlowOptions = Pick<RunFlowOptions, "spawn" | "signal" | "onEvent" | "timeoutMs" | "model"> & {
	/** How the resumed run reaches the world, checked again at the run stage. */
	readonly ports: FlowPorts;
	/** Whether a person can answer now: the run stage holds the flow to it, as at a start. */
	readonly somebodyThere: boolean;
	/** Refused when given: the input is the run's own, kept in its snapshot. */
	readonly input?: unknown;
};

What a resume is given: where it runs, and the switches of a run. model and input are the run’s own, frozen: giving either refuses the resume.