Encodes requests and decodes responses for the angelus_motor Port protocol.
Frame format (matching Erlang packet: 4):
[4 bytes big-endian uint32: payload length][payload: UTF-8 JSON]
Elixir opens the Port with packet: 4, so the VM handles the framing
automatically. This module only deals with the JSON payload layer.
Request schema: %{"id" => integer, "op" => string, ...op-specific fields...}
Response schema (success): %{"id" => integer, "ok" => true, "result" => term}
Response schema (error): %{"id" => integer, "ok" => false, "error" => string}
Summary
Functions
Coerces a state result map (string keys from JSON) into an Elixir map
with atom keys and typed values.
Coerces a mathematical point result map into an Elixir map.
Decodes a raw binary response from the worker.
Encodes a body request — a single UTC->ET->state round-trip.
Encodes a clear_kernels request.
Encodes a load_kernels request with explicit paths.
Encodes a mathematical point request.
Encodes a ping request.
Types
@type request_id() :: non_neg_integer()
Functions
@spec coerce_body(map()) :: {:ok, map()} | {:error, :invalid_body_result}
@spec coerce_body(term()) :: {:error, :invalid_body_result}
Coerces a state result map (string keys from JSON) into an Elixir map
with atom keys and typed values.
@spec coerce_point(map()) :: {:ok, map()} | {:error, :invalid_point_result}
@spec coerce_point(term()) :: {:error, :invalid_point_result}
Coerces a mathematical point result map into an Elixir map.
@spec decode(binary()) :: {:ok, request_id(), term()} | {:error, request_id(), term()} | {:error, :decode_error, binary()}
@spec decode(term()) :: {:error, :decode_error, term()}
Decodes a raw binary response from the worker.
Returns {:ok, id, result} or {:error, id, reason}.
Returns {:error, :decode_error, binary} if JSON is malformed.
@spec encode_body(request_id(), String.t(), String.t()) :: binary()
Encodes a body request — a single UTC->ET->state round-trip.
Fields:
target(string) — SPICE target nameutc(string) — ISO8601 datetime
@spec encode_clear_kernels(request_id()) :: binary()
Encodes a clear_kernels request.
@spec encode_load_kernels(request_id(), [String.t()]) :: binary()
Encodes a load_kernels request with explicit paths.
@spec encode_math_point(request_id(), String.t(), String.t()) :: binary()
Encodes a mathematical point request.
@spec encode_ping(request_id()) :: binary()
Encodes a ping request.