GRO-1169: Schema & Migration — Buffer Time Data Model #395

Closed
groombook-engineer[bot] wants to merge 1 commits from flea-flicker/gro-1162-pet-buffer-time into dev
groombook-engineer[bot] commented 2026-05-14 04:18:10 +00:00 (Migrated from github.com)

Summary

GRO-1162 epic: buffer time integration across slot generation, public booking API, and admin appointment API.

GRO-1169 — Schema & Migration: buffer_minutes on appointments, defaultBufferMinutes on services, bufferTimeRules lookup table

GRO-1170 — Buffer calculation engine (resolveBufferMinutes with 6-tier priority fallback)

GRO-1172 — Scheduling engine integration:

  • BookedSlot.bufferMinutes — existing appointment's buffer extends effective end
  • newBufferMinutes param — new appointment's buffer checked against existing appointments
  • GET /availability: accepts petSizeCategory/petCoatType, resolves buffer, passes to slot generation
  • POST /book/appointments: stores bufferMinutes, uses effective end for conflict detection
  • POST /appointments (admin): resolves + stores buffer, effective-end conflict checks for single and recurring

Test plan

  • GET /availability?petSizeCategory=large&petCoatType=double returns buffer-aware slots
  • GET /availability without pet params uses newBufferMinutes=0 (backward compatible)
  • POST /book/appointments stores bufferMinutes on created appointment
  • New appointment with buffer blocks adjacent existing appointment (overlapping effective ends)
  • Admin POST /appointments resolves and stores bufferMinutes
  • TypeScript clean; all 11 slots tests pass (3 new buffer tests added)

🤖 Generated with Claude Code

## Summary GRO-1162 epic: buffer time integration across slot generation, public booking API, and admin appointment API. **GRO-1169** — Schema & Migration: `buffer_minutes` on appointments, `defaultBufferMinutes` on services, `bufferTimeRules` lookup table **GRO-1170** — Buffer calculation engine (`resolveBufferMinutes` with 6-tier priority fallback) **GRO-1172** — Scheduling engine integration: - `BookedSlot.bufferMinutes` — existing appointment's buffer extends effective end - `newBufferMinutes` param — new appointment's buffer checked against existing appointments - `GET /availability`: accepts `petSizeCategory`/`petCoatType`, resolves buffer, passes to slot generation - `POST /book/appointments`: stores `bufferMinutes`, uses effective end for conflict detection - `POST /appointments` (admin): resolves + stores buffer, effective-end conflict checks for single and recurring ## Test plan - [ ] `GET /availability?petSizeCategory=large&petCoatType=double` returns buffer-aware slots - [ ] `GET /availability` without pet params uses `newBufferMinutes=0` (backward compatible) - [ ] `POST /book/appointments` stores `bufferMinutes` on created appointment - [ ] New appointment with buffer blocks adjacent existing appointment (overlapping effective ends) - [ ] Admin `POST /appointments` resolves and stores `bufferMinutes` - [ ] TypeScript clean; all 11 slots tests pass (3 new buffer tests added) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lint-roller-qa[bot] commented 2026-05-16 16:27:55 +00:00 (Migrated from github.com)

GRO-1175 / GRO-1162-G: Cascade Delay Prevention — Merged

Added the cascade delay prevention implementation to this PR (commit 1d8a086):

  • apps/api/src/lib/cascade.ts — core cascade logic:

    • cascadeDelay(triggeringId, newEndTime, originalEndTime) — detects overrun, queries same-groomer downstream scheduled/confirmed appointments, shifts each by (overrunEnd + buffer − downstreamStart), cascades through the chain, logs each shift.
    • cascadeOnStatusOverrun(id) — convenience wrapper for status-transition overruns.
    • Business-hours guard flags out-of-hours appointments instead of shifting.
    • Client reschedule email sent for each shifted appointment.
  • apps/api/src/routes/appointments.ts — wired cascadeDelay into the this_only PATCH path: captures originalEndTime before update, triggers cascade when endTime was extended, returns cascade: { shifted[], flaggedForReview[], cascadeLog[] } in the response.

  • apps/api/src/__tests__/cascade.test.ts — unit tests covering: no-shift when no overrun, no downstream, no groomer; single shift; chained cascade; business-hours guard; active-status filtering; stop condition; email notification.

  • apps/api/UAT_PLAYBOOK.md — new §2 (Cascade Delay Prevention) with checkboxes for all acceptance criteria.

Updated UAT_PLAYBOOK.md §2 — GRO-1175 cascade delay prevention test cases.

Ready for re-review. Thanks!

## GRO-1175 / GRO-1162-G: Cascade Delay Prevention — Merged Added the cascade delay prevention implementation to this PR (commit `1d8a086`): - **`apps/api/src/lib/cascade.ts`** — core cascade logic: - `cascadeDelay(triggeringId, newEndTime, originalEndTime)` — detects overrun, queries same-groomer downstream `scheduled`/`confirmed` appointments, shifts each by `(overrunEnd + buffer − downstreamStart)`, cascades through the chain, logs each shift. - `cascadeOnStatusOverrun(id)` — convenience wrapper for status-transition overruns. - Business-hours guard flags out-of-hours appointments instead of shifting. - Client reschedule email sent for each shifted appointment. - **`apps/api/src/routes/appointments.ts`** — wired `cascadeDelay` into the `this_only` PATCH path: captures `originalEndTime` before update, triggers cascade when `endTime` was extended, returns `cascade: { shifted[], flaggedForReview[], cascadeLog[] }` in the response. - **`apps/api/src/__tests__/cascade.test.ts`** — unit tests covering: no-shift when no overrun, no downstream, no groomer; single shift; chained cascade; business-hours guard; active-status filtering; stop condition; email notification. - **`apps/api/UAT_PLAYBOOK.md`** — new §2 (Cascade Delay Prevention) with checkboxes for all acceptance criteria. Updated UAT_PLAYBOOK.md §2 — GRO-1175 cascade delay prevention test cases. Ready for re-review. Thanks!
Member

CTO Assessment

This PR adds buffer time schema/migration (cascade.ts) to the monorepo. The standalone groombook/api repo now has api/#12 (GRO-1172: Scheduling Engine Buffer Integration) covering the same buffer time feature space.

Recommendation: Close this PR and consolidate buffer time work in the standalone groombook/api repo. Duplicating schema work across monorepo and standalone repos will cause conflicts.

@cpfarhood — please confirm if this can be closed.

## CTO Assessment This PR adds buffer time schema/migration (`cascade.ts`) to the monorepo. The standalone `groombook/api` repo now has `api/#12` (GRO-1172: Scheduling Engine Buffer Integration) covering the same buffer time feature space. **Recommendation:** Close this PR and consolidate buffer time work in the standalone `groombook/api` repo. Duplicating schema work across monorepo and standalone repos will cause conflicts. @cpfarhood — please confirm if this can be closed.
The Dogfather closed this pull request 2026-05-21 19:32:21 +00:00
This repo is archived. You cannot comment on pull requests.