Vòng đời Reservation: trạng thái, transition hợp lệ/không hợp lệ, invariant. Nguồn sự thật = code reservation-status.ts (state machine đã enforce + test). Nối: BOOKING-FLOW, platform-architecture/UNIVERSAL-BOOKING-MODEL.
pending ──▶ confirmed ──▶ checked_in ──▶ checked_out (terminal)
│ │
├──▶ cancelled (terminal) confirmed ──▶ cancelled / no_show
▼
cancelled
| Trạng thái | Ý nghĩa | Transition ĐI hợp lệ |
|---|---|---|
| pending | Vừa tạo, đã giữ chỗ | → confirmed, cancelled |
| confirmed | Xác nhận (giữ chỗ chắc) | → checked_in, cancelled, no_show |
| checked_in | Khách đã nhận | → checked_out |
| checked_out | Hoàn tất lưu trú (≈ Completed) | — (terminal) |
| cancelled | Đã huỷ | — (terminal) |
| no_show | Không đến (giữ chỗ KHÔNG hoàn) | — (terminal) |
Completed ánh xạchecked_out. Expired =PROPOSED(giữ chỗ chưa thanh toán hết hạn) — chưa hiện thực (backlog Beta, UNIVERSAL-BOOKING-MODEL §7).
checked_out/cancelled/no_show) → RESERVATION_INVALID_STATUS_TRANSITION (409).cancelled → cancelled không hợp lệ (cancelled terminal).pending → checked_in (bỏ qua confirmed), confirmed → checked_out (bỏ qua checked_in) — chặn.Reservation.canTransitionTo enforce; sai luật ⇒ Err, không đổi trạng thái.| Trạng thái | Invariant |
|---|---|
| pending | Đã giữ chỗ (Availability trừ tồn); giá snapshot bất biến; tenant-scoped |
| confirmed | Vẫn giữ chỗ; tính doanh thu (REVENUE_STATUSES) |
| checked_in/out | Chuỗi fulfillment lưu trú; checked_out tính doanh thu |
| cancelled | Hoàn tồn kho (held suy từ reservation non-cancelled ⇒ chỗ tự do lại); đơn bất biến sau huỷ |
| no_show | KHÔNG hoàn tồn (chỗ coi như tiêu tốn); tính/không doanh thu theo policy (MVP: không) |
held ⇒ Availability tăng lại (đặt lại được). Verify: [booking-lifecycle-e2e.test.ts].Cùng transaction (atomic): reservation.created (pending), reservation.confirmed, reservation.cancelled — append-only ([platform-policy]/[Audit Phase 2B]). Verify: audit đủ chuỗi trong E2E test.
packages/platform-infrastructure/src/__tests__/booking-lifecycle-e2e.test.ts (6 test): confirm · cancel · confirm→cancel · double-cancel reject · inventory hoàn trả · audit đủ chuỗi. Demo tay: demo/BOOKING-LIFECYCLE-DEMO.