pub struct Deliberation { /* private fields */ }Expand description
Aggregate root: one deliberation over one task.
Implementations§
Source§impl Deliberation
impl Deliberation
pub fn start( task_id: TaskId, specialty: Specialty, rounds_budget: Rounds, now: OffsetDateTime, ) -> Self
pub fn task_id(&self) -> &TaskId
pub fn specialty(&self) -> &Specialty
pub fn rounds_budget(&self) -> Rounds
pub fn phase(&self) -> DeliberationPhase
pub fn proposals(&self) -> &BTreeMap<ProposalId, Proposal>
pub fn outcomes(&self) -> &BTreeMap<ProposalId, ValidationOutcome>
pub fn started_at(&self) -> OffsetDateTime
pub fn completed_at(&self) -> Option<OffsetDateTime>
Sourcepub fn add_proposal(&mut self, proposal: Proposal) -> Result<(), DomainError>
pub fn add_proposal(&mut self, proposal: Proposal) -> Result<(), DomainError>
Add a new proposal. Only allowed while Proposing. Duplicate
proposal ids are rejected.
Sourcepub fn revise_proposal(
&mut self,
proposal_id: &ProposalId,
new_content: impl Into<ProposalContent>,
now: OffsetDateTime,
) -> Result<(), DomainError>
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.
Sourcepub fn attach_outcome(
&mut self,
proposal_id: &ProposalId,
outcome: ValidationOutcome,
) -> Result<(), DomainError>
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.
Sourcepub fn advance(&mut self) -> Result<DeliberationPhase, DomainError>
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.
Sourcepub fn complete(
&mut self,
now: OffsetDateTime,
) -> Result<Vec<RankedOutcome>, DomainError>
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.
Sourcepub fn reprioritize(
&mut self,
ranking: Vec<ProposalId>,
) -> Result<Vec<RankedOutcome>, DomainError>
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.
Sourcepub fn duration(&self) -> Option<DurationMs>
pub fn duration(&self) -> Option<DurationMs>
Total duration from start to completion, when completed.
pub fn ranking(&self) -> &[ProposalId]
Sourcepub fn ranked_outcomes(&self) -> Result<Vec<RankedOutcome>, DomainError>
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
impl Clone for Deliberation
Source§fn clone(&self) -> Deliberation
fn clone(&self) -> Deliberation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more