Define the local evaluation task
A synthetic local formatting repair ledger permits at most two attempts. A nonempty text verified code must be established; every permitted attempt must retain its own nonempty text code and a Boolean format label. A true format label finishes repair only after exact code matching. A changed code is an evidence error even when formatting passes. Stop after two invalid attempts; later logged attempts are not part of the permitted evaluation.
- Read at most two repair attempts
- Check retained fact before format result
- Finish or stop with explicit disposition
Changed verified facts stop repair; exhausted formatting attempts go to staff review.
Use the filled cases
| Case | Supplied input | Expected structured output | Decision and reason |
|---|---|---|---|
| Second attempt fixes format | {"verifiedCode":"K7","attempts":[{"code":"K7","valid":false},{"code":"K7","valid":true}]} | {"status":"complete","attemptsUsed":2} | The second permitted attempt passes while preserving K7. |
| Format fixed but code changed | {"verifiedCode":"K7","attempts":[{"code":"K9","valid":true}]} | {"status":"fact-changed","attemptsUsed":1} | A valid shape cannot authorise replacement of the verified fact. |
| Text false is not a format Boolean | {"verifiedCode":"K7","attempts":[{"code":"K7","valid":"false"}]} | {"status":"invalid-format-label","attemptsUsed":1} | The text false must not become truthy completion evidence. |
| Neither code is established | {"attempts":[{"valid":true}]} | {"status":"missing-code-evidence","attemptsUsed":0} | Undefined equals undefined is not evidence of retaining a verified code. |
| Attempt lacks its retained code | {"verifiedCode":"K7","attempts":[{"valid":true}]} | {"status":"missing-code-evidence","attemptsUsed":1} | A true format label cannot complete an attempt without its retained code. |
| Third attempt beyond bound | {"verifiedCode":"K7","attempts":[{"code":"K7","valid":false},{"code":"K7","valid":false},{"code":"K7","valid":true}]} | {"status":"stopped","attemptsUsed":2} | The third success lies outside the supplied two-attempt policy. |
Work the third-attempt-too-late case. Which output is required, and why?
Show the worked answer
{"status":"stopped","attemptsUsed":2} — The third success lies outside the supplied two-attempt policy.
Run the self-contained evaluator
import assert from 'node:assert/strict';
function evaluate(x){
if(typeof x.verifiedCode!=='string'||!x.verifiedCode.trim())return {status:'missing-code-evidence',attemptsUsed:0};
for(let i=0;i<Math.min(2,x.attempts.length);i++){const a=x.attempts[i];if(typeof a.code!=='string'||!a.code.trim())return {status:'missing-code-evidence',attemptsUsed:i+1};if(a.code!==x.verifiedCode)return {status:'fact-changed',attemptsUsed:i+1};if(typeof a.valid!=='boolean')return {status:'invalid-format-label',attemptsUsed:i+1};if(a.valid)return {status:'complete',attemptsUsed:i+1};}
return {status:x.attempts.length>=2?'stopped':'needs-next-attempt',attemptsUsed:Math.min(2,x.attempts.length)};
}
const cases = [
{
"id": "second-format-pass",
"input": {
"verifiedCode": "K7",
"attempts": [
{
"code": "K7",
"valid": false
},
{
"code": "K7",
"valid": true
}
]
},
"expected": {
"status": "complete",
"attemptsUsed": 2
}
},
{
"id": "format-pass-fact-change",
"input": {
"verifiedCode": "K7",
"attempts": [
{
"code": "K9",
"valid": true
}
]
},
"expected": {
"status": "fact-changed",
"attemptsUsed": 1
}
},
{
"id": "text-format-label",
"input": {
"verifiedCode": "K7",
"attempts": [
{
"code": "K7",
"valid": "false"
}
]
},
"expected": {
"status": "invalid-format-label",
"attemptsUsed": 1
}
},
{
"id": "verified-code-absent",
"input": {
"attempts": [
{
"valid": true
}
]
},
"expected": {
"status": "missing-code-evidence",
"attemptsUsed": 0
}
},
{
"id": "attempt-code-absent",
"input": {
"verifiedCode": "K7",
"attempts": [
{
"valid": true
}
]
},
"expected": {
"status": "missing-code-evidence",
"attemptsUsed": 1
}
},
{
"id": "third-attempt-too-late",
"input": {
"verifiedCode": "K7",
"attempts": [
{
"code": "K7",
"valid": false
},
{
"code": "K7",
"valid": false
},
{
"code": "K7",
"valid": true
}
]
},
"expected": {
"status": "stopped",
"attemptsUsed": 2
}
}
];
for (const c of cases) assert.deepEqual(evaluate(c.input), c.expected, c.id);
console.log(JSON.stringify({checked:cases.length,caseIds:cases.map(c=>c.id)}));
Keep each permitted attempt and its candidate output. This local loop makes no network retry, provider latency or model reliability claim; supplying more attempts changes the policy.