Set the decision and its input
Fictional quotations use three different units. The supplied account inventory contains twelve named accounts, eight marked active for the stated month, and a complete toy concurrency trace whose largest snapshot contains three distinct accounts. A named-seat quote therefore uses twelve, not the observed concurrent count of three.
| Case | Input JSON |
|---|---|
| Base test | {"basis":"named","traceComplete":true,"accounts":[{"id":1,"active":true},{"id":2,"active":true},{"id":3,"active":true},{"id":4,"active":true},{"id":5,"active":true},{"id":6,"active":true},{"id":7,"active":true},{"id":8,"active":true},{"id":9,"active":false},{"id":10,"active":false},{"id":11,"active":false},{"id":12,"active":false}],"samples":[{"accounts":[1,2]},{"accounts":[1,2,3]}]} |
Run the supplied comparison
Record the unit beside the count. These observations are inputs for this fictional comparison, not customer usage findings. A supplier demo must establish the contracted unit and trace completeness before a real peak is inferred.
| Path | Output JSON |
|---|---|
| Faulty path | {"basis":"named","count":3} |
| Required path | {"basis":"named","count":12} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(!['named','active','concurrent'].includes(i.basis))return {held:true,reason:'unit-basis-missing'};
if(corrected&&i.basis==='concurrent'&&i.traceComplete!==true)return {held:true,reason:'concurrency-trace-incomplete'};
const named=i.accounts.length,active=i.accounts.filter(a=>a.active).length;
const concurrent=Math.max(0,...i.samples.map(s=>new Set(s.accounts).size));
return {basis:i.basis,count:corrected?({named,active,concurrent})[i.basis]:concurrent};
};
const cases=[{"input":{"basis":"named","traceComplete":true,"accounts":[{"id":1,"active":true},{"id":2,"active":true},{"id":3,"active":true},{"id":4,"active":true},{"id":5,"active":true},{"id":6,"active":true},{"id":7,"active":true},{"id":8,"active":true},{"id":9,"active":false},{"id":10,"active":false},{"id":11,"active":false},{"id":12,"active":false}],"samples":[{"accounts":[1,2]},{"accounts":[1,2,3]}]},"corrected":false,"expected":{"basis":"named","count":3}},{"input":{"basis":"named","traceComplete":true,"accounts":[{"id":1,"active":true},{"id":2,"active":true},{"id":3,"active":true},{"id":4,"active":true},{"id":5,"active":true},{"id":6,"active":true},{"id":7,"active":true},{"id":8,"active":true},{"id":9,"active":false},{"id":10,"active":false},{"id":11,"active":false},{"id":12,"active":false}],"samples":[{"accounts":[1,2]},{"accounts":[1,2,3]}]},"corrected":true,"expected":{"basis":"named","count":12}},{"input":{"basis":"active","accounts":[{"id":1,"active":true},{"id":2,"active":false}],"samples":[{"accounts":[1]}]},"corrected":true,"expected":{"basis":"active","count":1}},{"input":{"basis":null,"accounts":[],"samples":[]},"corrected":true,"expected":{"held":true,"reason":"unit-basis-missing"}},{"input":{"basis":"concurrent","traceComplete":false,"accounts":[{"id":1,"active":true},{"id":2,"active":true}],"samples":[{"accounts":[1,2]}]},"corrected":true,"expected":{"held":true,"reason":"concurrency-trace-incomplete"}},{"input":{"basis":"concurrent","traceComplete":true,"accounts":[{"id":1,"active":true},{"id":2,"active":true}],"samples":[{"accounts":[1,1,2]},{"accounts":[1]}]},"corrected":true,"expected":{"basis":"concurrent","count":2}}];
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
Active mode counts the one supplied active account in its boundary. An absent unit definition is held; selecting the smallest count does not fill that gap.
- Read the quotation unit
- Select its matching observation
- Write the basis with the count
Hold an unstated unit or an incomplete trace before claiming peak fit.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| active account basis | {"basis":"active","accounts":[{"id":1,"active":true},{"id":2,"active":false}],"samples":[{"accounts":[1]}]} | {"basis":"active","count":1} |
| basis not supplied | {"basis":null,"accounts":[],"samples":[]} | {"held":true,"reason":"unit-basis-missing"} |
| incomplete concurrent trace | {"basis":"concurrent","traceComplete":false,"accounts":[{"id":1,"active":true},{"id":2,"active":true}],"samples":[{"accounts":[1,2]}]} | {"held":true,"reason":"concurrency-trace-incomplete"} |
| complete concurrent trace counts distinct accounts | {"basis":"concurrent","traceComplete":true,"accounts":[{"id":1,"active":true},{"id":2,"active":true}],"samples":[{"accounts":[1,1,2]},{"accounts":[1]}]} | {"basis":"concurrent","count":2} |
How many units belong to the base named-seat quotation?
Show the worked answer
Twelve. Eight describes monthly activity and three describes the supplied concurrent peak; neither changes the named-account unit.