/** * ConsensusProtocol — agent voting on proposed changes. * * Enables autonomous approval of code changes without a human. Agents register * as voters with a role weight; changes gather votes; the protocol resolves * the outcome based on configured quorum rules. * * Voting rules (configurable): * - Quorum: minimum fraction of eligible voters required (default: 0.5) * - Approval threshold: minimum fraction of cast votes that must be approve (default: 0.6) * - Veto roles: roles whose 'reject' vote is fatal regardless of count * - Auto-approve: changes with severity=critical bypass voting if the proposer is trusted * * The protocol is stateless — it reads from the KnowledgeGraph and writes results * back to it. This makes it naturally consistent with the shared knowledge model. * * @module consensus-protocol */ import type { VoteRecord, VoteValue } from './knowledge-graph.js'; import type { KnowledgeGraph } from './knowledge-graph.js'; import type { FleetBus } from './fleet-bus.js'; export interface VoterConfig { agentId: string; agentName: string; role: string; /** Weight multiplier for this voter's vote. Default: 1. */ weight: number; /** If true, a 'reject' vote from this role is a hard veto. Default: false. */ veto?: boolean; /** * @deprecated Not yet implemented. Auto-approve of low-risk changes is planned * but not wired up in the vote resolution logic. */ autoApprovesLowRisk?: boolean; } export interface QuorumRule { /** Fraction of eligible voters required (0-1). Default: 0.5. */ quorumFraction: number; /** Fraction of cast votes that must be approve (0-1). Default: 0.6. */ approvalFraction: number; /** Roles whose reject vote is a hard veto regardless of count. */ vetoRoles: string[]; /** Minimum total weight of approve votes to pass (0-1 of total eligible weight). */ approvalWeightFraction?: number | undefined; } export interface ConsensusResult { changeId: string; outcome: 'approved' | 'rejected' | 'pending' | 'vetoed' | 'quorum_not_met'; votes: VoteRecord[]; approveCount: number; rejectCount: number; abstainCount: number; totalWeightApprove: number; totalWeightReject: number; eligibleVoters: string[]; quorumMet: boolean; approvalMet: boolean; vetoedBy?: string; rationale: string; } export interface ConsensusOptions { rules?: Partial; voters: VoterConfig[]; graph: KnowledgeGraph; fleet?: FleetBus | undefined; } /** * ConsensusProtocol manages voting on ChangeNodes in the KnowledgeGraph. * It is instantiated once per autonomous session and used to initiate votes, * cast votes, and resolve outcomes. */ export declare class ConsensusProtocol { private readonly graph; private readonly fleet?; private readonly rules; private readonly voters; constructor(opts: ConsensusOptions); /** * Initiate a vote on a proposed change. Updates the change node's status * to 'proposed' and notifies eligible voters via FleetBus. */ initiateVote(changeId: string): Promise; /** * Cast a vote. Updates the change node in the graph and re-evaluates * consensus. If the vote triggers a resolution, updates the change status. */ castVote(changeId: string, voterId: string, value: VoteValue, rationale?: string): Promise; /** * Resolve the current vote without waiting for all eligible voters. * Useful when a timeout fires or an agent decides to finalize early. */ resolveNow(changeId: string): Promise; /** * Register or update a voter's configuration. */ registerVoter(config: VoterConfig): void; /** * Get the current vote status for a change. */ getStatus(changeId: string): ConsensusResult | null; private _eligibleVoters; private _resolve; private _toChangeStatus; private _notifyVoters; } //# sourceMappingURL=consensus-protocol.d.ts.map