enroll

suspend fun enroll(replica: ReplicaId, timeout: Duration? = null): ControlOutcome

Add replica to the log-known roster, serialized through the log — the set a later barrier quantifies its acknowledgments over (docs/heddle-ledger-relocation-design.md §6.2). Idempotent: enrolling an already-enrolled replica is ControlOutcome.Applied.

Any peer may enroll any replica, because enrolling only ever enlarges that set: a wrong enroll makes a barrier wait for a promise that never comes (a liveness cost, and the same class as an unreachable enrolled peer), never lets one complete without a promise it needed.

A peer must enroll before it authors any entitlement, and that is now structural. The roster is what makes "every writer has promised" a well-defined question; a replica that spends, delegates, or completes without being enrolled is a writer no barrier is waiting for (§13.2). So enrolling self is what opens this node's isWritable boot gate — until it returns ControlOutcome.Applied here, reserve and schedule answer GateClosed and author nothing.

It doubles as the §6.5.3 boot-ordering fence: ControlOutcome.Applied comes back only once this peer's apply loop has applied the entry, and Raft applies in index order, so a peer that has applied its own enroll has applied every entry before it — every quiesce mark this incarnation lost to a restart is restored before the first mutator can run. Do it on every boot, including a restart where the replica is already enrolled: the fold is then idempotent, but the act still commits, still applies, and opens the gate unless a later departure has already closed it, or this peer has halted at a log entry it cannot read, in which case the call is refused without proposing (and it is also what re-attaches a lost peer's detector, #1652).

The gate opens on this run's own applied enroll and nothing else: a third party enrolling this replica proves nothing about what this run has applied, and neither does an enroll an earlier run left in the log. A timeout does not stop it opening: the entry may apply after this call has thrown, and the gate opens then.