mcl_core_capabilities (mcl_core v1.0.0)
View SourceAdvertises a service''s capabilities on the mesh, and resolves other services' capabilities from the DHT.
A capability carrying handler => {HandlerModule, Args} is advertised ONCE, by advertise_one/6, via 'advertise_direct/7' on its provider module (see provider_module/1) — 'macula_response' (request/reply RPC, the default) or macula_streamer (a 'kind => streamer' capability) — the SDK''s own supervised wrapper, which registers a handler with the pool AND publishes the signed procedure_advertisement DHT record, in one call. It is given stations => [Station], this node''s serving station (choose_serving_station/2), so the handler is registered on that station''s link only and the record names it: a station''s registry holds one advertiser per (realm, procedure), and two providers of one procedure spread across stations instead of fighting over each one (issue #5). The pool renews the chain behind the registration itself (macula 12.7.0, D32); this module also re-resolves it every republish tick for the DHT record.
ADVERTISING RUNS IN A MONITORED WORKER, ONE RUN AT A TIME (issue #11): do_advertise/2 is network I/O for every capability, so it never runs in this gen_server. No call to this server -- list/0, lookup/1, publish/0, register/1 -- waits on an advertise, and a trigger (register/1, publish/0, the 30s republish tick) that arrives while a run is in flight is coalesced into ONE follow-up run. See "Internals -- the advertise worker" for the lifetime and linking story.
The one registration is under org_procedure(Org, Name) (<<Org/binary, "/", Name/binary>>). THERE IS NO BARE-NAME REGISTRATION: 11.x refuses a procedure with no org namespace (no_org_namespace), so a caller reaches a capability by its org-qualified string and by nothing else. A service whose org is acme and whose capability is 'echo' is called as acme/echo.
macula_remote_advertise_registry (station-side) keys purely on the opaque procedure string, so two orgs serving the same capability name from the SAME relay station each hold their own entry. Before the org namespace was mandatory they shared one bare-name slot and whichever republish landed last won — the exact bug a live test (test_live/mcl_core_capabilities_live_station_tests.erl's org_scoped_call_reaches_only_the_targeted_org_test_) caught: both an acme- and a contoso-targeted call were answered by whichever org''s registration was most recent.
⚠ 10.x ADVERTISED TWICE, under the bare name as well, and callers written against that era hardcode the bare string. Those calls do not reach an 11.x service at all. This is not a silent-fallback situation: there is nothing to fall back to.
The discovery URI macula_direct_dial builds internally (RealmHex/Procedure) and this module''s 'procedure_uri/3' (RealmHex/Org/Name) produce the IDENTICAL string when Procedure = org_procedure(Org, Name) — so advertise_direct's own internal DHT publish already lands the org-qualified record at exactly the key discovery_key_org/3 resolves on read. No separate record-only write is needed for the handler-bearing case.
A capability with no handler key gets the legacy record-only path (build_advertisement/5,6 + 'put_record'): discoverable, never callable via call_capability, kept for a capability another mechanism serves.
A HANDLER-BEARING capability must carry an auth policy (macula 18, macula#147: there is no default, and register/1 refuses a capability that names a handler and no policy, naming it) — open (serve any identified caller: stated, never assumed), {callers, members | role | {nodes, Ids}} (macula 18's call class, resolved against the realm key the pool pinned), handler_authorizes (macula 17: no gate at the link, the handler checks the call''s own token and proofs), {ucan_required, IssuerPubkey}, or {realm_member_required, RealmDid, RequiredCan} — forwarded via auth_opts/1 into BOTH 'advertise_direct' calls' Opts, through to macula:advertise/5 and enforced on every inbound call by macula_station_link's 'authorize_policy/2'. A capability with no handler is a discovery record only, which the SDK does not gate, and is not asked for a policy.
handler_authorizes is the one policy this module cannot check for you, and the one where the new terms are easy to misread: the link runs no gate, so macula checks NOTHING and hands the handler the call's ucan_token -- the token the caller put on the request, UNVERIFIED, and <<>> when it carried none -- beside proofs and the wire-authenticated caller. The handler must make the check itself, macula_ucan:authorize/3 being what does it; a handler that trusts the token, or the caller, without that check serves everybody. Use it where what admits a call is not visible to a gate — a group prefix inside a sealed payload, say — and remember that a handler which then trusts the token alone loses every check a gate used to make after it.
{ucan_required, IssuerPubkey} is a direct-signature check against ONE pre-known issuer, not a delegation-chain walk — it fits "only this one known identity may call this capability" (an operator-only capability like a corpus-mutating one).
{realm_member_required, RealmDid, RequiredCan} is the "anyone whose UCAN traces back to a trusted realm root" case ucan_required does not cover: a valid token signed by the realm''s own DID (RealmDid — an Ed25519 keypair the realm holds, NOT the 32-byte RealmId routing/scoping hash used elsewhere) whose audience is the wire-authenticated caller itself, at the specific membership tier RequiredCan names (mandatory, no default — a realm mints membership at more than one tier from the same signing key, see the comment on the auth_policy() type in macula_client for why a caller must name the tier it actually needs). The caller side (presenting a token shaped for either policy) shipped in macula-mcp 0.19.0.
call_capability/5,7 resolves 'CapName' under Org and only under Org ('discovery_key_org/3'). There is no bare-key fallback on the read side either: resolve_at/4 looks up exactly one key, and an org that has published nothing there resolves to nothing rather than to somebody else''s registration. resolve_full/4 tags each resolved provider with the wire-level procedure string that matched, and the CALL uses that string rather than the raw CapName, so a targeted call can only ever be answered by that org''s own registration, all the way to the wire.
reuse_sup/0's pid is round-tripped through this worker''s state — one slot per DISTINCT procedure string, which since 11.x means one slot per org-qualified registration — and passed back in as advertise_direct's own 'reuse_sup' option on every 30s republish tick — a station''s wire-level registration for a procedure is tied to the connection that sent it and does not survive that connection being replaced (see macula_response:advertise_direct/7 and an earlier tube service's tube_mesh_providers.erl, which hit this bug live before this option existed); periodic re-advertise without reuse_sup would also leak one factory supervisor per tick.
Every advertisement carries ttl_ms => ?ADVERTISEMENT_TTL_MS (4x the republish interval, leaving the same slack the SDK''s own half-life renewal (macula_station_link, TTL/2) assumes) instead of the ~48h envelope default — a dead service''s advertisement should age out on the order of minutes, not days. The handler-bearing path''s ttl_ms needs macula 10.11.1 or later: earlier releases dropped ttl_ms while macula_direct_dial forwarded the advertisement options; the record-only (no-handler) path builds the record directly and is unaffected by that gap.
lookup/1 resolves a capability by name: derive the same procedure key, read every advertisement stored there, verify each signature, return the {advertiser, serving_station} set.
list_org_capabilities/1 browses every capability an org has advertised — genuinely new, unlike lookup/1/'call_capability': the bare key needs a capability NAME to look anything up, and so does the org-qualified key (discovery_key_org/3, 'Realm/Org/Name' — Name is part of the key, not something a lookup can search past). There is no NAME-less "everything Org has" key to resolve. A DHT-composite-key design (publish the same record again under an org-prefix-only key) — the original plan for this — turned out infeasible: macula_record:storage_key/1 DERIVES a 'procedure_advertisement''s storage key from its own procedure_uri payload, so a record cannot be stored under an independently-chosen key without its procedure_uri field lying about what it actually is. Building a second, genuinely separate DHT record type just for this (with its own write-conflict semantics for multiple advertisers of one org) was judged more than this needs. Instead: list_org_capabilities/1 is a CLIENT-SIDE filter over macula:find_records_by_type/2 (matched via macula_topic_pattern:matches/2) — the exact same local-relay-view, warm-start-only mechanism read_model_services.md already documents for bulk browsing, honestly inheriting its "one relay''s local view, not authoritative" limitation rather than pretending to a DHT-wide index this record type cannot support.
ON A LAN, WHAT IS ADVERTISED DEPENDS ON THE NODE'S ROLE (mcl-core#7, mcl_core_bridge:role/0). standalone (LAN off): every hosted capability, as always. member: nothing; the mesh is its bridge's. bridge: only the capabilities marked export => mesh (mesh_sets/2), the cluster's as well as its own. One the LAN serves is advertised with mcl_core_bridge_inbound, which forwards each mesh call into the LAN with the mesh caller; an exported one the LAN does not serve (a realm-bound auth, a streamer, a record with no handler) is advertised as before, from this node's own services only. Each org advertised is claimed (mcl_core_claim:add_org/1), and rows for a procedure that left the set -- an exported capability whose node went away -- are dropped, so they do not degrade /health.
Signing needs the service''s stable identity key (mcl_core_identity:identity_key/0); an ephemeral service cannot sign and is correctly not advertised.
Summary
Functions
Whether this service''s advertise loop is alive, per org-namespaced procedure, as mcl_core_advertise_liveness entries — the last successful advertise and the last failure. Read from a table, not by a call, for the same reason as provider_grants/0. #{} before anything was advertised (or attempted).
The TTL stamped on every advertisement (4x the republish interval). Held under macula_record:procedure_advertisement_max_lifetime_ms/0 (300s), which macula enforces as a refusal, not a silent clamp.
The auth entry to merge into 'advertise_direct''s Opts, from a handler-bearing capability''s own auth key (open | {callers, members | role | {nodes, Ids}} | handler_authorizes | {ucan_required, Issuer} | {realm_member_required, RealmDid, RequiredCan}), forwarded all the way to macula_station_link's inbound call authorization — see moduledoc.
The names of every capability in Caps that names a handler but no auth policy. macula 18 refuses an advertise that names none ({error, {auth, required}}, macula#147): a procedure served to whoever can reach it is a decision, and an omission is not one. So such a capability fails the registration here, naming itself, rather than reaching the SDK and being refused procedure by procedure on a timer.
Call a capability by name over the DIRECT-DIAL data path: resolve the providers of CapName UNDER 'Org' specifically (their procedure_advertisement records, keyed 'Realm/Org/CapName' — discovery_key_org/3), resolve one provider''s serving station to a dialable endpoint, dial it directly and issue the CALL there. On failure (unresolvable endpoint, dead station, error reply) fail over to the next provider *of the same org* — this never silently falls over to a different org''s own implementation of the same capability name.
Explicit-pool form (testable without mcl_core_identity). Opts: - ucan_token => binary() (presented to a gated provider). - advertiser => <<_:256>> (dial ONLY the provider whose advertisement was published by this node id -- the pin that makes one procedure with many providers addressable, see mcl_core:call_capability/5. A pin that matches no resolved provider fails closed with {error, no_provider}.)
The validity window of the chain a provider_authorization answer carries: the created_at of the record that ends first, and its expires_at, the bound macula signs advertisements under. undefined for no chain or one that does not verify under this node's profile.
The serving station one node names among the connected stations: phash2(NodeId) over the SORTED set, so the pick is stable across republish ticks (links arrive and depart in arbitrary order; the sort removes that noise) and spreads distinct nodes across the stations. Two providers of one procedure with different node ids land on different stations whenever the station set has room -- the deployment half of the many-club contract. Pure.
Cap's 'confidential', merged into advertise_direct's 'Opts' for response AND streamer capabilities. macula 13's provider modes: off (the advertisement names no KEM key, even with kem_advertise enabled), preferred (it names one when kem_advertise is enabled; callers seal) and required (it names one and the provider refuses a clear call). Absent, the Opts are unchanged, which macula reads as preferred. Any other value never gets here: register/1 refuses it at boot (confidentiality_verdict/2); called directly with one, this still refuses it by name.
Whether Caps can be advertised as declared under macula''s kem_advertise setting. Every way this could fail at advertise time would be caught per republish tick as a warning, leaving the service green and unreachable, so register/1 turns each into a boot failure, by name: a confidential that is not one of macula''s provider modes (a typo), a kem_advertise that is not 'enabled' or disabled (macula raises not_a_switch on every advertise), and a required capability while kem_advertise is not enabled (macula refuses it: kem_advertise_disabled).
Cap's 'handler_timeout_ms', merged into advertise_direct's 'Opts': how long macula_response waits for the handler before answering the caller temporary_relay_failure (1 to 600000 ms, macula''s default 30000; macula refuses anything else). Only a response capability has one: macula_streamer takes no such option, so a streamer that sets it is refused by name rather than advertised as if it had taken effect.
Whether Cap carries a handler (and so should be advertised via advertise_direct, not just written to the DHT as a bare discovery record).
Every registered capability, every hosted service's in boot order.
The capabilities advertised under Org, as Org/Name: the sets of every hosted service in that org, a name two of them share once (the first).
Every capability Org has advertised — '{ok, [Advertisement]}', each the record as macula_record:read_procedure_advertisement/1 reads it (realm_id, procedure, advertiser_node, serving_stations) plus the signed record. See moduledoc for why this is a client-side filter over find_records_by_type, not a DHT-indexed query: a WARM-START view of whatever this pool''s connected station(s) locally hold, not an authoritative mesh-wide listing. Empty when nothing matches or the mesh is unreachable, same as lookup/1.
Resolve a capability by name to the providers advertising it. {ok, [#{advertiser := Pubkey, serving_station := Pubkey}]}. Empty when nothing is advertised or the mesh is unreachable.
Whether Procedure (a procedure_advertisement''s own procedure string, Org/Name) matches the 'Org/*' Pattern. Split purely on /. The realm is the record''s own realm_id, checked by the caller.
What a bridge advertises (mcl-core#7): per org, the exported capabilities of its own sets that the LAN does not serve, with their own handler, then every exported capability the LAN serves anywhere in the cluster (mcl_core_lan:exports/0, as {Org, Cap} without a handler), with the forwarding handler and no guard of its own. A name is advertised once per org, the first. An org with nothing exported is left out.
The org-qualified wire-level procedure string a handler-bearing capability''s SECOND advertise_direct registration uses. Deliberately NOT procedure_uri/3's realm-hex-prefixed form: the ADVERTISE/CALL wire frames already carry realm as a separate field (macula_frame:advertise/1), so re-embedding it here would be redundant on every wire message. The DHT KEY still ends up realm-prefixed regardless — see moduledoc, discovery_uri/2 does that wrapping on the publish side, matching discovery_key_org/3 on the read side.
The pin: keep only the provider whose advertisement was published by NodeId. No pin, no filter.
The last macula:provider_authorization/3 answer for each org-namespaced procedure this service advertises, as mcl_core_provider_grant entries. Read from a table, not by a call, so /health never waits behind a republish tick. #{} before anything was advertised.
Which macula provider module advertises Cap's handler -- macula_streamer only when the capability opts in with 'kind => streamer', macula_response (request/reply RPC) otherwise. Every capability declared before kind existed has no such key and keeps advertising through macula_response, unchanged.
Register the capability set of a node hosting one service, under mcl_core's own org. It replaces the set registered this way before.
Register the capability set of the hosted service Key under Org (mcl-om#8). It replaces that service's set and nothing else: every other service's set stays registered and advertised beside it.
?REPUBLISH_INTERVAL_MS +/- up to '?REPUBLISH_JITTER_MS' / 2, uniformly -- see ?REPUBLISH_JITTER_MS's own doc for why a fixed period is the actual bug being fixed here, not just a nice-to-have.
The base re-assert cadence, unjittered. The one knob that sets the advertisement renewal floor every station relays (mcl-om#26): advertisement_ttl_ms/0 is 4x this, and the health windows in mcl_core_advertise_liveness derive from these two so the whole advertise cadence moves together.
Every capability Org has advertised, under 'Realm' — see moduledoc for why this is a client-side filter over find_records_by_type, not a DHT-indexed query.
The extra Opts entry an 'advertise_direct' retry needs to reuse a prior call''s factory supervisor instead of leaking a new one every republish tick. #{} on a capability''s first-ever advertise.
Cap's 'stream_opts' (e.g. #{mode => client_stream}), merged into advertise_direct's 'Opts' only for a kind => streamer capability -- macula_response:advertise_direct has no 'mode' concept and a response-kind capability has no 'stream_opts' to begin with, so this is #{} for every non-streamer capability.
Functions
-spec advertise_liveness() -> #{binary() => mcl_core_advertise_liveness:entry()}.
Whether this service''s advertise loop is alive, per org-namespaced procedure, as mcl_core_advertise_liveness entries — the last successful advertise and the last failure. Read from a table, not by a call, for the same reason as provider_grants/0. #{} before anything was advertised (or attempted).
-spec advertisement_ttl_ms() -> pos_integer().
The TTL stamped on every advertisement (4x the republish interval). Held under macula_record:procedure_advertisement_max_lifetime_ms/0 (300s), which macula enforces as a refusal, not a silent clamp.
-spec auth_opts(mcl_core_service:capability()) -> #{auth := term()}.
The auth entry to merge into 'advertise_direct''s Opts, from a handler-bearing capability''s own auth key (open | {callers, members | role | {nodes, Ids}} | handler_authorizes | {ucan_required, Issuer} | {realm_member_required, RealmDid, RequiredCan}), forwarded all the way to macula_station_link's inbound call authorization — see moduledoc.
THERE IS NO DEFAULT (macula 18, macula#147): macula:advertise/5 refuses an advertise that names no policy, so a handler-bearing capability without auth never gets this far — register/1 refuses it first, naming the capability (auth_verdict/1). This function has no clause for a map without the key: the omission is a boot failure, not a silent open. It is deliberately policy-agnostic — it forwards whatever value auth holds without inspecting which variant it is, so a future policy macula adds needs no change here, only to the mcl_core_service:capability() type.
-spec auth_verdict([mcl_core_service:capability()]) -> ok | {error, {auth_required, [binary()]}}.
The names of every capability in Caps that names a handler but no auth policy. macula 18 refuses an advertise that names none ({error, {auth, required}}, macula#147): a procedure served to whoever can reach it is a decision, and an omission is not one. So such a capability fails the registration here, naming itself, rather than reaching the SDK and being refused procedure by procedure on a timer.
Only a HANDLER-BEARING capability is asked: a capability with no handler is written as a bare discovery record (build_advertisement/5 + put_record), which the SDK does not gate, so requiring a policy for it would refuse a boot over something nothing can call. open is one of the policies a service may name, and the point of asking is that somebody wrote it down.
-spec build_advertisement(macula_node_keys:node_key(), binary(), binary(), mcl_core_service:capability(), <<_:256>>) -> map().
-spec call_capability(binary(), binary(), term(), pos_integer(), map()) -> {ok, term()} | {error, term()}.
Call a capability by name over the DIRECT-DIAL data path: resolve the providers of CapName UNDER 'Org' specifically (their procedure_advertisement records, keyed 'Realm/Org/CapName' — discovery_key_org/3), resolve one provider''s serving station to a dialable endpoint, dial it directly and issue the CALL there. On failure (unresolvable endpoint, dead station, error reply) fail over to the next provider *of the same org* — this never silently falls over to a different org''s own implementation of the same capability name.
Falls back to the bare, any-provider key (discovery_key/2) only when Org has published no org-qualified advertisement at all — a fleet mid-migration onto this org-scoping keeps resolving exactly as it did before this existed. Once Org is genuinely irrelevant to you (any provider will do, e.g. a realm-wide commodity capability), pass whatever value is convenient; it only narrows the search, it never widens it beyond what an org-blind lookup would already find.
The CALL uses whichever wire-level procedure string actually resolved (resolve_full/4 tags each provider with it) — 'org_procedure(Org, CapName)' on an org-scoped hit, the bare CapName only on the any-provider fallback — matching whichever registration that specific provider made via advertise_one/7. Org-scoping therefore changes both WHICH station gets dialed AND what''s sent once dialed; a targeted call can only ever be answered by that org''s own registration, never a different org''s provider sharing the same station. Runs in the caller''s process (not the capabilities gen_server), so a slow mesh never blocks capability registration.
-spec call_capability(pid(), binary(), binary(), binary(), term(), pos_integer(), map()) -> {ok, term()} | {error, term()}.
Explicit-pool form (testable without mcl_core_identity). Opts: - ucan_token => binary() (presented to a gated provider). - advertiser => <<_:256>> (dial ONLY the provider whose advertisement was published by this node id -- the pin that makes one procedure with many providers addressable, see mcl_core:call_capability/5. A pin that matches no resolved provider fails closed with {error, no_provider}.)
{error, no_provider} is reserved for "nothing to dial": no provider resolved, or the pin matched none. A provider that WAS dialed reports its own failure ({error, timeout}, '{error, {station_endpoint, Reason}}', a call error...) -- see call_providers/7 for why the two must never collapse into one.
There is no TLS mode to choose. The 10.x verify => true cert-chain form went with the cert authorization form, and macula 12 refuses verify in any value: the trust check is the D25 authorization the pool verifies against its realm_trust keys, plus the pinned expected_node_id below.
-spec chain_window({ok, term()} | {error, term()}) -> mcl_core_provider_grant:window().
The validity window of the chain a provider_authorization answer carries: the created_at of the record that ends first, and its expires_at, the bound macula signs advertisements under. undefined for no chain or one that does not verify under this node's profile.
-spec choose_serving_station(<<_:256>>, [<<_:256>>]) -> <<_:256>>.
The serving station one node names among the connected stations: phash2(NodeId) over the SORTED set, so the pick is stable across republish ticks (links arrive and depart in arbitrary order; the sort removes that noise) and spreads distinct nodes across the stations. Two providers of one procedure with different node ids land on different stations whenever the station set has room -- the deployment half of the many-club contract. Pure.
-spec confidentiality_opts(mcl_core_service:capability()) -> map().
Cap's 'confidential', merged into advertise_direct's 'Opts' for response AND streamer capabilities. macula 13's provider modes: off (the advertisement names no KEM key, even with kem_advertise enabled), preferred (it names one when kem_advertise is enabled; callers seal) and required (it names one and the provider refuses a clear call). Absent, the Opts are unchanged, which macula reads as preferred. Any other value never gets here: register/1 refuses it at boot (confidentiality_verdict/2); called directly with one, this still refuses it by name.
-spec confidentiality_verdict([mcl_core_service:capability()], term()) -> ok | {error, {mcl_core_confidential_not_a_provider_mode | mcl_core_kem_advertise_not_a_switch | mcl_core_confidential_required_without_kem_advertise, map()}}.
Whether Caps can be advertised as declared under macula''s kem_advertise setting. Every way this could fail at advertise time would be caught per republish tick as a warning, leaving the service green and unreachable, so register/1 turns each into a boot failure, by name: a confidential that is not one of macula''s provider modes (a typo), a kem_advertise that is not 'enabled' or disabled (macula raises not_a_switch on every advertise), and a required capability while kem_advertise is not enabled (macula refuses it: kem_advertise_disabled).
-spec handler_timeout_opts(mcl_core_service:capability()) -> map().
Cap's 'handler_timeout_ms', merged into advertise_direct's 'Opts': how long macula_response waits for the handler before answering the caller temporary_relay_failure (1 to 600000 ms, macula''s default 30000; macula refuses anything else). Only a response capability has one: macula_streamer takes no such option, so a streamer that sets it is refused by name rather than advertised as if it had taken effect.
-spec has_handler(mcl_core_service:capability()) -> boolean().
Whether Cap carries a handler (and so should be advertised via advertise_direct, not just written to the DHT as a bare discovery record).
Every registered capability, every hosted service's in boot order.
-spec list(binary()) -> [mcl_core_service:capability()].
The capabilities advertised under Org, as Org/Name: the sets of every hosted service in that org, a name two of them share once (the first).
Every capability Org has advertised — '{ok, [Advertisement]}', each the record as macula_record:read_procedure_advertisement/1 reads it (realm_id, procedure, advertiser_node, serving_stations) plus the signed record. See moduledoc for why this is a client-side filter over find_records_by_type, not a DHT-indexed query: a WARM-START view of whatever this pool''s connected station(s) locally hold, not an authoritative mesh-wide listing. Empty when nothing matches or the mesh is unreachable, same as lookup/1.
Resolve a capability by name to the providers advertising it. {ok, [#{advertiser := Pubkey, serving_station := Pubkey}]}. Empty when nothing is advertised or the mesh is unreachable.
The resolve runs inside the capabilities gen_server, bounded at ?RESOLVE_BUDGET_MS wall clock (see find/2); the caller waits at most ?LOOKUP_CALL_TIMEOUT_MS, well past that bound, so a slow DHT degrades this call instead of wedging the server behind it (issue #5).
Whether Procedure (a procedure_advertisement''s own procedure string, Org/Name) matches the 'Org/*' Pattern. Split purely on /. The realm is the record''s own realm_id, checked by the caller.
-spec mesh_sets([{binary(), [mcl_core_service:capability()]}], [{binary(), mcl_core_service:capability()}]) -> [{binary(), [mcl_core_service:capability()]}].
What a bridge advertises (mcl-core#7): per org, the exported capabilities of its own sets that the LAN does not serve, with their own handler, then every exported capability the LAN serves anywhere in the cluster (mcl_core_lan:exports/0, as {Org, Cap} without a handler), with the forwarding handler and no guard of its own. A name is advertised once per org, the first. An org with nothing exported is left out.
The org-qualified wire-level procedure string a handler-bearing capability''s SECOND advertise_direct registration uses. Deliberately NOT procedure_uri/3's realm-hex-prefixed form: the ADVERTISE/CALL wire frames already carry realm as a separate field (macula_frame:advertise/1), so re-embedding it here would be redundant on every wire message. The DHT KEY still ends up realm-prefixed regardless — see moduledoc, discovery_uri/2 does that wrapping on the publish side, matching discovery_key_org/3 on the read side.
The pin: keep only the provider whose advertisement was published by NodeId. No pin, no filter.
-spec provider_grants() -> #{binary() => mcl_core_provider_grant:entry()}.
The last macula:provider_authorization/3 answer for each org-namespaced procedure this service advertises, as mcl_core_provider_grant entries. Read from a table, not by a call, so /health never waits behind a republish tick. #{} before anything was advertised.
-spec provider_module(mcl_core_service:capability()) -> module().
Which macula provider module advertises Cap's handler -- macula_streamer only when the capability opts in with 'kind => streamer', macula_response (request/reply RPC) otherwise. Every capability declared before kind existed has no such key and keeps advertising through macula_response, unchanged.
Register the capability set of a node hosting one service, under mcl_core's own org. It replaces the set registered this way before.
-spec register(term(), env | binary(), [mcl_core_service:capability()]) -> ok.
Register the capability set of the hosted service Key under Org (mcl-om#8). It replaces that service's set and nothing else: every other service's set stays registered and advertised beside it.
-spec republish_delay_ms() -> pos_integer().
?REPUBLISH_INTERVAL_MS +/- up to '?REPUBLISH_JITTER_MS' / 2, uniformly -- see ?REPUBLISH_JITTER_MS's own doc for why a fixed period is the actual bug being fixed here, not just a nice-to-have.
-spec republish_interval_ms() -> pos_integer().
The base re-assert cadence, unjittered. The one knob that sets the advertisement renewal floor every station relays (mcl-om#26): advertisement_ttl_ms/0 is 4x this, and the health windows in mcl_core_advertise_liveness derive from these two so the whole advertise cadence moves together.
Every capability Org has advertised, under 'Realm' — see moduledoc for why this is a client-side filter over find_records_by_type, not a DHT-indexed query.
The extra Opts entry an 'advertise_direct' retry needs to reuse a prior call''s factory supervisor instead of leaking a new one every republish tick. #{} on a capability''s first-ever advertise.
-spec stream_opts(mcl_core_service:capability()) -> map().
Cap's 'stream_opts' (e.g. #{mode => client_stream}), merged into advertise_direct's 'Opts' only for a kind => streamer capability -- macula_response:advertise_direct has no 'mode' concept and a response-kind capability has no 'stream_opts' to begin with, so this is #{} for every non-streamer capability.