Skip to main content

Deliberation

Struct Deliberation 

Source
pub struct Deliberation { /* private fields */ }
Expand description

Aggregate root: one deliberation over one task.

Implementations§

Source§

impl Deliberation

Source

pub fn start( task_id: TaskId, specialty: Specialty, rounds_budget: Rounds, now: OffsetDateTime, ) -> Self

Source

pub fn task_id(&self) -> &TaskId

Source

pub fn specialty(&self) -> &Specialty

Source

pub fn rounds_budget(&self) -> Rounds

Source

pub fn phase(&self) -> DeliberationPhase

Source

pub fn proposals(&self) -> &BTreeMap<ProposalId, Proposal>

Source

pub fn outcomes(&self) -> &BTreeMap<ProposalId, ValidationOutcome>

Source

pub fn started_at(&self) -> OffsetDateTime

Source

pub fn completed_at(&self) -> Option<OffsetDateTime>

Source

pub fn add_proposal(&mut self, proposal: Proposal) -> Result<(), DomainError>

Add a new proposal. Only allowed while Proposing. Duplicate proposal ids are rejected.

Source

pub fn revise_proposal( &mut self, proposal_id: &ProposalId, new_content: impl Into<ProposalContent>, now: OffsetDateTime, ) -> Result<(), DomainError>

Revise an existing proposal. Only allowed in the Revising phase.

Source

pub fn attach_outcome( &mut self, proposal_id: &ProposalId, outcome: ValidationOutcome, ) -> Result<(), DomainError>

Attach a validation outcome for a proposal. Only allowed in Validating. Every proposal must receive exactly one outcome before advancing to Scoring.

Source

pub fn advance(&mut self) -> Result<DeliberationPhase, DomainError>

Advance to the next phase, enforcing the preconditions of the transition:

  • Proposing -> Revising: at least one proposal present.
  • Validating -> Scoring: every proposal has an outcome.
  • Other transitions are unconditional.
Source

pub fn complete( &mut self, now: OffsetDateTime, ) -> Result<Vec<RankedOutcome>, DomainError>

Compute the ranking and mark the deliberation complete. Only allowed from Scoring. The winning proposal gets rank 0; ties are broken by proposal id to keep the ordering deterministic.

Source

pub fn reprioritize( &mut self, ranking: Vec<ProposalId>, ) -> Result<Vec<RankedOutcome>, DomainError>

Reorder the final ranking after completion while preserving the same proposal set. This lets the application layer impose a deterministic post-scoring preference (for example, valid structured outputs before invalid ones) without mutating proposals or outcomes.

Source

pub fn duration(&self) -> Option<DurationMs>

Total duration from start to completion, when completed.

Source

pub fn ranking(&self) -> &[ProposalId]

Source

pub fn ranked_outcomes(&self) -> Result<Vec<RankedOutcome>, DomainError>

Reconstruct RankedOutcomes from the persisted ranking + the stored proposals and outcomes. Useful when an upstream caller (e.g. RunCouncilDecisionUseCase in Warn mode) needs to read a completed deliberation back from a repository without re-running the algorithm.

Fails with DomainError::InvalidTransition if the deliberation is not yet in the Completed phase.

Trait Implementations§

Source§

impl Clone for Deliberation

Source§

fn clone(&self) -> Self

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 Debug for Deliberation

Source§

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

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

impl<'de> Deserialize<'de> for Deliberation

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Deliberation

Source§

impl PartialEq for Deliberation

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Deliberation

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Deliberation

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.