{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "GlemO Launch Conversion - Candidate Evidence Projection",
    "version": "0.1.0-candidate",
    "description": "CANDIDATE ONLY. Not a deployed API or implemented backend/security. Parent integrates. Reference model records are illustrative evidence only, not executed transactions or collected revenue. This interface projects existing native records; no RFQ/order creation, custody, provider calls, signing, reservations, transfers or live instruction dispatch. existing.* SQL names are logical binding prerequisites. All LC-PG production gates remain unsatisfied by this handoff."
  },
  "servers": [
    {
      "url": "https://conversion-candidate.invalid",
      "description": "Documentation placeholder only; no deployed endpoint."
    }
  ],
  "security": [
    {
      "candidateBearer": []
    }
  ],
  "x-status": "candidate_specs_not_deployed_backend",
  "x-contract": "conversion-contract.json",
  "x-production-gates": [
    "LC-PG001",
    "LC-PG002",
    "LC-PG003",
    "LC-PG004",
    "LC-PG005",
    "LC-PG006",
    "LC-PG007"
  ],
  "x-concurrency": "All POSTs require Idempotency-Key. Case commands require expectedVersion and matching strong If-Match. Authorize reads/replay first; exact replay returns stored original status/body/ETag before stale-version checking. Fingerprint tenant, authenticated actor, operation, target and full canonical body. Conflicting key reuse is 409. Commit projection, append-only decision and response receipt atomically. Source references are verified by the receiver, never trusted client authority.",
  "x-production-provenance": "New progression must consume authenticated native negotiation, external settlement and independent reconciliation events. Browser role/confirm/gate booleans or manually supplied stage labels cannot establish authority. No request accepts actor identity, role, resulting stage, matches or allocation as truth. Historical evidence recording does not authorize a new external action or clear a native exception.",
  "paths": {
    "/tenants/{tenantId}/launch/conversion/observations": {
      "parameters": [
        {
          "$ref": "#/components/parameters/TenantId"
        }
      ],
      "post": {
        "operationId": "recordConversionObservationCandidate",
        "summary": "Record first eligible observation attribution",
        "description": "Authenticated eligibility/first-touch projection only. Server fixes UTC cohort time from verified source. A later observation never changes existing first touch. No page beacon is sent by these artifacts.",
        "x-requirement-ids": [
          "LC-R001",
          "LC-R003",
          "LC-R005",
          "LC-R012"
        ],
        "x-test-ids": [
          "LC-T001",
          "LC-T003",
          "LC-T005",
          "LC-T013"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ObservationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Original immutable cohort, also for duplicate observation with a fresh request key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CohortResponse"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/tenants/{tenantId}/launch/conversion/cases": {
      "parameters": [
        {
          "$ref": "#/components/parameters/TenantId"
        }
      ],
      "post": {
        "operationId": "attachExistingInterestCandidate",
        "summary": "Attach an existing non-binding Launch interest",
        "description": "Resolve existing interest, campaign revision, offer and identity snapshot. Copy exact ticket/currency from native interest. Use existing cohort or create immutable interest-time cohort if no observation exists. No new native interest, RFQ, order or reservation. Preserve native active-interest/reconfirmation rules. New-key duplicate case/cohort/interest returns 409.",
        "x-requirement-ids": [
          "LC-R002",
          "LC-R003",
          "LC-R012"
        ],
        "x-test-ids": [
          "LC-T002",
          "LC-T003",
          "LC-T013"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCaseInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Version 1 interested projection, or exact original response replay.",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseResponse"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/tenants/{tenantId}/launch/conversion/cases/{caseId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/TenantId"
        },
        {
          "$ref": "#/components/parameters/CaseId"
        }
      ],
      "get": {
        "operationId": "getConversionCaseCandidate",
        "summary": "Read authorized conversion evidence projection",
        "description": "Tenant path is a selector, never permission. Resolve case/resource permissions before disclosure. Responses use opaque references; private native evidence remains in its owner.",
        "x-requirement-ids": [
          "LC-R002",
          "LC-R016"
        ],
        "x-test-ids": [
          "LC-T002",
          "LC-T017"
        ],
        "responses": {
          "200": {
            "description": "Current projection with version ETag.",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseResponse"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/tenants/{tenantId}/launch/conversion/cases/{caseId}/commands": {
      "parameters": [
        {
          "$ref": "#/components/parameters/TenantId"
        },
        {
          "$ref": "#/components/parameters/CaseId"
        }
      ],
      "post": {
        "operationId": "applyConversionEvidenceCommandCandidate",
        "summary": "Apply one authorized evidence-backed projection command",
        "description": "No generic set-stage operation. Derive actor and role from authenticated context, validate native record ownership/current versions/provenance and defined state transitions. Success increments case version exactly once; rejection retains a minimized audit decision without state advance. Delivery mismatch is a successful evidence record yielding exception and zero recognized principal/fee. 'instruct' records existing instruction evidence and never dispatches it. 'link' only adds attribution.",
        "x-requirement-ids": [
          "LC-R004",
          "LC-R005",
          "LC-R006",
          "LC-R007",
          "LC-R008",
          "LC-R009",
          "LC-R012",
          "LC-R013",
          "LC-R014",
          "LC-R015"
        ],
        "x-test-ids": [
          "LC-T004",
          "LC-T005",
          "LC-T006",
          "LC-T007",
          "LC-T008",
          "LC-T009",
          "LC-T010",
          "LC-T013",
          "LC-T014",
          "LC-T015",
          "LC-T016"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Command"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated illustrative projection, or stored original response on exact replay.",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaseResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "412": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "428": {
            "$ref": "#/components/responses/Error"
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/tenants/{tenantId}/launch/conversion/cases/{caseId}/events": {
      "parameters": [
        {
          "$ref": "#/components/parameters/TenantId"
        },
        {
          "$ref": "#/components/parameters/CaseId"
        }
      ],
      "get": {
        "operationId": "listConversionEventsCandidate",
        "summary": "Read authorized append-only decision history",
        "description": "Include applied/rejected decisions, failed reconciliation and corrections. No private evidence bytes or buyer criteria. Cursor is opaque; order by recordedAt then eventId. History is illustrative until production provenance gates are met.",
        "x-requirement-ids": [
          "LC-R013",
          "LC-R015"
        ],
        "x-test-ids": [
          "LC-T014",
          "LC-T016"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 500
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Minimized decision history.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventPage"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/tenants/{tenantId}/launch/conversion/metrics": {
      "parameters": [
        {
          "$ref": "#/components/parameters/TenantId"
        }
      ],
      "get": {
        "operationId": "getConversionMetricsCandidate",
        "summary": "Read illustrative metrics within one immutable UTC cohort scope",
        "description": "Filter cohortAt, not later event time. Unique cumulative stage counts differ from current stages. Rates use cohort-set intersections. Null denotes unavailable denominators or costs; actual cash/revenue/volume/profit remain null. Recognition requires independently reconciled matching evidence and no unresolved native exception. This is not demand validation or a forecast.",
        "x-requirement-ids": [
          "LC-R008",
          "LC-R010",
          "LC-R011"
        ],
        "x-test-ids": [
          "LC-T008",
          "LC-T009",
          "LC-T011",
          "LC-T012"
        ],
        "parameters": [
          {
            "name": "campaignId",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Channel"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive UTC cohort date; reject invalid/reversed range.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive UTC cohort date; use exclusive following-day midnight in storage.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Illustrative cohort metrics with exact values and coverage labels.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metrics"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "candidateBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Candidate server authentication requirement only. No token issuer, verifier, tenant authorization, role enforcement or security service is implemented by this document."
      }
    },
    "parameters": {
      "TenantId": {
        "name": "tenantId",
        "in": "path",
        "required": true,
        "description": "Opaque tenant selector. Membership and permissions must be verified server-side.",
        "schema": {
          "$ref": "#/components/schemas/Id"
        }
      },
      "CaseId": {
        "name": "caseId",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/Id"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Tenant-scoped immutable response receipt key. Same actor/operation/target/body replays original response; conflicting reuse is 409.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      },
      "IfMatch": {
        "name": "If-Match",
        "in": "header",
        "required": true,
        "description": "Strong case ETag, for example \"v7\". Must agree with expectedVersion and locked current version. Missing: 428; mismatch: 412. Exact authorized idempotent replay precedes this check.",
        "schema": {
          "type": "string",
          "pattern": "^\"v[1-9][0-9]*\"$"
        }
      }
    },
    "headers": {
      "ETag": {
        "description": "Strong version ETag bound to this response snapshot; original ETag is retained on replay.",
        "schema": {
          "type": "string",
          "pattern": "^\"v[1-9][0-9]*\"$"
        }
      }
    },
    "responses": {
      "Error": {
        "description": "400 invalid shape/decimals/header disagreement; 401 unauthenticated; 403 unauthorized actor/tenant; 404 missing or concealed resource; 409 duplicate cohort, request or source conflict; 412 stale version; 422 blocked transition, stale offer, missing evidence, link mismatch or failed reconciliation; 428 missing If-Match. Do not disclose inaccessible resource existence. A failed command does not advance stage/version.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Id": {
        "type": "string",
        "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,149}$",
        "description": "Opaque synthetic identifier in reference use; not private evidence or a payment address."
      },
      "Version": {
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "Instant": {
        "type": "string",
        "format": "date-time",
        "pattern": "Z$",
        "description": "Normalized UTC instant, including fractional seconds if present."
      },
      "MoneyInput": {
        "type": "string",
        "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,2})?$",
        "not": {
          "enum": [
            "0",
            "0.0",
            "0.00"
          ]
        },
        "description": "Positive exact USD decimal string, maximum 12 integer and 2 fractional digits. Never a JSON number or exponent."
      },
      "Units": {
        "type": "string",
        "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,8})?$",
        "not": {
          "pattern": "^0(\\.0{1,8})?$"
        },
        "description": "Positive exact quantity; principal product must be exactly representable in cents."
      },
      "Amount": {
        "type": "string",
        "pattern": "^(0|[1-9][0-9]{0,13})(\\.[0-9]{1,2})?$",
        "description": "Nonnegative exact computed USD amount; separate wider bound permits fee-inclusive totals."
      },
      "Decimal": {
        "type": "string",
        "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$",
        "description": "Exact nonnegative decimal string for aggregate values."
      },
      "Channel": {
        "type": "string",
        "enum": [
          "curated_invite",
          "seller_referral",
          "advisor",
          "event",
          "organic",
          "unknown"
        ]
      },
      "Stage": {
        "type": "string",
        "enum": [
          "interested",
          "reviewed",
          "negotiating",
          "agreed",
          "external_pending",
          "delivered",
          "reconciled",
          "lost",
          "withdrawn",
          "exception"
        ]
      },
      "Party": {
        "type": "string",
        "enum": [
          "buyer",
          "seller"
        ]
      },
      "AgentPayer": {
        "type": "string",
        "enum": [
          "buyer",
          "seller",
          "none"
        ]
      },
      "EvidenceRef": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "evidenceId",
          "evidenceVersion"
        ],
        "properties": {
          "evidenceId": {
            "$ref": "#/components/schemas/Id"
          },
          "evidenceVersion": {
            "$ref": "#/components/schemas/Version"
          }
        },
        "description": "Reference to existing tenant-scoped evidence version; receiver verifies provenance, scope, expiry/revocation and access. A string is not proof."
      },
      "SourceRef": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "service",
          "eventId",
          "version",
          "occurredAt",
          "evidence"
        ],
        "properties": {
          "service": {
            "type": "string",
            "enum": [
              "launch_review",
              "native_negotiation",
              "external_settlement",
              "independent_reconciliation",
              "native_identity",
              "acquisition_evidence"
            ]
          },
          "eventId": {
            "$ref": "#/components/schemas/Id"
          },
          "version": {
            "$ref": "#/components/schemas/Version"
          },
          "occurredAt": {
            "$ref": "#/components/schemas/Instant"
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Candidate authenticated native event envelope. Evidence retains the complete minimized native decision and action-specific evidence references, including all review gates and rejected reconciliation attempts. Sender/service claims alone are insufficient; verify emitter, ordering, duplicates/conflicts and records. Source version is independent of expectedVersion. An already applied verified source reuses its original result without another advance."
      },
      "ObservationInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "campaignId",
          "offerId",
          "offerVersion",
          "buyerId",
          "buyerRevision",
          "sellerId",
          "policyVersion",
          "snapshotEvidence",
          "channel",
          "source"
        ],
        "properties": {
          "campaignId": {
            "$ref": "#/components/schemas/Id"
          },
          "offerId": {
            "$ref": "#/components/schemas/Id"
          },
          "offerVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "buyerId": {
            "$ref": "#/components/schemas/Id"
          },
          "buyerRevision": {
            "$ref": "#/components/schemas/Version"
          },
          "sellerId": {
            "$ref": "#/components/schemas/Id"
          },
          "policyVersion": {
            "$ref": "#/components/schemas/Id"
          },
          "snapshotEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "source": {
            "$ref": "#/components/schemas/SourceRef"
          }
        }
      },
      "CreateCaseInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "interestId",
          "campaignId",
          "offerId",
          "offerVersion",
          "buyerId",
          "buyerRevision",
          "sellerId",
          "policyVersion",
          "snapshotEvidence",
          "channel",
          "source"
        ],
        "properties": {
          "interestId": {
            "$ref": "#/components/schemas/Id"
          },
          "campaignId": {
            "$ref": "#/components/schemas/Id"
          },
          "offerId": {
            "$ref": "#/components/schemas/Id"
          },
          "offerVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "buyerId": {
            "$ref": "#/components/schemas/Id"
          },
          "buyerRevision": {
            "$ref": "#/components/schemas/Version"
          },
          "sellerId": {
            "$ref": "#/components/schemas/Id"
          },
          "policyVersion": {
            "$ref": "#/components/schemas/Id"
          },
          "snapshotEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "source": {
            "$ref": "#/components/schemas/SourceRef"
          }
        },
        "description": "All fields must match existing native interest and authoritative snapshots. Existing cohort first-touch wins over supplied channel. No ticket or amount inferred/overwritten from this request."
      },
      "CommandBase": {
        "type": "object",
        "required": [
          "expectedVersion",
          "source",
          "action",
          "input"
        ],
        "properties": {
          "expectedVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "source": {
            "$ref": "#/components/schemas/SourceRef"
          },
          "action": {
            "type": "string"
          },
          "input": {
            "type": "object"
          }
        },
        "description": "Server derives actor/role; confirmation acknowledgement is illustrative only. Reject extra stage/actor/allocation fields. State, native source and eligibility checks remain production requirements."
      },
      "Command": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/ReviewCommand"
          },
          {
            "$ref": "#/components/schemas/ProposeCommand"
          },
          {
            "$ref": "#/components/schemas/ConfirmCommand"
          },
          {
            "$ref": "#/components/schemas/AgreementCommand"
          },
          {
            "$ref": "#/components/schemas/InstructCommand"
          },
          {
            "$ref": "#/components/schemas/DeliverCommand"
          },
          {
            "$ref": "#/components/schemas/CorrectCommand"
          },
          {
            "$ref": "#/components/schemas/ReconcileCommand"
          },
          {
            "$ref": "#/components/schemas/WithdrawCommand"
          },
          {
            "$ref": "#/components/schemas/CloseCommand"
          },
          {
            "$ref": "#/components/schemas/LinkCommand"
          },
          {
            "$ref": "#/components/schemas/CostCommand"
          }
        ]
      },
      "ReviewCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "review"
              },
              "input": {
                "$ref": "#/components/schemas/ReviewInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "ProposeCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "propose"
              },
              "input": {
                "$ref": "#/components/schemas/ProposalInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "ConfirmCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "confirm"
              },
              "input": {
                "$ref": "#/components/schemas/ConfirmationInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "AgreementCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "agreement"
              },
              "input": {
                "$ref": "#/components/schemas/AgreementInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "InstructCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "instruct"
              },
              "input": {
                "$ref": "#/components/schemas/InstructionInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "DeliverCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "deliver"
              },
              "input": {
                "$ref": "#/components/schemas/DeliveryInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "CorrectCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "correct"
              },
              "input": {
                "$ref": "#/components/schemas/CorrectionInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "ReconcileCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "reconcile"
              },
              "input": {
                "$ref": "#/components/schemas/ReconciliationInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "WithdrawCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "withdraw"
              },
              "input": {
                "$ref": "#/components/schemas/DropInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "CloseCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "close"
              },
              "input": {
                "$ref": "#/components/schemas/DropInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "LinkCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "link"
              },
              "input": {
                "$ref": "#/components/schemas/LinkInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "CostCommand": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CommandBase"
          },
          {
            "properties": {
              "action": {
                "const": "cost"
              },
              "input": {
                "$ref": "#/components/schemas/CostInput"
              }
            }
          }
        ],
        "unevaluatedProperties": false
      },
      "Gate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "checked",
          "evidence"
        ],
        "properties": {
          "checked": {
            "const": true
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Recorded review assertion with evidence; receiver must recheck current gate. Boolean alone is not verified authority."
      },
      "ReviewInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "gates",
          "reviewEvidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "reviewEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          },
          "gates": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "authority",
              "eligibility",
              "inventory",
              "promotion",
              "mapping"
            ],
            "properties": {
              "authority": {
                "$ref": "#/components/schemas/Gate"
              },
              "eligibility": {
                "$ref": "#/components/schemas/Gate"
              },
              "inventory": {
                "$ref": "#/components/schemas/Gate"
              },
              "promotion": {
                "$ref": "#/components/schemas/Gate"
              },
              "mapping": {
                "$ref": "#/components/schemas/Gate"
              }
            }
          }
        }
      },
      "ProposalInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "quoteId",
          "quoteVersion",
          "quantity",
          "unitPrice",
          "currency",
          "feePayer",
          "agentPayer",
          "evidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "quoteId": {
            "$ref": "#/components/schemas/Id"
          },
          "quoteVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "quantity": {
            "$ref": "#/components/schemas/Units"
          },
          "unitPrice": {
            "$ref": "#/components/schemas/MoneyInput"
          },
          "currency": {
            "const": "USD"
          },
          "feePayer": {
            "$ref": "#/components/schemas/Party"
          },
          "agentPayer": {
            "$ref": "#/components/schemas/AgentPayer"
          },
          "agentContractEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "agentPayer": {
                  "const": "none"
                }
              }
            },
            "then": {
              "not": {
                "required": [
                  "agentContractEvidence"
                ]
              }
            },
            "else": {
              "required": [
                "agentContractEvidence"
              ]
            }
          }
        ],
        "description": "Validate exact native quote/party/currency/terms, compute principal and new proposal version. No agreement may exist. Counter returns negotiating and invalidates earlier confirmation. Principal must be exact cents in current minimum/capacity. Fee policy: 1.2% GlemO, 0.2% estimated gateway, optional additional 1% agent, each half-up cents."
      },
      "ConfirmationInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "proposalVersion",
          "evidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "proposalVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Only the other authenticated party can confirm exactly the current proposal. Does not sign an agreement or create an order."
      },
      "AgreementInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "proposalVersion",
          "agreementId",
          "evidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "proposalVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "agreementId": {
            "$ref": "#/components/schemas/Id"
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Reviewer records a distinct already existing external agreement bound to current confirmed terms. Reference-model role choice; parent must resolve journey wording before production."
      },
      "InstructionInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "orderId",
          "instructionId",
          "network",
          "destinationRef",
          "evidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "orderId": {
            "$ref": "#/components/schemas/Id"
          },
          "instructionId": {
            "$ref": "#/components/schemas/Id"
          },
          "network": {
            "$ref": "#/components/schemas/Id"
          },
          "destinationRef": {
            "$ref": "#/components/schemas/Id"
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Rails records existing external evidence only, after reviewed agreement. destinationRef is an opaque private evidence reference, not an address or dispatch authorization."
      },
      "DeliveryFields": {
        "type": "object",
        "required": [
          "confirm",
          "deliveryId",
          "receivedPrincipal",
          "receivedQuantity",
          "network",
          "destinationRef",
          "paymentEvidence",
          "assetEvidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "deliveryId": {
            "$ref": "#/components/schemas/Id"
          },
          "receivedPrincipal": {
            "$ref": "#/components/schemas/MoneyInput"
          },
          "receivedQuantity": {
            "$ref": "#/components/schemas/Units"
          },
          "network": {
            "$ref": "#/components/schemas/Id"
          },
          "destinationRef": {
            "$ref": "#/components/schemas/Id"
          },
          "paymentEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          },
          "assetEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        }
      },
      "DeliveryInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DeliveryFields"
          }
        ],
        "unevaluatedProperties": false,
        "description": "Receiver compares principal, quantity, network and destination to current accepted proposal/instruction. Any mismatch records exception with zero recognition. No client matches flag."
      },
      "CorrectionInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DeliveryFields"
          },
          {
            "required": [
              "priorDeliveryId",
              "reason"
            ],
            "properties": {
              "priorDeliveryId": {
                "$ref": "#/components/schemas/Id"
              },
              "reason": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "description": "Exception only, append corrected evidence for a new delivery ID, referencing latest failed attempt in this case. Preserve original mismatch and reason; mismatching correction remains exception."
      },
      "ReconciliationInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "reconciliationId",
          "deliveryId",
          "paymentChecked",
          "assetChecked",
          "evidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "reconciliationId": {
            "$ref": "#/components/schemas/Id"
          },
          "deliveryId": {
            "$ref": "#/components/schemas/Id"
          },
          "paymentChecked": {
            "const": true
          },
          "assetChecked": {
            "const": true
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Verified auditor distinct from parties, instruction operator and delivery reporter. Require latest four-field matching delivery, both native receipt legs and no unresolved native exception. Compute allocation server-side; supplied checks alone are insufficient. Failed reconciliation remains in audit and contributes zero."
      },
      "DropInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "dropReason",
          "reason",
          "evidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "dropReason": {
            "type": "string",
            "enum": [
              "changed_terms",
              "ticket_fit",
              "documents_gap",
              "timing",
              "eligibility",
              "other"
            ]
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Explicit buyer withdrawal or reviewer closure, before external agreement; never inferred from inactivity."
      },
      "LinkInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "platformOfferId",
          "platformBuyerId",
          "discussionId",
          "mappingEvidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "platformOfferId": {
            "$ref": "#/components/schemas/Id"
          },
          "platformBuyerId": {
            "$ref": "#/components/schemas/Id"
          },
          "discussionId": {
            "$ref": "#/components/schemas/Id"
          },
          "mappingEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Validate current case/offer version, tenant, buyer, seller, native discussion participants and mapping. Reviewer only in reviewed/negotiating/agreed. Attribution only: never creates RFQ/order or accepts terms. Navigation URL carries only opaque case ID, no buyer/ticket data."
      },
      "CostInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirm",
          "costRef",
          "observedCost",
          "currency",
          "evidence"
        ],
        "properties": {
          "confirm": {
            "const": true
          },
          "costRef": {
            "$ref": "#/components/schemas/Id"
          },
          "observedCost": {
            "$ref": "#/components/schemas/MoneyInput"
          },
          "currency": {
            "const": "USD"
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          }
        },
        "description": "Unique tenant costRef, positive observed acquisition cost; inherits case campaign/channel/cohort. No absent-cost zero, invented estimate or company forecast change."
      },
      "Cohort": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "tenantId",
          "cohortId",
          "campaignId",
          "offerId",
          "offerVersion",
          "buyerId",
          "buyerRevision",
          "sellerId",
          "policyVersion",
          "snapshotEvidence",
          "cohortAt",
          "channel",
          "eligibleObserved"
        ],
        "properties": {
          "tenantId": {
            "$ref": "#/components/schemas/Id"
          },
          "cohortId": {
            "$ref": "#/components/schemas/Id"
          },
          "campaignId": {
            "$ref": "#/components/schemas/Id"
          },
          "offerId": {
            "$ref": "#/components/schemas/Id"
          },
          "offerVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "buyerId": {
            "$ref": "#/components/schemas/Id"
          },
          "buyerRevision": {
            "$ref": "#/components/schemas/Version"
          },
          "sellerId": {
            "$ref": "#/components/schemas/Id"
          },
          "policyVersion": {
            "$ref": "#/components/schemas/Id"
          },
          "snapshotEvidence": {
            "$ref": "#/components/schemas/EvidenceRef"
          },
          "cohortAt": {
            "$ref": "#/components/schemas/Instant"
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "eligibleObserved": {
            "type": "boolean"
          }
        }
      },
      "CohortResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "status",
          "evidenceClass",
          "cohort"
        ],
        "properties": {
          "status": {
            "const": "candidate_projection"
          },
          "evidenceClass": {
            "const": "illustrative_reference_evidence"
          },
          "cohort": {
            "$ref": "#/components/schemas/Cohort"
          }
        }
      },
      "Case": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "caseId",
          "interestId",
          "cohort",
          "version",
          "stage",
          "ticket",
          "currency",
          "reached",
          "createdAt",
          "updatedAt",
          "currentProposalVersion",
          "agreementId",
          "latestDeliveryId",
          "allocation"
        ],
        "properties": {
          "caseId": {
            "$ref": "#/components/schemas/Id"
          },
          "interestId": {
            "$ref": "#/components/schemas/Id"
          },
          "cohort": {
            "$ref": "#/components/schemas/Cohort"
          },
          "version": {
            "$ref": "#/components/schemas/Version"
          },
          "stage": {
            "$ref": "#/components/schemas/Stage"
          },
          "ticket": {
            "$ref": "#/components/schemas/MoneyInput"
          },
          "currency": {
            "const": "USD"
          },
          "reached": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "interested",
                "reviewed",
                "negotiating",
                "agreed",
                "external_pending",
                "delivered",
                "reconciled"
              ]
            }
          },
          "createdAt": {
            "$ref": "#/components/schemas/Instant"
          },
          "updatedAt": {
            "$ref": "#/components/schemas/Instant"
          },
          "currentProposalVersion": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Version"
              },
              {
                "type": "null"
              }
            ]
          },
          "agreementId": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "latestDeliveryId": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "allocation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Allocation"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "description": "Current projection; reached derives from applied events. cohort.eligibleObserved derives from applied observe events and can reflect a later view without changing immutable cohort time/channel. Allocation is null until independent reconciliation; totals remain illustrative, not cash/revenue. Retained native source evidence shows proposal versions, corrections, review gates and drop reasons."
      },
      "CaseResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "status",
          "evidenceClass",
          "record"
        ],
        "properties": {
          "status": {
            "const": "candidate_projection"
          },
          "evidenceClass": {
            "const": "illustrative_reference_evidence"
          },
          "record": {
            "$ref": "#/components/schemas/Case"
          }
        }
      },
      "Allocation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "principal",
          "buyerPays",
          "sellerReceives",
          "glemoFee",
          "gatewayEstimate",
          "agentFee",
          "feePayer",
          "agentPayer",
          "actualCashReceived",
          "profit"
        ],
        "properties": {
          "principal": {
            "$ref": "#/components/schemas/MoneyInput"
          },
          "buyerPays": {
            "$ref": "#/components/schemas/Amount"
          },
          "sellerReceives": {
            "$ref": "#/components/schemas/Amount"
          },
          "glemoFee": {
            "$ref": "#/components/schemas/Amount"
          },
          "gatewayEstimate": {
            "$ref": "#/components/schemas/Amount"
          },
          "agentFee": {
            "$ref": "#/components/schemas/Amount"
          },
          "feePayer": {
            "$ref": "#/components/schemas/Party"
          },
          "agentPayer": {
            "$ref": "#/components/schemas/AgentPayer"
          },
          "actualCashReceived": {
            "type": "null"
          },
          "profit": {
            "type": "null"
          }
        },
        "description": "Exact nonnegative values: buyerPays = sellerReceives + glemoFee + gatewayEstimate + agentFee. Independently half-up round 1%, estimated 0.2%, optional additional 1%. Gross fee is not profit/cash; third-party allocations are not GlemO revenue. No tax/FX/gas inferred."
      },
      "Event": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "eventId",
          "caseId",
          "action",
          "outcome",
          "beforeVersion",
          "afterVersion",
          "stage",
          "rejectionCode",
          "source",
          "recordedAt"
        ],
        "properties": {
          "eventId": {
            "$ref": "#/components/schemas/Id"
          },
          "caseId": {
            "$ref": "#/components/schemas/Id"
          },
          "action": {
            "type": "string",
            "enum": [
              "interest",
              "review",
              "propose",
              "confirm",
              "agreement",
              "instruct",
              "deliver",
              "correct",
              "reconcile",
              "withdraw",
              "close",
              "link",
              "cost"
            ]
          },
          "outcome": {
            "type": "string",
            "enum": [
              "applied",
              "rejected"
            ]
          },
          "beforeVersion": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Version"
              },
              {
                "type": "null"
              }
            ]
          },
          "afterVersion": {
            "$ref": "#/components/schemas/Version"
          },
          "stage": {
            "$ref": "#/components/schemas/Stage"
          },
          "rejectionCode": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 150
          },
          "source": {
            "$ref": "#/components/schemas/SourceRef"
          },
          "recordedAt": {
            "$ref": "#/components/schemas/Instant"
          }
        }
      },
      "EventPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "evidenceClass",
          "events",
          "nextCursor"
        ],
        "properties": {
          "evidenceClass": {
            "const": "illustrative_reference_evidence"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          }
        }
      },
      "Rational": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "numerator",
          "denominator"
        ],
        "properties": {
          "numerator": {
            "$ref": "#/components/schemas/Decimal"
          },
          "denominator": {
            "type": "string",
            "pattern": "^[1-9][0-9]*$"
          }
        },
        "description": "Exact ratio, including non-terminating fractions; decimal-string numerator and positive integer-string denominator. Display rounding is separate."
      },
      "FunnelRow": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stage",
          "count",
          "previousRate"
        ],
        "properties": {
          "stage": {
            "type": "string",
            "enum": [
              "eligible_view",
              "interested",
              "reviewed",
              "negotiating",
              "agreed",
              "external_pending",
              "delivered",
              "reconciled"
            ]
          },
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "previousRate": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Rational"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "description": "Unique cumulative cohort count; ratio numerator is intersection with previous-stage cohort set, denominator is previous count; first row and zero denominator are null."
      },
      "Metrics": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "evidenceClass",
          "currency",
          "funnel",
          "currentCounts",
          "illustrativePrincipal",
          "illustrativeGrossGlemoFee",
          "recordedCost",
          "costCoverage",
          "costPerInterest",
          "costPerReconciledCase",
          "actualVolume",
          "actualRevenue",
          "actualCashReceived",
          "profit"
        ],
        "properties": {
          "evidenceClass": {
            "const": "illustrative_reference_evidence"
          },
          "currency": {
            "const": "USD"
          },
          "funnel": {
            "type": "array",
            "minItems": 8,
            "maxItems": 8,
            "items": {
              "$ref": "#/components/schemas/FunnelRow"
            }
          },
          "currentCounts": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "interested",
              "reviewed",
              "negotiating",
              "agreed",
              "external_pending",
              "delivered",
              "reconciled",
              "lost",
              "withdrawn",
              "exception"
            ],
            "properties": {
              "interested": {
                "type": "integer",
                "minimum": 0
              },
              "reviewed": {
                "type": "integer",
                "minimum": 0
              },
              "negotiating": {
                "type": "integer",
                "minimum": 0
              },
              "agreed": {
                "type": "integer",
                "minimum": 0
              },
              "external_pending": {
                "type": "integer",
                "minimum": 0
              },
              "delivered": {
                "type": "integer",
                "minimum": 0
              },
              "reconciled": {
                "type": "integer",
                "minimum": 0
              },
              "lost": {
                "type": "integer",
                "minimum": 0
              },
              "withdrawn": {
                "type": "integer",
                "minimum": 0
              },
              "exception": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "illustrativePrincipal": {
            "$ref": "#/components/schemas/Decimal"
          },
          "illustrativeGrossGlemoFee": {
            "$ref": "#/components/schemas/Decimal"
          },
          "recordedCost": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Decimal"
              },
              {
                "type": "null"
              }
            ]
          },
          "costCoverage": {
            "const": "recorded_evidence_only_completeness_not_asserted"
          },
          "costPerInterest": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Rational"
              },
              {
                "type": "null"
              }
            ]
          },
          "costPerReconciledCase": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Rational"
              },
              {
                "type": "null"
              }
            ]
          },
          "actualVolume": {
            "type": "null"
          },
          "actualRevenue": {
            "type": "null"
          },
          "actualCashReceived": {
            "type": "null"
          },
          "profit": {
            "type": "null"
          }
        }
      },
      "Problem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "title",
          "status",
          "code",
          "correlationId"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599
          },
          "code": {
            "type": "string",
            "enum": [
              "invalid",
              "required",
              "unauthenticated",
              "forbidden",
              "missing",
              "duplicate",
              "idempotencyConflict",
              "sourceConflict",
              "sourceOrder",
              "stale",
              "offerChanged",
              "transition",
              "linkMismatch",
              "reconciliationFailed",
              "preconditionRequired",
              "unavailable"
            ]
          },
          "correlationId": {
            "$ref": "#/components/schemas/Id"
          }
        },
        "description": "Minimized error; no private buyer, ticket, evidence or provider details. Auditable operational failures and authorization denials must be retained under reviewed privacy controls, not manufactured into successful stage events."
      }
    }
  }
}
