Skip to main content

Consensus Calculator for MoE Classification System.

Implements the consensus algorithm specified in ADR-019:

  • Weighted voting based on analyst confidence
  • Agreement ratio calculation
  • Threshold-based auto-approval
  • Judge aggregation for final decision
  • Debate protocol for judge disagreement (H.3.3)

File: consensus.py

Classes

ConsensusConfig

Configuration for consensus calculation.

ConsensusCalculator

Calculates consensus from analyst votes and judge decisions.

Functions

enable_debate_protocol(orchestrator, evaluation_callback)

Enable debate protocol for judge disagreement resolution.

calculate_from_votes(votes)

Calculate initial consensus from analyst votes only.

apply_judge_decisions(result, decisions)

Apply judge decisions to finalize consensus.

get_detailed_breakdown(votes)

Get detailed breakdown of vote distribution.

convert_decisions_to_evaluations(decisions)

Convert JudgeDecision objects to JudgeEvaluation for debate protocol.

convert_evaluations_to_decisions(evaluations)

Convert JudgeEvaluation objects back to JudgeDecision after debate.

check_debate_needed(decisions)

Check if debate is needed for the given judge decisions.