Skip to content
Astera Technology

Retest an adapter after a declared output-key revision

A new response shape is silently interpreted using an older adapter.

Download complete case notes and answer keys ↓

Define the local evaluation task

A synthetic adapter supports two exact local response shapes: v 1 with qty, or v 2 with quantity. Each shape has exactly that one key and a nonnegative integer value. The caller declares the adapter revision. A response using the other revision’s key is incompatible rather than a zero quantity; unknown revisions are not guessed.

  1. Select explicit adapter revision
  2. Check the exact response key set
  3. Read value only from compatible shape

Incompatible shapes require a recorded adapter/version decision.

Use the filled cases

Original synthetic input and literal answer key
CaseSupplied inputExpected structured outputDecision and reason
v 1 adapter sees v 2 key{"revision":"v1","response":{"quantity":3}}{"status":"incompatible"}Missing qty is not a supplied zero; the declared revision does not match.
v 2 shape matches{"revision":"v2","response":{"quantity":3}}{"status":"accepted","quantity":3}The exact v 2 key and integer value satisfy this local contract.
Both revision keys supplied{"revision":"v2","response":{"qty":3,"quantity":3}}{"status":"incompatible"}The one-key envelope forbids ambiguous dual representation even when values agree.
Download editable CSV ↓

Work the both-revision-keys case. Which output is required, and why?

Show the worked answer

{"status":"incompatible"} — The one-key envelope forbids ambiguous dual representation even when values agree.

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 key=x.revision==='v1'?'qty':x.revision==='v2'?'quantity':null;if(!key)return {status:'unknown-revision'};
 if(Object.keys(x.response).length!==1||!Object.hasOwn(x.response,key))return {status:'incompatible'};
 const value=x.response[key];return Number.isInteger(value)&&value>=0?{status:'accepted',quantity:value}:{status:'invalid-value'};
}

const cases = [
  {
    "id": "v1-meets-v2-response",
    "input": {
      "revision": "v1",
      "response": {
        "quantity": 3
      }
    },
    "expected": {
      "status": "incompatible"
    }
  },
  {
    "id": "v2-matched",
    "input": {
      "revision": "v2",
      "response": {
        "quantity": 3
      }
    },
    "expected": {
      "status": "accepted",
      "quantity": 3
    }
  },
  {
    "id": "both-revision-keys",
    "input": {
      "revision": "v2",
      "response": {
        "qty": 3,
        "quantity": 3
      }
    },
    "expected": {
      "status": "incompatible"
    }
  }
];
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 ↓

Save revision and raw response with every fixture. This adapter example does not provide a rollout order, claim a provider supports either key or authorise a record write.

Related resources

Development services →