@orangecharts/wrun-chart-host 0.6.0 → 0.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 (142) hide show
  1. package/README.md +14 -5
  2. package/dist/constants/marketCapabilities.constants.d.ts +5 -0
  3. package/dist/constants/marketCapabilities.constants.js +16 -0
  4. package/dist/host-ports.types.d.ts +35 -3
  5. package/dist/index.d.ts +11 -1
  6. package/dist/index.js +11 -1
  7. package/dist/indicators/controls/tpo-session.util.js +42 -18
  8. package/dist/market-data/billing.interface.d.ts +2 -1
  9. package/dist/settings-templates/index.d.ts +2 -0
  10. package/dist/settings-templates/index.js +19 -5
  11. package/dist/settings-templates/indicator-fields.d.ts +2 -0
  12. package/dist/settings-templates/indicator-fields.js +10 -0
  13. package/dist/settings-templates/tool-rules.d.ts +12 -2
  14. package/dist/settings-templates/tool-rules.js +9 -2
  15. package/dist/settings-templates/tool-tables.generated.js +9 -0
  16. package/dist/utility/chart/crypto-index.leaf.d.ts +16 -0
  17. package/dist/utility/chart/crypto-index.leaf.js +19 -0
  18. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  19. package/dist/utility/chart/index-mode.util.d.ts +11 -5
  20. package/dist/utility/chart/index-mode.util.js +22 -10
  21. package/dist/utility/chart/kscript-source-answer-budget.leaf.d.ts +36 -0
  22. package/dist/utility/chart/kscript-source-answer-budget.leaf.js +39 -0
  23. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +38 -1
  24. package/dist/utility/chart/kscript-source-degrade.leaf.js +39 -1
  25. package/dist/utility/chart/live-bucket.util.d.ts +2 -1
  26. package/dist/utility/chart/live-bucket.util.js +47 -15
  27. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +15 -1
  28. package/dist/utility/chart/local-kscript-warmup-depth.util.js +9 -0
  29. package/dist/utility/chart/market-session-schedule.util.d.ts +3 -1
  30. package/dist/utility/chart/market-session-schedule.util.js +24 -2
  31. package/dist/utility/chart/marketKind.util.d.ts +12 -7
  32. package/dist/utility/chart/marketKind.util.js +15 -5
  33. package/dist/utility/chart/ny-calendar.util.d.ts +104 -0
  34. package/dist/utility/chart/ny-calendar.util.js +346 -0
  35. package/dist/utility/chart/om-panel.util.d.ts +14 -2
  36. package/dist/utility/chart/om-panel.util.js +108 -40
  37. package/dist/utility/chart/rth-session.util.d.ts +10 -7
  38. package/dist/utility/chart/rth-session.util.js +17 -22
  39. package/dist/utility/chart/trading-day.util.js +90 -18
  40. package/dist/utility/chart/us-equities-session.util.js +20 -67
  41. package/dist/utility/chart/wrun-bar-session-facts.util.js +14 -1
  42. package/dist/utility/common/time.util.d.ts +7 -1
  43. package/dist/utility/common/time.util.js +11 -41
  44. package/dist/utility/number-format.util.d.ts +17 -7
  45. package/dist/utility/number-format.util.js +18 -8
  46. package/dist/utility/options/option-symbol.util.js +13 -2
  47. package/dist/utility/symbol-selection/contract-expiry.util.js +9 -1
  48. package/dist/utility/watchlist/import/import-request.leaf.d.ts +4 -1
  49. package/dist/utility/watchlist/import/import-request.leaf.js +5 -2
  50. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +25 -4
  51. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +62 -4
  52. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +19 -0
  53. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +57 -0
  54. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +23 -0
  55. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +90 -0
  56. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.d.ts +39 -0
  57. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.js +60 -0
  58. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +77 -0
  59. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +195 -0
  60. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +56 -0
  61. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +70 -0
  62. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +53 -0
  63. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +239 -0
  64. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +16 -0
  65. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +14 -0
  66. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +43 -18
  67. package/dist/utility/wrun/sources/lanes/options_flow.js +209 -72
  68. package/dist/utility/wrun/sources/lanes/token_supply.js +5 -31
  69. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -18
  70. package/dist/utility/wrun/sources/opra-option-lanes.util.js +12 -57
  71. package/dist/utility/wrun/sources/row-lane-registry.d.ts +1 -1
  72. package/dist/utility/wrun/sources/row-lane-registry.js +22 -8
  73. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +61 -0
  74. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +103 -8
  75. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +5 -0
  76. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +24 -12
  77. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +55 -0
  78. package/dist/utility/wrun/sources/row-lanes/option_prints.js +95 -18
  79. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +15 -1
  80. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +23 -8
  81. package/dist/utility/wrun/sources/row-lanes/option_surface.js +11 -11
  82. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +14 -2
  83. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +6 -3
  84. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +43 -8
  85. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +77 -11
  86. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -16
  87. package/dist/utility/wrun/sources/wrun-row-lane.types.js +2 -0
  88. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +52 -12
  89. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +110 -46
  90. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +10 -0
  91. package/dist/utility/wrun/wrun-browser-sources.leaf.js +12 -0
  92. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +3 -3
  93. package/dist/utility/wrun/wrun-coin-lane-live.util.js +53 -18
  94. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -0
  95. package/dist/utility/wrun/wrun-color-settings.util.js +45 -0
  96. package/dist/utility/wrun/wrun-draft-overlay.util.js +14 -8
  97. package/dist/utility/wrun/wrun-failure-cause.d.ts +1 -1
  98. package/dist/utility/wrun/wrun-failure-cause.js +14 -0
  99. package/dist/utility/wrun/wrun-frames.js +6 -2
  100. package/dist/utility/wrun/wrun-host.service.d.ts +26 -18
  101. package/dist/utility/wrun/wrun-host.service.js +49 -52
  102. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
  103. package/dist/utility/wrun/wrun-hosted-wire-caps.js +2 -0
  104. package/dist/utility/wrun/wrun-input-requirements.leaf.js +7 -4
  105. package/dist/utility/wrun/wrun-kit-run-tables.util.d.ts +24 -0
  106. package/dist/utility/wrun/wrun-kit-run-tables.util.js +87 -0
  107. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +2 -1
  108. package/dist/utility/wrun/wrun-live-tick.util.d.ts +8 -2
  109. package/dist/utility/wrun/wrun-live-tick.util.js +35 -16
  110. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +40 -13
  111. package/dist/utility/wrun/wrun-opra-flow.leaf.js +39 -12
  112. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +70 -21
  113. package/dist/utility/wrun/wrun-option-contract-flow.util.js +257 -112
  114. package/dist/utility/wrun/wrun-option-prints.util.d.ts +62 -22
  115. package/dist/utility/wrun/wrun-option-prints.util.js +148 -46
  116. package/dist/utility/wrun/wrun-option-views.util.d.ts +262 -0
  117. package/dist/utility/wrun/wrun-option-views.util.js +356 -0
  118. package/dist/utility/wrun/wrun-options-chain.util.d.ts +23 -2
  119. package/dist/utility/wrun/wrun-options-chain.util.js +37 -3
  120. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +18 -3
  121. package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -7
  122. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -3
  123. package/dist/utility/wrun/wrun-overlay-recovery.util.js +146 -18
  124. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +50 -6
  125. package/dist/utility/wrun/wrun-overlay-run.util.js +816 -243
  126. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +5 -0
  127. package/dist/utility/wrun/wrun-pin-spelling.util.js +28 -12
  128. package/dist/utility/wrun/wrun-pin-venues.util.js +4 -6
  129. package/dist/utility/wrun/wrun-present-bits.util.d.ts +9 -0
  130. package/dist/utility/wrun/wrun-present-bits.util.js +39 -0
  131. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +3 -2
  132. package/dist/utility/wrun/wrun-refusal-surface.util.js +5 -4
  133. package/dist/utility/wrun/wrun-refusal.util.d.ts +66 -6
  134. package/dist/utility/wrun/wrun-refusal.util.js +335 -40
  135. package/dist/utility/wrun/wrun-source-rows.util.js +11 -0
  136. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +28 -3
  137. package/dist/utility/wrun/wrun-tier-grid.util.js +79 -19
  138. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +14 -3
  139. package/dist/utility/wrun/wrun-transient-rerun.util.js +33 -8
  140. package/package.json +5 -5
  141. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +0 -12
  142. package/dist/utility/wrun/wrun-opra-underlying.util.js +0 -1
@@ -1116,6 +1116,7 @@ export const TOOL_TEMPLATE_KEYS = {
1116
1116
  'textVerticalPosition',
1117
1117
  'fontWeight',
1118
1118
  'fontStyle',
1119
+ 'text',
1119
1120
  'visibleIntervalsMs',
1120
1121
  ],
1121
1122
  FibChannel: [
@@ -1347,6 +1348,7 @@ export const TOOL_TEMPLATE_KEYS = {
1347
1348
  'fontWeight',
1348
1349
  'fontStyle',
1349
1350
  'highlight',
1351
+ 'text',
1350
1352
  'visibleIntervalsMs',
1351
1353
  ],
1352
1354
  HorizontalRay: [
@@ -1360,6 +1362,7 @@ export const TOOL_TEMPLATE_KEYS = {
1360
1362
  'fontWeight',
1361
1363
  'fontStyle',
1362
1364
  'highlight',
1365
+ 'text',
1363
1366
  'visibleIntervalsMs',
1364
1367
  ],
1365
1368
  Icon: ['color', 'visibleIntervalsMs'],
@@ -1383,6 +1386,7 @@ export const TOOL_TEMPLATE_KEYS = {
1383
1386
  'stats',
1384
1387
  'statsPosition',
1385
1388
  'alwaysShowStats',
1389
+ 'text',
1386
1390
  'visibleIntervalsMs',
1387
1391
  ],
1388
1392
  InsidePitchfork: [
@@ -1438,6 +1442,7 @@ export const TOOL_TEMPLATE_KEYS = {
1438
1442
  'fontStyle',
1439
1443
  'fillBackground',
1440
1444
  'middleLine',
1445
+ 'text',
1441
1446
  'visibleIntervalsMs',
1442
1447
  ],
1443
1448
  Path: ['color', 'visibleIntervalsMs'],
@@ -1489,6 +1494,7 @@ export const TOOL_TEMPLATE_KEYS = {
1489
1494
  'textVerticalPosition',
1490
1495
  'fontWeight',
1491
1496
  'fontStyle',
1497
+ 'text',
1492
1498
  'visibleIntervalsMs',
1493
1499
  ],
1494
1500
  Rectangle: [
@@ -1505,6 +1511,7 @@ export const TOOL_TEMPLATE_KEYS = {
1505
1511
  'fontSize',
1506
1512
  'textPosition',
1507
1513
  'textVerticalPosition',
1514
+ 'text',
1508
1515
  'visibleIntervalsMs',
1509
1516
  ],
1510
1517
  RegressionTrend: [
@@ -1623,6 +1630,7 @@ export const TOOL_TEMPLATE_KEYS = {
1623
1630
  'stats',
1624
1631
  'statsPosition',
1625
1632
  'alwaysShowStats',
1633
+ 'text',
1626
1634
  'visibleIntervalsMs',
1627
1635
  ],
1628
1636
  Triangle: [
@@ -1653,6 +1661,7 @@ export const TOOL_TEMPLATE_KEYS = {
1653
1661
  'textVerticalPosition',
1654
1662
  'fontWeight',
1655
1663
  'fontStyle',
1664
+ 'text',
1656
1665
  'visibleIntervalsMs',
1657
1666
  ],
1658
1667
  Whisper: ['color', 'highlight', 'lineWidth', 'visibleIntervalsMs'],
@@ -0,0 +1,16 @@
1
+ /**
2
+ * CRYPTOCAP: the venue of the crypto-wide indices and dominance series (BTC.D, TOTAL, TOTAL2, OTHERS.D, ...; see
3
+ * docs/features/data/cryptocap-indices.md). The backend prints each series as raw CRYPTO_DOMINANCE points and serves
4
+ * its candles as CRYPTO_DOMINANCE_AGG on tsdb-gateway v2: value candles with no volume, trades or book behind them.
5
+ *
6
+ * A leaf on purpose, with no imports: the market-kind table (`marketKind.util`) and the ticker hub and the sub-minute
7
+ * block (`index-mode.util`) both read this list, and neither may call into the other at module load. Web code asks
8
+ * `checkIsCryptoIndex` here, never through `index-mode.util` or `marketKind.util`: over a hundred specs mock those two
9
+ * with partial factories, and a predicate read through such a mock throws.
10
+ */
11
+ export declare const CRYPTO_INDEX_EXCHANGES: readonly ["CRYPTOCAP"];
12
+ /**
13
+ * A crypto index venue (`CRYPTO_INDEX_EXCHANGES`), the `'cryptoIndex'` market kind. Case-insensitive like the kind
14
+ * table, and a foreign shape (a persisted object, a number) is no venue, never a throw.
15
+ */
16
+ export declare function checkIsCryptoIndex(exchange: string | undefined | null): boolean;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * CRYPTOCAP: the venue of the crypto-wide indices and dominance series (BTC.D, TOTAL, TOTAL2, OTHERS.D, ...; see
3
+ * docs/features/data/cryptocap-indices.md). The backend prints each series as raw CRYPTO_DOMINANCE points and serves
4
+ * its candles as CRYPTO_DOMINANCE_AGG on tsdb-gateway v2: value candles with no volume, trades or book behind them.
5
+ *
6
+ * A leaf on purpose, with no imports: the market-kind table (`marketKind.util`) and the ticker hub and the sub-minute
7
+ * block (`index-mode.util`) both read this list, and neither may call into the other at module load. Web code asks
8
+ * `checkIsCryptoIndex` here, never through `index-mode.util` or `marketKind.util`: over a hundred specs mock those two
9
+ * with partial factories, and a predicate read through such a mock throws.
10
+ */
11
+ export const CRYPTO_INDEX_EXCHANGES = ['CRYPTOCAP'];
12
+ const CRYPTO_INDEX_EXCHANGES_SET = new Set(CRYPTO_INDEX_EXCHANGES);
13
+ /**
14
+ * A crypto index venue (`CRYPTO_INDEX_EXCHANGES`), the `'cryptoIndex'` market kind. Case-insensitive like the kind
15
+ * table, and a foreign shape (a persisted object, a number) is no venue, never a throw.
16
+ */
17
+ export function checkIsCryptoIndex(exchange) {
18
+ return typeof exchange === 'string' && CRYPTO_INDEX_EXCHANGES_SET.has(exchange.toUpperCase());
19
+ }
@@ -14,11 +14,14 @@
14
14
  * Two market facts narrow it for a browser-run Indicator's lanes (`wrunLaneServiceOnMarket`):
15
15
  * - the market-kind table: forex and commodities trade no volume the chart can split, keep no
16
16
  * book and list no options, so they serve no volume profile, buy/sell volume, order book,
17
- * implied volatility or skew, whatever the index-mode admission lets through;
17
+ * implied volatility or skew, whatever the index-mode admission lets through; a crypto index
18
+ * (CRYPTOCAP, not index-mode: it fetches by period like crypto) serves its value candles and no
19
+ * other lane at all;
18
20
  * - the coin table: the option-summary lanes (implied volatility, skew) hold a series for the
19
21
  * coins `WRUN_OPTION_SUMMARY_COINS` lists (BTC and ETH) and no other.
20
22
  * The dispatcher's own admission (`isKScriptTypeServedOnIndexMode`) stays as it is.
21
23
  */
24
+ import { checkIsCryptoIndex } from './crypto-index.leaf.js';
22
25
  import { checkIsIndexMode } from './index-mode.util.js';
23
26
  import { checkIsForexOrCommodity } from './marketKind.util.js';
24
27
  import { WRUN_OPTION_SUMMARY_COINS, WRUN_OPTION_SUMMARY_LANES } from '../wrun/wrun-option-summary-lane.util.js';
@@ -34,6 +37,8 @@ const FOREX_COMMODITY_UNSERVED_TYPES = new Set([
34
37
  WRUN_OPTION_SUMMARY_LANES.implied_volatility.type,
35
38
  WRUN_OPTION_SUMMARY_LANES.skew.type,
36
39
  ]);
40
+ /** The one lane fetch type a crypto index market serves (the market-kind table): its value candles. */
41
+ const CRYPTO_INDEX_SERVED_TYPES = new Set(['ohlcv']);
37
42
  /** The lane fetch types served for some coins only, and those coins (the coin table). */
38
43
  const COIN_SERVED_TYPES = Object.freeze({
39
44
  [WRUN_OPTION_SUMMARY_LANES.implied_volatility.type]: WRUN_OPTION_SUMMARY_COINS,
@@ -55,6 +60,9 @@ export function wrunLaneServiceOnMarket({ type, exchange, coin, nativeRows, }) {
55
60
  if (FOREX_COMMODITY_UNSERVED_TYPES.has(type) && checkIsForexOrCommodity(exchange)) {
56
61
  return { served: false, reason: 'market-kind' };
57
62
  }
63
+ if (!CRYPTO_INDEX_SERVED_TYPES.has(type) && checkIsCryptoIndex(exchange)) {
64
+ return { served: false, reason: 'market-kind' };
65
+ }
58
66
  const coins = COIN_SERVED_TYPES[type];
59
67
  const word = typeof coin === 'string' ? coin.trim().toUpperCase() : '';
60
68
  if (coins !== undefined && word !== '' && !coins.includes(word))
@@ -55,11 +55,17 @@ export declare function checkIsIndexMode(exchange: string | undefined): boolean;
55
55
  /** An index venue (`INDEX_VENUE_EXCHANGES`): a quote series on the US session grid. */
56
56
  export declare function checkIsIndexVenue(exchange: string | undefined): boolean;
57
57
  /**
58
- * Exchanges that use TICKER/TICKER_AGG data type instead of TRADE (forex,
59
- * commodity, the index venues). Governed CME needs no carve-out here: the
60
- * flag-dependent kind already classifies it futures (TRADE data) with the
61
- * release gate on and commodity (TICKER, fail-closed) with it off; both
62
- * states are pinned by cme-futures-capability.spec.ts.
58
+ * Exchanges that print quotes instead of trades: value-only candles with no
59
+ * volume and a quote channel live (forex, commodity and the index venues on
60
+ * TICKER/TICKER_AGG, the crypto indices on CRYPTO_DOMINANCE/CRYPTO_DOMINANCE_AGG).
61
+ * The hub of the quote routing: the candle parse (the ohlcv and K_OHLCV
62
+ * workers keep a volume-less row), the sided-candle refusal and the live
63
+ * channel (`liveQuoteType`, live-feed-channel-factory.util) all read it; the
64
+ * wire candle Type follows `seriesDomainOf` (V2_CANDLE_TYPE). Governed CME
65
+ * needs no carve-out here: the flag-dependent kind already classifies it
66
+ * futures (TRADE data) with the release gate on and commodity (TICKER,
67
+ * fail-closed) with it off; both states are pinned by
68
+ * cme-futures-capability.spec.ts.
63
69
  */
64
70
  export declare function checkIsTickerDataType(exchange: string | undefined): boolean;
65
71
  export declare function checkIsBlockedOn1s(exchange: string | undefined): boolean;
@@ -1,4 +1,5 @@
1
1
  import { formatDisplayToExchange } from '../exchange-normalization.util.js';
2
+ import { CRYPTO_INDEX_EXCHANGES, checkIsCryptoIndex } from './crypto-index.leaf.js';
2
3
  import { PREDICTION_MARKET_EXCHANGE_NAMES } from './prediction-identity.util.js';
3
4
  // ============================================================================
4
5
  // EXCHANGE CONSTANTS
@@ -48,10 +49,15 @@ const INDEX_MODE_EXCHANGES = [
48
49
  ...COMMODITY_EXCHANGES,
49
50
  ...INDEX_VENUE_EXCHANGES,
50
51
  ];
51
- // Exchanges that don't support 1s interval (index mode + prediction + forex + commodity).
52
- // Prediction venues poll a price rather than printing trades, so none of them can
53
- // host a 1s bar — the list tracks the venue SET, not Polymarket alone.
54
- const EXCHANGES_BLOCKED_ON_1S = [...INDEX_MODE_EXCHANGES, ...PREDICTION_MARKET_EXCHANGE_NAMES];
52
+ // Exchanges that don't support 1s interval (index mode + prediction + forex + commodity + the
53
+ // crypto indices). Prediction venues poll a price rather than printing trades, so none of them can
54
+ // host a 1s bar: the list tracks the venue SET, not Polymarket alone. The crypto indices'
55
+ // candle tables start at 1m, so no sub-minute rung is ever served there.
56
+ const EXCHANGES_BLOCKED_ON_1S = [
57
+ ...INDEX_MODE_EXCHANGES,
58
+ ...PREDICTION_MARKET_EXCHANGE_NAMES,
59
+ ...CRYPTO_INDEX_EXCHANGES,
60
+ ];
55
61
  const PM_SIGNAL_CRYPTO_SYMBOLS = ['BTC', 'ETH', 'SOL', 'XRP'];
56
62
  const PM_SIGNAL_TRADFI_SYMBOLS = [
57
63
  'TSLA',
@@ -315,14 +321,20 @@ export function checkIsIndexVenue(exchange) {
315
321
  return checkIsExchangeInSet(exchange, INDEX_VENUE_EXCHANGES_SET);
316
322
  }
317
323
  /**
318
- * Exchanges that use TICKER/TICKER_AGG data type instead of TRADE (forex,
319
- * commodity, the index venues). Governed CME needs no carve-out here: the
320
- * flag-dependent kind already classifies it futures (TRADE data) with the
321
- * release gate on and commodity (TICKER, fail-closed) with it off; both
322
- * states are pinned by cme-futures-capability.spec.ts.
324
+ * Exchanges that print quotes instead of trades: value-only candles with no
325
+ * volume and a quote channel live (forex, commodity and the index venues on
326
+ * TICKER/TICKER_AGG, the crypto indices on CRYPTO_DOMINANCE/CRYPTO_DOMINANCE_AGG).
327
+ * The hub of the quote routing: the candle parse (the ohlcv and K_OHLCV
328
+ * workers keep a volume-less row), the sided-candle refusal and the live
329
+ * channel (`liveQuoteType`, live-feed-channel-factory.util) all read it; the
330
+ * wire candle Type follows `seriesDomainOf` (V2_CANDLE_TYPE). Governed CME
331
+ * needs no carve-out here: the flag-dependent kind already classifies it
332
+ * futures (TRADE data) with the release gate on and commodity (TICKER,
333
+ * fail-closed) with it off; both states are pinned by
334
+ * cme-futures-capability.spec.ts.
323
335
  */
324
336
  export function checkIsTickerDataType(exchange) {
325
- return checkIsForex(exchange) || checkIsCommodity(exchange) || checkIsIndexVenue(exchange);
337
+ return (checkIsForex(exchange) || checkIsCommodity(exchange) || checkIsIndexVenue(exchange) || checkIsCryptoIndex(exchange));
326
338
  }
327
339
  export function checkIsBlockedOn1s(exchange) {
328
340
  if (isCmeFuturesPolicyActive(exchange))
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The source answer budget: the most one kScript source answer may hold, in bytes at 8 per numeric cell (the row
3
+ * cache's estimate, `estimateKScriptSourceRowsBytes`). It is the one size limit every layer a source answer crosses
4
+ * reads, so the layers cannot disagree again (OPTFLOW-HANG, field dump 2026-10-20 17:50 SGT):
5
+ *
6
+ * - the row lanes plan their asks to fit it (`rowBudget`, wrun-row-lanes.util `wrunRowLaneMaxRows`): the newest bars
7
+ * whose projected rows fit are read, every older asked bar is partial;
8
+ * - a worker twin that holds its own row cap fails an answer past the CEILING loudly (never truncated);
9
+ * - the source row cache keeps an answer up to the ceiling, so a planned answer is always kept and a rerun (the
10
+ * source ladder's rung, a remount, a lazy refresh) reads it instead of asking the wire again;
11
+ * - the source fetch boundary rings `kscript-source-answer-over-budget` for an answer past the budget, and the dump's
12
+ * `sourceAnswerOverBudget` verdict counts them.
13
+ *
14
+ * The field case it closes: SPY 1h with Premium by Strike and Strike Footprint. The contract flow lane sized each ask
15
+ * by the worker's 500,000-row failure cap (about 25 MB on the wire, 25 s), past the lane's own deadline (10.6 s for
16
+ * 252 bars) and the row cache's 8 MiB entry cap: the lane degraded before the answer landed, the cache refused the
17
+ * late answer, the source ladder asked again, and neither indicator painted. Each answer that landed crossed to the
18
+ * page as one structured clone of about 400,000 nested arrays (2.7 s on the main thread).
19
+ *
20
+ * Why 8 MiB: the cache's entry cap before this budget existed, and about 1.6 MB on the wire for SPY's contract flow
21
+ * (measured 2026-10-20 on INT: about 35 bytes a row), answered in 2 to 5 s, inside the lane deadline's 10 s floor.
22
+ * Raising it is one edit here: every layer follows. A deeper read needs a smaller answer, not a bigger budget (the
23
+ * per-strike fold, UW-PARITY design/STRIKE-FLOW-SCOPE.md).
24
+ */
25
+ /** Bytes one numeric cell weighs in every estimate of a source answer. */
26
+ export declare const KSCRIPT_SOURCE_CELL_BYTES = 8;
27
+ /** The bytes a planned source answer stays within. */
28
+ export declare const KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES: number;
29
+ /**
30
+ * The bytes a source answer may reach at all: twice the budget. A plan projects its rows from a measured session; a
31
+ * busier session can land past the budget, and up to the ceiling it is still delivered, cached and rung (flagged);
32
+ * past it a worker twin with its own row cap fails the request by name.
33
+ */
34
+ export declare const KSCRIPT_SOURCE_ANSWER_CEILING_BYTES: number;
35
+ /** The rows of `cellsPerRow` numeric cells each that fit `bytes` (the budget by default); at least one. */
36
+ export declare function kScriptSourceAnswerRows(cellsPerRow: number, bytes?: number): number;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The source answer budget: the most one kScript source answer may hold, in bytes at 8 per numeric cell (the row
3
+ * cache's estimate, `estimateKScriptSourceRowsBytes`). It is the one size limit every layer a source answer crosses
4
+ * reads, so the layers cannot disagree again (OPTFLOW-HANG, field dump 2026-10-20 17:50 SGT):
5
+ *
6
+ * - the row lanes plan their asks to fit it (`rowBudget`, wrun-row-lanes.util `wrunRowLaneMaxRows`): the newest bars
7
+ * whose projected rows fit are read, every older asked bar is partial;
8
+ * - a worker twin that holds its own row cap fails an answer past the CEILING loudly (never truncated);
9
+ * - the source row cache keeps an answer up to the ceiling, so a planned answer is always kept and a rerun (the
10
+ * source ladder's rung, a remount, a lazy refresh) reads it instead of asking the wire again;
11
+ * - the source fetch boundary rings `kscript-source-answer-over-budget` for an answer past the budget, and the dump's
12
+ * `sourceAnswerOverBudget` verdict counts them.
13
+ *
14
+ * The field case it closes: SPY 1h with Premium by Strike and Strike Footprint. The contract flow lane sized each ask
15
+ * by the worker's 500,000-row failure cap (about 25 MB on the wire, 25 s), past the lane's own deadline (10.6 s for
16
+ * 252 bars) and the row cache's 8 MiB entry cap: the lane degraded before the answer landed, the cache refused the
17
+ * late answer, the source ladder asked again, and neither indicator painted. Each answer that landed crossed to the
18
+ * page as one structured clone of about 400,000 nested arrays (2.7 s on the main thread).
19
+ *
20
+ * Why 8 MiB: the cache's entry cap before this budget existed, and about 1.6 MB on the wire for SPY's contract flow
21
+ * (measured 2026-10-20 on INT: about 35 bytes a row), answered in 2 to 5 s, inside the lane deadline's 10 s floor.
22
+ * Raising it is one edit here: every layer follows. A deeper read needs a smaller answer, not a bigger budget (the
23
+ * per-strike fold, UW-PARITY design/STRIKE-FLOW-SCOPE.md).
24
+ */
25
+ /** Bytes one numeric cell weighs in every estimate of a source answer. */
26
+ export const KSCRIPT_SOURCE_CELL_BYTES = 8;
27
+ /** The bytes a planned source answer stays within. */
28
+ export const KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES = 8 * 1024 * 1024;
29
+ /**
30
+ * The bytes a source answer may reach at all: twice the budget. A plan projects its rows from a measured session; a
31
+ * busier session can land past the budget, and up to the ceiling it is still delivered, cached and rung (flagged);
32
+ * past it a worker twin with its own row cap fails the request by name.
33
+ */
34
+ export const KSCRIPT_SOURCE_ANSWER_CEILING_BYTES = 2 * KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES;
35
+ /** The rows of `cellsPerRow` numeric cells each that fit `bytes` (the budget by default); at least one. */
36
+ export function kScriptSourceAnswerRows(cellsPerRow, bytes = KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES) {
37
+ const width = Number.isFinite(cellsPerRow) && cellsPerRow >= 1 ? Math.floor(cellsPerRow) : 1;
38
+ return Math.max(1, Math.floor(bytes / (width * KSCRIPT_SOURCE_CELL_BYTES)));
39
+ }
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * A secondary source's retry and budget numbers (a leaf of utility/chart/kscript-source-degrade.util.ts;
3
- * P2/inventory.md section 1.1): the constants recovery reads and the budget the executor reads. The degrade registry and
3
+ * P2/inventory.md section 1.1): the constants recovery reads, the budget the executor reads and the send anchor both
4
+ * source lanes (the kScript engine proxy, the wrun run's lanes) count it from. The degrade registry and
4
5
  * its mutators stay in the old module (the chart store and the engine manager share it) behind the chart-host members
5
6
  * `chart.markSourcesTerminal`, `chart.markSourceDegraded` and the rest; this leaf holds no state, so it moves into the
6
7
  * chart-host package with the phase 2 closure. The old module re-exports it.
@@ -21,6 +22,14 @@
21
22
  * per-overlay registry the legend chip is DERIVED from at the diagnostics
22
23
  * choke point (chart.ts setIndicatorDiagnostics), so no diagnostics writer
23
24
  * can drop the chip and no writer ever sets it directly.
25
+ *
26
+ * On the wrun lane the budget is a paint deadline and stays the chip's
27
+ * authority: counted from the lane's send (resolveSecondarySourceDeadlineMs),
28
+ * a lane still out at it degrades and the run paints without it,
29
+ * while its read (abandoned, never aborted) is joined or adopted by the next
30
+ * run and the source ladder instead of asked again
31
+ * (wrun/run-schedule/wrun-late-reads.util). The read's own bound is the fetch
32
+ * deadline (wrun-deadline.util WRUN_SOURCE_FETCH_DEADLINE_MS).
24
33
  */
25
34
  /**
26
35
  * Base budget (the floor). Provisional instrumented SLO (2026-09-03): the
@@ -50,6 +59,34 @@ export declare function resolveSecondarySourceBudgetMs(window: {
50
59
  toMs?: number;
51
60
  intervalMs?: number;
52
61
  }): number;
62
+ /**
63
+ * Absolute cap measured from the moment a source request was asked (the
64
+ * engine proxy's request arrival, a wrun lane's dispatch): the send anchor
65
+ * may move the deadline to send + budget, but never past this, so a request
66
+ * that sits queued on the main thread, behind the socket's open or in the
67
+ * worker's queue (or never goes out) still degrades in bounded time.
68
+ */
69
+ export declare const KSCRIPT_SECONDARY_SOURCE_DISPATCH_CAP_MS = 60000;
70
+ /**
71
+ * When a secondary source request degrades (on the caller's clock), the one
72
+ * anchor rule the kScript engine lane and the wrun lanes share: the budget
73
+ * counts from the moment the request went to the wire (`dispatchedAtMs`),
74
+ * never past `capMs` from the moment it was asked (`startedAtMs`), and never
75
+ * before the budget counted from the ask (a cap below the budget is lifted to
76
+ * it). A request not on the wire yet (`dispatchedAtMs: null`) waits the cap:
77
+ * the engine proxy's rule once it holds a request. A wrun lane asks this rule
78
+ * only after its first send notice and keeps the budget counted from the
79
+ * dispatch until then (`wrunLaneSendDeadline`), so a transport that never
80
+ * reports its send degrades as it always did. The anchor has no default on
81
+ * purpose: every caller says whether its request is on the wire, so time
82
+ * queued before a reported send never eats the budget.
83
+ */
84
+ export declare function resolveSecondarySourceDeadlineMs(anchor: {
85
+ startedAtMs: number;
86
+ dispatchedAtMs: number | null;
87
+ budgetMs: number;
88
+ capMs?: number;
89
+ }): number;
53
90
  /**
54
91
  * Gaps between recovery attempts (each is one forced refetch of the overlay
55
92
  * with retryAttempt stamped on the degraded names only): the first fires 15s
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * A secondary source's retry and budget numbers (a leaf of utility/chart/kscript-source-degrade.util.ts;
3
- * P2/inventory.md section 1.1): the constants recovery reads and the budget the executor reads. The degrade registry and
3
+ * P2/inventory.md section 1.1): the constants recovery reads, the budget the executor reads and the send anchor both
4
+ * source lanes (the kScript engine proxy, the wrun run's lanes) count it from. The degrade registry and
4
5
  * its mutators stay in the old module (the chart store and the engine manager share it) behind the chart-host members
5
6
  * `chart.markSourcesTerminal`, `chart.markSourceDegraded` and the rest; this leaf holds no state, so it moves into the
6
7
  * chart-host package with the phase 2 closure. The old module re-exports it.
@@ -21,6 +22,14 @@
21
22
  * per-overlay registry the legend chip is DERIVED from at the diagnostics
22
23
  * choke point (chart.ts setIndicatorDiagnostics), so no diagnostics writer
23
24
  * can drop the chip and no writer ever sets it directly.
25
+ *
26
+ * On the wrun lane the budget is a paint deadline and stays the chip's
27
+ * authority: counted from the lane's send (resolveSecondarySourceDeadlineMs),
28
+ * a lane still out at it degrades and the run paints without it,
29
+ * while its read (abandoned, never aborted) is joined or adopted by the next
30
+ * run and the source ladder instead of asked again
31
+ * (wrun/run-schedule/wrun-late-reads.util). The read's own bound is the fetch
32
+ * deadline (wrun-deadline.util WRUN_SOURCE_FETCH_DEADLINE_MS).
24
33
  */
25
34
  /**
26
35
  * Base budget (the floor). Provisional instrumented SLO (2026-09-03): the
@@ -55,6 +64,35 @@ export function resolveSecondarySourceBudgetMs(window) {
55
64
  const scaled = KSCRIPT_SECONDARY_SOURCE_BUDGET_MS + (rows / 1000) * KSCRIPT_SECONDARY_SOURCE_BUDGET_PER_1K_ROWS_MS;
56
65
  return Math.round(Math.min(KSCRIPT_SECONDARY_SOURCE_BUDGET_MAX_MS, Math.max(KSCRIPT_SECONDARY_SOURCE_BUDGET_MS, scaled)));
57
66
  }
67
+ /**
68
+ * Absolute cap measured from the moment a source request was asked (the
69
+ * engine proxy's request arrival, a wrun lane's dispatch): the send anchor
70
+ * may move the deadline to send + budget, but never past this, so a request
71
+ * that sits queued on the main thread, behind the socket's open or in the
72
+ * worker's queue (or never goes out) still degrades in bounded time.
73
+ */
74
+ export const KSCRIPT_SECONDARY_SOURCE_DISPATCH_CAP_MS = 60_000;
75
+ /**
76
+ * When a secondary source request degrades (on the caller's clock), the one
77
+ * anchor rule the kScript engine lane and the wrun lanes share: the budget
78
+ * counts from the moment the request went to the wire (`dispatchedAtMs`),
79
+ * never past `capMs` from the moment it was asked (`startedAtMs`), and never
80
+ * before the budget counted from the ask (a cap below the budget is lifted to
81
+ * it). A request not on the wire yet (`dispatchedAtMs: null`) waits the cap:
82
+ * the engine proxy's rule once it holds a request. A wrun lane asks this rule
83
+ * only after its first send notice and keeps the budget counted from the
84
+ * dispatch until then (`wrunLaneSendDeadline`), so a transport that never
85
+ * reports its send degrades as it always did. The anchor has no default on
86
+ * purpose: every caller says whether its request is on the wire, so time
87
+ * queued before a reported send never eats the budget.
88
+ */
89
+ export function resolveSecondarySourceDeadlineMs(anchor) {
90
+ const { startedAtMs, dispatchedAtMs, budgetMs, capMs = KSCRIPT_SECONDARY_SOURCE_DISPATCH_CAP_MS } = anchor;
91
+ const cappedAtMs = startedAtMs + Math.max(budgetMs, capMs);
92
+ if (dispatchedAtMs === null)
93
+ return cappedAtMs;
94
+ return Math.min(cappedAtMs, Math.max(startedAtMs, dispatchedAtMs) + budgetMs);
95
+ }
58
96
  /**
59
97
  * Gaps between recovery attempts (each is one forced refetch of the overlay
60
98
  * with retryAttempt stamped on the degraded names only): the first fires 15s
@@ -61,6 +61,7 @@ export declare function liveBucketStartMs(tsMs: number, intervalMs: number, venu
61
61
  * `liveBucketStartMs`: a regular-session stock chart's hourly columns sit on its 13:30Z (EDT) candles,
62
62
  * a CME chart's on its session lattice, and an off-session instant contributes none. The bar holding
63
63
  * `fromMs` counts only when it opens inside the range. A probe still inside the last bar (a lattice
64
- * bar the fall-back Sunday stretches) or off session steps forward a quarter hour at most.
64
+ * bar the fall-back Sunday stretches) or off session steps forward a quarter hour at most; on a
65
+ * regular-session stock grid it steps session to session (`resumeProbeMs`) onto the same probes.
65
66
  */
66
67
  export declare function liveBucketStartsInRange(fromMs: number, toMs: number, intervalMs: number, venue?: LiveBucketVenue | null): number[];
@@ -30,6 +30,7 @@ import { checkIsEconomic } from './marketKind.util.js';
30
30
  import { extractTokensFromTransformations, parsedTransformations } from '../common/transformations.util.js';
31
31
  import { isChartRthActive, isFootprintRthFoldTfMs, isRthBucketExactIntervalMs, rthAnchoredBucketStartMs, } from './rth-session.util.js';
32
32
  import { isEquityRegularSessionGated, usEquityAnchoredBucketStartMs, usEquitySessionGridBucketStartMs, } from './us-equities-session.util.js';
33
+ import { nyNextRegularOpenAfterMs } from './ny-calendar.util.js';
33
34
  const THREE_DAYS_MS = Intervals.map_unit['3d'];
34
35
  /**
35
36
  * A chart's bar-grid identity as a worker reads it (plain, cloneable fields only): the venue a worker
@@ -107,7 +108,7 @@ export function cmeSessionLatticeBucketMs(tsMs, intervalMs, venue) {
107
108
  return null;
108
109
  return isCmeSessionLatticeVenue(venue) ? cmeSessionBucketMs(tsMs, intervalMs) : null;
109
110
  }
110
- export function liveBucketStartMs(tsMs, intervalMs, venue) {
111
+ function liveBucketGrid(intervalMs, venue) {
111
112
  // Calendar and weekly bars: a CME venue's trade-date months and weeks (a
112
113
  // month opens at the 17:00 Chicago open before its first trade date), else
113
114
  // the plain grid. Regular-session US equities group the session's daily bars
@@ -115,45 +116,76 @@ export function liveBucketStartMs(tsMs, intervalMs, venue) {
115
116
  // market; if the gateway stamps them on the first trade date's open instead,
116
117
  // this branch needs the session's own month key.
117
118
  if (calendarMonthsOfMs(intervalMs) !== null || intervalMs === TimeIntervalConstant.week) {
118
- return isCmeSessionLatticeVenue(venue)
119
- ? cmeSessionBucketMs(tsMs, intervalMs)
120
- : plainBucketStartMs(tsMs, intervalMs);
119
+ return isCmeSessionLatticeVenue(venue) ? 'cme-session' : 'plain';
121
120
  }
122
121
  if (venue && !isRthBucketExactIntervalMs(intervalMs)) {
123
- if (isChartRthActive(venue.exchange, venue.symbol, venue.sessionType, intervalMs)) {
124
- return rthAnchoredBucketStartMs(venue.symbol, tsMs, intervalMs);
125
- }
122
+ if (isChartRthActive(venue.exchange, venue.symbol, venue.sessionType, intervalMs))
123
+ return 'rth-anchored';
126
124
  if (isEquityRegularSessionGated(venue.exchange, venue.sessionType)) {
127
125
  if (isFootprintRthFoldTfMs(intervalMs))
128
- return usEquityAnchoredBucketStartMs(tsMs, intervalMs);
126
+ return 'equity-anchored';
129
127
  if (intervalMs === THREE_DAYS_MS)
130
- return usEquitySessionGridBucketStartMs(tsMs);
128
+ return 'equity-session-group';
131
129
  }
132
- if (isCmeSessionLatticeIntervalMs(intervalMs) && isCmeSessionLatticeVenue(venue)) {
130
+ if (isCmeSessionLatticeIntervalMs(intervalMs) && isCmeSessionLatticeVenue(venue))
131
+ return 'cme-session';
132
+ }
133
+ return 'utc-floor';
134
+ }
135
+ function bucketStartOnGrid(grid, tsMs, intervalMs, venue) {
136
+ switch (grid) {
137
+ case 'cme-session':
133
138
  return cmeSessionBucketMs(tsMs, intervalMs);
134
- }
139
+ case 'plain':
140
+ return plainBucketStartMs(tsMs, intervalMs);
141
+ case 'rth-anchored':
142
+ return rthAnchoredBucketStartMs(venue?.symbol, tsMs, intervalMs);
143
+ case 'equity-anchored':
144
+ return usEquityAnchoredBucketStartMs(tsMs, intervalMs);
145
+ case 'equity-session-group':
146
+ return usEquitySessionGridBucketStartMs(tsMs);
147
+ default:
148
+ return tsMs - (tsMs % intervalMs);
135
149
  }
136
- return tsMs - (tsMs % intervalMs);
150
+ }
151
+ export function liveBucketStartMs(tsMs, intervalMs, venue) {
152
+ return bucketStartOnGrid(liveBucketGrid(intervalMs, venue), tsMs, intervalMs, venue);
137
153
  }
138
154
  /** The probe step through an off-session gap: every open the anchored grids sit on is on the quarter hour. */
139
155
  const OFF_SESSION_PROBE_MS = 15 * 60_000;
156
+ /**
157
+ * Where the walk resumes after `probeMs` opened no new bar (`offSession`: no bar holds it). A
158
+ * regular-session stock grid opens bars only inside the cash session, and its 3d bar spans whole
159
+ * sessions, so every probe before the next regular open would come back empty: the walk lands on
160
+ * the first probe of the same quarter-hour run at or after that open, one New York calendar lookup
161
+ * per trade date, and ends when no open comes by `toMs`. Every other grid steps a quarter hour.
162
+ */
163
+ function resumeProbeMs(grid, probeMs, stepMs, offSession, toMs) {
164
+ if (grid === 'equity-session-group' || (grid === 'equity-anchored' && offSession)) {
165
+ const openMs = nyNextRegularOpenAfterMs(probeMs, toMs);
166
+ return openMs === null ? Number.POSITIVE_INFINITY : probeMs + Math.ceil((openMs - probeMs) / stepMs) * stepMs;
167
+ }
168
+ return probeMs + stepMs;
169
+ }
140
170
  /**
141
171
  * The starts of the venue's bars that open inside `[fromMs, toMs]`, ascending, each keyed by
142
172
  * `liveBucketStartMs`: a regular-session stock chart's hourly columns sit on its 13:30Z (EDT) candles,
143
173
  * a CME chart's on its session lattice, and an off-session instant contributes none. The bar holding
144
174
  * `fromMs` counts only when it opens inside the range. A probe still inside the last bar (a lattice
145
- * bar the fall-back Sunday stretches) or off session steps forward a quarter hour at most.
175
+ * bar the fall-back Sunday stretches) or off session steps forward a quarter hour at most; on a
176
+ * regular-session stock grid it steps session to session (`resumeProbeMs`) onto the same probes.
146
177
  */
147
178
  export function liveBucketStartsInRange(fromMs, toMs, intervalMs, venue) {
148
179
  const starts = [];
149
180
  if (!(intervalMs > 0) || !Number.isFinite(fromMs) || !Number.isFinite(toMs))
150
181
  return starts;
182
+ const grid = liveBucketGrid(intervalMs, venue);
151
183
  const stepMs = Math.min(intervalMs, OFF_SESSION_PROBE_MS);
152
184
  let last = -Infinity;
153
185
  for (let probe = fromMs; probe <= toMs;) {
154
- const start = liveBucketStartMs(probe, intervalMs, venue);
186
+ const start = bucketStartOnGrid(grid, probe, intervalMs, venue);
155
187
  if (start === null || start <= last) {
156
- probe += stepMs;
188
+ probe = resumeProbeMs(grid, probe, stepMs, start === null, toMs);
157
189
  continue;
158
190
  }
159
191
  last = start;
@@ -45,7 +45,9 @@ type LocalKScriptWarmupDepthSkipReason = 'no-rows' | 'no-viewport' | 'warmup-off
45
45
  /** A source of the script is still loading, degraded, or never settled: an all-NaN run is not warmup evidence. */
46
46
  | 'sources-pending'
47
47
  /** The script declares a lookback of 0 and simply printed nothing: an empty output is not a warmup gap. */
48
- | 'zero-lookback-empty';
48
+ | 'zero-lookback-empty'
49
+ /** The visible first value is where a source's history begins (`sourceReachFromTs`): no page can move it. */
50
+ | 'source-reach';
49
51
  export type LocalKScriptWarmupDepthDecision = {
50
52
  fetch: true;
51
53
  reason: 'warmup-visible' | 'no-values-yet' | 'declared-depth';
@@ -105,6 +107,15 @@ export interface LocalKScriptWarmupDepthInput {
105
107
  lookbackBars: number | null;
106
108
  /** Every source of the engine settled for the current timeline (the proxy's sourceSettlementLedger). */
107
109
  sourcesSettled: boolean;
110
+ /**
111
+ * Where the rows of the result's history sources begin at the clock, null or absent when unknown or when a source
112
+ * reads without a reach (the wrun lane: `wrunRunSourceReachFromMs`, the earliest of its row lanes' reaches, a
113
+ * horizon's served start or the oldest bar a lane's longest-kept tier holds). A visible first value at or after it,
114
+ * with the reach at or after the loaded start, is that history beginning, not a warm-up: a page of candles older
115
+ * than the loaded start holds none of the source's rows, so it cannot move the first value ('source-reach'). Spot
116
+ * Exposures on a 52-day 1h viewport bought a 500-bar page this way for strike rows kept 7 days (INT 2026-10-20).
117
+ */
118
+ sourceReachFromTs?: number | null;
108
119
  }
109
120
  /**
110
121
  * Bars in the loaded main window: floor((last - first) / interval) + 1. Null
@@ -124,6 +135,9 @@ export declare function loadedBarsOfWindow(loadedFirstTs: number | null | undefi
124
135
  * value at the loaded start, is the one non-observed reason ('declared-depth',
125
136
  * sized to the shortfall, one page at a time; a shortfall under the absolute
126
137
  * gap floor, or the caller's `minGapBars`, is left alone like any other small gap).
138
+ * A visible first value that a source's history explains (`sourceReachFromTs`:
139
+ * that history begins inside the loaded window and the first value at or after
140
+ * it) owes no page: older candles hold none of the source's rows.
127
141
  */
128
142
  export declare function chooseLocalKScriptWarmupDepth(input: LocalKScriptWarmupDepthInput): LocalKScriptWarmupDepthDecision;
129
143
  export interface WarmupOutputLike {
@@ -87,6 +87,9 @@ export function loadedBarsOfWindow(loadedFirstTs, loadedLastTs, intervalMs) {
87
87
  * value at the loaded start, is the one non-observed reason ('declared-depth',
88
88
  * sized to the shortfall, one page at a time; a shortfall under the absolute
89
89
  * gap floor, or the caller's `minGapBars`, is left alone like any other small gap).
90
+ * A visible first value that a source's history explains (`sourceReachFromTs`:
91
+ * that history begins inside the loaded window and the first value at or after
92
+ * it) owes no page: older candles hold none of the source's rows.
90
93
  */
91
94
  export function chooseLocalKScriptWarmupDepth(input) {
92
95
  if (!isFiniteTs(input.loadedFirstTs))
@@ -171,6 +174,12 @@ export function chooseLocalKScriptWarmupDepth(input) {
171
174
  const minGapBars = Math.max(LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS, Math.ceil(viewportBars * LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_VIEWPORT_FRACTION));
172
175
  if (missingBars < minGapBars)
173
176
  return { fetch: false, reason: 'gap-too-small' };
177
+ // A first value a source's history explains: that history begins inside the loaded window and the first value sits
178
+ // at or after its start, so a page of older candles holds none of the source's rows and cannot move it.
179
+ const reachTs = input.sourceReachFromTs;
180
+ if (isFiniteTs(reachTs) && reachTs >= input.loadedFirstTs && input.firstValueTs >= reachTs) {
181
+ return { fetch: false, reason: 'source-reach' };
182
+ }
174
183
  // The need is the observed visible gap, capped at two buckets. A known
175
184
  // lookback caps it further at max(lookback, one bucket): a script declaring
176
185
  // 5 bars never gets a second bucket even behind a 300-bar visible gap, a
@@ -16,7 +16,9 @@
16
16
  * until the data latch corrects it. Known-coarse by design (v1).
17
17
  *
18
18
  * All math is done in exchange wall-clock parts obtained through Intl with an
19
- * explicit timeZone, then converted back to UTC instants with the dual-offset
19
+ * explicit timeZone (the zone clock in ny-calendar.util: one Intl reading per
20
+ * UTC day, so the 1 Hz status tick does date arithmetic, not ~20 Intl calls),
21
+ * then converted back to UTC instants with the dual-offset
20
22
  * probe (try CST/CDT, keep the one that renders back to the intended wall
21
23
  * time). The session boundaries (16:00/17:00) are never inside a DST jump
22
24
  * (those happen at 02:00 local), so the probe is always unambiguous.