Skip to content

agenticraft_foundation.specifications.weighted_consensus_spec

Weighted quorum consensus — quality-weighted agents with \(2W/3\) quorum threshold for agreement, validity, and quorum intersection.

Weighted Byzantine Fault Tolerance specifications.

Extends consensus specifications with quality-weighted quorum consensus.

Key concepts: - Each agent has a weight w_i based on historical reliability - Weighted quorum requires total weight >= 2W/3 (not just count) - Weight-based leader rotation for liveness

References: - Cachin et al. (2000) - Random oracles in Constantinople - Malkhi & Reiter (1998) - Byzantine quorum systems

WeightedConsensusState dataclass

Consensus state with per-agent quality weights.

Extends ConsensusState with weight information for quality-weighted quorum consensus.

consensus_state instance-attribute

Underlying consensus state

weights = field(default_factory=dict) class-attribute instance-attribute

Per-agent quality weights (w_i). Higher = more reliable.

weight_history = field(default_factory=dict) class-attribute instance-attribute

Historical weight records per agent

total_weight property

Total weight W = sum(w_i).

quorum_threshold property

Weighted quorum threshold: 2W/3.

weight_of(participant)

Get weight of a participant (default 1.0).

weight_of_set(participants)

Get total weight of a set of participants.

is_quorum(participants)

Check if a set of participants forms a weighted quorum.

decided_weight()

Total weight of participants that have decided.

WeightedAgreement

Bases: FormalProperty[Any]

Weighted Agreement: Correct processes with sufficient weight agree.

For weighted quorum systems, agreement is enforced among processes whose combined weight exceeds the quorum threshold.

__init__(min_agreement_weight=None)

Initialize WeightedAgreement.

PARAMETER DESCRIPTION
min_agreement_weight

Minimum combined weight for agreement. If None, uses 2W/3 threshold.

TYPE: float | None DEFAULT: None

check(state, **kwargs)

Check weighted agreement property.

Accepts WeightedConsensusState via kwargs['weighted_state'] or wraps a regular ConsensusState with unit weights.

WeightedValidity

Bases: FormalProperty[Any]

Weighted Validity: Decided value was proposed by a weighted quorum.

Strengthens standard validity — the decided value must have been proposed by a set of processes with sufficient combined weight.

__init__(min_proposal_weight=None)

Initialize WeightedValidity.

PARAMETER DESCRIPTION
min_proposal_weight

Minimum weight of proposers for validity. If None, any single proposer suffices (standard validity).

TYPE: float | None DEFAULT: None

check(state, **kwargs)

Check weighted validity.

WeightedQuorum

Bases: FormalProperty[Any]

Weighted Quorum intersection property.

Verifies that any two quorums have sufficient intersection weight to guarantee agreement. For BFT: any two quorums must share honest weight > W/3.

__init__(byzantine_weight=0.0)

Initialize WeightedQuorum.

PARAMETER DESCRIPTION
byzantine_weight

Maximum total weight of Byzantine processes.

TYPE: float DEFAULT: 0.0

check(state, **kwargs)

Check quorum intersection property.

Verifies: For any two quorums Q1, Q2: weight(Q1 ∩ Q2) > byzantine_weight

select_weighted_leader(weighted_state, round_number)

Select leader based on weight-proportional rotation.

Higher-weight agents get selected more frequently.

PARAMETER DESCRIPTION
weighted_state

Weighted consensus state

TYPE: WeightedConsensusState

round_number

Current round number

TYPE: int

RETURNS DESCRIPTION
str

ID of selected leader