pub struct ConsensusSession {
pub id: String,
pub name: String,
pub proposal: String,
pub choices: Vec<String>,
pub quorum: u32,
pub votes: Vec<ConsensusVote>,
pub resolved: bool,
pub winner: String,
pub created_at: u64,
}Expand description
A named Consensus session — multi-agent agreement through voting.
Participants cast votes for choices. A quorum threshold determines when enough votes have been cast to reach a decision. The winning choice is the one with the most confidence-weighted votes.
ΛD alignment: ψ = ⟨T=“consensus”, V=outcome, E=⟨c≤0.99, τ, ρ, δ=derived⟩⟩ Consensus is aggregated opinion — always derived (Theorem 5.1). Certainty scales with agreement ratio (unanimous = high, split = low).
Fields§
§id: StringSession identifier.
name: StringSession name.
proposal: StringThe proposal or question being voted on.
choices: Vec<String>Available choices to vote for.
quorum: u32Minimum number of votes required for quorum.
votes: Vec<ConsensusVote>Votes cast.
resolved: boolWhether consensus has been reached.
winner: StringWinning choice (if resolved).
created_at: u64Unix timestamp of creation.
Implementations§
Source§impl ConsensusSession
impl ConsensusSession
Sourcepub fn vote(
&mut self,
voter: String,
choice: String,
confidence: f64,
rationale: String,
) -> Result<(), String>
pub fn vote( &mut self, voter: String, choice: String, confidence: f64, rationale: String, ) -> Result<(), String>
Cast a vote. Each voter may vote only once.
Sourcepub fn has_quorum(&self) -> bool
pub fn has_quorum(&self) -> bool
Check if quorum has been met.
Sourcepub fn tally(&self) -> Vec<(String, f64, u32)>
pub fn tally(&self) -> Vec<(String, f64, u32)>
Tally votes: returns (choice → weighted_score) sorted descending.
Sourcepub fn resolve(&mut self) -> Result<(String, f64, f64), String>
pub fn resolve(&mut self) -> Result<(String, f64, f64), String>
Resolve: determine winner if quorum is met.
Sourcepub fn vote_count(&self) -> u32
pub fn vote_count(&self) -> u32
Vote count.
Trait Implementations§
Source§impl Clone for ConsensusSession
impl Clone for ConsensusSession
Source§fn clone(&self) -> ConsensusSession
fn clone(&self) -> ConsensusSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConsensusSession
impl Debug for ConsensusSession
Source§impl<'de> Deserialize<'de> for ConsensusSession
impl<'de> Deserialize<'de> for ConsensusSession
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ConsensusSession
impl RefUnwindSafe for ConsensusSession
impl Send for ConsensusSession
impl Sync for ConsensusSession
impl Unpin for ConsensusSession
impl UnsafeUnpin for ConsensusSession
impl UnwindSafe for ConsensusSession
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more