Files
ha/doc.go
T
zeekay f583260ce2 ha: single-writer election, decomplected from vfs
HRW (Rendezvous) single-writer election as its own coordination primitive
— no coordinator, lock service, Postgres, or Redis. Answers "who is the
single writer for key K" identically on every replica.

Extracted from hanzoai/vfs/replica/owner.go (HIP-0107), which was
storage-agnostic pure Go with no vfs-internal callers. Election (who
writes) and replication (how state ships) are orthogonal; this is the cut.
Generalizes orgID -> key (any ownership unit).

API: Member, Owner, IsOwner, Replicas + the Membership seam + Static.
Zero deps (stdlib crypto/sha256, encoding/binary, context).
2026-07-08 18:35:29 -07:00

23 lines
1.2 KiB
Go

// Copyright 2025 Hanzo AI Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// Package ha is Hanzo's high-availability coordination primitive: single-writer
// election over a live membership set, with no coordinator, no lock service, no
// Postgres, no Redis. It answers one question identically on every replica —
// "which replica is the single writer for key K right now?" — via Rendezvous
// (Highest-Random-Weight) hashing, so N stateless replicas agree on one owner per
// key and fail over deterministically with no recomputation.
//
// ha decides WHO writes; it never touches HOW state is stored or replicated. That
// separation is the point: compose ha with hanzoai/vfs (per-org SQLite + object
// store) for HA storage, or with a cron tick, a queue consumer, or any singleton
// that must run exactly once across a multi-replica Deployment. The same election
// guards all of them.
//
// The seam is Membership: election is a pure function of (key, []Member), and a
// Membership supplies the live set. Wire a cluster source (hanzoai/ha/k8s) in
// production, or Static for a single process and tests.
package ha