Skip to content
Astera Technology

Check requested read fields against the tool projection

A broad default projection pulls extra fields despite a narrow permitted task.

Download complete case notes and answer keys ↓

Define the local evaluation task

A synthetic read task provides its exact required field projection. A proposed call must request that same distinct field set, with no omitted or extra field and no duplicate field entry. The evaluator reports all three failures before any retrieval. Required fields are fixture scope, not an inferred access policy.

  1. Retain required field projection
  2. Compare missing, extra and repeated fields
  3. Hold invalid read proposal before retrieval

A failed projection requires plan correction without fetching the extra fields.

Use the filled cases

Original synthetic input and literal answer key
CaseSupplied inputExpected structured outputDecision and reason
Unrequested note field{"required":["id","state"],"requested":["id","state","internalNote"]}{"extra":["internalNote"],"missing":[],"duplicates":[],"valid":false}InternalNote is outside the narrow supplied read projection.
Exact fields in another order{"required":["id","state"],"requested":["state","id"]}{"extra":[],"missing":[],"duplicates":[],"valid":true}Order is irrelevant for this distinct field set.
Duplicate id and missing state{"required":["id","state"],"requested":["id","id"]}{"extra":[],"missing":["state"],"duplicates":["id"],"valid":false}Two copies of id neither satisfy state nor meet the no-duplicate contract.
Download editable CSV ↓

Work the duplicate-missing case. Which output is required, and why?

Show the worked answer

{"extra":[],"missing":["state"],"duplicates":["id"],"valid":false} — Two copies of id neither satisfy state nor meet the no-duplicate contract.

Run the self-contained evaluator

Save as .mjs and run with Node.js; supplied fixtures only
import assert from 'node:assert/strict';

function evaluate(x){
 const required=[...new Set(x.required)].sort(),requested=[...new Set(x.requested)].sort();const duplicates=requested.filter(k=>x.requested.filter(v=>v===k).length>1);
 const extra=requested.filter(k=>!required.includes(k)),missing=required.filter(k=>!requested.includes(k));return {extra,missing,duplicates,valid:extra.length+missing.length+duplicates.length===0};
}

const cases = [
  {
    "id": "extra-note",
    "input": {
      "required": [
        "id",
        "state"
      ],
      "requested": [
        "id",
        "state",
        "internalNote"
      ]
    },
    "expected": {
      "extra": [
        "internalNote"
      ],
      "missing": [],
      "duplicates": [],
      "valid": false
    }
  },
  {
    "id": "exact-projection",
    "input": {
      "required": [
        "id",
        "state"
      ],
      "requested": [
        "state",
        "id"
      ]
    },
    "expected": {
      "extra": [],
      "missing": [],
      "duplicates": [],
      "valid": true
    }
  },
  {
    "id": "duplicate-missing",
    "input": {
      "required": [
        "id",
        "state"
      ],
      "requested": [
        "id",
        "id"
      ]
    },
    "expected": {
      "extra": [],
      "missing": [
        "state"
      ],
      "duplicates": [
        "id"
      ],
      "valid": false
    }
  }
];
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)}));
Download runnable example ↓

Use the field lists as a local plan acceptance sheet. A projection pass is independent of authentication, permission checks and the correctness of returned values.

Related resources