Case Study

// Same convention in the algorithm and the constraint: // overlap ⟺ aStart < bEnd && aEnd > bStart // tstzrange(..., '[)') ⟺ half-open, no off-by-one
constraint fade_appointments_no_overlap
exclude using gist (
barber_id with =,
tstzrange(starts_at, ends_at, '[)') with &&
) where (status != 'cancelled')waitUntil for the confirmation email.POST /api/parse-booking { text: "fade with Sam Saturday afternoon" }
→ { service: "Fade", barber: "Sam", dayHint: "Saturday",
timeHint: "afternoon", confidence: 0.99 }
response A: 409 {"error":"slot_taken","message":"That slot was just taken. Please pick another time."}
response B: 201 {"ok":true,"reference_code":"FC-20261006-0005",...}
✅ Exactly one booking succeeded (ref: FC-20261006-0005)
✅ Second request rejected with 409 slot_taken
✅ DB has exactly 1 row for slot 2026-10-06T01:00:00.000Z
PASS


