Set the decision and its input
The supplied trace has ten attempts: seven completed, two rejected and one unknown. A completed-run allowance consumes seven. An attempt allowance consumes ten, including failed and unknown attempts. Retries are attempts in this fictional contract, not extra completed outcomes.
| Case | Input JSON |
|---|---|
| Base test | {"event":"completed","results":["completed","completed","completed","completed","completed","completed","completed","rejected","rejected","unknown"]} |
Run the supplied comparison
The programme counts the contracted event and also reports unknown observations. A lower consumption count does not turn an uncertain attempt into success or establish how another supplier bills.
| Path | Output JSON |
|---|---|
| Faulty path | {"event":"completed","units":10,"unknown":1} |
| Required path | {"event":"completed","units":7,"unknown":1} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(!['attempt','completed'].includes(i.event))return {held:true};
return {event:i.event,units:corrected&&i.event==='completed'?i.results.filter(r=>r==='completed').length:i.results.length,unknown:i.results.filter(r=>r==='unknown').length};
};
const cases=[{"input":{"event":"completed","results":["completed","completed","completed","completed","completed","completed","completed","rejected","rejected","unknown"]},"corrected":false,"expected":{"event":"completed","units":10,"unknown":1}},{"input":{"event":"completed","results":["completed","completed","completed","completed","completed","completed","completed","rejected","rejected","unknown"]},"corrected":true,"expected":{"event":"completed","units":7,"unknown":1}},{"input":{"event":"attempt","results":["completed","rejected","unknown"]},"corrected":true,"expected":{"event":"attempt","units":3,"unknown":1}},{"input":{"event":null,"results":[]},"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
The three-attempt boundary consumes three under attempt billing while retaining one unknown. No event definition means no completed billing comparison.
- Identify the billed event
- Count matching trace entries
- Retain unknown outcomes
Do not infer an absent event definition from a successful run.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| attempts explicitly billed | {"event":"attempt","results":["completed","rejected","unknown"]} | {"event":"attempt","units":3,"unknown":1} |
| event definition absent | {"event":null,"results":[]} | {"held":true} |
How many units does the base completed-run allowance consume?
Show the worked answer
Seven; retain the one unknown attempt separately. Counting all ten would apply the attempt rule instead.