Skip to content

Rulvar API reference


Rulvar API reference / @rulvar/core / createCtx

Function: createCtx()

ts
function createCtx(internals, rootWorkflow?): Ctx<ErrorPolicy>;

Defined in: packages/core/src/engine/ctx.ts:971

Creates the per-run Ctx bound to internals. The current scope travels through AsyncLocalStorage so parallel branches and pipeline stages keep one ctx object while journaling under their own scope paths (I3: structure from call-and-return only).

Parameters

ParameterTypeDescription
internalsRunInternals-
rootWorkflow?{ effort?: Effort; model?: ModelSpec; routing?: Partial&lt;Record&lt;InvocationRole, ModelSpec&gt;&gt;; }The workflow whose body this ctx runs: its defaults become the root scope's layer 3. Absent for a CompiledWorkflow (the sandbox dialect declares no routing), which then contributes no layer, exactly as before.
rootWorkflow.effort?Effort-
rootWorkflow.model?ModelSpec-
rootWorkflow.routing?Partial&lt;Record&lt;InvocationRole, ModelSpec&gt;&gt;-

Returns

Ctx&lt;ErrorPolicy&gt;