Skip to Content
This documentation is provided with the HEAT environment and is relevant for this HEAT instance only.

Context and inputs

The ctx argument to run(ctx) is built once per run. It carries metadata and handles to the parent node’s output(s). Full bytes load only when you call open*Reader().


ArbexContext fields

FieldUse
apiVersionHost contract version (currently "1.0")
sessionid, projectId, simulationName, template, configuration, nodes[] (no email or display name)
session.nodes[]Every node in the session: instanceId, instanceName, templateName, lastState, statusDetails (truncated)
nodeinstanceId, instanceName, templateName, taskId, configuration (your script and parent settings)
parentResolved parent read block: nodeInstanceName, mode, historyLimit, historyOrder, readerHint, tabularOptions
parentsAll graph parents as { name, templateName, instanceId }[] (metadata only)
inputsLatest or history handles (see below)
systemOperator triage when enabled (default on system-arbex-js). version (platform build), live K8s lists, optional platform config. See system-arbex-js.

Use ctx.node.configuration for thresholds, feature flags, or JMESPath paths defined on the node instance. Use ctx.session.configuration for session-level settings.


ctx.inputs

Controlled by node config parent.mode:

modeFieldBehaviour
latestinputs.latestOne handle or null
historyinputs.historyIterable handles (bounded by parent.historyLimit)

Each handle exposes:

MemberDescription
descriptoroutputId, createdAtUtc, dataPath, contentType, detectedKind, sizeBytes
detectedKindjson, tabular, or binary
openJsonReader()Async; { kind: 'json', root, dispose() }
openTabularReader(opts?)Async; headers + readRow() or async iteration
openBinaryReader()Async; byteLength, base64, contentType, dispose()

Why async: readers fetch and parse parent storage via a C# bridge. Call dispose() when finished. Only one reader should be open per handle at a time.


HEAT_ARBEX guards

After open*Reader(), narrow types before use:

const reader = await item.openJsonReader(); if (!HEAT_ARBEX.isJsonReader(reader)) throw new Error("expected json"); const root = reader.root; await reader.dispose();
GuardWhen
isJsonReader(r)JSON root object or array
isTabularReader(r)CSV/TSV rows
isBinaryReader(r)Raw bytes as base64
isInputHandle(h)Valid handle in history loops

heat helpers (reading data)

APIWhy use it
heat.getPath(obj, "a.b.c")Safe dotted path without throwing
heat.coerceNumber(v, fallback?)Parse numbers from tabular strings
heat.parseIso8601(s)Parse timestamps for timeMs
heat.jmespath.search(expr, data)Query nested JSON from parent roots

Example: latest JSON and session threshold

Reads the latest parent JSON, extracts a subtree with JMESPath, and compares to a session config threshold:

async function run(ctx) { const item = ctx.inputs.latest; if (!item) return { empty: true }; const reader = await item.openJsonReader(); if (!HEAT_ARBEX.isJsonReader(reader)) throw new Error("expected json"); const metrics = heat.jmespath.search("metrics", reader.root); const threshold = heat.getPath(ctx.session.configuration, "alerts.cpuThreshold") ?? 0.8; await reader.dispose(); return { metrics, overThreshold: metrics && typeof metrics === "object" && "cpu" in metrics && metrics.cpu > threshold, }; }

Full sample: latest-json-transform.js.