This release is a pre-release and may not be stable for production use.
openrois-engine
The recursive RoIS HRI Engine, with its WebSocket server and client.
One Engine class realizes both roles the specification defines. Give it child engines and
it is a main HRI Engine, the gateway that applications connect to. Give it local
components and it is a sub HRI Engine, the adapter that runs next to a robot. Give it
both and it is a middle tier, which is how OpenRoIS composes into a hierarchy without a
second implementation.
The engine answers the RoIS method catalog of
openrois-interfaces, the same 16 methods and 4
notifications at every level. A parent engine reaches a child engine with the requests a
client would send.
Install
Alpha, pre-1.0, unstable API.
pip install openrois-engine
Or from a clone of the repository:
pip install -e ./engine
Components are written with
openrois-components-core:
pip install openrois-components-core
Public API
| Name | Purpose |
|---|---|
Engine |
The recursive HRI Engine: the method catalog, bindings, command sequences and id routing |
Session |
A client of an engine, or its parent engine |
ComponentContract |
Where the components of an engine live, local or behind a child engine |
LocalComponent |
The shape of a component the engine hosts in its process, which Component has |
LocalComponents |
The contract for the components of this process: parameters, commands, status and events |
ChildEngine |
The contract for one child engine, reached over the method catalog |
WsServer |
WebSocket server, for a gateway |
WsClient |
WebSocket client, for an adapter connecting out to a gateway |
The configuration loader lives in openrois.engine.config:
| Name | Purpose |
|---|---|
AdapterConfig |
The settings every adapter has, subclassed with one section per component |
load_adapter_config |
Load an adapter's settings from adapter.yaml, the environment and flags |
load_config |
The loader behind it, generic over the model and the environment prefix, which the gateway uses too |
ConfigError |
Raised for a file that cannot be read or settings that do not validate |
Usage
As an adapter, with a component written with openrois-components-core:
from pydantic import BaseModel
from openrois.engine import Engine, WsClient
from openrois.engine.config import AdapterConfig, load_adapter_config
class NavigationSettings(BaseModel):
speed: float = 0.5
class RobotConfig(AdapterConfig):
engine_id: str = "robot_1"
navigation: NavigationSettings = NavigationSettings()
config = load_adapter_config(RobotConfig)
engine = Engine(config.engine_id)
engine.add_component("navigation", Navigation(config.robot_address, config.navigation))
WsClient(engine, config.gateway_url).run()
The component is served as robot_1/navigation. WsClient opens the resources the
components share, connects the components to their backends, serves the gateway until
Ctrl+C, and then disconnects them and closes the resources.
load_adapter_config reads the settings in four layers, each overriding the one before:
the defaults of the model, the YAML file named by --config or OPENROIS_ADAPTER_CONFIG,
the environment, and the flags. The file is adapter.yaml by convention, never a
profile, because a profile is what rois.system.get_profile returns:
gateway_url: ws://gateway.example.com:8765
engine_id: robot_1
robot_address: http://192.168.0.10:8080
log_level: info
navigation:
speed: 0.8
The environment and the flags set only the four settings every adapter has:
| Setting | Flag | Environment | Default |
|---|---|---|---|
gateway_url |
--gateway-url |
OPENROIS_ADAPTER_GATEWAY_URL |
ws://127.0.0.1:8765 |
engine_id |
--engine-id |
OPENROIS_ADAPTER_ENGINE_ID |
none, the subclass gives one |
robot_address |
--robot-address |
OPENROIS_ADAPTER_ROBOT_ADDRESS |
none |
log_level |
--log-level |
OPENROIS_ADAPTER_LOG_LEVEL |
info |
The component sections come from the file only. A ROS 2 adapter shares one
RclpyExecutor, from openrois.components.core.ros2, among its components. It is a
resource, so the engine opens it before the components connect and closes it after they
disconnect.
As a gateway:
import asyncio
from openrois.engine import Engine, WsServer
async def main() -> None:
engine = Engine("gateway")
server = WsServer(engine)
await engine.start()
# Loopback only by default: the server does not authenticate its peers.
await server.start("127.0.0.1", 8765)
try:
await asyncio.Event().wait()
finally:
await server.stop()
await engine.stop()
asyncio.run(main())
The standalone gateway process, openrois-gateway in services/gateway/,
runs exactly this with configuration and signal handling.
What the Engine Does
- Sessions. A session sends
rois.system.connectbefore anything else, and every other request before it, or afterdisconnect, is answered with ERROR.disconnect, or a connection that closes, releases the binds and subscriptions of the session and aborts every sequence it had running. - Refs and ids. Every ref is
engine_id/name, owned by the engine that hosts the component. The ids an engine assigns, for commands, subscriptions, events, errors and set_parameter commands, start with its engine id too, so every engine in the hierarchy routes them back to their owner, and a service application or an agent can tell where each one came from. Engine ids are unique across the hierarchy. The engine a client calls assigns every command id of anexecuteand returns the sequence with them, and the engines below reuse them. - Conditions. search, bind_any, get_profile, query and subscribe select components
with the CQL2-Text subset of
openrois.interfaces.condition. get_profile lists the child engines as sub profiles, trimmed to the components a condition selects. The condition of a query or a subscribe also gives the arguments of its message, for examplestream_id = 'audio-1'. - Binds.
execute,get_parameterandset_parameterneed a bind from the calling session on every component they name, and answer ERROR without it. An actuation component takes one bind at a time, and a second session gets OUT_OF_RESOURCES. Any other component, one declared without a RoSO function included, takes one bind per session.releasedrops the caller's bind and aborts its commands still running on the component. A parent engine checked the binds before it forwarded a request, so the session of a parent is trusted. Clients therefore connect to the top engine of a hierarchy, which holds the binds for every engine below it. To abort a command on a child engine, the parent sends it astopof the component and then arelease, but only when no other client of the parent still holds the component. - execute. The engine checks the whole sequence before it answers: UNSUPPORTED for a
command no component serves, ERROR for a component the session has not bound, and
BAD_PARAMETER for arguments that do not fit the profile. It then runs the items in
order, waits each
delay_time, and runs the branches of aConcurrentCommandsitem at the same time, each branch in order and each command after its owndelay_time. Each engine sends a child one command at a time, with the delay already waited. A command that ends other than OK stops its branch and the items after it, whose commands complete with ABORT. Every command sends onerois.command.completed, to the session that started it. - Parameters.
set_parameterapplies the values before it replies and then sendsrois.command.completed. A parameter the profile marksread_only, one it does not list, a value that does not fit its type, or values the component's@on_set_parameterhook refuses answer BAD_PARAMETER with no command id, and none of the values is applied. Insideexecute, a hook refusal ends that command with ERROR. - Status and errors. The engine answers
component_statusfor the asking session: BUSY when another session holds an actuation component, UNINITIALIZED until the component's resources are open and it has connected, and WARNING or ERROR as the component or one of its resources raised it, ERROR above WARNING above the lifecycle. Each raise that changes what a component reports sendsrois.system.notify_errorto the sessions with a bind or a subscription on it, andget_error_detailreads itscomponent_ref,status,messageandtimeuntil it clears. A raised ERROR refuses the component's commands and queries and holds back its events.Engine.raise_statusreports an error of the engine itself to every connected session. - Local components. The engine opens the resources the components share, stores the
parameters, filled from the profile defaults, and answers
get_parameteritself. A command not started within the timeout of its profile ends with TIMEOUT. Astop, or a newstart, runs thestophandler and then aborts the runningstart. Events can be emitted from any thread, andget_event_detailreads an event until it expires. An event an emit names argument values for reaches the subscriptions that asked for them. - RoIS_Common. A local component whose profile includes RoISCommon gets
start,stop,suspendandresumeby default. It is started from the moment astartarrives untilstop, or until that start ends other than OK, and astartwithout a handler completes OK at once. On a component not started,suspend,resumeandstopcomplete OK and run no handler, except that astopwhile a cancelledstartstill unwinds cancels it again.suspendholdsstartand every other function command of the component, which wait without starting, directly or in a sequence, and end with TIMEOUT when their profile timeout elapses.set_parameterstill applies at once, a command already running keeps running, and the component's events are dropped untilresume, which releases the held commands.stopends the suspension, and the held commands end with ABORT. A handler adds to this: thesuspendhandler runs after the hold, and theresumehandler before the release. Asuspendthat fails lifts its hold, and aresumethat fails keeps it.component_statusdoes not change while a component is suspended. A gateway forwards the four commands and holds nothing itself.
Transport
WsServer serves child engines and clients on one port:
- A connection on the path
/adapteris a child engine. The server connects to it withrois.system.connect, reads its profile withrois.system.get_profileand adds it to the engine. A child whose profile names an empty or slashed engine id, an engine id already in the hierarchy, or a ref no engine of the child owns, is closed with code 1008 and the reason. A child that sendsrois.system.profile_changedis read again, and a changed profile that breaks these rules closes the child the same way. A reply that assigns an id outside the child's engine ids, or one the child already gave out, counts as ERROR. - A connection on any other path is a client with its own session. When it disconnects, its binds and subscriptions are released and its sequences aborted.
- Each request runs in its own task, so a slow request does not hold up the others, and replies are matched to requests by id. A reply always goes out before the notifications it causes, such as the completion of a set_parameter.
- A message that is not JSON gets PARSE_ERROR, one that is not a JSON-RPC request gets INVALID_REQUEST, a method outside the catalog gets METHOD_NOT_FOUND, params that fail the catalog model get INVALID_PARAMS with the issues as data, and an engine failure gets INTERNAL_ERROR. A notification gets no reply.
child_timeoutsets how long the server waits for a child engine's reply, 10 seconds by default. A request that times out may still take effect on the child: a subscription whose reply comes too late is ended, while a command keeps running.stop()closes every connection with code 1001.
WsClient appends /adapter to the gateway URL, serves the gateway through a trusted
session, and reconnects with a growing delay, also when the gateway refuses it.
Design Constraints
- The engine is transport-neutral and paradigm-neutral. It reaches every component
through the
ComponentContract, so no ROS, DDS, gRPC, or game engine import belongs in this package. ROS 2 nodes are spun byRclpyExecutorinopenrois-components-core, a resource the components share. - Components own their backend connections. The engine holds no shared backend state.
See architecture and the recursive engine for the rationale.
Test
pip install -e ./components/core -e "./engine[dev]"
cd engine && pytest && mypy && ruff check src/ tests/
The tests drive the engine through the JSON-RPC framing in process, and run a real
WsServer on an ephemeral loopback port with adapters, clients and a middle tier
connected over WebSockets.
Status
Alpha, pre-1.0, unstable API. The engine implements the RoIS interfaces, profiles and common messages (CP1 to CP3) as rois-reference §16 records them, without a conformance claim. It does not yet load XML-declared profiles at run time. Re-subscription after an adapter reconnects and health endpoints are planned for Phase 5.
License
Apache-2.0.
Metadata
Release files for openrois-engine 0.1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openrois_engine-0.1.0a2.tar.gz | 78.6 kB | With provenance | Details for openrois_engine-0.1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openrois_engine-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details for openrois_engine-0.1.0a2-py3-none-any.whl |
Total release size: 132.2 kB
Release files / openrois_engine-0.1.0a2.tar.gz
| Download URL | openrois_engine-0.1.0a2.tar.gz |
|---|---|
| Size | 78.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
596153bc6e65ecb8ba9891262706a97e9d36a36d85b02c44eb8ef517f8fd0a2e
|
|
BLAKE2b-256 checksum How to use checksums |
5aa87d8addb26f7b8ce0c7035bf53f4530ca39ed5b93d64a762798436005725b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / openrois_engine-0.1.0a2-py3-none-any.whl
| Download URL | openrois_engine-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 53.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b36728d90596a02fd0e762e5becca7a12d4d0574bdd33d216896b3c89437eff
|
|
BLAKE2b-256 checksum How to use checksums |
ac31cabde9bf7eb1f1677c771bab4c57df10b28f46211ba22d2f8ac793bf7073
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for openrois-engine 0.1.0a2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for openrois_engine-0.1.0a2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.