rlmesh.specs
Public RLMesh-native spec classes backed by the Rust extension.
import rlmesh.specsA contract is the handshake an endpoint hands a client: env id, spaces, render mode, metadata, and
instance count. You read one off a server or client (env_contract); you rarely build one.
SpaceSpec is the wire-safe description of one space. ServeOptions
and Tensor, exported from the top-level package, complete the native
value boundary.
EnvContract
For Gymnasium envs, id comes from env.spec.id and falls back to "UnknownEnv-v1". Spaces come
from observation_space / action_space, or the single_* variants on a vector env.
contract = env.env_contract # from a server or a remote client
print(contract.id, contract.num_envs)
print(contract.observation_space.kind)
payload = contract.to_dict() # JSON-serializable, nested specs included
SpaceSpec
SpaceSpec describes a space on the wire; a Space wrapper is the Python object that samples,
seeds, and validates values from it. Wrap one with
space_from_spec(), or convert it with
to_gymnasium_space() where code expects a
Gymnasium space.
ServeOptions
The constructor is keyword-only; pass the result to EnvServer(..., options=...).
options = rlmesh.ServeOptions(allow_remote_shutdown=True, idle_timeout_seconds=300.0)
server = rlmesh.EnvServer(env, "127.0.0.1:5555", options=options)
The bearer token that gates an endpoint is not a Python ServeOptions field; it is reachable only
from Rust (rlmesh::ServeOptions.token) and C (RlmeshServeOptions.token).
Tensor
Tensor is a validated transport container, not an ndarray: immutable element bytes with shape,
dtype, and strides, plus DLPack and buffer-protocol edges. Compute, slicing, and broadcasting belong to
the frameworks. device is always "cpu" today.
To leave the native boundary, use rlmesh.numpy.asarray() for a
writable NumPy copy (or numpy.from_dlpack(tensor) for a zero-copy read-only view),
rlmesh.torch.as_tensor() for a Torch tensor, or
rlmesh.jax.asarray() for a JAX array.