macula_attach_identity (macula v4.2.5)
View SourceDaemon-side attachment to a host station.
PLAN_MACULA_NET_PHASE3.md §6.2. The daemon dials its host, sends a signed attach-request frame on a bidi stream, and from then on sends/receives macula-net envelopes through that same stream.
The handshake reuses the existing macula_net_transport_quic pipe — daemons share the transport's framing logic with stations even though they don't accept inbound connections themselves. The handshake frame and subsequent envelopes are length-prefixed CBOR maps.
Phase 3 MVP: no heartbeat (QUIC keepalive holds the connection), no automatic reconnect (Phase 4). Detach is explicit.
Summary
Functions
Attach to a host station. Performs the handshake and returns an opaque handle on success. The caller may then push envelopes via send/2 and register an inbound handler via set_inbound_handler/2.
Send a macula-net envelope over the attach stream.
Types
-type config() :: #{host_endpoint := host_endpoint(), realm_pubkey := <<_:256>>, daemon_keypair := macula_identity:key_pair(), inbound_handler => inbound_handler()}.
-type handle() :: pid().
Functions
-spec attach(host_endpoint(), RealmPubkey :: <<_:256>>, macula_identity:key_pair(), map()) -> {ok, handle()} | {error, term()}.
Attach to a host station. Performs the handshake and returns an opaque handle on success. The caller may then push envelopes via send/2 and register an inbound handler via set_inbound_handler/2.
-spec detach(handle()) -> ok.
Send a macula-net envelope over the attach stream.
-spec set_inbound_handler(handle(), inbound_handler()) -> ok.