registry
registry
¶
The devices this installation knows, and what each is allowed to do.
The registry answers the three questions the domain cannot (spec §5): which devices exist, what each one is, and whether it may still be listened to. Succès remains the single source of truth for tasks and notes — nothing here duplicates business data.
Pairing mirrors the mechanism Succès already proved in production: a one-time invitation token, hashed at rest, short TTL, redeemed exactly once. What the mesh adds is the exchange of PUBLIC KEYS, which is what later lets a command be verified rather than merely accepted.
Trust is a state, not a flag (spec §5): UNTRUSTED → PENDING → TRUSTED → REVOKED, and revocation is terminal — a revoked device is never silently re-admitted by presenting the same key.
Classes¶
MeshError
¶
Bases: RuntimeError
A mesh operation the user must see explained, in French.
DeviceRegistry
¶
Devices known to this installation, in its own SQLite file.
Source code in src/diapason/mesh/registry.py
Methods:¶
create_pairing
¶
Open a one-time, short-lived invitation for a new device.
Source code in src/diapason/mesh/registry.py
redeem_pairing
¶
redeem_pairing(
token: str,
*,
device_id: str,
public_key_b64: str,
name: str,
platform: str,
device_type: str = "DESKTOP",
declared_capabilities: Sequence[str] | None = None,
app_version: str = "",
) -> dict[str, Any]
Spend an invitation and enrol the device that presented it.
The invitation proves a human authorised THIS enrolment; the public key is what every later command will be checked against.
Source code in src/diapason/mesh/registry.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
enrol_host
¶
enrol_host(
*,
device_id: str,
public_key_b64: str,
name: str,
platform: str = "UNKNOWN",
device_type: str = "DESKTOP",
declared_capabilities: Sequence[str] | None = None,
address: str = "",
) -> dict[str, Any]
Enregistrer l'hôte QUI VIENT DE NOUS ACCUEILLIR dans la flotte.
Le pendant invité de redeem_pairing (Spatial Mesh, 25 août
2026) : sans lui, un Diapason qui rejoint sait parler à son hôte
mais ne sait pas le reconnaître quand il répond — le jumelage
n'était mutuel que d'un côté.
La confiance vient d'un fait, pas d'une déclaration : cette méthode n'est appelable qu'après avoir consommé AVEC SUCCÈS une invitation que l'hôte a lui-même émise. Les mêmes refus qu'au jumelage s'appliquent — une révocation ne se blanchit pas, et une clé qui change demande l'arbitrage de l'utilisateur.
Source code in src/diapason/mesh/registry.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
public_key_of
¶
The key a command from this device must verify against.
Returns None for unknown OR revoked devices, so a caller cannot accidentally verify a signature from a device that was cut off.
Source code in src/diapason/mesh/registry.py
record_seal_key
¶
Enregistrer la clé de scellement publiée par un pair.
Rend False quand la publication n'est pas STRICTEMENT plus récente
que la dernière retenue — ce à quoi ressemble un rejeu. Le contrôle et
l'écriture sont un seul UPDATE, exactement comme heartbeat_signed
et pour la même raison : deux publications arrivant ensemble ne
peuvent pas voir toutes deux l'ancienne marque, donc une seule gagne.
Un attaquant qui rejoue une vieille publication ne peut donc pas réinstaller une clé périmée dont il aurait, lui, la moitié privée.
Source code in src/diapason/mesh/registry.py
seal_key_of
¶
La clé vers laquelle sceller, et QUAND elle a été vue.
Rend None pour un appareil inconnu, révoqué, ou qui n'a jamais publié
— comme public_key_of, et pour la même raison : la révocation doit
arrêter un appareil au même goulot que tout le reste.
L'instant est rendu avec la clé parce que l'appelant en a besoin : une clé trop ancienne ne s'emploie plus, et c'est le SEUL mécanisme de repli — on ne démote jamais sur un corps de réponse.
Source code in src/diapason/mesh/registry.py
forget_seal_key
¶
Oublier la clé d'un pair, pour repartir en clair immédiatement.
Le repli normal est l'expiration, qui prend sept jours. Ceci est la sortie de secours quand on sait déjà que le pair ne sait plus ouvrir ce qu'on lui scelle — une réinstallation, un retour en arrière — et qu'on ne veut pas attendre.
Source code in src/diapason/mesh/registry.py
heartbeat
¶
heartbeat(
device_id: str,
*,
app_state: str = "",
transport: str = "",
address: str = "",
) -> dict[str, Any]
Record that a TRUSTED device is alive right now.
Restricted to trusted devices on purpose: a revoked one must not be able to make itself look reachable again simply by keeping a timer running.
Source code in src/diapason/mesh/registry.py
heartbeat_signed
¶
heartbeat_signed(
device_id: str,
*,
app_state: str = "",
transport: str = "",
address: str = "",
app_version: str = "",
sent_at_ms: int,
) -> dict[str, Any] | None
Record presence claimed by the device itself, once per timestamp.
Returns None when the beacon is not strictly newer than the last
one accepted — which is what a replay looks like. The comparison and
the write are one UPDATE on purpose: two beacons arriving together
cannot both see the old watermark, so only one can win.
Source code in src/diapason/mesh/registry.py
declare_capabilities
¶
Record what a device CLAIMS. What it gets is computed on read.
Source code in src/diapason/mesh/registry.py
revoke
¶
Cut a device off. Terminal until the user deletes it outright.
Source code in src/diapason/mesh/registry.py
forget
¶
Delete a device outright — the only way back from revocation.