Define the local evaluation task
A synthetic evaluator intake allows at most 100 UTF-8 bytes and at most three LF-separated nonempty rows. Check bytes before inspecting row count, preserving the raw text on hold. Exactly 100 bytes is within the size bound. Empty text yields zero rows. These are local resource bounds, not security or file-format certification.
- Count bytes in the declared encoding
- Check nonempty LF rows only within the byte bound
- Hold over-limit text before parsing
A held input keeps its raw text and reason; do not silently trim it to fit.
Use the filled cases
| Case | Supplied input | Expected structured output | Decision and reason |
|---|---|---|---|
| Exact byte limit | {"raw":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} | {"status":"ready-to-parse","bytes":100,"rows":1} | Exactly 100 ASCII bytes fit; ready-to-parse still is not a parsed-content pass. |
| One byte over limit | {"raw":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} | {"status":"size-hold","bytes":101} | Size stops intake before a row-count or parser decision. |
| Four nonempty rows | {"raw":"a\nb\nc\nd"} | {"status":"row-hold","bytes":7,"rows":4} | Seven bytes fit but four rows exceed the separate row bound. |
Work the four-rows case. Which output is required, and why?
Show the worked answer
{"status":"row-hold","bytes":7,"rows":4} — Seven bytes fit but four rows exceed the separate row bound.
Run the self-contained evaluator
import assert from 'node:assert/strict';
import {Buffer} from 'node:buffer';
function evaluate(x){
const bytes=Buffer.byteLength(x.raw,'utf8');if(bytes>100)return {status:'size-hold',bytes};const rows=x.raw===''?0:x.raw.split('\n').filter(line=>line!=='').length;
return {status:rows>3?'row-hold':'ready-to-parse',bytes,rows};
}
const cases = [
{
"id": "exact-byte-limit",
"input": {
"raw": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"expected": {
"status": "ready-to-parse",
"bytes": 100,
"rows": 1
}
},
{
"id": "one-byte-over",
"input": {
"raw": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
},
"expected": {
"status": "size-hold",
"bytes": 101
}
},
{
"id": "four-rows",
"input": {
"raw": "a\nb\nc\nd"
},
"expected": {
"status": "row-hold",
"bytes": 7,
"rows": 4
}
}
];
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)}));
Use a separate parser and business validator after these local bounds. Limits must be supplied for a deployment; this example does not establish safe handling of arbitrary files.