pub struct AgentConsensusVoting { /* private fields */ }Expand description
Agentic consensus for response voting
Agents submit responses and vote. Majority wins.
Implementations§
Source§impl AgentConsensusVoting
impl AgentConsensusVoting
Sourcepub fn new(threshold: f64, min_responses: usize, min_votes: usize) -> Self
pub fn new(threshold: f64, min_responses: usize, min_votes: usize) -> Self
Create new consensus instance
§Arguments
threshold- Fraction of votes needed (0.5 = majority)min_responses- Minimum responses before checking consensusmin_votes- Minimum votes before checking consensus
Sourcepub async fn submit_query(&self, query: Query) -> QueryId
pub async fn submit_query(&self, query: Query) -> QueryId
Submit a new query
Sourcepub async fn submit_response(
&self,
response: Response,
) -> Result<ResponseId, Error>
pub async fn submit_response( &self, response: Response, ) -> Result<ResponseId, Error>
Submit a response to a query
Sourcepub async fn vote(
&self,
query_id: QueryId,
response_id: ResponseId,
voter: Did,
) -> Result<(), Error>
pub async fn vote( &self, query_id: QueryId, response_id: ResponseId, voter: Did, ) -> Result<(), Error>
Vote for a response
Each agent can only vote once per query (across all responses)
Sourcepub async fn get_result(&self, query_id: QueryId) -> Option<ConsensusResult>
pub async fn get_result(&self, query_id: QueryId) -> Option<ConsensusResult>
Get the consensus result for a query
Sourcepub async fn is_finalized(&self, query_id: QueryId) -> bool
pub async fn is_finalized(&self, query_id: QueryId) -> bool
Check if a query has reached consensus
Sourcepub async fn get_responses(&self, query_id: QueryId) -> Option<Vec<Response>>
pub async fn get_responses(&self, query_id: QueryId) -> Option<Vec<Response>>
Get all responses for a query
Sourcepub async fn get_vote_counts(
&self,
query_id: QueryId,
) -> Option<HashMap<ResponseId, usize>>
pub async fn get_vote_counts( &self, query_id: QueryId, ) -> Option<HashMap<ResponseId, usize>>
Get vote counts for a query
Auto Trait Implementations§
impl Freeze for AgentConsensusVoting
impl !RefUnwindSafe for AgentConsensusVoting
impl Send for AgentConsensusVoting
impl Sync for AgentConsensusVoting
impl Unpin for AgentConsensusVoting
impl !UnwindSafe for AgentConsensusVoting
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more