{
  "fictional": true,
  "unitContract": "100 integer minor units per MU; whole item quantities",
  "dateContract": "Whole-day business periods and closed-day knowledge snapshots; lower-inclusive upper-exclusive intervals",
  "orders": [
    {
      "id": "O1",
      "item": "A",
      "businessDate": "2026-11-03",
      "acceptedDate": "2026-11-08",
      "quantity": 10,
      "salesMinor": 10000,
      "currency": "MU"
    },
    {
      "id": "O2",
      "item": "A",
      "businessDate": "2026-11-05",
      "acceptedDate": "2026-11-08",
      "quantity": 20,
      "salesMinor": 20000,
      "currency": "MU"
    },
    {
      "id": "O3",
      "item": "A",
      "businessDate": "2026-11-06",
      "acceptedDate": "2026-11-08",
      "quantity": 10,
      "salesMinor": 10000,
      "currency": "MU"
    },
    {
      "id": "O4",
      "item": "A",
      "businessDate": "2026-11-08",
      "acceptedDate": "2026-11-08",
      "quantity": 20,
      "salesMinor": 20000,
      "currency": "MU"
    }
  ],
  "costs": [
    {
      "id": "C1",
      "item": "A",
      "currency": "MU",
      "unitCostMinor": 400,
      "effectiveFrom": "2026-11-01",
      "effectiveTo": "2026-11-06",
      "knownFrom": "2026-10-31",
      "knownTo": "2026-11-09"
    },
    {
      "id": "C2",
      "item": "A",
      "currency": "MU",
      "unitCostMinor": 500,
      "effectiveFrom": "2026-11-06",
      "effectiveTo": null,
      "knownFrom": "2026-11-06",
      "knownTo": null
    },
    {
      "id": "C3",
      "item": "A",
      "currency": "MU",
      "unitCostMinor": 450,
      "effectiveFrom": "2026-11-01",
      "effectiveTo": "2026-11-06",
      "knownFrom": "2026-11-09",
      "knownTo": null
    }
  ],
  "expected": {
    "originalSnapshot": "2026-11-08",
    "originalVersions": [
      "C1",
      "C1",
      "C2",
      "C2"
    ],
    "salesMinor": 60000,
    "originalCostMinor": 27000,
    "originalContributionMinor": 33000,
    "correctedSnapshot": "2026-11-10",
    "correctedVersions": [
      "C3",
      "C3",
      "C2",
      "C2"
    ],
    "correctedCostMinor": 28500,
    "correctedContributionMinor": 31500,
    "correctionBridgeMinor": 1500,
    "wrongCurrentEffectiveCostMinor": 30000,
    "wrongCurrentEffectiveContributionMinor": 30000,
    "wrongLatestRecordedCostMinor": 27000,
    "wrongLatestRecordedHistoricalRowErrorsMinor": [
      500,
      1000,
      -500,
      -1000
    ],
    "wrongEffectiveOnlyJoin": {
      "joinedRows": 6,
      "salesMinor": 90000,
      "costMinor": 40500,
      "contributionMinor": 49500
    }
  },
  "additionalOrderScenario": {
    "order": {
      "id": "O5",
      "item": "A",
      "businessDate": "2026-11-04",
      "acceptedDate": "2026-11-10",
      "quantity": 10,
      "salesMinor": 10000,
      "currency": "MU"
    },
    "beforeAvailability": "O5 pending; cannot claim complete five-order population",
    "laterSalesMinor": 70000,
    "laterCostMinor": 33000,
    "laterContributionMinor": 37000,
    "bridge": {
      "newOrderContributionMinor": 5500,
      "originalPopulationCostCorrectionMinor": -1500,
      "netContributionChangeMinor": 4000
    }
  },
  "tests": [
    {
      "change": "Add overlapping effective and knowledge intervals for same item",
      "expected": "reject ambiguity before aggregation"
    },
    {
      "change": "Remove earlier-period history",
      "expected": "O1 and O2 unmatched, complete total unavailable"
    },
    {
      "change": "Duplicate order or cost-version identity",
      "expected": "reject"
    },
    {
      "change": "Add a future known-from correction without overlap",
      "expected": "earlier snapshot assignments remain unchanged"
    },
    {
      "change": "Order on6November",
      "expected": "C2; earlier effective upper boundary excluded"
    }
  ],
  "sources": [
    {
      "url": "https://www.postgresql.org/docs/current/rangetypes.html",
      "claim": "Interval-boundary and overlap mechanics; not restaurant cost policy"
    },
    {
      "url": "https://learn.microsoft.com/en-us/sql/relational-databases/tables/temporal/overview?view=sql-server-ver17",
      "claim": "System-versioned history and querying in named products; not automatic business-effective/availability semantics"
    }
  ]
}