Set the decision and its input
The toy job pauses at5 and resumes25 with ten-minute cadence. Triggers10 and20 were missed. Under replay, both execute at25 and the next trigger is30. Under future-only, they are explicitly skipped and the next is30. “Resume” alone does not choose one.
| Case | Input JSON |
|---|---|
| Base test | {"mode":"replay","triggers":[10,20],"pause":5,"resume":25,"interval":10} |
Run the supplied comparison
The executable event list retains scheduled and actual times separately. Only the supplied local triggers are expanded; replaying this list performs no external action.
| Path | Output JSON |
|---|---|
| Faulty path | {"events":[{"scheduled":30,"actual":30}],"skipped":[10,20]} |
| Required path | {"events":[{"scheduled":10,"actual":25},{"scheduled":20,"actual":25},{"scheduled":30,"actual":30}],"skipped":[]} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(!['replay','future-only'].includes(i.mode))return {held:true};
const missed=i.triggers.filter(t=>t>i.pause&&t<=i.resume),next=(Math.floor(i.resume/i.interval)+1)*i.interval;
const replay=corrected&&i.mode==='replay';return {events:[...(replay?missed.map(scheduled=>({scheduled,actual:i.resume})):[]),{scheduled:next,actual:next}],skipped:replay?[]:missed};
};
const cases=[{"input":{"mode":"replay","triggers":[10,20],"pause":5,"resume":25,"interval":10},"corrected":false,"expected":{"events":[{"scheduled":30,"actual":30}],"skipped":[10,20]}},{"input":{"mode":"replay","triggers":[10,20],"pause":5,"resume":25,"interval":10},"corrected":true,"expected":{"events":[{"scheduled":10,"actual":25},{"scheduled":20,"actual":25},{"scheduled":30,"actual":30}],"skipped":[]}},{"input":{"mode":"future-only","triggers":[10,20],"pause":5,"resume":25,"interval":10},"corrected":true,"expected":{"events":[{"scheduled":30,"actual":30}],"skipped":[10,20]}},{"input":{"mode":"future-only","triggers":[10,20,30],"pause":5,"resume":30,"interval":10},"corrected":true,"expected":{"events":[{"scheduled":40,"actual":40}],"skipped":[10,20,30]}},{"input":{"mode":null,"triggers":[],"pause":5,"resume":25,"interval":10},"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
Future-only is strictly after the resume moment: resuming exactly30 makes the next40. Unknown catch-up mode is held.
- Identify missed triggers
- Apply the declared resume origin
- Retain original and execution times
Catch-up requires an explicit policy before external effects are considered.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| declared future-only origin | {"mode":"future-only","triggers":[10,20],"pause":5,"resume":25,"interval":10} | {"events":[{"scheduled":30,"actual":30}],"skipped":[10,20]} |
| strictly later tick at exact resume | {"mode":"future-only","triggers":[10,20,30],"pause":5,"resume":30,"interval":10} | {"events":[{"scheduled":40,"actual":40}],"skipped":[10,20,30]} |
| resume rule unknown | {"mode":null,"triggers":[],"pause":5,"resume":25,"interval":10} | {"held":true} |
How are the two missed base triggers treated under replay?
Show the worked answer
They retain scheduled10/20 but both execute at25. Neither is silently dropped or relabelled as scheduled25.