dexbot 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +3 -3
  3. package/analysis/README.md +33 -13
  4. package/claw/package.json +1 -1
  5. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  6. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  7. package/dist/analysis/account_resolver.js +5 -6
  8. package/dist/analysis/analyze_liquidity.js +15 -4
  9. package/dist/analysis/bot_key_utils.d.ts +44 -1
  10. package/dist/analysis/bot_key_utils.js +76 -7
  11. package/dist/analysis/fills_cache.js +2 -1
  12. package/dist/analysis/grid_correction_check.d.ts +1 -19
  13. package/dist/analysis/grid_correction_check.js +12 -30
  14. package/dist/analysis/liquidity/liquidity_chart_generator.js +190 -20
  15. package/dist/analysis/liquidity/liquidity_depth_model.d.ts +41 -16
  16. package/dist/analysis/liquidity/liquidity_depth_model.js +49 -21
  17. package/dist/analysis/liquidity/liquidity_view.d.ts +15 -0
  18. package/dist/analysis/liquidity/liquidity_view.js +11 -0
  19. package/dist/analysis/resolve_bot_accounts.js +7 -6
  20. package/dist/analysis/trade_profitability.js +2 -1
  21. package/dist/credential-daemon.js +13 -2
  22. package/dist/dexbot.js +4 -4
  23. package/dist/modules/account_bots.d.ts +11 -1
  24. package/dist/modules/account_orders.d.ts +12 -0
  25. package/dist/modules/account_orders.js +30 -0
  26. package/dist/modules/bitshares-native/transport.js +24 -6
  27. package/dist/modules/bitshares_client.d.ts +24 -6
  28. package/dist/modules/bitshares_client.js +44 -7
  29. package/dist/modules/bot_settings.d.ts +2 -0
  30. package/dist/modules/constants.d.ts +26 -3
  31. package/dist/modules/constants.js +63 -8
  32. package/dist/modules/dexbot_class.d.ts +1 -6
  33. package/dist/modules/dexbot_class.js +14 -0
  34. package/dist/modules/dexbot_cow_runtime.d.ts +97 -7
  35. package/dist/modules/dexbot_cow_runtime.js +620 -132
  36. package/dist/modules/dexbot_fill_runtime.js +124 -35
  37. package/dist/modules/dexbot_maintenance_runtime.js +226 -73
  38. package/dist/modules/dexbot_startup_runtime.js +32 -20
  39. package/dist/modules/dexbot_state_recovery.d.ts +33 -1
  40. package/dist/modules/dexbot_state_recovery.js +167 -5
  41. package/dist/modules/node_connect_policy.d.ts +8 -1
  42. package/dist/modules/node_connect_policy.js +18 -2
  43. package/dist/modules/node_flap_score.d.ts +87 -0
  44. package/dist/modules/node_flap_score.js +124 -0
  45. package/dist/modules/node_health_cache.d.ts +40 -3
  46. package/dist/modules/node_health_cache.js +66 -20
  47. package/dist/modules/node_manager.d.ts +101 -19
  48. package/dist/modules/node_manager.js +255 -65
  49. package/dist/modules/order/accounting.js +56 -7
  50. package/dist/modules/order/format.d.ts +24 -10
  51. package/dist/modules/order/format.js +30 -10
  52. package/dist/modules/order/grid.js +82 -11
  53. package/dist/modules/order/grid_reconcile.d.ts +5 -1
  54. package/dist/modules/order/grid_reconcile.js +333 -210
  55. package/dist/modules/order/grid_reconcile_internal.d.ts +38 -2
  56. package/dist/modules/order/grid_reconcile_internal.js +207 -87
  57. package/dist/modules/order/index.d.ts +4 -0
  58. package/dist/modules/order/lifecycle.d.ts +353 -0
  59. package/dist/modules/order/lifecycle.js +1109 -0
  60. package/dist/modules/order/manager.d.ts +271 -5
  61. package/dist/modules/order/manager.js +651 -48
  62. package/dist/modules/order/placement_lock.d.ts +102 -0
  63. package/dist/modules/order/placement_lock.js +222 -0
  64. package/dist/modules/order/strategy.js +13 -1
  65. package/dist/modules/order/sync_engine.d.ts +13 -1
  66. package/dist/modules/order/sync_engine.js +153 -53
  67. package/dist/modules/order/utils/math.d.ts +22 -1
  68. package/dist/modules/order/utils/math.js +54 -1
  69. package/dist/modules/order/utils/order.d.ts +75 -5
  70. package/dist/modules/order/utils/order.js +158 -9
  71. package/dist/modules/order/utils/system.d.ts +18 -0
  72. package/dist/modules/order/utils/system.js +84 -8
  73. package/dist/modules/order/utils/validate.d.ts +7 -1
  74. package/dist/modules/order/utils/validate.js +48 -2
  75. package/dist/modules/outcome.d.ts +54 -0
  76. package/dist/modules/outcome.js +51 -0
  77. package/dist/modules/settings_merge.d.ts +4 -0
  78. package/dist/modules/settings_merge.js +9 -0
  79. package/dist/modules/timing_policy.d.ts +82 -0
  80. package/dist/modules/timing_policy.js +244 -0
  81. package/dist/modules/types.d.ts +132 -0
  82. package/dist/scripts/analyze-credit.js +54 -17
  83. package/dist/scripts/analyze-orders.d.ts +4 -2
  84. package/dist/scripts/analyze-orders.js +113 -34
  85. package/dist/scripts/chart_targets.js +11 -15
  86. package/dist/scripts/test-credit-renewal.js +12 -5
  87. package/docs/COW_INVARIANTS.md +67 -8
  88. package/docs/DEXBOT_COMPARISON.md +6 -6
  89. package/docs/EVOLUTION.md +9 -8
  90. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  91. package/docs/GRID_PRICE_INVARIANT.md +1 -1
  92. package/docs/GRID_RECONCILE.md +17 -12
  93. package/docs/LOGGING.md +25 -1
  94. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +175 -26
  95. package/docs/README.md +23 -2
  96. package/docs/WORKFLOW.md +9 -3
  97. package/docs/architecture.md +42 -5
  98. package/docs/developer_guide.md +25 -8
  99. package/modules/README.md +3 -0
  100. package/package.json +1 -1
  101. package/scripts/README.md +16 -0
  102. package/scripts/pdev.sh +14 -1
  103. package/scripts/pmain.sh +23 -8
  104. package/scripts/ptest.sh +7 -0
  105. package/tests/README.md +30 -1
@@ -18,6 +18,10 @@ import Logger from './logger.js';
18
18
  import Accountant from './accounting.js';
19
19
  import StrategyEngine from './strategy.js';
20
20
  import SyncEngine from './sync_engine.js';
21
+ import { LifecycleRegistry } from './lifecycle.js';
22
+ import type { LifecycleView } from './lifecycle.js';
23
+ import PlacementLock from './placement_lock.js';
24
+ import type { PlacementLease } from './placement_lock.js';
21
25
  import type { GridGenesis } from './utils/math.js';
22
26
  import type { OrderManagerLike, ManagedOrder, GridConfig, AssetPair, AccountTotals, ManagerFunds, PendingPriceCorrection, ProcessedFillStoreLike, PendingBroadcast, ManagerLock, IllegalStateSignal, AccountingFailureSignal, BotMetrics, AccountOrdersLike, CowAction, RebalanceResult, ProjectedFunds, SyncResult, FillHistorySyncResult, FundDriftCheck, ChainFundsSnapshot, OrderType, OrderState, UnknownRecord } from '../types.js';
23
27
  /**
@@ -107,6 +111,10 @@ declare class OrderManager implements OrderManagerLike {
107
111
  sync: SyncEngine;
108
112
  _rebalanceState: string;
109
113
  _bootstrapping: number;
114
+ _structuralRebuildDepth: number;
115
+ _structuralRebuildStartedAt: number;
116
+ _structuralRebuildDeferWarnAt: number;
117
+ _structuralRebuildReason: string | null;
110
118
  _endOfBootstrapValidationDone: boolean;
111
119
  _broadcastingFlag: number;
112
120
  _broadcastingStartedAt: number;
@@ -157,6 +165,13 @@ declare class OrderManager implements OrderManagerLike {
157
165
  private _getOrderIdIndex;
158
166
  initialSpreadCount: number;
159
167
  currentSpreadCount: number;
168
+ /**
169
+ * True once a grid has been loaded/created and the spread metric measured.
170
+ * Before that both counters are 0, which is indistinguishable from a
171
+ * genuinely empty band — telemetry must print "unknown" instead of "0"
172
+ * (the restore line otherwise claims the spread band is gone).
173
+ */
174
+ _spreadCountKnown: boolean;
160
175
  outOfSpread: number;
161
176
  assets: AssetPair;
162
177
  accountId: string | null;
@@ -172,6 +187,7 @@ declare class OrderManager implements OrderManagerLike {
172
187
  processedFillStore: ProcessedFillStoreLike | null;
173
188
  _syncLock: ManagerLock;
174
189
  _fillProcessingLock: ManagerLock;
190
+ _placementLock: PlacementLock;
175
191
  _divergenceLock: ManagerLock;
176
192
  _gridLock: ManagerLock;
177
193
  _fundLock: ManagerLock;
@@ -187,11 +203,22 @@ declare class OrderManager implements OrderManagerLike {
187
203
  _syncGeneration: number;
188
204
  _gridVersion: number;
189
205
  _gridPersistenceSuspendedReason: string | null;
190
- _pendingBroadcasts: Map<string, PendingBroadcast>;
191
- _committedOrderIds: Set<string>;
192
- _committedOrderIdsBuiltAt: number;
193
- _orderIdAssignedAt: Map<string, number>;
194
- _placedAt: Map<string, number>;
206
+ /**
207
+ * Single owner of "does this order exist on chain, and how sure are we".
208
+ * The legacy maps below are live views onto it — see modules/order/lifecycle.ts.
209
+ */
210
+ readonly _lifecycle: LifecycleRegistry;
211
+ /** Live view onto `_lifecycle`. Assigned as a whole by the COW commit path. */
212
+ get _committedOrderIds(): Set<string>;
213
+ set _committedOrderIds(value: Iterable<string>);
214
+ get _committedOrderIdsBuiltAt(): number;
215
+ set _committedOrderIdsBuiltAt(value: number);
216
+ get _orderIdAssignedAt(): Map<string, number>;
217
+ set _orderIdAssignedAt(value: Map<string, number>);
218
+ get _placedAt(): Map<string, number>;
219
+ set _placedAt(value: Map<string, number>);
220
+ get _pendingBroadcasts(): Map<string, PendingBroadcast>;
221
+ set _pendingBroadcasts(value: Map<string, PendingBroadcast>);
195
222
  _gapSlots: number;
196
223
  _genesis: GridGenesis | null;
197
224
  _missingGenesis: unknown;
@@ -213,6 +240,20 @@ declare class OrderManager implements OrderManagerLike {
213
240
  side: string;
214
241
  ts: number;
215
242
  }[];
243
+ /**
244
+ * Chain-size resizes already absorbed by sync pass 1 (partial fill seen in
245
+ * an open-orders snapshot). The fill-history batch that follows the same
246
+ * fill must not subtract / credit the same amount a second time.
247
+ * Live view onto `_lifecycle`; key = chain orderId.
248
+ */
249
+ get _chainSizeAppliedFills(): Map<string, {
250
+ filledInt: number;
251
+ at: number;
252
+ }>;
253
+ set _chainSizeAppliedFills(value: Map<string, {
254
+ filledInt: number;
255
+ at: number;
256
+ }>);
216
257
  _recentFillKeysSnapshot: Record<string, number> | null;
217
258
  _lastFilledBuyPrice: number | null;
218
259
  _lastFilledSellPrice: number | null;
@@ -296,16 +337,187 @@ declare class OrderManager implements OrderManagerLike {
296
337
  * @returns {boolean}
297
338
  */
298
339
  isBootstrapping(): boolean;
340
+ /**
341
+ * Mark a structural grid rebuild (trigger-file resync, startup regenerate)
342
+ * as in progress. While active, fill-driven COW rebalances DEFER: they would
343
+ * otherwise re-plan against the freshly rebuilt, order-id-less master and
344
+ * emit a create-only batch while the reconcile re-prices the live orders
345
+ * onto the same levels (duplicate-price orphan incident 2026-11-03).
346
+ * This is deliberately narrower than isBootstrapping(): the constructor's
347
+ * initial bootstrap is not a rebuild and fills may still rebalance there.
348
+ * @param {string} reason - Diagnostic label (e.g. 'trigger-file resync')
349
+ */
350
+ beginStructuralRebuild(reason?: string): void;
351
+ /** End a structural rebuild region (balanced with beginStructuralRebuild). */
352
+ endStructuralRebuild(): void;
353
+ /** Whether a structural rebuild currently owns placement. */
354
+ isStructuralRebuildInProgress(): boolean;
355
+ /** Diagnostic label of the active structural rebuild, or null. */
356
+ structuralRebuildReason(): string | null;
357
+ /**
358
+ * Run a chain-mutating placement path inside the exclusive region.
359
+ *
360
+ * SINGLE SOURCE OF TRUTH: every caller that can broadcast (COW, startup
361
+ * reconcile Phase 2, correction drain, dust/residual cancels, pool swaps)
362
+ * must go through this helper. It is NOT reentrant: a nested caller must not
363
+ * call it again — the COW body hands its lease to the pre-batch drain
364
+ * (`correctAllPriceMismatches({ placementLease })`), which verifies it with
365
+ * `isPlacementLeaseCurrent()` before mutating.
366
+ *
367
+ * Lock hierarchy: acquire placement BEFORE `_gridLock`; never acquire it
368
+ * while holding `_gridLock` (Level 0.5 — see `manageLocks`).
369
+ *
370
+ * @returns `null` when the region could not be acquired; the caller must
371
+ * defer/abort its broadcast.
372
+ */
373
+ withPlacement<T>(kind: string, fn: (lease: PlacementLease) => Promise<T>, options?: {
374
+ timeoutMs?: number;
375
+ isShuttingDown?: () => boolean;
376
+ }): Promise<T | null>;
377
+ /**
378
+ * Acquire the exclusive placement region (see placement_lock.ts).
379
+ * Callers MUST release the lease in a finally block before returning.
380
+ * @param {string} kind - Owner label for diagnostics (e.g. 'cow-broadcast')
381
+ * @param {Object} [options] - Wait bound + shutdown probe
382
+ * @returns {Promise<Object|null>} Lease, or null on timeout/shutdown
383
+ */
384
+ acquirePlacement(kind: string, options?: {
385
+ timeoutMs?: number;
386
+ isShuttingDown?: () => boolean;
387
+ }): Promise<PlacementLease | null>;
388
+ /**
389
+ * Non-blocking placement acquire for paths that must defer rather than queue.
390
+ * @param {string} kind - Owner label
391
+ * @returns {Object|null} Lease when free, otherwise null
392
+ */
393
+ tryAcquirePlacement(kind: string): PlacementLease | null;
394
+ /** Whether another placement path currently holds the exclusive region. */
395
+ isPlacementActive(): boolean;
396
+ /**
397
+ * Whether the given lease is STILL the one that owns the region.
398
+ *
399
+ * The authoritative nesting predicate: a nested caller (the COW pre-batch
400
+ * drain) must verify its inherited lease with this before mutating.
401
+ * `isPlacementActive()` cannot answer it — it is true for any holder, so a
402
+ * lease invalidated by `forceRelease()` would still read as "live".
403
+ * @param {Object|null|undefined} lease - Lease to verify
404
+ * @returns {boolean}
405
+ */
406
+ isPlacementLeaseCurrent(lease: PlacementLease | null | undefined): boolean;
407
+ /** Owner label of the active placement region, or null. */
408
+ placementKind(): string | null;
409
+ /** Milliseconds the current placement region has been held (0 when free). */
410
+ placementHeldForMs(): number;
411
+ /**
412
+ * True when the given staleness reason means the master grid was
413
+ * structurally rebuilt while a plan was in flight. Such a plan must NOT be
414
+ * re-planned from the fresh (order-id-less) master: a create-only re-plan
415
+ * duplicates every live chain order the reconcile is about to update.
416
+ */
417
+ isStructuralRebuildStale(reason: unknown): boolean;
299
418
  /**
300
419
  * Whether a broadcast is currently active (no side-effects).
301
420
  * @returns {boolean}
302
421
  */
303
422
  isBroadcastingActive(): boolean;
423
+ /**
424
+ * Record that sync pass 1 already applied a chain-size reduction (a
425
+ * partial fill) for this order. The following fill-history batch checks it
426
+ * to stay idempotent: subtracting/crediting the same fill again shrinks the
427
+ * order twice and over-credits free balance (2026-11-03 log: 3.6604 ->
428
+ * 3.3046 by pass 1, then 3.3046 -> 2.9488 by the fill batch).
429
+ *
430
+ * Markers ACCUMULATE: two pass-1 detections before the fill queue drains
431
+ * (or one aggregated fill-history entry covering both) must add up, not
432
+ * overwrite — an overwritten marker makes the batch total unmatchable and
433
+ * re-opens the double-shrink. The map is mirrored into the persisted grid
434
+ * snapshot (debugInputs) so a restart between pass 1 and fill processing
435
+ * does not lose the evidence.
436
+ * @param {string} orderId - Chain order id
437
+ * @param {number} filledInt - Base-amount delta in chain integer units
438
+ * @returns {void}
439
+ */
440
+ noteChainSizeAppliedFill(orderId: string, filledInt: number, maxAgeMs?: number): void;
441
+ /**
442
+ * Consume a pass-1 chain-size marker for a fill without requiring an exact
443
+ * total match. Returns the number of chain-size units this fill may treat
444
+ * as ALREADY reflected in `rawOnChain` (0 when there is no marker).
445
+ *
446
+ * Partial consumption is the split-batch case: pass 1 absorbed A+B, the
447
+ * fill queue drains A first (marker keeps B), then B. The old all-or-nothing
448
+ * match rejected both and double-shrunk the slot twice.
449
+ * @param {string} orderId - Chain order id
450
+ * @param {number} filledInt - Base-amount delta in chain integer units
451
+ * @param {number} [maxAgeMs] - Marker freshness bound
452
+ * @returns {number} Applied (already-in-snapshot) amount, 0..filledInt
453
+ */
454
+ consumeChainSizeAppliedFillAmount(orderId: string, filledInt: number, maxAgeMs?: number): number;
455
+ /**
456
+ * Boolean compatibility wrapper for {@link consumeChainSizeAppliedFillAmount}.
457
+ * @param {string} orderId - Chain order id
458
+ * @param {number} filledInt - Base-amount delta in chain integer units
459
+ * @param {number} [maxAgeMs] - Marker freshness bound
460
+ * @returns {boolean} true when any part of the fill was already applied
461
+ */
462
+ consumeChainSizeAppliedFill(orderId: string, filledInt: number, maxAgeMs?: number): boolean;
463
+ /**
464
+ * Merge persisted pass-1 markers into the in-memory set (recovery reload).
465
+ * Live markers win on conflict: they may already be partially consumed,
466
+ * and replacing them with the older persisted total would double-count.
467
+ * Entries are sanitized and the clock is freshened (see below).
468
+ * @param {unknown} payload - `{ [orderId]: { filledInt, at } }`
469
+ * @returns {void}
470
+ */
471
+ restoreChainSizeAppliedFills(payload: unknown): void;
472
+ /** Snapshot the live pass-1 markers for persistence (empty when none). */
473
+ snapshotChainSizeAppliedFills(): Record<string, {
474
+ filledInt: number;
475
+ at: number;
476
+ }>;
477
+ /**
478
+ * Wake the tasks that deferred on isPlacementActive() when the region ends.
479
+ * The broadcast-region-end listener reschedules a deferred rebalance and
480
+ * drains queued fills; without this a fill deferred because a correction
481
+ * drain/COW held placement would only retry on the next unrelated event.
482
+ * Skipped while a broadcast region is still active (stopBroadcasting will
483
+ * fire the same listeners when it ends).
484
+ * @returns {void}
485
+ */
486
+ _handlePlacementRegionEnd(): void;
304
487
  /**
305
488
  * @param {boolean} value
306
489
  * @returns {void}
307
490
  */
308
491
  setShuttingDown(value: boolean): void;
492
+ /**
493
+ * Auto-clears a stale placement region after
494
+ * TIMING.PLACEMENT_STALE_CLEAR_MS so a hung chain call / missed release
495
+ * cannot park fills and rebalances forever. The holder's lease becomes a
496
+ * no-op on release (token guard), so a late finally cannot release a
497
+ * successor.
498
+ *
499
+ * TWO GUARDS, ONE TEARDOWN:
500
+ * - A bot-level batch/recovery still in flight and YOUNGER than the bound is
501
+ * evidence of progress, so the region is not torn down (a long create-group
502
+ * reconcile must survive). Only a batch older than the same bound is
503
+ * treated as part of the hung region.
504
+ * - When the teardown does happen it also clears a broadcast refcount that
505
+ * is itself past its bound, atomically. A refcount raised by a placement
506
+ * holder belongs to the same region (the COW body and the reconcile call
507
+ * startBroadcasting() INSIDE it), so clearing both in one place stops the
508
+ * maintenance tick from tearing down placement first and the refcount
509
+ * second (two authorities, one hung region). A refcount raised OUTSIDE any
510
+ * region (the spread-correction pre-broadcast hold in `order/grid.ts`) is
511
+ * not this region's and is left to `_clearStaleBroadcastFlag`, which still
512
+ * refuses to act on its own while a placement lease is held.
513
+ * @param {number} [maxAgeMs] - Override for tests
514
+ * @param {Object} [options] - `batchInFlightMs`: age of the LAST raised
515
+ * bot-level pipeline counter (0/undefined when none).
516
+ * @returns {boolean} true when a stale region was force-released
517
+ */
518
+ _clearStalePlacementRegion(maxAgeMs?: number, options?: {
519
+ batchInFlightMs?: number;
520
+ }): boolean;
309
521
  /**
310
522
  * Auto-clears a stale broadcast flag after 120s so a hung
311
523
  * broadcast cannot permanently block rebalancing.
@@ -547,6 +759,32 @@ declare class OrderManager implements OrderManagerLike {
547
759
  */
548
760
  getActiveShadowLockCount(): number;
549
761
  _cleanExpiredLocks(): void;
762
+ /**
763
+ * The single answer to "does this order exist on chain, and how sure are we".
764
+ *
765
+ * Every consumer that used to infer this from one of the legacy maps must
766
+ * read it here instead — that is the whole point of the lifecycle registry:
767
+ * four sites consulting four different structures is how the engine ended up
768
+ * with four different answers for the same order.
769
+ *
770
+ * A `createUncertain` slot flag (persisted across restarts) is folded into
771
+ * `phase === 'unknown'` here, so no caller has to remember to check it.
772
+ *
773
+ * @param identity - Slot id, chain order id, or pending-broadcast fingerprint
774
+ * @returns {LifecycleView} Unified read surface (never null)
775
+ */
776
+ getLifecycle(identity: string | null | undefined): LifecycleView;
777
+ /**
778
+ * Lifecycle view for a slot, folding in the slot's own persisted flags.
779
+ * Prefer this over `getLifecycle(slotId)` wherever a slot object is at hand.
780
+ * @param slot - Grid slot (ManagedOrder) or null
781
+ * @returns {LifecycleView}
782
+ */
783
+ getSlotLifecycle(slot: {
784
+ id?: string;
785
+ orderId?: string | null;
786
+ createUncertain?: boolean;
787
+ } | null | undefined): LifecycleView;
550
788
  _normalizeOrderUpdateOptions(options?: UnknownRecord): {
551
789
  skipAccounting: boolean;
552
790
  fee: number;
@@ -557,6 +795,34 @@ declare class OrderManager implements OrderManagerLike {
557
795
  };
558
796
  _updateOrder(order: ManagedOrder, context?: string, options?: UnknownRecord): Promise<boolean>;
559
797
  _applyOrderUpdate(order: ManagedOrder, context?: string, options?: UnknownRecord): Promise<boolean>;
798
+ /**
799
+ * Project one order mutation into the lifecycle registry.
800
+ *
801
+ * This is the single write funnel for chain existence: every mutation goes
802
+ * through `_applyOrderUpdate`, so no call site has to remember which of the
803
+ * seven legacy structures to touch. A slot is the record's identity, so a
804
+ * chain-id change (rotation / re-place) updates the same record instead of
805
+ * starting a parallel one.
806
+ *
807
+ * @param previous - Slot before the mutation (absent on create)
808
+ * @param next - Slot after the mutation
809
+ * @param context - Mutation context label
810
+ * @returns {void}
811
+ */
812
+ _syncLifecycleFromMutation(previous: ManagedOrder | null | undefined, next: ManagedOrder, context: string): void;
813
+ /**
814
+ * Abandon an unresolved pending CREATE (TTL sweep / give-up).
815
+ *
816
+ * Distinct from `_pendingBroadcasts.delete()`: dropping an entry because the
817
+ * create RESOLVED leaves the slot free, while dropping it because we ran out
818
+ * of patience means the order may still be live. Collapsing both into one
819
+ * delete is how a lost receipt turned into a clean hole that got re-CREATEd.
820
+ *
821
+ * @param fingerprint - Pending-broadcast fingerprint being abandoned
822
+ * @param entry - The abandoned entry (carries the slot id)
823
+ * @returns {void}
824
+ */
825
+ _expirePendingBroadcast(fingerprint: string, entry: PendingBroadcast | null | undefined): void;
560
826
  _peekWorkingGrid(): WorkingGrid | null;
561
827
  _syncWorkingGridFromMasterMutation(orderId: string, context: string): void;
562
828
  /**