1 executor nu
~larandar edited this page 2026-09-09 13:34:00 +02:00

← Home

executor-nu

In-process Nushell embedding. Workflow steps expressed as Nushell evaluate inside the executor's own process — no child shell, no interpreter startup cost — and produce typed values back.

Interface

Engine::new() builds a full Nushell engine state (language commands plus the shell command set). Two entry points:

  • eval(script) — evaluate a script, return a Nushell Value.
  • eval_with_run_context(script, run) — the same, with the run context injected first.

Failures cross the boundary as executor_core::WorkflowError; Nushell ShellErrors are converted at the edge, never leaked.

Run context: $env.TING_RUN

RunContext carries run_id, workflow, step, plus optional extras (arbitrary nested JSON). Before evaluation it is serialized to JSON, converted into a native Nushell record (value::json_to_value preserves field order; unknown JSON variants become strings), and bound as $env.TING_RUN. A step script therefore reads its run identity as ordinary Nushell:

$env.TING_RUN.run_id
$env.TING_RUN.workflow

Linked-stream combinators

The embedded engine keeps the standard Nushell command set intact, so the linked-stream combinators run natively against real pipelines — verified by the crate's own tests:

  • par-each — concurrent per-item evaluation
  • reduce — fold a stream into one value
  • chunks — fixed-size grouping of a stream
  • zip — pair two streams
  • window — sliding windows over a stream

These are the composition primitives workflow steps use for fan-out and aggregation; the crate adds no custom commands of its own.