Expand description
Direct-dial resolve-and-call: resolving a signed procedure_advertisement
DHT record and its serving station’s own signed station_endpoint, then
dialing that station in one hop — instead of depending on ordinary
advertise-gossip having propagated a route between whichever two
stations happen to be involved.
Ported from macula-io/macula’s macula_direct_dial.erl, cross-checked
against macula-go’s own port of the same reference
(directdial/directdial.go) — see that file’s doc for the fuller
reasoning behind each design choice made here.
Trust model (see macula_direct_dial.erl’s module doc for the full
reasoning): every candidate procedure_advertisement must carry a valid
Ed25519 signature before its serving_station is trusted at all, and
the resolved station_endpoint must be signed by the station itself.
The actual QUIC dial trusts neither the TLS certificate (a production
station’s TLS is terminated by an unrelated PKI) nor nothing — trust is
enforced at the application layer, by checking the freshly dialed
session’s own signature-verified HELLO identity against the exact
pubkey the signed DHT chain resolved.
cert_chain-based org/realm authorization (Slice 7c Direction B,
macula_record:verify_advertisement_cert_chain/3 on the Erlang side) is
opt-in here too, matching the reference and macula-go’s own port —
see resolve_with_cert_chain/call_with_cert_chain/
advertise_direct_with_cert_chain. Plain resolve/call/
advertise_direct are completely unaffected.
Structs§
- Content
NotAnnounced mcidhas no live, verifiablecontent_announcementin the DHT — either nobody announced it (common: a single-block content put alone is never announced, matchingmacula_content_transfer:put_single_block/3), or every candidate found failed signature/self-consistency verification.- Resolved
- One resolved direct-dial target: the station’s own node id plus a dialable host/port.
Enums§
- Advertise
Direct Error - Call
Error - Dial
AndVerify Error - The dial-then-pin sequence every direct-dial call shape needs after
resolving: dial
resolved’s host:port, then check the freshly connected session’s own signature-verified HELLO identity againstresolved.station— factored out here (unlikecall/call_with_cert_chain, which had it inline before this existed) becauseopen_stream_direct/put_direct/get_directall need the identical sequence against a station identity that isn’t necessarily reached viaresolve. - GetDirect
Error - Open
Stream Direct Error - PutDirect
Error - Resolve
Error
Functions§
- advertise_
direct - Publishes a signed
procedure_advertisementnamingsession’s own currently-connected station (session.station.node_id) asprocedure’s server, discoverable by any caller’sresolve/call. Mirrorsmacula_response:advertise_direct/6,7+macula_direct_dial:publish_advertisement/4,5— unlike the Erlang reference’s pool (many links, one chosen byconnected_station/1), aSessionis always exactly one connection, so there is no link-selection step: the session’s own verified HELLO identity IS the serving station. - advertise_
direct_ with_ cert_ chain advertise_directplus an embedded X.509 service-cert chain, for Slice 7c Direction B managed-realm authorization — seeresolve_with_cert_chain/call_with_cert_chainfor the corresponding checks. Opt-in: plainadvertise_directis unaffected.- call
- Resolves
procedure’s provider via direct-dial (throughresolve_via, used only to query the DHT) and calls it there, in one hop, in a SEPARATE connection fromresolve_via. The provider must have advertised viaadvertise_direct(or the Erlangmacula_response:advertise_direct/6,7) — a plainadvertisepublishes no discoverable record andresolvewill returnResolveError::ProcedureNotAdvertised. - call_
with_ cert_ chain call, resolved viaresolve_with_cert_chaininstead ofresolve— see both for the full contract. Opt-in managed-realm authorization;callitself is unaffected.- call_
with_ ucan call, presentingucan_tokento a provider gated with{ucan_required, Issuer}. Every hecate-om capability is advertised viaadvertise_direct, so this is the only way a UCAN-gated capability is reachable through this crate at all –callitself has no token parameter, andSession::call_with_ucanis the plain, non-direct path, which cannot resolve a direct-dial-only advertisement to begin with.- get_
direct - Fetches and verifies the content addressed by
mcidfrom whichever station a signedcontent_announcementnames as its host, dialing that station in one hop instead of relaying throughresolve_via’s own station. Mirrorsmacula_direct_dial:get_content/3. - keep_
advertised_ direct - Calls
advertise_directimmediately, then again everyinterval, untilstopresolves. Rust has nothing equivalent tomacula_response’sreuse_supto worry about here, becauseadvertise_direct(unlike Erlang’sadvertise/5, which spawns a real per-call OTP supervisor) is already a stateless, side-effect-free-on- repeat async function: nothing is created per tick that could leak — same reasoningmacula-go’sKeepAdvertisedDirectalready applied and verified live. - open_
stream_ direct - Resolves
procedure’s provider via direct-dial (throughresolve_via, used only to query the DHT) and opens a stream there, in one hop, in a SEPARATE connection fromresolve_via— the streaming-RPC counterpart tocall. The provider must have advertised viaadvertise_direct: streaming’s provider side (macula_streamer.erl) shares the identicalprocedure_advertisementmechanism RPC uses (confirmed againstmacula_streamer.erl/macula_stream_sink.erl’s ownadvertise_direct/start_link_direct— both aremacula_response:advertise_direct/macula_direct_dial:call_streamunder the hood, nothing stream-specific added), so no separate stream-shaped advertise function exists or is needed. - open_
stream_ direct_ with_ cert_ chain open_stream_direct, resolved viaresolve_with_cert_chaininstead ofresolve— see both for the full contract. Opt-in managed-realm authorization;open_stream_directitself is unaffected.- put_
direct - Stores
dataat a KNOWNstationdirectly, in one hop, instead of going through whatever stationresolve_viahappens to be connected to. Mirrorsmacula_feeder:start_link_direct/5,6, which — unlike procedure/stream direct-dial — takes the target station’s pubkey directly rather than resolving one via aprocedure_advertisement: content has no “procedure” to advertise, so there is nothing to resolve here beyond the station’s ownstation_endpoint(resolve_station_endpoint).resolve_viais used only to query the DHT forstation’sstation_endpoint; it does not need to already be connected tostation. - resolve
- Finds
procedure’s currently-advertised serving station and its dialable host/port, retrying past DHT propagation lag.realmandproceduremust match exactly what the provider passed toadvertise_direct(or the Erlang equivalent) — the discovery URI they derive must agree.sessionis used only to query the DHT; it does not need to be connected to the same station that will end up serving the call. - resolve_
with_ cert_ chain resolveplus Slice 7c Direction B managed-realm authorization: only an advertisement whose embedded cert chain validates torealm_ca_pemand namesexpected_orgis trusted. Opt-in —resolveitself is unaffected and remains the right choice for unmanaged realms.