domain/staff.rs
1//! Staff tasking decisions for resort labor assignment and closeout.
2//!
3//! Staff work is shared across service lines. These types 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/// Staff-task completion evidence retained for audit and BI reconciliation.
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/// Staff task assembled from source-backed resort work so managers can route labor without guessing.
43pub struct Task {
44 /// Resort location whose team owns this task.
45 pub location_id: LocationId,
46 /// Type of labor staff must perform or review.
47 pub kind: task::Kind,
48 /// Staff-visible task title used in work queues and manager briefs.
49 pub title: workflow_task::Title,
50 /// Current workflow state controlling whether staff can act, wait, or review.
51 pub status: task::Status,
52 /// Urgency used to rank the labor queue for leads and managers.
53 pub priority: task::Priority,
54 /// Time by which the resort work should be completed or escalated.
55 pub due_at: DateTime<Utc>,
56 /// Staff member or labor role currently responsible for the work.
57 pub assignment: task::Assignment,
58 /// Source record or workflow event that explains why this task exists.
59 pub source: task::Source,
60 /// Optional closeout note proving the task was finished before reports treat it as done.
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/// Staff-task vocabulary for routing work, ranking urgency, and preserving source proof.
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 /// Labor to prepare a reservation for arrival, documents, room, and front-desk handoff.
97 CheckInPrep {
98 /// Reservation that requires this staff preparation or closeout work.
99 reservation_id: entities::reservation::Id,
100 },
101 /// Labor to prepare pickup, belongings, invoice, and checkout communication.
102 CheckOutPrep {
103 /// Reservation that requires this staff preparation or closeout work.
104 reservation_id: entities::reservation::Id,
105 },
106 /// Pet-care labor for feeding instructions or exceptions that staff must complete.
107 Feeding {
108 /// Pet whose care task needs staff handling.
109 pet_id: PetId,
110 },
111 /// Medication labor that requires reviewed instructions and completion evidence.
112 MedicationAdministration {
113 /// Pet whose medication task needs reviewed instructions and completion evidence.
114 pet_id: PetId,
115 },
116 /// Labor for temperament or group-play assessment before daycare assignment.
117 PlaygroupAssessment {
118 /// Pet whose playgroup assessment needs temperament or eligibility review.
119 pet_id: PetId,
120 },
121 /// Labor for kennel, room, or run turnover tied to a reservation.
122 CleaningTurnover {
123 /// Reservation that requires this staff preparation or closeout work.
124 reservation_id: entities::reservation::Id,
125 },
126 /// Labor to prepare a customer-safe daily update draft from care evidence.
127 DailyUpdateDraft {
128 /// Reservation that requires this staff preparation or closeout work.
129 reservation_id: entities::reservation::Id,
130 },
131 /// Labor to review document evidence before compliance or care workflows trust it.
132 DocumentReview {
133 /// Pet whose document evidence must be reviewed before staff trust it.
134 pet_id: PetId,
135 },
136 /// Labor to investigate, document, or communicate about a safety/customer incident.
137 IncidentFollowUp {
138 /// Pet connected to the incident follow-up labor.
139 pet_id: PetId,
140 },
141 /// Labor to contact a customer for missing proof, changes, review response, or service recovery.
142 CustomerFollowUp {
143 /// Customer whose follow-up should be routed to staff.
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 /// Work is visible in the queue but not yet being handled.
154 Open,
155 /// A staff member or role is actively handling the work.
156 InProgress,
157 /// Work cannot proceed until missing proof, policy, or approval is resolved.
158 Blocked,
159 /// Manager must review the task before staff treat it as complete.
160 NeedsManagerReview,
161 /// Evidence says the resort work is complete and can feed reports.
162 Completed,
163 /// Staff task was cancelled or suppressed before completion and should not count as done labor.
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 /// Low urgency task that can wait behind normal and safety-sensitive labor.
171 Low,
172 /// Routine resort work that can follow normal queue order.
173 Normal,
174 /// High urgency task that should be handled ahead of routine resort work.
175 High,
176 /// Safety, customer-trust, or operations issue that should jump the queue.
177 Critical,
178 }
179
180 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
181 /// Staff assignment state used to distinguish scheduled coverage from backup or inactive labor.
182 pub enum Assignment {
183 /// No staff member or role owns this work yet.
184 Unassigned,
185 /// Named staff member owns the task.
186 Staff(StaffId),
187 /// Labor role owns the task until a person claims it.
188 Role(super::Role),
189 }
190
191 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
192 /// Staff source system retained so labor records can be reconciled with provider authority.
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 snapshot raised this task for staff review.
201 DailyBrief(daily_brief::snapshot::Id),
202 /// Workflow event raised this task for staff review.
203 WorkflowEvent(crate::workflow::EventId),
204 /// Staff created the task directly outside automated source ingestion.
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 team handling check-in, checkout, customer, or document work.
213 FrontDesk,
214 /// Kennel technician team handling pet care, feeding, medication, or cleanup work.
215 KennelTechnician,
216 /// Groomer handling grooming preparation, service, or follow-up work.
217 Groomer,
218 /// Trainer handling training assignment, progress, package, or follow-up work.
219 Trainer,
220 /// Lead staff member triaging work before manager escalation.
221 LeadStaff,
222 /// Manager accountable for approvals, exceptions, and queue escalation.
223 Manager,
224}