Skip to content
Astera Technology

Count allowances by the contracted run event

Apply the quoted consumption event without erasing unresolved attempts.

Download complete case notes and answer keys ↓

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.

Filled local test worksheet
CaseInput JSON
Base test{"event":"completed","results":["completed","completed","completed","completed","completed","completed","completed","rejected","rejected","unknown"]}
Download editable CSV ↓

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.

Faulty and required outputs
PathOutput JSON
Faulty path{"event":"completed","units":10,"unknown":1}
Required path{"event":"completed","units":7,"unknown":1}
Download editable CSV ↓
Complete local Node24.14.1 programme
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);}
Download runnable example ↓

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.

  1. Identify the billed event
  2. Count matching trace entries
  3. Retain unknown outcomes

Do not infer an absent event definition from a successful run.

Editable boundary inputs and outputs
ConditionInput JSONExpected 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}
Download editable CSV ↓

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.

Related resources