- Document separated booking/payment state engine, 48-hour payment follow-up queue, and deliberate slot release in SRS.md and architecture.md. - Add ADR-0005 for server-side Google OAuth2 and Turso admin_allowlist. - Rewrite AGENTS.md as a local technical blueprint defining SQLModel + Repository layers, pytest-mock boundaries, and mutmut audits. Refs: #1, #3, #6
2.4 KiB
2.4 KiB
ADR 0003: Mandatory Buffer Times and Recoverable Google Calendar Synchronization
Status
Accepted (Amended 2026-10-18)
Context
Discovery feedback from long-term clients revealed chronic 10-to-35-minute delays in therapy sessions caused by emotional consultation overruns and back-to-back scheduling without buffers. Additionally, Jasmin relies on Google Calendar to view her daily schedule on her phone, while armonia-api (backed by Turso) must remain the authoritative record of business state.
Decision
- Mandatory Post-Session Buffers: Every individual appointment (
ONE_ON_ONE) enforces an unbookable 15-to-20-minute buffer interval immediately following the session. A 60-minute consultation blocks 75 minutes on the scheduling engine for anyRESERVEDbooking. - Backend-Owned Truth with Google Calendar Coordination:
armonia-apiowns the authoritative booking and payment decision in Turso; Google Calendar reflects the schedule:[PAGO PENDIENTE]whenbooking_status = 'RESERVED',payment_arrangement = 'PREPAID_DEFAULT', andpayment_status = 'AWAITING_ACKNOWLEDGMENT'.[PAGO DIFERIDO]whenbooking_status = 'RESERVED',payment_arrangement = 'DELAYED_ALLOWED', andpayment_status = 'AWAITING_ACKNOWLEDGMENT'.[CONFIRMADO]whenpayment_status = 'ACKNOWLEDGED'orpayment_arrangement = 'PACKAGE_REDEEMED'.- Event deleted/cancelled when
booking_statustransitions toRELEASEDorCANCELLED.
- Visible & Recoverable Integration State:
- Each booking stores
gcal_event_id,gcal_sync_status(PENDING,SYNCED,FAILED,NOT_CONFIGURED),gcal_sync_error, andgcal_synced_at. - If the Google Calendar API fails transiently, the Turso record is preserved with
gcal_sync_status = 'FAILED'and administrators can retry synchronization viaPOST /bookings/{id}/sync-calendar.
- Each booking stores
Consequences
Positive
- Prevents cascade delays across consultations and frees slots immediately when a booking is
RELEASED. - Prevents silent divergence between Turso and Google Calendar by surfacing
gcal_sync_statusandgcal_sync_errordirectly to the dashboard. - Works cleanly in local development and tests (
NOT_CONFIGUREDfallback when GCP credentials are absent).
Negative / Trade-offs
- Slightly reduces theoretical maximum daily capacity (e.g., maximum 5 sessions/day instead of 6) in exchange for punctuality and therapist well-being.