{"record":{"id":"8c3a9f48e0f195ad","repo":"nautechsystems/nautilus_trader","slug":"retired-lighter-binding-conflicts-at-client-order","errorCode":null,"errorMessage":"retired Lighter binding conflicts at client_order_index {client_order_index} and venue order ID {venue_order_id}","messagePattern":"retired Lighter binding conflicts at client_order_index (.+?) and venue order ID (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":1342,"sourceCode":"                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);\n        } else {\n            if let Some(existing) = self.venue_id_map.get(&cloid) {\n                anyhow::ensure!(\n                    *existing.value() == venue_order_id,\n                    \"active Lighter order {cloid} conflicts with venue order ID {venue_order_id}\",\n                );\n            }\n\n            match self.cloid_map.entry(client_order_index) {\n                dashmap::mapref::entry::Entry::Vacant(entry) => {\n                    self.venue_id_map.insert(cloid, venue_order_id);\n                    self.order_identities.insert(cloid, identity);","sourceCodeStart":1324,"sourceCodeEnd":1360,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L1324-L1360","documentation":"When binding a brand-new (previously unseen cloid) terminal order, the code ensures no retired order is already bound to the same (client_order_index, venue_order_id) pair. A hit means two different cloids claim the same venue-side identity in the retired map — a hard conflict the adapter refuses to create.","triggerScenarios":"A terminal reconciliation event whose cloid is new but whose client_order_index + venue_order_id combination is already occupied by a different cloid in retired_orders.","commonSituations":"Client_order_id collisions across restarts (same index reused with different cloids), venue reusing order IDs, corrupted persisted state.","solutions":["Regenerate client order IDs so cloid↔client_order_index mapping is injective per session","Clear retired_orders and rebuild from authoritative venue state","Audit persisted order cache for duplicate (index, venue_id) pairs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if retired.cloid_for_venue(idx, vid).is_some() {\n    tracing::error!(\"venue identity {idx}/{vid} already bound to another cloid\");\n    full_reconcile_from_venue().await?;\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = bind_reconciliation(order, idx, vid, terminal).await {\n    if e.to_string().contains(\"retired Lighter binding conflicts\") {\n        rebuild_retired_map_from_venue().await?;\n        return Ok(());\n    }\n    return Err(e);\n}","preventionTips":["Ensure client_order_index is unique per cloid (injective mapping)","Audit persisted order caches for duplicate venue identities","Rebuild retired maps from venue state rather than trusting cross-session persistence"],"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-14T00:17:10.932Z"}