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
@@ -121,6 +121,7 @@ import { sleep } from './system.js';
121
121
  import { getErrorMessage, getErrorCode, getErrorName } from '../../utils/errors.js';
122
122
  import { hasGenesisLadder } from '../genesis_policy.js';
123
123
  import { parseSlotIndex } from './slot.js';
124
+ import { pendingBroadcastTtlMs } from '../lifecycle.js';
124
125
  const { isValidNumber, toFiniteNumber } = Format;
125
126
  const { blockchainToFloat, floatToBlockchainInt, quantizeFloat, slotIndexForPrice, priceSlotEqual } = MathUtils;
126
127
  const orderLogger = new Logger('Order');
@@ -162,6 +163,28 @@ function isOrderGoneErrorMessage(message, orderId) {
162
163
  return true;
163
164
  return false;
164
165
  }
166
+ /**
167
+ * Classify a working-grid staleness reason as a STRUCTURAL rebuild.
168
+ *
169
+ * `_syncWorkingGridFromMasterMutation` stamps reasons such as
170
+ * `master mutation during broadcasting (grid-init)` (a full grid rebuild) or
171
+ * `(fill-place)` (a fill landing during the plan). The two are NOT
172
+ * interchangeable: after a rebuild the fresh master no longer carries the live
173
+ * chain order IDs, so re-planning from it emits CREATEs for price levels the
174
+ * startup reconcile is concurrently re-pricing via UPDATE — both generations
175
+ * land and the loser becomes a duplicate-price orphan backlog.
176
+ *
177
+ * Single source of truth for every planner/guard that must treat a rebuild
178
+ * differently from a fill. Keep the pattern anchored to the context tokens
179
+ * emitted by manager._syncWorkingGridFromMasterMutation / structural paths.
180
+ * @param {unknown} reason - evaluateCommit refusal reason or staleness label.
181
+ * @returns {boolean} True when the master was structurally rebuilt.
182
+ */
183
+ function isStructuralRebuildStaleReason(reason) {
184
+ if (typeof reason !== 'string' || reason.length === 0)
185
+ return false;
186
+ return /\bgrid-init\b|\brebuild\b|\bresync\b|\bregenerated grid\b|\bstructural rebuild\b/i.test(reason);
187
+ }
165
188
  // ---------------------------------------------------------------------------
166
189
  // Persistent duplicate-orphan detection escalation. A duplicate-price-level
167
190
  // orphan is expected self-healing (fully filled order leaves a sub-dust
@@ -243,8 +266,15 @@ function _filterUnmatchedChainOrders(manager, chainOrderId) {
243
266
  }
244
267
  /**
245
268
  * Record a fresh on-chain placement timestamp for surplus-cancel grace.
246
- * Called when a slot gains a chain orderId it did not have before (create,
247
- * adopt, rotation target). Powers isFreshlyPlacedOrder below.
269
+ * Powers isFreshlyPlacedOrder below.
270
+ *
271
+ * NOTE: in production the placement stamp is written by the lifecycle write
272
+ * funnel (`OrderManager._syncLifecycleFromMutation` -> `markPlaced`) for every
273
+ * mutation, including the COW whole-map commit. This helper remains for callers
274
+ * that hold only a manager-shaped object (tests, fixtures) and for the `_placedAt`
275
+ * retention bound; it writes through the same facade, so there is still one copy
276
+ * of the stamp.
277
+ *
248
278
  * @param {unknown} manager - OrderManager instance (owns `_placedAt`)
249
279
  * @param {string} chainOrderId - Chain order id that was just placed
250
280
  */
@@ -252,6 +282,8 @@ function recordOrderPlacement(manager, chainOrderId) {
252
282
  try {
253
283
  if (!manager || chainOrderId == null || String(chainOrderId).length === 0)
254
284
  return;
285
+ // Writing through the facade records `placedAt` on the lifecycle record
286
+ // (one clock, one owner) — no separate grace bookkeeping to keep in sync.
255
287
  if (!(manager._placedAt instanceof Map))
256
288
  manager._placedAt = new Map();
257
289
  manager._placedAt.set(String(chainOrderId), Date.now());
@@ -280,6 +312,11 @@ function isFreshlyPlacedOrder(manager, chainOrderId, graceMs) {
280
312
  try {
281
313
  if (chainOrderId == null || String(chainOrderId).length === 0)
282
314
  return false;
315
+ // Single definition of the grace window lives on the lifecycle view.
316
+ const lifecycle = manager?.getLifecycle;
317
+ if (typeof lifecycle === 'function') {
318
+ return lifecycle.call(manager, String(chainOrderId)).isFreshlyPlaced(graceMs);
319
+ }
283
320
  const placedAt = manager?._placedAt instanceof Map
284
321
  ? manager._placedAt.get(String(chainOrderId))
285
322
  : null;
@@ -1290,13 +1327,56 @@ function resolveCorrectionWarnRateLimitMs(manager) {
1290
1327
  * Cancel-type corrections (duplicate orphans, surplus) are batched into
1291
1328
  * chunked multi-op transactions; price updates run sequentially.
1292
1329
  *
1330
+ * Runs inside the exclusive placement region: every correction broadcasts a
1331
+ * chain mutation, so it must never interleave with a COW batch, startup
1332
+ * reconcile Phase 2 or a dust/residual cancel. A caller already holding the
1333
+ * region (COW pre-batch drain) passes its lease so the nested call does not
1334
+ * deadlock.
1335
+ *
1293
1336
  * @param {Object} manager - OrderManager instance
1294
1337
  * @param {string} accountName - Account name for blockchain transactions
1295
1338
  * @param {string} privateKey - Private key for signing
1296
1339
  * @param {Object} accountOrders - AccountOrders accessor for blockchain ops
1340
+ * @param {Object} [options] - placementLease (reuse) + timeoutMs (bounded wait)
1297
1341
  * @returns {Promise<Object>} Summary {corrected, failed, results}
1298
1342
  */
1299
- async function correctAllPriceMismatches(manager, accountName, privateKey, accountOrders) {
1343
+ async function correctAllPriceMismatches(manager, accountName, privateKey, accountOrders, options = {}) {
1344
+ if (!manager || !manager._gridLock)
1345
+ return { corrected: 0, failed: 0, results: [] };
1346
+ const run = () => _correctAllPriceMismatchesLocked(manager, accountName, privateKey, accountOrders);
1347
+ // NESTED CALLER (COW pre-batch drain): the caller already owns the region.
1348
+ // Reuse the inherited lease only while it STILL owns it — `isPlacementActive()`
1349
+ // would also be true for a different holder (e.g. the watchdog force-released
1350
+ // this lease and another path took the region), which would run the drain
1351
+ // unprotected and re-open the duplicate window.
1352
+ if (options.placementLease) {
1353
+ const inherited = options.placementLease;
1354
+ const stillCurrent = typeof manager.isPlacementLeaseCurrent === 'function'
1355
+ ? manager.isPlacementLeaseCurrent(inherited)
1356
+ : true;
1357
+ if (stillCurrent)
1358
+ return await run();
1359
+ }
1360
+ const timeoutMs = Math.max(1, Number.isFinite(Number(options.timeoutMs)) ? Number(options.timeoutMs) : 5000);
1361
+ const deferredResult = { corrected: 0, failed: 0, results: [], staleDropped: 0, deferred: true, reason: 'placement-active' };
1362
+ // Single acquire/release contract (placement_lock.withPlacement).
1363
+ if (typeof manager.withPlacement === 'function') {
1364
+ const placed = await manager.withPlacement('correction-drain', async () => run(), { timeoutMs });
1365
+ return placed ?? deferredResult;
1366
+ }
1367
+ if (typeof manager.acquirePlacement !== 'function')
1368
+ return await run();
1369
+ const lease = await manager.acquirePlacement('correction-drain', { timeoutMs });
1370
+ if (!lease)
1371
+ return deferredResult;
1372
+ try {
1373
+ return await run();
1374
+ }
1375
+ finally {
1376
+ lease.release();
1377
+ }
1378
+ }
1379
+ async function _correctAllPriceMismatchesLocked(manager, accountName, privateKey, accountOrders) {
1300
1380
  if (!manager || !manager._gridLock)
1301
1381
  return { corrected: 0, failed: 0, results: [] };
1302
1382
  // 6b: backlog alarm (rate-limited). Emitted even when the drain defers
@@ -1761,9 +1841,15 @@ function detectGapEvacuationCandidates(masterGrid, boundaryIdx, gapSlots, option
1761
1841
  * @param {Map} streakMap - Mutable Map slotId -> consecutive-cycle count
1762
1842
  * @param {Array} candidates - detectGapEvacuationCandidates output
1763
1843
  * @param {number} [threshold] - GRID_LIMITS.GAP_EVACUATION_STREAK_THRESHOLD default
1844
+ * @param {Object} [options] - `increment: false` re-derives the ledger (prune
1845
+ * resolved ids + report readiness) WITHOUT counting a new observation. The
1846
+ * committed-geometry sweep uses it because the plan ticks the same ledger in
1847
+ * the same cycle; counting twice would arm the cancel-only teeth in the very
1848
+ * cycle whose rotation is about to evacuate the order.
1764
1849
  * @returns {{streaks: Object, ready: Array}}
1765
1850
  */
1766
- function updateGapEvacuationStreaks(streakMap, candidates, threshold = null) {
1851
+ function updateGapEvacuationStreaks(streakMap, candidates, threshold = null, options = {}) {
1852
+ const increment = options?.increment !== false;
1767
1853
  const thrRaw = threshold !== null && threshold !== undefined ? Number(threshold) : Number(GRID_LIMITS?.GAP_EVACUATION_STREAK_THRESHOLD);
1768
1854
  const thr = Number.isFinite(thrRaw) && thrRaw > 0 ? Math.floor(thrRaw) : 2;
1769
1855
  const seen = new Set();
@@ -1773,7 +1859,7 @@ function updateGapEvacuationStreaks(streakMap, candidates, threshold = null) {
1773
1859
  continue;
1774
1860
  seen.add(c.id);
1775
1861
  if (streakMap instanceof Map) {
1776
- streakMap.set(c.id, Number(streakMap.get(c.id) || 0) + 1);
1862
+ streakMap.set(c.id, increment ? Number(streakMap.get(c.id) || 0) + 1 : Number(streakMap.get(c.id) || 0));
1777
1863
  }
1778
1864
  }
1779
1865
  if (streakMap instanceof Map) {
@@ -1941,6 +2027,68 @@ function isCrossingCheckCandidate(o, excludeChainOrderId = null, cancelOpIndexBy
1941
2027
  return false;
1942
2028
  return true;
1943
2029
  }
2030
+ /**
2031
+ * LIVE (unexpired) pending-broadcast entries — the SINGLE liveness authority.
2032
+ *
2033
+ * A pending entry protects a slot/price whose uncertain CREATE may already be
2034
+ * live on chain but is not adopted yet. Three readers need that set (the COW
2035
+ * pre-broadcast guard, the reconcile CREATE path, and the reconcile surplus
2036
+ * sweep) and they used to disagree: two re-implemented the TTL by hand with
2037
+ * different rules and one read the raw map with no TTL at all, so a reconcile
2038
+ * could stay blocked by an entry the COW guard already considered dead.
2039
+ *
2040
+ * Liveness rule (unchanged from the COW guard, now the only one):
2041
+ * - younger than `PENDING_BROADCAST_TTL_MS` → live;
2042
+ * - older than the TTL but a successful open-orders sync completed AFTER it was
2043
+ * recorded → expired (a caught-up read re-verifies the level);
2044
+ * - older than 2× the TTL → expired regardless (a permanently lagging node must
2045
+ * not park CREATEs forever);
2046
+ * - no usable `recordedAt` → live (fail closed, never a silent unblock).
2047
+ *
2048
+ * Expired entries are DELETED here; callers get the live list.
2049
+ *
2050
+ * @param {Object} manager - OrderManager (`_pendingBroadcasts`, `_lastSyncAt`)
2051
+ * @param {Object} [options] - `now` clock override (tests)
2052
+ * @returns {Array} Live pending-broadcast entries
2053
+ */
2054
+ function getLivePendingBroadcasts(manager, options = {}) {
2055
+ const map = manager?._pendingBroadcasts;
2056
+ if (!(map instanceof Map))
2057
+ return [];
2058
+ // Single definition of the TTL and its fixture fallback (lifecycle.ts).
2059
+ const ttl = pendingBroadcastTtlMs();
2060
+ const now = Number.isFinite(Number(options?.now)) ? Number(options.now) : Date.now();
2061
+ const lastSyncAt = Number(manager?._lastSyncAt) || 0;
2062
+ const log = manager?.logger?.log;
2063
+ for (const [fingerprint, rawEntry] of map) {
2064
+ const entry = rawEntry;
2065
+ const recordedAt = Number(entry?.recordedAt) || 0;
2066
+ if (!(recordedAt > 0))
2067
+ continue;
2068
+ const age = now - recordedAt;
2069
+ if (age <= ttl)
2070
+ continue;
2071
+ const syncedSinceRecord = lastSyncAt > recordedAt;
2072
+ if (!syncedSinceRecord && age <= ttl * 2) {
2073
+ log?.(`[COW] Pending-broadcast entry ${String(fingerprint)} is ${Math.round(age / 1000)}s old but no sync has completed since it was recorded; keeping it (fail-closed) until a caught-up read`, 'debug');
2074
+ continue;
2075
+ }
2076
+ map.delete(fingerprint);
2077
+ // Abandoned, not resolved: the order may be live. Route through the
2078
+ // lifecycle so the slot records `unknown` instead of becoming a clean
2079
+ // hole the next cycle re-CREATEs.
2080
+ try {
2081
+ const expire = manager
2082
+ ?._expirePendingBroadcast;
2083
+ if (typeof expire === 'function')
2084
+ expire.call(manager, String(fingerprint), entry);
2085
+ }
2086
+ catch { /* bookkeeping only */ }
2087
+ log?.(`[COW] Dropped expired pending-broadcast entry ${String(fingerprint)} (slot ${entry?.slotId ?? '?'}, age ${Math.round(age / 1000)}s, ` +
2088
+ `${syncedSinceRecord ? 'sync completed since record' : 'hard TTL cap'})`, 'warn');
2089
+ }
2090
+ return Array.from(map.values());
2091
+ }
1944
2092
  /**
1945
2093
  * Shared candidate set for crossing-placement checks: master orders plus
1946
2094
  * chain-side orders that may exist on chain but are not (yet) adopted into
@@ -1976,9 +2124,10 @@ function buildCrossingCheckCandidates(manager) {
1976
2124
  ? [...manager.orders.values()].map(withLivePrice)
1977
2125
  : [];
1978
2126
  if (manager._pendingBroadcasts instanceof Map) {
1979
- for (const entry of manager._pendingBroadcasts.values()) {
1980
- if (entry && entry.slotId && entry.order)
1981
- candidates.push(withLivePrice(entry));
2127
+ for (const entry of getLivePendingBroadcasts(manager)) {
2128
+ const wrapper = entry;
2129
+ if (wrapper && wrapper.slotId && wrapper.order)
2130
+ candidates.push(withLivePrice(wrapper));
1982
2131
  }
1983
2132
  }
1984
2133
  if (Array.isArray(manager._lastUnmatchedChainOrders)) {
@@ -3808,6 +3957,6 @@ function collectKnownOnChainOrderIds(mgr, placedResults, placedContexts, extraCr
3808
3957
  const all = new Set([...masterIds, ...createIds]);
3809
3958
  return { masterIds: [...masterIds], createIds: [...createIds], all: [...all] };
3810
3959
  }
3811
- export { parseChainOrder, resolveLiveOrderLadderPosition, applyChainSizeToGridOrder, resolveExecutionPrice, resolveSlotIdForFillPrice, reviveVirtualSlotFromChain, attributeUnmatchedFillToGrid, buildFillKey, correctOrderPriceOnChain, correctAllPriceMismatches, _validatePriceCorrectionEntry, _stampCorrectionProvenance, findLiveOrderOwnerByChainId, buildCreateOrderArgs, getOrderTypeFromUpdatedFlags, resolveConfiguredPriceBound, virtualizeOrder, convertToSpreadPlaceholder, toRailHolePlaceholder, geometryTypeForSlotIndex, detectGapEvacuationCandidates, updateGapEvacuationStreaks, resolveSpreadOrderSide, chainOrderMatchesSlot, chainOrderMatchesSlotWithTolerance, crossingCandidateChainId, isCrossingCheckCandidate, buildCrossingCheckCandidates, filterOrdersByType, buildOutsideInPairGroups, extractBatchOperationResults, formatUnmatchedChainOrder, isNonBlockingUnmatchedOrder, isStrandedHoldOrder, isOrderOnChain, isOrderVirtual, hasOnChainId, isOrderPlaced, isPhantomOrder, isSlotAvailable, isEmptyGridSlot, isOrderHealthy, checkSizeThreshold, checkSizesBeforeMinimum, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, shouldFlagOutOfSpread, buildIndexes, validateIndexes, ordersEqual, buildDelta, deriveTargetBoundary, isShiftEligibleFill, resolveEdgeCount, resolveEdgeOrders, selectEdgeSlots, getCoreOrdersTotal, getSideBudget, calculateBudgetedSizes, buildCreateOpFingerprint, isOrderGoneErrorMessage, recordDuplicateOrphanDetection, clearDuplicateOrphanDetection, duplicateOrphanLogInfo, chainOrderUnchangedFromCache, detectCrossedBookPlan, collectKnownOnChainOrderIds, collectEdgePinnedFillIds, edgeOrderIdSet, liveWindowIdSet, checkGridPriceInvariant, reportGridPriceInvariant };
3960
+ export { parseChainOrder, resolveLiveOrderLadderPosition, applyChainSizeToGridOrder, resolveExecutionPrice, resolveSlotIdForFillPrice, reviveVirtualSlotFromChain, attributeUnmatchedFillToGrid, getLivePendingBroadcasts, buildFillKey, correctOrderPriceOnChain, correctAllPriceMismatches, _validatePriceCorrectionEntry, _stampCorrectionProvenance, findLiveOrderOwnerByChainId, buildCreateOrderArgs, getOrderTypeFromUpdatedFlags, resolveConfiguredPriceBound, virtualizeOrder, convertToSpreadPlaceholder, toRailHolePlaceholder, geometryTypeForSlotIndex, detectGapEvacuationCandidates, updateGapEvacuationStreaks, resolveSpreadOrderSide, chainOrderMatchesSlot, chainOrderMatchesSlotWithTolerance, crossingCandidateChainId, isCrossingCheckCandidate, buildCrossingCheckCandidates, filterOrdersByType, buildOutsideInPairGroups, extractBatchOperationResults, formatUnmatchedChainOrder, isNonBlockingUnmatchedOrder, isStrandedHoldOrder, isOrderOnChain, isOrderVirtual, hasOnChainId, isOrderPlaced, isPhantomOrder, isSlotAvailable, isEmptyGridSlot, isOrderHealthy, checkSizeThreshold, checkSizesBeforeMinimum, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, shouldFlagOutOfSpread, buildIndexes, validateIndexes, ordersEqual, buildDelta, deriveTargetBoundary, isShiftEligibleFill, resolveEdgeCount, resolveEdgeOrders, selectEdgeSlots, getCoreOrdersTotal, getSideBudget, calculateBudgetedSizes, buildCreateOpFingerprint, isOrderGoneErrorMessage, isStructuralRebuildStaleReason, recordDuplicateOrphanDetection, clearDuplicateOrphanDetection, duplicateOrphanLogInfo, chainOrderUnchangedFromCache, detectCrossedBookPlan, collectKnownOnChainOrderIds, collectEdgePinnedFillIds, edgeOrderIdSet, liveWindowIdSet, checkGridPriceInvariant, reportGridPriceInvariant };
3812
3961
  export { resolveEdgeAnchorPrice, resolveLiveEdgeAnchorPrice, compareEdge, collectRefillSlotIds, recordOrderPlacement, isFreshlyPlacedOrder, _filterUnmatchedChainOrders };
3813
3962
  //# sourceMappingURL=order.js.map
@@ -644,6 +644,24 @@ export declare function hasUnsettledFills(source: unknown): {
644
644
  unsettled: boolean;
645
645
  reason: string | null;
646
646
  };
647
+ /**
648
+ * Age of the most recent bot-level pipeline raise.
649
+ *
650
+ * The two counters (`_batchInFlight`, `_recoverySyncInFlight`) each carry a
651
+ * `*StartedAt` stamp maintained by their raise site; a nested raise (a COW
652
+ * re-plan, a second recovery frame) refreshes it, so this reports how long ago
653
+ * the pipeline LAST showed activity, not how long the oldest frame has been
654
+ * open. That is the question a stale-region watchdog needs: a recent raise is
655
+ * evidence of progress. Lives here (next to
656
+ * `hasUnsettledFills`, the same bot/manager field-peeking contract) so the
657
+ * maintenance tick and the fill consumer cannot disagree about it.
658
+ *
659
+ * @param {Object} source - DEXBot-like (or OrderManager-like) instance
660
+ * @param {number} [nowMs] - Clock override (tests)
661
+ * @returns {number} Milliseconds since the most recent raise, 0 when nothing
662
+ * is in flight or the stamp is missing
663
+ */
664
+ export declare function getPipelineInFlightAgeMs(source: unknown, nowMs?: number): number;
647
665
  /**
648
666
  * Restore the persisted bot-scoped last-market-fill reference into the
649
667
  * manager. Deliberately independent of the boundary and the genesis: this is
@@ -934,11 +934,20 @@ export async function persistGridSnapshot(manager, accountOrders, snapshotOrders
934
934
  // Bot-scoped market-fill reference: survives grid regeneration, used
935
935
  // by spread correction as the price it must not trade through.
936
936
  const lastMarketFill = buildLastMarketFillPayload(manager);
937
+ // Restart durability for the pass-1 "size already applied" markers.
938
+ // They live on the manager only, so a crash between pass 1 and the
939
+ // fill-history batch would lose the evidence and replay the fill as a
940
+ // second shrink. Persisted in the existing free-form debugInputs blob
941
+ // (no schema change to the order rows).
942
+ const chainSizeAppliedFills = typeof manager.snapshotChainSizeAppliedFills === 'function'
943
+ ? manager.snapshotChainSizeAppliedFills()
944
+ : undefined;
937
945
  await accountOrders.storeMasterGrid(orders, btsFeesOwed, manager.boundaryIdx, manager.assets || null, {
938
946
  persistedAt: nowIso(),
939
947
  config: debugConfig,
940
948
  accountTotals,
941
- btsBalance
949
+ btsBalance,
950
+ ...(chainSizeAppliedFills !== undefined ? { chainSizeAppliedFills } : {})
942
951
  }, fillKeys, genesis, gapEvacStreaks, pendingFillCrawls, lastFillPivot, lastMarketFill);
943
952
  return true;
944
953
  }
@@ -1374,7 +1383,9 @@ export function reanchorBoundaryFromLastFill(manager, boundaryIdx, slots, gapSlo
1374
1383
  // leaves the remainder at the fill slot, and any boundary that puts the
1375
1384
  // fill outside its window necessarily puts that slot inside the implied
1376
1385
  // band. Allow exactly that residual (PARTIAL, same side, same ladder
1377
- // level); every other in-band order still refuses the re-anchor.
1386
+ // level); every other in-band order still refuses the re-anchor UNLESS the
1387
+ // move strands strictly fewer placed orders than the committed boundary
1388
+ // (the violation-reducing repair below).
1378
1389
  //
1379
1390
  // ANCHOR-AWARE: the residual sits at the slot the re-anchor is derived
1380
1391
  // from (`anchorIdx`), which is the batch EXTREMUM, not necessarily the
@@ -1408,7 +1419,23 @@ export function reanchorBoundaryFromLastFill(manager, boundaryIdx, slots, gapSlo
1408
1419
  check = { ok: false, reason: getErrorMessage(err) };
1409
1420
  }
1410
1421
  if (!check || check.ok !== true) {
1411
- return { boundaryIdx: boundary, reanchored: false, reason: `unsafe: ${check?.reason ?? 'unknown'}` };
1422
+ // VIOLATION-REDUCING REPAIR: a fill-derived re-anchor may legitimately
1423
+ // land while older strands are still waiting for GAP-EVAC. Refusing it
1424
+ // keeps the window behind the fill (the counter order stays in-band);
1425
+ // accepting it is safe only when the move strands STRICTLY FEWER placed
1426
+ // orders than the committed boundary already does — the same bound the
1427
+ // strict validator applies, measured instead of assumed. Structural
1428
+ // refusals (crossed book, ceiling, range) are never a repair.
1429
+ const repairsStrands = check?.reason === MathUtils.BOUNDARY_REJECT_PLACED_IN_BAND
1430
+ && MathUtils.boundaryMoveReducesStrands(boundary, candidate, slots ?? [], gap, allowedInBandSlotIds.length > 0 ? { allowInBandSlotIds: allowedInBandSlotIds } : undefined);
1431
+ if (!repairsStrands) {
1432
+ return { boundaryIdx: boundary, reanchored: false, reason: `unsafe: ${check?.reason ?? 'unknown'}` };
1433
+ }
1434
+ try {
1435
+ manager.logger?.log?.(`[BOUNDARY] Re-anchor accepted as a violation-reducing repair: boundary ${boundary} -> ` +
1436
+ `${candidate} strands fewer placed orders than the committed geometry (${check?.reason})`, 'warn');
1437
+ }
1438
+ catch { /* logging is best-effort */ }
1412
1439
  }
1413
1440
  try {
1414
1441
  manager.logger?.log?.(`[BOUNDARY] Re-anchored from the last fill: ${side} filled at slot ${anchorIdx} ` +
@@ -1783,6 +1810,48 @@ export function hasUnsettledFills(source) {
1783
1810
  }
1784
1811
  return { unsettled: false, reason: null };
1785
1812
  }
1813
+ /**
1814
+ * Age of the most recent bot-level pipeline raise.
1815
+ *
1816
+ * The two counters (`_batchInFlight`, `_recoverySyncInFlight`) each carry a
1817
+ * `*StartedAt` stamp maintained by their raise site; a nested raise (a COW
1818
+ * re-plan, a second recovery frame) refreshes it, so this reports how long ago
1819
+ * the pipeline LAST showed activity, not how long the oldest frame has been
1820
+ * open. That is the question a stale-region watchdog needs: a recent raise is
1821
+ * evidence of progress. Lives here (next to
1822
+ * `hasUnsettledFills`, the same bot/manager field-peeking contract) so the
1823
+ * maintenance tick and the fill consumer cannot disagree about it.
1824
+ *
1825
+ * @param {Object} source - DEXBot-like (or OrderManager-like) instance
1826
+ * @param {number} [nowMs] - Clock override (tests)
1827
+ * @returns {number} Milliseconds since the most recent raise, 0 when nothing
1828
+ * is in flight or the stamp is missing
1829
+ */
1830
+ export function getPipelineInFlightAgeMs(source, nowMs) {
1831
+ if (!source || typeof source !== 'object')
1832
+ return 0;
1833
+ const outer = source;
1834
+ const bot = (outer.manager && typeof outer.manager === 'object') ? outer : source;
1835
+ const fields = bot;
1836
+ const now = Number.isFinite(Number(nowMs)) ? Number(nowMs) : Date.now();
1837
+ const pairs = [
1838
+ ['_batchInFlight', '_batchInFlightStartedAt'],
1839
+ ['_recoverySyncInFlight', '_recoverySyncInFlightStartedAt'],
1840
+ ];
1841
+ let oldest = -1;
1842
+ for (const [countKey, startedKey] of pairs) {
1843
+ const count = Number(fields[countKey]) || 0;
1844
+ if (count <= 0)
1845
+ continue;
1846
+ const startedAt = Number(fields[startedKey]) || 0;
1847
+ if (!startedAt)
1848
+ continue;
1849
+ const age = Math.max(0, now - startedAt);
1850
+ if (age > oldest)
1851
+ oldest = age;
1852
+ }
1853
+ return oldest > 0 ? oldest : 0;
1854
+ }
1786
1855
  /**
1787
1856
  * Restore the persisted bot-scoped last-market-fill reference into the
1788
1857
  * manager. Deliberately independent of the boundary and the genesis: this is
@@ -2726,11 +2795,16 @@ export async function withBlockchainRetry(fn, label, options) {
2726
2795
  }
2727
2796
  catch (err) {
2728
2797
  lastError = err;
2729
- // Report node failure so NodeManager can blacklist and trigger failover
2798
+ // Report node failure so NodeManager can blacklist and trigger failover.
2799
+ // Attribute it to the node that actually served the attempt —
2800
+ // getBestNode() is the top *candidate*, which is frequently a
2801
+ // different node than the connected one, so using it punished an
2802
+ // innocent node and left the failing one in place.
2730
2803
  try {
2731
- const { getNodeManager } = require('../../bitshares_client');
2804
+ const { getNodeManager, getActiveNodeUrl } = require('../../bitshares_client');
2732
2805
  const nodeManager = getNodeManager?.();
2733
- const nodeUrl = nodeManager?.getBestNode?.();
2806
+ const nodeUrl = (typeof getActiveNodeUrl === 'function' ? getActiveNodeUrl() : null)
2807
+ || nodeManager?.getBestNode?.();
2734
2808
  if (nodeUrl && typeof nodeManager.reportNodeFailure === 'function') {
2735
2809
  nodeManager.reportNodeFailure(nodeUrl, getErrorMessage(err), 'blockchain-op');
2736
2810
  }
@@ -2744,9 +2818,11 @@ export async function withBlockchainRetry(fn, label, options) {
2744
2818
  }
2745
2819
  // All retries exhausted — force-switch to a different node and retry once more
2746
2820
  try {
2747
- const { getNodeManager, reconnectForCycle } = require('../../bitshares_client');
2821
+ const { getNodeManager, reconnectForCycle, getActiveNodeUrl } = require('../../bitshares_client');
2748
2822
  const nodeManager = getNodeManager?.();
2749
- const failedNode = nodeManager?.getBestNode?.();
2823
+ // Blacklist the node the operation ran on, not the best candidate.
2824
+ const failedNode = (typeof getActiveNodeUrl === 'function' ? getActiveNodeUrl() : null)
2825
+ || nodeManager?.getBestNode?.();
2750
2826
  if (failedNode && typeof nodeManager.blacklistNode === 'function') {
2751
2827
  nodeManager.blacklistNode(failedNode);
2752
2828
  logger?.log?.(`${label}: blacklisted node ${failedNode.substring(0, 40)}... after ${maxRetries} failed attempts. Switching nodes...`, 'warn');
@@ -224,7 +224,13 @@ declare function hasExecutableActions(rebalanceResult: unknown): boolean;
224
224
  * with {chainOrderId, price, size, type} to check beyond the grid
225
225
  * @returns {{isValid: boolean, violations: Array<Object>, violatingTargetIds: Set<string>}} Validation result
226
226
  */
227
- declare function validateCreateTargetSlots(actions: CowAction[], orders: Map<string, ManagedOrder>, _assets?: AssetPair | null, chainOrderCandidates?: UnmatchedChainOrder[], incrementPercent?: number | null): {
227
+ declare function validateCreateTargetSlots(actions: CowAction[], orders: Map<string, ManagedOrder>, _assets?: AssetPair | null, chainOrderCandidates?: UnmatchedChainOrder[], incrementPercent?: number | null, pendingBroadcasts?: Array<{
228
+ slotId?: unknown;
229
+ price?: unknown;
230
+ size?: unknown;
231
+ type?: unknown;
232
+ fingerprint?: unknown;
233
+ }>): {
228
234
  isValid: boolean;
229
235
  violations: CreateTargetViolation[];
230
236
  violatingTargetIds: Set<string>;
@@ -40,6 +40,7 @@ import * as Format from '../format.js';
40
40
  import { ORDER_STATES, ORDER_TYPES, COW_ACTIONS, COW_ORIGINS, GRID_LIMITS } from '../../constants.js';
41
41
  import { floatToBlockchainInt, blockchainToFloat, getPrecisionSlack, getPrecisionByOrderType, getDoubleDustThreshold, getSellStartIdx, isSlotIndexInGapBand, isEvacuationRotationAllowed, clamp, pricesOnSameLevel, sameGridPrice } from './math.js';
42
42
  import { parseSlotIndex } from './slot.js';
43
+ import { isSlotCreateUncertain } from '../lifecycle.js';
43
44
  import { isOrderOnChain, isPhantomOrder, convertToSpreadPlaceholder, detectGapEvacuationCandidates, updateGapEvacuationStreaks, isNonBlockingUnmatchedOrder } from './order.js';
44
45
  const { isValidNumber, toFiniteNumber } = Format;
45
46
  // Pre-computed valid sets
@@ -751,7 +752,7 @@ function hasExecutableActions(rebalanceResult) {
751
752
  * with {chainOrderId, price, size, type} to check beyond the grid
752
753
  * @returns {{isValid: boolean, violations: Array<Object>, violatingTargetIds: Set<string>}} Validation result
753
754
  */
754
- function validateCreateTargetSlots(actions, orders, _assets = null, chainOrderCandidates = [], incrementPercent = null) {
755
+ function validateCreateTargetSlots(actions, orders, _assets = null, chainOrderCandidates = [], incrementPercent = null, pendingBroadcasts = []) {
755
756
  const safeActions = Array.isArray(actions) ? actions : [];
756
757
  const orderMap = orders instanceof Map ? orders : new Map();
757
758
  const releasedSlotIds = new Set();
@@ -785,7 +786,9 @@ function validateCreateTargetSlots(actions, orders, _assets = null, chainOrderCa
785
786
  // sync pass 1 (`sync-clear-stale-id`), which turns the slot back into a
786
787
  // plain hole on the next cycle — so this gate cannot strand a level.
787
788
  const currentOwnsChainId = Boolean(current?.orderId);
788
- const currentCreateUncertain = current?.createUncertain === true;
789
+ // Single definition of the durable "CREATE result lost" marker
790
+ // (modules/order/lifecycle.ts) — this site used to read the raw flag.
791
+ const currentCreateUncertain = isSlotCreateUncertain(current);
789
792
  if (current && (isOrderOnChain(current) || currentOwnsChainId)) {
790
793
  violations.push({
791
794
  targetId,
@@ -866,6 +869,49 @@ function validateCreateTargetSlots(actions, orders, _assets = null, chainOrderCa
866
869
  }
867
870
  }
868
871
  }
872
+ // Pending-broadcast collisions: an uncertain CREATE from an earlier
873
+ // batch already targets this slot/price. Its orderId is not visible yet
874
+ // (the broadcast outcome is unknown), so the chain-orphan layers above
875
+ // cannot see it. Landing a second CREATE at the same level duplicates
876
+ // the order. Check BOTH the exact slot id and the price level, because
877
+ // a rebuilt grid can re-map a price onto a different slot id.
878
+ if (pendingBroadcasts.length > 0) {
879
+ const pendingSlotIds = new Set();
880
+ for (const p of pendingBroadcasts) {
881
+ if (p?.slotId != null && String(p.slotId).length > 0)
882
+ pendingSlotIds.add(String(p.slotId));
883
+ }
884
+ for (const entry of createEntries) {
885
+ if (pendingSlotIds.has(entry.targetId)) {
886
+ violations.push({
887
+ targetId: entry.targetId,
888
+ currentOrderId: `pending:${entry.targetId}`,
889
+ currentType: entry.type,
890
+ currentState: 'PENDING_BROADCAST',
891
+ reason: 'pending_broadcast_collision'
892
+ });
893
+ continue;
894
+ }
895
+ if (!_assets)
896
+ continue;
897
+ for (const p of pendingBroadcasts) {
898
+ if (p?.price == null)
899
+ continue;
900
+ if (p.type && entry.type && p.type !== entry.type)
901
+ continue;
902
+ if (pricesOnSameLevel(Number(p.price), Number(p.size) || 0, p.type, Number(entry.price), Number(entry.size) || 0, entry.type, _assets, incrementPercent)) {
903
+ violations.push({
904
+ targetId: entry.targetId,
905
+ currentOrderId: `pending:${String(p.fingerprint ?? p.slotId ?? 'unknown')}`,
906
+ currentType: entry.type,
907
+ currentState: 'PENDING_BROADCAST',
908
+ reason: 'pending_broadcast_collision'
909
+ });
910
+ break;
911
+ }
912
+ }
913
+ }
914
+ }
869
915
  // Same-batch duplicate slot
870
916
  const seen = new Set();
871
917
  for (const entry of createEntries) {
@@ -0,0 +1,54 @@
1
+ /**
2
+ * modules/outcome.ts - Three-valued outcomes
3
+ *
4
+ * The engine has many operations whose result is genuinely unknowable: a
5
+ * broadcast whose receipt was lost, a chain read that came back ambiguous, a
6
+ * timeout that won a race. Historically each such site returned a plain object
7
+ * with an ad-hoc `uncertain: true` field — sometimes next to a *second* ad-hoc
8
+ * flag describing the same fact (`ambiguousRead`), so the two could disagree
9
+ * and no consumer was forced to handle the third case at all.
10
+ *
11
+ * `Outcome<T>` (modules/types.ts) gives that third case a name. This module is
12
+ * the only place those result objects are constructed, so the flags cannot
13
+ * drift apart: one `cause` in, both legacy booleans derived out.
14
+ *
15
+ * Browser-safe: no Node APIs.
16
+ */
17
+ import type { UnknownCause, UnknownOutcome } from './types.js';
18
+ /**
19
+ * Build an `unknown` outcome. Callers must name the cause.
20
+ *
21
+ * @param cause - Why the outcome is unknown
22
+ * @param detail - Optional human-readable context
23
+ * @returns {UnknownOutcome} An `unknown` outcome
24
+ */
25
+ export declare function unknownOutcome(cause: UnknownCause, detail?: string): UnknownOutcome;
26
+ export interface CowOutcomeShape {
27
+ executed: boolean;
28
+ hadRotation: boolean;
29
+ [key: string]: unknown;
30
+ }
31
+ export interface UnknownCowOutcome extends CowOutcomeShape {
32
+ /** Canonical discriminator. */
33
+ kind: 'unknown';
34
+ /** Canonical reason. */
35
+ cause: UnknownCause;
36
+ /** Legacy alias kept for existing readers; always true. */
37
+ uncertain: true;
38
+ /** Legacy alias kept for existing readers; derived from `cause`. */
39
+ ambiguousRead: boolean;
40
+ }
41
+ /**
42
+ * Build a COW result for a batch whose effect is not knowable.
43
+ *
44
+ * `cause` is the single input: `uncertain` is always true and `ambiguousRead`
45
+ * is true exactly when the cause is an ambiguous read. A caller cannot make
46
+ * those two disagree because it never sets them. Fields in `extra` are merged
47
+ * FIRST, so they cannot override the canonical ones either.
48
+ *
49
+ * @param cause - Why the outcome is unknown
50
+ * @param extra - Additional fields to merge (e.g. adoptedCount)
51
+ * @returns {UnknownCowOutcome} Consistent COW result
52
+ */
53
+ export declare function unknownCowOutcome(cause: UnknownCause, extra?: Record<string, unknown>): UnknownCowOutcome;
54
+ //# sourceMappingURL=outcome.d.ts.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * modules/outcome.ts - Three-valued outcomes
3
+ *
4
+ * The engine has many operations whose result is genuinely unknowable: a
5
+ * broadcast whose receipt was lost, a chain read that came back ambiguous, a
6
+ * timeout that won a race. Historically each such site returned a plain object
7
+ * with an ad-hoc `uncertain: true` field — sometimes next to a *second* ad-hoc
8
+ * flag describing the same fact (`ambiguousRead`), so the two could disagree
9
+ * and no consumer was forced to handle the third case at all.
10
+ *
11
+ * `Outcome<T>` (modules/types.ts) gives that third case a name. This module is
12
+ * the only place those result objects are constructed, so the flags cannot
13
+ * drift apart: one `cause` in, both legacy booleans derived out.
14
+ *
15
+ * Browser-safe: no Node APIs.
16
+ */
17
+ /**
18
+ * Build an `unknown` outcome. Callers must name the cause.
19
+ *
20
+ * @param cause - Why the outcome is unknown
21
+ * @param detail - Optional human-readable context
22
+ * @returns {UnknownOutcome} An `unknown` outcome
23
+ */
24
+ export function unknownOutcome(cause, detail) {
25
+ return detail ? { kind: 'unknown', cause, detail } : { kind: 'unknown', cause };
26
+ }
27
+ /**
28
+ * Build a COW result for a batch whose effect is not knowable.
29
+ *
30
+ * `cause` is the single input: `uncertain` is always true and `ambiguousRead`
31
+ * is true exactly when the cause is an ambiguous read. A caller cannot make
32
+ * those two disagree because it never sets them. Fields in `extra` are merged
33
+ * FIRST, so they cannot override the canonical ones either.
34
+ *
35
+ * @param cause - Why the outcome is unknown
36
+ * @param extra - Additional fields to merge (e.g. adoptedCount)
37
+ * @returns {UnknownCowOutcome} Consistent COW result
38
+ */
39
+ export function unknownCowOutcome(cause, extra = {}) {
40
+ const outcome = unknownOutcome(cause);
41
+ return {
42
+ ...extra,
43
+ executed: false,
44
+ hadRotation: false,
45
+ kind: outcome.kind,
46
+ cause: outcome.cause,
47
+ uncertain: true,
48
+ ambiguousRead: outcome.cause === 'ambiguous-read',
49
+ };
50
+ }
51
+ //# sourceMappingURL=outcome.js.map
@@ -44,6 +44,10 @@ interface NodesHealthCheckView {
44
44
  timeoutMs?: number;
45
45
  maxPingMs?: number;
46
46
  blacklistThreshold?: number;
47
+ strikeDecayMs?: number;
48
+ flapHalfLifeMs?: number;
49
+ flapPenaltyMsPerDrop?: number;
50
+ flapPenaltyMaxMs?: number;
47
51
  [key: string]: unknown;
48
52
  }
49
53
  interface NodesSelectionView {
@@ -86,6 +86,11 @@ const NODES_SUBKEY_MAP = {
86
86
  timeoutMs: 'HEALTH_CHECK_TIMEOUT_MS',
87
87
  maxPingMs: 'MAX_PING_MS',
88
88
  blacklistThreshold: 'BLACKLIST_THRESHOLD',
89
+ // Strike lifetime and flapping penalty (see modules/node_flap_score.ts).
90
+ strikeDecayMs: 'FAILURE_STRIKE_DECAY_MS',
91
+ flapHalfLifeMs: 'FLAP_HALF_LIFE_MS',
92
+ flapPenaltyMsPerDrop: 'FLAP_PENALTY_MS_PER_DROP',
93
+ flapPenaltyMaxMs: 'FLAP_PENALTY_MAX_MS',
89
94
  },
90
95
  selection: {
91
96
  strategy: 'SELECTION_STRATEGY',
@@ -134,6 +139,10 @@ function buildNodesView(nm) {
134
139
  timeoutMs: nm.HEALTH_CHECK_TIMEOUT_MS,
135
140
  maxPingMs: nm.MAX_PING_MS,
136
141
  blacklistThreshold: nm.BLACKLIST_THRESHOLD,
142
+ strikeDecayMs: nm.FAILURE_STRIKE_DECAY_MS,
143
+ flapHalfLifeMs: nm.FLAP_HALF_LIFE_MS,
144
+ flapPenaltyMsPerDrop: nm.FLAP_PENALTY_MS_PER_DROP,
145
+ flapPenaltyMaxMs: nm.FLAP_PENALTY_MAX_MS,
137
146
  },
138
147
  selection: {
139
148
  strategy: nm.SELECTION_STRATEGY,