Skip to main content
Rules let you set constraints on working days, hours, and shift sequences. Use rules to enforce labor regulations, contractual limits, and scheduling policies.

Rule Types

Counter Rules

Count and limit occurrences within a planning period.

Working Days

Limit total working days:

Days Idle

Ensure minimum days off:

Weekends Idle

Guarantee free weekends:
Requires weekend definition in options to specify what constitutes a weekend.

Shift Type Limits

Limit specific shift types using tags:

Maximum Consecutive Days

Cap the number of consecutive working days:

Counter Types

DAYS_IDLE and WEEKENDS_IDLE require a period (either a fixed from/to range or a duration) to be specified — without one, the rule is silently ignored and never affects the schedule.

Period Scoping

By default, rules apply to the entire planning period. Scope rules to specific periods:

Fixed Period

Fixed-Length Windows

period.duration splits the planning horizon into consecutive, non-overlapping blocks of the given length, starting at the horizon’s start date (e.g. P3D over a 14-day horizon produces four 3-day blocks plus one 2-day clamped block). Each block is scored independently:
This is not a true rolling/sliding window, so violations spanning a block boundary are not caught. Align period.duration (e.g. P7D) to your planning horizon’s start date for a weekly cap. For a true any-N-day rolling check, this feature does not currently support it.

Sequence Rules

Limit consecutive occurrences without specifying a period window.

Consecutive Working Days

Employees work between 2 and 4 consecutive days before a day off.

Maximum Consecutive Days

Conditional Rules

Trigger a rule when another rule’s threshold is exceeded. Example: If 20+ hours of night shifts within 72 hours, then require 2 days idle:
Use max to trigger on “N or more”; use min to trigger on “fewer than N”.
Conditional rules can create complex constraints. Test thoroughly to avoid making problems infeasible.

Rule Properties

constraint
string
required
Rule type: COUNTER or SEQUENCE
type
string
required
What to count or sequence (see tables above)
min
integer
Minimum count or sequence length
max
integer
Maximum count or sequence length
shifts
array
Filter rule to specific shift tags
period
object
Time scope with from/to dates, or a fixed-length duration that tiles the planning horizon into non-overlapping blocks
then
Rule
Conditional rule triggered when this rule is exceeded. The then rule always inherits the parent rule’s resolved period window (including any rolling-window expansion); any period set directly on the then object is ignored.

Common Rule Patterns