Skip to main content

Official Python SDK for the RCAN robot communication protocol

Project description

rcan-py

Python SDK for the RCAN protocol. Build robots that communicate securely, audit every action, enforce safety gates locally, and register with the Robot Registry Foundation. Pinned protocol version: see the live compatibility matrix.

PyPI version RCAN Spec Tests License Python

Where this fits in the stack

This repo is the Python SDK layer — the library any Python planner, gateway, or driver links against to speak RCAN. Everything below is independent; adopt one, or all seven.

Layer Piece What it is
Declaration ROBOT.md The file a robot ships at its root. YAML frontmatter + markdown prose. Declares identity, capabilities, safety gates. Spec + Python CLI.
Agent bridge robot-md-mcp MCP server that exposes a ROBOT.md to Claude Code, Claude Desktop, Cursor, Zed, Gemini CLI — any MCP-aware agent.
Wire protocol RCAN How robots, gateways, and planners talk. Signed envelopes, LoA enforcement, PQC crypto. Think HTTP for robots.
Python SDKthis rcan-py pip install rcanRCANMessage, RobotURI, ConfidenceGate, HiTLGate, AuditChain, RegistryClient.
TypeScript SDK rcan-ts npm install rcan-ts — same API surface for Node + browser.
Registry Robot Registry Foundation Permanent RRN identities. Public resolver at /r/<rrn>. Like ICANN for robots.
Reference runtime OpenCastor Open-source robot runtime — connects LLM brains to hardware bodies. One implementation of RCAN.

Install

pip install rcan

Optional extras:

pip install rcan[http]    # httpx for registry client
pip install rcan[crypto]  # cryptography for Ed25519 signing
pip install rcan[all]     # everything

Quick Start

from rcan import RobotURI, RCANMessage, ConfidenceGate
from rcan.audit import AuditChain, CommitmentRecord
from rcan.replay import ReplayCache
from rcan.qos import QoSLevel
from rcan.consent import ConsentRequest

# 1. Address a robot
uri = RobotURI.build(manufacturer="acme", model="arm", version="v2", device_id="unit-001")
# rcan://registry.rcan.dev/acme/arm/v2/unit-001

# 2. Gate on AI confidence before acting
gate = ConfidenceGate(threshold=0.8)
confidence = 0.91

if gate.allows(confidence):
    msg = RCANMessage(
        cmd="move_forward",
        target=uri,
        params={"distance_m": 1.0},
        confidence=confidence,
        model_identity="gemini-2.5-flash",
    )

# 3. Replay attack prevention — deduplicate incoming messages
cache = ReplayCache(window_seconds=300)
if cache.is_replay(msg.msg_id):
    raise ValueError("Replay attack detected")
cache.record(msg.msg_id)

# 4. Tamper-evident audit chain — every action sealed and linked
chain = AuditChain(secret="your-hmac-secret")
chain.append(CommitmentRecord(
    action="move_forward",
    robot_uri=str(uri),
    confidence=confidence,
    model_identity="gemini-2.5-flash",
    safety_approved=True,
))
chain.verify_all()  # raises if chain is tampered

# 5. Request human consent before a sensitive action
req = ConsentRequest(
    action="open_gripper",
    robot_uri=str(uri),
    requester="operator-alice",
    scope="control",
)
print(req.to_json())

What's in v0.6.0

Module Description
rcan.message Core RCANMessage envelope with all v1.6 fields
rcan.address RobotURI — parse, build, and validate RCAN robot addresses
rcan.audit AuditChain + CommitmentRecord — tamper-evident HMAC-chained logs
rcan.gates ConfidenceGate, HiTLGate — safety gates for AI-driven actions
rcan.replay ReplayCache — sliding-window replay attack prevention (GAP-03)
rcan.clock ClockSyncStatus — NTP clock sync verification (GAP-04)
rcan.qos QoSLevel — FIRE_AND_FORGET / ACKNOWLEDGED / EXACTLY_ONCE (GAP-11)
rcan.consent Consent wire protocol — request/grant/deny (GAP-05)
rcan.revocation Robot identity revocation with TTL cache (GAP-02)
rcan.training_consent Training data consent, GDPR/EU AI Act Annex III §5 (GAP-10)
rcan.delegation Command delegation chain, max 4 hops, Ed25519-signed (GAP-01)
rcan.offline Offline operation mode — ESTOP always allowed (GAP-06)
rcan.fault FaultCode structured fault taxonomy (GAP-20)
rcan.federation Federated consent — cross-registry trust, DNS discovery (GAP-16)
rcan.transport Constrained transports — compact CBOR, 32-byte ESTOP minimal, BLE (GAP-17)
rcan.multimodal Multi-modal payloads — inline/ref media, streaming (GAP-18)
rcan.identity Level of Assurance — LoA policies, JWT parsing (GAP-14)
rcan.keys Key rotation with JWKS-compatible KeyStore (GAP-09)
rcan.config_update CONFIG_UPDATE protocol with safety scope enforcement (GAP-07)
rcan.node NodeClient — resolve RRNs across federated registry nodes (§17)
rcan.validate L1/L2/L3 conformance validation for configs, messages, URIs

Protocol 66 Compliance

Protocol 66 is RCAN's safety layer. Key invariants enforced by this SDK:

  • ESTOP always deliveredQoSLevel.EXACTLY_ONCE, never blocked by QoS downgrade
  • Local safety winsoffline module enforces local limits even without cloud connectivity
  • Confidence gates run locallyConfidenceGate never makes a network call
  • Audit chain requiredAuditChain.verify_all() before executing any flagged command
from rcan.offline import OfflineMode
from rcan.safety import SafetyInvariant

mode = OfflineMode()
mode.assert_estop_reachable()   # raises if ESTOP path is blocked

CLI

# Validate a robot config (L1/L2/L3 conformance)
rcan-validate config myrobot.rcan.yaml

# Validate a RCAN message
rcan-validate message command.json

# Verify an audit chain
rcan-validate audit audit.jsonl

# Validate a Robot URI
rcan-validate uri 'rcan://registry.rcan.dev/acme/arm/v2/unit-001'

# Run all checks
rcan-validate all myrobot.rcan.yaml

Spec Compliance

Implements the RCAN protocol — 587 tests, 0 skipped. See the live compatibility matrix for the pinned version this SDK targets.

Covered sections: §1 Robot URI · §2 RBAC · §3 Message Format · §5 Authentication · §5.3 QoS · §6 Safety Invariants · §8.3 Replay Prevention · §8.4 Clock Sync · §8.5 Sender Type · §8.6 Key Lifecycle · §8.7 Level of Assurance · §9 Capabilities · §11 Behavior Scripts · §12 Command Delegation · §13 Revocation · §14 Offline Mode · §16 AI Accountability · §17 Distributed Registry · §18 Federation · §19 Constrained Transport · §21 Registry Integration

Ecosystem

Package Version Purpose
rcan-py (this) v2.0.0 Python SDK
rcan-ts v2.0.0 TypeScript SDK
rcan-spec v3.0 Protocol spec
ROBOT.md v0.1.3 Single-file robot manifest
OpenCastor v2026.3.17.1 Robot runtime (reference impl)
RRF v1.6.0 Robot identity registry
Fleet UI live Web fleet dashboard
Docs live Runtime reference, RCAN, API

Contributing

Issues and PRs welcome at github.com/continuonai/rcan-py.

Spec discussions: github.com/continuonai/rcan-spec/issues

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rcan-3.4.0.tar.gz (177.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rcan-3.4.0-py3-none-any.whl (125.9 kB view details)

Uploaded Python 3

File details

Details for the file rcan-3.4.0.tar.gz.

File metadata

  • Download URL: rcan-3.4.0.tar.gz
  • Upload date:
  • Size: 177.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rcan-3.4.0.tar.gz
Algorithm Hash digest
SHA256 e7dd9932b5a5b40f08b77e586a0129dac3d1db462ffbbafa8a2aa6b96a1ec835
MD5 10bae1e00c9a8b706d0cd7106426b728
BLAKE2b-256 ec7c8c9749d4d6a80311ab6747f3d5eca8b749fc7754034b618f5385b81d36e9

See more details on using hashes here.

File details

Details for the file rcan-3.4.0-py3-none-any.whl.

File metadata

  • Download URL: rcan-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 125.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rcan-3.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a19c7e0b7cf3b10c12c41143b3008eef6fce65ac1fa34751bf7221937e23a4a
MD5 71d825328d497bccbd856e688a90947d
BLAKE2b-256 84323c047e449dec1a9d255afcdcbaa26cd223d14c9ac6e6b9ffe1d1714ff4ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page