mcl_core_provider_grant (mcl_core v1.0.0)

View Source

Whether this service holds the D25 grant each of its org-namespaced procedures needs, and what that means for /health.

A provider with no grant used to look healthy while serving nothing: the advertise path asked macula:provider_authorization/3 on every republish tick, dropped the refusal, and retried quietly. That answer is kept now, per procedure, and judged here:

- no procedure_delegation naming this node: degraded at once. The realm has the service's claim on file and an operator has to grant it; nothing will change until someone does. - no org configured (org_unset, recorded by mcl_core_capabilities, which then advertises nothing): degraded at once; an operator sets the org. - no org_directory, or any other refusal: waiting for a grace window (provider_grant_grace_ms, default 60 s), then degraded. The realm republishes an absent chain within seconds, so a gap that outlasts the window is a real fault, while a lookup that fails once should not flap /health. The reason is macula's, as given.

The window runs from the FIRST failure of an unbroken run, so a gap that fails on every tick still comes due, and a grant resets it.

Pure: the caller supplies the clock. mcl_core_capabilities records one entry per procedure per tick; mcl_core_health judges them on read, so /health changes the moment a window closes, not at the next tick.

Summary

Functions

Where a chain stands at wall-clock SysNow: fresh with more than a third of its life left, expiring with a third or less (a healthy realm reissues every 10 min, so a 30-min delegation never gets there), expired past its bound, unknown with no chain.

The grace window from mcl_core app env, default 60 s.

The entry for one procedure, from its provider_authorization answer at Now (monotonic), the window of the chain it carries (undefined when there is none), and its previous entry (undefined on the first tick). A refusal keeps the previous window: the registration still carries that chain until its bound passes.

Every procedure with its state, for /health to list whatever the verdict: a service inside its window is ok and still says why, and a procedure with a chain says when it ends.

ok, or {degraded, #{provider_grants => Failing}} naming each procedure that is past waiting, or whose chain is expiring or expired, with the cause an operator acts on.

Types

clock/0

-type clock() :: #{mono := integer(), sys := integer()}.

entry/0

-type entry() ::
          #{result := granted | {not_granted, term()},
            since := integer() | undefined,
            window := window()}.

window/0

-type window() :: {CreatedAt :: integer(), NotAfter :: integer()} | undefined.

Functions

expiry(Window, SysNow)

-spec expiry(window(), integer()) -> fresh | expiring | expired | unknown.

Where a chain stands at wall-clock SysNow: fresh with more than a third of its life left, expiring with a third or less (a healthy realm reissues every 10 min, so a 30-min delegation never gets there), expired past its bound, unknown with no chain.

grace_ms()

-spec grace_ms() -> non_neg_integer().

The grace window from mcl_core app env, default 60 s.

observed(_, Window, Now, Previous)

-spec observed({ok, term()} | {error, term()}, window(), integer(), entry() | undefined) -> entry().

The entry for one procedure, from its provider_authorization answer at Now (monotonic), the window of the chain it carries (undefined when there is none), and its previous entry (undefined on the first tick). A refusal keeps the previous window: the registration still carries that chain until its bound passes.

report(Entries, Clock, GraceMs)

-spec report(#{binary() => entry()}, clock(), non_neg_integer()) -> [map()].

Every procedure with its state, for /health to list whatever the verdict: a service inside its window is ok and still says why, and a procedure with a chain says when it ends.

verdict(Entries, Clock, GraceMs)

-spec verdict(#{binary() => entry()}, clock(), non_neg_integer()) ->
                 ok | {degraded, #{provider_grants := [map()]}}.

ok, or {degraded, #{provider_grants => Failing}} naming each procedure that is past waiting, or whose chain is expiring or expired, with the cause an operator acts on.