RFC-0028: The host kind contract, everything the runner asks of a simulator¶
Status: Accepted (the operator, 2026-12-02): steps 1 to 6 are to be built on branch seams,
to merge when baseline-a ends; open questions 1, 2 and 4 as recommended, and question 3 answered
by a trace (section 6). Built: steps 1 to 6 (2026-12-02), merged into main, with the amendments
marked in sections 3, 4 and 6. It designs gap 1 of RFC-0033. The
number was reserved by NXT-D0 §1.
Date: 2026-12-02
Builds on: ADR-0027 decision 1 (a simulator is a host
kind; nothing outside it names Pollen, MuJoCo, Gazebo or ROS),
ADR-0029 (contact and proximity),
RFC-0025 §3.4 (a reset returns when settled), NXT-D0 §1 (the minimal
dispatch), RFC-0033 (register row 5).
Evidence: the code read at 4f68ae8, and the contact block of baseline-a's first 131
result.json files. Nothing was run for this RFC. What is not verified is in section 8.
1. Motivation¶
ADR-0027 decision 1 says the runner names no simulator. Today it does, in five places:
| What | Where | What it knows of the duck's simulator |
|---|---|---|
| The world file | labrunner/scene.py:115 mjcf, called at challenge.py:65 |
MuJoCo XML from Pollen's scene_backlash.xml, through host.scenarios and host.scene_dir |
| Contact | labrunner/contact.py |
the body server's touches op (a Pollen patch); MuJoCo's check of recorded poses, run with host.microduck_rl's python; circle_host decides a host has no physics because it has no Pollen checkout |
| Truth | 22 reads of host.truth_port in the runner, Mission Control and the duck |
one field used both as "this host has a truth" and as a TCP port |
| The camera | labrunner/camera.py:24-81 |
opens the duck's body server (simhost.truth.Body) on that port |
| The payload's independence | challenge.py:98, remote.truth_connections |
counts TCP connections to the truth port, to show the navigator reads no truth |
Gazebo, the simulator of MVP 2 (RFC-0025), would need an edit in each. That is gap 1.
2. What exists¶
simhost.kinds.Kind is five fields: parse, reset, down, truth, simulates. Two kinds
use it: pollen-duck-sim and nxt-kinematic-sim. NXT-D0 §1 refused a base class until a third
kind shows what the kinds share. Gazebo is that third kind and is not built. So this RFC writes
the contract from what the runner asks, not from a third implementation.
3. Proposal: the kind answers everything the runner asks of a simulator¶
The Kind entry grows to the functions below. The runner calls them only through simhost
functions that take the host.
| Function | Returns | Duck (pollen-duck-sim) |
NXT (nxt-kinematic-sim) |
|---|---|---|---|
parse(raw, source) |
the kind's host | as now | as now |
world(host, scene, out) |
the kind's world file for a lab scene, read by shape (section 6, question 1) | mjcf, moved to simhost.duckworld; reads the scene's boxes and floors |
the scene's own scene.json (scene.path); nothing written |
reset(host, world) |
nothing, once a truth sample stamped after the reset is read | as now | as now |
down(host) |
nothing | as now | as now |
has_truth(host) |
true when the kind reads a truth | truth_port set |
true |
truth(host) |
a reader: read() gives (pose, z, quat, sim_time), close() |
Body on the port |
nxt.Truth |
truth_address(host) |
the truth's (host, port), or none | 127.0.0.1, truth_port |
nxt-web's |
contacts(host, sampler, obstacles, floors, checker) |
a contact source, or none | the touches op, else MuJoCo's check | the footprint circle |
checkout(host) |
the simulator's source checkout, whose commit a run's build records, or none | microduck_rl |
none |
socket(host, name) |
the Unix socket of the robot's robot, depth, map, gate or camera, or none (added by the review of the merge) |
the host file's sockets |
none: the robot is reached over TCP |
simulates |
the sensor kinds it makes readings for | as now | as now |
socket has a sibling, require_socket(host, name), for a caller that cannot do without the socket:
it raises a HostError naming the file, the kind and the socket. A caller that can do without
asks socket and handles none: no camera, no zero move.
connections() is not in the table: it is a method of NxtHost (nxt-web and nxt-gate, its
page and its gate's address), read by the NXT's own code, not a function of the kind. The
duck's sockets are the socket row.
A contact source has by (its name: simulator, mujoco, circle), step_s (its time
resolution: 0.005 for the touches op, the sample period for a check of recorded poses), poll
(per truth sample) and finish (per run, with the run's folder). Amended when built (step 3,
2026-12-02): there is no finish. Its only work would be running MuJoCo's checker and reading
its answer, which is evaluating, so the runner does it (labrunner.contact.by_source) with the
command the source carries. The source is simhost.contactsource.Source; step_s 0.005 is the
body server's TIMESTEP (body_server.py:66 in Pollen's checkout).
Rules:
- Nothing outside
simhostreads a kind's fields:truth_port,microduck_rl,scene_dir,scenarios,pollen.scripts/check_boundaries.pyalready reads every file withast. It grows one rule for these attribute names outsidesimhost. Amended after the merge:socketsjoined the list (the review foundhost.sockets["camera"]in the runner, and the NXT's host has none), and so did a call of.as_json()on a host. The navigator's ownsocketsdictionary (duck_lab.nav) and the duck's probes (rule 5) are not flagged forsockets. The check is a lint for honest code, not a wall: it does not catchgetattrwith a variable name,vars(host),attrgetter,asdict, anas_jsonkept as a bound method, or reading the host file's JSON directly, and it does not scanscripts/. - A contact source says what it is.
result.json'scontactrecordsby(it does today) and addsstep_s. A run evaluated by a coarser source says so (ADR-0029). A kind with no source gives no verdict, as a duck host with neither source does today. - The camera reads the pose from
truth(host), not from the duck's body server. - A test-only third kind exercises the contract in the runner's tests. It is neither the duck nor the NXT, so a duck assumption left in the runner fails there first.
- The duck's probes stay the duck's. The 83 scripts in
robots/duck/sim/probesmay use the duck's kind directly; they are not the runner.
4. Order of building¶
Each step comes with its tests first, on branch seams.
has_truthandtruth_addressreplace the 22 reads oftruth_port. This is mechanical, and it is the most callers.world:mjcfmoves into the duck's kind.labrunner.scenekeepsminiview_scene.contacts:contact.py's three sources become two kinds' sources, andcircle_hostgoes.- The camera through
truth(host). - The boundary rule (rule 1) and the test-only kind (rule 4).
- Then RFC-0033 question 4: one RPC client in
runfile, used by the kinds' readers and the runner's clients. Amended when built: the kinds' readers speak no JSON-RPC (Pollen's body server over TCP, the NXT's HTTP), sorunfile.jsonrpc.ClientandStreamserve the three JSON-RPC clients (labrunner.rpc,duck_lab.nav.client,straight.py); the gate's lease refusal moves torobotgate.lease_lost.
5. Alternatives considered¶
- A base class or a
typing.ProtocolforKind. A table of functions already names the contract, and a class adds nothing two kinds need. Revisit with Gazebo. - Kinds as entry-point plugins. Rejected in NXT-D0 §1: every kind lives in this repository.
- Gazebo made to look like Pollen's body server, behind a bridge that speaks its ops. The runner would not change, but every kind would pretend to be MuJoCo: geom names, a touches op, an MJCF world. Rejected.
- Keep contact in the runner, with a branch per kind. This is what exists. A third kind adds a third branch.
6. Open questions (answered 2026-12-02: 1, 2 and 4 as recommended; 3 by a trace)¶
- Does
worldtake theSceneor thescene.jsonpath? Recommended: theScene, validated and versioned (scene_version, RFC-0033 gap 3), and an output folder. Amended when built (step 2, 2026-12-02): the recommendation could not hold. The runfileScenehas rooms, bounds and drops but no floors or boxes, and the duck's MuJoCo world is made of them; they exist only in the challenge scene the runner draws per seed (labrunner.scene.Scene).simhostimports no other package, soworldreads the scene by shape: the duck's needsid,boxesandfloors; the NXT's needspath, its storedscene.json. Adding floors toscene.jsonwould change the Observatory's scene format; it waits until a kind must build a world from a stored scene (Gazebo on the apartment). - Must a kind give a physics-step contact source before its runs count toward a milestone? Recommended: yes. Runs evaluated by a coarser source are recorded and reported apart.
- Who places the robot at the scene's start: the world file or a call after the reset?
Traced 2026-12-02: the duck's body server always starts the duck at the origin facing +x
and takes no position (
simulator.py:4), so the lab moves the world instead: every challenge is drawn in the start's frame, and a probe's start re-frames it (challenges.py:1,:665-678). The NXT takes its host file'sstart(nxt.py:82-85). The answer, for step 2: the start is a pose in the scene's frame. A kind that cannot place the robot (Pollen's body server) is given a scene re-framed so the start is its origin, as the challenges are; a kind that can (nxt-web's--start) takes the start. Corrected 2026-12-02: this answer first said the NXT'sstartleaves its host file. Step 2 showed it cannot: the apartment is one frame shared by its evaluator, Mission Control and the Observatory, so re-drawing it around the NXT's start moves every room and hazard, and astartinscene.jsonis a format change. The NXT'sstartstays in its host file until a scene carries one. - Gazebo's reset and clock. Its
reset allsets simulation time to zero, and the sampler's clock epoch per reset is ADR-0027's unbuilt "clock epoch". Recommended: settle these in the Gazebo kind's own step, with this contract unchanged.
7. Consequences¶
- The runner, the camera and the evaluator stop naming MuJoCo; a third kind adds a
KINDSentry and no runner edit. result.json'scontactgainsstep_s; the run format stays 2 (an added field).- 22 call sites change in step 1, across three projects. The baseline's code does not change
under it: the work is on branch
seams, merged when baseline-a ends.
8. Not verified¶
- Nothing was run. Gazebo is not installed here, and nothing in this RFC was checked against it.
- The 22 reads of
truth_portare counted, not classified one by one into predicate and port. - Whether the NXT kind's runs skip the real-time factor check, given that it has no simulation
time (
simhost/nxt.py:39), was not read. - Whether any probe imports runner code that step 2 or 3 moves was not checked.
- Whether the boundary check's blind spots (rule 1) hide a read today: the check passes, and nothing else was searched for what it cannot see.
- Rule 1's other fields after step 2: six probes read
scenariosto re-reset to a world an earlier run wrote, andrunfile/build.py:97readsmicroduck_rl; steps 3 and 5 take them.