Skip to main content

Module node_registry

Module node_registry 

Source
Expand description

Node identity registry.

A Node is a physical thing in the mesh — an ESP32, the daemon host, a Pi. It signs emissions (sensor data, heartbeats, anything it merely reports). Sensing is not acting; nodes are deliberately distinct from actors (crate::agent_registry::AgentRegistry), which sign Actions (Foundry-style mutations).

Each node holds an Ed25519 keypair. The node-id is hex(SHA-256(pubkey)[..16]) (32 hex chars, ADR-103 D11), computed by crate::node_id::node_id_from_pubkey — self-authenticating (recompute to verify), and a 32-hex segment can never equal a reserved word like _derived or meta. A friendly human label lives as a property at substrate/<node-id>/meta/label, not as the identity itself — labels can collide, keys cannot.

§Substrate write gate

Under the node-identity contract every substrate write belongs to exactly one node and must land under that node’s namespace:

substrate/<node-id>/...

This module provides the registry (node-id → pubkey) and the canonical signing payload (node_publish_payload). Enforcement of the prefix rule lives on SubstrateService; signature verification lives at the RPC boundary in clawft-weave. Both consult this registry.

The registry is in-memory. Node keys are provisioned on the node side (firmware-burned for the ESP32, persisted on disk for the daemon) and registered at kernel boot. Restart-resets by design — the on-disk provisioning is the source of truth.

Re-exports§

pub use crate::node_id::node_id_from_pubkey;

Structs§

DerivedWriteGrant
Capability allowing a node to publish under substrate/_derived/<topic> (or its subtree, depending on GrantScope).
NodeRegistry
In-memory node-id → public-key map.
RegisteredNode
A registered node: node-id, public key, optional friendly label, and when it was added to the registry.

Enums§

DerivedGrantError
Failure modes for NodeRegistry::issue_derived_grant.
GrantScope
Scope of a DerivedWriteGrant. Decides whether the registered topic matches one literal subtree or all subtrees beneath it.

Constants§

MESH_CANONICAL_PREFIX
Required path prefix for a mesh-canonical write. Trailing slash included so a strip_prefix cleanly leaves the remaining <topic> segment without a leading separator. See R3.0.

Functions§

node_publish_payload
Compose the canonical byte payload a node must sign for a substrate.publish.
node_register_payload
Compose the canonical byte payload a node must sign as the proof-of-possession for node.register.
path_belongs_to
Whether path is a legal write target for node_id. Convenience wrapper over required_path_prefix.
required_path_prefix
Required path prefix for any substrate write originated by node_id.