PRO

Effect Leader Lease Election

Leader election that recovers from a dead leader and fences a zombie one. A plain lock leader that crashes without releasing holds the role forever; a time-bounded lease expires unless renewed, so a dead leader's grip lapses and a follower wins the next election with no human. A leader that pauses past its lease (GC, VM freeze) and resumes must not act on stale authority: every lease carries a monotonic fencing token, and the protected resource rejects any write stamped below the highest token it has seen. The demo elects one leader from a contested lease, hands off after a lapse, and fences a thawed zombie's overwrite. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add @compronents/effect-leader-lease-election

Installs from ui.aryank.space. Needs a registry token and a one-time @compronents entry in components.json. The docs walk through both.

Visualization
guard
zombie write
Effect<void, never>
resource owner
a
resource.write(staleValue) // no token check

The old leader froze past its lease, node-b took over, then node-a thawed and wrote with stale authority. Without a fencing token the resource accepts it, rolling the value backward.

Files
Checking access…
Dependencies