Skip to content

registry

diapason.mesh.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.

DeviceRegistry

Devices known to this installation, in its own SQLite file.

create_pairing(device_name)

Open a one-time, short-lived invitation for a new device.

declare_capabilities(device_id, capabilities)

Record what a device CLAIMS. What it gets is computed on read.

enrol_host(*, device_id, public_key_b64, name, platform='UNKNOWN', device_type='DESKTOP', declared_capabilities=None, address='')

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.

forget(device_id)

Delete a device outright — the only way back from revocation.

forget_seal_key(device_id)

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.

heartbeat(device_id, *, app_state='', transport='', address='')

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.

heartbeat_signed(device_id, *, app_state='', transport='', address='', app_version='', sent_at_ms)

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.

public_key_of(device_id)

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.

record_seal_key(device_id, key_b64, sent_at_ms)

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.

redeem_pairing(token, *, device_id, public_key_b64, name, platform, device_type='DESKTOP', declared_capabilities=None, app_version='')

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.

revoke(device_id)

Cut a device off. Terminal until the user deletes it outright.

seal_key_of(device_id)

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.

MeshError

Bases: RuntimeError

A mesh operation the user must see explained, in French.