{
  "id": "records",
  "number": "05",
  "label": "Structured records",
  "formats": "JSON · CSV · stable IDs",
  "title": "Separate duplicates, revisions and unknowns.",
  "summary": "An incoming batch repeats one record, revises another and leaves a quantity unknown.",
  "status": "Constructed scenario",
  "source_note": "Fictional order-like records with stable identifiers. No customer or personal data is included.",
  "sources": [],
  "attribution": "Original Tesserva demonstration. All record identifiers, quantities and prices are invented.",
  "input": "A101: 5 units at $12. A102: unknown units at $10. A103: 2 units at $15. The known subtotal is $90; one record is unresolved.",
  "change": "The batch repeats A101 at revision 1 and supplies A103 revision 2 with 3 units. A102 is still unknown. The rules say to deduplicate identical ID/revision pairs and use the highest approved revision per ID.",
  "task": "Repair records.json and totals.json. Keep one row per stable ID, retain null for unknown units, apply the approved revision, and calculate only the known subtotal. Sort records by ID for the declared output contract.",
  "result": "Three records remain. A103 changes to 3 units, A101 is counted once, and A102 stays unknown. The known subtotal is $105, with one unresolved record.",
  "checks": [
    "The duplicate does not create a fourth row or another charge.",
    "A103 revision 2 replaces revision 1.",
    "Unknown units remain null, rather than becoming zero.",
    "The known subtotal is $105 and unresolved_records is 1."
  ],
  "inputs": {
    "records": [
      {
        "id": "A101",
        "revision": 1,
        "units": 5,
        "unit_price_usd": 12
      },
      {
        "id": "A102",
        "revision": 1,
        "units": null,
        "unit_price_usd": 10
      },
      {
        "id": "A103",
        "revision": 1,
        "units": 2,
        "unit_price_usd": 15
      }
    ]
  },
  "update": {
    "approved_batch": [
      {
        "id": "A101",
        "revision": 1,
        "units": 5,
        "unit_price_usd": 12
      },
      {
        "id": "A103",
        "revision": 2,
        "units": 3,
        "unit_price_usd": 15
      }
    ]
  },
  "prior_outputs": {
    "records.json": [
      {
        "id": "A101",
        "revision": 1,
        "units": 5,
        "unit_price_usd": 12
      },
      {
        "id": "A102",
        "revision": 1,
        "units": null,
        "unit_price_usd": 10
      },
      {
        "id": "A103",
        "revision": 1,
        "units": 2,
        "unit_price_usd": 15
      }
    ],
    "totals.json": {
      "known_subtotal_usd": 90,
      "unresolved_records": 1,
      "unique_records": 3
    }
  },
  "expected_outputs": {
    "records.json": [
      {
        "id": "A101",
        "revision": 1,
        "units": 5,
        "unit_price_usd": 12
      },
      {
        "id": "A102",
        "revision": 1,
        "units": null,
        "unit_price_usd": 10
      },
      {
        "id": "A103",
        "revision": 2,
        "units": 3,
        "unit_price_usd": 15
      }
    ],
    "totals.json": {
      "known_subtotal_usd": 105,
      "unresolved_records": 1,
      "unique_records": 3
    }
  }
}
