mcl_core_advertise_liveness (mcl_core v1.0.0)
View SourceWhether this service's advertise loop is alive, per capability, and what that means for /health.
The grants table answers "does the realm authorize this provider" (mcl_core_provider_grant). This answers "is the provider's own advertise loop actually running": mcl_core_capabilities records the last advertise outcome per org-namespaced procedure on every republish tick, and /health judges the entries here.
Why it exists: an advertise loop can be dead while everything else is green. A provider whose republish timer stopped (found live 2026-09-25, beam03: the loop went silent after a pre-grant advertise failure) still answered /health ok with failed_publishes: 0 -- zero is exactly what a loop that makes no attempts produces. The last successful advertise's age is the signal: a healthy loop republishes every republish interval, so a success older than the advertisement TTL (four intervals) means this service's own advertise loop is dead or stuck -- whatever the grants say. (The SDK link renews a live advertisement on its own half-life timer, so a stale window here is specifically "mcl-core's loop stopped re-asserting", not every possible mesh failure.)
Judging rules (the caller supplies the clock, like mcl_core_provider_grant):
- alive: a success within stale_after_ms/0. - stale: a success older than that -- the record has expired and the loop is not replacing it. Degraded at once. - never_succeeded: attempts have failed but none has succeeded. Degraded once the failure run is older than grace_ms/0 (two republish intervals, so a cold boot gets two attempts): a pre-grant boot fails its first advertises for reasons the grants already report, and one transient failure should not flap /health.
A procedure with no entry at all has never been attempted (or its service just booted): not listed, and not degrading -- the first tick writes the first entry.
Summary
Functions
The grace window for a never-succeeded procedure, from mcl_core app env, defaulting to two republish intervals: a cold boot gets two advertise attempts before a never-succeeded loop degrades /health.
The entry for one procedure, from its advertise outcome at Now (monotonic ms) and its previous entry (undefined on the first tick). A success clears the failure; a failure leaves the last success in place, so an alive-then-failing loop still ages its last success toward stale.
Every procedure with its state, for /health to list whatever the verdict: a procedure inside its grace window is ok and still says what its loop last did. The report shows the raw state (alive | stale | never_succeeded); the verdict separately grace-buffers never_succeeded.
The staleness window from mcl_core app env, defaulting to the advertisement record's TTL (mcl_core_capabilities:advertisement_ttl_ms/0, four republish intervals). Not a second copy of the TTL: it tracks the one cadence knob, so raising the republish interval widens this window with it and a single missed tick never trips /health (mcl-om#26).
ok, or {degraded, #{advertise_liveness => Failing}} naming each procedure whose loop is stale or has never succeeded past the grace window.
Types
Functions
-spec grace_ms() -> non_neg_integer().
The grace window for a never-succeeded procedure, from mcl_core app env, defaulting to two republish intervals: a cold boot gets two advertise attempts before a never-succeeded loop degrades /health.
The entry for one procedure, from its advertise outcome at Now (monotonic ms) and its previous entry (undefined on the first tick). A success clears the failure; a failure leaves the last success in place, so an alive-then-failing loop still ages its last success toward stale.
-spec report(#{binary() => entry()}, integer(), non_neg_integer()) -> [map()].
Every procedure with its state, for /health to list whatever the verdict: a procedure inside its grace window is ok and still says what its loop last did. The report shows the raw state (alive | stale | never_succeeded); the verdict separately grace-buffers never_succeeded.
-spec stale_after_ms() -> non_neg_integer().
The staleness window from mcl_core app env, defaulting to the advertisement record's TTL (mcl_core_capabilities:advertisement_ttl_ms/0, four republish intervals). Not a second copy of the TTL: it tracks the one cadence knob, so raising the republish interval widens this window with it and a single missed tick never trips /health (mcl-om#26).
-spec verdict(#{binary() => entry()}, integer(), non_neg_integer()) -> ok | {degraded, #{advertise_liveness := [map()]}}.
ok, or {degraded, #{advertise_liveness => Failing}} naming each procedure whose loop is stale or has never succeeded past the grace window.