Skip to main content

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

  1. You move Performance A from 9:00 to 9:15 (+15 minutes)
  2. Engine identifies all performances after A in the same session
  3. Each subsequent performance shifts by 15 minutes
  4. 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 application
  • server/validate-changes.ts - Zod validation schemas