@orangecharts/wrun-chart-host 0.2.0 → 0.3.0

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 (320) hide show
  1. package/README.md +14 -6
  2. package/dist/constants/common.constants.d.ts +15 -0
  3. package/dist/constants/common.constants.js +23 -0
  4. package/dist/constants/data-source.constants.d.ts +1 -0
  5. package/dist/constants/data-source.constants.js +1 -0
  6. package/dist/constants/economic.constants.d.ts +39 -0
  7. package/dist/constants/economic.constants.js +77 -0
  8. package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
  9. package/dist/constants/etf-covered-coins.constants.js +9 -0
  10. package/dist/constants/feature-flags.constants.d.ts +60 -0
  11. package/dist/constants/feature-flags.constants.js +308 -0
  12. package/dist/constants/feature-limits.constants.d.ts +134 -0
  13. package/dist/constants/feature-limits.constants.js +155 -0
  14. package/dist/constants/marketCapabilities.constants.d.ts +87 -0
  15. package/dist/constants/marketCapabilities.constants.js +213 -0
  16. package/dist/constants/option-venues.constants.d.ts +100 -0
  17. package/dist/constants/option-venues.constants.js +167 -0
  18. package/dist/constants/overlay-data.constants.d.ts +53 -0
  19. package/dist/constants/overlay-data.constants.js +80 -0
  20. package/dist/constants/pane-grid.constants.d.ts +15 -0
  21. package/dist/constants/pane-grid.constants.js +17 -0
  22. package/dist/constants/venue-presets.constants.d.ts +10 -0
  23. package/dist/constants/venue-presets.constants.js +22 -0
  24. package/dist/enums/chart.enum.d.ts +68 -0
  25. package/dist/enums/chart.enum.js +70 -0
  26. package/dist/helpers/data.helpers.d.ts +2 -0
  27. package/dist/helpers/data.helpers.js +14 -0
  28. package/dist/host-env.d.ts +161 -5
  29. package/dist/host-ports.types.d.ts +446 -0
  30. package/dist/host-ports.types.js +1 -0
  31. package/dist/index.d.ts +128 -0
  32. package/dist/index.js +128 -0
  33. package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
  34. package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
  35. package/dist/interfaces/asset-venue.interface.d.ts +91 -0
  36. package/dist/interfaces/asset-venue.interface.js +1 -0
  37. package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
  38. package/dist/interfaces/cancel-reason.interface.js +2 -0
  39. package/dist/interfaces/catalog-display.interface.d.ts +3 -0
  40. package/dist/interfaces/catalog-display.interface.js +1 -0
  41. package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
  42. package/dist/interfaces/cme-realtime.interface.js +46 -0
  43. package/dist/interfaces/feed.interface.d.ts +80 -0
  44. package/dist/interfaces/feed.interface.js +7 -0
  45. package/dist/interfaces/market-kind.interface.d.ts +8 -0
  46. package/dist/interfaces/market-kind.interface.js +1 -0
  47. package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
  48. package/dist/interfaces/opra-realtime.interface.js +105 -0
  49. package/dist/interfaces/option-instrument.interface.d.ts +32 -0
  50. package/dist/interfaces/option-instrument.interface.js +1 -0
  51. package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
  52. package/dist/interfaces/options-chain-scope.interface.js +7 -0
  53. package/dist/interfaces/prediction-market.interface.d.ts +88 -0
  54. package/dist/interfaces/prediction-market.interface.js +8 -0
  55. package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
  56. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
  57. package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
  58. package/dist/settings-templates/frvp-fields.d.ts +27 -0
  59. package/dist/settings-templates/frvp-fields.js +108 -0
  60. package/dist/settings-templates/index.d.ts +119 -0
  61. package/dist/settings-templates/index.js +442 -0
  62. package/dist/settings-templates/indicator-fields.d.ts +56 -0
  63. package/dist/settings-templates/indicator-fields.js +793 -0
  64. package/dist/settings-templates/tool-rules.d.ts +59 -0
  65. package/dist/settings-templates/tool-rules.js +49 -0
  66. package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
  67. package/dist/settings-templates/tool-tables.generated.js +1668 -0
  68. package/dist/utility/blk-market.util.d.ts +5 -0
  69. package/dist/utility/blk-market.util.js +12 -0
  70. package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
  71. package/dist/utility/chart/chart-load-phase.util.js +78 -0
  72. package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
  73. package/dist/utility/chart/cme-cache-context.util.js +166 -0
  74. package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
  75. package/dist/utility/chart/cme-session-bucket.util.js +343 -0
  76. package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
  77. package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
  78. package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
  79. package/dist/utility/chart/continuous-contracts.util.js +374 -0
  80. package/dist/utility/chart/feed-interval.util.d.ts +119 -0
  81. package/dist/utility/chart/feed-interval.util.js +321 -0
  82. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
  83. package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
  84. package/dist/utility/chart/footprint-band.util.d.ts +76 -0
  85. package/dist/utility/chart/footprint-band.util.js +205 -0
  86. package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
  87. package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
  88. package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
  89. package/dist/utility/chart/formula-calendar.util.js +59 -0
  90. package/dist/utility/chart/history-wall.util.d.ts +67 -0
  91. package/dist/utility/chart/history-wall.util.js +87 -0
  92. package/dist/utility/chart/index-mode.util.d.ts +66 -0
  93. package/dist/utility/chart/index-mode.util.js +360 -0
  94. package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
  95. package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
  96. package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
  97. package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
  98. package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
  99. package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
  100. package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
  101. package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
  102. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
  103. package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
  104. package/dist/utility/chart/interval-registry.util.d.ts +23 -0
  105. package/dist/utility/chart/interval-registry.util.js +83 -0
  106. package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
  107. package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
  108. package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
  109. package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
  110. package/dist/utility/chart/live-bucket.util.d.ts +66 -0
  111. package/dist/utility/chart/live-bucket.util.js +165 -0
  112. package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
  113. package/dist/utility/chart/market-session-schedule.util.js +337 -0
  114. package/dist/utility/chart/marketKind.util.d.ts +181 -0
  115. package/dist/utility/chart/marketKind.util.js +371 -0
  116. package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
  117. package/dist/utility/chart/opra-read-access.leaf.js +25 -0
  118. package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
  119. package/dist/utility/chart/prediction-identity.util.js +236 -0
  120. package/dist/utility/chart/rth-session.util.d.ts +352 -0
  121. package/dist/utility/chart/rth-session.util.js +926 -0
  122. package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
  123. package/dist/utility/chart/titan-constants.pin.js +50 -0
  124. package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
  125. package/dist/utility/chart/us-equities-session.util.js +251 -0
  126. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
  127. package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
  128. package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
  129. package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
  130. package/dist/utility/common/safe-math-eval.d.ts +18 -0
  131. package/dist/utility/common/safe-math-eval.js +160 -0
  132. package/dist/utility/common/time.util.d.ts +134 -0
  133. package/dist/utility/common/time.util.js +428 -0
  134. package/dist/utility/common/transformations.util.d.ts +126 -0
  135. package/dist/utility/common/transformations.util.js +711 -0
  136. package/dist/utility/common/visible-timeout.util.d.ts +17 -0
  137. package/dist/utility/common/visible-timeout.util.js +75 -0
  138. package/dist/utility/exchange-normalization.util.d.ts +8 -0
  139. package/dist/utility/exchange-normalization.util.js +32 -0
  140. package/dist/utility/intl-locale.util.d.ts +2 -0
  141. package/dist/utility/intl-locale.util.js +28 -0
  142. package/dist/utility/number-format.util.d.ts +14 -1
  143. package/dist/utility/number-format.util.js +50 -19
  144. package/dist/utility/options/option-symbol.util.d.ts +28 -0
  145. package/dist/utility/options/option-symbol.util.js +176 -0
  146. package/dist/utility/options/option-trade-units.util.d.ts +190 -0
  147. package/dist/utility/options/option-trade-units.util.js +283 -0
  148. package/dist/utility/options/option-venue.util.d.ts +75 -0
  149. package/dist/utility/options/option-venue.util.js +85 -0
  150. package/dist/utility/pool-symbol.leaf.d.ts +34 -0
  151. package/dist/utility/pool-symbol.leaf.js +95 -0
  152. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
  153. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
  154. package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
  155. package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
  156. package/dist/utility/v2/gate-plane.util.d.ts +58 -0
  157. package/dist/utility/v2/gate-plane.util.js +99 -0
  158. package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
  159. package/dist/utility/v2/gate-session-latch.util.js +34 -0
  160. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
  161. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
  162. package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
  163. package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
  164. package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
  165. package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
  166. package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
  167. package/dist/utility/wrun/sources/lanes/economic.js +79 -0
  168. package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
  169. package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
  170. package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
  171. package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
  172. package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
  173. package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
  174. package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
  175. package/dist/utility/wrun/sources/lanes/index.js +32 -0
  176. package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
  177. package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
  178. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +30 -0
  179. package/dist/utility/wrun/sources/lanes/option_daily.js +53 -0
  180. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +23 -0
  181. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +20 -0
  182. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
  183. package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
  184. package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
  185. package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
  186. package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
  187. package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
  188. package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
  189. package/dist/utility/wrun/sources/lanes/series.js +321 -0
  190. package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
  191. package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
  192. package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
  193. package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
  194. package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
  195. package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
  196. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +196 -0
  197. package/dist/utility/wrun/sources/opra-option-lanes.util.js +446 -0
  198. package/dist/utility/wrun/sources/registry.d.ts +21 -0
  199. package/dist/utility/wrun/sources/registry.js +207 -0
  200. package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
  201. package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
  202. package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
  203. package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
  204. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
  205. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
  206. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +6 -0
  207. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +70 -0
  208. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
  209. package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
  210. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +13 -0
  211. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +137 -0
  212. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +38 -0
  213. package/dist/utility/wrun/sources/row-lanes/option_surface.js +150 -0
  214. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +275 -0
  215. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
  216. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +224 -0
  217. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +394 -0
  218. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +283 -0
  219. package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
  220. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +205 -0
  221. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +469 -0
  222. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
  223. package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
  224. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
  225. package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
  226. package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
  227. package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
  228. package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
  229. package/dist/utility/wrun/wrun-deadline.util.js +82 -0
  230. package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
  231. package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
  232. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
  233. package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
  234. package/dist/utility/wrun/wrun-frames.d.ts +20 -1
  235. package/dist/utility/wrun/wrun-frames.js +103 -49
  236. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  237. package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
  238. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
  239. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
  240. package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
  241. package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
  242. package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
  243. package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
  244. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
  245. package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
  246. package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
  247. package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
  248. package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
  249. package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
  250. package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
  251. package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
  252. package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
  253. package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
  254. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
  255. package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
  256. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
  257. package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
  258. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +30 -0
  259. package/dist/utility/wrun/wrun-opra-stats.leaf.js +96 -0
  260. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
  261. package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
  262. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
  263. package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
  264. package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
  265. package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
  266. package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
  267. package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
  268. package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
  269. package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
  270. package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
  271. package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
  272. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
  273. package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
  274. package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
  275. package/dist/utility/wrun/wrun-param-map.util.js +581 -0
  276. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
  277. package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
  278. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
  279. package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
  280. package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
  281. package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
  282. package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
  283. package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
  284. package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
  285. package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
  286. package/dist/utility/wrun/wrun-refusal.util.d.ts +41 -1
  287. package/dist/utility/wrun/wrun-refusal.util.js +69 -2
  288. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
  289. package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
  290. package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
  291. package/dist/utility/wrun/wrun-row-source.js +75 -0
  292. package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
  293. package/dist/utility/wrun/wrun-run-health.util.js +273 -0
  294. package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
  295. package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
  296. package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
  297. package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
  298. package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
  299. package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
  300. package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
  301. package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
  302. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
  303. package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
  304. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
  305. package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
  306. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
  307. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
  308. package/dist/utility/wrun-display-name.util.d.ts +33 -0
  309. package/dist/utility/wrun-display-name.util.js +64 -0
  310. package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
  311. package/dist/workers/constants/kscript-transport-codes.js +15 -0
  312. package/dist/workers/constants/socket-slots.d.ts +574 -0
  313. package/dist/workers/constants/socket-slots.js +539 -0
  314. package/dist/workers/utils/number.worker.util.d.ts +5 -0
  315. package/dist/workers/utils/number.worker.util.js +10 -0
  316. package/dist/workers/utils/time.worker.util.d.ts +12 -0
  317. package/dist/workers/utils/time.worker.util.js +24 -0
  318. package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
  319. package/dist/workers/utils/volume-profile.worker.util.js +631 -0
  320. package/package.json +10 -4
@@ -0,0 +1,217 @@
1
+ /**
2
+ * ONE range decider for indicator history coverage (fan-out unification P1).
3
+ * Both the wave-settled gap-repair scan (B3 in the fan-out census) and the
4
+ * gap-recovery poller (B4) produce their fetch/registration ranges here;
5
+ * timers, overlay eligibility, and executors stay with the callers.
6
+ *
7
+ * The TRIGGER POLICY TABLE pins today's asymmetries explicitly (they predate
8
+ * the planner and each is adjudicated separately, not silently unified):
9
+ * - the wave-settled scan caps ranges per overlay and per scan and consumes
10
+ * bounded attempts; the recovery poller's persistence is bounded by its
11
+ * own 3-minute window instead, so its triggers run uncapped;
12
+ * - the per-scan cap counts PLAIN requests only, but once reached it stops
13
+ * the whole iteration, so protected overlays later in metadata order get
14
+ * nothing that scan (pinned in the golden as a named pathology);
15
+ * - only protected kScript overlays consult the servable floor; since the
16
+ * P1 adjudication it applies on EVERY trigger (vacuous for the recovery
17
+ * poller until something learns plain floors: its allowlist is plain-only,
18
+ * and only the protected repair callback writes floors today);
19
+ * - attempt caps stay wave-settled-only DELIBERATELY: the recovery poller's
20
+ * persistence bound is its own 3-minute window, and capping it at
21
+ * 3 attempts would break the bounded-retry parity that the B4 deletion
22
+ * adjudication (P4) must measure;
23
+ * - wave-settled requests widen the gap by one interval; recovery requests
24
+ * fetch the bare gap;
25
+ * - the two triggers use DIFFERENT gap detectors whose divergences are
26
+ * pinned side by side in indicator-coverage-detectors.golden.spec.ts
27
+ * (merged in P3);
28
+ * - the cluster-scan trigger (footprint cluster-search extension) is an
29
+ * 'explicit'-detector row: the feature declares its exact demand range via
30
+ * fallbackGaps and the planner still owns caps/attempts/floor, so a
31
+ * user-driven extension can never bypass the coverage discipline;
32
+ * - the failed-span trigger (the prompt heal's ladder for types off the
33
+ * recovery allowlist, 2026-10-15) is the other 'explicit' row: it re-asks
34
+ * exactly the spans a terminal transport failure left unserved, never a
35
+ * cadence inference, uncapped and attempts-off (the ladder bounds itself).
36
+ */
37
+ import { type IndicatorGapRange } from './indicator-gap-repair.util.js';
38
+ export declare const INDICATOR_COVERAGE_MAX_ATTEMPTS = 3;
39
+ export type IndicatorCoverageOverlayKind = 'plain' | 'protected-kscript';
40
+ export type IndicatorCoverageTrigger = 'wave-dispatch' | 'wave-settled' | 'apply-time' | 'retry-rearm' | 'chart-init' | 'cluster-scan' | 'failed-span';
41
+ export interface IndicatorCoverageOverlaySnapshot {
42
+ overlayId: string;
43
+ kind: IndicatorCoverageOverlayKind;
44
+ /** Gap-detection rows (already protected-extracted for kScript overlays). */
45
+ rows: number[][] | undefined;
46
+ /**
47
+ * Ranges to use at a total miss (< 2 rows), where both detectors are blind
48
+ * by design: the arming site passes the failed request's range, the
49
+ * re-detect passes the overlay's registered gaps.
50
+ */
51
+ fallbackGaps?: IndicatorGapRange[];
52
+ /**
53
+ * Opt-in for overlays whose CLOSED-bar tail is fetch-owned (the orderbook
54
+ * heatmap's column grid, adapted through heatmap-coverage-rows.util): the
55
+ * 'recovery' detector also emits the suffix hole `[lastRow, lastMain +
56
+ * interval]` when main has bars after the overlay's last row beyond the
57
+ * cadence threshold. Plain indicators keep it off: their tail belongs to
58
+ * the live/polling lane (2026-08-22 adjudication, the BTC1! RTH weekend
59
+ * dump whose Friday tail no lane ever asked).
60
+ */
61
+ tailHoles?: boolean;
62
+ /** Overrides the tail detector's missing-row minimum (profiles use 4). */
63
+ tailHoleMinMissingRows?: number;
64
+ /**
65
+ * Which main bars the detectors judge this overlay against. 'real'
66
+ * (default): the server's bars only, synthetic marker rows stripped
67
+ * (`realMainRows`); right for every trade-driven series, whose upstream
68
+ * rows exist exactly where candles do. 'all': the full mounted series,
69
+ * synthetic bridges included; for book-driven overlays (the orderbook
70
+ * heatmap's column grid): the book had a snapshot at a tradeless minute
71
+ * and the bar-grid fold restamps columns onto every mounted bar, so a
72
+ * bridged minute without a column is a real, re-askable hole there.
73
+ * 'traded': the real bars minus zero-volume rows (`tradedMainRows`): for a
74
+ * single-venue profile overlay riding the chart's own trade source, a
75
+ * gap-filled tradeless minute is not a bar it could be missing
76
+ * (`profileMainGridForOverlay` decides; callers pass it explicitly).
77
+ */
78
+ mainGrid?: IndicatorCoverageMainGrid;
79
+ /**
80
+ * AUTHORITATIVE_EMPTY_RANGE_SKIP: wire-authoritative empty spans for this
81
+ * overlay's current request identity (known-empty-range.util). A gap fully
82
+ * contained in one is filtered with reason 'authoritative-empty' before it
83
+ * consumes any budget: the wire already answered "nothing here".
84
+ */
85
+ authoritativeEmptySpans?: IndicatorGapRange[];
86
+ /**
87
+ * The window the CONTAINMENT test above judges for a detected gap
88
+ * (data-loading S6, A36): the recovery poller asks the wire for the
89
+ * interior window (one interval past a mounted left bound,
90
+ * `resolveRecoveryFetchStartMs`) and the empty verdict is recorded over
91
+ * THAT window, so the raw gap was never contained in the span it wrote
92
+ * and the poller re-planned the same gap every 5 s for the whole episode
93
+ * (F063/F066/F082). The recovery poller passes the shifted window here
94
+ * explicitly; every other caller leaves it unset and keeps today's test
95
+ * on the raw gap. Detection, budgets and the emitted range are untouched.
96
+ */
97
+ containmentWindowFor?: (gap: IndicatorGapRange) => IndicatorGapRange;
98
+ /**
99
+ * WARMUP_SKIPPED_SPAN_CLIP: candle spans a non-user prepend (the local
100
+ * kScript warmup backfill) deliberately left uncovered for this per-bar
101
+ * viewport-only overlay (`warmupSkippedSpansForOverlay`). The part of a
102
+ * detected gap inside one is CLIPPED away with reason 'warmup-skipped'
103
+ * before any budget; the remainder plans normally. Clipping, not
104
+ * containment: the heatmap's total-miss demand is the whole main span, and
105
+ * containment would never match it. The visible part of a skipped span is
106
+ * the settle catch-up's coverage plan, never a heal.
107
+ */
108
+ warmupSkippedSpans?: IndicatorGapRange[];
109
+ }
110
+ export interface IndicatorCoverageSnapshot {
111
+ chartIndex: number;
112
+ /** Attempt-key namespace; null when the trigger consumes no attempts. */
113
+ datasetKey: string | null;
114
+ intervalMs: number;
115
+ mainRows: number[][] | undefined;
116
+ /**
117
+ * The main series' synthetic-row flags (`metadata[0].syntheticFlags`,
118
+ * SYNTHETIC_REAL = 0 per row). When present, both detectors judge holes
119
+ * against the REAL bars only (`realMainRows`): a client-inserted marker
120
+ * row for a tradeless minute is not a bar the overlay could be missing.
121
+ */
122
+ mainSyntheticFlags?: ArrayLike<number>;
123
+ viewport?: {
124
+ startTs?: unknown;
125
+ endTs?: unknown;
126
+ };
127
+ overlays: IndicatorCoverageOverlaySnapshot[];
128
+ }
129
+ export interface IndicatorCoverageRequest {
130
+ overlayId: string;
131
+ kind: IndicatorCoverageOverlayKind;
132
+ /** The detected gap (what logs report). */
133
+ gap: IndicatorGapRange;
134
+ /** The range to actually request (gap, widened per policy). */
135
+ range: IndicatorGapRange;
136
+ attemptKey: string | null;
137
+ /** 1-based attempt this plan consumed, when the trigger counts attempts. */
138
+ attempt: number | null;
139
+ }
140
+ export type IndicatorCoverageFilterReason = 'below-servable-floor' | 'proven-served' | 'attempts-exhausted' | 'overlay-cap' | 'scan-cap' | 'viewport-cushion' | 'authoritative-empty' | 'warmup-skipped';
141
+ export interface IndicatorCoverageFiltered {
142
+ overlayId: string;
143
+ gap: IndicatorGapRange;
144
+ reason: IndicatorCoverageFilterReason;
145
+ }
146
+ export interface IndicatorCoveragePlan {
147
+ requests: IndicatorCoverageRequest[];
148
+ /** Every suppressed range, so no cap or filter is a silent drop. */
149
+ filtered: IndicatorCoverageFiltered[];
150
+ /** An overlay had detectable gaps (even if every range was filtered). */
151
+ sawRepairableGap: boolean;
152
+ }
153
+ interface CoverageTriggerPolicy {
154
+ /**
155
+ * 'repair' / 'recovery' are the two row-based gap detectors; 'explicit'
156
+ * plans EXACTLY the caller-declared `fallbackGaps` (the initiator computes
157
+ * its demand, the planner stays the authority on caps, attempts, and the
158
+ * servable floor). Used by the cluster-scan extension and failed-span
159
+ * heal triggers.
160
+ */
161
+ detector: 'repair' | 'recovery' | 'explicit';
162
+ maxRangesPerOverlay: number | null;
163
+ /** Plain-request budget per plan; when reached, iteration stops for ALL kinds. */
164
+ maxPlainRangesPerScan: number | null;
165
+ widenRequestByInterval: boolean;
166
+ servableFloor: 'protected-only' | 'off';
167
+ attempts: 'consume' | 'off';
168
+ }
169
+ export declare const INDICATOR_COVERAGE_TRIGGER_POLICY: Record<IndicatorCoverageTrigger, CoverageTriggerPolicy>;
170
+ /**
171
+ * Subtract closed spans from a gap. Pieces keep the gap's other fields; the
172
+ * `tail` stamp survives only on the piece that still ends where the gap did.
173
+ * Returns the kept pieces and the removed intersections (what the filter log
174
+ * reports), in time order.
175
+ */
176
+ export declare function subtractSpansFromGap<T extends IndicatorGapRange>(gap: T, spans: readonly IndicatorGapRange[]): {
177
+ kept: T[];
178
+ removed: IndicatorGapRange[];
179
+ };
180
+ export type IndicatorCoverageMainGrid = 'real' | 'all' | 'traded';
181
+ export declare function defaultMainGridForOverlay(overlayId: string): IndicatorCoverageMainGrid;
182
+ /**
183
+ * The grid a trade-driven profile overlay is judged against: 'traded' when the
184
+ * overlay is a single-venue profile riding the chart's own trade source (its
185
+ * settings name the chart's exchange and symbol, or name none), else the
186
+ * caller's fallback (undefined = the planner default). Same evidence test the
187
+ * live-feed trailing heal applies (`healMainEvidence`, live-feed.service.ts).
188
+ */
189
+ export declare function profileMainGridForOverlay(args: {
190
+ indicatorType: string | null | undefined;
191
+ overlaySettings?: {
192
+ exchange?: unknown;
193
+ symbol?: unknown;
194
+ } | null;
195
+ chartExchange?: unknown;
196
+ chartSymbol?: unknown;
197
+ }): 'traded' | undefined;
198
+ /** The main rows a detector judges against for `grid` (see `mainGrid`); 'all' is the full mounted series. */
199
+ export declare function mainRowsForGrid(mainRows: number[][] | undefined, syntheticFlags: ArrayLike<number> | undefined, grid: IndicatorCoverageMainGrid | undefined): number[][] | undefined;
200
+ /**
201
+ * Clip sorted-ascending rows to [fromMs, toMs] inclusive (binary-searched).
202
+ * The wave-dispatch trigger uses this to bound the repair detector to the
203
+ * wave span; callers must pass rows already sorted by timestamp (main-series
204
+ * rawData is).
205
+ */
206
+ export declare function sliceSortedRowsToSpan(rows: number[][], fromMs: number, toMs: number): number[][];
207
+ /**
208
+ * `sliceSortedRowsToSpan` plus the matching slice of the series' positional
209
+ * synthetic flags, so a clipped planning input keeps row i paired with flag
210
+ * i (`realMainRows` refuses a length mismatch). Flags absent: undefined.
211
+ */
212
+ export declare function sliceSortedRowsToSpanWithFlags(rows: number[][], flags: ArrayLike<number> | undefined, fromMs: number, toMs: number): {
213
+ rows: number[][];
214
+ flags: ArrayLike<number> | undefined;
215
+ };
216
+ export declare function planIndicatorCoverage(snapshot: IndicatorCoverageSnapshot, trigger: IndicatorCoverageTrigger): IndicatorCoveragePlan;
217
+ export {};
@@ -0,0 +1,443 @@
1
+ /**
2
+ * ONE range decider for indicator history coverage (fan-out unification P1).
3
+ * Both the wave-settled gap-repair scan (B3 in the fan-out census) and the
4
+ * gap-recovery poller (B4) produce their fetch/registration ranges here;
5
+ * timers, overlay eligibility, and executors stay with the callers.
6
+ *
7
+ * The TRIGGER POLICY TABLE pins today's asymmetries explicitly (they predate
8
+ * the planner and each is adjudicated separately, not silently unified):
9
+ * - the wave-settled scan caps ranges per overlay and per scan and consumes
10
+ * bounded attempts; the recovery poller's persistence is bounded by its
11
+ * own 3-minute window instead, so its triggers run uncapped;
12
+ * - the per-scan cap counts PLAIN requests only, but once reached it stops
13
+ * the whole iteration, so protected overlays later in metadata order get
14
+ * nothing that scan (pinned in the golden as a named pathology);
15
+ * - only protected kScript overlays consult the servable floor; since the
16
+ * P1 adjudication it applies on EVERY trigger (vacuous for the recovery
17
+ * poller until something learns plain floors: its allowlist is plain-only,
18
+ * and only the protected repair callback writes floors today);
19
+ * - attempt caps stay wave-settled-only DELIBERATELY: the recovery poller's
20
+ * persistence bound is its own 3-minute window, and capping it at
21
+ * 3 attempts would break the bounded-retry parity that the B4 deletion
22
+ * adjudication (P4) must measure;
23
+ * - wave-settled requests widen the gap by one interval; recovery requests
24
+ * fetch the bare gap;
25
+ * - the two triggers use DIFFERENT gap detectors whose divergences are
26
+ * pinned side by side in indicator-coverage-detectors.golden.spec.ts
27
+ * (merged in P3);
28
+ * - the cluster-scan trigger (footprint cluster-search extension) is an
29
+ * 'explicit'-detector row: the feature declares its exact demand range via
30
+ * fallbackGaps and the planner still owns caps/attempts/floor, so a
31
+ * user-driven extension can never bypass the coverage discipline;
32
+ * - the failed-span trigger (the prompt heal's ladder for types off the
33
+ * recovery allowlist, 2026-10-15) is the other 'explicit' row: it re-asks
34
+ * exactly the spans a terminal transport failure left unserved, never a
35
+ * cadence inference, uncapped and attempts-off (the ladder bounds itself).
36
+ */
37
+ import { clampIndicatorGapToViewportCushion, findIndicatorDataGaps, } from './indicator-gap-repair.util.js';
38
+ import { findIndicatorGaps, findIndicatorTailHole, realMainRows, tradedMainRows } from './indicator-gap-detector.util.js';
39
+ import { getIndicatorCoverageAttempts, getIndicatorServableFloorMs, indicatorCoverageAttemptKey, isIndicatorRangeProvenServed, noteIndicatorCoverageAttempt, } from './indicator-coverage-state.util.js';
40
+ export const INDICATOR_COVERAGE_MAX_ATTEMPTS = 3;
41
+ const MAX_RANGES_PER_SCAN = 6;
42
+ const MAX_RANGES_PER_OVERLAY = 2;
43
+ export const INDICATOR_COVERAGE_TRIGGER_POLICY = {
44
+ // P3.2 flagship (the fan-out contract's terminal phase): the B1 wave's
45
+ // plain branch fetches only planner-missing sub-ranges of the wave span
46
+ // instead of buying the whole span per overlay. The caller clips mainRows
47
+ // to the span, which bounds the repair detector to the span; an overlay
48
+ // with no rows inside the span (including every heatmap overlay, whose
49
+ // metadata rows are structurally empty) detects the whole clipped span as
50
+ // one gap, so first-load dispatches are unchanged. Un-widened so the
51
+ // wave's ledger keys stay bucket-exact and the guard-site dedupe classes
52
+ // (covered-recent-completion, known-empty) keep matching; attempts off
53
+ // because a dispatch is the first ask, never a bounded retry.
54
+ 'wave-dispatch': {
55
+ detector: 'repair',
56
+ maxRangesPerOverlay: MAX_RANGES_PER_OVERLAY,
57
+ maxPlainRangesPerScan: null,
58
+ widenRequestByInterval: false,
59
+ servableFloor: 'protected-only',
60
+ attempts: 'off',
61
+ },
62
+ 'wave-settled': {
63
+ detector: 'repair',
64
+ maxRangesPerOverlay: MAX_RANGES_PER_OVERLAY,
65
+ maxPlainRangesPerScan: MAX_RANGES_PER_SCAN,
66
+ widenRequestByInterval: true,
67
+ servableFloor: 'protected-only',
68
+ attempts: 'consume',
69
+ },
70
+ 'apply-time': {
71
+ detector: 'recovery',
72
+ maxRangesPerOverlay: null,
73
+ maxPlainRangesPerScan: null,
74
+ widenRequestByInterval: false,
75
+ servableFloor: 'protected-only',
76
+ attempts: 'off',
77
+ },
78
+ 'retry-rearm': {
79
+ detector: 'recovery',
80
+ maxRangesPerOverlay: null,
81
+ maxPlainRangesPerScan: null,
82
+ widenRequestByInterval: false,
83
+ servableFloor: 'protected-only',
84
+ attempts: 'off',
85
+ },
86
+ 'chart-init': {
87
+ detector: 'recovery',
88
+ maxRangesPerOverlay: null,
89
+ maxPlainRangesPerScan: null,
90
+ widenRequestByInterval: false,
91
+ servableFloor: 'protected-only',
92
+ attempts: 'off',
93
+ },
94
+ // User-demanded footprint cluster-scan extension: ONE explicit range per
95
+ // plan (the feature asks to widen the scanned history by a fixed bar count
96
+ // behind the overlay's earliest row), bare range, bounded attempts so an
97
+ // unservable extension is refused as 'attempts-exhausted' instead of being
98
+ // re-asked forever. Every refusal reaches the plan's filtered[] and the
99
+ // scan UI surfaces it; a silent cap here is a defect.
100
+ 'cluster-scan': {
101
+ detector: 'explicit',
102
+ maxRangesPerOverlay: 1,
103
+ maxPlainRangesPerScan: 1,
104
+ widenRequestByInterval: false,
105
+ servableFloor: 'protected-only',
106
+ attempts: 'consume',
107
+ },
108
+ // Failed-span heal ladder (indicator-gap-heal.util, adjudicated 2026-10-15):
109
+ // an overlay OFF the recovery allowlist whose history ask ended on a
110
+ // terminal transport failure re-asks exactly the armed spans (the failed
111
+ // request plus the family's never-dispatched siblings). No cadence
112
+ // inference: the types outside the allowlist are there because their rows
113
+ // are sparse, session-shaped or profile-shaped, so a detector would read
114
+ // holes everywhere (a TPO under four rows falls back to the chart interval
115
+ // and flags every session edge). Uncapped and bare like apply-time (the
116
+ // heal dispatches its spans one at a time); attempts off because the ladder
117
+ // bounds itself (four rungs, at most one attempt each).
118
+ 'failed-span': {
119
+ detector: 'explicit',
120
+ maxRangesPerOverlay: null,
121
+ maxPlainRangesPerScan: null,
122
+ widenRequestByInterval: false,
123
+ servableFloor: 'protected-only',
124
+ attempts: 'off',
125
+ },
126
+ };
127
+ /**
128
+ * Subtract closed spans from a gap. Pieces keep the gap's other fields; the
129
+ * `tail` stamp survives only on the piece that still ends where the gap did.
130
+ * Returns the kept pieces and the removed intersections (what the filter log
131
+ * reports), in time order.
132
+ */
133
+ export function subtractSpansFromGap(gap, spans) {
134
+ const kept = [];
135
+ const removed = [];
136
+ const sorted = spans
137
+ .filter((span) => Number.isFinite(span.fromMs) && Number.isFinite(span.toMs) && span.fromMs < span.toMs)
138
+ .sort((a, b) => a.fromMs - b.fromMs);
139
+ let cursor = gap.fromMs;
140
+ for (const span of sorted) {
141
+ if (span.toMs <= cursor)
142
+ continue;
143
+ if (span.fromMs >= gap.toMs)
144
+ break;
145
+ if (span.fromMs > cursor) {
146
+ const piece = { ...gap, fromMs: cursor, toMs: span.fromMs };
147
+ delete piece.tail;
148
+ kept.push(piece);
149
+ }
150
+ removed.push({ fromMs: Math.max(cursor, span.fromMs), toMs: Math.min(gap.toMs, span.toMs) });
151
+ cursor = Math.min(gap.toMs, span.toMs);
152
+ if (cursor >= gap.toMs)
153
+ break;
154
+ }
155
+ if (removed.length === 0)
156
+ return { kept: [gap], removed };
157
+ if (cursor < gap.toMs)
158
+ kept.push({ ...gap, fromMs: cursor });
159
+ return { kept, removed };
160
+ }
161
+ /** WARMUP_SKIPPED_SPAN_CLIP (see `warmupSkippedSpans`): applied before every budget. */
162
+ function clipWarmupSkippedSpans(overlay, detected, filtered) {
163
+ const spans = overlay.warmupSkippedSpans;
164
+ if (!spans?.length || detected.length === 0)
165
+ return detected;
166
+ const kept = [];
167
+ for (const gap of detected) {
168
+ const clipped = subtractSpansFromGap(gap, spans);
169
+ for (const piece of clipped.removed) {
170
+ filtered.push({ overlayId: overlay.overlayId, gap: piece, reason: 'warmup-skipped' });
171
+ }
172
+ kept.push(...clipped.kept);
173
+ }
174
+ return kept;
175
+ }
176
+ /**
177
+ * Book-driven overlay families, by the type prefix every overlay id carries
178
+ * (`createIndicatorId`: `<TYPE><digits>...`): their rows come from order-book
179
+ * snapshots that exist at tradeless minutes too, so they are judged against
180
+ * the full mounted grid unless the caller says otherwise (see `mainGrid`).
181
+ */
182
+ const BOOK_DRIVEN_OVERLAY_ID = /^(AGGREGATED_)?ORDERBOOK_[A-Z_]*\d/;
183
+ export function defaultMainGridForOverlay(overlayId) {
184
+ return BOOK_DRIVEN_OVERLAY_ID.test(overlayId) ? 'all' : 'real';
185
+ }
186
+ /**
187
+ * Trade-driven profile families whose rows are trades at price for ONE venue:
188
+ * a bar the chart's own trade source did not trade is not a bar these can be
189
+ * missing. Aggregated variants stay out (their venues are not the chart's
190
+ * main; indicator-gap.util.ts already keeps them off the recovery allowlist).
191
+ */
192
+ const SINGLE_VENUE_PROFILE_TYPES = new Set([
193
+ 'VOLUME_FOOTPRINT',
194
+ 'SESSION_VOLUME_PROFILE',
195
+ 'VISIBLE_RANGE_VOLUME_PROFILE',
196
+ 'FIXED_RANGE_VOLUME_PROFILE',
197
+ 'DELTA_PROFILE',
198
+ 'DEVELOPING_SESSION_PROFILE',
199
+ 'TIME_PRICE_OPPORTUNITY',
200
+ ]);
201
+ /**
202
+ * The grid a trade-driven profile overlay is judged against: 'traded' when the
203
+ * overlay is a single-venue profile riding the chart's own trade source (its
204
+ * settings name the chart's exchange and symbol, or name none), else the
205
+ * caller's fallback (undefined = the planner default). Same evidence test the
206
+ * live-feed trailing heal applies (`healMainEvidence`, live-feed.service.ts).
207
+ */
208
+ export function profileMainGridForOverlay(args) {
209
+ if (!args.indicatorType || !SINGLE_VENUE_PROFILE_TYPES.has(args.indicatorType))
210
+ return undefined;
211
+ const ovExchange = args.overlaySettings?.exchange;
212
+ const ovSymbol = args.overlaySettings?.symbol;
213
+ if (ovExchange != null && ovExchange !== '' && args.chartExchange != null && ovExchange !== args.chartExchange) {
214
+ return undefined;
215
+ }
216
+ if (ovSymbol != null && ovSymbol !== '' && args.chartSymbol != null && ovSymbol !== args.chartSymbol)
217
+ return undefined;
218
+ return 'traded';
219
+ }
220
+ /** The main rows a detector judges against for `grid` (see `mainGrid`); 'all' is the full mounted series. */
221
+ export function mainRowsForGrid(mainRows, syntheticFlags, grid) {
222
+ if (grid === 'all')
223
+ return mainRows;
224
+ if (grid === 'traded')
225
+ return tradedMainRows(mainRows, syntheticFlags);
226
+ return realMainRows(mainRows, syntheticFlags);
227
+ }
228
+ function detectOverlayGaps(overlay, fullSnapshot, realMain, tradedMain, policy, filtered) {
229
+ // Trade-driven overlays are judged against the server's bars only; a
230
+ // book-driven overlay keeps the full mounted grid; a single-venue profile
231
+ // on the chart's own trade source drops the zero-volume gap-filled bars
232
+ // too (see `mainGrid`).
233
+ const mainGrid = overlay.mainGrid ?? defaultMainGridForOverlay(overlay.overlayId);
234
+ const gridMain = mainGrid === 'all' ? fullSnapshot.mainRows : mainGrid === 'traded' ? tradedMain() : realMain;
235
+ const snapshot = gridMain === fullSnapshot.mainRows ? fullSnapshot : { ...fullSnapshot, mainRows: gridMain };
236
+ // Traded grid below two main rows (a wave clip over gap-filled minutes):
237
+ // the row-based detectors are blind, and a fallback to the real rows would
238
+ // resurrect the placeholder holes the grid removes. Zero traded rows: the
239
+ // clip holds nothing the overlay could be missing. One traded row: ask it
240
+ // exactly when the overlay has no row for it, else nothing. The repair
241
+ // detector (wave lanes) has no fallback demand, so it takes this branch
242
+ // whatever the overlay holds; the recovery detector keeps its
243
+ // fallback-demand path for a total miss (fewer than two overlay rows).
244
+ if (mainGrid === 'traded' &&
245
+ policy.detector !== 'explicit' &&
246
+ gridMain &&
247
+ gridMain.length < 2 &&
248
+ (policy.detector === 'repair' || (overlay.rows?.length ?? 0) >= 2)) {
249
+ if (gridMain.length === 1) {
250
+ const ts = gridMain[0][0];
251
+ const covered = overlay.rows?.some((row) => row?.[0] === ts) ?? false;
252
+ if (!covered)
253
+ return [{ fromMs: ts, toMs: ts + fullSnapshot.intervalMs }];
254
+ }
255
+ return [];
256
+ }
257
+ if (policy.detector === 'explicit') {
258
+ // Caller-declared demand: no row-based detection. Caps, attempts, and
259
+ // the servable floor still apply downstream, so the initiator never
260
+ // decides more than WHAT it wants — the planner decides WHETHER.
261
+ return overlay.fallbackGaps ?? [];
262
+ }
263
+ if (policy.detector === 'recovery') {
264
+ // Below two rows the cadence/interior detector returns nothing by design
265
+ // (median cadence is undefined); the caller-supplied fallback ranges keep
266
+ // a total miss retryable. PROFILE callers (parameterized threshold) still
267
+ // get the suffix hole from a 1-row overlay (the session-flip truncation
268
+ // shape when only the seed bar survived) because the tail detector needs
269
+ // only the main lattice plus one row; the heatmap/book lanes stay on the
270
+ // bounded fallback-only path (viewport cushion + horizon cap, fail
271
+ // CLOSED when the viewport is unreadable) which a raw-main tail range
272
+ // would blow past. A tail already covered by a fallback range is not
273
+ // appended (the planner never merges overlaps downstream).
274
+ if ((overlay.rows?.length ?? 0) < 2) {
275
+ const fallback = overlay.fallbackGaps ?? [];
276
+ if (overlay.tailHoles && overlay.tailHoleMinMissingRows !== undefined && overlay.rows?.length === 1) {
277
+ const tail = findIndicatorTailHole(overlay.rows, snapshot.mainRows, snapshot.intervalMs, overlay.tailHoleMinMissingRows, true);
278
+ const covered = tail !== null && fallback.some((g) => g.fromMs <= tail.fromMs && g.toMs >= tail.toMs);
279
+ if (tail && !covered)
280
+ return [...fallback, tail];
281
+ }
282
+ return fallback;
283
+ }
284
+ const recovered = findIndicatorGaps(overlay.rows, snapshot.mainRows, snapshot.intervalMs);
285
+ if (overlay.tailHoles) {
286
+ const tail = findIndicatorTailHole(overlay.rows, snapshot.mainRows, snapshot.intervalMs, overlay.tailHoleMinMissingRows, overlay.tailHoleMinMissingRows !== undefined);
287
+ if (tail)
288
+ recovered.push(tail);
289
+ }
290
+ return recovered;
291
+ }
292
+ const detected = findIndicatorDataGaps(overlay.rows, snapshot.mainRows, snapshot.intervalMs);
293
+ if (overlay.kind !== 'protected-kscript')
294
+ return detected;
295
+ // Protected kScript repairs stay within the viewport cushion: the server
296
+ // recomputes ranges it is asked for, so unbounded historical gaps would
297
+ // turn every deep pan into a full recompute.
298
+ const viewportStartMs = Number(snapshot.viewport?.startTs);
299
+ const viewportEndMs = Number(snapshot.viewport?.endTs);
300
+ const clamped = [];
301
+ for (const gap of detected) {
302
+ const clampedGap = clampIndicatorGapToViewportCushion(gap, viewportStartMs, viewportEndMs, snapshot.intervalMs);
303
+ if (clampedGap) {
304
+ clamped.push(clampedGap);
305
+ }
306
+ else {
307
+ filtered.push({ overlayId: overlay.overlayId, gap, reason: 'viewport-cushion' });
308
+ }
309
+ }
310
+ return clamped;
311
+ }
312
+ /**
313
+ * Clip sorted-ascending rows to [fromMs, toMs] inclusive (binary-searched).
314
+ * The wave-dispatch trigger uses this to bound the repair detector to the
315
+ * wave span; callers must pass rows already sorted by timestamp (main-series
316
+ * rawData is).
317
+ */
318
+ export function sliceSortedRowsToSpan(rows, fromMs, toMs) {
319
+ const [start, end] = sortedRowsSpanIndices(rows, fromMs, toMs);
320
+ return rows.slice(start, end);
321
+ }
322
+ /**
323
+ * `sliceSortedRowsToSpan` plus the matching slice of the series' positional
324
+ * synthetic flags, so a clipped planning input keeps row i paired with flag
325
+ * i (`realMainRows` refuses a length mismatch). Flags absent: undefined.
326
+ */
327
+ export function sliceSortedRowsToSpanWithFlags(rows, flags, fromMs, toMs) {
328
+ const [start, end] = sortedRowsSpanIndices(rows, fromMs, toMs);
329
+ const sliced = rows.slice(start, end);
330
+ if (!flags || flags.length !== rows.length)
331
+ return { rows: sliced, flags: undefined };
332
+ const slicedFlags = Array.prototype.slice.call(flags, start, end);
333
+ return { rows: sliced, flags: slicedFlags };
334
+ }
335
+ function sortedRowsSpanIndices(rows, fromMs, toMs) {
336
+ let lo = 0;
337
+ let hi = rows.length;
338
+ while (lo < hi) {
339
+ const mid = (lo + hi) >> 1;
340
+ if (rows[mid][0] < fromMs)
341
+ lo = mid + 1;
342
+ else
343
+ hi = mid;
344
+ }
345
+ const start = lo;
346
+ hi = rows.length;
347
+ while (lo < hi) {
348
+ const mid = (lo + hi) >> 1;
349
+ if (rows[mid][0] <= toMs)
350
+ lo = mid + 1;
351
+ else
352
+ hi = mid;
353
+ }
354
+ return [start, lo];
355
+ }
356
+ export function planIndicatorCoverage(snapshot, trigger) {
357
+ const policy = INDICATOR_COVERAGE_TRIGGER_POLICY[trigger];
358
+ // Detectors see the server's bars only (per overlay, see `mainGrid`):
359
+ // synthetic marker rows the client inserted for tradeless minutes are not
360
+ // coverage a trade-driven overlay lacks. Computed once per plan.
361
+ const realMain = realMainRows(snapshot.mainRows, snapshot.mainSyntheticFlags);
362
+ // The traded grid (single-venue profiles) is derived lazily, once per plan.
363
+ let tradedMainCache = null;
364
+ const tradedMain = () => {
365
+ if (tradedMainCache === null)
366
+ tradedMainCache = tradedMainRows(snapshot.mainRows, snapshot.mainSyntheticFlags);
367
+ return tradedMainCache;
368
+ };
369
+ const requests = [];
370
+ const filtered = [];
371
+ let sawRepairableGap = false;
372
+ let plainRequestCount = 0;
373
+ const scanCapReached = () => policy.maxPlainRangesPerScan !== null && plainRequestCount >= policy.maxPlainRangesPerScan;
374
+ for (const overlay of snapshot.overlays) {
375
+ if (scanCapReached())
376
+ break;
377
+ const allDetected = clipWarmupSkippedSpans(overlay, detectOverlayGaps(overlay, snapshot, realMain, tradedMain, policy, filtered), filtered);
378
+ // AUTHORITATIVE_EMPTY_RANGE_SKIP: a gap fully contained in a
379
+ // wire-authoritative empty span is not damage — the wire already answered
380
+ // "nothing here". Filtered before EVERY budget, including the per-overlay
381
+ // cap slice below: contained gaps must not occupy cap slots and starve a
382
+ // genuine gap sitting behind them. Straddlers plan normally (containment
383
+ // only, fail-open).
384
+ const detected = allDetected.filter((gap) => {
385
+ const window = overlay.containmentWindowFor?.(gap) ?? gap;
386
+ if (overlay.authoritativeEmptySpans?.some((span) => span.fromMs <= window.fromMs && window.toMs <= span.toMs)) {
387
+ filtered.push({ overlayId: overlay.overlayId, gap, reason: 'authoritative-empty' });
388
+ return false;
389
+ }
390
+ return true;
391
+ });
392
+ const gaps = policy.maxRangesPerOverlay !== null ? detected.slice(0, policy.maxRangesPerOverlay) : detected;
393
+ if (policy.maxRangesPerOverlay !== null) {
394
+ for (const gap of detected.slice(policy.maxRangesPerOverlay)) {
395
+ filtered.push({ overlayId: overlay.overlayId, gap, reason: 'overlay-cap' });
396
+ }
397
+ }
398
+ if (gaps.length === 0)
399
+ continue;
400
+ sawRepairableGap = true;
401
+ for (const gap of gaps) {
402
+ if (scanCapReached()) {
403
+ filtered.push({ overlayId: overlay.overlayId, gap, reason: 'scan-cap' });
404
+ continue;
405
+ }
406
+ // Gaps entirely below the proven servable floor are unfillable: the
407
+ // source keeps answering with its newest window no matter the request.
408
+ if (policy.servableFloor === 'protected-only' && overlay.kind === 'protected-kscript') {
409
+ const servableFloorMs = getIndicatorServableFloorMs(snapshot.chartIndex, overlay.overlayId);
410
+ if (servableFloorMs !== undefined && gap.toMs <= servableFloorMs + snapshot.intervalMs) {
411
+ filtered.push({ overlayId: overlay.overlayId, gap, reason: 'below-servable-floor' });
412
+ continue;
413
+ }
414
+ // A gap inside a range a repair has already proven as-served is
415
+ // phantom damage (legitimate NaN break rows in the script's output):
416
+ // the source answers with identical rows every time, so repairing
417
+ // re-detects and refetches forever.
418
+ if (isIndicatorRangeProvenServed(snapshot.chartIndex, overlay.overlayId, gap.fromMs, gap.toMs)) {
419
+ filtered.push({ overlayId: overlay.overlayId, gap, reason: 'proven-served' });
420
+ continue;
421
+ }
422
+ }
423
+ let attemptKey = null;
424
+ let attempt = null;
425
+ if (policy.attempts === 'consume') {
426
+ attemptKey = indicatorCoverageAttemptKey(snapshot.chartIndex, snapshot.datasetKey ?? 'unknown', overlay.overlayId, gap, snapshot.intervalMs);
427
+ if (getIndicatorCoverageAttempts(attemptKey) >= INDICATOR_COVERAGE_MAX_ATTEMPTS) {
428
+ filtered.push({ overlayId: overlay.overlayId, gap, reason: 'attempts-exhausted' });
429
+ continue;
430
+ }
431
+ // Increment at plan time so the cap holds under coalescing executors.
432
+ attempt = noteIndicatorCoverageAttempt(attemptKey);
433
+ }
434
+ const range = policy.widenRequestByInterval
435
+ ? { fromMs: gap.fromMs, toMs: gap.toMs + snapshot.intervalMs }
436
+ : gap;
437
+ requests.push({ overlayId: overlay.overlayId, kind: overlay.kind, gap, range, attemptKey, attempt });
438
+ if (overlay.kind === 'plain')
439
+ plainRequestCount++;
440
+ }
441
+ }
442
+ return { requests, filtered, sawRepairableGap };
443
+ }