Behaviour for the raw subprocess transport layer.
In addition to the long-lived subscriber-driven transport API, the transport
layer also owns synchronous non-PTY command execution through run/2.
Subscribers receive tagged events only:
{event_tag, subscriber_pid, {:message, line}}forsubscribe/2{event_tag, ref, {:message, line}}{event_tag, tag, {:data, chunk}}{event_tag, tag, {:error, %ExecutionPlane.Process.Transport.Error{}}}{event_tag, tag, {:stderr, chunk}}{event_tag, tag, {:exit, %ExecutionPlane.ProcessExit{}}}
where tag is the subscriber pid when subscribe/2 is used and an explicit
reference when subscribe/3 is used.
When :replay_stderr_on_subscribe? is enabled at startup, newly attached
subscribers also receive the retained stderr tail immediately after
subscription. When :buffer_events_until_subscribe? is enabled, stdout,
stderr, and error events emitted before the first subscriber attaches are
replayed in order.
Summary
Types
The tagged event atom prefix.
Caller-supplied tag for explicit subscriptions.
Normalized transport event payload extracted from a mailbox message.
Transport events delivered to subscribers.
Mailbox tag carried on tagged delivery.
Generic execution-surface placement kind.
Opaque transport reference.
Functions
Stops the transport.
Returns stable mailbox-delivery metadata for the current transport snapshot.
Closes stdin for EOF-driven CLIs.
Extracts a normalized transport event from a tagged mailbox message.
Extracts a normalized transport event for a matching subscriber tag.
Forces the subprocess down immediately.
Returns the current transport metadata snapshot.
Sends SIGINT to the subprocess.
Runs a one-shot non-PTY command and captures exact stdout, stderr, and exit data.
Sends data to the subprocess stdin.
Starts the default raw transport implementation.
Starts the default raw transport implementation and links it to the caller.
Returns transport connectivity status.
Returns the stderr ring buffer tail.
Subscribes a process using the subscriber pid as the default mailbox tag.
Subscribes a process with an explicit reference tag.
Removes a subscriber.
Types
@type event_tag() :: atom()
The tagged event atom prefix.
@type explicit_subscription_tag() :: reference()
Caller-supplied tag for explicit subscriptions.
@type extracted_event() :: {:message, binary()} | {:data, binary()} | {:error, ExecutionPlane.Process.Transport.Error.t()} | {:stderr, binary()} | {:exit, ExecutionPlane.ProcessExit.t()}
Normalized transport event payload extracted from a mailbox message.
@type message() :: {event_tag(), subscription_tag(), extracted_event()}
Transport events delivered to subscribers.
Mailbox tag carried on tagged delivery.
@type surface_kind() ::
:local_subprocess | :ssh_exec | :guest_bridge | :lower_simulation
Generic execution-surface placement kind.
@type t() :: pid()
Opaque transport reference.
Callbacks
@callback close(t()) :: :ok
@callback end_input(t()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback force_close(t()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback info(t()) :: ExecutionPlane.Process.Transport.Info.t()
@callback interrupt(t()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback run( ExecutionPlane.Command.t(), keyword() ) :: {:ok, ExecutionPlane.Process.Transport.RunResult.t()} | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback send(t(), iodata() | map() | list()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback start(keyword()) :: {:ok, t()} | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback start_link(keyword()) :: {:ok, t()} | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback status(t()) :: :connected | :disconnected | :error
@callback subscribe(t(), pid()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
@callback subscribe(t(), pid(), explicit_subscription_tag()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Functions
@spec close(t()) :: :ok
Stops the transport.
@spec delivery_info(t()) :: ExecutionPlane.Process.Transport.Delivery.t()
Returns stable mailbox-delivery metadata for the current transport snapshot.
@spec end_input(t()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Closes stdin for EOF-driven CLIs.
Pipe-backed transports send :eof; PTY-backed transports send the terminal
EOF byte (Ctrl-D).
@spec extract_event(term()) :: {:ok, extracted_event()} | :error
Extracts a normalized transport event from a tagged mailbox message.
@spec extract_event(term(), subscription_tag()) :: {:ok, extracted_event()} | :error
Extracts a normalized transport event for a matching subscriber tag.
This is the stable core-owned way for adapters to consume tagged transport delivery without hard-coding the configured outer event atom.
@spec force_close(t()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Forces the subprocess down immediately.
@spec info(t()) :: ExecutionPlane.Process.Transport.Info.t()
Returns the current transport metadata snapshot.
@spec interrupt(t()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Sends SIGINT to the subprocess.
@spec run( ExecutionPlane.Command.t(), keyword() ) :: {:ok, ExecutionPlane.Process.Transport.RunResult.t()} | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Runs a one-shot non-PTY command and captures exact stdout, stderr, and exit data.
@spec send(t(), iodata() | map() | list()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Sends data to the subprocess stdin.
@spec start(keyword()) :: {:ok, t()} | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Starts the default raw transport implementation.
@spec start_link(keyword()) :: {:ok, t()} | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Starts the default raw transport implementation and links it to the caller.
@spec status(t()) :: :connected | :disconnected | :error
Returns transport connectivity status.
Returns the stderr ring buffer tail.
@spec subscribe(t(), pid()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Subscribes a process using the subscriber pid as the default mailbox tag.
@spec subscribe(t(), pid(), explicit_subscription_tag()) :: :ok | {:error, {:transport, ExecutionPlane.Process.Transport.Error.t()}}
Subscribes a process with an explicit reference tag.
Removes a subscriber.