@jsb188/schedule 1.1.11

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 (60) hide show
  1. package/package.json +61 -0
  2. package/src/constants/schedule.ts +549 -0
  3. package/src/css.d.ts +7 -0
  4. package/src/libs/gantt-geometry.ts +771 -0
  5. package/src/libs/gantt-histogram.ts +124 -0
  6. package/src/libs/gantt-keyboard.ts +113 -0
  7. package/src/libs/gantt-state.ts +57 -0
  8. package/src/libs/gantt-url.ts +63 -0
  9. package/src/modules/Gantt.helpers.ts +138 -0
  10. package/src/modules/Gantt.tsx +719 -0
  11. package/src/types/schedule.d.ts +1149 -0
  12. package/src/ui/ActivityFormUI.tsx +133 -0
  13. package/src/ui/GanttEditorsUI.tsx +102 -0
  14. package/src/ui/GanttHistogramUI.tsx +236 -0
  15. package/src/ui/GanttUI.tsx +792 -0
  16. package/src/ui/ProjectFormUI.tsx +273 -0
  17. package/src/ui/ProjectMobileListUI.tsx +80 -0
  18. package/src/ui/ProjectToolbarUI.tsx +54 -0
  19. package/src/ui/RelationshipListUI.tsx +176 -0
  20. package/src/ui/ScheduleRunUI.tsx +173 -0
  21. package/src/ui/ScheduleSettingsUI.tsx +420 -0
  22. package/src/utils/coverage.helpers.ts +679 -0
  23. package/src/utils/coverage.ts +630 -0
  24. package/src/utils/cpm.helpers.ts +674 -0
  25. package/src/utils/cpm.ts +907 -0
  26. package/src/utils/cpmLeveling.helpers.ts +564 -0
  27. package/src/utils/cpmLeveling.ts +367 -0
  28. package/src/utils/defaults.ts +8 -0
  29. package/src/utils/eligibility.ts +457 -0
  30. package/src/utils/planCsv.ts +344 -0
  31. package/src/utils/predecessorText.ts +96 -0
  32. package/src/utils/recurrence.ts +616 -0
  33. package/src/utils/request.ts +153 -0
  34. package/src/utils/resource.ts +182 -0
  35. package/src/utils/rule.ts +216 -0
  36. package/src/utils/run.ts +43 -0
  37. package/src/utils/series.ts +161 -0
  38. package/src/utils/slot.ts +208 -0
  39. package/src/utils/workTime.ts +1382 -0
  40. package/tests/coverage.fixtures.ts +111 -0
  41. package/tests/coverage.test.ts +503 -0
  42. package/tests/cpm.bench.test.ts +154 -0
  43. package/tests/cpm.test.ts +354 -0
  44. package/tests/cpmCorrectness.test.ts +327 -0
  45. package/tests/cpmLeveling.test.ts +471 -0
  46. package/tests/eligibility.test.ts +320 -0
  47. package/tests/gantt-geometry.test.ts +367 -0
  48. package/tests/gantt-histogram.test.ts +78 -0
  49. package/tests/gantt-keyboard.test.ts +69 -0
  50. package/tests/helpers/cpmFixtures.ts +101 -0
  51. package/tests/projectInputs.test.ts +165 -0
  52. package/tests/recurrence.test.ts +68 -0
  53. package/tests/request.test.ts +99 -0
  54. package/tests/resource.test.ts +95 -0
  55. package/tests/rule.test.ts +98 -0
  56. package/tests/series.test.ts +120 -0
  57. package/tests/workTime.test.ts +1007 -0
  58. package/tests/workTimeContracts.test.ts +111 -0
  59. package/tsconfig.json +13 -0
  60. package/vitest.config.ts +8 -0
@@ -0,0 +1,111 @@
1
+ import type {
2
+ CoverageEvaluationInput,
3
+ CoverageOccurrenceInput,
4
+ CoverageResourceInput,
5
+ CoverageRuleInput,
6
+ CoverageSlotInput,
7
+ } from '../src/types/schedule.d.ts';
8
+
9
+ /* Build a UTC fixture instant on a Monday. */
10
+ export function at(hour: number, day = 7): string {
11
+ return new Date(Date.UTC(2026, 8, day, 0, hour * 60)).toISOString();
12
+ }
13
+
14
+ /* Build a validated resource with explicit nullability and empty configuration. */
15
+ export function person(
16
+ id: string,
17
+ extra: Partial<CoverageResourceInput> = {},
18
+ ): CoverageResourceInput {
19
+ return {
20
+ id,
21
+ kind: 'LABOR',
22
+ capacity: null,
23
+ retiredAt: null,
24
+ config: {
25
+ roles: [],
26
+ tags: [],
27
+ qualifications: [],
28
+ ageGroup: null,
29
+ notify: null,
30
+ },
31
+ ...extra,
32
+ };
33
+ }
34
+
35
+ /* Build a staff slot with no predicate by default. */
36
+ export function slot(
37
+ key = 'teacher',
38
+ extra: Partial<CoverageSlotInput> = {},
39
+ ): CoverageSlotInput {
40
+ return {
41
+ key,
42
+ label: null,
43
+ requiredCount: 1,
44
+ predicate: null,
45
+ ordinal: 0,
46
+ ...extra,
47
+ };
48
+ }
49
+
50
+ /* Build one shift with pinned assignments for the given resources. */
51
+ export function shift(
52
+ id = '10',
53
+ people: string[] = [],
54
+ extra: Partial<CoverageOccurrenceInput> = {},
55
+ ): CoverageOccurrenceInput {
56
+ return {
57
+ id,
58
+ kind: 'SHIFT',
59
+ resourceId: 'room',
60
+ startAt: at(8),
61
+ endAt: at(12),
62
+ slots: [slot()],
63
+ assignments: people.map((resourceId) => ({
64
+ id: `${id}-${resourceId}`,
65
+ resourceId,
66
+ slotKey: 'teacher',
67
+ })),
68
+ ...extra,
69
+ };
70
+ }
71
+
72
+ /* Build one active rule row at organization scope. */
73
+ export function rule(
74
+ kind: CoverageRuleInput['kind'],
75
+ config: CoverageRuleInput['config'],
76
+ extra: Partial<CoverageRuleInput> = {},
77
+ ): CoverageRuleInput {
78
+ return {
79
+ id: `r-${kind}`,
80
+ kind,
81
+ calendarId: null,
82
+ resourceId: null,
83
+ config,
84
+ severity: 'BLOCK',
85
+ ...extra,
86
+ };
87
+ }
88
+
89
+ /* Build a complete coverage snapshot for deterministic regression probes. */
90
+ export function snapshot(
91
+ extra: Partial<CoverageEvaluationInput> = {},
92
+ ): CoverageEvaluationInput {
93
+ return {
94
+ calendarId: 'calendar',
95
+ window: { from: at(7), to: at(18) },
96
+ timeZone: 'UTC',
97
+ operatingHours: null,
98
+ occurrences: [],
99
+ external: [],
100
+ resources: [
101
+ person('room', { kind: 'SPACE', capacity: 20 }),
102
+ person('1'),
103
+ person('2'),
104
+ person('3'),
105
+ ],
106
+ demand: [],
107
+ timeOff: [],
108
+ rules: [],
109
+ ...extra,
110
+ };
111
+ }
@@ -0,0 +1,503 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ evaluateScheduleCoverage,
4
+ hasBlockingViolations,
5
+ } from '../src/utils/coverage.ts';
6
+ import {
7
+ at,
8
+ person,
9
+ rule,
10
+ shift,
11
+ slot,
12
+ snapshot,
13
+ } from './coverage.fixtures.ts';
14
+
15
+ /* Project violation intervals for readable half-open stretch assertions. */
16
+ function intervals(
17
+ result: ReturnType<typeof evaluateScheduleCoverage>,
18
+ kind: string,
19
+ code?: string,
20
+ ) {
21
+ return result.violations
22
+ .filter((v) => v.kind === kind && (!code || v.code === code))
23
+ .map((v) => [v.startAt.toISOString(), v.endAt.toISOString(), v.degree]);
24
+ }
25
+
26
+ describe('per-instant coverage', () => {
27
+ it('combines adults from multiple shifts in a room', () => {
28
+ const result = evaluateScheduleCoverage(
29
+ snapshot({
30
+ occurrences: [shift('10', ['1', '2']), shift('11', ['3'])],
31
+ demand: [
32
+ {
33
+ id: 'd',
34
+ resourceId: 'room',
35
+ key: 'INFANT',
36
+ quantity: 12,
37
+ startAt: at(8),
38
+ endAt: at(12),
39
+ },
40
+ ],
41
+ rules: [
42
+ rule('DERIVED_COUNT', { ratios: { INFANT: 4 }, predicate: null }),
43
+ ],
44
+ }),
45
+ );
46
+ expect(result.violations).toEqual([]);
47
+ });
48
+ it('sums overlapping demand instead of taking the peak', () => {
49
+ const result = evaluateScheduleCoverage(
50
+ snapshot({
51
+ occurrences: [shift('10', ['1', '2'])],
52
+ demand: [
53
+ {
54
+ id: 'd1',
55
+ resourceId: 'room',
56
+ key: 'INFANT',
57
+ quantity: 6,
58
+ startAt: at(8),
59
+ endAt: at(11),
60
+ },
61
+ {
62
+ id: 'd2',
63
+ resourceId: 'room',
64
+ key: 'INFANT',
65
+ quantity: 6,
66
+ startAt: at(9),
67
+ endAt: at(12),
68
+ },
69
+ ],
70
+ rules: [
71
+ rule('DERIVED_COUNT', { ratios: { INFANT: 4 }, predicate: null }),
72
+ ],
73
+ }),
74
+ );
75
+ expect(intervals(result, 'DERIVED_COUNT')).toEqual([[at(9), at(11), 1]]);
76
+ });
77
+ it('licensed capacity judges children, never shifts or blocks', () => {
78
+ const base = snapshot({
79
+ resources: [person('room', { kind: 'SPACE', capacity: 1 })],
80
+ occurrences: [
81
+ shift('10'),
82
+ shift('11'),
83
+ shift('12', [], { kind: 'BLOCK' }),
84
+ ],
85
+ });
86
+ expect(intervals(evaluateScheduleCoverage(base), 'ROOM_CAPACITY')).toEqual(
87
+ [],
88
+ );
89
+ expect(
90
+ intervals(
91
+ evaluateScheduleCoverage({
92
+ ...base,
93
+ demand: [
94
+ {
95
+ id: 'd',
96
+ resourceId: 'room',
97
+ key: 'INFANT',
98
+ quantity: 1.5,
99
+ startAt: at(9),
100
+ endAt: at(10),
101
+ },
102
+ ],
103
+ }),
104
+ 'ROOM_CAPACITY',
105
+ ),
106
+ ).toEqual([[at(9), at(10), 0.5]]);
107
+ });
108
+ it.each([1, 2])('places %i unslotted people once each', (count) => {
109
+ const result = evaluateScheduleCoverage(
110
+ snapshot({
111
+ occurrences: [
112
+ shift('10', [], {
113
+ slots: [slot('a'), slot('b', { ordinal: 1 })],
114
+ assignments: ['1', '2']
115
+ .slice(0, count)
116
+ .map((resourceId) => ({
117
+ id: resourceId,
118
+ resourceId,
119
+ slotKey: null,
120
+ })),
121
+ }),
122
+ ],
123
+ }),
124
+ );
125
+ expect(result.violations.map((v) => v.slotKey)).toEqual(
126
+ count === 1 ? ['b'] : [],
127
+ );
128
+ });
129
+ it('does not overflow pinned people into another slot', () => {
130
+ const result = evaluateScheduleCoverage(
131
+ snapshot({
132
+ occurrences: [
133
+ shift('10', [], {
134
+ slots: [slot('a'), slot('b', { ordinal: 1 })],
135
+ assignments: ['1', '2'].map((resourceId) => ({
136
+ id: resourceId,
137
+ resourceId,
138
+ slotKey: 'a',
139
+ })),
140
+ }),
141
+ ],
142
+ }),
143
+ );
144
+ expect(result.violations.map((v) => v.slotKey)).toEqual(['b']);
145
+ });
146
+ it.each([8, 10, 12])('cuts certificate expiry at hour %i', (expiry) => {
147
+ const staff = person('1');
148
+ staff.config.qualifications = [{ key: 'CPR', expiresAt: at(expiry) }];
149
+ const result = evaluateScheduleCoverage(
150
+ snapshot({
151
+ resources: [staff],
152
+ occurrences: [
153
+ shift('10', ['1'], {
154
+ resourceId: null,
155
+ slots: [
156
+ slot('teacher', { predicate: { qualifications: ['CPR'] } }),
157
+ ],
158
+ }),
159
+ ],
160
+ }),
161
+ );
162
+ expect(intervals(result, 'ELIGIBILITY', 'QUALIFICATION_EXPIRED')).toEqual(
163
+ expiry === 12 ? [] : [[at(expiry), at(12), 1]],
164
+ );
165
+ expect(intervals(result, 'REQUIRED_COUNT')).toEqual(
166
+ expiry === 12 ? [] : [[at(expiry), at(12), 1]],
167
+ );
168
+ });
169
+ it('reports invalid expiry and treats it as expired', () => {
170
+ const staff = person('1');
171
+ staff.config.qualifications = [{ key: 'CPR', expiresAt: 'invalid' }];
172
+ const result = evaluateScheduleCoverage(
173
+ snapshot({
174
+ resources: [staff],
175
+ occurrences: [
176
+ shift('10', ['1'], {
177
+ resourceId: null,
178
+ slots: [
179
+ slot('teacher', { predicate: { qualifications: ['CPR'] } }),
180
+ ],
181
+ }),
182
+ ],
183
+ }),
184
+ );
185
+ expect(result.diagnostics.map((d) => d.code)).toEqual([
186
+ 'QUALIFICATION_EXPIRY_INVALID',
187
+ ]);
188
+ expect(intervals(result, 'ELIGIBILITY', 'QUALIFICATION_EXPIRED')).toEqual([
189
+ [at(8), at(12), 1],
190
+ ]);
191
+ });
192
+ it('reports unslotted expired qualifications', () => {
193
+ const staff = person('1');
194
+ staff.config.qualifications = [{ key: 'CPR', expiresAt: at(10) }];
195
+ const result = evaluateScheduleCoverage(
196
+ snapshot({
197
+ resources: [staff],
198
+ occurrences: [
199
+ shift('10', [], {
200
+ resourceId: null,
201
+ slots: [
202
+ slot('teacher', { predicate: { qualifications: ['CPR'] } }),
203
+ ],
204
+ assignments: [{ id: 'a', resourceId: '1', slotKey: null }],
205
+ }),
206
+ ],
207
+ }),
208
+ );
209
+ expect(intervals(result, 'ELIGIBILITY', 'QUALIFICATION_EXPIRED')).toEqual([
210
+ [at(10), at(12), 1],
211
+ ]);
212
+ });
213
+ it('flags an unknown slot while using its assignee as unslotted', () => {
214
+ const result = evaluateScheduleCoverage(
215
+ snapshot({
216
+ occurrences: [
217
+ shift('10', [], {
218
+ assignments: [{ id: 'a', resourceId: '1', slotKey: 'typo' }],
219
+ }),
220
+ ],
221
+ }),
222
+ );
223
+ expect(result.diagnostics.map((d) => d.code)).toEqual(['UNKNOWN_SLOT_KEY']);
224
+ expect(result.violations.map((v) => v.code)).toEqual(['SLOT_UNKNOWN']);
225
+ });
226
+ it('allows room-less shifts and reports an unknown room without discarding staff', () => {
227
+ expect(
228
+ evaluateScheduleCoverage(
229
+ snapshot({ occurrences: [shift('10', ['1'], { resourceId: null })] }),
230
+ ).diagnostics,
231
+ ).toEqual([]);
232
+ const result = evaluateScheduleCoverage(
233
+ snapshot({
234
+ occurrences: [shift('10', ['1'], { resourceId: 'unknown' })],
235
+ }),
236
+ );
237
+ expect(result.diagnostics.map((d) => d.code)).toEqual(['UNKNOWN_RESOURCE']);
238
+ expect(result.violations).toEqual([]);
239
+ });
240
+ it('cuts time-off to the actual interval', () => {
241
+ const result = evaluateScheduleCoverage(
242
+ snapshot({
243
+ occurrences: [shift('10', ['1'])],
244
+ timeOff: [
245
+ { id: 'off', resourceId: '1', startAt: at(9), endAt: at(10) },
246
+ ],
247
+ }),
248
+ );
249
+ expect(intervals(result, 'ELIGIBILITY', 'TIME_OFF')).toEqual([
250
+ [at(9), at(10), 1],
251
+ ]);
252
+ });
253
+ it('emits own overlap once on the larger numeric shift id', () => {
254
+ const result = evaluateScheduleCoverage(
255
+ snapshot({
256
+ occurrences: [
257
+ shift('9', ['1']),
258
+ shift('10', ['1'], { startAt: at(10), endAt: at(14) }),
259
+ ],
260
+ }),
261
+ );
262
+ expect(intervals(result, 'ELIGIBILITY', 'OVERLAP')).toEqual([
263
+ [at(10), at(12), 1],
264
+ ]);
265
+ expect(
266
+ result.violations.find((v) => v.code === 'OVERLAP')?.occurrenceId,
267
+ ).toBe('10');
268
+ });
269
+ it('cuts external overlap at external endpoints', () => {
270
+ const result = evaluateScheduleCoverage(
271
+ snapshot({
272
+ occurrences: [shift('10', ['1'])],
273
+ external: [
274
+ {
275
+ occurrenceId: '20',
276
+ calendarId: 'other',
277
+ resourceId: '1',
278
+ kind: 'SHIFT',
279
+ startAt: at(9),
280
+ endAt: at(10),
281
+ },
282
+ ],
283
+ }),
284
+ );
285
+ expect(intervals(result, 'ELIGIBILITY', 'OVERLAP')).toEqual([
286
+ [at(9), at(10), 1],
287
+ ]);
288
+ });
289
+ it('deduplicates own rows loaded again as external evidence', () => {
290
+ const result = evaluateScheduleCoverage(
291
+ snapshot({
292
+ occurrences: [shift('10', ['1'])],
293
+ external: [
294
+ {
295
+ occurrenceId: '10',
296
+ calendarId: 'calendar',
297
+ resourceId: '1',
298
+ kind: 'SHIFT',
299
+ startAt: at(8),
300
+ endAt: at(12),
301
+ },
302
+ ],
303
+ }),
304
+ );
305
+ expect(result.violations).toEqual([]);
306
+ });
307
+ it('does not apply eligibility to EVENT assignments', () => {
308
+ const result = evaluateScheduleCoverage(
309
+ snapshot({
310
+ occurrences: [
311
+ shift('10', ['1']),
312
+ shift('11', ['1'], { kind: 'EVENT' }),
313
+ shift('12', ['1'], { kind: 'EVENT' }),
314
+ ],
315
+ timeOff: [
316
+ { id: 'off', resourceId: '1', startAt: at(8), endAt: at(12) },
317
+ ],
318
+ }),
319
+ );
320
+ expect(
321
+ result.violations
322
+ .filter((v) => v.kind === 'ELIGIBILITY')
323
+ .every((v) => v.occurrenceId === '10'),
324
+ ).toBe(true);
325
+ });
326
+ it('requires adults in an empty open center except during BLOCK closures', () => {
327
+ const result = evaluateScheduleCoverage(
328
+ snapshot({
329
+ operatingHours: {
330
+ id: 'work',
331
+ timeZone: 'UTC',
332
+ minutesPerDay: 480,
333
+ weekHours: { '1': [['08:00', '12:00']] },
334
+ exceptions: null,
335
+ },
336
+ rules: [rule('OPERATING_HOURS', { minAdults: 2, predicate: null })],
337
+ occurrences: [
338
+ shift('closed', [], {
339
+ kind: 'BLOCK',
340
+ resourceId: null,
341
+ startAt: at(9),
342
+ endAt: at(10),
343
+ }),
344
+ ],
345
+ }),
346
+ );
347
+ expect(intervals(result, 'OPERATING_HOURS')).toEqual([
348
+ [at(8), at(9), 2],
349
+ [at(10), at(12), 2],
350
+ ]);
351
+ });
352
+ it('counts floaters in the center without counting them in a room', () => {
353
+ const result = evaluateScheduleCoverage(
354
+ snapshot({
355
+ operatingHours: {
356
+ id: 'work',
357
+ timeZone: 'UTC',
358
+ minutesPerDay: 240,
359
+ weekHours: { '1': [['08:00', '12:00']] },
360
+ exceptions: null,
361
+ },
362
+ rules: [
363
+ rule('OPERATING_HOURS', { minAdults: 1, predicate: null }),
364
+ rule(
365
+ 'OPERATING_HOURS',
366
+ { minAdults: 1, predicate: null },
367
+ { id: 'roomRule', resourceId: 'room' },
368
+ ),
369
+ ],
370
+ occurrences: [shift('10', ['1'], { resourceId: null })],
371
+ }),
372
+ );
373
+ expect(result.violations.map((v) => v.resourceId)).toEqual(['room']);
374
+ });
375
+ it('diagnoses missing operating hours only when a rule applies', () => {
376
+ expect(evaluateScheduleCoverage(snapshot()).diagnostics).toEqual([]);
377
+ expect(
378
+ evaluateScheduleCoverage(
379
+ snapshot({
380
+ rules: [rule('OPERATING_HOURS', { minAdults: 1, predicate: null })],
381
+ }),
382
+ ).diagnostics.map((d) => d.code),
383
+ ).toEqual(['OPERATING_HOURS_NOT_CONFIGURED']);
384
+ });
385
+ it('loads history into rolling totals without making external rows subjects', () => {
386
+ const result = evaluateScheduleCoverage(
387
+ snapshot({
388
+ occurrences: [shift('10', ['1'])],
389
+ external: [
390
+ {
391
+ occurrenceId: '9',
392
+ calendarId: 'other',
393
+ resourceId: '1',
394
+ kind: 'SHIFT',
395
+ startAt: at(8, 6),
396
+ endAt: at(16, 6),
397
+ },
398
+ ],
399
+ rules: [
400
+ rule('ACTOR_WINDOW_AGGREGATE', {
401
+ windowDays: 7,
402
+ maxMinutes: 600,
403
+ minRestMinutes: null,
404
+ }),
405
+ ],
406
+ }),
407
+ );
408
+ expect(intervals(result, 'ACTOR_WINDOW_AGGREGATE', 'HOURS')).toEqual([
409
+ [at(8), at(12), 120],
410
+ ]);
411
+ });
412
+ it.each([11, 12])(
413
+ 'judges rest for a subsequent shift beginning at %i',
414
+ (start) => {
415
+ const result = evaluateScheduleCoverage(
416
+ snapshot({
417
+ occurrences: [
418
+ shift('10', ['1']),
419
+ shift('11', ['1'], { startAt: at(start), endAt: at(14) }),
420
+ ],
421
+ rules: [
422
+ rule('ACTOR_WINDOW_AGGREGATE', {
423
+ windowDays: null,
424
+ maxMinutes: null,
425
+ minRestMinutes: 60,
426
+ }),
427
+ ],
428
+ }),
429
+ );
430
+ expect(intervals(result, 'ACTOR_WINDOW_AGGREGATE', 'REST')).toEqual(
431
+ start === 11 ? [] : [[at(12), at(14), 60]],
432
+ );
433
+ },
434
+ );
435
+ it('is deterministic across input order and preserves warning-only publication', () => {
436
+ const base = snapshot({
437
+ occurrences: [shift('10'), shift('11')],
438
+ rules: [rule('REQUIRED_COUNT', {}, { severity: 'WARN' })],
439
+ });
440
+ const a = evaluateScheduleCoverage(base);
441
+ expect(
442
+ evaluateScheduleCoverage({
443
+ ...base,
444
+ occurrences: [...base.occurrences].reverse(),
445
+ resources: [...base.resources].reverse(),
446
+ }),
447
+ ).toEqual(a);
448
+ expect(hasBlockingViolations(a.violations)).toBe(false);
449
+ });
450
+ it('clips output and preserves a sixty-character slot key', () => {
451
+ const key = 'x'.repeat(60);
452
+ const result = evaluateScheduleCoverage(
453
+ snapshot({
454
+ window: { from: at(9), to: at(10) },
455
+ occurrences: [shift('10', [], { slots: [slot(key)] })],
456
+ }),
457
+ );
458
+ expect(intervals(result, 'REQUIRED_COUNT')).toEqual([[at(9), at(10), 1]]);
459
+ expect(result.violations[0].identity).toContain(key);
460
+ expect(result.violations[0].key.length).toBeLessThan(255);
461
+ });
462
+ });
463
+
464
+ describe('coverage scale', () => {
465
+ it('evaluates 150 staff across two weeks and a maximum-size window', () => {
466
+ for (const days of [14, 62]) {
467
+ const resources = [
468
+ person('room', { kind: 'SPACE', capacity: 600 }),
469
+ ...Array.from({ length: 150 }, (_, i) => person(String(i + 1))),
470
+ ];
471
+ const occurrences = Array.from({ length: days }, (_, day) =>
472
+ Array.from({ length: 150 }, (_, index) =>
473
+ shift(String(day * 150 + index + 1), [String(index + 1)], {
474
+ startAt: at(8, 7 + day),
475
+ endAt: at(16, 7 + day),
476
+ }),
477
+ ),
478
+ ).flat();
479
+ const base = snapshot({
480
+ resources,
481
+ occurrences,
482
+ window: { from: at(0), to: at(0, 7 + days) },
483
+ rules: [
484
+ rule('ACTOR_WINDOW_AGGREGATE', {
485
+ windowDays: 7,
486
+ maxMinutes: 4000,
487
+ minRestMinutes: 480,
488
+ }),
489
+ ],
490
+ });
491
+ const started = performance.now();
492
+ const result = evaluateScheduleCoverage(base);
493
+ const elapsed = performance.now() - started;
494
+ expect(result.violations).toEqual([]);
495
+ expect(result.diagnostics).toEqual([]);
496
+ expect(elapsed).toBeLessThan(1500);
497
+ if (process.env.BENCH)
498
+ console.log(
499
+ `coverage ${days} days / ${occurrences.length} shifts: ${elapsed.toFixed(1)} ms`,
500
+ );
501
+ }
502
+ });
503
+ });