# Class WeightedVoting

Weighted Byzantine voting implementation. Implements CP-WBFT pattern for fault-tolerant multi-agent consensus.

#### Implements

- IWeightedVoting

- Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:52

##### Index

### Constructors

constructor

### Methods

calculateWeight
updatePerformance
weightedConsensus
registerAgent
getAgentRecord
flagByzantine
getAllRecords
canVote
recalibrateWeights

## Constructors

### constructor

- new WeightedVoting(options?: WeightedVotingOptions): WeightedVoting

  #### Parameters

  - options: WeightedVotingOptions = {}

  #### Returns WeightedVoting

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:58

## Methods

### calculateWeight

- calculateWeight(agentId: string): number

  Calculate vote weight for an agent

  #### Parameters

  - agentId: string

  #### Returns number

  Implementation of IWeightedVoting.calculateWeight

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:68

### updatePerformance

- updatePerformance(
  agentId: string,
  outcome: "unknown" | "success" | "failure" | "partial",
  ): void

  Update agent performance based on task outcome

  #### Parameters

  - agentId: string
  - outcome: "unknown" | "success" | "failure" | "partial"

  #### Returns void

  Implementation of IWeightedVoting.updatePerformance

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:74

### weightedConsensus

- weightedConsensus(
  votes: ReadonlyMap<
  string,
  {
  decision: "approve"
  | "reject"
  | "abstain";
  reasoning: string;
  confidence: number;
  conditions?: string[];
  rejectionCategories?: (
  | "YAGNI"
  | "DRY_VIOLATION"
  | "OVER_ENGINEERING"
  | "SCOPE_CREEP"
  | "SECURITY_RISK"
  | "MISALIGNED"
  | "INSUFFICIENT_EVIDENCE"
  )[];
  findings?: {
  summary: string;
  location: string;
  severity: "low"
  | "medium"
  | "high"
  | "critical";
  gate: {
  reread_cited_line: "failed" | "skipped" | "passed";
  traced_call_path: "failed" | "skipped" | "passed";
  named_assertion: string;
  ruled_out_language_non_issue: "failed" | "skipped" | "passed";
  };
  claim: string;
  }[];
  timestamp?: string;
  },
  >,
  ): WeightedConsensusResult

  Run weighted consensus on votes

  #### Parameters

  - votes: ReadonlyMap<
    string,
    {
    decision: "approve"
    | "reject"
    | "abstain";
    reasoning: string;
    confidence: number;
    conditions?: string[];
    rejectionCategories?: (
    | "YAGNI"
    | "DRY_VIOLATION"
    | "OVER_ENGINEERING"
    | "SCOPE_CREEP"
    | "SECURITY_RISK"
    | "MISALIGNED"
    | "INSUFFICIENT_EVIDENCE"
    )[];
    findings?: {
    summary: string;
    location: string;
    severity: "low"
    | "medium"
    | "high"
    | "critical";
    gate: {
    reread_cited_line: "failed" | "skipped" | "passed";
    traced_call_path: "failed" | "skipped" | "passed";
    named_assertion: string;
    ruled_out_language_non_issue: "failed" | "skipped" | "passed";
    };
    claim: string;
    }[];
    timestamp?: string;
    },
    >

  #### Returns WeightedConsensusResult

  Implementation of IWeightedVoting.weightedConsensus

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:109

### registerAgent

- registerAgent(agentId: string): void

  Register a new agent

  #### Parameters

  - agentId: string

  #### Returns void

  Implementation of IWeightedVoting.registerAgent

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:136

### getAgentRecord

- getAgentRecord(agentId: string): WeightedAgentRecord | undefined

  Get agent performance record

  #### Parameters

  - agentId: string

  #### Returns WeightedAgentRecord | undefined

  Implementation of IWeightedVoting.getAgentRecord

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:146

### flagByzantine

- flagByzantine(agentId: string, reason: string): void

  Flag agent for Byzantine behavior

  #### Parameters

  - agentId: string
  - reason: string

  #### Returns void

  Implementation of IWeightedVoting.flagByzantine

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:152

### getAllRecords

- getAllRecords(): readonly WeightedAgentRecord[]

  Get all agent records

  #### Returns readonly WeightedAgentRecord[]

  Implementation of IWeightedVoting.getAllRecords

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:181

### canVote

- canVote(agentId: string): boolean

  Check if agent can vote

  #### Parameters

  - agentId: string

  #### Returns boolean

  Implementation of IWeightedVoting.canVote

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:185

### recalibrateWeights

- recalibrateWeights(): void

  Recalibrate all weights based on global performance

  #### Returns void

  Implementation of IWeightedVoting.recalibrateWeights

  - Defined in packages/nexus-agents/src/consensus/weighted-voting.ts:191