Priority System
The priority system is the foundation of Smart Scheduling. It determines which items get scheduled first and which items can bump others.Priority Levels
Smart Scheduling uses four priority levels:| Level | Weight | Description |
|---|---|---|
| Critical | 4 | Must be done immediately, can bump other events |
| High | 3 | Important, scheduled before normal items |
| Normal | 2 | Standard priority, default for most items |
| Low | 1 | Can be deferred, scheduled when convenient |
Priority Inference
When an item doesn’t have an explicit priority set, the system infers it from the deadline:Explicit priorities always override inferred priorities. If you set a task as “Low” priority, it stays low even if it’s overdue.
Priority Score Calculation
For more granular sorting, the system calculates a numeric priority score:- Overdue items are scheduled first (score up to 9000)
- Items due soon are prioritized even within the same priority level
- Low priority items with urgent deadlines can outrank high priority items due later
Sorting Algorithm
Items are sorted using a multi-level comparison:1
Primary: Priority
Higher priority items come first (critical > high > normal > low)
2
Secondary: Deadline
Among same priority, earlier deadlines come first
3
Tertiary: Creation Date
Among same priority and deadline, older items come first (FIFO)
Bumping Rules
Only critical priority items can bump other events:| Bumper Priority | Can Bump |
|---|---|
| Critical | High, Normal, Low |
| High | Nothing |
| Normal | Nothing |
| Low | Nothing |
Bumping Process
When a critical task needs a time slot occupied by a lower-priority habit:- The habit event is marked for rescheduling
- The task is scheduled in the freed slot
- The bumped habit is rescheduled to the next available slot
- If no suitable slot exists, a warning is generated
Implementation Details
The priority calculator is implemented inpackages/ai/src/scheduling/priority-calculator.ts:
Testing
The priority system is thoroughly tested with 61 test cases covering:- Priority weight ordering
- Explicit priority handling
- Deadline-based inference
- Priority comparison functions
- Bumping rules
- Multi-level sorting
- Score calculation with urgency bonuses