{"record":{"id":"14a769b7244ed203","repo":"nautechsystems/nautilus_trader","slug":"active-lighter-order-cloid-conflicts-with-reconc","errorCode":null,"errorMessage":"active Lighter order {cloid} conflicts with reconciliation binding","messagePattern":"active Lighter order (.+?) conflicts with reconciliation binding","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":1315,"sourceCode":"        venue_order_id: VenueOrderId,\n        terminal: bool,\n    ) -> anyhow::Result<()> {\n        let cloid = order.client_order_id();\n        anyhow::ensure!(\n            order.venue_order_id() == Some(venue_order_id),\n            \"cached Lighter order {cloid} does not match venue order ID {venue_order_id}\",\n        );\n        anyhow::ensure!(\n            (0..=i64::from(CLOID_INDEX_MAX)).contains(&client_order_index),\n            \"Lighter client_order_index {client_order_index} is outside the venue-safe range\",\n        );\n\n        if let Some(existing) = self\n            .order_identities\n            .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),","sourceCodeStart":1297,"sourceCodeEnd":1333,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L1297-L1333","documentation":"When a cached active order exists for the cloid, the reconciliation binding must agree on both client_order_index and venue order ID. If the new binding disagrees with the stored OrderIdentity, ensure! fails — a conflicting identity would otherwise silently corrupt the order map.","triggerScenarios":"Rebinding an active order whose stored client_order_index or venue_order_id differs from the values in the current reconciliation event (e.g. duplicate cloid, wrong event routed, or cache poisoned by an earlier bad bind).","commonSituations":"Two orders sharing a client_order_id, stale in-memory state after reconnect, replayed events from a previous session.","solutions":["Inspect the conflicting OrderIdentity vs the event values in the message context","Purge the conflicting cloid from order_identities and re-reconcile from venue state","Guarantee unique client_order_ids per session"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if let Some(existing) = state.identity_for(&cloid) {\n    if existing.client_order_index != idx || !existing.matches_venue_order_id(vid) {\n        tracing::error!(\"conflict for {cloid}; rebuilding state\");\n        full_reconcile_from_venue().await?;\n    }\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = bind_reconciliation(order, idx, vid, terminal).await {\n    if e.to_string().contains(\"conflicts with reconciliation binding\") {\n        purge_cloid(&cloid);\n        full_reconcile_from_venue().await?;\n        return Ok(());\n    }\n    return Err(e);\n}","preventionTips":["Guarantee client_order_id uniqueness across sessions","Re-reconcile from venue state after reconnects instead of trusting stale maps","Detect and log duplicate client_order_id generation early"],"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"}