FAILURE MAP
← Case archive

FA-396 / Consensus / Open access

Transfer leadership to a chosen voter: A transfer races outstanding leader writes · case 01

The leader transfer operation is admitted even though a transfer races outstanding leader writes.

Verified by executionVariant 1 · 9 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The admission path omits the writes drained invariant while validating the other operation preconditions.

VERIFIED REPAIR

Require r['writes_drained'] == 0 together with every other stated precondition before accepting the operation.

Unsuccessful approach: Adding the writes drained check repairs the reported defect, but replacing the adjacent target voter check loses that independent invariant.

Case contract

Return a Boolean admission decision for transfer leadership to a chosen voter. The record r must satisfy all of: r['target_voter'][0] in r['target_voter'][1]; r['log_caught_up'][0] >= r['log_caught_up'][1]; r['transfer_term'][0] == r['transfer_term'][1]; r['transfer_deadline'][0] < r['transfer_deadline'][1]; r['writes_drained'] == 0. Extra tracing fields are ignored; validation does not mutate the record.

Why this case matters

A deterministic local contract for consensus. Each negative fixture violates exactly one invariant. No transport timing, persistence, cryptographic verification, or full protocol implementation is claimed.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(r):
    return (r['target_voter'][0] in r['target_voter'][1]) and (r['log_caught_up'][0] >= r['log_caught_up'][1]) and (r['transfer_term'][0] == r['transfer_term'][1]) and (r['transfer_deadline'][0] < r['transfer_deadline'][1])
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
r = {'target_voter': ['b', ['a', 'b']], 'log_caught_up': [12, 12], 'transfer_term': [4, 4], 'transfer_deadline': [9, 10], 'writes_drained': 0}
check('valid operation', solve(r), True)
check('Leadership is handed to a learner', solve(dict(r, **{'target_voter': ['c', ['a', 'b']]})), False)
check('The target lacks the leader final log entry', solve(dict(r, **{'log_caught_up': [11, 12]})), False)
check('A delayed handoff names an obsolete term', solve(dict(r, **{'transfer_term': [3, 4]})), False)
check('The handoff arrives after its transfer deadline', solve(dict(r, **{'transfer_deadline': [10, 10]})), False)
check('A transfer races outstanding leader writes', solve(dict(r, **{'writes_drained': 1})), False)
check('unrelated tracing metadata', solve(dict(r, trace='run-'+str(N))), True)
check('repeat validation is pure', solve(r), True)
invalid = {'target_voter': ['c', ['a', 'b']], 'log_caught_up': [11, 12], 'transfer_term': [3, 4], 'transfer_deadline': [10, 10], 'writes_drained': 1}
keys = list(invalid)
pair = {keys[N % len(keys)]: invalid[keys[N % len(keys)]], keys[(N+1) % len(keys)]: invalid[keys[(N+1) % len(keys)]]}
check('two independent violations in variant', solve(dict(r, **pair)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
valid operationTrueTruePassed
Leadership is handed to a learnerFalseFalsePassed
The target lacks the leader final log entryFalseFalsePassed
A delayed handoff names an obsolete termFalseFalsePassed
The handoff arrives after its transfer deadlineFalseFalsePassed
A transfer races outstanding leader writesTrueFalseFailed
unrelated tracing metadataTrueTruePassed
repeat validation is pureTrueTruePassed
two independent violations in variantFalseFalsePassed

SHA-256 / 86676ed60b426f29fbdf75068c1b7cf2aa0b05be78e98ccb715231a0fa752b13

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(r):
    return (r['log_caught_up'][0] >= r['log_caught_up'][1]) and (r['transfer_term'][0] == r['transfer_term'][1]) and (r['transfer_deadline'][0] < r['transfer_deadline'][1]) and (r['writes_drained'] == 0)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
r = {'target_voter': ['b', ['a', 'b']], 'log_caught_up': [12, 12], 'transfer_term': [4, 4], 'transfer_deadline': [9, 10], 'writes_drained': 0}
check('valid operation', solve(r), True)
check('Leadership is handed to a learner', solve(dict(r, **{'target_voter': ['c', ['a', 'b']]})), False)
check('The target lacks the leader final log entry', solve(dict(r, **{'log_caught_up': [11, 12]})), False)
check('A delayed handoff names an obsolete term', solve(dict(r, **{'transfer_term': [3, 4]})), False)
check('The handoff arrives after its transfer deadline', solve(dict(r, **{'transfer_deadline': [10, 10]})), False)
check('A transfer races outstanding leader writes', solve(dict(r, **{'writes_drained': 1})), False)
check('unrelated tracing metadata', solve(dict(r, trace='run-'+str(N))), True)
check('repeat validation is pure', solve(r), True)
invalid = {'target_voter': ['c', ['a', 'b']], 'log_caught_up': [11, 12], 'transfer_term': [3, 4], 'transfer_deadline': [10, 10], 'writes_drained': 1}
keys = list(invalid)
pair = {keys[N % len(keys)]: invalid[keys[N % len(keys)]], keys[(N+1) % len(keys)]: invalid[keys[(N+1) % len(keys)]]}
check('two independent violations in variant', solve(dict(r, **pair)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
valid operationTrueTruePassed
Leadership is handed to a learnerTrueFalseFailed
The target lacks the leader final log entryFalseFalsePassed
A delayed handoff names an obsolete termFalseFalsePassed
The handoff arrives after its transfer deadlineFalseFalsePassed
A transfer races outstanding leader writesFalseFalsePassed
unrelated tracing metadataTrueTruePassed
repeat validation is pureTrueTruePassed
two independent violations in variantFalseFalsePassed

SHA-256 / 8fb5f85ff2afe2cb770bd63ddbd75576dff157cd6de9ccf74e06b61011ac0b77

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(r):
    return (r['target_voter'][0] in r['target_voter'][1]) and (r['log_caught_up'][0] >= r['log_caught_up'][1]) and (r['transfer_term'][0] == r['transfer_term'][1]) and (r['transfer_deadline'][0] < r['transfer_deadline'][1]) and (r['writes_drained'] == 0)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
r = {'target_voter': ['b', ['a', 'b']], 'log_caught_up': [12, 12], 'transfer_term': [4, 4], 'transfer_deadline': [9, 10], 'writes_drained': 0}
check('valid operation', solve(r), True)
check('Leadership is handed to a learner', solve(dict(r, **{'target_voter': ['c', ['a', 'b']]})), False)
check('The target lacks the leader final log entry', solve(dict(r, **{'log_caught_up': [11, 12]})), False)
check('A delayed handoff names an obsolete term', solve(dict(r, **{'transfer_term': [3, 4]})), False)
check('The handoff arrives after its transfer deadline', solve(dict(r, **{'transfer_deadline': [10, 10]})), False)
check('A transfer races outstanding leader writes', solve(dict(r, **{'writes_drained': 1})), False)
check('unrelated tracing metadata', solve(dict(r, trace='run-'+str(N))), True)
check('repeat validation is pure', solve(r), True)
invalid = {'target_voter': ['c', ['a', 'b']], 'log_caught_up': [11, 12], 'transfer_term': [3, 4], 'transfer_deadline': [10, 10], 'writes_drained': 1}
keys = list(invalid)
pair = {keys[N % len(keys)]: invalid[keys[N % len(keys)]], keys[(N+1) % len(keys)]: invalid[keys[(N+1) % len(keys)]]}
check('two independent violations in variant', solve(dict(r, **pair)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
valid operationTrueTruePassed
Leadership is handed to a learnerFalseFalsePassed
The target lacks the leader final log entryFalseFalsePassed
A delayed handoff names an obsolete termFalseFalsePassed
The handoff arrives after its transfer deadlineFalseFalsePassed
A transfer races outstanding leader writesFalseFalsePassed
unrelated tracing metadataTrueTruePassed
repeat validation is pureTrueTruePassed
two independent violations in variantFalseFalsePassed

SHA-256 / 4ce9e53377245e383b22d77dc0c1cb278b244dc64ac833b4e8de485fbcbfaf8f

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:36:52.627593+00:00.

Case digest / 8b5df21a50232cc6905a81d1956bd59d53ab62b26c9185e497ca4905c018e31a