Fief.Authority.Local (Fief v0.1.0)

Copy Markdown View Source

Single-process, in-memory implementation of the three Authority contracts (implementation.md §3.2). It exists for three reasons: executable reference semantics for the contracts, unit tests without Postgres, and single-node development. Not for production multi-node use — it is itself a SPOF with none of Postgres's durability.

Lease and leadership expiry are judged on Fief.Seam read in this process, so under simulation the arbiter's clock is virtual and steppable — and may be skewed against per-node virtual clocks (design §6.4). Test seams (undocumented, test-substrate only):

Summary

Functions

Returns a specification to start this module under a supervisor.

Current leader per Fief.Leadership.leader/1 semantics.

Simulate arbiter unreachability for node_id (or :all). Test substrate.

Campaign for leadership. Grants (with a fresh monotonic term) if the seat is empty or expired; renews (same term) if node_id already holds it; otherwise {:error, {:held, holder, term}}.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

leader(store)

Current leader per Fief.Leadership.leader/1 semantics.

set_unreachable(store, node_id \\ :all, flag)

Simulate arbiter unreachability for node_id (or :all). Test substrate.

start_link(opts \\ [])

try_lead(store, node_id, ttl_ms)

Campaign for leadership. Grants (with a fresh monotonic term) if the seat is empty or expired; renews (same term) if node_id already holds it; otherwise {:error, {:held, holder, term}}.