{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "ModernEDI Scenario Workspace API",
    "version": "1.0.0",
    "summary": "Customer v1 contract for scenario authoring, execution, and platform context inside a signed-in workspace.",
    "description": "This contract serves signed-in ModernEDI workspace users and browser/BFF automation acting with the same tenant session. It is intentionally separate from the public API-key Integration API. An Integration API key does not authenticate tenant routes. The one stateless Mapper expression-diagnostics operation is explicitly public and never reads or changes tenant data."
  },
  "externalDocs": {
    "description": "Scenario authoring guide, schema-derived field reference, and executable examples",
    "url": "https://www.modernedi.com/docs/scenarios/reference"
  },
  "servers": [
    {
      "url": "https://api.modernedi.com",
      "description": "ModernEDI production Workspace API origin"
    }
  ],
  "tags": [
    {
      "name": "Catalog",
      "description": "Discover definitions and runtime readiness."
    },
    {
      "name": "Authoring",
      "description": "Validate draft JSON without lifecycle mutation."
    },
    {
      "name": "Lifecycle",
      "description": "Publish definitions and apply binding revisions immutably."
    },
    {
      "name": "Managed profiles",
      "description": "Prepare ModernEDI-owned test dependencies used by guided scenario examples."
    },
    {
      "name": "Runs",
      "description": "Start, inspect, and advance durable evidence-bearing runs."
    },
    {
      "name": "Evidence",
      "description": "Export immutable, redacted proof for terminal scenario runs."
    },
    {
      "name": "Context",
      "description": "Connect ordinary transactions, partners, and mappings to scenario conversations."
    },
    {
      "name": "Tooling",
      "description": "Stateless JSON authoring support shared with the Mapper editor."
    }
  ],
  "paths": {
    "/tenant/scenarios/catalog": {
      "get": {
        "operationId": "listScenarioCatalog",
        "tags": [
          "Catalog"
        ],
        "summary": "List scenario definitions available to the tenant",
        "description": "Returns managed and tenant-published definitions with canonical hashes, topological order, syntax-tree readiness, and managed-adapter information. definition_only means the catalog has no single stored X12 release covering every step; syntax_tree_backed means at least one stored release covers every step but no exact ModernEDI-managed adapter is registered; executable_adapter means one exact registered managed adapter covers the definition identity, hash, and every step. These catalog labels do not decide whether a tenant-specific binding can run: Validate and Apply make that decision from the binding's exact partners, per-step syntax trees, mappings, observation targets, fact expressions, and adapters. The response is private and conditionally cacheable with its strong ETag.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioCatalogResource.java#catalog",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioCatalogResponse"
                },
                "example": {
                  "success": true,
                  "definitions": [
                    {
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                      "topologicalStepOrder": [
                        "purchaseOrder",
                        "invoice"
                      ],
                      "readiness": {
                        "level": "syntax_tree_backed",
                        "completeSyntaxTreeVersions": [
                          "004010"
                        ],
                        "missingSyntaxTreeStepIds": []
                      },
                      "definition": {
                        "$schema": "https://www.modernedi.com/docs/scenarios/schemas/scenario-definition-v1.schema.json",
                        "apiVersion": "modernedi.com/scenario/v1",
                        "kind": "ScenarioDefinition",
                        "metadata": {
                          "namespace": "acme",
                          "key": "retail-order-invoice",
                          "version": "1.0.0"
                        },
                        "spec": {
                          "actors": [
                            {
                              "id": "retailer"
                            },
                            {
                              "id": "supplier"
                            }
                          ],
                          "steps": [
                            {
                              "id": "purchaseOrder",
                              "fromActor": "retailer",
                              "toActor": "supplier",
                              "transaction": {
                                "standard": "X12",
                                "transactionSet": "850",
                                "businessUsage": "purchase_order"
                              },
                              "occurrence": {
                                "min": 1,
                                "max": 1,
                                "closure": {
                                  "kind": "fixed"
                                }
                              },
                              "assurance": {
                                "requirements": [
                                  {
                                    "type": "mapping_succeeded"
                                  }
                                ]
                              },
                              "facts": [
                                {
                                  "name": "purchaseOrderNumber",
                                  "type": "string",
                                  "cardinality": "one",
                                  "normalization": [
                                    "trim"
                                  ],
                                  "sensitivity": "business"
                                }
                              ],
                              "pipeline": [
                                {
                                  "id": "exchange",
                                  "kind": "exchange"
                                },
                                {
                                  "id": "extract",
                                  "kind": "extract",
                                  "facts": [
                                    "purchaseOrderNumber"
                                  ]
                                },
                                {
                                  "id": "assure",
                                  "kind": "assure"
                                }
                              ]
                            },
                            {
                              "id": "invoice",
                              "fromActor": "supplier",
                              "toActor": "retailer",
                              "transaction": {
                                "standard": "X12",
                                "transactionSet": "810",
                                "businessUsage": "invoice"
                              },
                              "occurrence": {
                                "min": 1,
                                "max": 1,
                                "closure": {
                                  "kind": "fixed"
                                }
                              },
                              "assurance": {
                                "requirements": [
                                  {
                                    "type": "transport_receipt_accepted",
                                    "within": "PT4H"
                                  },
                                  {
                                    "type": "functional_or_implementation_acknowledgment_accepted"
                                  }
                                ]
                              },
                              "facts": [
                                {
                                  "name": "purchaseOrderNumber",
                                  "type": "string",
                                  "cardinality": "one",
                                  "normalization": [
                                    "trim"
                                  ],
                                  "sensitivity": "business"
                                },
                                {
                                  "name": "invoiceTotal",
                                  "type": "decimal",
                                  "cardinality": "optional",
                                  "normalization": [
                                    "decimal_canonical"
                                  ],
                                  "sensitivity": "financial"
                                }
                              ],
                              "pipeline": [
                                {
                                  "id": "exchange",
                                  "kind": "exchange"
                                },
                                {
                                  "id": "extract",
                                  "kind": "extract",
                                  "facts": [
                                    "purchaseOrderNumber",
                                    "invoiceTotal"
                                  ]
                                },
                                {
                                  "id": "assure",
                                  "kind": "assure"
                                }
                              ]
                            }
                          ],
                          "transitions": [
                            {
                              "id": "invoiceSettlesOrder",
                              "fromStep": "purchaseOrder",
                              "toStep": "invoice",
                              "relationship": "follows",
                              "within": "P30D",
                              "correlations": [
                                {
                                  "id": "samePurchaseOrder",
                                  "operator": "equal",
                                  "left": {
                                    "kind": "fact",
                                    "stepId": "purchaseOrder",
                                    "fact": "purchaseOrderNumber",
                                    "projection": "value"
                                  },
                                  "right": {
                                    "kind": "fact",
                                    "stepId": "invoice",
                                    "fact": "purchaseOrderNumber",
                                    "projection": "value"
                                  }
                                }
                              ],
                              "matching": {
                                "strategy": "correlate",
                                "quantifiers": [
                                  {
                                    "kind": "every",
                                    "scope": "from"
                                  },
                                  {
                                    "kind": "every",
                                    "scope": "to"
                                  }
                                ],
                                "unmatched": "fail"
                              }
                            }
                          ],
                          "assertions": [
                            {
                              "id": "invoiceTotalExists",
                              "operator": "exists",
                              "left": {
                                "kind": "fact",
                                "stepId": "invoice",
                                "fact": "invoiceTotal",
                                "projection": "value"
                              }
                            }
                          ],
                          "parameters": [],
                          "checkpoints": [],
                          "branches": []
                        }
                      }
                    }
                  ]
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/lifecycleETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Link": {
                "$ref": "#/components/headers/Link"
              }
            }
          },
          "304": {
            "description": "The catalog has not changed.",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/lifecycleETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Link": {
                "$ref": "#/components/headers/Link"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          }
        }
      }
    },
    "/x12mapper/workspaces/{workspaceId}/scenario-authoring/validate": {
      "post": {
        "operationId": "validateScenarioAuthoring",
        "tags": [
          "Authoring"
        ],
        "summary": "Validate scenario definition and binding drafts",
        "description": "Runs strict JSON parsing, JSON Schema validation, cross-file resolution, tenant-authority checks, graph checks, fact typing, and current runtime-capability checks without publishing or applying anything.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantMapperWorkspaceResource.java#validateScenarioAuthoring",
        "parameters": [
          {
            "$ref": "#/components/parameters/workspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioValidationResponse"
                },
                "example": {
                  "success": true,
                  "files": [
                    {
                      "id": "order-invoice.scenario.json",
                      "fileType": "SCENARIO_DEFINITION",
                      "kind": "definition",
                      "status": "resolved",
                      "issues": [],
                      "compiled": {
                        "definition": {
                          "namespace": "acme",
                          "key": "retail-order-invoice",
                          "version": "1.0.0",
                          "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                        },
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      }
                    },
                    {
                      "id": "order-invoice.binding.json",
                      "fileType": "SCENARIO_BINDING",
                      "kind": "binding",
                      "status": "resolved",
                      "issues": [],
                      "compiled": {
                        "definition": {
                          "namespace": "acme",
                          "key": "retail-order-invoice",
                          "version": "1.0.0",
                          "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                        },
                        "contentSha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
                        "authorityEtag": "\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"",
                        "referencedPartnerIds": [
                          42
                        ],
                        "applyEligibility": {
                          "eligible": true,
                          "activationKind": "scenario_graph_v1",
                          "reason": null
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScenarioValidationRequest"
              },
              "example": {
                "files": [
                  {
                    "id": "order-invoice.scenario.json",
                    "fileType": "SCENARIO_DEFINITION",
                    "source": "{\n  \"$schema\": \"https://www.modernedi.com/docs/scenarios/schemas/scenario-definition-v1.schema.json\",\n  \"apiVersion\": \"modernedi.com/scenario/v1\",\n  \"kind\": \"ScenarioDefinition\",\n  \"metadata\": {\n    \"namespace\": \"acme\",\n    \"key\": \"retail-order-invoice\",\n    \"version\": \"1.0.0\"\n  },\n  \"spec\": {\n    \"actors\": [\n      {\n        \"id\": \"retailer\"\n      },\n      {\n        \"id\": \"supplier\"\n      }\n    ],\n    \"steps\": [\n      {\n        \"id\": \"purchaseOrder\",\n        \"fromActor\": \"retailer\",\n        \"toActor\": \"supplier\",\n        \"transaction\": {\n          \"standard\": \"X12\",\n          \"transactionSet\": \"850\",\n          \"businessUsage\": \"purchase_order\"\n        },\n        \"occurrence\": {\n          \"min\": 1,\n          \"max\": 1,\n          \"closure\": {\n            \"kind\": \"fixed\"\n          }\n        },\n        \"assurance\": {\n          \"requirements\": [\n            {\n              \"type\": \"mapping_succeeded\"\n            }\n          ]\n        },\n        \"facts\": [\n          {\n            \"name\": \"purchaseOrderNumber\",\n            \"type\": \"string\",\n            \"cardinality\": \"one\",\n            \"normalization\": [\n              \"trim\"\n            ],\n            \"sensitivity\": \"business\"\n          }\n        ],\n        \"pipeline\": [\n          {\n            \"id\": \"exchange\",\n            \"kind\": \"exchange\"\n          },\n          {\n            \"id\": \"extract\",\n            \"kind\": \"extract\",\n            \"facts\": [\n              \"purchaseOrderNumber\"\n            ]\n          },\n          {\n            \"id\": \"assure\",\n            \"kind\": \"assure\"\n          }\n        ]\n      },\n      {\n        \"id\": \"invoice\",\n        \"fromActor\": \"supplier\",\n        \"toActor\": \"retailer\",\n        \"transaction\": {\n          \"standard\": \"X12\",\n          \"transactionSet\": \"810\",\n          \"businessUsage\": \"invoice\"\n        },\n        \"occurrence\": {\n          \"min\": 1,\n          \"max\": 1,\n          \"closure\": {\n            \"kind\": \"fixed\"\n          }\n        },\n        \"assurance\": {\n          \"requirements\": [\n            {\n              \"type\": \"transport_receipt_accepted\",\n              \"within\": \"PT4H\"\n            },\n            {\n              \"type\": \"functional_or_implementation_acknowledgment_accepted\"\n            }\n          ]\n        },\n        \"facts\": [\n          {\n            \"name\": \"purchaseOrderNumber\",\n            \"type\": \"string\",\n            \"cardinality\": \"one\",\n            \"normalization\": [\n              \"trim\"\n            ],\n            \"sensitivity\": \"business\"\n          },\n          {\n            \"name\": \"invoiceTotal\",\n            \"type\": \"decimal\",\n            \"cardinality\": \"optional\",\n            \"normalization\": [\n              \"decimal_canonical\"\n            ],\n            \"sensitivity\": \"financial\"\n          }\n        ],\n        \"pipeline\": [\n          {\n            \"id\": \"exchange\",\n            \"kind\": \"exchange\"\n          },\n          {\n            \"id\": \"extract\",\n            \"kind\": \"extract\",\n            \"facts\": [\n              \"purchaseOrderNumber\",\n              \"invoiceTotal\"\n            ]\n          },\n          {\n            \"id\": \"assure\",\n            \"kind\": \"assure\"\n          }\n        ]\n      }\n    ],\n    \"transitions\": [\n      {\n        \"id\": \"invoiceSettlesOrder\",\n        \"fromStep\": \"purchaseOrder\",\n        \"toStep\": \"invoice\",\n        \"relationship\": \"follows\",\n        \"within\": \"P30D\",\n        \"correlations\": [\n          {\n            \"id\": \"samePurchaseOrder\",\n            \"operator\": \"equal\",\n            \"left\": {\n              \"kind\": \"fact\",\n              \"stepId\": \"purchaseOrder\",\n              \"fact\": \"purchaseOrderNumber\",\n              \"projection\": \"value\"\n            },\n            \"right\": {\n              \"kind\": \"fact\",\n              \"stepId\": \"invoice\",\n              \"fact\": \"purchaseOrderNumber\",\n              \"projection\": \"value\"\n            }\n          }\n        ],\n        \"matching\": {\n          \"strategy\": \"correlate\",\n          \"quantifiers\": [\n            {\n              \"kind\": \"every\",\n              \"scope\": \"from\"\n            },\n            {\n              \"kind\": \"every\",\n              \"scope\": \"to\"\n            }\n          ],\n          \"unmatched\": \"fail\"\n        }\n      }\n    ],\n    \"assertions\": [\n      {\n        \"id\": \"invoiceTotalExists\",\n        \"operator\": \"exists\",\n        \"left\": {\n          \"kind\": \"fact\",\n          \"stepId\": \"invoice\",\n          \"fact\": \"invoiceTotal\",\n          \"projection\": \"value\"\n        }\n      }\n    ],\n    \"parameters\": [],\n    \"checkpoints\": [],\n    \"branches\": []\n  }\n}\n"
                  },
                  {
                    "id": "order-invoice.binding.json",
                    "fileType": "SCENARIO_BINDING",
                    "source": "{\n  \"$schema\": \"https://www.modernedi.com/docs/scenarios/schemas/scenario-binding-v1.schema.json\",\n  \"apiVersion\": \"modernedi.com/scenario-binding-authoring/v1\",\n  \"kind\": \"ScenarioBinding\",\n  \"metadata\": {\n    \"id\": \"retailOrderInvoice\",\n    \"name\": \"Retail order to invoice\"\n  },\n  \"spec\": {\n    \"definition\": {\n      \"namespace\": \"acme\",\n      \"key\": \"retail-order-invoice\",\n      \"version\": \"1.0.0\",\n      \"contentSha256\": \"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"\n    },\n    \"environment\": \"production\",\n    \"actors\": [\n      {\n        \"actorId\": \"retailer\",\n        \"endpoint\": {\n          \"kind\": \"partner\",\n          \"partnerId\": 42\n        }\n      },\n      {\n        \"actorId\": \"supplier\",\n        \"endpoint\": {\n          \"kind\": \"workspace\"\n        }\n      }\n    ],\n    \"steps\": [\n      {\n        \"stepId\": \"purchaseOrder\",\n        \"target\": {\n          \"kind\": \"runtime-mapping\",\n          \"runtimeMappingId\": 101\n        },\n        \"factSources\": [\n          {\n            \"fact\": \"purchaseOrderNumber\",\n            \"source\": {\n              \"kind\": \"x12-mapper-expression\",\n              \"expression\": \"ST->BEG(03)\"\n            }\n          }\n        ]\n      },\n      {\n        \"stepId\": \"invoice\",\n        \"syntaxTree\": {\n          \"x12Version\": \"004010\",\n          \"transactionSet\": \"810\"\n        },\n        \"target\": {\n          \"kind\": \"runtime-mapping\",\n          \"runtimeMappingId\": 102\n        },\n        \"factSources\": [\n          {\n            \"fact\": \"purchaseOrderNumber\",\n            \"source\": {\n              \"kind\": \"x12-mapper-expression\",\n              \"expression\": \"ST->BIG(04)\"\n            }\n          },\n          {\n            \"fact\": \"invoiceTotal\",\n            \"source\": {\n              \"kind\": \"x12-mapper-expression\",\n              \"expression\": \"ST->TDS(01)\"\n            }\n          }\n        ]\n      }\n    ]\n  }\n}\n"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/x12mapper/workspaces/{workspaceId}/scenario-authoring/definitions": {
      "get": {
        "operationId": "listPublishedScenarioDefinitions",
        "tags": [
          "Lifecycle"
        ],
        "summary": "List immutable tenant-published definitions",
        "description": "Returns definition identities and publication provenance for this tenant. The original source is intentionally represented by its canonical identity and hash.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantMapperWorkspaceResource.java#publishedScenarioDefinitions",
        "parameters": [
          {
            "$ref": "#/components/parameters/workspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedDefinitionListResponse"
                },
                "example": {
                  "success": true,
                  "definitions": [
                    {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                      "etag": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"",
                      "publishedAt": "2026-08-24T18:00:00Z",
                      "publishedBy": {
                        "memberId": 17,
                        "email": "operator@example.com",
                        "role": "OPERATOR"
                      }
                    }
                  ]
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          }
        }
      }
    },
    "/x12mapper/workspaces/{workspaceId}/scenario-authoring/definitions/publish": {
      "post": {
        "operationId": "publishScenarioDefinition",
        "tags": [
          "Lifecycle"
        ],
        "summary": "Publish a validated definition immutably",
        "description": "Publishes the exact definition source only when its canonical hash matches expectedContentSha256. Reusing an Idempotency-Key with the identical request replays the original result; reusing it for different content is a conflict.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request",
          "precondition_required",
          "precondition_failed",
          "definition_identity_conflict",
          "scenario_revision_conflict",
          "idempotency_key_conflict",
          "content_hash_mismatch",
          "scenario_authoring_quota_exceeded"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantMapperWorkspaceResource.java#publishScenarioDefinition",
        "parameters": [
          {
            "$ref": "#/components/parameters/workspaceId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required command identity. Replays require byte-equivalent normalized input.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "scenario-run-20260824-001"
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": true,
            "description": "Use * when creating a resource that must not already exist.",
            "schema": {
              "type": "string",
              "enum": [
                "*"
              ]
            },
            "example": "*"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedDefinitionMutationResponse"
                },
                "example": {
                  "success": true,
                  "replay": false,
                  "definition": {
                    "namespace": "acme",
                    "key": "retail-order-invoice",
                    "version": "1.0.0",
                    "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "etag": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"",
                    "publishedAt": "2026-08-24T18:00:00Z",
                    "publishedBy": {
                      "memberId": 17,
                      "email": "operator@example.com",
                      "role": "OPERATOR"
                    }
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/lifecycleETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "201": {
            "description": "The immutable resource or durable run was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedDefinitionMutationResponse"
                },
                "example": {
                  "success": true,
                  "replay": false,
                  "definition": {
                    "namespace": "acme",
                    "key": "retail-order-invoice",
                    "version": "1.0.0",
                    "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "etag": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"",
                    "publishedAt": "2026-08-24T18:00:00Z",
                    "publishedBy": {
                      "memberId": 17,
                      "email": "operator@example.com",
                      "role": "OPERATOR"
                    }
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/lifecycleETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishScenarioDefinitionRequest"
              },
              "example": {
                "file": {
                  "id": "order-invoice.scenario.json",
                  "fileType": "SCENARIO_DEFINITION",
                  "source": "{\n  \"$schema\": \"https://www.modernedi.com/docs/scenarios/schemas/scenario-definition-v1.schema.json\",\n  \"apiVersion\": \"modernedi.com/scenario/v1\",\n  \"kind\": \"ScenarioDefinition\",\n  \"metadata\": {\n    \"namespace\": \"acme\",\n    \"key\": \"retail-order-invoice\",\n    \"version\": \"1.0.0\"\n  },\n  \"spec\": {\n    \"actors\": [\n      {\n        \"id\": \"retailer\"\n      },\n      {\n        \"id\": \"supplier\"\n      }\n    ],\n    \"steps\": [\n      {\n        \"id\": \"purchaseOrder\",\n        \"fromActor\": \"retailer\",\n        \"toActor\": \"supplier\",\n        \"transaction\": {\n          \"standard\": \"X12\",\n          \"transactionSet\": \"850\",\n          \"businessUsage\": \"purchase_order\"\n        },\n        \"occurrence\": {\n          \"min\": 1,\n          \"max\": 1,\n          \"closure\": {\n            \"kind\": \"fixed\"\n          }\n        },\n        \"assurance\": {\n          \"requirements\": [\n            {\n              \"type\": \"mapping_succeeded\"\n            }\n          ]\n        },\n        \"facts\": [\n          {\n            \"name\": \"purchaseOrderNumber\",\n            \"type\": \"string\",\n            \"cardinality\": \"one\",\n            \"normalization\": [\n              \"trim\"\n            ],\n            \"sensitivity\": \"business\"\n          }\n        ],\n        \"pipeline\": [\n          {\n            \"id\": \"exchange\",\n            \"kind\": \"exchange\"\n          },\n          {\n            \"id\": \"extract\",\n            \"kind\": \"extract\",\n            \"facts\": [\n              \"purchaseOrderNumber\"\n            ]\n          },\n          {\n            \"id\": \"assure\",\n            \"kind\": \"assure\"\n          }\n        ]\n      },\n      {\n        \"id\": \"invoice\",\n        \"fromActor\": \"supplier\",\n        \"toActor\": \"retailer\",\n        \"transaction\": {\n          \"standard\": \"X12\",\n          \"transactionSet\": \"810\",\n          \"businessUsage\": \"invoice\"\n        },\n        \"occurrence\": {\n          \"min\": 1,\n          \"max\": 1,\n          \"closure\": {\n            \"kind\": \"fixed\"\n          }\n        },\n        \"assurance\": {\n          \"requirements\": [\n            {\n              \"type\": \"transport_receipt_accepted\",\n              \"within\": \"PT4H\"\n            },\n            {\n              \"type\": \"functional_or_implementation_acknowledgment_accepted\"\n            }\n          ]\n        },\n        \"facts\": [\n          {\n            \"name\": \"purchaseOrderNumber\",\n            \"type\": \"string\",\n            \"cardinality\": \"one\",\n            \"normalization\": [\n              \"trim\"\n            ],\n            \"sensitivity\": \"business\"\n          },\n          {\n            \"name\": \"invoiceTotal\",\n            \"type\": \"decimal\",\n            \"cardinality\": \"optional\",\n            \"normalization\": [\n              \"decimal_canonical\"\n            ],\n            \"sensitivity\": \"financial\"\n          }\n        ],\n        \"pipeline\": [\n          {\n            \"id\": \"exchange\",\n            \"kind\": \"exchange\"\n          },\n          {\n            \"id\": \"extract\",\n            \"kind\": \"extract\",\n            \"facts\": [\n              \"purchaseOrderNumber\",\n              \"invoiceTotal\"\n            ]\n          },\n          {\n            \"id\": \"assure\",\n            \"kind\": \"assure\"\n          }\n        ]\n      }\n    ],\n    \"transitions\": [\n      {\n        \"id\": \"invoiceSettlesOrder\",\n        \"fromStep\": \"purchaseOrder\",\n        \"toStep\": \"invoice\",\n        \"relationship\": \"follows\",\n        \"within\": \"P30D\",\n        \"correlations\": [\n          {\n            \"id\": \"samePurchaseOrder\",\n            \"operator\": \"equal\",\n            \"left\": {\n              \"kind\": \"fact\",\n              \"stepId\": \"purchaseOrder\",\n              \"fact\": \"purchaseOrderNumber\",\n              \"projection\": \"value\"\n            },\n            \"right\": {\n              \"kind\": \"fact\",\n              \"stepId\": \"invoice\",\n              \"fact\": \"purchaseOrderNumber\",\n              \"projection\": \"value\"\n            }\n          }\n        ],\n        \"matching\": {\n          \"strategy\": \"correlate\",\n          \"quantifiers\": [\n            {\n              \"kind\": \"every\",\n              \"scope\": \"from\"\n            },\n            {\n              \"kind\": \"every\",\n              \"scope\": \"to\"\n            }\n          ],\n          \"unmatched\": \"fail\"\n        }\n      }\n    ],\n    \"assertions\": [\n      {\n        \"id\": \"invoiceTotalExists\",\n        \"operator\": \"exists\",\n        \"left\": {\n          \"kind\": \"fact\",\n          \"stepId\": \"invoice\",\n          \"fact\": \"invoiceTotal\",\n          \"projection\": \"value\"\n        }\n      }\n    ],\n    \"parameters\": [],\n    \"checkpoints\": [],\n    \"branches\": []\n  }\n}\n"
                },
                "expectedContentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
              }
            }
          }
        }
      }
    },
    "/x12mapper/workspaces/{workspaceId}/scenario-authoring/bindings": {
      "get": {
        "operationId": "listAppliedScenarioBindings",
        "tags": [
          "Lifecycle"
        ],
        "summary": "List applied binding revisions",
        "description": "Returns every immutable applied binding revision visible to this tenant, including the exact definition, runtime activation, authority state, and ETag.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantMapperWorkspaceResource.java#appliedScenarioBindings",
        "parameters": [
          {
            "$ref": "#/components/parameters/workspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppliedBindingListResponse"
                },
                "example": {
                  "success": true,
                  "bindings": [
                    {
                      "id": "retailOrderInvoice",
                      "name": "Retail order to invoice",
                      "status": "ACTIVE",
                      "revision": 0,
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "authoringContentSha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
                      "bindingContentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
                      "adapterId": "scenario-graph-interpreter-v1",
                      "environment": "production",
                      "referencedMappingIds": [
                        17
                      ],
                      "referencedPartnerIds": [
                        42
                      ],
                      "etag": "\"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"",
                      "appliedAt": "2026-08-24T18:05:00Z",
                      "appliedBy": {
                        "memberId": 17,
                        "email": "operator@example.com",
                        "role": "OPERATOR"
                      },
                      "activation": {
                        "kind": "scenario_graph_v1",
                        "runnable": true,
                        "current": true,
                        "reason": null
                      }
                    }
                  ]
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          }
        }
      }
    },
    "/x12mapper/workspaces/{workspaceId}/scenario-authoring/bindings/{bindingId}": {
      "get": {
        "operationId": "getAppliedScenarioBinding",
        "tags": [
          "Lifecycle"
        ],
        "summary": "Read one applied binding revision",
        "description": "Reads one exact binding identity and returns the strong ETag required to apply the next revision.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "scenario_binding_not_found"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantMapperWorkspaceResource.java#appliedScenarioBinding",
        "parameters": [
          {
            "$ref": "#/components/parameters/workspaceId"
          },
          {
            "$ref": "#/components/parameters/bindingId"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppliedBindingResponse"
                },
                "example": {
                  "success": true,
                  "binding": {
                    "id": "retailOrderInvoice",
                    "name": "Retail order to invoice",
                    "status": "ACTIVE",
                    "revision": 0,
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "authoringContentSha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
                    "bindingContentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "environment": "production",
                    "referencedMappingIds": [
                      17
                    ],
                    "referencedPartnerIds": [
                      42
                    ],
                    "etag": "\"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"",
                    "appliedAt": "2026-08-24T18:05:00Z",
                    "appliedBy": {
                      "memberId": 17,
                      "email": "operator@example.com",
                      "role": "OPERATOR"
                    },
                    "activation": {
                      "kind": "scenario_graph_v1",
                      "runnable": true,
                      "current": true,
                      "reason": null
                    }
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/lifecycleETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          }
        }
      },
      "put": {
        "operationId": "applyScenarioBinding",
        "tags": [
          "Lifecycle"
        ],
        "summary": "Apply an immutable binding revision",
        "description": "Resolves the authoring document against current tenant authority, freezes exact runtime artifacts, and creates a reproducible applied revision. Use If-None-Match: * to create revision zero; use the current strong If-Match ETag for later revisions.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request",
          "precondition_required",
          "precondition_failed",
          "etag_mismatch",
          "authority_etag_mismatch",
          "scenario_revision_conflict",
          "idempotency_key_conflict",
          "content_hash_mismatch",
          "scenario_authoring_quota_exceeded",
          "scenario_binding_no_change",
          "scenario_binding_not_executable"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantMapperWorkspaceResource.java#applyScenarioBinding",
        "parameters": [
          {
            "$ref": "#/components/parameters/workspaceId"
          },
          {
            "$ref": "#/components/parameters/bindingId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required command identity. Replays require byte-equivalent normalized input.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "scenario-run-20260824-001"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "Current strong lifecycle ETag. Required for optimistic-concurrency mutation of an existing published or applied resource.",
            "schema": {
              "$ref": "#/components/schemas/LifecycleEtag"
            },
            "example": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "required": false,
            "description": "Use * when creating a resource that must not already exist.",
            "schema": {
              "type": "string",
              "enum": [
                "*"
              ]
            },
            "example": "*"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppliedBindingMutationResponse"
                },
                "example": {
                  "success": true,
                  "replay": false,
                  "binding": {
                    "id": "retailOrderInvoice",
                    "name": "Retail order to invoice",
                    "status": "ACTIVE",
                    "revision": 0,
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "authoringContentSha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
                    "bindingContentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "environment": "production",
                    "referencedMappingIds": [
                      17
                    ],
                    "referencedPartnerIds": [
                      42
                    ],
                    "etag": "\"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"",
                    "appliedAt": "2026-08-24T18:05:00Z",
                    "appliedBy": {
                      "memberId": 17,
                      "email": "operator@example.com",
                      "role": "OPERATOR"
                    },
                    "activation": {
                      "kind": "scenario_graph_v1",
                      "runnable": true,
                      "current": true,
                      "reason": null
                    }
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/lifecycleETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "201": {
            "description": "The immutable resource or durable run was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppliedBindingMutationResponse"
                },
                "example": {
                  "success": true,
                  "replay": false,
                  "binding": {
                    "id": "retailOrderInvoice",
                    "name": "Retail order to invoice",
                    "status": "ACTIVE",
                    "revision": 0,
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "authoringContentSha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
                    "bindingContentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "environment": "production",
                    "referencedMappingIds": [
                      17
                    ],
                    "referencedPartnerIds": [
                      42
                    ],
                    "etag": "\"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"",
                    "appliedAt": "2026-08-24T18:05:00Z",
                    "appliedBy": {
                      "memberId": 17,
                      "email": "operator@example.com",
                      "role": "OPERATOR"
                    },
                    "activation": {
                      "kind": "scenario_graph_v1",
                      "runnable": true,
                      "current": true,
                      "reason": null
                    }
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/lifecycleETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyScenarioBindingRequest"
              },
              "example": {
                "file": {
                  "id": "order-invoice.binding.json",
                  "fileType": "SCENARIO_BINDING",
                  "source": "{\n  \"$schema\": \"https://www.modernedi.com/docs/scenarios/schemas/scenario-binding-v1.schema.json\",\n  \"apiVersion\": \"modernedi.com/scenario-binding-authoring/v1\",\n  \"kind\": \"ScenarioBinding\",\n  \"metadata\": {\n    \"id\": \"retailOrderInvoice\",\n    \"name\": \"Retail order to invoice\"\n  },\n  \"spec\": {\n    \"definition\": {\n      \"namespace\": \"acme\",\n      \"key\": \"retail-order-invoice\",\n      \"version\": \"1.0.0\",\n      \"contentSha256\": \"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\"\n    },\n    \"environment\": \"production\",\n    \"actors\": [\n      {\n        \"actorId\": \"retailer\",\n        \"endpoint\": {\n          \"kind\": \"partner\",\n          \"partnerId\": 42\n        }\n      },\n      {\n        \"actorId\": \"supplier\",\n        \"endpoint\": {\n          \"kind\": \"workspace\"\n        }\n      }\n    ],\n    \"steps\": [\n      {\n        \"stepId\": \"purchaseOrder\",\n        \"target\": {\n          \"kind\": \"runtime-mapping\",\n          \"runtimeMappingId\": 101\n        },\n        \"factSources\": [\n          {\n            \"fact\": \"purchaseOrderNumber\",\n            \"source\": {\n              \"kind\": \"x12-mapper-expression\",\n              \"expression\": \"ST->BEG(03)\"\n            }\n          }\n        ]\n      },\n      {\n        \"stepId\": \"invoice\",\n        \"syntaxTree\": {\n          \"x12Version\": \"004010\",\n          \"transactionSet\": \"810\"\n        },\n        \"target\": {\n          \"kind\": \"runtime-mapping\",\n          \"runtimeMappingId\": 102\n        },\n        \"factSources\": [\n          {\n            \"fact\": \"purchaseOrderNumber\",\n            \"source\": {\n              \"kind\": \"x12-mapper-expression\",\n              \"expression\": \"ST->BIG(04)\"\n            }\n          },\n          {\n            \"fact\": \"invoiceTotal\",\n            \"source\": {\n              \"kind\": \"x12-mapper-expression\",\n              \"expression\": \"ST->TDS(01)\"\n            }\n          }\n        ]\n      }\n    ]\n  }\n}\n"
                },
                "expectedContentSha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
                "expectedAuthorityEtag": "\"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\""
              }
            }
          }
        }
      }
    },
    "/x12mapper/workspace/expression/diagnostics": {
      "post": {
        "operationId": "validateScenarioMapperExpression",
        "tags": [
          "Tooling"
        ],
        "summary": "Validate one X12 Mapper fact-source expression",
        "description": "Returns tree-aware X12 Mapper diagnostics for exactly one value-returning expression. This is the fast editor/tooling check used while authoring a binding; scenario Validate remains authoritative for definition fact types, exact fact coverage, tenant artifacts, and Apply eligibility.",
        "security": [],
        "x-modernedi-permission": "Public and stateless; no tenant data",
        "x-modernedi-error-codes": [],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/X12MapperPublicResource.java#expressionDiagnostics",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MapperExpressionDiagnosticsResponse"
                },
                "example": {
                  "success": true,
                  "diagnostics": [
                    {
                      "range": {
                        "start": {
                          "line": 0,
                          "character": 0
                        },
                        "end": {
                          "line": 0,
                          "character": 19
                        }
                      },
                      "message": "Expected exactly one value-returning expression.",
                      "code": "E3001",
                      "severity": "ERROR"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/MapperToolingError400"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MapperExpressionDiagnosticsRequest"
              },
              "example": {
                "source": "ST->BEG(03)",
                "x12Version": "004010",
                "transactionSetId": "850"
              }
            }
          }
        }
      }
    },
    "/tenant/scenario-runs": {
      "get": {
        "operationId": "listScenarioRuns",
        "tags": [
          "Runs"
        ],
        "summary": "List recent scenario conversations",
        "description": "Returns a bounded tenant-scoped summary of recent runs for discovery and navigation without exposing fact values or evidence payloads.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "server_error"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#list",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum recent runs to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "example": 25
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque tenant-bound keyset cursor returned as nextCursor by the preceding page. Return it unchanged.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 1024,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "example": "eyJiZWZvcmVSdW5JZCI6InJ1bi01MDA3ZGJmMy1mMTE1LTRjYWMtODUzMC0xODhmYjQzMjZjNDUiLCJiZWZvcmVTdGFydGVkQXQiOiIyMDI2LTA4LTI0VDE4OjEwOjAwWiIsInRlbmFudElkIjo0MiwidiI6MX0"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunCollection"
                },
                "example": {
                  "apiVersion": "modernedi.com/scenario-platform/v1",
                  "kind": "scenario_run_collection",
                  "runs": [
                    {
                      "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                      "revision": 1,
                      "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\"",
                      "binding": {
                        "id": "retailOrderInvoice",
                        "revision": 0,
                        "name": "Retail order to invoice",
                        "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                      },
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "environment": "production",
                      "status": "active",
                      "outcome": "waiting",
                      "phase": "observing",
                      "startedAt": "2026-08-24T18:10:00Z",
                      "completedAt": null,
                      "lastUpdatedAt": "2026-08-24T18:12:00Z",
                      "guidance": {
                        "nextAction": "attach_or_refresh",
                        "stepId": null,
                        "occurrence": null
                      }
                    }
                  ],
                  "nextCursor": "eyJiZWZvcmVSdW5JZCI6InJ1bi01MDA3ZGJmMy1mMTE1LTRjYWMtODUzMC0xODhmYjQzMjZjNDUiLCJiZWZvcmVTdGFydGVkQXQiOiIyMDI2LTA4LTI0VDE4OjEwOjAwWiIsInRlbmFudElkIjo0MiwidiI6MX0"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        }
      },
      "post": {
        "operationId": "startScenarioRun",
        "tags": [
          "Runs"
        ],
        "summary": "Start a run from an exact applied binding",
        "description": "Starts a durable run from exact definition and binding hashes. Optional typed parameters are checked against the definition before any operation is accepted. Registered adapter targets prepare their current runtime dependencies before the run is inserted; temporary preparation failures are retryable and return Retry-After.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request",
          "scenario_environment_not_executable",
          "scenario_definition_changed",
          "scenario_preparation_unavailable",
          "scenario_binding_incomplete",
          "scenario_target_executor_unavailable",
          "idempotency_key_conflict",
          "scenario_binding_changed",
          "scenario_active_run_quota_exceeded",
          "scenario_start_rate_limited",
          "server_error"
        ],
        "x-modernedi-retryable-errors": [
          {
            "code": "scenario_start_rate_limited",
            "status": 429
          },
          {
            "code": "scenario_preparation_unavailable",
            "status": 503
          }
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#start",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required command identity. Replays require byte-equivalent normalized input.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "scenario-run-20260824-001"
          }
        ],
        "responses": {
          "201": {
            "description": "The immutable resource or durable run was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunCommandResponse"
                },
                "example": {
                  "success": true,
                  "operation": {
                    "id": "op-01K5QED4DP89F67V3MKRK9R5JM",
                    "action": "start",
                    "disposition": "started",
                    "fromRevision": 0,
                    "toRevision": 0
                  },
                  "run": {
                    "apiVersion": "modernedi.com/scenario-run-response/v1",
                    "kind": "graph",
                    "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                    "origin": "tenant_applied",
                    "binding": {
                      "id": "retailOrderInvoice",
                      "revision": 0,
                      "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                    },
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "environment": "production",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "execution": {
                      "kind": "scenario_graph_v1",
                      "runtimeVersion": "1.0.0",
                      "authorityContentSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                      "parametersContentSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
                    },
                    "status": "active",
                    "outcome": "waiting",
                    "phase": "observing",
                    "startedAt": "2026-08-24T18:10:00Z",
                    "completedAt": null,
                    "lastUpdatedAt": "2026-08-24T18:10:05Z",
                    "retry": {
                      "mode": "advance",
                      "reason": "Attach an authoritative transaction or advance the next adapter-controlled step.",
                      "requiresApiKey": false
                    },
                    "revision": 0,
                    "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:0\"",
                    "counts": {
                      "observations": 0,
                      "checkpoints": 0
                    },
                    "guidance": {
                      "nextAction": "attach_or_refresh",
                      "stepId": null,
                      "occurrence": null
                    },
                    "steps": [
                      {
                        "stepId": "purchaseOrder",
                        "fromActor": "retailer",
                        "toActor": "supplier",
                        "transactionSet": "850",
                        "direction": "incoming",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [],
                        "occurrences": []
                      },
                      {
                        "stepId": "invoice",
                        "fromActor": "supplier",
                        "toActor": "retailer",
                        "transactionSet": "810",
                        "direction": "outgoing",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [],
                        "occurrences": []
                      }
                    ],
                    "checks": [
                      {
                        "id": "step:purchaseOrder:occurrence",
                        "kind": "occurrence",
                        "outcome": "pending",
                        "code": "OCCURRENCE_PENDING",
                        "subjects": [],
                        "attributes": {
                          "minimum": "1",
                          "maximum": "1"
                        }
                      }
                    ]
                  }
                }
              }
            },
            "headers": {
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "ETag": {
                "$ref": "#/components/headers/runETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartScenarioRunRequest"
              },
              "example": {
                "definition": {
                  "namespace": "acme",
                  "key": "retail-order-invoice",
                  "version": "1.0.0",
                  "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                },
                "environment": "production",
                "binding": {
                  "id": "retailOrderInvoice",
                  "revision": 0,
                  "contentSha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
                },
                "parameters": {}
              }
            }
          }
        }
      }
    },
    "/tenant/implementation-verifications/test-partner-order-invoice/runs": {
      "post": {
        "operationId": "startManagedTestPartnerOrderInvoiceVerification",
        "tags": [
          "Runs"
        ],
        "summary": "Start the managed test-partner 850 to 810 verification",
        "description": "Starts the named ModernEDI-managed test-partner order/invoice flow without asking the caller to create or select a binding. This is a deliberate guided shortcut for the exact bundled 850 to 810 conversation; every resulting run still uses the same scenario evaluator as a custom run and can be inspected through the general run routes.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request",
          "scenario_definition_not_executable",
          "scenario_environment_not_executable",
          "scenario_preparation_unavailable",
          "scenario_binding_incomplete",
          "idempotency_key_conflict",
          "scenario_binding_changed",
          "scenario_active_run_quota_exceeded",
          "scenario_start_rate_limited",
          "server_error"
        ],
        "x-modernedi-retryable-errors": [
          {
            "code": "scenario_start_rate_limited",
            "status": 429
          },
          {
            "code": "scenario_preparation_unavailable",
            "status": 503
          }
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantTestPartnerOrderInvoiceVerificationResource.java#start",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required command identity. Replays require byte-equivalent normalized input.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "scenario-run-20260824-001"
          }
        ],
        "responses": {
          "201": {
            "description": "The immutable resource or durable run was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunCommandResponse"
                },
                "example": {
                  "success": true,
                  "operation": {
                    "id": "op-01K5QED4DP89F67V3MKRK9R5JM",
                    "action": "start",
                    "disposition": "started",
                    "fromRevision": 0,
                    "toRevision": 0
                  },
                  "run": {
                    "apiVersion": "modernedi.com/scenario-run-response/v1",
                    "kind": "graph",
                    "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                    "origin": "tenant_applied",
                    "binding": {
                      "id": "retailOrderInvoice",
                      "revision": 0,
                      "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                    },
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "environment": "production",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "execution": {
                      "kind": "scenario_graph_v1",
                      "runtimeVersion": "1.0.0",
                      "authorityContentSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                      "parametersContentSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
                    },
                    "status": "active",
                    "outcome": "waiting",
                    "phase": "observing",
                    "startedAt": "2026-08-24T18:10:00Z",
                    "completedAt": null,
                    "lastUpdatedAt": "2026-08-24T18:10:05Z",
                    "retry": {
                      "mode": "advance",
                      "reason": "Attach an authoritative transaction or advance the next adapter-controlled step.",
                      "requiresApiKey": false
                    },
                    "revision": 0,
                    "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:0\"",
                    "counts": {
                      "observations": 0,
                      "checkpoints": 0
                    },
                    "guidance": {
                      "nextAction": "attach_or_refresh",
                      "stepId": null,
                      "occurrence": null
                    },
                    "steps": [
                      {
                        "stepId": "purchaseOrder",
                        "fromActor": "retailer",
                        "toActor": "supplier",
                        "transactionSet": "850",
                        "direction": "incoming",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [],
                        "occurrences": []
                      },
                      {
                        "stepId": "invoice",
                        "fromActor": "supplier",
                        "toActor": "retailer",
                        "transactionSet": "810",
                        "direction": "outgoing",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [],
                        "occurrences": []
                      }
                    ],
                    "checks": [
                      {
                        "id": "step:purchaseOrder:occurrence",
                        "kind": "occurrence",
                        "outcome": "pending",
                        "code": "OCCURRENCE_PENDING",
                        "subjects": [],
                        "attributes": {
                          "minimum": "1",
                          "maximum": "1"
                        }
                      }
                    ]
                  }
                }
              }
            },
            "headers": {
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "ETag": {
                "$ref": "#/components/headers/runETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "429": {
            "$ref": "#/components/responses/Error429"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ManagedScenarioRunStartRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/tenant/test-as2-partner/warehouse-outbound/setup": {
      "post": {
        "operationId": "prepareManagedWarehouseOutboundProfile",
        "tags": [
          "Managed profiles"
        ],
        "summary": "Prepare the managed warehouse outbound test profile",
        "description": "Idempotently creates or refreshes the ModernEDI-owned test partner and managed X12 940 runtime mapping used by the warehouse outbound example. This prepares tenant-owned dependencies but does not publish a definition, apply a binding, or start a run. Validate and Apply an exact warehouse binding in Mapper, then start it through POST /tenant/scenario-runs.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantTestAs2PartnerResource.java#setupWarehouseOutbound",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WarehouseOutboundSetupResponse"
                },
                "example": {
                  "success": true,
                  "testOnly": true,
                  "configured": true,
                  "mappingAvailable": true,
                  "partnerId": 42,
                  "mappingId": 17,
                  "canSendShippingOrder": true,
                  "readyAfter": null
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/WarehouseOutboundSetupError400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WarehouseOutboundSetupRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/tenant/scenario-runs/{runId}": {
      "get": {
        "operationId": "getScenarioRun",
        "tags": [
          "Runs"
        ],
        "summary": "Read current scenario run state and evidence",
        "description": "Returns the current durable revision, evidence-bearing observations, checks, outcome, and strong ETag. Sensitive fact values are redacted from the public representation.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "scenario_run_not_found",
          "server_error"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#get",
        "parameters": [
          {
            "$ref": "#/components/parameters/runId"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunViewResponse"
                },
                "example": {
                  "success": true,
                  "run": {
                    "apiVersion": "modernedi.com/scenario-run-response/v1",
                    "kind": "graph",
                    "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                    "origin": "tenant_applied",
                    "binding": {
                      "id": "retailOrderInvoice",
                      "revision": 0,
                      "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                    },
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "environment": "production",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "execution": {
                      "kind": "scenario_graph_v1",
                      "runtimeVersion": "1.0.0",
                      "authorityContentSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                      "parametersContentSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
                    },
                    "status": "active",
                    "outcome": "waiting",
                    "phase": "observing",
                    "startedAt": "2026-08-24T18:10:00Z",
                    "completedAt": null,
                    "lastUpdatedAt": "2026-08-24T18:12:00Z",
                    "retry": {
                      "mode": "advance",
                      "reason": "Attach an authoritative transaction or advance the next adapter-controlled step.",
                      "requiresApiKey": false
                    },
                    "revision": 1,
                    "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\"",
                    "counts": {
                      "observations": 1,
                      "checkpoints": 0
                    },
                    "guidance": {
                      "nextAction": "attach_or_refresh",
                      "stepId": null,
                      "occurrence": null
                    },
                    "steps": [
                      {
                        "stepId": "purchaseOrder",
                        "fromActor": "retailer",
                        "toActor": "supplier",
                        "transactionSet": "850",
                        "direction": "incoming",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [
                          1
                        ],
                        "occurrences": [
                          {
                            "occurrence": 1,
                            "observedAt": "2026-08-24T18:12:00Z",
                            "messageId": "msg-01K5QED4DP89F67V3MKRK9R5JM",
                            "transactionKey": "tx-01K5QED4DP89F67V3MKRK9R5JM",
                            "replyToMessageId": null,
                            "replyToTransactionKey": null,
                            "direction": "incoming",
                            "partnerId": 42,
                            "transactionSet": "850",
                            "x12Version": "004010",
                            "mappingId": 101,
                            "assurances": {
                              "mapping_succeeded": "pending"
                            },
                            "evidence": [
                              {
                                "reference": "evidence-1111111111111111111111111111111111111111111111111111111111111111",
                                "kind": "transaction"
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "stepId": "invoice",
                        "fromActor": "supplier",
                        "toActor": "retailer",
                        "transactionSet": "810",
                        "direction": "outgoing",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [],
                        "occurrences": []
                      }
                    ],
                    "checks": [
                      {
                        "id": "assurance:purchaseOrder:1:mapping_succeeded",
                        "kind": "assurance",
                        "outcome": "pending",
                        "code": "ASSURANCE_PENDING",
                        "subjects": [
                          {
                            "stepId": "purchaseOrder",
                            "occurrence": 1,
                            "fact": null,
                            "sensitivity": null,
                            "redacted": false,
                            "evidenceReferences": [
                              "evidence-1111111111111111111111111111111111111111111111111111111111111111"
                            ]
                          }
                        ],
                        "attributes": {
                          "assurance": "mapping_succeeded"
                        }
                      }
                    ]
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/runETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        }
      }
    },
    "/tenant/scenario-runs/{runId}/timeline": {
      "get": {
        "operationId": "getScenarioRunTimeline",
        "tags": [
          "Runs"
        ],
        "summary": "Read the actor-attributed operation timeline for a run",
        "description": "Returns a bounded, newest-first audit timeline without idempotency hashes, attempt tokens, transient credentials, or operation result payloads. The cursor is opaque and bound to both the tenant and run.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "scenario_run_not_found",
          "server_error"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#timeline",
        "parameters": [
          {
            "$ref": "#/components/parameters/runId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum operations to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "example": 25
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque tenant-and-run-bound keyset cursor returned as nextCursor by the preceding page. Return it unchanged.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 1024,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "example": "eyJiZWZvcmVPcGVyYXRpb25JZCI6Im9wLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NSIsImJlZm9yZVJlcXVlc3RlZEF0IjoiMjAyNi0wOC0yNFQxODoxMDowMFoiLCJydW5JZCI6InJ1bi01MDA3ZGJmMy1mMTE1LTRjYWMtODUzMC0xODhmYjQzMjZjNDUiLCJ0ZW5hbnRJZCI6NDIsInYiOjF9"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunTimelineResponse"
                },
                "example": {
                  "success": true,
                  "runId": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                  "operations": [
                    {
                      "operationId": "op-01K5QG8KTRV0JB4FQ3G0A3P6CY",
                      "action": "attach_transaction",
                      "status": "succeeded",
                      "expectedRunRevision": 0,
                      "actor": {
                        "memberId": 17,
                        "email": "operator@example.com",
                        "role": "OPERATOR"
                      },
                      "attempts": 1,
                      "requestedAt": "2026-08-24T18:11:59Z",
                      "startedAt": "2026-08-24T18:11:59Z",
                      "completedAt": "2026-08-24T18:12:00Z",
                      "lastUpdatedAt": "2026-08-24T18:12:00Z",
                      "error": null
                    }
                  ],
                  "nextCursor": null
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        }
      }
    },
    "/tenant/scenario-runs/{runId}/evidence-report": {
      "get": {
        "operationId": "downloadScenarioEvidenceReport",
        "tags": [
          "Evidence"
        ],
        "summary": "Download the immutable evidence report for a terminal run",
        "description": "Creates the report once from terminal durable state and thereafter returns the exact persisted canonical JSON. It records the frozen authority and redacted evidence needed to substantiate the bounded implementation-verification claim; it is not editable scenario source, raw X12, or a compliance certificate. Stable failure codes are included, while detailed failure messages remain in the run timeline so the credential-free proof stays within its fixed export bound. If a retry creates another audit record for the same successful state change, the report counts that change once and keeps its earliest record; the timeline still shows every attempt.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "scenario_run_not_found",
          "scenario_run_not_terminal",
          "scenario_evidence_report_too_large",
          "server_error"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#evidenceReport",
        "parameters": [
          {
            "$ref": "#/components/parameters/runId"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioEvidenceReport"
                },
                "example": {
                  "apiVersion": "modernedi.com/scenario-evidence-report/v1",
                  "createdAt": "2026-09-24T18:12:02Z",
                  "claim": {
                    "type": "implementation_verification",
                    "statement": "ModernEDI observed and evaluated this scenario run against the exact applied binding recorded in this report.",
                    "scope": "This report proves only the recorded run; it does not certify the tenant's broader EDI implementation."
                  },
                  "run": {
                    "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                    "status": "completed",
                    "outcome": "failed",
                    "phase": "complete",
                    "revision": 2,
                    "environment": "production",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "binding": {
                      "id": "retailOrderInvoice",
                      "revision": 0
                    },
                    "startedBy": {
                      "memberId": 17,
                      "email": "operator@example.com",
                      "role": "OPERATOR"
                    },
                    "startedAt": "2026-08-24T18:10:00Z",
                    "completedAt": "2026-09-24T18:12:01Z",
                    "lastUpdatedAt": "2026-09-24T18:12:01Z"
                  },
                  "binding": {
                    "id": "retailOrderInvoice",
                    "revision": 0,
                    "name": "Retail order to invoice",
                    "snapshotContentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
                    "definitionContentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "environment": "production",
                    "authority": {
                      "partners": [
                        {
                          "actorId": "retailer",
                          "id": 42,
                          "configurationSha256": "1111111111111111111111111111111111111111111111111111111111111111"
                        }
                      ],
                      "mappings": [
                        {
                          "stepId": "purchaseOrder",
                          "id": 101,
                          "partnerId": 42,
                          "direction": "incoming",
                          "x12Version": "004010",
                          "transactionSet": "850",
                          "configurationEtag": "\"2222222222222222222222222222222222222222222222222222222222222222\"",
                          "mapFileSha256Hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
                        }
                      ],
                      "syntaxTrees": [
                        {
                          "stepId": "purchaseOrder",
                          "x12Version": "004010",
                          "transactionSet": "850",
                          "catalogRevision": "3333333333333333333333333333333333333333333333333333333333333333",
                          "catalogManifestSha256": "4444444444444444444444444444444444444444444444444444444444444444",
                          "syntaxTreeSha256": "5555555555555555555555555555555555555555555555555555555555555555"
                        },
                        {
                          "stepId": "invoice",
                          "x12Version": "004010",
                          "transactionSet": "810",
                          "catalogRevision": "3333333333333333333333333333333333333333333333333333333333333333",
                          "catalogManifestSha256": "4444444444444444444444444444444444444444444444444444444444444444",
                          "syntaxTreeSha256": "5555555555555555555555555555555555555555555555555555555555555555"
                        }
                      ],
                      "targets": [
                        {
                          "stepId": "purchaseOrder",
                          "kind": "runtime_mapping",
                          "adapterId": null,
                          "mappingId": 101
                        },
                        {
                          "stepId": "invoice",
                          "kind": "runtime_mapping",
                          "adapterId": null,
                          "mappingId": 102
                        }
                      ]
                    }
                  },
                  "operations": {
                    "total": 2,
                    "succeeded": 2,
                    "failed": 0,
                    "successfulTransitions": [
                      {
                        "operationId": "op-01K5QED4DP89F67V3MKRK9R5JM",
                        "action": "start",
                        "disposition": "started",
                        "fromRevision": 0,
                        "toRevision": 0,
                        "actor": {
                          "memberId": 17,
                          "email": "operator@example.com",
                          "role": "OPERATOR"
                        },
                        "requestedAt": "2026-08-24T18:10:00Z",
                        "completedAt": "2026-08-24T18:10:00Z"
                      },
                      {
                        "operationId": "op-01K5QF8E2Q5H8X6P9T3R7C4V1Z",
                        "action": "reevaluate_graph_clock",
                        "disposition": "advanced",
                        "fromRevision": 1,
                        "toRevision": 2,
                        "actor": {
                          "memberId": 17,
                          "email": "operator@example.com",
                          "role": "OPERATOR"
                        },
                        "requestedAt": "2026-09-24T18:12:00Z",
                        "completedAt": "2026-09-24T18:12:01Z"
                      }
                    ],
                    "failures": []
                  },
                  "evidence": {
                    "kind": "graph",
                    "counts": {
                      "observations": 1,
                      "checkpoints": 0
                    },
                    "steps": [
                      {
                        "stepId": "purchaseOrder",
                        "fromActor": "retailer",
                        "toActor": "supplier",
                        "transactionSet": "850",
                        "direction": "incoming",
                        "targetKind": "runtime_mapping",
                        "occurrences": [
                          {
                            "occurrence": 1,
                            "observedAt": "2026-08-24T18:12:00Z",
                            "messageId": "msg-01K5QED4DP89F67V3MKRK9R5JM",
                            "transactionKey": "tx-01K5QED4DP89F67V3MKRK9R5JM",
                            "partnerId": 42,
                            "mappingId": 101
                          }
                        ]
                      }
                    ],
                    "checks": [
                      {
                        "id": "transition:invoiceSettlesOrder",
                        "kind": "transition",
                        "outcome": "failed",
                        "code": "TRANSITION_WINDOW_EXPIRED",
                        "subjects": [],
                        "attributes": {
                          "within": "P30D"
                        },
                        "evidenceDigests": []
                      }
                    ],
                    "references": [
                      {
                        "reference": "evidence-1111111111111111111111111111111111111111111111111111111111111111",
                        "kind": "transaction"
                      }
                    ]
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/evidenceETag"
              },
              "X-Content-Sha256": {
                "$ref": "#/components/headers/XContentSha256"
              },
              "Content-Disposition": {
                "$ref": "#/components/headers/ContentDisposition"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        }
      }
    },
    "/tenant/scenario-runs/{runId}/cancel": {
      "post": {
        "operationId": "cancelScenarioRun",
        "tags": [
          "Runs"
        ],
        "summary": "Cancel an active scenario run",
        "description": "Records an actor-attributed operator cancellation as an inconclusive terminal result while preserving all evidence already gathered. Cancellation is optimistic-concurrency controlled and idempotent, and it does not interrupt a command that still owns the run. If a command stops without saving a result and its temporary ownership period expires, ModernEDI records that attempt as failed and claims cancellation as one durable change. If the abandoned command may already have affected an external system, its failed timeline entry remains available for manual reconciliation. Each run can store at most 256 command records. The initial start and all later ordinary commands share 253 records; the remaining three are held for one retry record, cancellation, and a retry of cancellation. Result documents for ordinary commands share a 32 MiB budget, with additional space held for those same three reserved records.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request",
          "precondition_required",
          "etag_mismatch",
          "scenario_run_not_found",
          "scenario_run_terminal",
          "idempotency_key_conflict",
          "scenario_operation_in_progress",
          "scenario_run_operation_limit_exceeded",
          "scenario_run_result_bytes_limit_exceeded",
          "scenario_operation_ownership_lost",
          "server_error"
        ],
        "x-modernedi-retryable-errors": [
          {
            "code": "scenario_operation_in_progress",
            "status": 409
          },
          {
            "code": "scenario_operation_ownership_lost",
            "status": 409
          }
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#cancel",
        "parameters": [
          {
            "$ref": "#/components/parameters/runId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required command identity. Replays require byte-equivalent normalized input.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "scenario-run-20260824-001"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Current strong run-revision ETag returned in the run body or ETag response header.",
            "schema": {
              "$ref": "#/components/schemas/ScenarioRunEtag"
            },
            "example": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\""
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunCommandResponse"
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/runETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelScenarioRunRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/tenant/scenario-runs/{runId}/advance": {
      "post": {
        "operationId": "advanceScenarioRun",
        "tags": [
          "Runs"
        ],
        "summary": "Advance adapter work or reevaluate graph deadlines",
        "description": "When runtime guidance selects a server-controlled step, this command dispatches or reconciles that step. Before external dispatch, ModernEDI prepares the current runtime dependencies and reconfirms the managed adapter target against the run's frozen binding authority. A temporary preparation outage is retryable and may return Retry-After; an incomplete or changed binding, or an unavailable target executor, rejects the command before dispatch. A failed adapter or preparation advance is durable: retry it with the current run ETag and a fresh Idempotency-Key. Reusing the failed operation's Idempotency-Key is a pure replay and never attempts preparation or dispatch again. Transient downstream rejections use scenario_adapter_dispatch_retryable; when the supplied x-api-key must be corrected they use scenario_adapter_dispatch_api_key_correction_required. The selected step and occurrence stay in structured run guidance instead of changing the stable error code. Observation-only and runtime-mapping steps still advance through the observation operation. For a waiting scenario run, the same empty-body command can safely ask the evaluator to recheck elapsed time: before every declared transition window and evidence deadline expires it returns HTTP 409 with scenario_observation_required, creates no operation, and leaves the run revision and ETag unchanged; once durable evidence reevaluation reaches a terminal outcome, it atomically persists a reevaluate_graph_clock operation and the completed run. The reevaluate_graph_clock value is the stable operation action recorded for this time-based reevaluation; it does not name another API. This time reevaluation never accepts x-api-key. The command rejects a stale ETag (optimistic concurrency), and replaying the same Idempotency-Key safely returns the original result (idempotency). x-api-key, when required by a selected adapter, is a transient Integration API credential used for that adapter operation only; it is not Workspace API authentication and is never persisted.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request",
          "precondition_required",
          "etag_mismatch",
          "scenario_run_not_found",
          "scenario_run_terminal",
          "scenario_adapter_dispatch_response_invalid",
          "scenario_adapter_dispatch_unavailable",
          "scenario_adapter_not_ready",
          "scenario_adapter_reply_ambiguous",
          "scenario_adapter_transaction_ambiguous",
          "scenario_binding_changed",
          "scenario_binding_incomplete",
          "scenario_observation_required",
          "scenario_predecessor_fact_not_ready",
          "scenario_predecessor_observation_required",
          "scenario_preparation_unavailable",
          "scenario_target_executor_unavailable",
          "scenario_target_not_adapter",
          "scenario_target_occurrence_unavailable",
          "scenario_target_partner_authority_invalid",
          "scenario_target_step_unavailable",
          "scenario_adapter_dispatch_api_key_correction_required",
          "scenario_adapter_dispatch_retryable",
          "idempotency_key_conflict",
          "scenario_operation_in_progress",
          "scenario_run_operation_limit_exceeded",
          "scenario_run_result_bytes_limit_exceeded",
          "scenario_operation_ownership_lost",
          "integration_api_key_required",
          "integration_api_key_not_allowed",
          "server_error"
        ],
        "x-modernedi-retryable-errors": [
          {
            "code": "scenario_adapter_not_ready",
            "status": 409
          },
          {
            "code": "scenario_predecessor_fact_not_ready",
            "status": 409
          },
          {
            "code": "scenario_predecessor_observation_required",
            "status": 409
          },
          {
            "code": "scenario_preparation_unavailable",
            "status": 503
          },
          {
            "code": "scenario_adapter_dispatch_api_key_correction_required",
            "status": 409
          },
          {
            "code": "scenario_adapter_dispatch_retryable",
            "status": 409
          },
          {
            "code": "scenario_operation_in_progress",
            "status": 409
          },
          {
            "code": "scenario_operation_ownership_lost",
            "status": 409
          }
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#advance",
        "parameters": [
          {
            "$ref": "#/components/parameters/runId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required command identity. Replays require byte-equivalent normalized input.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "scenario-run-20260824-001"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Current strong run-revision ETag returned in the run body or ETag response header.",
            "schema": {
              "$ref": "#/components/schemas/ScenarioRunEtag"
            },
            "example": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\""
          },
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "description": "Optional transient Integration API credential accepted only by a selected managed runtime target during advance. It does not authenticate this Workspace API request and is not persisted.",
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "transient-integration-api-key"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunCommandResponse"
                },
                "examples": {
                  "adapterStep": {
                    "value": {
                      "success": true,
                      "operation": {
                        "id": "op-01K5QF4VY2GWB3A6AW09M0F42T",
                        "action": "graph_dispatch_001_000001",
                        "disposition": "advanced",
                        "fromRevision": 0,
                        "toRevision": 1
                      },
                      "run": {
                        "apiVersion": "modernedi.com/scenario-run-response/v1",
                        "kind": "graph",
                        "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                        "origin": "tenant_applied",
                        "binding": {
                          "id": "retailOrderInvoice",
                          "revision": 0,
                          "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                        },
                        "definition": {
                          "namespace": "acme",
                          "key": "retail-order-invoice",
                          "version": "1.0.0",
                          "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                        },
                        "environment": "production",
                        "adapterId": "scenario-graph-interpreter-v1",
                        "execution": {
                          "kind": "scenario_graph_v1",
                          "runtimeVersion": "1.0.0",
                          "authorityContentSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                          "parametersContentSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
                        },
                        "status": "active",
                        "outcome": "waiting",
                        "phase": "observing",
                        "startedAt": "2026-08-24T18:10:00Z",
                        "completedAt": null,
                        "lastUpdatedAt": "2026-08-24T18:12:00Z",
                        "retry": {
                          "mode": "advance",
                          "reason": "Attach an authoritative transaction or advance the next adapter-controlled step.",
                          "requiresApiKey": false
                        },
                        "revision": 1,
                        "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\"",
                        "counts": {
                          "observations": 1,
                          "checkpoints": 0
                        },
                        "guidance": {
                          "nextAction": "attach_or_refresh",
                          "stepId": null,
                          "occurrence": null
                        },
                        "steps": [
                          {
                            "stepId": "purchaseOrder",
                            "fromActor": "retailer",
                            "toActor": "supplier",
                            "transactionSet": "850",
                            "direction": "incoming",
                            "targetKind": "runtime_mapping",
                            "attachable": true,
                            "occurrence": {
                              "min": 1,
                              "max": 1
                            },
                            "observedOccurrences": [
                              1
                            ],
                            "occurrences": [
                              {
                                "occurrence": 1,
                                "observedAt": "2026-08-24T18:12:00Z",
                                "messageId": "msg-01K5QED4DP89F67V3MKRK9R5JM",
                                "transactionKey": "tx-01K5QED4DP89F67V3MKRK9R5JM",
                                "replyToMessageId": null,
                                "replyToTransactionKey": null,
                                "direction": "incoming",
                                "partnerId": 42,
                                "transactionSet": "850",
                                "x12Version": "004010",
                                "mappingId": 101,
                                "assurances": {
                                  "mapping_succeeded": "pending"
                                },
                                "evidence": [
                                  {
                                    "reference": "evidence-1111111111111111111111111111111111111111111111111111111111111111",
                                    "kind": "transaction"
                                  }
                                ]
                              }
                            ]
                          },
                          {
                            "stepId": "invoice",
                            "fromActor": "supplier",
                            "toActor": "retailer",
                            "transactionSet": "810",
                            "direction": "outgoing",
                            "targetKind": "runtime_mapping",
                            "attachable": true,
                            "occurrence": {
                              "min": 1,
                              "max": 1
                            },
                            "observedOccurrences": [],
                            "occurrences": []
                          }
                        ],
                        "checks": [
                          {
                            "id": "assurance:purchaseOrder:1:mapping_succeeded",
                            "kind": "assurance",
                            "outcome": "pending",
                            "code": "ASSURANCE_PENDING",
                            "subjects": [
                              {
                                "stepId": "purchaseOrder",
                                "occurrence": 1,
                                "fact": null,
                                "sensitivity": null,
                                "redacted": false,
                                "evidenceReferences": [
                                  "evidence-1111111111111111111111111111111111111111111111111111111111111111"
                                ]
                              }
                            ],
                            "attributes": {
                              "assurance": "mapping_succeeded"
                            }
                          }
                        ]
                      }
                    }
                  },
                  "expiredGraphClock": {
                    "value": {
                      "success": true,
                      "operation": {
                        "id": "op-01K5QF8E2Q5H8X6P9T3R7C4V1Z",
                        "action": "reevaluate_graph_clock",
                        "disposition": "advanced",
                        "fromRevision": 1,
                        "toRevision": 2
                      },
                      "run": {
                        "apiVersion": "modernedi.com/scenario-run-response/v1",
                        "kind": "graph",
                        "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                        "origin": "tenant_applied",
                        "binding": {
                          "id": "retailOrderInvoice",
                          "revision": 0,
                          "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                        },
                        "definition": {
                          "namespace": "acme",
                          "key": "retail-order-invoice",
                          "version": "1.0.0",
                          "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                        },
                        "environment": "production",
                        "adapterId": "scenario-graph-interpreter-v1",
                        "execution": {
                          "kind": "scenario_graph_v1",
                          "runtimeVersion": "1.0.0",
                          "authorityContentSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                          "parametersContentSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
                        },
                        "status": "completed",
                        "outcome": "failed",
                        "phase": "complete",
                        "startedAt": "2026-08-24T18:10:00Z",
                        "completedAt": "2026-09-24T18:12:01Z",
                        "lastUpdatedAt": "2026-09-24T18:12:01Z",
                        "retry": {
                          "mode": "terminal",
                          "reason": "A declared transition window expired.",
                          "requiresApiKey": false
                        },
                        "revision": 2,
                        "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:2\"",
                        "counts": {
                          "observations": 1,
                          "checkpoints": 0
                        },
                        "guidance": {
                          "nextAction": null,
                          "stepId": null,
                          "occurrence": null
                        },
                        "steps": [
                          {
                            "stepId": "purchaseOrder",
                            "fromActor": "retailer",
                            "toActor": "supplier",
                            "transactionSet": "850",
                            "direction": "incoming",
                            "targetKind": "runtime_mapping",
                            "attachable": true,
                            "occurrence": {
                              "min": 1,
                              "max": 1
                            },
                            "observedOccurrences": [
                              1
                            ],
                            "occurrences": [
                              {
                                "occurrence": 1,
                                "observedAt": "2026-08-24T18:12:00Z",
                                "messageId": "msg-01K5QED4DP89F67V3MKRK9R5JM",
                                "transactionKey": "tx-01K5QED4DP89F67V3MKRK9R5JM",
                                "replyToMessageId": null,
                                "replyToTransactionKey": null,
                                "direction": "incoming",
                                "partnerId": 42,
                                "transactionSet": "850",
                                "x12Version": "004010",
                                "mappingId": 101,
                                "assurances": {
                                  "mapping_succeeded": "pending"
                                },
                                "evidence": [
                                  {
                                    "reference": "evidence-1111111111111111111111111111111111111111111111111111111111111111",
                                    "kind": "transaction"
                                  }
                                ]
                              }
                            ]
                          },
                          {
                            "stepId": "invoice",
                            "fromActor": "supplier",
                            "toActor": "retailer",
                            "transactionSet": "810",
                            "direction": "outgoing",
                            "targetKind": "runtime_mapping",
                            "attachable": true,
                            "occurrence": {
                              "min": 1,
                              "max": 1
                            },
                            "observedOccurrences": [],
                            "occurrences": []
                          }
                        ],
                        "checks": [
                          {
                            "id": "transition:invoiceSettlesOrder",
                            "kind": "transition",
                            "outcome": "failed",
                            "code": "TRANSITION_WINDOW_EXPIRED",
                            "subjects": [],
                            "attributes": {
                              "fromStep": "purchaseOrder",
                              "matchedPairCount": "0",
                              "pendingPairCount": "0",
                              "recordedInitialCount": "0",
                              "relationship": "follows",
                              "strategy": "correlate",
                              "toStep": "invoice",
                              "unmatchedFromCount": "1",
                              "unmatchedPolicy": "fail",
                              "unmatchedToCount": "0",
                              "within": "P30D"
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/runETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdvanceScenarioRunRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/tenant/scenario-runs/{runId}/observations": {
      "post": {
        "operationId": "attachScenarioRunObservation",
        "tags": [
          "Runs"
        ],
        "summary": "Attach or refresh a persisted transaction observation",
        "description": "Attaches one exact tenant-visible ModernEDI transaction to an attachable runtime-mapping or observation-only occurrence. The body identifies persisted transaction metadata; raw X12 is never accepted. The transaction must carry the exact partner-configuration fingerprint frozen into the applied binding; legacy or mismatched transactions are ineligible, while acknowledgments and receipts produced under a different configuration remain pending. Repeating the same slot and transaction with the current ETag and a new Idempotency-Key re-reads trusted transaction detail, refreshes pending mapping or acknowledgment evidence, and reevaluates the graph atomically. Reusing the original key is a pure replay and does not refresh evidence. Adapter-controlled steps reject client attachment. Mapper-derived facts use ordinary X12 Mapper semantics, with dynamic durability limits enforced before SQL persistence: collections contain at most 1000 scalar values; text scalars contain at most 4096 UTF-8 bytes; one canonical typed value contains at most 32768 bytes; and one observation's facts JSON contains at most 262144 bytes. A fact provenance receipt contains at most 4096 bytes. Each evidence document contains at most 8192 bytes, with at most 8 non-fact evidence documents and 524288 bytes of aggregate evidence JSON per observation. Capacity failures use fact_value_limit_exceeded, transaction_observation_capacity_exceeded, transaction_fact_evidence_capacity_exceeded, or transaction_evidence_capacity_exceeded. fact_evaluation_timeout and fact_evaluation_busy_or_limited return HTTP 409 with retryable=true and operationStatus=failed; reload the run if needed, then retry with its current ETag and a fresh Idempotency-Key to re-read trusted transaction evidence.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "OPERATE",
        "x-modernedi-error-codes": [
          "invalid_request",
          "precondition_required",
          "etag_mismatch",
          "scenario_run_not_found",
          "scenario_run_terminal",
          "observation_step_not_bound",
          "observation_target_controlled",
          "observation_occurrence_out_of_range",
          "scenario_observation_identity_conflict",
          "scenario_checkpoint_conflict",
          "scenario_observation_attempt_expired",
          "transaction_not_found",
          "transaction_messageid_mismatch",
          "transaction_transactionkey_mismatch",
          "transaction_transaction_set_mismatch",
          "transaction_x12_syntax_tree_version_mismatch",
          "transaction_partner_mismatch",
          "transaction_partner_configuration_mismatch",
          "transaction_mapping_mismatch",
          "transaction_timestamp_in_future",
          "transaction_timestamp_invalid",
          "transaction_direction_invalid",
          "transaction_direction_mismatch",
          "transaction_acknowledgment_timestamp_missing",
          "binding_fact_source_missing",
          "binding_route_not_observable",
          "transaction_fact_extraction_failed",
          "fact_evaluation_timeout",
          "fact_evaluation_busy_or_limited",
          "transaction_observation_capacity_exceeded",
          "transaction_fact_evidence_missing",
          "transaction_fact_evidence_inconsistent",
          "transaction_fact_evidence_capacity_exceeded",
          "transaction_evidence_capacity_exceeded",
          "fact_value_limit_exceeded",
          "transaction_observation_unavailable",
          "idempotency_key_conflict",
          "scenario_operation_in_progress",
          "scenario_run_operation_limit_exceeded",
          "scenario_run_result_bytes_limit_exceeded",
          "scenario_operation_ownership_lost",
          "scenario_observation_unavailable",
          "scenario_observation_failed",
          "scenario_observation_completion_failed",
          "scenario_run_revision_changed",
          "scenario_binding_changed",
          "server_error"
        ],
        "x-modernedi-retryable-errors": [
          {
            "code": "fact_evaluation_timeout",
            "status": 409
          },
          {
            "code": "fact_evaluation_busy_or_limited",
            "status": 409
          },
          {
            "code": "scenario_operation_in_progress",
            "status": 409
          },
          {
            "code": "scenario_operation_ownership_lost",
            "status": 409
          },
          {
            "code": "scenario_observation_unavailable",
            "status": 503
          },
          {
            "code": "server_error",
            "status": 500
          }
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioRunResource.java#attachObservation",
        "parameters": [
          {
            "$ref": "#/components/parameters/runId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required command identity. Replays require byte-equivalent normalized input.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "scenario-run-20260824-001"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Current strong run-revision ETag returned in the run body or ETag response header.",
            "schema": {
              "$ref": "#/components/schemas/ScenarioRunEtag"
            },
            "example": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\""
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRunCommandResponse"
                },
                "example": {
                  "success": true,
                  "operation": {
                    "id": "op-01K5QG8KTRV0JB4FQ3G0A3P6CY",
                    "action": "attach_transaction",
                    "disposition": "advanced",
                    "fromRevision": 0,
                    "toRevision": 1
                  },
                  "run": {
                    "apiVersion": "modernedi.com/scenario-run-response/v1",
                    "kind": "graph",
                    "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                    "origin": "tenant_applied",
                    "binding": {
                      "id": "retailOrderInvoice",
                      "revision": 0,
                      "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                    },
                    "definition": {
                      "namespace": "acme",
                      "key": "retail-order-invoice",
                      "version": "1.0.0",
                      "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    },
                    "environment": "production",
                    "adapterId": "scenario-graph-interpreter-v1",
                    "execution": {
                      "kind": "scenario_graph_v1",
                      "runtimeVersion": "1.0.0",
                      "authorityContentSha256": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                      "parametersContentSha256": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
                    },
                    "status": "active",
                    "outcome": "waiting",
                    "phase": "observing",
                    "startedAt": "2026-08-24T18:10:00Z",
                    "completedAt": null,
                    "lastUpdatedAt": "2026-08-24T18:12:00Z",
                    "retry": {
                      "mode": "advance",
                      "reason": "Attach an authoritative transaction or advance the next adapter-controlled step.",
                      "requiresApiKey": false
                    },
                    "revision": 1,
                    "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\"",
                    "counts": {
                      "observations": 1,
                      "checkpoints": 0
                    },
                    "guidance": {
                      "nextAction": "attach_or_refresh",
                      "stepId": null,
                      "occurrence": null
                    },
                    "steps": [
                      {
                        "stepId": "purchaseOrder",
                        "fromActor": "retailer",
                        "toActor": "supplier",
                        "transactionSet": "850",
                        "direction": "incoming",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [
                          1
                        ],
                        "occurrences": [
                          {
                            "occurrence": 1,
                            "observedAt": "2026-08-24T18:12:00Z",
                            "messageId": "msg-01K5QED4DP89F67V3MKRK9R5JM",
                            "transactionKey": "tx-01K5QED4DP89F67V3MKRK9R5JM",
                            "replyToMessageId": null,
                            "replyToTransactionKey": null,
                            "direction": "incoming",
                            "partnerId": 42,
                            "transactionSet": "850",
                            "x12Version": "004010",
                            "mappingId": 101,
                            "assurances": {
                              "mapping_succeeded": "pending"
                            },
                            "evidence": [
                              {
                                "reference": "evidence-1111111111111111111111111111111111111111111111111111111111111111",
                                "kind": "transaction"
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "stepId": "invoice",
                        "fromActor": "supplier",
                        "toActor": "retailer",
                        "transactionSet": "810",
                        "direction": "outgoing",
                        "targetKind": "runtime_mapping",
                        "attachable": true,
                        "occurrence": {
                          "min": 1,
                          "max": 1
                        },
                        "observedOccurrences": [],
                        "occurrences": []
                      }
                    ],
                    "checks": [
                      {
                        "id": "assurance:purchaseOrder:1:mapping_succeeded",
                        "kind": "assurance",
                        "outcome": "pending",
                        "code": "ASSURANCE_PENDING",
                        "subjects": [
                          {
                            "stepId": "purchaseOrder",
                            "occurrence": 1,
                            "fact": null,
                            "sensitivity": null,
                            "redacted": false,
                            "evidenceReferences": [
                              "evidence-1111111111111111111111111111111111111111111111111111111111111111"
                            ]
                          }
                        ],
                        "attributes": {
                          "assurance": "mapping_succeeded"
                        }
                      }
                    ]
                  }
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/runETag"
              },
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "409": {
            "$ref": "#/components/responses/ObservationError409"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/ObservationError503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScenarioRunObservationRequest"
              },
              "example": {
                "stepId": "purchaseOrder",
                "occurrence": 1,
                "messageId": "msg-01K5QED4DP89F67V3MKRK9R5JM",
                "transactionKey": "tx-01K5QED4DP89F67V3MKRK9R5JM"
              }
            }
          }
        }
      }
    },
    "/tenant/scenario-context/transactions/{messageId}/{transactionKey}": {
      "get": {
        "operationId": "getScenarioTransactionContext",
        "tags": [
          "Context"
        ],
        "summary": "Read scenario membership and eligible occurrences for one transaction",
        "description": "Projects existing run membership and currently attachable occurrences by matching the tenant-visible persisted transaction against the exact frozen partner, direction, X12 release, transaction set, and runtime mapping authority. This read never performs fact extraction or changes a run.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "scenario_transaction_not_found",
          "server_error"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioContextResource.java#transaction",
        "parameters": [
          {
            "$ref": "#/components/parameters/messageId"
          },
          {
            "$ref": "#/components/parameters/transactionKey"
          },
          {
            "name": "environment",
            "in": "query",
            "required": false,
            "description": "Scenario v1 transaction environment.",
            "schema": {
              "const": "production",
              "default": "production"
            },
            "example": "production"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioTransactionContext"
                },
                "example": {
                  "apiVersion": "modernedi.com/scenario-context/v1",
                  "kind": "scenario_transaction_context",
                  "subject": {
                    "environment": "production",
                    "messageId": "msg-01K5QED4DP89F67V3MKRK9R5JM",
                    "transactionKey": "tx-01K5QED4DP89F67V3MKRK9R5JM"
                  },
                  "memberships": [
                    {
                      "run": {
                        "id": "run-5007dbf3-f115-4cac-8530-188fb4326c45",
                        "revision": 1,
                        "etag": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\"",
                        "status": "active",
                        "outcome": "waiting",
                        "phase": "observing",
                        "lastUpdatedAt": "2026-08-24T18:12:00Z"
                      },
                      "binding": {
                        "id": "retailOrderInvoice",
                        "revision": 0,
                        "name": "Retail order to invoice",
                        "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                      },
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "step": {
                        "id": "purchaseOrder",
                        "direction": "incoming",
                        "transactionSet": "850",
                        "x12Version": "004010",
                        "partnerId": 42,
                        "mappingId": 101,
                        "targetKind": "runtime_mapping"
                      },
                      "occurrence": 1,
                      "observedAt": "2026-08-24T18:12:00Z"
                    }
                  ],
                  "candidates": [
                    {
                      "run": {
                        "id": "run-6007dbf3-f115-4cac-8530-188fb4326c45",
                        "revision": 0,
                        "etag": "\"scenario-run:v1:42:cnVuLTYwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:0\"",
                        "status": "active",
                        "outcome": "waiting",
                        "phase": "observing",
                        "lastUpdatedAt": "2026-08-24T18:15:00Z"
                      },
                      "binding": {
                        "id": "retailOrderInvoice",
                        "revision": 0,
                        "name": "Retail order to invoice",
                        "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                      },
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "step": {
                        "id": "purchaseOrder",
                        "direction": "incoming",
                        "transactionSet": "850",
                        "x12Version": "004010",
                        "partnerId": 42,
                        "mappingId": 101,
                        "targetKind": "runtime_mapping"
                      },
                      "occurrence": 1
                    }
                  ],
                  "truncated": false
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        }
      }
    },
    "/tenant/scenario-context/partners/{partnerId}": {
      "get": {
        "operationId": "getScenarioPartnerContext",
        "tags": [
          "Context"
        ],
        "summary": "Read scenario dependencies and expected documents for one partner",
        "description": "Shows every active applied binding step that freezes this partner, including non-current activation state, plus currently eligible open occurrences for active scenario runs.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "server_error"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioContextResource.java#partner",
        "parameters": [
          {
            "$ref": "#/components/parameters/partnerId"
          },
          {
            "name": "environment",
            "in": "query",
            "required": false,
            "description": "Scenario v1 environment.",
            "schema": {
              "const": "production",
              "default": "production"
            },
            "example": "production"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioPartnerContext"
                },
                "example": {
                  "apiVersion": "modernedi.com/scenario-context/v1",
                  "kind": "scenario_partner_context",
                  "subject": {
                    "environment": "production",
                    "partnerId": 42
                  },
                  "dependencies": [
                    {
                      "binding": {
                        "id": "retailOrderInvoice",
                        "revision": 0,
                        "name": "Retail order to invoice",
                        "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                      },
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "activation": {
                        "current": true,
                        "reason": null
                      },
                      "step": {
                        "id": "purchaseOrder",
                        "direction": "incoming",
                        "transactionSet": "850",
                        "x12Version": "004010",
                        "partnerId": 42,
                        "mappingId": 101,
                        "targetKind": "runtime_mapping"
                      }
                    }
                  ],
                  "expectedOccurrences": [
                    {
                      "run": {
                        "id": "run-6007dbf3-f115-4cac-8530-188fb4326c45",
                        "revision": 0,
                        "etag": "\"scenario-run:v1:42:cnVuLTYwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:0\"",
                        "status": "active",
                        "outcome": "waiting",
                        "phase": "observing",
                        "lastUpdatedAt": "2026-08-24T18:15:00Z"
                      },
                      "binding": {
                        "id": "retailOrderInvoice",
                        "revision": 0,
                        "name": "Retail order to invoice",
                        "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                      },
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "step": {
                        "id": "purchaseOrder",
                        "direction": "incoming",
                        "transactionSet": "850",
                        "x12Version": "004010",
                        "partnerId": 42,
                        "mappingId": 101,
                        "targetKind": "runtime_mapping"
                      },
                      "occurrence": 1
                    }
                  ],
                  "truncated": false
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        }
      }
    },
    "/tenant/scenario-context/mappings/{mappingId}": {
      "get": {
        "operationId": "getScenarioMappingContext",
        "tags": [
          "Context"
        ],
        "summary": "Read scenario dependencies and expected documents for one mapping",
        "description": "Shows every active applied binding step that freezes this exact runtime mapping, including non-current activation state, plus currently eligible open occurrences for active scenario runs.",
        "security": [
          {
            "workspaceSession": []
          }
        ],
        "x-modernedi-permission": "READ",
        "x-modernedi-error-codes": [
          "invalid_request",
          "server_error"
        ],
        "x-modernedi-source": "backend/src/main/java/com/modernedi/backend/TenantScenarioContextResource.java#mapping",
        "parameters": [
          {
            "$ref": "#/components/parameters/mappingId"
          },
          {
            "name": "environment",
            "in": "query",
            "required": false,
            "description": "Scenario v1 environment.",
            "schema": {
              "const": "production",
              "default": "production"
            },
            "example": "production"
          }
        ],
        "responses": {
          "200": {
            "description": "The operation completed successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScenarioMappingContext"
                },
                "example": {
                  "apiVersion": "modernedi.com/scenario-context/v1",
                  "kind": "scenario_mapping_context",
                  "subject": {
                    "environment": "production",
                    "mappingId": 101
                  },
                  "dependencies": [
                    {
                      "binding": {
                        "id": "retailOrderInvoice",
                        "revision": 0,
                        "name": "Retail order to invoice",
                        "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                      },
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "activation": {
                        "current": true,
                        "reason": null
                      },
                      "step": {
                        "id": "purchaseOrder",
                        "direction": "incoming",
                        "transactionSet": "850",
                        "x12Version": "004010",
                        "partnerId": 42,
                        "mappingId": 101,
                        "targetKind": "runtime_mapping"
                      }
                    }
                  ],
                  "expectedOccurrences": [
                    {
                      "run": {
                        "id": "run-6007dbf3-f115-4cac-8530-188fb4326c45",
                        "revision": 0,
                        "etag": "\"scenario-run:v1:42:cnVuLTYwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:0\"",
                        "status": "active",
                        "outcome": "waiting",
                        "phase": "observing",
                        "lastUpdatedAt": "2026-08-24T18:15:00Z"
                      },
                      "binding": {
                        "id": "retailOrderInvoice",
                        "revision": 0,
                        "name": "Retail order to invoice",
                        "contentSha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                      },
                      "definition": {
                        "namespace": "acme",
                        "key": "retail-order-invoice",
                        "version": "1.0.0",
                        "contentSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                      },
                      "step": {
                        "id": "purchaseOrder",
                        "direction": "incoming",
                        "transactionSet": "850",
                        "x12Version": "004010",
                        "partnerId": 42,
                        "mappingId": 101,
                        "targetKind": "runtime_mapping"
                      },
                      "occurrence": 1
                    }
                  ],
                  "truncated": false
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/CacheControl"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "402": {
            "$ref": "#/components/responses/Error402"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "workspaceSession": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Cognito ID token",
        "description": "The signed-in workspace session used by app.modernedi.com. Tenant product access and READ or OPERATE permission are enforced in addition to authentication. This is not an Integration API key."
      }
    },
    "parameters": {
      "workspaceId": {
        "name": "workspaceId",
        "in": "path",
        "required": true,
        "description": "Mapper workspace identifier.",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,127}$"
        },
        "example": "order-validation"
      },
      "bindingId": {
        "name": "bindingId",
        "in": "path",
        "required": true,
        "description": "Stable scenario binding identifier.",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,127}$"
        },
        "example": "order-invoice"
      },
      "runId": {
        "name": "runId",
        "in": "path",
        "required": true,
        "description": "Durable scenario run identifier.",
        "schema": {
          "type": "string",
          "pattern": "^run-[0-9a-f-]+$"
        },
        "example": "run-5007dbf3-f115-4cac-8530-188fb4326c45"
      },
      "messageId": {
        "name": "messageId",
        "in": "path",
        "required": true,
        "description": "Exact persisted transaction message identifier.",
        "schema": {
          "type": "string",
          "pattern": "^\\S+$"
        },
        "example": "msg-01K5QED4DP89F67V3MKRK9R5JM"
      },
      "transactionKey": {
        "name": "transactionKey",
        "in": "path",
        "required": true,
        "description": "Exact persisted transaction key.",
        "schema": {
          "type": "string",
          "pattern": "^\\S+$"
        },
        "example": "tx-01K5QED4DP89F67V3MKRK9R5JM"
      },
      "partnerId": {
        "name": "partnerId",
        "in": "path",
        "required": true,
        "description": "Tenant partner identifier.",
        "schema": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        },
        "example": 42
      },
      "mappingId": {
        "name": "mappingId",
        "in": "path",
        "required": true,
        "description": "Tenant runtime mapping identifier.",
        "schema": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        },
        "example": 17
      }
    },
    "headers": {
      "ETag": {
        "description": "Strong entity tag. Lifecycle resources use a SHA-256 tag; scenario runs use the opaque revision-bearing run tag.",
        "schema": {
          "$ref": "#/components/schemas/StrongEtag"
        },
        "example": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""
      },
      "lifecycleETag": {
        "description": "Strong SHA-256 entity tag for a scenario lifecycle or catalog resource.",
        "schema": {
          "$ref": "#/components/schemas/LifecycleEtag"
        },
        "example": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""
      },
      "evidenceETag": {
        "description": "Strong SHA-256 entity tag for the exact immutable evidence-report bytes.",
        "schema": {
          "$ref": "#/components/schemas/LifecycleEtag"
        },
        "example": "\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\""
      },
      "runETag": {
        "description": "Opaque strong scenario-run entity tag. Return it unchanged as If-Match for the next run command.",
        "schema": {
          "$ref": "#/components/schemas/ScenarioRunEtag"
        },
        "example": "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\""
      },
      "CacheControl": {
        "description": "Private cache policy for tenant data.",
        "schema": {
          "type": "string"
        },
        "example": "private, no-store"
      },
      "IdempotencyReplayed": {
        "description": "true when the response replays a prior result for the same key and request.",
        "schema": {
          "type": "boolean"
        },
        "example": false
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying a rate-limited start, refreshing runtime dependency, or in-progress run operation.",
        "schema": {
          "type": "integer",
          "minimum": 1
        },
        "example": 60
      },
      "Location": {
        "description": "Canonical route for the created run.",
        "schema": {
          "type": "string",
          "format": "uri-reference"
        },
        "example": "/tenant/scenario-runs/run-5007dbf3-f115-4cac-8530-188fb4326c45"
      },
      "XContentSha256": {
        "description": "Lowercase SHA-256 of the exact canonical response bytes.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "example": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
      },
      "ContentDisposition": {
        "description": "Attachment filename for the immutable evidence report.",
        "schema": {
          "type": "string"
        },
        "example": "attachment; filename=\"scenario-evidence-run-5007dbf3-f115-4cac-8530-188fb4326c45.json\""
      },
      "Link": {
        "description": "RFC 8288 links to the human reference, both JSON Schemas, and this OpenAPI service description.",
        "schema": {
          "type": "string"
        },
        "example": "<https://www.modernedi.com/docs/scenarios/reference>; rel=\"help\", <https://www.modernedi.com/docs/scenarios/workspace-api.openapi.json>; rel=\"service-desc\""
      }
    },
    "responses": {
      "Error400": {
        "description": "The request body, selector, or header was invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "invalid_request",
              "error": "The request body, selector, or header was invalid.",
              "retryable": false
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          }
        }
      },
      "Error401": {
        "description": "The Cognito ID-token workspace session was missing or invalid. Authentication failures intentionally have no response body."
      },
      "Error402": {
        "description": "The tenant does not currently have ordinary product access. This is an account-level billing boundary, not a scenario-specific entitlement.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ProductAccessErrorResponse"
            },
            "example": {
              "success": false,
              "tenantId": 42,
              "billingStatus": "cancelled",
              "runtimeAccessAllowed": false,
              "billingAttentionRequired": true,
              "serviceAccessState": "restricted",
              "error": "Tenant billing status \"cancelled\" does not allow access to this API.",
              "nextAction": "manage_billing"
            }
          }
        }
      },
      "Error403": {
        "description": "The signed-in workspace member does not have the required READ or OPERATE permission. Permission denials intentionally have no response body."
      },
      "Error404": {
        "description": "The selected definition, binding, transaction, or run was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "scenario_run_not_found",
              "error": "The selected definition, binding, transaction, or run was not found.",
              "retryable": false
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          }
        }
      },
      "Error409": {
        "description": "The command conflicts with current state or an idempotency key was reused for different input.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "idempotency_key_conflict",
              "error": "The command conflicts with current state or an idempotency key was reused for different input.",
              "retryable": false
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          },
          "ETag": {
            "$ref": "#/components/headers/ETag"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        }
      },
      "Error412": {
        "description": "A supplied entity tag or authority token is stale.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "etag_mismatch",
              "error": "A supplied entity tag or authority token is stale.",
              "retryable": false,
              "currentEtag": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          },
          "ETag": {
            "$ref": "#/components/headers/ETag"
          }
        }
      },
      "Error428": {
        "description": "A required If-Match or If-None-Match precondition was omitted.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "precondition_required",
              "error": "A required If-Match or If-None-Match precondition was omitted.",
              "retryable": false
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          }
        }
      },
      "Error429": {
        "description": "The tenant reached the bounded rolling scenario-start rate.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "scenario_start_rate_limited",
              "error": "The tenant reached the bounded rolling scenario-start rate.",
              "retryable": true,
              "limit": 10
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        }
      },
      "Error500": {
        "description": "The operation failed unexpectedly; the response does not expose internal details.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "server_error",
              "error": "The operation failed unexpectedly; the response does not expose internal details.",
              "retryable": true
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          }
        }
      },
      "Error503": {
        "description": "A required runtime dependency is temporarily unavailable. Honor Retry-After when present.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "code": "scenario_preparation_unavailable",
              "error": "A required runtime dependency is temporarily unavailable. Honor Retry-After when present.",
              "retryable": true
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        }
      },
      "ObservationError409": {
        "description": "The observation conflicts with current run or transaction state. Durably failed observations return operationStatus=failed, and a new attempt uses a fresh Idempotency-Key. Retryable Mapper evaluation failures are distinguished from definitive validation and capacity failures.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "factEvaluationTimeout": {
                "summary": "Trusted Mapper evaluation timed out; a fresh command may retry",
                "value": {
                  "success": false,
                  "code": "fact_evaluation_timeout",
                  "error": "The hosted X12 Mapper fact evaluation timed out; retry the observation.",
                  "retryable": true,
                  "operationStatus": "failed"
                }
              },
              "factValueLimit": {
                "summary": "Mapper-derived fact exceeded a durable value limit",
                "value": {
                  "success": false,
                  "code": "fact_value_limit_exceeded",
                  "error": "The Mapper-derived fact exceeds the scenario v1 value limit.",
                  "retryable": false,
                  "operationStatus": "failed"
                }
              }
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          },
          "ETag": {
            "$ref": "#/components/headers/ETag"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        }
      },
      "ObservationError503": {
        "description": "Trusted transaction observation is temporarily unavailable.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "observationUnavailable": {
                "value": {
                  "success": false,
                  "code": "scenario_observation_unavailable",
                  "error": "Scenario transaction observation is not configured.",
                  "retryable": true
                }
              }
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          }
        }
      },
      "MapperToolingError400": {
        "description": "The stateless Mapper tooling request shape or tree context was invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MapperToolingErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Request body field \"x12Version\" must be a string."
            }
          }
        }
      },
      "WarehouseOutboundSetupError400": {
        "description": "The request body was not exactly an empty JSON object, or the managed warehouse profile could not be prepared from the current tenant configuration.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WarehouseOutboundSetupErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Request body must be exactly an empty JSON object."
            }
          }
        },
        "headers": {
          "Cache-Control": {
            "$ref": "#/components/headers/CacheControl"
          }
        }
      }
    },
    "schemas": {
      "LifecycleEtag": {
        "type": "string",
        "pattern": "^\"[0-9a-f]{64}\"$",
        "description": "Quoted lowercase SHA-256 ETag used by immutable definition, binding, authority, and catalog resources.",
        "examples": [
          "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""
        ]
      },
      "ScenarioRunEtag": {
        "type": "string",
        "pattern": "^\"scenario-run:v1:[1-9][0-9]*:[A-Za-z0-9_-]+:(?:0|[1-9][0-9]*)\"$",
        "description": "Opaque quoted strong ETag for one tenant-scoped run revision. Clients must return the current value unchanged; its fields are not client authority.",
        "examples": [
          "\"scenario-run:v1:42:cnVuLTUwMDdkYmYzLWYxMTUtNGNhYy04NTMwLTE4OGZiNDMyNmM0NQ:1\""
        ]
      },
      "StrongEtag": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/LifecycleEtag"
          },
          {
            "$ref": "#/components/schemas/ScenarioRunEtag"
          }
        ],
        "description": "One of the two strong ETag formats used by the signed-in Scenario Workspace API."
      },
      "ScenarioDefinition": {
        "$ref": "./schemas/scenario-definition-v1.schema.json"
      },
      "ScenarioBinding": {
        "$ref": "./schemas/scenario-binding-v1.schema.json"
      },
      "DefinitionIdentity": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "namespace",
          "key",
          "version",
          "contentSha256"
        ],
        "properties": {
          "namespace": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/namespace"
          },
          "key": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "version": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/artifactVersion"
          },
          "contentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "WorkspaceActor": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "memberId",
          "email",
          "role"
        ],
        "properties": {
          "memberId": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "email": {
            "type": "string",
            "minLength": 1
          },
          "role": {
            "enum": [
              "OWNER",
              "OPERATOR",
              "VIEWER"
            ]
          }
        }
      },
      "DefinitionSourceFile": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "fileType",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "fileType": {
            "const": "SCENARIO_DEFINITION"
          },
          "source": {
            "type": "string",
            "maxLength": 65536,
            "contentMediaType": "application/json",
            "contentSchema": {
              "$ref": "./schemas/scenario-definition-v1.schema.json"
            }
          }
        }
      },
      "BindingSourceFile": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "fileType",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "fileType": {
            "const": "SCENARIO_BINDING"
          },
          "source": {
            "type": "string",
            "maxLength": 65536,
            "contentMediaType": "application/json",
            "contentSchema": {
              "$ref": "./schemas/scenario-binding-v1.schema.json"
            }
          }
        }
      },
      "ScenarioSourceFile": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/DefinitionSourceFile"
          },
          {
            "$ref": "#/components/schemas/BindingSourceFile"
          }
        ]
      },
      "ScenarioValidationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioSourceFile"
            }
          }
        }
      },
      "ValidationIssue": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "pointer",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "pointer": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ValidationCompiledResult": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "definition",
              "contentSha256"
            ],
            "properties": {
              "definition": {
                "$ref": "#/components/schemas/DefinitionIdentity"
              },
              "contentSha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "definition",
              "contentSha256",
              "authorityEtag",
              "referencedPartnerIds",
              "applyEligibility"
            ],
            "properties": {
              "definition": {
                "$ref": "#/components/schemas/DefinitionIdentity"
              },
              "contentSha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "authorityEtag": {
                "$ref": "#/components/schemas/LifecycleEtag"
              },
              "referencedPartnerIds": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "format": "int64",
                  "minimum": 1
                },
                "uniqueItems": true
              },
              "applyEligibility": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "eligible",
                  "activationKind",
                  "reason"
                ],
                "properties": {
                  "eligible": {
                    "type": "boolean"
                  },
                  "activationKind": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        ],
        "description": "Definition validation returns the first shape. Binding validation additionally freezes current authority and Apply eligibility in the second shape."
      },
      "ValidationFileResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "fileType",
          "kind",
          "status",
          "issues"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "fileType": {
            "enum": [
              "SCENARIO_DEFINITION",
              "SCENARIO_BINDING"
            ]
          },
          "kind": {
            "enum": [
              "definition",
              "binding"
            ]
          },
          "status": {
            "enum": [
              "resolved",
              "needs_attention"
            ]
          },
          "issues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ValidationIssue"
            }
          },
          "compiled": {
            "$ref": "#/components/schemas/ValidationCompiledResult"
          }
        }
      },
      "ScenarioValidationResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "files"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ValidationFileResult"
            }
          }
        }
      },
      "PublishedDefinition": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "namespace",
          "key",
          "version",
          "contentSha256",
          "etag",
          "publishedAt",
          "publishedBy"
        ],
        "properties": {
          "namespace": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/namespace"
          },
          "key": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "version": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/artifactVersion"
          },
          "contentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "etag": {
            "$ref": "#/components/schemas/LifecycleEtag"
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time"
          },
          "publishedBy": {
            "$ref": "#/components/schemas/WorkspaceActor"
          }
        }
      },
      "PublishedDefinitionListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "definitions"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "definitions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublishedDefinition"
            }
          }
        }
      },
      "PublishScenarioDefinitionRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "file",
          "expectedContentSha256"
        ],
        "properties": {
          "file": {
            "$ref": "#/components/schemas/DefinitionSourceFile"
          },
          "expectedContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "PublishedDefinitionMutationResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "replay",
          "definition"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "replay": {
            "type": "boolean"
          },
          "definition": {
            "$ref": "#/components/schemas/PublishedDefinition"
          }
        }
      },
      "AppliedBinding": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "status",
          "revision",
          "definition",
          "authoringContentSha256",
          "bindingContentSha256",
          "adapterId",
          "environment",
          "referencedMappingIds",
          "referencedPartnerIds",
          "etag",
          "appliedAt",
          "appliedBy",
          "activation"
        ],
        "properties": {
          "id": {
            "$ref": "./schemas/scenario-binding-v1.schema.json#/$defs/token"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "pattern": "\\S"
          },
          "status": {
            "const": "ACTIVE"
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "authoringContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "bindingContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "adapterId": {
            "type": "string"
          },
          "environment": {
            "const": "production"
          },
          "referencedMappingIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64",
              "minimum": 1
            },
            "uniqueItems": true
          },
          "referencedPartnerIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64",
              "minimum": 1
            },
            "uniqueItems": true
          },
          "etag": {
            "$ref": "#/components/schemas/LifecycleEtag"
          },
          "appliedAt": {
            "type": "string",
            "format": "date-time"
          },
          "appliedBy": {
            "$ref": "#/components/schemas/WorkspaceActor"
          },
          "activation": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "runnable",
                  "current",
                  "reason"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "minLength": 1
                  },
                  "runnable": {
                    "const": true
                  },
                  "current": {
                    "const": true
                  },
                  "reason": {
                    "type": "null"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "runnable",
                  "current",
                  "reason"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "minLength": 1
                  },
                  "runnable": {
                    "const": true
                  },
                  "current": {
                    "const": false
                  },
                  "reason": {
                    "const": "referenced_configuration_changed"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "runnable",
                  "current",
                  "reason"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "minLength": 1
                  },
                  "runnable": {
                    "const": false
                  },
                  "current": {
                    "const": false
                  },
                  "reason": {
                    "const": "activation_unavailable"
                  }
                }
              }
            ]
          }
        }
      },
      "AppliedBindingListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "bindings"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "bindings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AppliedBinding"
            }
          }
        }
      },
      "AppliedBindingResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "binding"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "binding": {
            "$ref": "#/components/schemas/AppliedBinding"
          }
        }
      },
      "ApplyScenarioBindingRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "file",
          "expectedContentSha256",
          "expectedAuthorityEtag"
        ],
        "properties": {
          "file": {
            "$ref": "#/components/schemas/BindingSourceFile"
          },
          "expectedContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "expectedAuthorityEtag": {
            "$ref": "#/components/schemas/LifecycleEtag"
          }
        }
      },
      "AppliedBindingMutationResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "replay",
          "binding"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "replay": {
            "type": "boolean"
          },
          "binding": {
            "$ref": "#/components/schemas/AppliedBinding"
          }
        }
      },
      "ScenarioContextBinding": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "revision",
          "name",
          "contentSha256"
        ],
        "properties": {
          "id": {
            "$ref": "./schemas/scenario-binding-v1.schema.json#/$defs/token"
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "contentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "ScenarioContextRun": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "revision",
          "etag",
          "status",
          "outcome",
          "phase",
          "lastUpdatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^run-[0-9a-f-]+$"
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "etag": {
            "$ref": "#/components/schemas/ScenarioRunEtag"
          },
          "status": {
            "enum": [
              "active",
              "completed",
              "cancelled"
            ]
          },
          "outcome": {
            "enum": [
              "waiting",
              "passed",
              "failed",
              "inconclusive"
            ]
          },
          "phase": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ScenarioContextStep": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "direction",
          "transactionSet",
          "x12Version",
          "partnerId",
          "mappingId",
          "targetKind"
        ],
        "properties": {
          "id": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "direction": {
            "enum": [
              "incoming",
              "outgoing"
            ]
          },
          "transactionSet": {
            "type": "string",
            "pattern": "^[0-9]{3}$"
          },
          "x12Version": {
            "type": "string",
            "pattern": "^[0-9]{6}$"
          },
          "partnerId": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "mappingId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 1
          },
          "targetKind": {
            "enum": [
              "adapter",
              "runtime_mapping",
              "observation_only"
            ]
          }
        }
      },
      "ScenarioContextActivation": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "current",
              "reason"
            ],
            "properties": {
              "current": {
                "const": true
              },
              "reason": {
                "type": "null"
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "current",
              "reason"
            ],
            "properties": {
              "current": {
                "const": false
              },
              "reason": {
                "enum": [
                  "referenced_configuration_changed",
                  "activation_unavailable"
                ]
              }
            }
          }
        ]
      },
      "ScenarioContextDependency": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "binding",
          "definition",
          "activation",
          "step"
        ],
        "properties": {
          "binding": {
            "$ref": "#/components/schemas/ScenarioContextBinding"
          },
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "activation": {
            "$ref": "#/components/schemas/ScenarioContextActivation"
          },
          "step": {
            "$ref": "#/components/schemas/ScenarioContextStep"
          }
        }
      },
      "ScenarioExpectedOccurrence": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "run",
          "binding",
          "definition",
          "step",
          "occurrence"
        ],
        "properties": {
          "run": {
            "$ref": "#/components/schemas/ScenarioContextRun"
          },
          "binding": {
            "$ref": "#/components/schemas/ScenarioContextBinding"
          },
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "step": {
            "$ref": "#/components/schemas/ScenarioContextStep"
          },
          "occurrence": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "ScenarioTransactionMembership": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "run",
          "binding",
          "definition",
          "step",
          "occurrence",
          "observedAt"
        ],
        "properties": {
          "run": {
            "$ref": "#/components/schemas/ScenarioContextRun"
          },
          "binding": {
            "$ref": "#/components/schemas/ScenarioContextBinding"
          },
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "step": {
            "$ref": "#/components/schemas/ScenarioContextStep"
          },
          "occurrence": {
            "type": "integer",
            "minimum": 1
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ScenarioTransactionContext": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "apiVersion",
          "kind",
          "subject",
          "memberships",
          "candidates",
          "truncated"
        ],
        "properties": {
          "apiVersion": {
            "const": "modernedi.com/scenario-context/v1"
          },
          "kind": {
            "const": "scenario_transaction_context"
          },
          "subject": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "environment",
              "messageId",
              "transactionKey"
            ],
            "properties": {
              "environment": {
                "const": "production"
              },
              "messageId": {
                "type": "string",
                "minLength": 1
              },
              "transactionKey": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "memberships": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioTransactionMembership"
            }
          },
          "candidates": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioExpectedOccurrence"
            }
          },
          "truncated": {
            "type": "boolean"
          }
        }
      },
      "ScenarioPartnerContext": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "apiVersion",
          "kind",
          "subject",
          "dependencies",
          "expectedOccurrences",
          "truncated"
        ],
        "properties": {
          "apiVersion": {
            "const": "modernedi.com/scenario-context/v1"
          },
          "kind": {
            "const": "scenario_partner_context"
          },
          "subject": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "environment",
              "partnerId"
            ],
            "properties": {
              "environment": {
                "const": "production"
              },
              "partnerId": {
                "type": "integer",
                "format": "int64",
                "minimum": 1
              }
            }
          },
          "dependencies": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioContextDependency"
            }
          },
          "expectedOccurrences": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioExpectedOccurrence"
            }
          },
          "truncated": {
            "type": "boolean"
          }
        }
      },
      "ScenarioMappingContext": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "apiVersion",
          "kind",
          "subject",
          "dependencies",
          "expectedOccurrences",
          "truncated"
        ],
        "properties": {
          "apiVersion": {
            "const": "modernedi.com/scenario-context/v1"
          },
          "kind": {
            "const": "scenario_mapping_context"
          },
          "subject": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "environment",
              "mappingId"
            ],
            "properties": {
              "environment": {
                "const": "production"
              },
              "mappingId": {
                "type": "integer",
                "format": "int64",
                "minimum": 1
              }
            }
          },
          "dependencies": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioContextDependency"
            }
          },
          "expectedOccurrences": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioExpectedOccurrence"
            }
          },
          "truncated": {
            "type": "boolean"
          }
        }
      },
      "ScenarioRunSummaryGuidance": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "nextAction",
              "stepId",
              "occurrence"
            ],
            "properties": {
              "nextAction": {
                "type": "null"
              },
              "stepId": {
                "type": "null"
              },
              "occurrence": {
                "type": "null"
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "nextAction",
              "stepId",
              "occurrence"
            ],
            "properties": {
              "nextAction": {
                "const": "attach_or_refresh"
              },
              "stepId": {
                "type": "null"
              },
              "occurrence": {
                "type": "null"
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "nextAction",
              "stepId",
              "occurrence"
            ],
            "properties": {
              "nextAction": {
                "const": "advance_adapter"
              },
              "stepId": {
                "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
              },
              "occurrence": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "ScenarioRunSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "revision",
          "etag",
          "binding",
          "definition",
          "environment",
          "status",
          "outcome",
          "phase",
          "startedAt",
          "completedAt",
          "lastUpdatedAt",
          "guidance"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^run-[0-9a-f-]+$"
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "etag": {
            "$ref": "#/components/schemas/ScenarioRunEtag"
          },
          "binding": {
            "$ref": "#/components/schemas/ScenarioContextBinding"
          },
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "environment": {
            "const": "production"
          },
          "status": {
            "enum": [
              "active",
              "completed",
              "cancelled"
            ]
          },
          "outcome": {
            "enum": [
              "waiting",
              "passed",
              "failed",
              "inconclusive"
            ]
          },
          "phase": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "guidance": {
            "$ref": "#/components/schemas/ScenarioRunSummaryGuidance"
          }
        }
      },
      "ScenarioRunCollection": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "apiVersion",
          "kind",
          "runs",
          "nextCursor"
        ],
        "properties": {
          "apiVersion": {
            "const": "modernedi.com/scenario-platform/v1"
          },
          "kind": {
            "const": "scenario_run_collection"
          },
          "runs": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioRunSummary"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1024,
            "pattern": "^[A-Za-z0-9_-]+$",
            "description": "Opaque tenant-bound keyset cursor for the next page, or null when history is exhausted."
          }
        }
      },
      "ScenarioRunTimelineError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1
          },
          "message": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "ScenarioRunTimelineOperation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operationId",
          "action",
          "status",
          "expectedRunRevision",
          "actor",
          "attempts",
          "requestedAt",
          "startedAt",
          "completedAt",
          "lastUpdatedAt",
          "error"
        ],
        "properties": {
          "operationId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,95}$"
          },
          "action": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "status": {
            "enum": [
              "processing",
              "succeeded",
              "failed"
            ]
          },
          "expectedRunRevision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "actor": {
            "$ref": "#/components/schemas/WorkspaceActor"
          },
          "attempts": {
            "type": "integer",
            "minimum": 1
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          },
          "startedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "error": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ScenarioRunTimelineError"
              }
            ]
          }
        }
      },
      "ScenarioRunTimelineResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "runId",
          "operations",
          "nextCursor"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "runId": {
            "type": "string",
            "pattern": "^run-[0-9a-f-]+$"
          },
          "operations": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioRunTimelineOperation"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1024,
            "pattern": "^[A-Za-z0-9_-]+$",
            "description": "Opaque tenant-and-run-bound keyset cursor for the next page, or null when the timeline is exhausted."
          }
        }
      },
      "ScenarioEvidencePartnerAuthority": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "actorId",
          "id",
          "configurationSha256"
        ],
        "properties": {
          "actorId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "id": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "configurationSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "ScenarioEvidenceMappingAuthority": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stepId",
          "id",
          "partnerId",
          "direction",
          "x12Version",
          "transactionSet",
          "configurationEtag",
          "mapFileSha256Hash"
        ],
        "properties": {
          "stepId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "id": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "partnerId": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "direction": {
            "enum": [
              "incoming",
              "outgoing"
            ]
          },
          "x12Version": {
            "type": "string",
            "pattern": "^[0-9]{6}$"
          },
          "transactionSet": {
            "type": "string",
            "pattern": "^[0-9]{3}$"
          },
          "configurationEtag": {
            "type": "string",
            "minLength": 1
          },
          "mapFileSha256Hash": {
            "type": "string",
            "pattern": "^[A-Za-z0-9+/]{42}[AEIMQUYcgkosw048]=$"
          }
        }
      },
      "ScenarioEvidenceSyntaxTreeAuthority": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stepId",
          "x12Version",
          "transactionSet",
          "catalogRevision",
          "catalogManifestSha256",
          "syntaxTreeSha256"
        ],
        "properties": {
          "stepId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "x12Version": {
            "type": "string",
            "pattern": "^[0-9]{6}$"
          },
          "transactionSet": {
            "type": "string",
            "pattern": "^[0-9]{3}$"
          },
          "catalogRevision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "catalogManifestSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "syntaxTreeSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "ScenarioEvidenceTargetAuthority": {
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "stepId",
              "kind",
              "adapterId",
              "mappingId"
            ],
            "properties": {
              "stepId": {
                "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
              },
              "kind": {
                "const": "runtime_mapping"
              },
              "adapterId": {
                "type": "null"
              },
              "mappingId": {
                "type": "integer",
                "format": "int64",
                "minimum": 1
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "stepId",
              "kind",
              "adapterId",
              "mappingId"
            ],
            "properties": {
              "stepId": {
                "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
              },
              "kind": {
                "const": "adapter"
              },
              "adapterId": {
                "type": "string",
                "minLength": 1
              },
              "mappingId": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int64",
                "minimum": 1
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "stepId",
              "kind",
              "adapterId",
              "mappingId"
            ],
            "properties": {
              "stepId": {
                "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
              },
              "kind": {
                "const": "observation_only"
              },
              "adapterId": {
                "type": "null"
              },
              "mappingId": {
                "type": "null"
              }
            }
          }
        ]
      },
      "ScenarioEvidenceAuthority": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "partners",
          "mappings",
          "syntaxTrees",
          "targets"
        ],
        "properties": {
          "partners": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidencePartnerAuthority"
            }
          },
          "mappings": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceMappingAuthority"
            }
          },
          "syntaxTrees": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceSyntaxTreeAuthority"
            }
          },
          "targets": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceTargetAuthority"
            }
          }
        }
      },
      "ScenarioEvidenceClaim": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "statement",
          "scope"
        ],
        "properties": {
          "type": {
            "const": "implementation_verification"
          },
          "statement": {
            "const": "ModernEDI observed and evaluated this scenario run against the exact applied binding recorded in this report."
          },
          "scope": {
            "const": "This report proves only the recorded run; it does not certify the tenant's broader EDI implementation."
          }
        }
      },
      "ScenarioEvidenceRun": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "status",
          "outcome",
          "phase",
          "revision",
          "environment",
          "adapterId",
          "definition",
          "binding",
          "startedBy",
          "startedAt",
          "completedAt",
          "lastUpdatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^run-[0-9a-f-]+$"
          },
          "status": {
            "enum": [
              "completed",
              "cancelled"
            ]
          },
          "outcome": {
            "enum": [
              "passed",
              "failed",
              "inconclusive"
            ]
          },
          "phase": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "environment": {
            "const": "production"
          },
          "adapterId": {
            "const": "scenario-graph-interpreter-v1"
          },
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "binding": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "revision"
            ],
            "properties": {
              "id": {
                "$ref": "./schemas/scenario-binding-v1.schema.json#/$defs/token"
              },
              "revision": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              }
            }
          },
          "startedBy": {
            "$ref": "#/components/schemas/WorkspaceActor"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUpdatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ScenarioEvidenceBinding": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "revision",
          "name",
          "snapshotContentSha256",
          "definitionContentSha256",
          "adapterId",
          "environment",
          "authority"
        ],
        "properties": {
          "id": {
            "$ref": "./schemas/scenario-binding-v1.schema.json#/$defs/token"
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "snapshotContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "definitionContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "adapterId": {
            "const": "scenario-graph-interpreter-v1"
          },
          "environment": {
            "const": "production"
          },
          "authority": {
            "$ref": "#/components/schemas/ScenarioEvidenceAuthority"
          }
        }
      },
      "ScenarioEvidenceSuccessfulTransition": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operationId",
          "action",
          "disposition",
          "fromRevision",
          "toRevision",
          "actor",
          "requestedAt",
          "completedAt"
        ],
        "properties": {
          "operationId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,95}$"
          },
          "action": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "disposition": {
            "enum": [
              "started",
              "advanced",
              "reconciled",
              "reconciliation_pending",
              "binding_drifted",
              "cancelled"
            ]
          },
          "fromRevision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "toRevision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "actor": {
            "$ref": "#/components/schemas/WorkspaceActor"
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ScenarioEvidenceFailure": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operationId",
          "action",
          "expectedRunRevision",
          "actor",
          "requestedAt",
          "completedAt",
          "error"
        ],
        "properties": {
          "operationId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,95}$"
          },
          "action": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "expectedRunRevision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "actor": {
            "$ref": "#/components/schemas/WorkspaceActor"
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_.:-]{0,95}$"
              },
              "message": {
                "const": "See the run timeline for the failure detail."
              }
            }
          }
        }
      },
      "ScenarioEvidenceOperations": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "total",
          "succeeded",
          "failed",
          "successfulTransitions",
          "failures"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "minimum": 1,
            "maximum": 256
          },
          "succeeded": {
            "type": "integer",
            "minimum": 1,
            "maximum": 256
          },
          "failed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 256
          },
          "successfulTransitions": {
            "type": "array",
            "maxItems": 256,
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceSuccessfulTransition"
            }
          },
          "failures": {
            "type": "array",
            "maxItems": 256,
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceFailure"
            }
          }
        }
      },
      "ScenarioEvidenceOccurrence": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "occurrence",
          "observedAt",
          "messageId",
          "transactionKey",
          "partnerId",
          "mappingId"
        ],
        "properties": {
          "occurrence": {
            "type": "integer",
            "minimum": 1
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "transactionKey": {
            "type": "string",
            "minLength": 1
          },
          "partnerId": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "mappingId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 1
          }
        }
      },
      "ScenarioEvidenceStep": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stepId",
          "fromActor",
          "toActor",
          "transactionSet",
          "direction",
          "targetKind",
          "occurrences"
        ],
        "properties": {
          "stepId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "fromActor": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "toActor": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "transactionSet": {
            "type": "string",
            "pattern": "^[0-9]{3}$"
          },
          "direction": {
            "enum": [
              "incoming",
              "outgoing"
            ]
          },
          "targetKind": {
            "enum": [
              "runtime_mapping",
              "adapter",
              "observation_only"
            ]
          },
          "occurrences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceOccurrence"
            }
          }
        }
      },
      "ScenarioEvidenceCheckSubject": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stepId",
          "occurrence",
          "redacted",
          "fact",
          "sensitivity",
          "evidenceReferences"
        ],
        "properties": {
          "stepId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "occurrence": {
            "type": "integer",
            "minimum": 1
          },
          "redacted": {
            "type": "boolean"
          },
          "fact": {
            "oneOf": [
              {
                "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
              },
              {
                "type": "null"
              }
            ]
          },
          "sensitivity": {
            "enum": [
              "business",
              "personal",
              "financial",
              "health",
              "restricted",
              null
            ]
          },
          "evidenceReferences": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      },
      "ScenarioEvidenceDigest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "sha256"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "minLength": 1
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "ScenarioEvidenceCheck": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "kind",
          "outcome",
          "code",
          "subjects",
          "attributes",
          "evidenceDigests"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "enum": [
              "parameter",
              "occurrence",
              "pipeline",
              "assurance",
              "branch",
              "transition",
              "assertion",
              "revision"
            ]
          },
          "outcome": {
            "enum": [
              "pending",
              "passed",
              "failed",
              "inconclusive"
            ]
          },
          "code": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]{0,95}$"
          },
          "subjects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceCheckSubject"
            }
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "evidenceDigests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceDigest"
            }
          }
        }
      },
      "ScenarioEvidenceReference": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reference",
          "kind"
        ],
        "properties": {
          "reference": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "ScenarioEvidence": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "counts",
          "steps",
          "checks",
          "references"
        ],
        "properties": {
          "kind": {
            "const": "graph"
          },
          "counts": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "observations",
              "checkpoints"
            ],
            "properties": {
              "observations": {
                "type": "integer",
                "minimum": 0
              },
              "checkpoints": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceStep"
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceCheck"
            }
          },
          "references": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioEvidenceReference"
            }
          }
        }
      },
      "ScenarioEvidenceReport": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "apiVersion",
          "createdAt",
          "claim",
          "run",
          "binding",
          "operations",
          "evidence"
        ],
        "properties": {
          "apiVersion": {
            "const": "modernedi.com/scenario-evidence-report/v1"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "claim": {
            "$ref": "#/components/schemas/ScenarioEvidenceClaim"
          },
          "run": {
            "$ref": "#/components/schemas/ScenarioEvidenceRun"
          },
          "binding": {
            "$ref": "#/components/schemas/ScenarioEvidenceBinding"
          },
          "operations": {
            "$ref": "#/components/schemas/ScenarioEvidenceOperations"
          },
          "evidence": {
            "$ref": "#/components/schemas/ScenarioEvidence"
          }
        }
      },
      "ScenarioCatalogReadiness": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "level",
          "completeSyntaxTreeVersions",
          "missingSyntaxTreeStepIds"
        ],
        "properties": {
          "level": {
            "enum": [
              "definition_only",
              "syntax_tree_backed",
              "executable_adapter"
            ],
            "description": "Catalog-level readiness only. definition_only has no common stored X12 release for every step; syntax_tree_backed has common-release syntax-tree coverage but no exact registered managed adapter; executable_adapter has one exact registered managed adapter covering the definition and every step. Tenant-specific runnability is decided separately by Validate and Apply."
          },
          "completeSyntaxTreeVersions": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[0-9]{6}$"
            },
            "uniqueItems": true,
            "description": "Stored X12 releases that contain syntax trees for every definition step."
          },
          "missingSyntaxTreeStepIds": {
            "type": "array",
            "items": {
              "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
            },
            "uniqueItems": true,
            "description": "Step IDs not covered by one common stored X12 release when readiness is definition_only."
          },
          "adapterId": {
            "type": "string",
            "minLength": 1,
            "description": "Exact registered ModernEDI-managed adapter ID. Present only for executable_adapter readiness."
          }
        }
      },
      "ScenarioCatalogEntry": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "contentSha256",
          "topologicalStepOrder",
          "readiness",
          "definition"
        ],
        "properties": {
          "contentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "topologicalStepOrder": {
            "type": "array",
            "items": {
              "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
            },
            "uniqueItems": true
          },
          "readiness": {
            "$ref": "#/components/schemas/ScenarioCatalogReadiness"
          },
          "definition": {
            "$ref": "./schemas/scenario-definition-v1.schema.json"
          }
        }
      },
      "ScenarioCatalogResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "definitions"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "definitions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioCatalogEntry"
            }
          }
        }
      },
      "MapperPosition": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "line",
          "character"
        ],
        "properties": {
          "line": {
            "type": "integer",
            "minimum": 0
          },
          "character": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "MapperRange": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "start",
          "end"
        ],
        "properties": {
          "start": {
            "$ref": "#/components/schemas/MapperPosition"
          },
          "end": {
            "$ref": "#/components/schemas/MapperPosition"
          }
        }
      },
      "MapperDiagnostic": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "range",
          "message",
          "code",
          "severity"
        ],
        "properties": {
          "range": {
            "$ref": "#/components/schemas/MapperRange"
          },
          "message": {
            "type": [
              "string",
              "null"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ]
          },
          "severity": {
            "enum": [
              "ERROR",
              "WARNING",
              "INFORMATION",
              "HINT"
            ]
          }
        }
      },
      "MapperExpressionDiagnosticsRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source"
        ],
        "properties": {
          "source": {
            "type": "string",
            "maxLength": 16384,
            "description": "Exactly one value-returning X12 Mapper expression. A blank string returns the ordinary one-expression diagnostic."
          },
          "x12Version": {
            "type": "string",
            "pattern": "^[0-9]{6}$",
            "description": "Exact stored X12 release used for tree-aware diagnostics. Omission uses the general Mapper default and is not a substitute for binding Validate."
          },
          "transactionSetId": {
            "type": "string",
            "pattern": "^[0-9]{3}$",
            "description": "Exact three-digit X12 transaction set for the expression context. Omission uses the general Mapper default and is not a substitute for binding Validate."
          }
        }
      },
      "MapperExpressionDiagnosticsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "diagnostics"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "diagnostics": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MapperDiagnostic"
            }
          }
        }
      },
      "MapperToolingErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "const": false
          },
          "error": {
            "type": "string"
          }
        }
      },
      "ScenarioRunParameterScalar": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          }
        ],
        "description": "One raw parameter value. The selected definition is authoritative for its declared type. Send decimal values as JSON strings when exact decimal precision matters."
      },
      "ScenarioRunParameterValue": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/ScenarioRunParameterScalar"
          },
          {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioRunParameterScalar"
            }
          }
        ]
      },
      "ScenarioRunParameterValues": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/components/schemas/ScenarioRunParameterValue"
        },
        "description": "Values keyed by declared definition parameter ID. The server rejects unknown, missing-required, or type-invalid values and materializes declared defaults before hashing the run input. Raw parameter values are never returned by the run API.",
        "examples": [
          {
            "shipmentCount": 2,
            "cutoffTotal": "1250.00",
            "priority": true,
            "allowedWarehouses": [
              "PHX",
              "LAX"
            ]
          }
        ]
      },
      "StartScenarioRunRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "definition",
          "environment",
          "binding"
        ],
        "properties": {
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "environment": {
            "const": "production"
          },
          "binding": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "revision",
              "contentSha256"
            ],
            "properties": {
              "id": {
                "$ref": "./schemas/scenario-binding-v1.schema.json#/$defs/token"
              },
              "revision": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "contentSha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            }
          },
          "parameters": {
            "$ref": "#/components/schemas/ScenarioRunParameterValues"
          }
        }
      },
      "AdvanceScenarioRunRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {}
      },
      "CancelScenarioRunRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {}
      },
      "ManagedScenarioRunStartRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {}
      },
      "WarehouseOutboundSetupRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {}
      },
      "WarehouseOutboundSetupResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "testOnly",
          "configured",
          "mappingAvailable",
          "partnerId",
          "mappingId",
          "canSendShippingOrder",
          "readyAfter"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "testOnly": {
            "const": true
          },
          "configured": {
            "type": "boolean"
          },
          "mappingAvailable": {
            "type": "boolean"
          },
          "partnerId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 1
          },
          "mappingId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 1
          },
          "canSendShippingOrder": {
            "type": "boolean"
          },
          "readyAfter": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "WarehouseOutboundSetupErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "const": false
          },
          "error": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "ScenarioRunObservationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stepId",
          "occurrence",
          "messageId",
          "transactionKey"
        ],
        "properties": {
          "stepId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "occurrence": {
            "type": "integer",
            "minimum": 1
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "transactionKey": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "ScenarioGraphExecution": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "runtimeVersion",
          "authorityContentSha256",
          "parametersContentSha256"
        ],
        "properties": {
          "kind": {
            "const": "scenario_graph_v1"
          },
          "runtimeVersion": {
            "const": "1.0.0"
          },
          "authorityContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "parametersContentSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "ScenarioGraphCounts": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "observations",
          "checkpoints"
        ],
        "properties": {
          "observations": {
            "type": "integer",
            "minimum": 0
          },
          "checkpoints": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "ScenarioGraphRetry": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "mode",
          "reason",
          "requiresApiKey"
        ],
        "properties": {
          "mode": {
            "enum": [
              "advance",
              "reconcile_only",
              "terminal"
            ]
          },
          "reason": {
            "type": "string",
            "minLength": 1
          },
          "requiresApiKey": {
            "type": "boolean"
          }
        }
      },
      "ScenarioGraphGuidance": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "nextAction",
          "stepId",
          "occurrence"
        ],
        "properties": {
          "nextAction": {
            "enum": [
              "advance_adapter",
              "attach_or_refresh",
              null
            ]
          },
          "stepId": {
            "oneOf": [
              {
                "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
              },
              {
                "type": "null"
              }
            ]
          },
          "occurrence": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          }
        }
      },
      "ScenarioGraphEvidenceReference": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reference",
          "kind"
        ],
        "properties": {
          "reference": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "ScenarioGraphAssurances": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mapping_succeeded": {
            "enum": [
              "pending",
              "passed",
              "failed"
            ]
          },
          "transport_receipt_accepted": {
            "enum": [
              "pending",
              "passed",
              "failed"
            ]
          },
          "interchange_acknowledgment_accepted": {
            "enum": [
              "pending",
              "passed",
              "failed"
            ]
          },
          "functional_or_implementation_acknowledgment_accepted": {
            "enum": [
              "pending",
              "passed",
              "failed"
            ]
          }
        },
        "description": "Only assurances declared by this step are present. Pending evidence can be refreshed by observing the same transaction again with a new command identity."
      },
      "ScenarioGraphOccurrence": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "occurrence",
          "observedAt",
          "messageId",
          "transactionKey",
          "replyToMessageId",
          "replyToTransactionKey",
          "direction",
          "partnerId",
          "transactionSet",
          "x12Version",
          "mappingId",
          "assurances",
          "evidence"
        ],
        "properties": {
          "occurrence": {
            "type": "integer",
            "minimum": 1
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "transactionKey": {
            "type": "string",
            "minLength": 1
          },
          "replyToMessageId": {
            "type": [
              "string",
              "null"
            ]
          },
          "replyToTransactionKey": {
            "type": [
              "string",
              "null"
            ]
          },
          "direction": {
            "enum": [
              "incoming",
              "outgoing"
            ]
          },
          "partnerId": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "transactionSet": {
            "type": "string",
            "pattern": "^[0-9]{3}$"
          },
          "x12Version": {
            "type": "string",
            "pattern": "^[0-9]{6}$",
            "description": "Canonical six-digit public X12 release identity."
          },
          "mappingId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 1
          },
          "assurances": {
            "$ref": "#/components/schemas/ScenarioGraphAssurances"
          },
          "evidence": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioGraphEvidenceReference"
            }
          }
        }
      },
      "ScenarioGraphStep": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stepId",
          "fromActor",
          "toActor",
          "transactionSet",
          "direction",
          "targetKind",
          "attachable",
          "occurrence",
          "observedOccurrences",
          "occurrences"
        ],
        "properties": {
          "stepId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "fromActor": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "toActor": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "transactionSet": {
            "type": "string",
            "pattern": "^[0-9]{3}$"
          },
          "direction": {
            "enum": [
              "incoming",
              "outgoing"
            ]
          },
          "targetKind": {
            "enum": [
              "adapter",
              "runtime_mapping",
              "observation_only"
            ]
          },
          "attachable": {
            "type": "boolean",
            "description": "True only for runtime_mapping and observation_only targets. Adapter steps are advanced through /advance."
          },
          "occurrence": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "min",
              "max"
            ],
            "properties": {
              "min": {
                "type": "integer",
                "minimum": 0
              },
              "max": {
                "type": "integer",
                "minimum": 1
              }
            }
          },
          "observedOccurrences": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "integer",
              "minimum": 1
            }
          },
          "occurrences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioGraphOccurrence"
            }
          }
        }
      },
      "ScenarioGraphCheckSubject": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stepId",
          "occurrence",
          "redacted",
          "fact",
          "sensitivity",
          "evidenceReferences"
        ],
        "properties": {
          "stepId": {
            "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
          },
          "occurrence": {
            "type": "integer",
            "minimum": 1
          },
          "redacted": {
            "type": "boolean"
          },
          "fact": {
            "oneOf": [
              {
                "$ref": "./schemas/scenario-definition-v1.schema.json#/$defs/token"
              },
              {
                "type": "null"
              }
            ]
          },
          "sensitivity": {
            "enum": [
              "business",
              "personal",
              "financial",
              "health",
              "restricted",
              null
            ]
          },
          "evidenceReferences": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      },
      "ScenarioGraphCheck": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "kind",
          "outcome",
          "code",
          "subjects",
          "attributes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_.:-]{0,255}$"
          },
          "kind": {
            "enum": [
              "parameter",
              "occurrence",
              "pipeline",
              "assurance",
              "branch",
              "transition",
              "assertion",
              "revision"
            ]
          },
          "outcome": {
            "enum": [
              "pending",
              "passed",
              "failed",
              "inconclusive"
            ]
          },
          "code": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]{0,95}$"
          },
          "subjects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioGraphCheckSubject"
            }
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "ScenarioRun": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "apiVersion",
          "kind",
          "id",
          "origin",
          "binding",
          "definition",
          "environment",
          "adapterId",
          "execution",
          "status",
          "outcome",
          "phase",
          "revision",
          "etag",
          "startedAt",
          "completedAt",
          "lastUpdatedAt",
          "counts",
          "retry",
          "guidance",
          "steps",
          "checks"
        ],
        "properties": {
          "apiVersion": {
            "const": "modernedi.com/scenario-run-response/v1"
          },
          "kind": {
            "const": "graph"
          },
          "id": {
            "type": "string",
            "pattern": "^run-[0-9a-f-]+$"
          },
          "origin": {
            "enum": [
              "system_managed",
              "tenant_applied"
            ],
            "description": "Server-owned run origin. system_managed is reserved for the managed implementation-verification route; tenant_applied identifies an exact tenant-applied binding start."
          },
          "binding": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "revision",
              "contentSha256"
            ],
            "properties": {
              "id": {
                "$ref": "./schemas/scenario-binding-v1.schema.json#/$defs/token"
              },
              "revision": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "contentSha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            }
          },
          "definition": {
            "$ref": "#/components/schemas/DefinitionIdentity"
          },
          "environment": {
            "const": "production"
          },
          "adapterId": {
            "const": "scenario-graph-interpreter-v1"
          },
          "execution": {
            "$ref": "#/components/schemas/ScenarioGraphExecution"
          },
          "status": {
            "enum": [
              "active",
              "completed",
              "cancelled"
            ]
          },
          "outcome": {
            "enum": [
              "waiting",
              "passed",
              "failed",
              "inconclusive"
            ]
          },
          "phase": {
            "enum": [
              "observing",
              "complete",
              "binding_drifted",
              "reconciliation_pending"
            ]
          },
          "revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "etag": {
            "$ref": "#/components/schemas/ScenarioRunEtag"
          },
          "startedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastUpdatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "counts": {
            "$ref": "#/components/schemas/ScenarioGraphCounts"
          },
          "retry": {
            "$ref": "#/components/schemas/ScenarioGraphRetry"
          },
          "guidance": {
            "$ref": "#/components/schemas/ScenarioGraphGuidance"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioGraphStep"
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScenarioGraphCheck"
            }
          }
        }
      },
      "ScenarioOperation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "action",
          "disposition",
          "fromRevision",
          "toRevision"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,95}$"
          },
          "action": {
            "type": "string",
            "pattern": "^(start|cancel|attach_transaction|reevaluate_graph_clock|graph_(dispatch|reconcile)_[0-9]{3}_[0-9]{6})$",
            "description": "Opaque operation telemetry. Clients transition from the returned run, ETag, and guidance rather than parsing this value."
          },
          "disposition": {
            "enum": [
              "started",
              "advanced",
              "reconciled",
              "reconciliation_pending",
              "binding_drifted",
              "cancelled"
            ]
          },
          "fromRevision": {
            "type": "integer",
            "minimum": 0
          },
          "toRevision": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "ScenarioRunCommandResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "operation",
          "run"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "operation": {
            "$ref": "#/components/schemas/ScenarioOperation"
          },
          "run": {
            "$ref": "#/components/schemas/ScenarioRun"
          }
        }
      },
      "ScenarioRunViewResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "run"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "run": {
            "$ref": "#/components/schemas/ScenarioRun"
          }
        }
      },
      "ProductAccessErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "tenantId",
          "error",
          "runtimeAccessAllowed",
          "billingAttentionRequired",
          "serviceAccessState"
        ],
        "properties": {
          "success": {
            "const": false
          },
          "tenantId": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "error": {
            "type": "string"
          },
          "billingStatus": {
            "type": "string"
          },
          "runtimeAccessAllowed": {
            "type": "boolean"
          },
          "billingAttentionRequired": {
            "type": "boolean"
          },
          "serviceAccessState": {
            "type": "string"
          },
          "nextAction": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "code",
          "error",
          "retryable"
        ],
        "properties": {
          "success": {
            "const": false
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable error code. Scenario lifecycle codes include invalid_request, precondition_required, precondition_failed, etag_mismatch, authority_etag_mismatch, definition_identity_conflict, scenario_revision_conflict, idempotency_key_conflict, content_hash_mismatch, scenario_authoring_quota_exceeded, scenario_binding_no_change, and scenario_binding_not_executable. Run commands additionally expose their scenario_* operation and readiness codes."
          },
          "error": {
            "type": "string",
            "description": "Safe user-facing explanation with no secret or internal exception detail."
          },
          "retryable": {
            "type": "boolean"
          },
          "operationStatus": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Configured tenant boundary when a start rate or active-run quota rejects the request, or the fixed per-run durable-operation row/byte ceiling named by the error code."
          },
          "currentEtag": {
            "$ref": "#/components/schemas/StrongEtag"
          },
          "currentAuthorityEtag": {
            "$ref": "#/components/schemas/LifecycleEtag"
          },
          "run": {
            "$ref": "#/components/schemas/ScenarioRun"
          }
        }
      }
    }
  }
}
