{
  "apiVersion": "modernedi.com/scenario/v1",
  "kind": "ScenarioDefinition",
  "metadata": {"namespace": "modernedi.examples", "key": "grocery-order-to-invoice", "version": "1.0.0"},
  "spec": {
    "parameters": [{"id": "expectedInvoiceTotal", "type": "decimal", "required": true}],
    "actors": [{"id": "groceryBuyer"}, {"id": "grocerySupplier"}],
    "steps": [
      {
        "id": "groceryPurchaseOrder", "fromActor": "groceryBuyer", "toActor": "grocerySupplier",
        "transaction": {"standard": "X12", "transactionSet": "875", "businessUsage": "grocery_purchase_order"},
        "occurrence": {"min": 1, "max": 1, "closure": {"kind": "fixed"}},
        "facts": [
          {"name": "purchaseOrderNumber", "type": "string", "cardinality": "one", "normalization": ["trim"], "sensitivity": "business"},
          {"name": "orderedItems", "type": "set", "elementType": "string", "cardinality": "one", "normalization": [], "sensitivity": "business"}
        ],
        "pipeline": [
          {"id": "exchange", "kind": "exchange"},
          {"id": "extract", "kind": "extract", "facts": ["purchaseOrderNumber", "orderedItems"]}
        ]
      },
      {
        "id": "advanceShipNotice", "fromActor": "grocerySupplier", "toActor": "groceryBuyer",
        "transaction": {"standard": "X12", "transactionSet": "856", "businessUsage": "advance_ship_notice"},
        "occurrence": {"min": 1, "max": 1, "closure": {"kind": "fixed"}},
        "facts": [
          {"name": "purchaseOrderNumber", "type": "string", "cardinality": "one", "normalization": ["trim"], "sensitivity": "business"},
          {"name": "shippedItems", "type": "set", "elementType": "string", "cardinality": "one", "normalization": [], "sensitivity": "business"}
        ],
        "pipeline": [
          {"id": "exchange", "kind": "exchange"},
          {"id": "extract", "kind": "extract", "facts": ["purchaseOrderNumber", "shippedItems"]}
        ]
      },
      {
        "id": "groceryInvoice", "fromActor": "grocerySupplier", "toActor": "groceryBuyer",
        "transaction": {"standard": "X12", "transactionSet": "880", "businessUsage": "grocery_invoice"},
        "occurrence": {"min": 1, "max": 1, "closure": {"kind": "fixed"}},
        "facts": [
          {"name": "purchaseOrderNumber", "type": "string", "cardinality": "one", "normalization": ["trim"], "sensitivity": "business"},
          {"name": "invoiceTotal", "type": "decimal", "cardinality": "one", "normalization": ["decimal_canonical"], "sensitivity": "financial"}
        ],
        "pipeline": [
          {"id": "exchange", "kind": "exchange"},
          {"id": "extract", "kind": "extract", "facts": ["purchaseOrderNumber", "invoiceTotal"]}
        ]
      }
    ],
    "transitions": [
      {
        "id": "shipmentForGroceryOrder", "fromStep": "groceryPurchaseOrder", "toStep": "advanceShipNotice", "relationship": "follows",
        "correlations": [{"id": "sameOrder", "operator": "equal", "left": {"kind": "fact", "stepId": "groceryPurchaseOrder", "fact": "purchaseOrderNumber", "projection": "value"}, "right": {"kind": "fact", "stepId": "advanceShipNotice", "fact": "purchaseOrderNumber", "projection": "value"}}],
        "matching": {"strategy": "correlate", "quantifiers": [{"kind": "every", "scope": "from"}, {"kind": "every", "scope": "to"}], "unmatched": "fail"}
      },
      {
        "id": "invoiceSettlesShipment", "fromStep": "advanceShipNotice", "toStep": "groceryInvoice", "relationship": "follows",
        "correlations": [],
        "matching": {"strategy": "position", "quantifiers": [{"kind": "every", "scope": "pairs"}], "unmatched": "fail"}
      }
    ],
    "assertions": [
      {"id": "shippedItemsWereOrdered", "operator": "subset", "left": {"kind": "fact", "stepId": "advanceShipNotice", "fact": "shippedItems", "projection": "value"}, "right": {"kind": "fact", "stepId": "groceryPurchaseOrder", "fact": "orderedItems", "projection": "value"}},
      {"id": "invoiceTotalMatches", "operator": "equal", "left": {"kind": "fact", "stepId": "groceryInvoice", "fact": "invoiceTotal", "projection": "value"}, "right": {"kind": "parameter", "parameter": "expectedInvoiceTotal"}}
    ],
    "checkpoints": [],
    "branches": []
  }
}
