Schedule Engine
The Schedule Engine is the core system that manages performance times, handles cascade changes, and ensures schedule integrity.
Core Concepts
Cascade Logic
When you change a performance time, the engine can automatically shift subsequent performances. This is called "cascading."
Optimistic Locking
The engine uses version numbers to prevent conflicts when multiple users edit simultaneously.
Transactional Updates
All schedule changes happen in a single database transaction, ensuring consistency.
How Cascade Works
- You move Performance A from 9:00 to 9:15 (+15 minutes)
- Engine identifies all performances after A in the same session
- Each subsequent performance shifts by 15 minutes
- Changes are applied in a single transaction
Safety Features
Maximum Cascade Depth
The engine limits cascade to 1000 operations to prevent infinite loops.
Session Boundaries
By default, cascade changes stop at session boundaries.
Version Conflicts
If another user modified the schedule, you'll see a conflict error.
Technical Details
For developers:
- Located in
lib/schedule-engine/ cascade.ts- Cascade calculation (O(n) linear)server/apply-changes.ts- Transactional applicationserver/validate-changes.ts- Zod validation schemas
Related Docs
- Schedule Management - Using the schedule UI
- Sessions - How sessions affect cascading