fix: normalize schedule capacity conflicts

This commit is contained in:
Danny Avila 2026-08-17 12:04:43 -04:00
parent eb1475b4b3
commit fc5dc0baa1
2 changed files with 15 additions and 1 deletions

View file

@ -950,6 +950,15 @@ describe('scheduled resume capacity', () => {
});
expect(methods.markRunResumeClaimed).not.toHaveBeenCalled();
});
it('normalizes an exhausted slot-collision retry to public capacity conflict', async () => {
const { service, methods } = makeResumeService({ takenSlots: [], unslotted: 0 });
methods.markRunResumeClaimed.mockResolvedValue({ conflict: 'slot-taken' });
await expect(service.claimScheduleResume('s1', '2026-08-17T12:00:00.000Z')).resolves.toEqual({
conflict: 'capacity',
});
});
});
describe('deployment-wide limits', () => {

View file

@ -855,7 +855,12 @@ export function createSchedulesService(
}
const claimed = allocation.claimed;
if ('conflict' in claimed) {
return { conflict: claimed.conflict };
// withCapacitySlot consumes this internal collision sentinel by retrying the
// next free slot. Normalize defensively at the public boundary as well so a
// custom/test allocator can never leak an implementation-only conflict.
return {
conflict: claimed.conflict === 'slot-taken' ? 'capacity' : claimed.conflict,
};
}
return { capacitySlot: claimed.capacitySlot };
});