{"record":{"id":"0ecefa44252607e5","repo":"nautechsystems/nautilus_trader","slug":"retired-lighter-order-cloid-conflicts-with-recon","errorCode":null,"errorMessage":"retired Lighter order {cloid} conflicts with reconciliation binding","messagePattern":"retired Lighter order (.+?) conflicts with reconciliation binding","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":1330,"sourceCode":"            .get(&cloid)\n            .map(|entry| entry.value().clone())\n        {\n            anyhow::ensure!(\n                existing.client_order_index == client_order_index\n                    && existing.matches_venue_order_id(venue_order_id),\n                \"active Lighter order {cloid} conflicts with reconciliation binding\",\n            );\n\n            if terminal {\n                self.retire_order_identity(&cloid);\n            } else if order.is_triggered() == Some(true) {\n                self.mark_triggered_emitted(cloid);\n            }\n            return Ok(());\n        }\n\n        if let Some(existing) = self.retired_orders.identity_for_cloid(&cloid) {\n            anyhow::ensure!(\n                terminal\n                    && existing.client_order_index == client_order_index\n                    && existing.matches_venue_order_id(venue_order_id),\n                \"retired Lighter order {cloid} conflicts with reconciliation binding\",\n            );\n            return Ok(());\n        }\n\n        let identity = OrderIdentity::restored(order, client_order_index, venue_order_id);\n\n        if terminal {\n            anyhow::ensure!(\n                self.retired_orders\n                    .cloid_for_venue(client_order_index, venue_order_id)\n                    .is_none(),\n                \"retired Lighter binding conflicts at client_order_index {client_order_index} and venue order ID {venue_order_id}\",\n            );\n            self.retired_orders.insert(cloid, identity);","sourceCodeStart":1312,"sourceCodeEnd":1348,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L1312-L1348","documentation":"If the cloid is already recorded in retired_orders, the new binding is only acceptable when the event is terminal and both client_order_index and venue order ID match the stored identity. Any other combination — e.g. a non-terminal update for an already-retired order, or mismatched identity — trips this ensure!.","triggerScenarios":"A non-terminal (open/amend) venue event arrives for a cloid already retired, or a terminal event for a retired cloid carrying a different client_order_index/venue_order_id.","commonSituations":"Duplicate/delayed events after terminal fill, event replays, cache restored from persistence with stale identities.","solutions":["Check for late/duplicate events and drop them before reconciliation","Re-reconcile the order's true state from the venue API","Ensure persistence restore writes correct client_order_index and venue_order_id"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if retired.identity_for_cloid(&cloid).is_some() && !terminal {\n    tracing::warn!(\"ignoring non-terminal event for retired order {cloid}\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = bind_reconciliation(order, idx, vid, terminal).await {\n    if e.to_string().contains(\"retired Lighter order\") {\n        tracing::warn!(\"stale/duplicate event for retired order; ignoring: {e}\");\n        return Ok(());\n    }\n    return Err(e);\n}","preventionTips":["Filter duplicate and out-of-order events before reconciliation","Persist retired identities with correct indices and venue IDs","Re-fetch authoritative state when a retired order receives fresh events"],"tags":["rust","websocket","reconciliation","conflict"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}