@obversa/runner starts a stored graph in a worker process and makes the
calling process its watchdog: it checks the engines before the first step,
restarts the worker after a crash within the limits you set, and resumes a
paused run from its exact record. The guide is
Supervised local runs; this page is the surface.
Install
@obversa/obversa.
Quickstart
Start one graph under the watchdog and wait for its result:examples/preflight-supervised-run.ts (excerpt)
startSupervisedRun returns a SupervisedRunHandle with done,
status() and stop(). done resolves to a SupervisedRunResult:
complete, pause or fail. The host module named by module exports
bindRun, which returns the compiled graph and the node and engine
bindings; examples/preflight-host.mjs is one.
Read progress
readSupervisedRunStatus reads a run’s recorded progress from any process
with the same storage settings, without taking ownership of the run:
examples/supervised-run.ts (excerpt)
SupervisedRunStatus carries the run phase, worker liveness, inspected
processes, the restart count, backoff, elapsed and remaining time, and
pause reasons. cleanupVerified is null before a terminal result, true
when cleanup was verified, false when it couldn’t be; leaseRetained
reports a lease still held after a terminal failure. Read both before
treating the workspace as released.
Resume a pause
resumeSupervisedRun reopens one recorded pause. For a preflight pause,
pass the preflightEventId; for a node pause, the exact position:
examples/preflight-supervised-run.ts (excerpt)
Options
limits and restart
limits.timeoutMs covers worker execution and restart backoff across
pauses and resumes; it counts from the stored run timestamp, freezes at each
settled pause, and resumes at the next launch. limits.maxDispatches
counts recorded dispatches across workers. restart.maxRestarts caps
replacement workers, with backoff from initialBackoffMs to
maxBackoffMs. A run over a limit ends with fail.
module and environmentVariables
module is a relative specifier inside runRoot; a path outside it after
symlinks resolve is refused with HOST_MODULE, and changed bytes between
imports fail with HOST_MODULE_CHANGED. The worker inherits only PATH,
HOME, TMPDIR, TMP, TEMP, SystemRoot, USERPROFILE and PATHEXT;
list any other variable name in environmentVariables and the runner
copies its value when set, storing neither name nor value.
The rest
Errors
SupervisedRunErroris the runner’s own error class. The codes on afailresult:STOPPED,PREFLIGHT_FAILED,OUTPUT_LIMIT,TERMINAL_ARTIFACT,RUN_STORAGE,PROCESS_LOCKED,HOST_MODULE,HOST_MODULE_CHANGED,DAG_NODE_FAILED; on apause:PREFLIGHT_PAUSED,WORKSPACE_DRIFT,WORKSPACE_ANCHOR_MISSING,WORKSPACE_ANCHOR_INVALID,WORKSPACE_ANCHOR_WRITE,RESUME_EVENT_MISMATCH. What each means is on Supervised local runs.
API
startSupervisedRun(options): start a worker under the calling process’s supervision. Quickstart.resumeSupervisedRun(options): reopen one recorded pause. Resume a pause.readSupervisedRunStatus({ storage, runId }): read recorded progress from another process. Read progress.SupervisedRunError: the error class. Errors.- Types:
SupervisedRunOptions,ResumeSupervisedRunOptions,ResumePreflightSupervisedRunOptions,ReadSupervisedRunStatusOptions,SupervisedRunHandle,SupervisedRunResult,SupervisedRunStatus,SupervisedRunUsage,SupervisedRunBindings,SupervisedHostContext.
Next steps
- Supervised local runs: the guide, with the whole example and its output.
- The record: what a restarted run skips and repeats.