Skip to main content

EffectiveThreshold

Enum EffectiveThreshold 

Source
pub enum EffectiveThreshold {
    Inert,
    Approvals(u32),
    Unsatisfiable,
}
Expand description

The approval bar a Quorum Mode QuorumThreshold imposes on one session.

Produced only by QuorumThreshold::effective, which is the single implementation of that rule. It lives in macp-core because two crates need it — QuorumMode::effective_threshold in macp-modes and evaluate_quorum_commitment_outcome in macp-policy — and when they each carried their own copy they disagreed: the mode truncated a fractional value (0.50) while the evaluator ceiled it (0.51), so one policy produced two different thresholds. RFC-MACP-0011 §7 forbids exactly that (“implementations MUST derive the same quorum state and the same commitment eligibility”). A third caller must call this, not re-derive it.

Deliberately not #[non_exhaustive], unlike its neighbours in this crate (crate::error::MacpError, crate::mode::ModeResponse, crate::mode::MessageContext, crate::session::Session, super::PolicyDecision, super::CommitmentMode). That attribute binds every crate except the defining one, so here it would force a _ arm at exactly the two call sites — QuorumMode::effective_threshold in macp-modes and evaluate_quorum_commitment_outcome in macp-policy — whose compile-time exhaustiveness is the guarantee unifying this rule buys. A fail-closed _ arm would be strictly worse for a governance kernel: a future variant would silently decline instead of failing to build, which is the same class of silent mis-handling as issue #145. Adding a variant later is not a silent break either — enum_variant_added is a major cargo-semver-checks lint and release-plz.toml sets semver_check = true, so it blocks the release PR. The residual cost is release coordination, not an undetected breakage.

Variants§

§

Inert

The rule imposes no bar (value <= 0, including the schema default), so the caller keeps its own default.

The two callers’ defaults differ, and unifying them is out of scope for the rounding fix: the mode falls back to the ApprovalRequest’s required_approvals, while the evaluator applies no threshold check at all. See ASSUMPTIONS.md, “Quorum threshold.value = 0”.

§

Approvals(u32)

This many approvals are required to seal a positive commitment. Never zero: a bar of zero would be met before any ballot was cast.

§

Unsatisfiable

No number of approvals can satisfy the rule, so the session can seal no positive commitment. Returned for type: "weighted" (unimplemented here — threshold.value is typed integer by quorum-rules.schema.json, so a weighted sum is not expressible and per-participant quorum weights are not modelled), for any unrecognised type, and for a percentage over an empty participant set.

Registration refuses the first two (PolicyRegistry::validate_quorum_threshold), so reaching those needs a directly-constructed PolicyDefinition; the empty-participant-set case is not catchable there, since registration has no participant count, and QuorumMode::on_session_start blocks it instead. It fails closed rather than silently reinterpreting the value as a raw approval count, which is what the old shared _ arm did.

Trait Implementations§

Source§

impl Clone for EffectiveThreshold

Source§

fn clone(&self) -> EffectiveThreshold

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for EffectiveThreshold

Source§

impl Debug for EffectiveThreshold

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for EffectiveThreshold

Source§

impl PartialEq for EffectiveThreshold

Source§

fn eq(&self, other: &EffectiveThreshold) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EffectiveThreshold

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.