assignment-user-matcher 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +164 -10
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +19 -1
  5. package/dist/learning/auto-weights.d.ts +7 -4
  6. package/dist/learning/auto-weights.d.ts.map +1 -1
  7. package/dist/learning/auto-weights.js +7 -6
  8. package/dist/lua/workflow-transition.lua +8 -2
  9. package/dist/managers/LearningManager.d.ts.map +1 -1
  10. package/dist/managers/LearningManager.js +47 -0
  11. package/dist/managers/WorkflowManager.d.ts +7 -1
  12. package/dist/managers/WorkflowManager.d.ts.map +1 -1
  13. package/dist/managers/WorkflowManager.js +85 -12
  14. package/dist/matcher.class.d.ts +35 -3
  15. package/dist/matcher.class.d.ts.map +1 -1
  16. package/dist/matcher.class.js +319 -76
  17. package/dist/queries/users.d.ts +34 -0
  18. package/dist/queries/users.d.ts.map +1 -0
  19. package/dist/queries/users.js +227 -0
  20. package/dist/scheduling/constraints/availability.d.ts +43 -0
  21. package/dist/scheduling/constraints/availability.d.ts.map +1 -0
  22. package/dist/scheduling/constraints/availability.js +165 -0
  23. package/dist/scheduling/constraints/consecutive.d.ts +25 -0
  24. package/dist/scheduling/constraints/consecutive.d.ts.map +1 -0
  25. package/dist/scheduling/constraints/consecutive.js +215 -0
  26. package/dist/scheduling/constraints/constraint.d.ts +35 -0
  27. package/dist/scheduling/constraints/constraint.d.ts.map +1 -0
  28. package/dist/scheduling/constraints/constraint.js +97 -0
  29. package/dist/scheduling/constraints/contract.d.ts +21 -0
  30. package/dist/scheduling/constraints/contract.d.ts.map +1 -0
  31. package/dist/scheduling/constraints/contract.js +120 -0
  32. package/dist/scheduling/constraints/cost.d.ts +18 -0
  33. package/dist/scheduling/constraints/cost.d.ts.map +1 -0
  34. package/dist/scheduling/constraints/cost.js +65 -0
  35. package/dist/scheduling/constraints/daily-rest.d.ts +22 -0
  36. package/dist/scheduling/constraints/daily-rest.d.ts.map +1 -0
  37. package/dist/scheduling/constraints/daily-rest.js +123 -0
  38. package/dist/scheduling/constraints/duty-quota.d.ts +20 -0
  39. package/dist/scheduling/constraints/duty-quota.d.ts.map +1 -0
  40. package/dist/scheduling/constraints/duty-quota.js +95 -0
  41. package/dist/scheduling/constraints/engagement-floor.d.ts +28 -0
  42. package/dist/scheduling/constraints/engagement-floor.d.ts.map +1 -0
  43. package/dist/scheduling/constraints/engagement-floor.js +79 -0
  44. package/dist/scheduling/constraints/fairness.d.ts +34 -0
  45. package/dist/scheduling/constraints/fairness.d.ts.map +1 -0
  46. package/dist/scheduling/constraints/fairness.js +149 -0
  47. package/dist/scheduling/constraints/group-composition.d.ts +19 -0
  48. package/dist/scheduling/constraints/group-composition.d.ts.map +1 -0
  49. package/dist/scheduling/constraints/group-composition.js +92 -0
  50. package/dist/scheduling/constraints/hour-budget.d.ts +13 -0
  51. package/dist/scheduling/constraints/hour-budget.d.ts.map +1 -0
  52. package/dist/scheduling/constraints/hour-budget.js +65 -0
  53. package/dist/scheduling/constraints/in-shift-breaks.d.ts +24 -0
  54. package/dist/scheduling/constraints/in-shift-breaks.d.ts.map +1 -0
  55. package/dist/scheduling/constraints/in-shift-breaks.js +99 -0
  56. package/dist/scheduling/constraints/intervals.d.ts +5 -0
  57. package/dist/scheduling/constraints/intervals.d.ts.map +1 -0
  58. package/dist/scheduling/constraints/intervals.js +17 -0
  59. package/dist/scheduling/constraints/max-shift-duration.d.ts +7 -0
  60. package/dist/scheduling/constraints/max-shift-duration.d.ts.map +1 -0
  61. package/dist/scheduling/constraints/max-shift-duration.js +38 -0
  62. package/dist/scheduling/constraints/min-rest.d.ts +22 -0
  63. package/dist/scheduling/constraints/min-rest.d.ts.map +1 -0
  64. package/dist/scheduling/constraints/min-rest.js +49 -0
  65. package/dist/scheduling/constraints/min-staffing.d.ts +14 -0
  66. package/dist/scheduling/constraints/min-staffing.d.ts.map +1 -0
  67. package/dist/scheduling/constraints/min-staffing.js +59 -0
  68. package/dist/scheduling/constraints/night-work.d.ts +24 -0
  69. package/dist/scheduling/constraints/night-work.d.ts.map +1 -0
  70. package/dist/scheduling/constraints/night-work.js +179 -0
  71. package/dist/scheduling/constraints/no-overlap.d.ts +11 -0
  72. package/dist/scheduling/constraints/no-overlap.d.ts.map +1 -0
  73. package/dist/scheduling/constraints/no-overlap.js +35 -0
  74. package/dist/scheduling/constraints/notice.d.ts +44 -0
  75. package/dist/scheduling/constraints/notice.d.ts.map +1 -0
  76. package/dist/scheduling/constraints/notice.js +140 -0
  77. package/dist/scheduling/constraints/one-shift-per-day.d.ts +7 -0
  78. package/dist/scheduling/constraints/one-shift-per-day.d.ts.map +1 -0
  79. package/dist/scheduling/constraints/one-shift-per-day.js +35 -0
  80. package/dist/scheduling/constraints/overtime.d.ts +47 -0
  81. package/dist/scheduling/constraints/overtime.d.ts.map +1 -0
  82. package/dist/scheduling/constraints/overtime.js +149 -0
  83. package/dist/scheduling/constraints/protections.d.ts +21 -0
  84. package/dist/scheduling/constraints/protections.d.ts.map +1 -0
  85. package/dist/scheduling/constraints/protections.js +93 -0
  86. package/dist/scheduling/constraints/qualification.d.ts +18 -0
  87. package/dist/scheduling/constraints/qualification.d.ts.map +1 -0
  88. package/dist/scheduling/constraints/qualification.js +78 -0
  89. package/dist/scheduling/constraints/rest-days.d.ts +30 -0
  90. package/dist/scheduling/constraints/rest-days.d.ts.map +1 -0
  91. package/dist/scheduling/constraints/rest-days.js +133 -0
  92. package/dist/scheduling/constraints/rolling-hours.d.ts +24 -0
  93. package/dist/scheduling/constraints/rolling-hours.d.ts.map +1 -0
  94. package/dist/scheduling/constraints/rolling-hours.js +147 -0
  95. package/dist/scheduling/constraints/start-interval.d.ts +20 -0
  96. package/dist/scheduling/constraints/start-interval.d.ts.map +1 -0
  97. package/dist/scheduling/constraints/start-interval.js +53 -0
  98. package/dist/scheduling/constraints/support.d.ts +48 -0
  99. package/dist/scheduling/constraints/support.d.ts.map +1 -0
  100. package/dist/scheduling/constraints/support.js +97 -0
  101. package/dist/scheduling/constraints/time-off.d.ts +7 -0
  102. package/dist/scheduling/constraints/time-off.d.ts.map +1 -0
  103. package/dist/scheduling/constraints/time-off.js +42 -0
  104. package/dist/scheduling/constraints/weekly-rest.d.ts +22 -0
  105. package/dist/scheduling/constraints/weekly-rest.d.ts.map +1 -0
  106. package/dist/scheduling/constraints/weekly-rest.js +103 -0
  107. package/dist/scheduling/cost.d.ts +56 -0
  108. package/dist/scheduling/cost.d.ts.map +1 -0
  109. package/dist/scheduling/cost.js +120 -0
  110. package/dist/scheduling/engine/construction.d.ts +22 -0
  111. package/dist/scheduling/engine/construction.d.ts.map +1 -0
  112. package/dist/scheduling/engine/construction.js +104 -0
  113. package/dist/scheduling/engine/explain.d.ts +12 -0
  114. package/dist/scheduling/engine/explain.d.ts.map +1 -0
  115. package/dist/scheduling/engine/explain.js +24 -0
  116. package/dist/scheduling/engine/objective.d.ts +73 -0
  117. package/dist/scheduling/engine/objective.d.ts.map +1 -0
  118. package/dist/scheduling/engine/objective.js +164 -0
  119. package/dist/scheduling/engine/prng.d.ts +5 -0
  120. package/dist/scheduling/engine/prng.d.ts.map +1 -0
  121. package/dist/scheduling/engine/prng.js +24 -0
  122. package/dist/scheduling/engine/propagation.d.ts +19 -0
  123. package/dist/scheduling/engine/propagation.d.ts.map +1 -0
  124. package/dist/scheduling/engine/propagation.js +40 -0
  125. package/dist/scheduling/engine/search.d.ts +50 -0
  126. package/dist/scheduling/engine/search.d.ts.map +1 -0
  127. package/dist/scheduling/engine/search.js +127 -0
  128. package/dist/scheduling/engine/state.d.ts +28 -0
  129. package/dist/scheduling/engine/state.d.ts.map +1 -0
  130. package/dist/scheduling/engine/state.js +96 -0
  131. package/dist/scheduling/engine/timeline.d.ts +179 -0
  132. package/dist/scheduling/engine/timeline.d.ts.map +1 -0
  133. package/dist/scheduling/engine/timeline.js +416 -0
  134. package/dist/scheduling/engine/verdicts.d.ts +18 -0
  135. package/dist/scheduling/engine/verdicts.d.ts.map +1 -0
  136. package/dist/scheduling/engine/verdicts.js +74 -0
  137. package/dist/scheduling/index.d.ts +10 -0
  138. package/dist/scheduling/index.d.ts.map +1 -0
  139. package/dist/scheduling/index.js +29 -0
  140. package/dist/scheduling/model.d.ts +53 -0
  141. package/dist/scheduling/model.d.ts.map +1 -0
  142. package/dist/scheduling/model.js +380 -0
  143. package/dist/scheduling/operations.d.ts +134 -0
  144. package/dist/scheduling/operations.d.ts.map +1 -0
  145. package/dist/scheduling/operations.js +376 -0
  146. package/dist/scheduling/provenance.d.ts +33 -0
  147. package/dist/scheduling/provenance.d.ts.map +1 -0
  148. package/dist/scheduling/provenance.js +70 -0
  149. package/dist/scheduling/rules.d.ts +23 -0
  150. package/dist/scheduling/rules.d.ts.map +1 -0
  151. package/dist/scheduling/rules.js +37 -0
  152. package/dist/scheduling/scheduler.class.d.ts +24 -0
  153. package/dist/scheduling/scheduler.class.d.ts.map +1 -0
  154. package/dist/scheduling/scheduler.class.js +150 -0
  155. package/dist/scheduling/time.d.ts +138 -0
  156. package/dist/scheduling/time.d.ts.map +1 -0
  157. package/dist/scheduling/time.js +267 -0
  158. package/dist/scheduling/types.d.ts +938 -0
  159. package/dist/scheduling/types.d.ts.map +1 -0
  160. package/dist/scheduling/types.js +19 -0
  161. package/dist/types/matcher.d.ts +86 -2
  162. package/dist/types/matcher.d.ts.map +1 -1
  163. package/dist/utils/keys.d.ts +1 -0
  164. package/dist/utils/keys.d.ts.map +1 -1
  165. package/dist/utils/keys.js +6 -0
  166. package/package.json +4 -2
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ /**
3
+ * Working-time volume — Directive 2003/88/EC Art 6 and Art 16(b).
4
+ *
5
+ * The headline EU rule is "average working time for each seven-day period,
6
+ * including overtime, not exceeding 48 hours", averaged over a reference period
7
+ * of up to four months — extensible to six by derogation and twelve by
8
+ * collective agreement.
9
+ *
10
+ * The part that defeats a per-week hour budget: **any** seven-day period, and
11
+ * **any** four-month window. A person can sit under 48h in every calendar week
12
+ * and still average over it across week boundaries, and a fixed quarterly
13
+ * reference period hides an overrun that straddles two quarters. So every limit
14
+ * here is evaluated over rolling windows anchored on the person's own
15
+ * assignment boundaries.
16
+ *
17
+ * Art 16(b) also requires paid annual leave and sick leave to be "not included
18
+ * or neutral" in the average. Counting an absent week as zero hours would drag
19
+ * a person's average down and licence a heavier following week, so neutralised
20
+ * absence shortens the window's divisor instead.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.rollingHours = exports.WEEKLY_LIMIT_CITATION = void 0;
24
+ const support_1 = require("./support");
25
+ exports.WEEKLY_LIMIT_CITATION = 'Directive 2003/88/EC Art 6(b), Art 16(b)';
26
+ function rollingHours(limits) {
27
+ return (0, support_1.fromVerdict)({
28
+ id: 'rolling-hours',
29
+ hardness: 'hard',
30
+ weight: 1,
31
+ citation: exports.WEEKLY_LIMIT_CITATION,
32
+ verdict(state, pair) {
33
+ const inst = (0, support_1.instanceOf)(state, pair);
34
+ if (!inst)
35
+ return (0, support_1.pass)('rolling-hours', 'unknown shift');
36
+ const timeline = (0, support_1.timelineFor)(state, pair.employeeId);
37
+ const range = (0, support_1.rangeOf)(inst);
38
+ const probe = { ...range, id: (0, support_1.entryIdOf)(pair), workingMinutes: inst.workingMinutes };
39
+ return timeline.withEntry(probe, (t) => {
40
+ if (limits.maxPerShiftMinutes !== undefined && inst.workingMinutes > limits.maxPerShiftMinutes) {
41
+ return over('shift', inst.workingMinutes, limits.maxPerShiftMinutes, pair.employeeId, inst.id);
42
+ }
43
+ // Daily cap: the ordinary limit, or the extended one when an
44
+ // averaging window is configured and still holds.
45
+ if (limits.maxPerDayMinutes !== undefined) {
46
+ const dayTotal = t.maxWorkingMinutesInAnyWindow(support_1.MINUTES_PER_DAY, windowFor(range, support_1.MINUTES_PER_DAY));
47
+ const cap = limits.maxPerDayExtendedMinutes !== undefined && dayAverageHolds(t, limits, range)
48
+ ? limits.maxPerDayExtendedMinutes
49
+ : limits.maxPerDayMinutes;
50
+ if (dayTotal > cap)
51
+ return over('day', dayTotal, cap, pair.employeeId, inst.id);
52
+ }
53
+ if (limits.maxPerWeekAbsoluteMinutes !== undefined) {
54
+ const span = 7 * support_1.MINUTES_PER_DAY;
55
+ const weekTotal = t.maxWorkingMinutesInAnyWindow(span, windowFor(range, span));
56
+ if (weekTotal > limits.maxPerWeekAbsoluteMinutes) {
57
+ return over('week', weekTotal, limits.maxPerWeekAbsoluteMinutes, pair.employeeId, inst.id);
58
+ }
59
+ }
60
+ for (const average of limits.rollingAverages ?? []) {
61
+ const span = average.windowDays * support_1.MINUTES_PER_DAY;
62
+ const breach = worstAverageBreach(state, t, pair.employeeId, average.maxMinutes, span, range, limits);
63
+ if (breach !== null) {
64
+ const label = average.label ?? `${(0, support_1.h)(average.maxMinutes)}/${average.windowDays}d`;
65
+ return (0, support_1.fail)('rolling-hours', 'hard', `employee "${pair.employeeId}" would work ${(0, support_1.h)(breach.worked)} in some ${average.windowDays}-day window, over the ${label} limit of ${(0, support_1.h)(breach.allowance)}`, {
66
+ actual: breach.worked,
67
+ required: breach.allowance,
68
+ unit: 'minutes',
69
+ citation: exports.WEEKLY_LIMIT_CITATION,
70
+ });
71
+ }
72
+ }
73
+ if (limits.maxPerPeriodMinutes !== undefined) {
74
+ const total = t.workingMinutesIn({ start: 0, end: state.ctx.periodDays * support_1.MINUTES_PER_DAY });
75
+ if (total > limits.maxPerPeriodMinutes) {
76
+ return over('period', total, limits.maxPerPeriodMinutes, pair.employeeId, inst.id);
77
+ }
78
+ }
79
+ return (0, support_1.pass)('rolling-hours', 'within every configured working-time limit', {
80
+ unit: 'minutes',
81
+ citation: exports.WEEKLY_LIMIT_CITATION,
82
+ });
83
+ });
84
+ },
85
+ });
86
+ }
87
+ exports.rollingHours = rollingHours;
88
+ function over(scope, actual, required, employeeId, instanceId) {
89
+ return (0, support_1.fail)('rolling-hours', 'hard', `employee "${employeeId}" would work ${(0, support_1.h)(actual)} per ${scope} taking "${instanceId}", over the ${(0, support_1.h)(required)} limit`, { actual, required, unit: 'minutes', citation: exports.WEEKLY_LIMIT_CITATION });
90
+ }
91
+ /** Windows overlapping `range` are the only ones the new shift can worsen. */
92
+ function windowFor(range, span) {
93
+ return { start: range.start - span, end: range.end + span };
94
+ }
95
+ /** Whether the extended daily cap is earned by the averaging window still holding. */
96
+ function dayAverageHolds(timeline, limits, range) {
97
+ if (limits.dayAverageWindowDays === undefined || limits.maxPerDayMinutes === undefined)
98
+ return false;
99
+ const span = limits.dayAverageWindowDays * support_1.MINUTES_PER_DAY;
100
+ const worst = timeline.maxWorkingMinutesInAnyWindow(span, windowFor(range, span));
101
+ return worst <= limits.maxPerDayMinutes * limits.dayAverageWindowDays;
102
+ }
103
+ /**
104
+ * Worst breach of a rolling average across the windows the new shift can worsen,
105
+ * with the allowance reduced *per window* for neutralised absence.
106
+ *
107
+ * Art 16(b) makes paid leave and sick leave neutral in the average. Treating
108
+ * them as zero-hour days would let a fortnight off buy a 96-hour week, so the
109
+ * absent time is removed from each window's allowance — but only the absence
110
+ * that actually falls inside that window: sick leave in March must not shrink a
111
+ * January week's budget.
112
+ *
113
+ * Worked minutes and neutral minutes are both piecewise-linear in the window's
114
+ * start, with breakpoints at entry and absence boundaries, so the extreme lies
115
+ * on a window whose edge touches one of those boundaries (or the probe bounds).
116
+ */
117
+ function worstAverageBreach(state, timeline, employeeId, maxMinutes, span, range, limits) {
118
+ const bounds = windowFor(range, span);
119
+ const kinds = limits.neutraliseAbsenceKinds;
120
+ const neutral = kinds?.length
121
+ ? (state.ctx.absences.get(employeeId) ?? []).filter((a) => a.kind !== undefined && kinds.includes(a.kind))
122
+ : [];
123
+ if (neutral.length === 0) {
124
+ const worked = timeline.maxWorkingMinutesInAnyWindow(span, bounds);
125
+ return worked > maxMinutes ? { worked, allowance: maxMinutes } : null;
126
+ }
127
+ const starts = new Set([bounds.start, bounds.end - span]);
128
+ for (const entry of timeline.entriesIn({ start: bounds.start - span, end: bounds.end + span })) {
129
+ starts.add(entry.start);
130
+ starts.add(entry.end - span);
131
+ }
132
+ for (const a of neutral) {
133
+ starts.add(a.start);
134
+ starts.add(a.end - span);
135
+ }
136
+ let worst = null;
137
+ for (const start of starts) {
138
+ const window = { start, end: start + span };
139
+ const worked = timeline.workingMinutesIn(window);
140
+ const neutralMinutes = neutral.reduce((sum, a) => sum + Math.max(0, Math.min(a.end, window.end) - Math.max(a.start, window.start)), 0);
141
+ const allowance = maxMinutes * (1 - Math.min(1, neutralMinutes / span));
142
+ const excess = worked - allowance;
143
+ if (excess > 0 && (worst === null || excess > worst.excess))
144
+ worst = { worked, allowance, excess };
145
+ }
146
+ return worst === null ? null : { worked: worst.worked, allowance: worst.allowance };
147
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Minimum interval between shift *starts* — Poland's *doba pracownicza*.
3
+ *
4
+ * Polish law defines a "worker's day" as the 24 consecutive hours from the
5
+ * start of work. Beginning work again inside that window counts as overtime
6
+ * regardless of how much rest was taken in between, so a person who finishes at
7
+ * 14:00 and starts again at 06:00 the next morning has had 16 hours off — well
8
+ * clear of any rest rule — and is still inside the previous *doba*.
9
+ *
10
+ * That makes it a distinct shape from `daily-rest`: it is keyed on the distance
11
+ * between two *starts*, not on the gap between an end and the next start. No
12
+ * rest-based rule can express it, which is why it gets its own constraint
13
+ * rather than a parameter on another.
14
+ */
15
+ import type { SchedulingConstraint } from '../types';
16
+ export declare const START_INTERVAL_CITATION = "PL Kodeks pracy art. 128 \u00A73 (doba pracownicza)";
17
+ export declare function startInterval(rule: {
18
+ minMinutes: number;
19
+ }): SchedulingConstraint;
20
+ //# sourceMappingURL=start-interval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-interval.d.ts","sourceRoot":"","sources":["../../../src/scheduling/constraints/start-interval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGlE,eAAO,MAAM,uBAAuB,wDAAmD,CAAC;AAExF,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,oBAAoB,CAsChF"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /**
3
+ * Minimum interval between shift *starts* — Poland's *doba pracownicza*.
4
+ *
5
+ * Polish law defines a "worker's day" as the 24 consecutive hours from the
6
+ * start of work. Beginning work again inside that window counts as overtime
7
+ * regardless of how much rest was taken in between, so a person who finishes at
8
+ * 14:00 and starts again at 06:00 the next morning has had 16 hours off — well
9
+ * clear of any rest rule — and is still inside the previous *doba*.
10
+ *
11
+ * That makes it a distinct shape from `daily-rest`: it is keyed on the distance
12
+ * between two *starts*, not on the gap between an end and the next start. No
13
+ * rest-based rule can express it, which is why it gets its own constraint
14
+ * rather than a parameter on another.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.startInterval = exports.START_INTERVAL_CITATION = void 0;
18
+ const support_1 = require("./support");
19
+ exports.START_INTERVAL_CITATION = 'PL Kodeks pracy art. 128 §3 (doba pracownicza)';
20
+ function startInterval(rule) {
21
+ return (0, support_1.fromVerdict)({
22
+ id: 'start-interval',
23
+ hardness: 'hard',
24
+ weight: 1,
25
+ citation: exports.START_INTERVAL_CITATION,
26
+ verdict(state, pair) {
27
+ const inst = (0, support_1.instanceOf)(state, pair);
28
+ if (!inst)
29
+ return (0, support_1.pass)('start-interval', 'unknown shift');
30
+ const timeline = (0, support_1.timelineFor)(state, pair.employeeId);
31
+ const range = (0, support_1.rangeOf)(inst);
32
+ const ownId = (0, support_1.entryIdOf)(pair);
33
+ let closest = Infinity;
34
+ for (const entry of timeline.all()) {
35
+ if (entry.id === ownId)
36
+ continue;
37
+ const distance = Math.abs(entry.start - range.start);
38
+ if (distance < closest)
39
+ closest = distance;
40
+ }
41
+ if (closest < rule.minMinutes) {
42
+ return (0, support_1.fail)('start-interval', 'hard', `employee "${pair.employeeId}" would start "${inst.id}" only ${(0, support_1.h)(closest)} after another shift's start, inside the ${(0, support_1.h)(rule.minMinutes)} working day`, { actual: closest, required: rule.minMinutes, unit: 'minutes', citation: exports.START_INTERVAL_CITATION });
43
+ }
44
+ return (0, support_1.pass)('start-interval', `starts are at least ${(0, support_1.h)(rule.minMinutes)} apart`, {
45
+ actual: closest === Infinity ? undefined : closest,
46
+ required: rule.minMinutes,
47
+ unit: 'minutes',
48
+ citation: exports.START_INTERVAL_CITATION,
49
+ });
50
+ },
51
+ });
52
+ }
53
+ exports.startInterval = startInterval;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Shared helpers for the rule-driven constraints.
3
+ *
4
+ * Every constraint in this directory needs the same four things: the person
5
+ * behind an employee record, that person's timeline, the rules that apply to
6
+ * them, and a structured verdict. Centralizing them keeps each rule file about
7
+ * its rule.
8
+ */
9
+ import type { AssignmentPair, ModelContext, RuleVerdict, SchedulingConstraint, SearchState, Severity, ShiftInstance, WorkingTimeRules } from '../types';
10
+ import type { MinuteRange } from '../time';
11
+ import type { PersonTimeline } from '../engine/timeline';
12
+ export declare const MINUTES_PER_DAY = 1440;
13
+ /** The natural person behind an employee record. */
14
+ export declare function personIdFor(ctx: ModelContext, employeeId: string): string;
15
+ /** The person's timeline, including history and every contract they hold. */
16
+ export declare function timelineFor(state: SearchState, employeeId: string): PersonTimeline;
17
+ /** Rules applying to this employee, after merging their overrides over the global set. */
18
+ export declare function rulesFor(ctx: ModelContext, employeeId: string): WorkingTimeRules;
19
+ /** The elapsed span of a shift instance. */
20
+ export declare function rangeOf(inst: ShiftInstance): MinuteRange;
21
+ /** The timeline entry id a pair would occupy, so rules can exclude it from their own lookups. */
22
+ export declare function entryIdOf(pair: AssignmentPair): string;
23
+ /** Resolve a pair to its instance, or `undefined` when the id is unknown. */
24
+ export declare function instanceOf(state: SearchState, pair: AssignmentPair): ShiftInstance | undefined;
25
+ /**
26
+ * A window of `days` centred on `range`, clamped to nothing — history lives at
27
+ * negative minutes, so windows deliberately extend before the period start.
28
+ */
29
+ export declare function windowAround(range: MinuteRange, days: number): MinuteRange;
30
+ /** Build a passing verdict. */
31
+ export declare function pass(ruleId: string, message: string, extra?: Partial<RuleVerdict>): RuleVerdict;
32
+ /** Build a failing verdict. */
33
+ export declare function fail(ruleId: string, severity: Severity, message: string, extra?: Partial<RuleVerdict>): RuleVerdict;
34
+ /** Hours, to one decimal, for human-readable messages. */
35
+ export declare function h(minutes: number): string;
36
+ /**
37
+ * Wire a rule's `verdict` into the `delta`/`explain` members the engine and the
38
+ * legacy reason strings still use, so each rule file states its logic once.
39
+ *
40
+ * `magnitude` converts a failing verdict into a breach size: local search needs
41
+ * to know a rest gap is 10 minutes short rather than merely "short", or it sits
42
+ * on a plateau with no gradient to follow.
43
+ */
44
+ export declare function fromVerdict(spec: Omit<SchedulingConstraint, 'delta' | 'explain' | 'verdict'> & {
45
+ verdict(state: SearchState, pair: AssignmentPair): RuleVerdict;
46
+ magnitude?(v: RuleVerdict): number;
47
+ }): SchedulingConstraint;
48
+ //# sourceMappingURL=support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support.d.ts","sourceRoot":"","sources":["../../../src/scheduling/constraints/support.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACR,cAAc,EACd,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,aAAa,EACb,gBAAgB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,CAElF;AAED,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAEhF;AAED,4CAA4C;AAC5C,wBAAgB,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,WAAW,CAExD;AAED,iGAAiG;AACjG,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAEtD;AAED,6EAA6E;AAC7E,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,GAAG,aAAa,GAAG,SAAS,CAE9F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAG1E;AAED,+BAA+B;AAC/B,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAEnG;AAED,+BAA+B;AAC/B,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAEvH;AAED,0DAA0D;AAC1D,wBAAgB,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACvB,IAAI,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC,GAAG;IAChE,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,GAAG,WAAW,CAAC;IAC/D,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;CACtC,GACF,oBAAoB,CActB"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /**
3
+ * Shared helpers for the rule-driven constraints.
4
+ *
5
+ * Every constraint in this directory needs the same four things: the person
6
+ * behind an employee record, that person's timeline, the rules that apply to
7
+ * them, and a structured verdict. Centralizing them keeps each rule file about
8
+ * its rule.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.fromVerdict = exports.h = exports.fail = exports.pass = exports.windowAround = exports.instanceOf = exports.entryIdOf = exports.rangeOf = exports.rulesFor = exports.timelineFor = exports.personIdFor = exports.MINUTES_PER_DAY = void 0;
12
+ const state_1 = require("../engine/state");
13
+ exports.MINUTES_PER_DAY = 1440;
14
+ /** The natural person behind an employee record. */
15
+ function personIdFor(ctx, employeeId) {
16
+ return ctx.personIdOf.get(employeeId) ?? employeeId;
17
+ }
18
+ exports.personIdFor = personIdFor;
19
+ /** The person's timeline, including history and every contract they hold. */
20
+ function timelineFor(state, employeeId) {
21
+ return state.timelines.for(personIdFor(state.ctx, employeeId));
22
+ }
23
+ exports.timelineFor = timelineFor;
24
+ /** Rules applying to this employee, after merging their overrides over the global set. */
25
+ function rulesFor(ctx, employeeId) {
26
+ return ctx.rulesByEmployee.get(employeeId) ?? ctx.rules;
27
+ }
28
+ exports.rulesFor = rulesFor;
29
+ /** The elapsed span of a shift instance. */
30
+ function rangeOf(inst) {
31
+ return { start: inst.startMinute, end: inst.endMinute };
32
+ }
33
+ exports.rangeOf = rangeOf;
34
+ /** The timeline entry id a pair would occupy, so rules can exclude it from their own lookups. */
35
+ function entryIdOf(pair) {
36
+ return (0, state_1.timelineEntryId)(pair.employeeId, pair.shiftInstanceId);
37
+ }
38
+ exports.entryIdOf = entryIdOf;
39
+ /** Resolve a pair to its instance, or `undefined` when the id is unknown. */
40
+ function instanceOf(state, pair) {
41
+ return state.ctx.instanceById.get(pair.shiftInstanceId);
42
+ }
43
+ exports.instanceOf = instanceOf;
44
+ /**
45
+ * A window of `days` centred on `range`, clamped to nothing — history lives at
46
+ * negative minutes, so windows deliberately extend before the period start.
47
+ */
48
+ function windowAround(range, days) {
49
+ const span = days * exports.MINUTES_PER_DAY;
50
+ return { start: range.start - span, end: range.end + span };
51
+ }
52
+ exports.windowAround = windowAround;
53
+ /** Build a passing verdict. */
54
+ function pass(ruleId, message, extra = {}) {
55
+ return { ruleId, pass: true, severity: 'soft', message, ...extra };
56
+ }
57
+ exports.pass = pass;
58
+ /** Build a failing verdict. */
59
+ function fail(ruleId, severity, message, extra = {}) {
60
+ return { ruleId, pass: false, severity, message, ...extra };
61
+ }
62
+ exports.fail = fail;
63
+ /** Hours, to one decimal, for human-readable messages. */
64
+ function h(minutes) {
65
+ return `${(minutes / 60).toFixed(1)}h`;
66
+ }
67
+ exports.h = h;
68
+ /**
69
+ * Wire a rule's `verdict` into the `delta`/`explain` members the engine and the
70
+ * legacy reason strings still use, so each rule file states its logic once.
71
+ *
72
+ * `magnitude` converts a failing verdict into a breach size: local search needs
73
+ * to know a rest gap is 10 minutes short rather than merely "short", or it sits
74
+ * on a plateau with no gradient to follow.
75
+ */
76
+ function fromVerdict(spec) {
77
+ const magnitude = spec.magnitude ?? defaultMagnitude;
78
+ return {
79
+ ...spec,
80
+ verdict: spec.verdict,
81
+ delta(state, pair) {
82
+ const v = spec.verdict(state, pair);
83
+ return v.pass ? 0 : Math.max(1, magnitude(v));
84
+ },
85
+ explain(state, pair) {
86
+ const v = spec.verdict(state, pair);
87
+ return v.pass ? null : v.message;
88
+ },
89
+ };
90
+ }
91
+ exports.fromVerdict = fromVerdict;
92
+ /** Shortfall or excess against the bound, when both are known; 1 otherwise. */
93
+ function defaultMagnitude(v) {
94
+ if (v.actual === undefined || v.required === undefined)
95
+ return 1;
96
+ return Math.max(1, Math.abs(v.required - v.actual));
97
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Time-off — an employee never works during their blocked intervals. Hard by
3
+ * default; prunes ineligible pairs before search.
4
+ */
5
+ import type { SchedulingConstraint } from '../types';
6
+ export declare function timeOff(): SchedulingConstraint;
7
+ //# sourceMappingURL=time-off.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-off.d.ts","sourceRoot":"","sources":["../../../src/scheduling/constraints/time-off.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,wBAAgB,OAAO,IAAI,oBAAoB,CA6B9C"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Time-off — an employee never works during their blocked intervals. Hard by
4
+ * default; prunes ineligible pairs before search.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.timeOff = void 0;
8
+ const intervals_1 = require("./intervals");
9
+ function timeOff() {
10
+ return {
11
+ id: 'time-off',
12
+ hardness: 'hard',
13
+ prune(ctx, eligibility) {
14
+ for (const [employeeId, instances] of eligibility) {
15
+ const blocked = ctx.employeeBlockedIntervals.get(employeeId) ?? [];
16
+ if (blocked.length === 0)
17
+ continue;
18
+ for (const instanceId of [...instances]) {
19
+ const inst = ctx.instanceById.get(instanceId);
20
+ if (!inst)
21
+ continue;
22
+ if (blocked.some((b) => (0, intervals_1.overlaps)(inst.startMinute, inst.endMinute, b.start, b.end))) {
23
+ instances.delete(instanceId);
24
+ }
25
+ }
26
+ }
27
+ },
28
+ delta(state, pair) {
29
+ const inst = state.ctx.instanceById.get(pair.shiftInstanceId);
30
+ if (!inst)
31
+ return 0;
32
+ const blocked = state.ctx.employeeBlockedIntervals.get(pair.employeeId) ?? [];
33
+ return blocked.some((b) => (0, intervals_1.overlaps)(inst.startMinute, inst.endMinute, b.start, b.end)) ? 1 : 0;
34
+ },
35
+ explain(state, pair) {
36
+ return this.delta(state, pair) > 0
37
+ ? `employee "${pair.employeeId}" has time off during "${pair.shiftInstanceId}"`
38
+ : null;
39
+ },
40
+ };
41
+ }
42
+ exports.timeOff = timeOff;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Weekly rest — Directive 2003/88/EC Art 5, with the Art 16(a) averaging option.
3
+ *
4
+ * Art 5 is "24 uninterrupted hours plus the 11 hours' daily rest per each
5
+ * seven-day period" — 35h — dropping to 24h where objective, technical or work
6
+ * organisation conditions justify it. National floors range from 24h (IT, IE)
7
+ * through 35h (FR, PL, DK, FI, CZ, PT) and 36h (NL, SE, AT) to 48h (RO, EE).
8
+ *
9
+ * Two shapes matter beyond the number:
10
+ *
11
+ * - **Rolling, not calendar.** "Per each seven-day period" is any seven days,
12
+ * so a person can satisfy every Monday-to-Sunday week and still go eleven
13
+ * days without a proper break across a week boundary.
14
+ * - **Two-level.** Estonia requires 36h every week *and* 48h averaged over the
15
+ * reference period; Poland 24h with a 35h two-week average. A single
16
+ * threshold cannot express that, so `absoluteFloorMinutes` sits underneath
17
+ * `minMinutes` and both are checked.
18
+ */
19
+ import type { SchedulingConstraint, WeeklyRestRule } from '../types';
20
+ export declare const WEEKLY_REST_CITATION = "Directive 2003/88/EC Art 5";
21
+ export declare function weeklyRest(rule: WeeklyRestRule): SchedulingConstraint;
22
+ //# sourceMappingURL=weekly-rest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weekly-rest.d.ts","sourceRoot":"","sources":["../../../src/scheduling/constraints/weekly-rest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAe,oBAAoB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAIlF,eAAO,MAAM,oBAAoB,+BAA+B,CAAC;AAEjE,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,oBAAoB,CA2DrE"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ /**
3
+ * Weekly rest — Directive 2003/88/EC Art 5, with the Art 16(a) averaging option.
4
+ *
5
+ * Art 5 is "24 uninterrupted hours plus the 11 hours' daily rest per each
6
+ * seven-day period" — 35h — dropping to 24h where objective, technical or work
7
+ * organisation conditions justify it. National floors range from 24h (IT, IE)
8
+ * through 35h (FR, PL, DK, FI, CZ, PT) and 36h (NL, SE, AT) to 48h (RO, EE).
9
+ *
10
+ * Two shapes matter beyond the number:
11
+ *
12
+ * - **Rolling, not calendar.** "Per each seven-day period" is any seven days,
13
+ * so a person can satisfy every Monday-to-Sunday week and still go eleven
14
+ * days without a proper break across a week boundary.
15
+ * - **Two-level.** Estonia requires 36h every week *and* 48h averaged over the
16
+ * reference period; Poland 24h with a 35h two-week average. A single
17
+ * threshold cannot express that, so `absoluteFloorMinutes` sits underneath
18
+ * `minMinutes` and both are checked.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.weeklyRest = exports.WEEKLY_REST_CITATION = void 0;
22
+ const support_1 = require("./support");
23
+ exports.WEEKLY_REST_CITATION = 'Directive 2003/88/EC Art 5';
24
+ function weeklyRest(rule) {
25
+ const windowMinutes = rule.windowDays * support_1.MINUTES_PER_DAY;
26
+ const averagingMinutes = rule.averageOverDays ? rule.averageOverDays * support_1.MINUTES_PER_DAY : undefined;
27
+ return (0, support_1.fromVerdict)({
28
+ id: 'weekly-rest',
29
+ hardness: 'hard',
30
+ weight: 1,
31
+ citation: exports.WEEKLY_REST_CITATION,
32
+ verdict(state, pair) {
33
+ const inst = (0, support_1.instanceOf)(state, pair);
34
+ if (!inst)
35
+ return (0, support_1.pass)('weekly-rest', 'unknown shift');
36
+ const timeline = (0, support_1.timelineFor)(state, pair.employeeId);
37
+ const range = (0, support_1.rangeOf)(inst);
38
+ // Only windows the new shift could have worsened are worth testing.
39
+ const bounds = { start: range.start - windowMinutes, end: range.end + windowMinutes };
40
+ const probeEntry = { ...range, id: (0, support_1.entryIdOf)(pair), workingMinutes: inst.workingMinutes };
41
+ return timeline.withEntry(probeEntry, (t) => {
42
+ // The floor that must hold in *every* window. Without averaging
43
+ // the headline figure is itself the per-window requirement.
44
+ const floor = averagingMinutes ? (rule.absoluteFloorMinutes ?? 0) : rule.minMinutes;
45
+ if (floor > 0) {
46
+ const worst = t.minLongestRestInAnyWindow(windowMinutes, bounds);
47
+ if (worst < floor) {
48
+ return (0, support_1.fail)('weekly-rest', 'hard', `employee "${pair.employeeId}" would have only ${(0, support_1.h)(worst)} continuous rest in some ${rule.windowDays}-day window, below the ${(0, support_1.h)(floor)} floor`, { actual: worst, required: floor, unit: 'minutes', citation: exports.WEEKLY_REST_CITATION });
49
+ }
50
+ }
51
+ if (averagingMinutes) {
52
+ // Over the longer window the person must accumulate the rest
53
+ // they would have had from each short window.
54
+ const windows = averagingMinutes / windowMinutes;
55
+ const required = rule.minMinutes * windows;
56
+ const worstAveraged = totalQualifyingRest(t, averagingMinutes, bounds, rule.minMinutes);
57
+ if (worstAveraged < required) {
58
+ return (0, support_1.fail)('weekly-rest', 'hard', `employee "${pair.employeeId}" would average ${(0, support_1.h)(worstAveraged / windows)} weekly rest over ${rule.averageOverDays} days, below the ${(0, support_1.h)(rule.minMinutes)} average`, { actual: worstAveraged, required, unit: 'minutes', citation: exports.WEEKLY_REST_CITATION });
59
+ }
60
+ }
61
+ return (0, support_1.pass)('weekly-rest', `weekly rest of at least ${(0, support_1.h)(rule.minMinutes)} preserved`, {
62
+ required: rule.minMinutes,
63
+ unit: 'minutes',
64
+ citation: exports.WEEKLY_REST_CITATION,
65
+ });
66
+ });
67
+ },
68
+ });
69
+ }
70
+ exports.weeklyRest = weeklyRest;
71
+ /**
72
+ * Total rest, counting only stretches long enough to qualify, in the worst
73
+ * averaging window.
74
+ *
75
+ * Averaging counts *rest periods*, not idle minutes: eight scattered hours are
76
+ * not half a weekly rest. Only unbroken stretches of at least `minPer` count,
77
+ * and each contributes at most one qualifying period's worth.
78
+ */
79
+ function totalQualifyingRest(timeline, averagingMinutes, bounds, minPer) {
80
+ // Window starts anchored on entry boundaries, never a day grid (a grid
81
+ // silently misses straddling windows — see CLAUDE.md). The worst (least
82
+ // rest) windows are the ones aligning their edges with work, so probe
83
+ // every start where a window edge touches an entry boundary.
84
+ const starts = new Set([bounds.start, bounds.end]);
85
+ for (const entry of timeline.entriesIn({ start: bounds.start, end: bounds.end + averagingMinutes })) {
86
+ for (const s of [entry.start, entry.end, entry.start - averagingMinutes + 1, entry.end - averagingMinutes]) {
87
+ if (s >= bounds.start && s <= bounds.end)
88
+ starts.add(s);
89
+ }
90
+ }
91
+ let worst = Infinity;
92
+ for (const start of starts) {
93
+ const window = { start, end: start + averagingMinutes };
94
+ let total = 0;
95
+ for (const gap of timeline.restGapsIn(window)) {
96
+ if (gap >= minPer)
97
+ total += minPer * Math.floor(gap / minPer);
98
+ }
99
+ if (total < worst)
100
+ worst = total;
101
+ }
102
+ return worst === Infinity ? 0 : worst;
103
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Labour-cost arithmetic — pure logic, shared by the solve objective, the
3
+ * repair candidate ranking and the result's cost summary.
4
+ *
5
+ * One implementation on purpose: an objective that minimises a different cost
6
+ * than the ranking reports would steer the roster one way and justify it
7
+ * another. All money is minor units (cents), integral until the final rounding.
8
+ *
9
+ * What is priced, and what deliberately is not:
10
+ *
11
+ * - The *working* portion of a span is paid at the hourly rate, uplifted by
12
+ * whichever premium bands apply (night / Sunday / holiday), stacked
13
+ * additively or by maximum as the cost model says.
14
+ * - The non-working remainder of a *duty-classified* span — stand-by hours
15
+ * that occupy the clock without counting as work — is paid flat at
16
+ * `standbyRateFraction` of the rate (Estonia's *valveaeg* owes ≥ 1/10 of
17
+ * the agreed wage). No premiums apply to it; unset means unpaid.
18
+ * - Overtime is a per-employee surcharge on the minutes worked past
19
+ * `overtimeAfterMinutes`, at `(overtimeMultiplier − 1)` on top of the base
20
+ * already priced per shift. Kept separate from the per-shift price because
21
+ * which minutes are "the overtime ones" is an accounting fiction — the
22
+ * surcharge belongs to the person's total, not to any one shift.
23
+ */
24
+ import type { Employee, EmployeeCost, EngagementRule, SearchState, ShiftInstance } from './types';
25
+ /**
26
+ * Price of one shift for one cost model, excluding any overtime surcharge.
27
+ *
28
+ * Premium predicates are judged on the instance: `night` applies when any of
29
+ * the shift falls in the configured night band, `sunday`/`holiday` on the start
30
+ * day. Romania stacks premiums additively (overtime 75% + night 25% + holiday
31
+ * 100%); most jurisdictions apply only the largest, so `'max'` is the default —
32
+ * under-stating the Romanian bill rather than over-stating everyone else's.
33
+ */
34
+ export declare function shiftCostCents(inst: ShiftInstance, cost: EmployeeCost | undefined, engagement?: EngagementRule): number;
35
+ /**
36
+ * Surcharge owed on `workedMinutes` of total working time — the extra above
37
+ * base rate for the minutes past the overtime threshold. Base pay for those
38
+ * minutes is already in the per-shift price, so only the uplift is added here.
39
+ */
40
+ export declare function overtimeSurchargeCents(workedMinutes: number, cost: EmployeeCost | undefined): number;
41
+ /**
42
+ * Marginal cost of adding one shift on top of `workedMinutes` already assigned:
43
+ * the shift's own price plus the overtime surcharge it newly triggers. This is
44
+ * the number a call-out decision needs — the same shift is dearer in the hands
45
+ * of someone already at their threshold.
46
+ */
47
+ export declare function marginalCostCents(inst: ShiftInstance, employee: Employee, workedMinutes: number, engagement?: EngagementRule): number;
48
+ /**
49
+ * Whole-roster cost, per employee and total, or `undefined` when nobody has a
50
+ * cost model — so rosters without one keep a byte-identical result shape.
51
+ */
52
+ export declare function rosterCost(state: SearchState): {
53
+ totalCents: number;
54
+ byEmployee: Record<string, number>;
55
+ } | undefined;
56
+ //# sourceMappingURL=cost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/scheduling/cost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGlG;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,EAAE,UAAU,CAAC,EAAE,cAAc,GAAG,MAAM,CAsBvH;AAaD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CAIpG;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EACrB,UAAU,CAAC,EAAE,cAAc,GAC5B,MAAM,CAQR;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,SAAS,CAiBrH"}