domain/staff.rs
1//! Canonical domain contracts for staff tasking and assignment.
2//!
3//! Staff work is shared across service lines. These contracts turn validated daily-brief,
4//! reservation, pet, and workflow signals into assignable labor, making the cost levers
5//! explicit: what work exists, who/what role owns it, priority, due time, and completion
6//! evidence.
7
8use bon::Builder;
9use chrono::{DateTime, Utc};
10use nutype::nutype;
11#[allow(unused_imports)]
12use serde::{Deserialize, Serialize};
13
14use crate::daily_brief::{self, FollowUpReason};
15use crate::entities::{self, CustomerId, LocationId, PetId, StaffId};
16use crate::workflow::task as workflow_task;
17
18/// Completion evidence boundary for staff contracts.
19pub mod completion_evidence {
20 use super::*;
21
22 #[nutype(
23 sanitize(trim),
24 validate(not_empty, len_char_max = 500),
25 derive(
26 Debug,
27 Clone,
28 PartialEq,
29 Eq,
30 PartialOrd,
31 Ord,
32 Hash,
33 Serialize,
34 Deserialize
35 )
36 )]
37 /// Evidence that a staff task was completed, retained for audit and BI reconciliation.
38 pub struct Evidence(String);
39}
40
41#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Builder)]
42/// Assignable unit of resort labor generated from validated operational signals.
43pub struct Task {
44 /// Location id fact promoted into this staff contract.
45 pub location_id: LocationId,
46 /// Kind fact promoted into this staff contract.
47 pub kind: task::Kind,
48 /// Title fact promoted into this staff contract.
49 pub title: workflow_task::Title,
50 /// Status fact promoted into this staff contract.
51 pub status: task::Status,
52 /// Priority fact promoted into this staff contract.
53 pub priority: task::Priority,
54 /// Due at fact promoted into this staff contract.
55 pub due_at: DateTime<Utc>,
56 /// Assignment fact promoted into this staff contract.
57 pub assignment: task::Assignment,
58 /// Source fact promoted into this staff contract.
59 pub source: task::Source,
60 /// Completion evidence fact promoted into this staff contract.
61 pub completion_evidence: Option<completion_evidence::Evidence>,
62}
63
64impl Task {
65 /// Returns whether priority, status, or safety-sensitive kind should surface to managers.
66 pub fn requires_manager_attention(&self) -> bool {
67 matches!(
68 self.status,
69 task::Status::Blocked | task::Status::NeedsManagerReview
70 ) || matches!(
71 self.priority,
72 task::Priority::High | task::Priority::Critical
73 ) || matches!(
74 self.kind,
75 task::Kind::IncidentFollowUp { .. }
76 | task::Kind::MedicationAdministration { .. }
77 | task::Kind::DocumentReview { .. }
78 )
79 }
80
81 /// Marks the task completed with auditable evidence for workflow/read-model closeout.
82 pub fn complete_with(mut self, evidence: completion_evidence::Evidence) -> Self {
83 self.status = task::Status::Completed;
84 self.completion_evidence = Some(evidence);
85 self
86 }
87}
88
89/// Task boundary for staff contracts.
90pub mod task {
91 use super::*;
92
93 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
94 /// Type of labor a staff task represents across check-in, care, cleanup, and follow-up.
95 pub enum Kind {
96 /// Check in prep staff role, schedule, or labor-planning signal.
97 CheckInPrep {
98 /// Reservation id fact promoted into this staff contract.
99 reservation_id: entities::reservation::Id,
100 },
101 /// Check out prep staff role, schedule, or labor-planning signal.
102 CheckOutPrep {
103 /// Reservation id fact promoted into this staff contract.
104 reservation_id: entities::reservation::Id,
105 },
106 /// Feeding staff role, schedule, or labor-planning signal.
107 Feeding {
108 /// Pet receiving the grooming or care service.
109 pet_id: PetId,
110 },
111 /// Medication service that requires care instructions.
112 MedicationAdministration {
113 /// Pet receiving the grooming or care service.
114 pet_id: PetId,
115 },
116 /// Playgroup assessment staff role, schedule, or labor-planning signal.
117 PlaygroupAssessment {
118 /// Pet receiving the grooming or care service.
119 pet_id: PetId,
120 },
121 /// Cleaning turnover staff role, schedule, or labor-planning signal.
122 CleaningTurnover {
123 /// Reservation id fact promoted into this staff contract.
124 reservation_id: entities::reservation::Id,
125 },
126 /// Daily update draft staff role, schedule, or labor-planning signal.
127 DailyUpdateDraft {
128 /// Reservation id fact promoted into this staff contract.
129 reservation_id: entities::reservation::Id,
130 },
131 /// Document review staff role, schedule, or labor-planning signal.
132 DocumentReview {
133 /// Pet receiving the grooming or care service.
134 pet_id: PetId,
135 },
136 /// Incident follow up staff role, schedule, or labor-planning signal.
137 IncidentFollowUp {
138 /// Pet receiving the grooming or care service.
139 pet_id: PetId,
140 },
141 /// Customer follow up staff role, schedule, or labor-planning signal.
142 CustomerFollowUp {
143 /// Customer id fact promoted into this staff contract.
144 customer_id: CustomerId,
145 /// Business reason staff should review before proceeding.
146 reason: FollowUpReason,
147 },
148 }
149
150 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
151 /// Current workflow state for an assignable staff task.
152 pub enum Status {
153 /// Open staff role, schedule, or labor-planning signal.
154 Open,
155 /// In progress staff role, schedule, or labor-planning signal.
156 InProgress,
157 /// Blocked staff role, schedule, or labor-planning signal.
158 Blocked,
159 /// Needs manager review staff role, schedule, or labor-planning signal.
160 NeedsManagerReview,
161 /// Completed staff role, schedule, or labor-planning signal.
162 Completed,
163 /// Reservation is no longer active.
164 Cancelled,
165 }
166
167 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
168 /// Priority level used to sequence staff labor and manager attention.
169 pub enum Priority {
170 /// Estimate is uncertain and may require staff confirmation.
171 Low,
172 /// Normal staff role, schedule, or labor-planning signal.
173 Normal,
174 /// Estimate is reliable enough for normal scheduling.
175 High,
176 /// Critical staff role, schedule, or labor-planning signal.
177 Critical,
178 }
179
180 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
181 /// Domain vocabulary for assignment decisions in staff workflows.
182 pub enum Assignment {
183 /// Unassigned staff role, schedule, or labor-planning signal.
184 Unassigned,
185 /// Staff staff role, schedule, or labor-planning signal.
186 Staff(StaffId),
187 /// Role staff role, schedule, or labor-planning signal.
188 Role(super::Role),
189 }
190
191 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
192 /// Domain vocabulary for source decisions in staff workflows.
193 pub enum Source {
194 /// Reservation record participating in the workflow.
195 Reservation(entities::reservation::Id),
196 /// Pet record participating in the workflow.
197 Pet(PetId),
198 /// Customer record participating in the workflow.
199 Customer(CustomerId),
200 /// Daily brief staff role, schedule, or labor-planning signal.
201 DailyBrief(daily_brief::snapshot::Id),
202 /// Workflow event staff role, schedule, or labor-planning signal.
203 WorkflowEvent(crate::workflow::EventId),
204 /// Staff created staff role, schedule, or labor-planning signal.
205 StaffCreated,
206 }
207}
208
209#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
210/// Resort labor role that can own or be assigned a staff task.
211pub enum Role {
212 /// Front desk staff role, schedule, or labor-planning signal.
213 FrontDesk,
214 /// Kennel technician staff role, schedule, or labor-planning signal.
215 KennelTechnician,
216 /// Groomer staff role, schedule, or labor-planning signal.
217 Groomer,
218 /// Trainer staff role, schedule, or labor-planning signal.
219 Trainer,
220 /// Lead staff staff role, schedule, or labor-planning signal.
221 LeadStaff,
222 /// Manager staff role, schedule, or labor-planning signal.
223 Manager,
224}