Set the decision and its input
Triggers occur at minutes0 and10; each run takes12. The supplied queue policy starts the second at12 and finishes24. An overlap implementation starts it10 and finishes22. Under skip, only the first run executes and10 is explicitly skipped.
| Case | Input JSON |
|---|---|
| Base test | {"policy":"queue","triggers":[0,10],"duration":12} |
Run the supplied comparison
The deterministic local scheduler constructs each run’s scheduled, start and finish times. It specifies expected execution behaviour, not a real platform’s scheduling feature or a production benchmark.
| Path | Output JSON |
|---|---|
| Faulty path | {"runs":[{"scheduled":0,"start":0,"finish":12},{"scheduled":10,"start":10,"finish":22}],"skipped":[]} |
| Required path | {"runs":[{"scheduled":0,"start":0,"finish":12},{"scheduled":10,"start":12,"finish":24}],"skipped":[]} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(!['queue','skip','overlap'].includes(i.policy))return {held:true};
const runs=[],skipped=[];let busyUntil=-Infinity;
for(const scheduled of i.triggers){const policy=corrected?i.policy:'overlap';if(policy==='skip'&&scheduled<busyUntil){skipped.push(scheduled);continue;}
const start=policy==='queue'?Math.max(scheduled,busyUntil):scheduled;const finish=start+i.duration;runs.push({scheduled,start,finish});busyUntil=Math.max(busyUntil,finish);}
return {runs,skipped};
};
const cases=[{"input":{"policy":"queue","triggers":[0,10],"duration":12},"corrected":false,"expected":{"runs":[{"scheduled":0,"start":0,"finish":12},{"scheduled":10,"start":10,"finish":22}],"skipped":[]}},{"input":{"policy":"queue","triggers":[0,10],"duration":12},"corrected":true,"expected":{"runs":[{"scheduled":0,"start":0,"finish":12},{"scheduled":10,"start":12,"finish":24}],"skipped":[]}},{"input":{"policy":"skip","triggers":[0,10],"duration":12},"corrected":true,"expected":{"runs":[{"scheduled":0,"start":0,"finish":12}],"skipped":[10]}},{"input":{"policy":"queue","triggers":[0,10],"duration":10},"corrected":true,"expected":{"runs":[{"scheduled":0,"start":0,"finish":10},{"scheduled":10,"start":10,"finish":20}],"skipped":[]}},{"input":{"policy":null,"triggers":[0,10],"duration":12},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
At exactly10 minutes duration, the next run can start10 without overlap. Missing policy is held before counting expected outputs.
- Read the overlap disposition
- Execute the trigger trace
- Inspect runs and skipped triggers
Do not infer queueing from the word scheduled.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| skip while occupied | {"policy":"skip","triggers":[0,10],"duration":12} | {"runs":[{"scheduled":0,"start":0,"finish":12}],"skipped":[10]} |
| exact finish permits next run | {"policy":"queue","triggers":[0,10],"duration":10} | {"runs":[{"scheduled":0,"start":0,"finish":10},{"scheduled":10,"start":10,"finish":20}],"skipped":[]} |
| policy absent | {"policy":null,"triggers":[0,10],"duration":12} | {"held":true} |
What is the queued second run’s base interval?
Show the worked answer
12..24, for the trigger scheduled at10. A10..22 interval would implement overlap instead.