---
title: Process
description: Ports, terminal outcomes, settings and qualification evidence for
  the Process connector.
url: https://docs.rastok.com/reference/connectors/process
source_revision: v0.2.0-alpha
---

# Process

`std/process@1`. `job` starts one child per Call and publishes its ordered frames with the exit. `service` opens a resident child per Node instance on first input and reuses it. One exit ends that child, not each application request.

## Declaration

This declaration comes from `examples/echo.rkg`. Place the Connector in a Graph
and wire its ports; the excerpt alone is not an App.

```rkg
connector shell : Process {
  mode = job ; command = "cat"
  codec = lines
  idempotent = true; behavior = deterministic
  timeout = duration("5s")
}
```

The [contract index](/reference/contracts.md) explains shared settings, build features
and the distinction between a Contract, a Lab model and an installed Driver.

Selector: `mode` defaults to `job`.

In `job` mode, Calls on one instance are serialized and [queue time counts toward `timeout`](/reference/execution.md#instances-own-state-not-threads); `service` uses a Session instead.

| Mode | Driver direction | Exchange | Lab model | Installed in this binary |
|---|---|---|---|---|
| `job` | outbound | call | `lab-call` | `process-job` |
| `service` | inbound+outbound | session | `lab-process-service` | `process-service` |

## Ports and completion

| Mode | Port | Direction | Type rule |
|---|---|---|---|
| job, service | `in` | input | `codec = lines` → `string`; `codec = jsonl` → `variant`; `codec = bytes` → `array<byte>` |
| job, service | `out` | output | `codec = lines` → `string`; `codec = jsonl` → `variant`; `codec = bytes` → `array<byte>` |
| job, service | `err` | output | `err_codec = lines` → `string`; `err_codec = bytes` → `array<byte>` |
| job, service | `exit` | output | ProcessExit, below |

| Mode | Output cardinality |
|---|---|
| job | `err`: zero or more; `out`: zero or more; exactly one final `exit` per Call |
| service | Zero or more frames and writes; exactly one `exit` per Session |

## Exit union

| Case | Payload | Call visibility |
|---|---|---|
| `CaptureFailed` | Empty | outcome_unknown |
| `DecodeFailed` | `{ line: string?, message: string }` | outcome_unknown |
| `Exited` | `{ exit_code: int, signal: int? }` | after_effect |
| `OutcomeUnknown` | Empty | outcome_unknown |
| `OutputOverflow` | `{ limit: ulong, reason: enum { Budget, Capacity } }` | outcome_unknown |
| `SpawnFailed` | `{ message: string }` | before_effect |
| `TimeoutExpired` | Empty | outcome_unknown |

## Settings

With `codec = jsonl`, `rastok check` refuses a producer whose resolved type
contains a [value without a JSON form](/reference/types.md#json-request-values), using
`E-TYPE-INVALID`. A `variant` producer is checked at execution instead; an
unencodable request produces `DecodeFailed` before its frame is written.
In `service` mode, an unencodable request closes the Session.

| Mode | Setting | Domain | Presence / default | Latest phase |
|---|---|---|---|---|
| job, service | `args` | `array<string>` | `[]` | instance |
| job, service | `behavior` | `deterministic \| probabilistic` | required | plan |
| job, service | `codec` | `bytes \| jsonl \| lines` | required | plan |
| job, service | `err_codec` | `bytes \| lines` | `lines` | plan |
| job, service | `command` | `string` | required | instance |
| job, service | `cwd` | `string` | optional | instance |
| job, service | `env` | `map<string,string>` | optional | instance |
| job | `idempotent` | `bool` | `false` | plan |
| job | `timeout` | `duration` | optional | instance |
| job | `max_output` | `ByteSize` | `"8MiB"` | plan |
| job | `on_timeout` | `kill` | `kill` | plan |
| service | `max_frame` | `ByteSize` | `"1MiB"` | plan |

The shared catalogue lists framing choices for both modes; service validation further restricts `codec` to `lines | jsonl` and `err_codec` to `lines`. Service has no per-turn timeout or idempotence setting. Its mock supports input-driven `match` responses and an optional terminal; delayed/unsolicited mock frames, `now()` in Session mocks and system-close acknowledgements are not scripted. Physical unsolicited output is supported. Job mocks retain the ordinary Call timeout and terminal rules.

## Qualification inventory

`job`: fixture `crates/rastok/tests/conformance_process.rs`. Cases without a portable forced fixture: `CaptureFailed`, `OutcomeUnknown`. Related tests: `crates/rastok/tests/process_service.rs`, `crates/rastok/src/connector/drivers/process/mod.rs`.

`service`: No dedicated full-Contract fixture is declared. Related tests: `crates/rastok/tests/process_service.rs`, `crates/rastok/src/connector/drivers/process/mod.rs`.
