Skip to main content

macp_core/
decision.rs

1//! Decision mode domain types.
2//!
3//! These plain data structs model the Decision mode's accumulated state. They
4//! live in core (rather than in `macp-modes`) because the [`crate::policy`]
5//! evaluation trait names them: `evaluate_decision_commitment` inspects a
6//! [`DecisionState`]. Keeping them here lets `macp-policy` evaluate decisions
7//! without depending on `macp-modes`, breaking the historical mode<->policy
8//! cycle.
9
10use serde::{Deserialize, Serialize};
11use std::collections::BTreeMap;
12
13#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
14pub enum DecisionPhase {
15    #[default]
16    Proposal,
17    Evaluation,
18    Voting,
19    Committed,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct DecisionState {
24    pub proposals: BTreeMap<String, Proposal>,
25    pub evaluations: Vec<Evaluation>,
26    pub objections: Vec<Objection>,
27    pub votes: BTreeMap<String, BTreeMap<String, Vote>>,
28    pub phase: DecisionPhase,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct Proposal {
33    pub proposal_id: String,
34    pub option: String,
35    pub rationale: String,
36    pub sender: String,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct Evaluation {
41    pub proposal_id: String,
42    pub recommendation: String,
43    pub confidence: f64,
44    pub reason: String,
45    pub sender: String,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct Objection {
50    pub proposal_id: String,
51    pub reason: String,
52    pub severity: String,
53    pub sender: String,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct Vote {
58    pub proposal_id: String,
59    pub vote: String,
60    pub reason: String,
61    pub sender: String,
62}