Define the local evaluation task
A synthetic table continuation supplies an explicit nonempty text previous table identity, distinct ordered headings and a page’s stated continuation identity. Reuse headings only when those identities match. Each row must have exactly one cell per heading. A mismatched continuation or uneven row is held as a layout error; no headings are invented.
- Match explicit continuation identity
- Check row width against supplied headings
- Emit each heading/cell association
Missing continuation identity or uneven rows stay in layout review.
Use the filled cases
| Case | Supplied input | Expected structured output | Decision and reason |
|---|---|---|---|
| Declared matching continuation | {"previous":{"id":"T1","headings":["code","quantity"]},"continues":"T1","rows":[["P8",6]]} | {"rows":[{"code":"P8","quantity":6}]} | T1 supplies both headings to the declared continuation row. |
| Page continues another table | {"previous":{"id":"T1","headings":["code","quantity"]},"continues":"T2","rows":[["P8",6]]} | {"error":"continuation"} | A nearby header cannot substitute for a different table identity. |
| Both table identities absent | {"previous":{"headings":["code"]},"rows":[["P8"]]} | {"error":"continuation-identity"} | Two absent values do not establish that a page continues the same table. |
| Nontext table identity | {"previous":{"id":7,"headings":["code"]},"continues":7,"rows":[["P8"]]} | {"error":"continuation-identity"} | Matching numbers cannot substitute for the required supplied text identities. |
| Continuation row short by one cell | {"previous":{"id":"T1","headings":["code","quantity"]},"continues":"T1","rows":[["P8"]]} | {"error":"row-width"} | One cell cannot establish the second heading’s value; zero must not be invented. |
Work the missing-cell case. Which output is required, and why?
Show the worked answer
{"error":"row-width"} — One cell cannot establish the second heading’s value; zero must not be invented.
Run the self-contained evaluator
import assert from 'node:assert/strict';
function evaluate(x){
if(!x.previous||typeof x.previous.id!=='string'||!x.previous.id.trim()||typeof x.continues!=='string'||!x.continues.trim())return {error:'continuation-identity'};
if(new Set(x.previous.headings).size!==x.previous.headings.length)return {error:'heading-identity'};
if(x.previous.id!==x.continues)return {error:'continuation'};
if(x.rows.some(r=>r.length!==x.previous.headings.length))return {error:'row-width'};
return {rows:x.rows.map(cells=>Object.fromEntries(x.previous.headings.map((h,i)=>[h,cells[i]])))};
}
const cases = [
{
"id": "matched-continuation",
"input": {
"previous": {
"id": "T1",
"headings": [
"code",
"quantity"
]
},
"continues": "T1",
"rows": [
[
"P8",
6
]
]
},
"expected": {
"rows": [
{
"code": "P8",
"quantity": 6
}
]
}
},
{
"id": "different-table",
"input": {
"previous": {
"id": "T1",
"headings": [
"code",
"quantity"
]
},
"continues": "T2",
"rows": [
[
"P8",
6
]
]
},
"expected": {
"error": "continuation"
}
},
{
"id": "both-identities-absent",
"input": {
"previous": {
"headings": [
"code"
]
},
"rows": [
[
"P8"
]
]
},
"expected": {
"error": "continuation-identity"
}
},
{
"id": "nontext-table-identity",
"input": {
"previous": {
"id": 7,
"headings": [
"code"
]
},
"continues": 7,
"rows": [
[
"P8"
]
]
},
"expected": {
"error": "continuation-identity"
}
},
{
"id": "missing-cell",
"input": {
"previous": {
"id": "T1",
"headings": [
"code",
"quantity"
]
},
"continues": "T1",
"rows": [
[
"P8"
]
]
},
"expected": {
"error": "row-width"
}
}
];
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 the header-bearing page and continuation evidence beside the extracted rows. This case tests header reuse after page association is supplied, not a guess based on neighbouring pages.