Skip to main content

@svatah/yam-runtime

Runner-agnostic executor core: scope, guards, checkpoints, policies, results, audit

Exports

ExportKindSignature
abortedByPolicyfunctionexport function abortedByPolicy(results: readonly StepResult[]): booleanDid a policy abort the flow these results belong to (LLD §8.3, Draft 2.7)?
ApiRunnertypealiasexport type ApiRunner = (Runs an api step. Injected for the same reason.
AuditContextinterfaceexport interface AuditContext
Auditorclassexport class Auditor
AuditSinkinterfaceexport interface AuditSink
checkpointForfunctionexport function checkpointFor(parts: Omit<Checkpoint, "schemaVersion">): CheckpointA checkpoint for a step (REQ-AUTO-2).
classifyfunctionexport function classify(error: unknown): FailureClassThe class LLD §8.4 assigns to an error.
clearTracerfunctionexport function clearTracer(): void
currentTracerfunctionexport function currentTracer(): Tracer
CustomStepRunnertypealiasexport type CustomStepRunner = (Runs a Tier 0 custom step.
DataErrorclassexport class DataError extends Error
EXITvariableEXIT Non-zero on failed, healed or aborted (REQ-RUN-9, LLD §15).
expandRunsfunctionexport function expandRuns(Which stories run, in which order (REQ-LANG-10, LLD §8.1).
GuardErrorclassexport class GuardError extends ErrorThrown when a guard could not be evaluated (LLD §8.3).
JsonLinesLoggerclassexport class JsonLinesLogger implements LoggerWrites one JSON object per line to a stream. The default.
Loggerinterfaceexport interface Logger
LogLineinterfaceexport interface LogLineJSON-lines logging, and the OpenTelemetry hook (REQ-NFR-5).
MemoryAuditSinkclassexport class MemoryAuditSink implements AuditSinkCollects lines in memory. The runner writes them to audit.jsonl.
messageOffunctionexport function messageOf(error: unknown): string
newRunIdfunctionexport function newRunId(now = new Date(), random = Math.random): stringA lexicographically sortable id, which is what a run directory wants.
NO_TRACERvariableNO_TRACER: Tracer = { startSpan: () => NO_SPAN }The tracer that does nothing, which is the default.
openRunDirectoryfunctionexport function openRunDirectory(outputDir: string, runId: string): RunDirectoryOpen (creating) a run directory.
planResumefunctionexport function planResume(options:Find the checkpoint a --from step resumes out of.
readCheckpointfunctionexport function readCheckpoint(runDir: string, stepId: string): Checkpoint | undefinedRead one step's checkpoint out of a run directory (REQ-AUTO-3, T5.1).
REDACTEDvariableREDACTED = "«redacted»"What a secret becomes wherever it would otherwise be written.
Resolvertypealiasexport type Resolver = (Resolves a target to a live reference. Supplied by the runner (LLD §6.3).
Resumeinterfaceexport interface ResumeWhere a resumed run picks up.
ResumeMismatchErrorclassexport class ResumeMismatchError extends ErrorThe plan or the bindings moved under a checkpoint (LLD §15, exit 12).
ResumeUnavailableErrorclassexport class ResumeUnavailableError extends Error--resume was asked for and the run directory cannot support it.
runfunctionexport async function run(options: RunOptions): Promise<RunOutcome>
RunDirectoryinterfaceexport interface RunDirectory
RunOptionsinterfaceexport interface RunOptions
RunOutcomeinterfaceexport interface RunOutcome
runStepfunctionexport async function runStep(step: Step, context: StepContext): Promise<StepOutcome>
runStoryfunctionexport async function runStory(
Scopeclassexport class Scope
ScopeOptionsinterfaceexport interface ScopeOptions
setTracerfunctionexport function setTracer(next: Tracer): voidRegister a tracer (REQ-NFR-5, "optional OpenTelemetry").
signatureOffunctionexport function signatureOf(story: Story): Signature | undefinedA story's signature, for the runner's own validation.
SILENTvariableSILENT: Logger = { log: () => undefined }Discards everything. What a library-mode caller wants.
Spaninterfaceexport interface SpanA span, as much of OpenTelemetry as the runtime needs to know about.
stackOffunctionexport function stackOf(error: unknown): string | undefined
StepContextinterfaceexport interface StepContext
StepOutcomeinterfaceexport interface StepOutcome
StoryContextinterfaceexport interface StoryContext extends Omit<StepContext, "scope">
StoryOutcomeinterfaceexport interface StoryOutcome
StoryRunnertypealiasexport type StoryRunner = (Runs another story as a function (invoke, REQ-AUTO-5).
summarisefunctionexport function summarise(The totals and the exit code a summary carries (REQ-RUN-9).
Tracerinterfaceexport interface Tracer
verifyResumeHashesfunctionexport function verifyResumeHashes(Refuse a resume whose artifacts have moved (REQ-AUTO-3, LLD §15).