diff --git a/plugins/robot-md/.claude-plugin/plugin.json b/plugins/robot-md/.claude-plugin/plugin.json index 87bca04..96ea158 100644 --- a/plugins/robot-md/.claude-plugin/plugin.json +++ b/plugins/robot-md/.claude-plugin/plugin.json @@ -1,8 +1,8 @@ { "name": "robot-md", "displayName": "robot-md", - "version": "0.6.1", - "description": "Connect a robot to Claude through its ROBOT.md: read capabilities and safety limits, drive it through the robot-md MCP server, keep AI-driven motion behind a gate and test its limits with Bounded Embodiment, and manage its identity, keys and EU AI Act evidence at the Robot Registry Foundation. Requires `pip install 'robot-md[hardware]'`.", + "version": "0.7.0", + "description": "Connect a robot to Claude through its ROBOT.md: read capabilities and safety limits, route any motion through robot-md-gateway, keep AI-driven motion behind a gate and test its limits with Bounded Embodiment, and manage its identity, keys and EU AI Act evidence at the Robot Registry Foundation. Requires robot-md 2.0.1 or newer (`pip install 'robot-md[hardware]>=2.0.1'`); the MCP server's launcher refuses an older robot-md.", "author": { "name": "Robot Registry Foundation", "email": "craigm26@gmail.com", diff --git a/plugins/robot-md/README.md b/plugins/robot-md/README.md index 10a2a5d..9a19d48 100644 --- a/plugins/robot-md/README.md +++ b/plugins/robot-md/README.md @@ -8,7 +8,7 @@ The robot-md plugin connects a robot to Claude through the `ROBOT.md` at the roo | `bounded-embodiment` skill | Keeps AI-driven motion behind a gate, drafts envelopes, rehearses EV-03 and EV-10 in simulation, reads verdicts honestly | [plugins/bounded-embodiment](../bounded-embodiment/skills/bounded-embodiment) | | `rrf-registry` skill | Registers the robot, rotates and revokes keys, proves manufacturer identity, emits and submits EU AI Act evidence | this plugin | | `/robot-md:enable-dispatch` | Writes dispatcher config and bearer tokens without printing the token into the conversation | [robot-md-mcp](https://github.com/RobotRegistryFoundation/robot-md-mcp/tree/main/commands) | -| `robot-md` MCP server | Manifest reads plus motion (`execute_task`, `execute_capability`, `vision_find`, `estop`). `scripts/start-mcp-server.py` finds your installed `robot-md` CLI and runs `robot-md mcp` | [robot-md](https://github.com/RobotRegistryFoundation/robot-md) (PyPI) | +| `robot-md` MCP server | Manifest reads, read-only perception (`vision_find`; the camera stays closed unless `ROBOT_MD_MCP_OPEN_CAMERA=1`), and motion tools (`execute_task`, `execute_capability`, `estop`) that send only to robot-md-gateway and refuse without one. `scripts/start-mcp-server.py` finds your installed `robot-md` CLI, refuses one older than 2.0.1, and runs `robot-md mcp` | [robot-md](https://github.com/RobotRegistryFoundation/robot-md) (PyPI) | ## Install @@ -16,10 +16,10 @@ The robot-md plugin connects a robot to Claude through the `ROBOT.md` at the roo /plugin install robot-md --marketplace RobotRegistryFoundation/claude-code-plugins ``` -Then install the CLI the MCP server runs on: +Then install the CLI the MCP server runs on. It needs robot-md 2.0.1 or newer, and the launcher refuses to start an older one. In robot-md 1.x, the MCP server's motion tools move the arm from inside the server process instead of sending to robot-md-gateway. robot-md 2.0.0 sends motion to the gateway, but its MCP server doesn't refuse a motion gated on a scope such as `destructive` or `system`, which is how the so-arm101 preset gates the arm. If pip finds no 2.0.1, it isn't released yet. ```bash -python3 -m pip install --user 'robot-md[hardware]' +python3 -m pip install --user 'robot-md[hardware]>=2.0.1' ``` Launch Claude Code from a directory with a `ROBOT.md` at its root. If you don't have one, ask Claude to set the robot up; the `using-robot-md` skill walks through `robot-md init`. diff --git a/plugins/robot-md/scripts/start-mcp-server.py b/plugins/robot-md/scripts/start-mcp-server.py index 42c0d51..8611ac7 100644 --- a/plugins/robot-md/scripts/start-mcp-server.py +++ b/plugins/robot-md/scripts/start-mcp-server.py @@ -3,27 +3,111 @@ The plugin's .mcp.json runs this file with python3 instead of calling the `robot-md` command directly, so the plugin directory's checks can read exactly what the server command does: find the `robot-md` CLI the user -installed (`pip install 'robot-md[hardware]'`) and run `robot-md mcp` -with this process's stdin and stdout. Nothing is downloaded or installed. +installed (`pip install 'robot-md[hardware]'`), check its version, and run +`robot-md mcp` with this process's stdin and stdout. Nothing is downloaded +or installed. + +The version check is a safety check. In robot-md 1.x, the MCP server's +motion tools (`execute_capability`, `execute_task`) move the arm from inside +the server process, and their gate accepts any non-empty token, which the +model can supply. robot-md 2.0.0 sends every step to robot-md-gateway, but +its gate check matches a gate only against a capability's family or name, +so a gate on a scope such as `destructive` or `system`, which is how the +so-arm101 preset gates the arm, refuses nothing: a gated motion is sent and +runs. From robot-md 2.0.1 a gate that needs a person refuses every motion +(RobotRegistryFoundation/robot-md#121), which is what this plugin's skill +and description say. So the launcher refuses to start an older server +rather than let the plugin's text describe a server that isn't running. """ import os +import re import shutil import subprocess import sys +# The first robot-md release whose MCP motion tools go only through +# robot-md-gateway and refuse every motion under a gate that needs a person. +MIN_ROBOT_MD = (2, 0, 1) + INSTALL_HINT = ( "robot-md MCP server: the `robot-md` command was not found on PATH.\n" - "Install it with: python3 -m pip install --user 'robot-md[hardware]'\n" - "then restart Claude Code. Docs: https://docs.robotmd.dev/mcp/\n" + "Install it with: python3 -m pip install --user 'robot-md[hardware]>=2.0.1'\n" + "If pip finds no 2.0.1, it isn't released yet, and this plugin's MCP server\n" + "can't start until it is. Then restart Claude Code.\n" + "Docs: https://docs.robotmd.dev/mcp/\n" ) +# The whole first line of `robot-md --version`, e.g. "robot-md 2.0.1". A +# pre-release (2.0.1rc1, 2.0.1.dev3) or any other text doesn't match, so it +# is refused: PEP 440 puts a pre-release before the release it leads to. +VERSION_LINE = re.compile(r"robot-md (\d+)\.(\d+)\.(\d+)(?:\.post\d+)?") + + +def installed_version(exe: str): + """Return (version, problem). + + version is the (major, minor, patch) that `robot-md --version` prints, or + None; problem says why it is None. + """ + try: + result = subprocess.run( + [exe, "--version"], capture_output=True, text=True, timeout=30 + ) + except subprocess.TimeoutExpired: + return None, "`robot-md --version` did not answer within 30 s" + except (OSError, subprocess.SubprocessError) as exc: + return None, f"`robot-md --version` could not run ({exc})" + if result.returncode != 0: + return None, f"`robot-md --version` exited {result.returncode}" + lines = (result.stdout or "").strip().splitlines() + match = VERSION_LINE.fullmatch(lines[0].strip()) if lines else None + if match is None: + shown = lines[0].strip()[:80] if lines else "nothing" + return None, f"`robot-md --version` printed {shown!r}, not a release version" + return tuple(int(part) for part in match.groups()), None + + +def refusal_message(found, problem) -> str: + want = ".".join(str(part) for part in MIN_ROBOT_MD) + if found is None: + return ( + f"robot-md MCP server: this plugin needs robot-md {want} or newer, and {problem}.\n" + "Reinstall robot-md, then restart Claude Code. Docs: https://docs.robotmd.dev/mcp/\n" + ) + seen = ".".join(str(part) for part in found) + if found < (2, 0, 0): + why = ( + "In robot-md 1.x the MCP server's motion tools move the arm from inside the\n" + "server process, past robot-md-gateway.\n" + ) + else: + why = ( + f"robot-md {seen} sends motion through robot-md-gateway, but its MCP server\n" + "doesn't refuse a motion gated on a scope such as `destructive` or `system`,\n" + "which is how the so-arm101 preset gates the arm.\n" + ) + return ( + f"robot-md MCP server: this plugin needs robot-md {want} or newer, and found {seen}.\n" + + why + + f"From robot-md {want} every motion goes through the gateway, and a gate that\n" + "needs a person refuses it, which is what this plugin's skill tells Claude.\n" + f"Upgrade with: python3 -m pip install --user --upgrade 'robot-md[hardware]>={want}'\n" + f"If pip finds no {want}, it isn't released yet, and this plugin's MCP server\n" + "can't start until it is. Then restart Claude Code.\n" + "Docs: https://docs.robotmd.dev/mcp/\n" + ) + def main() -> int: exe = shutil.which("robot-md") if exe is None: sys.stderr.write(INSTALL_HINT) return 1 + found, problem = installed_version(exe) + if found is None or found < MIN_ROBOT_MD: + sys.stderr.write(refusal_message(found, problem)) + return 1 argv = [exe, "mcp", *sys.argv[1:]] if os.name == "nt": # os.execv on Windows starts a new process and exits this one, diff --git a/plugins/robot-md/skills/using-robot-md/SKILL.md b/plugins/robot-md/skills/using-robot-md/SKILL.md index f034414..9691bac 100644 --- a/plugins/robot-md/skills/using-robot-md/SKILL.md +++ b/plugins/robot-md/skills/using-robot-md/SKILL.md @@ -1,47 +1,76 @@ --- name: using-robot-md -description: Use when the user wants to install, configure, or operate robot-md — cold install on a fresh Pi, or post-install operation (asking what the robot can do, whether something is safe, validating/rendering/registering the manifest, posing or calibrating). Triggers on robot-md install + any mention of the robot's capabilities/drivers/safety/manifest tooling. +description: Use when the user wants to install, configure, or operate robot-md — cold install on a fresh Pi, or post-install operation (asking what the robot can do, whether something is safe, validating/rendering/registering the manifest, posing or calibrating, moving the robot through robot-md-gateway). Triggers on robot-md install + any mention of the robot's capabilities/drivers/safety/manifest tooling. --- # Using robot-md +## Motion: the gateway decides, and a person is at the machine + +Read this before anything that can move the robot. These rules hold in every section below. + +1. **Motion goes only through robot-md-gateway.** `execute_capability` and `execute_task` send each step to the gateway (`POST /v1/invoke`). The gateway checks the credential's tier, the tool allowlist, the scope, the manifest and its own safety state; the actuator behind it bounds and paces the motion; the gateway records each decision. Nothing in this session writes to the robot. Never write to the servo port (`/dev/ttyACM*`, `/dev/ttyUSB*`), never run a command or script that opens it, and never start, stop or restart the gateway or any other service that drives actuators. Never send to the gateway's `/v1/invoke` yourself, with `robot-md invoke`, `curl` or a script: those calls go around this server's stop latch, its one-motion-at-a-time rule and its gate check. If the motion tools say no gateway is configured or reachable, report that and stop; don't look for another route. `gateway_redirect` means something in front of the gateway tried to send the request elsewhere, and this server refused: report it as given, and never point this server at the redirect's target, which would hand that address the gateway token. +2. **A person at the machine, with a hardware stop, comes before any motion.** Before the first motion of a session, ask the person to confirm all of these: they are at the machine and will watch every motion; nobody else is within its reach; a hardware stop that depends on no software (a relay on servo power, an e-stop button, the power plug) is within their reach. If they can't confirm all three, don't call a motion tool. The `estop` tool is a software stop, not that hardware stop. +3. **A chat "yes" is never authorization for motion.** Asking "shall I?" and getting "yes" authorizes nothing. There is no token to pass: the motion tools no longer take a `confirm_token`, and nothing you write can stand in for a person's confirmation. The gateway decides, against credentials the person controls. The person's confirmation in rule 2 is a precondition you check, not a permission you hold; don't tell them their answer made a motion allowed or safe. +4. **Gated motion is refused.** A `hitl_gates[]` entry needs a person's confirmation from outside this conversation unless it says `require_auth: false`, and robot-md has no path for that confirmation yet. So any such gate makes the motion tools refuse every capability that moves (`hitl_gate`), dry runs included, whatever scope it names: the gateway's names, such as `destructive` and `system`, a capability's prefix, such as `arm`, or a name the gateway doesn't know. The one exception is a gate on `commission`, which covers no motion. Reads still go. The so-arm101 preset gates `destructive` and `system`, so on a manifest made from it every motion is refused for now. Tell the person. Don't edit the manifest to remove or loosen the gate. +5. **Refusals stand.** When the gateway refuses (`status: denied`), report its `deny` and `reason` as given. Don't relabel the scope, split the motion into smaller ones, retry, or reach for another tool to get past it. A motion that ends `gateway_no_answer` or `gateway_unknown_outcome` may have run: tell the person, and don't resend it. A stop that isn't confirmed falls under rule 6. `status: ok` means the gateway ran the call, not that the arm arrived: read the telemetry's `reached`, which is false when a stop interrupted the motion (`stopped_by_estop: true`). `execute_task` stops at a step that didn't reach (`status: not_reached`). Pass on any `warnings` a result carries, as given. +6. **Stops.** `estop` latches this MCP server and sends the gateway's declared stop (`arm.estop`). The arm then holds its pose in software; that is not a hardware e-stop. If `estop` reports `stop_not_confirmed` or returns an error, the stop was not confirmed: tell the person to use the hardware stop now. **Never call `estop_clear` to resume on your own**; it refuses and sends nothing anyway. Clearing a stop makes the robot movable again. It needs a commission-tier credential, which belongs to the person at the machine; the person clears it. After a robot-md-gateway trip, the gateway needs its own clear as well as the arm's. This MCP server keeps refusing motion after any `estop` until it restarts: once the stop is cleared, the person restarts this MCP server (`/mcp` → `robot-md` → Reconnect). +7. **Test runs are started by the person, never by you.** That covers Bounded Embodiment EV runs (`be run`, `be goto-start`, `be doctor --port`), `robot-md trial start` and every `robot-md trial iteration`, hardware-in-the-loop test suites, and calibration that moves the arm. You prepare the commands; the person runs them and types the confirmations. + +Never read or print `bearers.yaml` or a gateway token into this conversation, and don't print the environment (`env`, `printenv`): the person may have put the token there for the MCP server. The MCP server reads its own credential; tool results name where it came from, never what it is. + +### How this skill relates to the bounded-embodiment skill + +The [bounded-embodiment](https://github.com/RobotRegistryFoundation/claude-code-plugins/tree/main/plugins/bounded-embodiment) skill covers test runs and gate work: building or changing a gate, declaring an envelope, rehearsing EV-03 and EV-10, and preparing hardware runs. The two skills agree on everything above: motion only through the gate, a person at the machine with a hardware stop, no chat "yes" as authorization, no stop cleared by you, and test runs started by the person. + +Its motion rule is stricter than this one. It says you never start motion on real hardware by any route, a project's own gated motion tools included, and it applies whenever `execute_capability` is in use, not only during test runs. So when the bounded-embodiment skill is in your session, you call no motion tool on real hardware: you prepare each command and the person runs it. This skill's rules for calling `execute_capability` and `execute_task` apply only when it isn't there. Wherever the two differ, or you can't tell which applies, follow the stricter rule. + +--- + ## First-time setup recipe -If you're seeing this on first plugin load, the operator has just installed the plugin and wants to wire up their robot. Run these commands in a terminal: +If you're seeing this on first plugin load, the operator has just installed the plugin and wants to wire up their robot. These are the commands, in order. Steps 1 and 4 touch no actuator. Step 2 opens every serial port to look for servos, opens the camera and, at a terminal, runs a calibration that moves each joint; step 3 installs and starts the gateway service, which takes the robot's servo port. So the person runs both at the machine: ```bash # 1) Install robot-md from PyPI. On Pi OS Bookworm+ you need --break-system-packages. -python3 -m pip install --user --break-system-packages robot-md +# The plugin's MCP server needs robot-md 2.0.1 or newer. If pip finds no +# 2.0.1, it isn't released yet, and the MCP server can't start until it is. +python3 -m pip install --user --break-system-packages 'robot-md>=2.0.1' -# 2) Initialize a manifest. Replace + email; the preset is so-arm101 by default. +# 2) Initialize a manifest (the person runs this: it opens the serial ports to +# find the servos, opens the camera, and can move each joint to calibrate it). Replace + email; the preset is so-arm101 by default. robot-md init --preset so-arm101 --register --contact-email you@example.com -# 3) (Optional, but required for actual motion) Install the enforcement gateway. +# 3) Install the enforcement gateway (the person runs this). Motion goes only +# through it: without it, the MCP motion tools refuse. robot-md install-gateway -# 4) Health check. -robot-md doctor +# 4) Health check (--hardware off keeps it away from the servo port). +robot-md doctor --path /ROBOT.md --hardware off ``` Each step should take ~30 s. Total cold-install time on a fresh Pi: under 2 minutes. +The MCP server sends to `http://127.0.0.1:8080`, where `robot-md install-gateway` puts the gateway; `ROBOT_MD_GATEWAY_URL` in the MCP server's environment overrides it. The server also needs the gateway's actuate-tier token, and it can't read `/etc/robot-md-gateway/bearers.yaml`, which `install-gateway` keeps readable only by the gateway's own user. So the person starts Claude Code with the token in `ROBOT_MD_GATEWAY_BEARER`, or with `ROBOT_MD_BEARERS_FILE` naming a bearers file of their own. The token never goes in the chat. + ### When something errors Paste the error message back and we'll find the workaround. Common ones today: - **PEP 668 `externally-managed-environment`** → `pip install` needs `--break-system-packages` on Pi OS. The robot-md CLI handles this automatically inside `init`, but the first `pip install` step is operator-driven. - **`claude mcp list` shows "Failed to connect"** → either you haven't `cd`'d into a directory with a `ROBOT.md`, or `ROBOT_MD_PATH` isn't set. Try `export ROBOT_MD_PATH=$HOME//ROBOT.md`. -- **`/dev/ttyACM0` permission denied** → the gateway claims the device by design. Talk to the gateway at `127.0.0.1:8080`, not the device directly. +- **`/dev/ttyACM0` permission denied** → the gateway claims the device by design. Motion goes through the MCP tools, which reach the gateway; never open the device yourself. +- **`gateway_not_configured`** from a motion tool → no gateway bearer was found. See "Motion intent without a gateway" below. ### After install -Once `robot-md doctor` returns 0 fails, you're ready for the first prompt: try "what's the state of the robot?" — the MCP should answer from frontmatter resources without any motion. The remainder of this skill covers ongoing operation of the manifest. +Once that doctor run returns 0 fails, you're ready for the first prompt: try "what's the state of the robot?" — the MCP should answer from frontmatter resources without any motion. The remainder of this skill covers ongoing operation of the manifest. --- ## Overview -This project has a `ROBOT.md` at its root — a single-file declaration of what the robot IS and what it CAN DO. `robot-md` is the CLI that reads, validates, renders, diagnoses, calibrates, and registers that file. It also ships an MCP server (registered as `robot-md`) that exposes the file to this agent session as resources. +This project has a `ROBOT.md` at its root — a single-file declaration of what the robot IS and what it CAN DO. `robot-md` is the CLI that reads, validates, renders, diagnoses, calibrates, and registers that file. It also ships an MCP server (registered as `robot-md`) that exposes the file to this agent session as resources, and whose motion tools send to robot-md-gateway. **Core principle:** `ROBOT.md` is authoritative. Never guess what the robot can do or how it's configured. Read the manifest. @@ -55,7 +84,7 @@ digraph when_to_use { "Operator asks for motion?" [shape=diamond]; "Is there a ROBOT.md?" [shape=diamond]; "Use this skill" [shape=box style=filled fillcolor=lightgreen]; - "Check safety first" [shape=box style=filled fillcolor=orange]; + "Motion rules first" [shape=box style=filled fillcolor=orange]; "Suggest: robot-md init" [shape=box]; "Not a robot task" [shape=box]; @@ -64,7 +93,7 @@ digraph when_to_use { "Is there a ROBOT.md?" -> "Use this skill" [label="yes"]; "Is there a ROBOT.md?" -> "Suggest: robot-md init" [label="no"]; "Use this skill" -> "Operator asks for motion?"; - "Operator asks for motion?" -> "Check safety first" [label="yes"]; + "Operator asks for motion?" -> "Motion rules first" [label="yes"]; } ``` @@ -76,14 +105,17 @@ digraph when_to_use { | "What's it called?" / "what's the RRN?" | Read `robot-md:///identity` (MCP) | | "Brief me on this robot" / "give me the full context" | Read `robot-md:///context` (MCP) | | "What are the safety gates?" / "is it safe to X?" | Read `robot-md:///safety` (MCP). **Before any motion, always.** | -| "Pick up X" / "move to Y" / any physical motion | Read `safety` FIRST. If scope matches a gate with `require_auth: true`, pause and ask the operator to authorize. | -| "Something's wrong" / "it won't respond" | Run `robot-md doctor --path ROBOT.md` from Bash | +| "Pick up X" / "move to Y" / any physical motion | Follow the motion rules at the top. If the bounded-embodiment skill is in your session, or the manifest has a gate that refuses motion (rule 4), prepare the steps and hand them to the person. Otherwise read `safety`, confirm the person is at the machine with a hardware stop in reach, then call `execute_capability`, which sends it to the gateway. Report the gateway's answer as given. | +| "Stop!" / "e-stop" | Call `estop` at once. If it reports `stop_not_confirmed` or returns an error, tell the person to use the hardware stop now. | +| "Resume" / "clear the stop" | The person clears it with their own commission-tier credential: `arm.estop.clear` at the commission tier, plus the gateway's own clear after a gateway trip. Then they reconnect this MCP server (`/mcp` → `robot-md` → Reconnect). Don't call `estop_clear`: it refuses and sends nothing. | +| "Something's wrong" / "it won't respond" | Run `robot-md doctor --path ROBOT.md --hardware off` from Bash. Keep `--hardware off`: with `--path` and no flag, doctor opens the servo port and reads every servo when one is connected. | | "Is the manifest valid?" / "did I break it?" | Call MCP tool `validate`, or run `robot-md validate ROBOT.md` | | "Quick-check" / "is everything OK" | Call MCP tool `doctor_summary` (manifest-only, fast) | | "Give me just the YAML" / "dump config" | Call MCP tool `render`, or `robot-md render ROBOT.md` | -| "Set up a new ROBOT.md" (none exists) | `robot-md init --preset --register --manufacturer <...> --contact-email <...>`. See `docs/getting-started-claude-code.md` in the robot-md repo. | -| "Pose the arm at zero" / "calibrate zero" | `robot-md calibrate --zero ROBOT.md`. Relay interactive prompts to the operator. | -| "Calibrate the hand-eye" / "solve the camera extrinsic" | `robot-md calibrate --hand-eye --marker-pos x,y,z ROBOT.md` | +| "Set up a new ROBOT.md" (none exists) | Give the person `robot-md init --preset --register --manufacturer <...> --contact-email <...>` to run at the machine: it opens every serial port to look for servos and opens the camera, and at a terminal it can move each joint to calibrate it. See `docs/getting-started-claude-code.md` in the robot-md repo. | +| "Pose the arm at zero" / "calibrate zero" | Give the person `robot-md calibrate --zero ROBOT.md` to run at the machine. It opens the servo port directly, so it's theirs to run, not yours. | +| "Calibrate the hand-eye" / "solve the camera extrinsic" | Give the person `robot-md calibrate --extrinsic ROBOT.md` (`--hand-eye` is its deprecated name). It moves the arm through calibration poses directly on the servo bus: the person runs it at the machine. | +| "Teach a pose" / "record where the arm is" | Give the person the `robot-md pose teach` command to run at the machine. It releases the servos' torque, so the arm goes limp. | | "Publish my robot" / "give it a public URL" | `robot-md publish-discovery ROBOT.md --url ` | | "Register this robot" / "get an RRN" | `robot-md register ROBOT.md` (defaults read from the manifest). See **Registration** below for the confirm-first flow. | | "Unregister" / "take it down" | `robot-md unregister ` — confirm with operator first (destructive). | @@ -119,37 +151,39 @@ This signs the body with the local key under `~/.robot-md/keys/` (RCAN protocol 4. On any field-missing error, collect the specific value from the operator and retry with the matching flag rather than guessing. 5. On success, re-read `robot-md:///frontmatter` (the MCP server re-reads the file on every call, so the new RRN is visible immediately). Read the RRN back to the operator and share the public URL. +Registration moves nothing, so a confirmation in chat is enough for it. That is not true of motion: see the motion rules at the top. + ### When NOT to register - Dry-run or rehearsal manifests — pass `--dry-run` to sign + print without POSTing. - Manifests that fail `validate` — fix schema issues first. - Anything the operator hasn't explicitly approved. -## Motion intent without motion tools +## Motion intent without a gateway -If the operator requests physical motion or perception (any of `arm.*`, `nav.*`, `gripper.*`, `perceive.*` capabilities, or English phrasing like "find / move / grasp / place / pick up / put / look / see / detect / scan"), AND the `execute_task` tool is NOT in your available tools, **stop before issuing any action**. Output the upgrade instructions verbatim: +If the operator requests physical motion or perception (any of `arm.*`, `nav.*`, `gripper.*`, `perceive.*` capabilities, or English phrasing like "find / move / grasp / place / pick up / put / look / see / detect / scan") and the motion tools answer `gateway_not_configured` or `gateway_unreachable`, or `execute_capability` is not in your available tools, **stop before issuing any action**. Tell the operator: -> "This robot's manifest declares motion capabilities, but the runtime isn't installed in this environment. To enable motion: +> "Motion on this robot goes only through robot-md-gateway, and this session can't reach one. To set it up: > -> 1. `pip install 'robot-md[hardware]'` -> 2. (Verify with `which robot-md` first to make sure it's on your shell PATH.) -> 3. In Claude Code: `/mcp` → arrow to `robot-md` → Reconnect. +> 1. On the robot, run `robot-md install-gateway` yourself (it installs the gateway and starts its service, which takes the servo port). +> 2. Give the MCP server the gateway's actuate token. It can't read the gateway's own `bearers.yaml`, so start Claude Code with the token in `ROBOT_MD_GATEWAY_BEARER`, or with `ROBOT_MD_BEARERS_FILE` naming a bearers file of your own. Don't paste the token into this chat. +> 3. If Claude Code already started that way, `/mcp` → arrow to `robot-md` → Reconnect is enough. > > Then ask me again." -Wait for the operator to confirm. Do NOT attempt manifest reads as a substitute for motion. Do NOT attempt motion via wrong tools. +Wait for the operator to confirm. Do NOT attempt manifest reads as a substitute for motion. Do NOT attempt motion by any other route: no scripts, no serial access, no other tools. **False-positive guard:** Documentation lookups ("find docs", "find the file", "find the README") are NOT motion intent — proceed normally with manifest tools. ## Safety Protocol -**Before ANY physical motion — no exceptions:** +**Before ANY physical motion — no exceptions** (the motion rules at the top, as a checklist): 1. Read `robot-md:///safety` (MCP) or parse `safety:` from the manifest. -2. Scan `hitl_gates[]`. Does the requested scope match one with `require_auth: true`? -3. If yes: stop. Tell the operator the gate requires explicit authorization, name the scope, and wait for them to say "yes, authorize this specific action." -4. If no gate matches and the motion is potentially harmful (grasping unknown objects, high velocity, workspace-boundary-approaching): **surface the gap to the operator**. Don't silently proceed; don't silently decline. Say: "Your manifest doesn't declare a gate for this scope. Add one to ROBOT.md or authorize this specific action." -5. Know the E-stop. `safety.estop.software: true` means a software e-stop exists — learn the driver command for it before attempting motion. +2. Confirm with the person that they are at the machine, watching, with nobody else in reach and a hardware stop within their reach. +3. Scan `hitl_gates[]`. A gate that doesn't say `require_auth: false`, on any scope but `commission`, makes the motion tools refuse every motion (rule 4): name the gate and tell the person the confirmation has to come from outside this conversation. A reply in chat is not that confirmation. +4. If no gate matches and the motion could cause harm (grasping unknown objects, high velocity, near the workspace boundary): **surface the gap to the operator**. Don't silently proceed; don't silently decline. Say: "Your manifest doesn't declare a gate for this scope. Adding one to ROBOT.md is your decision." +5. Know the stops: `estop` is the software stop through the gateway; the person's hardware stop is the one that depends on no software. ## Prefer MCP over Shell @@ -164,7 +198,7 @@ If `robot-md >= 0.2.1` is registered, these prompts are available as slash comma | Slash command | When to expect it | |---|---| | `/brief-me` | Operator wants an at-a-glance summary of the robot. Invoke when first orienting in a session, or when the operator says "remind me what this robot is". | -| `/check-safety action=""` | **Invoke before any physical motion.** Operator describes the action; the prompt cross-references declared `hitl_gates[]` and returns one of "✓ safe", "⚠ auth required — ", or "⚠ gate gap". | +| `/check-safety action=""` | **Invoke before any physical motion.** Operator describes the action; the prompt cross-references declared `hitl_gates[]` and returns one of "✓ no gate applies; robot-md-gateway decides", "⚠ gated — : needs a person's confirmation outside this chat", or "⚠ gate gap". It is a preview: the gateway enforces the limits. | | `/explain-capability capability=""` | Operator asks about a specific capability like `arm.pick` or `nav.go_to`. Returns what it does, hardware path, and gates that apply. | | `/manifest-status` | Operator asks for a quick health check. Wraps the `doctor_summary` tool in a human-readable report. | @@ -180,6 +214,10 @@ If the operator hasn't invoked a prompt, you can still proceed via the matching - **Problem:** You issue a motion command without first checking `hitl_gates[]`. - **Fix:** Always read `/safety` before the first motion of a session. +**Treating a "yes" in chat as authorization** +- **Problem:** You ask "shall I pick it up?", the operator says "yes", and you treat that as the gate being satisfied. +- **Fix:** It isn't. The gateway decides; gated scopes are refused until a confirmation arrives from outside this conversation. Check the person is at the machine (rule 2), then call the tool and report what the gateway says. + **Proposing a capability not in the list** - **Problem:** Operator asks "can you pick this up?" and you say yes because it's an arm — but `arm.pick` isn't declared. - **Fix:** If the capability isn't in `capabilities[]`, the robot can't do it through this interface. Tell the operator. @@ -228,14 +266,21 @@ from a terminal, or — in the future — a pendant). Tell them you saw it ## Red Flags **Never:** +- Treat a reply in chat as authorization for motion +- Call a motion tool without the person at the machine and a hardware stop within their reach +- Move the robot by any route other than robot-md-gateway: no serial port, no scripts that open it, no services started or restarted +- Call `estop_clear` to resume on your own +- Start a test run: a Bounded Embodiment EV run, `robot-md trial start` or `robot-md trial iteration` - Issue a physical motion command before reading `/safety` - Invent capabilities not declared in the manifest - Edit `metadata.rrn`, `metadata.rcan_uri`, or other registry-bound fields without operator confirmation +- Read or print `bearers.yaml` or a gateway token into the conversation - Commit files under `~/.robot-md/keys/*` — those are API keys - Run `robot-md unregister` without the operator typing "unregister" **Always:** - Read `robot-md:///safety` before the first motion of the session +- Report a gateway refusal as given, and stop - Read `robot-md:///capabilities` before claiming what the robot can do - Validate after any edit (`validate` MCP tool or `robot-md validate ROBOT.md`) - Prefer MCP resources over shell-out when the MCP server is registered @@ -283,21 +328,23 @@ The plugin also auto-registers the `robot-md` MCP server, so the `robot-md:///*` resources + `validate` / `render` / `doctor_summary` tools. Announces its own routing table via the MCP `instructions` field. +- **`robot-md`** (MCP server) — provides `robot-md:///*` resources, `validate` / `render` / `doctor_summary` tools, the motion tools (`execute_capability`, `execute_task`, `estop`), which send to robot-md-gateway, and `estop_clear`, which refuses and sends nothing. Announces its own routing table via the MCP `instructions` field. +- **robot-md-gateway** — the bounded layer every motion goes through. It enforces the limits; this skill does not. +- **bounded-embodiment** (skill) — test runs and gate work; see "How this skill relates to the bounded-embodiment skill" at the top. - **`CLAUDE.md` in the project root** — generated by `robot-md claude-md ROBOT.md`; encodes the same intent→action table as a plain text file the harness reads at session start. **Called by:** any session where the operator works on a robot declared by a `ROBOT.md` in the project. ## Pick-place trial protocol -When the operator runs `robot-md trial iteration --capture-pre`, your next steps are: +A pick-place trial is a test run, so the person starts it and every iteration (`robot-md trial start`, `robot-md trial iteration --capture-pre`, `--capture-post-and-verdict`, `--reset-confirmed`). You never run those commands. Within an iteration the person has opened, under the motion rules at the top: + +1. Locate the brick and the bowl with the read-only perception tools (`vision_find` with the manifest's object descriptors). If they report that no camera is open in this server, ask the person; don't open the camera yourself. +2. Plan the steps from capabilities the manifest declares. Whether you send them depends on two things: + - If the bounded-embodiment skill is in your session, or the manifest has a gate that refuses motion (rule 4; the so-arm101 preset's gates do), you don't send them: hand the steps to the person. A trial with you driving the arm can't run while either holds. + - Otherwise, send each step with `execute_capability`, one at a time. Wait for `status: ok` with `reached: true` before sending the next. A refusal, or a step that didn't reach, ends the iteration: report it as given. +3. Report completion to the person. They run `robot-md trial iteration --capture-post-and-verdict` to score it. -1. Call the `oak-d` actuator's `perceive` capability via the gateway to locate the brick: - - `mcp__robot-md__invoke` with `actuator_name="oak-d", tool_name="perceive", tool_args={"query": "red_blob"}` - - The telemetry returns `{found, centroid_px, centroid_depth_mm, bbox_px, pixel_count}`. -2. Same call with `tool_args={"query": "bowl_top"}` to locate the bowl. -3. Plan a joint sequence: home pose → above brick (use brick centroid + a fixed bird's-eye camera-to-arm offset, documented per-rig) → descend → close gripper → ascend → above bowl → descend → open gripper → home. -4. Dispatch each `move` call sequentially via `mcp__robot-md__invoke` with `actuator_name="so-arm101", tool_name="move", tool_args={"joint_positions": {...}, "timeout_s": 5.0}`. Wait for each outcome's `outcome_kind == "executed"` before sending the next. -5. Report completion to the operator. They will run `robot-md trial iteration --capture-post-and-verdict` to score the iteration. +Earlier versions of this section named an `mcp__robot-md__invoke` tool with joint-level `move` commands. robot-md's MCP server has never registered that tool; don't look for it. Camera mount + arm geometry are rig-specific and documented in the rig's case-study page at `/case-studies//pick-place/`. If you don't know the offset, ask the operator before dispatching any move.