Set the decision and its input
The supplied trace has network2 seconds, server3 and client render4. A server-only measure is3; the user-complete interval is9. The base requirement asks for user completion, so a server-only result cannot satisfy its measurement contract.
| Case | Input JSON |
|---|---|
| Base test | {"scope":"user-complete","seconds":{"network":2,"server":3,"render":4}} |
Run the supplied comparison
The programme sums only the named observed phases for the requested scope. It does not infer an unknown phase or certify that a real system’s instrumentation captures every possible delay.
| Path | Output JSON |
|---|---|
| Faulty path | {"scope":"user-complete","measuredSeconds":3} |
| Required path | {"scope":"user-complete","measuredSeconds":9} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(!['server','user-complete'].includes(i.scope)||['network','server','render'].some(k=>!Number.isFinite(i.seconds[k])||i.seconds[k]<0))return {held:true};
const total=i.seconds.network+i.seconds.server+i.seconds.render;
return {scope:i.scope,measuredSeconds:corrected&&i.scope==='user-complete'?total:i.seconds.server};
};
const cases=[{"input":{"scope":"user-complete","seconds":{"network":2,"server":3,"render":4}},"corrected":false,"expected":{"scope":"user-complete","measuredSeconds":3}},{"input":{"scope":"user-complete","seconds":{"network":2,"server":3,"render":4}},"corrected":true,"expected":{"scope":"user-complete","measuredSeconds":9}},{"input":{"scope":"server","seconds":{"network":2,"server":3,"render":4}},"corrected":true,"expected":{"scope":"server","measuredSeconds":3}},{"input":{"scope":"user-complete","seconds":{"network":2,"server":3,"render":null}},"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
Explicit server scope legitimately gives3. Missing render duration makes the full comparison held rather than9 guessed from another trace.
- Name the interval endpoints
- Collect each included phase
- Report the scoped duration
Hold an unobserved required phase instead of treating it as zero.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| server-only target | {"scope":"server","seconds":{"network":2,"server":3,"render":4}} | {"scope":"server","measuredSeconds":3} |
| render interval unobserved | {"scope":"user-complete","seconds":{"network":2,"server":3,"render":null}} | {"held":true} |
What duration belongs to the base user-complete target?
Show the worked answer
Nine seconds:2+3+4. Three seconds describes only the server phase and must retain that narrower label.