lucen-device 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. lucen_device-0.3.0/LICENSE +202 -0
  2. lucen_device-0.3.0/PKG-INFO +256 -0
  3. lucen_device-0.3.0/README.md +236 -0
  4. lucen_device-0.3.0/pyproject.toml +57 -0
  5. lucen_device-0.3.0/src/lucen_device/__init__.py +13 -0
  6. lucen_device-0.3.0/src/lucen_device/adapter_runtime.py +214 -0
  7. lucen_device-0.3.0/src/lucen_device/adapters/__init__.py +203 -0
  8. lucen_device-0.3.0/src/lucen_device/adapters/capabilities.py +127 -0
  9. lucen_device-0.3.0/src/lucen_device/adapters/command.py +468 -0
  10. lucen_device-0.3.0/src/lucen_device/adapters/lucen_legged.py +11 -0
  11. lucen_device-0.3.0/src/lucen_device/adapters/registry.py +323 -0
  12. lucen_device-0.3.0/src/lucen_device/adapters/virtual.py +313 -0
  13. lucen_device-0.3.0/src/lucen_device/approval.py +203 -0
  14. lucen_device-0.3.0/src/lucen_device/config.py +259 -0
  15. lucen_device-0.3.0/src/lucen_device/embodiment.py +90 -0
  16. lucen_device-0.3.0/src/lucen_device/endpoint.py +644 -0
  17. lucen_device-0.3.0/src/lucen_device/enroll.py +234 -0
  18. lucen_device-0.3.0/src/lucen_device/events.py +60 -0
  19. lucen_device-0.3.0/src/lucen_device/hub.py +303 -0
  20. lucen_device-0.3.0/src/lucen_device/link.py +86 -0
  21. lucen_device-0.3.0/src/lucen_device/main.py +714 -0
  22. lucen_device-0.3.0/src/lucen_device/outbox.py +222 -0
  23. lucen_device-0.3.0/src/lucen_device/serve.py +1125 -0
  24. lucen_device-0.3.0/src/lucen_device/stage_process.py +257 -0
  25. lucen_device-0.3.0/src/lucen_device/trial.py +524 -0
  26. lucen_device-0.3.0/src/lucen_device/trial_log.py +465 -0
  27. lucen_device-0.3.0/src/lucen_device/trust.py +130 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,256 @@
1
+ Metadata-Version: 2.4
2
+ Name: lucen-device
3
+ Version: 0.3.0
4
+ Summary: MouseMouse robot-side driver (`lucen-device`): runs only what a person approved, verified offline
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Dist: typer>=0.20
8
+ Requires-Dist: lucen-cli>=0.1.0,<0.2
9
+ Requires-Dist: lucen-sdk>=0.1.0,<0.2
10
+ Requires-Dist: pyjwt[crypto]>=2.10
11
+ Requires-Dist: cryptography>=42
12
+ Requires-Dist: websockets>=14,<16
13
+ Requires-Dist: msgpack>=1.0
14
+ Requires-Dist: numpy>=2.0,<3
15
+ Requires-Python: >=3.12
16
+ Project-URL: Homepage, https://mousemouse.ai
17
+ Project-URL: Documentation, https://mousemouse.ai/docs/connect-your-robot
18
+ Project-URL: Repository, https://github.com/ICE-CUBA/lucen-hub
19
+ Description-Content-Type: text/markdown
20
+
21
+ # `lucen-device` — the robot side of the consent layer
22
+
23
+ `lucen-device` runs on the robot's own computer. It holds two things the hub
24
+ never sees — the device's Ed25519 private key and whatever the robot needs to
25
+ start a policy — and acts only on approvals a **person** signed in the web app,
26
+ which it verifies **offline** against the hub's published signing key.
27
+
28
+ The hub's rule is that no API key of any scope can put a policy on a robot
29
+ (`POST /v1/devices/{id}/approvals` is `session`-only). This package is how a
30
+ policy gets there anyway: the hub records consent, the box does the handoff.
31
+
32
+ ## Install
33
+
34
+ From PyPI, as a tool on the robot's own computer (`uv`, or `pipx install
35
+ lucen-device`):
36
+
37
+ ```bash
38
+ uv tool install lucen-device
39
+ ```
40
+
41
+ `lucen-device` depends on `lucen-cli`, so the same install puts `lucen` on the
42
+ `PATH` beside it (a robot box runs `lucen pull` anyway). A MouseMouse hub also
43
+ serves its own copy of these wheels: `curl -fsSL <hub API>/install.sh | sh -s --
44
+ device` installs the version built from the hub's own commit and points the
45
+ driver at that hub; see the hub's docs page *Connect your robot*.
46
+
47
+ ## Pair (K1) — no person's key on the robot
48
+
49
+ ```
50
+ lucen-device pair K7QF-2M9D --hub https://hub.example/api # a code a person issued on the hub
51
+ lucen-device pair --hub https://hub.example/api # no code: the box asks for one and shows it
52
+ ```
53
+
54
+ The box generates its Ed25519 key, declares itself (adapter and provenance,
55
+ fail-safe probe, any `--accept` contracts) and prints its **key fingerprint**.
56
+ A signed-in person opens the pairing on the hub, compares that fingerprint,
57
+ picks the trust mode and confirms ("Not my robot" drops it; an unconfirmed
58
+ claim expires with the code, ten minutes). The box then collects — signing with
59
+ its key — a **device credential** that acts only as this device, the hub's
60
+ signing key and the robot card's interface, all pinned in `device.json`. The
61
+ owner revokes the credential from the hub (disconnect); every later call is
62
+ `401`, and a running policy stops.
63
+
64
+ **Trust mode.** `registered` (default) runs only the IO contracts this box
65
+ registered. `approved` also runs a contract it never registered when a signed
66
+ approval names it **and** the policy's `embodiment_fingerprint` equals the
67
+ interface fingerprint this box pinned; an **unstamped** policy additionally
68
+ needs the approver's acknowledgment in the token and a contract that fits the
69
+ pinned interface (joint order, control rate, one action per joint), which the
70
+ box checks itself. The person chooses it at
71
+ confirmation; afterwards only the box changes it: `lucen-device trust approved`.
72
+
73
+ ## Credentials
74
+
75
+ A paired box uses its own device credential (in `device.json`, mode 0600). A
76
+ box set up with `register` uses the `lucen` CLI's: `lucen auth login` on the box
77
+ (a `write` key for the device's owner — it registers and posts telemetry, and
78
+ by contract it cannot approve anything), or `LUCEN_API_KEY` / `LUCEN_API_URL` in
79
+ the environment. No flag takes a key.
80
+
81
+ The driver's own state lives in `$LUCEN_DEVICE_CONFIG_DIR` (default
82
+ `~/.config/lucen-device`): `device.json` (the registration and the hub signing
83
+ key pinned at registration), `device_key.pem` (mode 0600, refused if looser) and
84
+ `models/<approval id>/` (each pulled repo).
85
+
86
+ ## Register
87
+
88
+ ```
89
+ lucen-device register --robot lucen/laika --name lab-laika --adapter virtual \
90
+ --accept-from ./omni/omni_c4_ff800.onnx # and/or --accept <fingerprint>
91
+ ```
92
+
93
+ Registration generates the keypair, fetches and **pins** the hub's signing key
94
+ (`kid` + PEM + issuer), and tells the hub which IO contracts this box will run —
95
+ as fingerprints (`sha256` of a stamped ONNX manifest's canonical `contract`
96
+ block). `--accept-from` reads one out of a policy file; a device that accepts
97
+ no contract cannot be registered, because it could never be handed anything.
98
+ If the hub signs with an ephemeral key (no `DEVICE_APPROVAL_SIGNING_KEY`), the
99
+ command warns you: approvals will stop verifying when the hub restarts, and
100
+ `lucen-device signing-key --refresh` re-pins.
101
+
102
+ ## Serve
103
+
104
+ ```
105
+ lucen-device serve # poll every 10 s, forever
106
+ lucen-device serve --once # handle what is issued now, then exit
107
+ ```
108
+
109
+ For every approval the hub lists as `issued` for this device:
110
+
111
+ 1. **verify the token offline** — `alg` is `EdDSA`, `kid` is the pinned one,
112
+ the signature holds, `exp`/`nbf`/`iat` hold (10 s leeway), `aud` is
113
+ `lucen-device`, `iss` is the pinned issuer, `sub` is this device;
114
+ 2. cross-check the listing against the signature (id and digest);
115
+ 3. **pull the model repo** with `lucen pull`'s code (every file digest-checked),
116
+ then compare the ONNX to the digest **inside the token**;
117
+ 4. read the ONNX's own `lucen_manifest` and **refuse a contract this box did not
118
+ register** (or one that differs from what the hub pre-checked);
119
+ 5. load the ONE adapter this box registered, check the embodiment, pass it the
120
+ robot card's safe stop, walk its staged start;
121
+ 6. start the adapter, post `started`, heartbeat every `heartbeat_s` seconds
122
+ (2 s by default; `--heartbeat` overrides it), stop at `expires_at` on this
123
+ box's clock (or at `--max-run-seconds`, a local cap), post `stopped`;
124
+ 7. **stop when the link is lost.** A heartbeat the hub does not acknowledge
125
+ within the interval is a miss and a warning. `link_lost_heartbeats` misses
126
+ in a row (5 by default, about ten seconds) are link loss: the adapter is
127
+ held (`hold()`, when it has one) and then stopped, in the same order a
128
+ person's Stop uses, and the approval is over on the robot's side. Nothing
129
+ restarts the policy. The signed `stopped` (reason `link_lost`, with the
130
+ misses it counted and `stop_sequence`) waits in the outbox and is posted
131
+ when the link returns; `serve --once` waits up to a minute for that, then
132
+ exits and warns. The rule counts answers, never clocks, so clock skew
133
+ cannot fire it. Both numbers live in `device.json` (`heartbeat_s`,
134
+ `link_lost_heartbeats`).
135
+
136
+ The trail says `verified` (step 1) and `pulled` (step 3) before `started`. A
137
+ person's **Stop** arrives on a heartbeat's answer: the adapter is held
138
+ (`hold()`, when it has one) and then stopped at once, in M17d's fail-safe
139
+ order, and `stopped` says `stop_requested` with `stop_sequence: [hold, stop]`,
140
+ within one heartbeat plus a round trip. Only a signed-in person can press it;
141
+ no API key can. A robot that cannot reach the hub does not wait for the Stop:
142
+ it stops the policy itself about ten seconds after it loses the hub (step 7).
143
+ Stop is a convenience over the network, not a safety system: keep a hardware
144
+ emergency stop within reach.
145
+
146
+ Every refusal is posted back as a signed `refused` event with a machine reason
147
+ (`bad_signature`, `unknown_kid`, `expired`, `wrong_device`, `digest_mismatch`,
148
+ `unstamped`, `contract_mismatch`, `adapter_refused`, …) so the person who
149
+ approved can read why nothing happened. Every event is signed with the device
150
+ key; the hub verifies it against the key you registered.
151
+
152
+ ## Adapters
153
+
154
+ **Adapters are plugins (M17d).** The adapter is the only part of the driver that
155
+ knows a robot: it takes a verified policy (or a fresh action chunk) and makes
156
+ the robot do it. Three ship here; any other robot installs its own — see
157
+ `examples/device-adapter/` (141 lines, a fake robot, both protocols) and the
158
+ docs page `/docs/connect-your-robot`.
159
+
160
+ ```
161
+ lucen-device adapters # what is installed — reads metadata, imports nothing
162
+ lucen-device adapters --check example-arm # import ONE, list its protocols, probe its fail-safe
163
+ ```
164
+
165
+ An adapter is a class registered in the entry-point group
166
+ `lucen_device.adapters` by an installed distribution (the built-ins register
167
+ through the same group), or named directly for unpackaged code:
168
+ `--adapter my_robot.adapter:MyArm` / `--adapter ./my_arm.py:MyArm`.
169
+ **Loading one is code execution on the robot box.** So: the operator names it
170
+ at `register` and the driver loads that one and no other; listing never
171
+ imports; a name two distributions claim — a third party registering `virtual`
172
+ included — is refused; `serve` refuses (`adapter_changed`) when the registered
173
+ name now resolves to a different distribution or class; and the distribution,
174
+ version and class go into the device's `adapter_info` on the hub and into every
175
+ signed `started` event.
176
+
177
+ | Protocol | Methods | |
178
+ |---|---|---|
179
+ | `policy` | `start / stop / status / is_running` | run the approved file on the robot |
180
+ | `chunks` | `begin / observe / apply / hold / resume / stop / status / is_running` | consume a hub endpoint |
181
+ | `staged_start` (optional) | `stage(name, interface)` | `"safe"`, then `"default_pose"`, before the policy |
182
+ | `safe_stop` (optional) | `set_safe_stop(mode)` | the robot card's `safety.safe_stop` decides what hold / stop mean |
183
+
184
+ - **`virtual`** — every protocol. Validates the manifest and runs a clock at the
185
+ policy's control rate for the approved window. It simulates **nothing**: no
186
+ inference (the ONNX is never loaded), no physics, no actuators. It exists so
187
+ the whole consent path runs in CI on a laptop, and every heartbeat says so.
188
+ - **`command`** — `policy` only: shells out to the box's own start/stop/status
189
+ commands, from `device.json` `adapter_config` (`register --adapter-config
190
+ FILE.json`) or `LUCEN_DEVICE_START_CMD` / `LUCEN_DEVICE_STOP_CMD` /
191
+ `LUCEN_DEVICE_STATUS_CMD`, **never from the hub**. Placeholders:
192
+ `{model_path}`, `{manifest_path}`, `{interface_path}`, `{seconds}`,
193
+ `{approval_id}`, `{safe_stop}`; a shell string or a JSON list; an unknown
194
+ placeholder is refused before anything starts. **Stop**: `stop_cmd` first
195
+ (30 s cap), then `SIGTERM` to the start command's whole process group (it
196
+ runs in its own session, so a runner forked by `sh -c` is reached), then
197
+ `SIGKILL` after 10 s. **Unverified on hardware** — there is no robot here;
198
+ the plumbing is tested with a shell command standing in for the runner.
199
+ - **`lucen-legged`** — the deprecated alias of `command` (M13's name for it;
200
+ there was never anything legged in it). Existing registrations keep serving.
201
+
202
+ **The robot card's interface, on the box.** `register` pins the robot card's
203
+ embodiment `interface` and `interface_fingerprint` (refresh on purpose:
204
+ `lucen-device interface --refresh`). `safety.safe_stop` reaches
205
+ `set_safe_stop()` — and if the card asks for something other than `hold` and
206
+ the adapter has no such hook, nothing starts; `default_pose` reaches the staged
207
+ start; a policy stamped with a different `embodiment_fingerprint` is refused
208
+ (`embodiment_mismatch`), and when either side is silent the `started` event
209
+ records the check as **not made**.
210
+
211
+ ## Other commands
212
+
213
+ ```
214
+ lucen-device status # registration, adapter provenance, issued approvals, last events
215
+ lucen-device trust [MODE] # show the trust mode, or change it (the box's call alone, signed)
216
+ lucen-device signing-key [--refresh] # the pinned hub key; --refresh re-pins it
217
+ lucen-device interface [--refresh] # the pinned robot-card interface fingerprint
218
+ lucen-device version
219
+ ```
220
+
221
+
222
+ ## Consuming a hub endpoint (M15)
223
+
224
+ An approval may name an **endpoint** instead of a file to run: "let this
225
+ device consume hub endpoint X" — a skill-layer model (action chunks at 1–10 Hz)
226
+ served by `lucen serve` on a GPU box. The driver then does not pull the model.
227
+ It opens a session on the hub with the approval token (`POST
228
+ /v1/endpoints/{id}/sessions`), checks that the hub's and the server's
229
+ `model_sha256` are the digest inside the token and that the served contract is
230
+ one this box registered, connects over openpi's protocol with the session token
231
+ as the `Api-Key` header, and runs the loop at the contract's control rate.
232
+
233
+ **The fail-safe is local and mandatory.** One chunk period is the deadline; a
234
+ chunk that arrives late is dropped, never applied; two consecutive misses or a
235
+ dropped link call the adapter's `hold()` (freeze a safe posture, or the
236
+ adapter's own stop), post `degraded`, and reconnect until the window ends; when
237
+ chunks flow again the adapter `resume()`s and `recovered` is posted. Only an
238
+ adapter that implements `begin / observe / apply / hold / resume / stop` **and
239
+ whose `hold()` then `stop()` run clean on a fresh instance** may consume an
240
+ endpoint: `register` establishes `endpoint_capable` from the adapter's own code
241
+ and that probe — never from a list of names (`virtual` and the example yes,
242
+ `command` no) — and the hub refuses a request naming an endpoint on any other
243
+ device. `hold()` and `stop()` must therefore work in any state and never raise.
244
+ The loop does not trust them anyway: a `hold()` that raises or does not return
245
+ within a second is answered with `stop()`, a `degraded` event saying
246
+ `hold_failed`, and the end of the run; an exception out of `observe()` /
247
+ `apply()` holds and ends it; and a watchdog thread holds and stops a loop that
248
+ has made no progress for ten seconds (a coarse backstop, not a real-time
249
+ guarantee — the robot's own controller must also stop when commands stop). A queued endpoint or an unreachable server is
250
+ *deferred* (the approval stays issued; the next poll tries again), not refused.
251
+
252
+ The device reports its own metering — chunks applied, round-trip p50/p95,
253
+ deadline misses, how often it held — to the session on the hub every heartbeat;
254
+ the endpoint page shows it beside the server's numbers.
255
+
256
+ Apache-2.0. © 2026 Lucen Robotics.