@orangecharts/wrun-chart-host 0.4.0 → 0.5.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 (322) hide show
  1. package/README.md +15 -4
  2. package/dist/constants/exchange-names.leaf.d.ts +8 -0
  3. package/dist/constants/exchange-names.leaf.js +101 -0
  4. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
  5. package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
  6. package/dist/constants/opra-compliance.constants.d.ts +19 -0
  7. package/dist/constants/opra-compliance.constants.js +19 -0
  8. package/dist/constants/replay-ladder.leaf.d.ts +30 -0
  9. package/dist/constants/replay-ladder.leaf.js +99 -0
  10. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  11. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  12. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  13. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  14. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  15. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  16. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  17. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  18. package/dist/host-env.d.ts +313 -18
  19. package/dist/host-env.js +15 -0
  20. package/dist/host-ports.types.d.ts +853 -16
  21. package/dist/index.d.ts +139 -2
  22. package/dist/index.js +139 -2
  23. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  24. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  25. package/dist/interfaces/market-event.interface.d.ts +231 -0
  26. package/dist/interfaces/market-event.interface.js +15 -0
  27. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  28. package/dist/interfaces/opra-realtime.interface.js +34 -59
  29. package/dist/interfaces/replay.interface.d.ts +285 -0
  30. package/dist/interfaces/replay.interface.js +1 -0
  31. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  32. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  33. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  34. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  35. package/dist/market-data/billing.interface.d.ts +219 -0
  36. package/dist/market-data/billing.interface.js +58 -0
  37. package/dist/market-data/venue-governed.util.d.ts +2 -0
  38. package/dist/market-data/venue-governed.util.js +10 -0
  39. package/dist/market-data/venue.d.ts +122 -0
  40. package/dist/market-data/venue.js +1 -0
  41. package/dist/market-data/venues/index.d.ts +97 -0
  42. package/dist/market-data/venues/index.js +33 -0
  43. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  44. package/dist/market-data/venues/opra.d.ts +70 -0
  45. package/dist/market-data/venues/opra.js +74 -0
  46. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  47. package/dist/replay/replayIndicatorRows.js +117 -0
  48. package/dist/replay/replayLadder.d.ts +85 -0
  49. package/dist/replay/replayLadder.js +388 -0
  50. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  51. package/dist/utility/auth/server-clock.util.js +238 -0
  52. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  53. package/dist/utility/chart/builtin-identity.util.js +51 -0
  54. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  55. package/dist/utility/chart/cache-alignment.util.js +926 -0
  56. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  57. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  58. package/dist/utility/chart/chart-mount-epoch.util.d.ts +5 -0
  59. package/dist/utility/chart/chart-mount-epoch.util.js +29 -0
  60. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  61. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  62. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  63. package/dist/utility/chart/color-customization.leaf.js +16 -0
  64. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  65. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  66. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  67. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  68. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  69. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  70. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  71. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  72. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  73. package/dist/utility/chart/index-host-tier.util.js +118 -0
  74. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  75. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  76. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  77. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  78. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  79. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  80. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  81. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  82. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  83. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  84. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  85. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  86. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  87. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  88. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  89. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  90. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  91. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  92. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  93. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  94. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  95. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  96. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  97. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  98. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  99. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  100. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  101. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  102. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  103. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  104. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  105. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  106. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  107. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  108. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  109. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  110. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  111. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  112. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  113. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  114. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  115. package/dist/utility/chart/live-cadence.util.js +37 -0
  116. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  117. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  118. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  119. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  120. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  121. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  122. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  123. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  124. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  125. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  126. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  127. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  128. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  129. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  130. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  131. package/dist/utility/chart/mixed-mode.util.js +139 -0
  132. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  133. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  134. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  135. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  136. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  137. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  138. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  139. package/dist/utility/chart/price-precision.util.js +70 -0
  140. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  141. package/dist/utility/chart/profile-block-size.util.js +141 -0
  142. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  143. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  144. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  145. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  146. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  147. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  148. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  149. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  150. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  151. package/dist/utility/chart/titan-constants.pin.js +18 -5
  152. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  153. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  154. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  155. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  156. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  157. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  158. package/dist/utility/common/data-processing.util.d.ts +138 -0
  159. package/dist/utility/common/data-processing.util.js +346 -0
  160. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  161. package/dist/utility/common/visible-timeout.util.js +23 -8
  162. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  163. package/dist/utility/exchange-format.leaf.js +47 -0
  164. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  165. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  166. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  167. package/dist/utility/market-events/market-events.util.js +392 -0
  168. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  169. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  170. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  171. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  172. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  173. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  174. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  175. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  176. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  177. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  178. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  179. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  180. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  181. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  182. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  183. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
  184. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
  185. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  186. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  187. package/dist/utility/wrun/wrun-bar-count.util.d.ts +83 -0
  188. package/dist/utility/wrun/wrun-bar-count.util.js +259 -0
  189. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  190. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  191. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  192. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  193. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  194. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  195. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  196. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  197. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  198. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  199. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  200. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  201. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  202. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  203. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  204. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  205. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  206. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  207. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  208. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  209. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  210. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  211. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  212. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  213. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  214. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  215. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  216. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  217. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  218. package/dist/utility/wrun/wrun-host.service.d.ts +266 -0
  219. package/dist/utility/wrun/wrun-host.service.js +655 -0
  220. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  221. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  222. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  223. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  224. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  225. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  226. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  227. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  228. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  229. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  230. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  231. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  232. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  233. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  234. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  235. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  236. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  237. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  238. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  239. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  240. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  241. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  242. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  243. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  244. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  245. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  246. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  247. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  248. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  249. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  250. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  251. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  252. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  253. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  254. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  255. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  256. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  257. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  258. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  259. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  260. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
  261. package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
  262. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  263. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  264. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  265. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  266. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  267. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  268. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  269. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  270. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  271. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  272. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  273. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  274. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  275. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  276. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  277. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  278. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  279. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  280. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  281. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  282. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  283. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  284. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  285. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  286. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  287. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  288. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  289. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  290. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  291. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  292. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  293. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  294. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  295. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  296. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  297. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  298. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  299. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  300. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  301. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  302. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  303. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  304. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  305. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  306. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  307. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  308. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  309. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  310. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  311. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  312. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  313. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  314. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  315. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  316. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  317. package/dist/utils/replay/replay-buffer-math.js +684 -0
  318. package/dist/workers/wrun/wrun-abi-host.d.ts +190 -0
  319. package/dist/workers/wrun/wrun-abi-host.js +1201 -0
  320. package/dist/workers/wrun/wrun-engine-handler.d.ts +37 -0
  321. package/dist/workers/wrun/wrun-engine-handler.js +211 -0
  322. package/package.json +3 -3
@@ -0,0 +1,89 @@
1
+ /** Reference capture of the mounted overlay fields the deciders consult. */
2
+ export type MountedIntegrationSnapshot = {
3
+ present: boolean;
4
+ lazyIdentity?: unknown;
5
+ rawData?: unknown;
6
+ runResult?: unknown;
7
+ nestedMeta?: unknown;
8
+ };
9
+ export type LazyMergePlan = 'degenerate-replace' | 'canonical-merge';
10
+ /**
11
+ * A zombie mount (epoch-adjacent rows from a broken integration) must not be
12
+ * preserved by the merge; the fresh result replaces it wholesale.
13
+ */
14
+ export declare function resolveLazyMergePlan(snapshot: MountedIntegrationSnapshot): LazyMergePlan;
15
+ export type LocalRunRoute = {
16
+ action: 'skip';
17
+ reason: 'style-mismatch' | 'preserve-previous-output' | 'orderbook-zero-bar-summary-only' | 'no-renderer-update';
18
+ } | {
19
+ action: 'apply-rows-refresh';
20
+ } | {
21
+ action: 'apply-rows-merge';
22
+ } | {
23
+ action: 'apply-remount';
24
+ };
25
+ /**
26
+ * The local engine callback's integration route, in its exact historical
27
+ * decision order: style mismatch -> transient preserve -> no renderer update
28
+ * (orderbook zero-bar results surface summaries only; everything else is
29
+ * diagnostics-only) -> mounted-rows fast path when the run is an ambient
30
+ * live-source refresh AND no full integration is owed -> mounted-rows MERGE
31
+ * when the run is a range refresh over the same plot set AND no full
32
+ * integration is owed -> full remount.
33
+ * Pure: the caller keeps every side effect; this pins the CHOICE.
34
+ */
35
+ export declare function localRunIntegrationRoute(input: {
36
+ styleMatch: boolean;
37
+ preservePreviousOutput: boolean;
38
+ hasRendererUpdate: boolean;
39
+ allowOrderbookZeroBar: boolean;
40
+ isLiveSourceRefresh: boolean;
41
+ owedFullIntegration: boolean;
42
+ /**
43
+ * A source-cache revalidation result whose plot set (output keys, plot
44
+ * types, nested panes) matches the last integrated result: the fresh rows
45
+ * land on the mounted row set, never a remount. Defaults false (every
46
+ * pre-existing caller).
47
+ */
48
+ revalidationSamePlotSet?: boolean;
49
+ /**
50
+ * A range-refresh result (a lazy history page, the loaded-range refresh,
51
+ * or a refresh whose cycle already acked: `isLocalRunRangeRefreshResult`)
52
+ * whose plot set matches the last integrated result and whose mount is
53
+ * not a degenerate zombie (`resolveLazyMergePlan`). Its rows UNION with
54
+ * the mounted rows in place (mounted rows plus the new rows, values
55
+ * refreshed where they overlap), never a remount: every candle prepend
56
+ * used to remount every local script, one blink per page per script.
57
+ * Defaults false (every pre-existing caller).
58
+ */
59
+ rangeRefreshSamePlotSet?: boolean;
60
+ }): LocalRunRoute;
61
+ /**
62
+ * Resync reasons whose results are full recomputes over the loaded range:
63
+ * a lazy history page (titan-charts.ts lazy load) and the loaded-range
64
+ * refresh after a main candle commit (data-fetching.util.ts). String
65
+ * literals on purpose: this is a leaf module and the loaded-range reason is
66
+ * only ever spelled at its producer.
67
+ */
68
+ export declare const LOCAL_RUN_RANGE_REFRESH_REASONS: ReadonlySet<string>;
69
+ /**
70
+ * Whether a local-run result is a range refresh (a full recompute over the
71
+ * loaded range) rather than a first run, a live tick, a settings recompute
72
+ * or a domain switch. Two shapes qualify:
73
+ * - the resync slot names a range-refresh reason;
74
+ * - the slot is EMPTY on a non-first, non-deferred result. The engine
75
+ * proxy resolves `refresh()` on the worker ACK, which can land before the
76
+ * run result posts, and the cycle's `complete()` clears the slot on that
77
+ * ack: the run result then arrives unlabelled. The 2026-09-13 boot ring
78
+ * (three overlapping refreshes: init, loaded-range, warmup lazy page)
79
+ * showed exactly that, the third result attributed `null` and remounted.
80
+ * A deferred unlabelled result is a live tick (the caller's live arm);
81
+ * a first run is the mount and never a refresh.
82
+ * Only the attribution: the same-plot-set and degenerate-mount checks stay
83
+ * with the caller (`rangeRefreshSamePlotSet`).
84
+ */
85
+ export declare function isLocalRunRangeRefreshResult(input: {
86
+ resyncReason: string | null | undefined;
87
+ deferred: boolean;
88
+ wasFirstRun: boolean;
89
+ }): boolean;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The integration decision core's names a wrun run reads (a leaf of utility/chart/kscript-integration-decision.util.ts;
3
+ * P2/inventory.md section 1.1): the lazy merge plan over a mounted snapshot, and the local-run route with its
4
+ * range-refresh attribution, the choice wrun-integration-route.util feeds from a wrun run. Pure: verbatim bodies, no
5
+ * state, and its one import is the degenerate-rows leaf, so it moves into the chart-host package with the phase 2
6
+ * closure. The decision core re-exports every name and keeps its deciders.
7
+ */
8
+ import { protectedKScriptRowsLookDegenerate } from './protected-kscript-degenerate-rows.leaf.js';
9
+ /**
10
+ * A zombie mount (epoch-adjacent rows from a broken integration) must not be
11
+ * preserved by the merge; the fresh result replaces it wholesale.
12
+ */
13
+ export function resolveLazyMergePlan(snapshot) {
14
+ if (snapshot.present && protectedKScriptRowsLookDegenerate(snapshot.rawData))
15
+ return 'degenerate-replace';
16
+ return 'canonical-merge';
17
+ }
18
+ /**
19
+ * The local engine callback's integration route, in its exact historical
20
+ * decision order: style mismatch -> transient preserve -> no renderer update
21
+ * (orderbook zero-bar results surface summaries only; everything else is
22
+ * diagnostics-only) -> mounted-rows fast path when the run is an ambient
23
+ * live-source refresh AND no full integration is owed -> mounted-rows MERGE
24
+ * when the run is a range refresh over the same plot set AND no full
25
+ * integration is owed -> full remount.
26
+ * Pure: the caller keeps every side effect; this pins the CHOICE.
27
+ */
28
+ export function localRunIntegrationRoute(input) {
29
+ if (!input.styleMatch)
30
+ return { action: 'skip', reason: 'style-mismatch' };
31
+ if (input.preservePreviousOutput)
32
+ return { action: 'skip', reason: 'preserve-previous-output' };
33
+ if (!input.hasRendererUpdate) {
34
+ if (input.allowOrderbookZeroBar)
35
+ return { action: 'skip', reason: 'orderbook-zero-bar-summary-only' };
36
+ return { action: 'skip', reason: 'no-renderer-update' };
37
+ }
38
+ if ((input.isLiveSourceRefresh || input.revalidationSamePlotSet === true) && !input.owedFullIntegration) {
39
+ return { action: 'apply-rows-refresh' };
40
+ }
41
+ if (input.rangeRefreshSamePlotSet === true && !input.owedFullIntegration) {
42
+ return { action: 'apply-rows-merge' };
43
+ }
44
+ return { action: 'apply-remount' };
45
+ }
46
+ /**
47
+ * Resync reasons whose results are full recomputes over the loaded range:
48
+ * a lazy history page (titan-charts.ts lazy load) and the loaded-range
49
+ * refresh after a main candle commit (data-fetching.util.ts). String
50
+ * literals on purpose: this is a leaf module and the loaded-range reason is
51
+ * only ever spelled at its producer.
52
+ */
53
+ export const LOCAL_RUN_RANGE_REFRESH_REASONS = new Set([
54
+ 'lazy-range-refresh',
55
+ 'loaded-range-refresh',
56
+ ]);
57
+ /**
58
+ * Whether a local-run result is a range refresh (a full recompute over the
59
+ * loaded range) rather than a first run, a live tick, a settings recompute
60
+ * or a domain switch. Two shapes qualify:
61
+ * - the resync slot names a range-refresh reason;
62
+ * - the slot is EMPTY on a non-first, non-deferred result. The engine
63
+ * proxy resolves `refresh()` on the worker ACK, which can land before the
64
+ * run result posts, and the cycle's `complete()` clears the slot on that
65
+ * ack: the run result then arrives unlabelled. The 2026-09-13 boot ring
66
+ * (three overlapping refreshes: init, loaded-range, warmup lazy page)
67
+ * showed exactly that, the third result attributed `null` and remounted.
68
+ * A deferred unlabelled result is a live tick (the caller's live arm);
69
+ * a first run is the mount and never a refresh.
70
+ * Only the attribution: the same-plot-set and degenerate-mount checks stay
71
+ * with the caller (`rangeRefreshSamePlotSet`).
72
+ */
73
+ export function isLocalRunRangeRefreshResult(input) {
74
+ if (input.wasFirstRun)
75
+ return false;
76
+ if (typeof input.resyncReason === 'string' && input.resyncReason.length > 0) {
77
+ return LOCAL_RUN_RANGE_REFRESH_REASONS.has(input.resyncReason);
78
+ }
79
+ return !input.deferred;
80
+ }
@@ -0,0 +1,76 @@
1
+ import { type KScriptLiveSourceSnapshotLike } from './kscript-live-source-identity.util.js';
2
+ export declare const V2_LIVE_PENDING_DATA_POINT_CAP = 1024;
3
+ export declare const V2_LIVE_HIDDEN_BACKLOG_RUN_POINTS = 512;
4
+ /**
5
+ * Hidden hold counters (rest-cost H6), for the hidden live pace stats
6
+ * (`window.__kiyoLiveHiddenPaceStats()`, hidden-live-drain.util):
7
+ * - `kscriptHolds`: script holds taken, once per script per hide (the
8
+ * `local-kscript-hidden-hold` ring event);
9
+ * - `kscriptHiddenRuns`: engine passes a held script ran while the page was
10
+ * hidden (the backlog runs). A healthy hide adds 0: the return's one pass
11
+ * per script is the `local-kscript-hidden-drain` ring event.
12
+ */
13
+ export interface LocalKScriptHiddenHoldStats {
14
+ kscriptHolds: number;
15
+ kscriptHiddenRuns: number;
16
+ }
17
+ export declare function noteLocalKScriptHiddenHold(): void;
18
+ export declare function noteLocalKScriptHiddenRun(): void;
19
+ export declare function getLocalKScriptHiddenHoldStats(): LocalKScriptHiddenHoldStats;
20
+ export declare function shouldAccumulateV2LiveDataPoints(sourceType: unknown): boolean;
21
+ /**
22
+ * The size floor a raw TRADE print must clear to fold into ANY `trades`
23
+ * source of an engine: the smallest declared minSize (0 when a source has
24
+ * none). Applied at intake, before the pending queue, so a busy feed's small
25
+ * prints cannot push a qualifying print out of the 1,024-message window.
26
+ */
27
+ export declare function v2LiveTradesSizeFloor(snapshots: ReadonlyArray<{
28
+ sourceType?: string;
29
+ payload?: unknown;
30
+ }> | undefined): number;
31
+ /** True when a raw TRADE message carries a print below `floor` (a non-print message never is). */
32
+ export declare function v2LiveTradePrintBelowFloor(data: unknown, floor: number): boolean;
33
+ /**
34
+ * One coalesce key's pending live points, oldest first, bounded by the cap.
35
+ *
36
+ * The intake appends every point IN PLACE. The previous shape (a fresh copy
37
+ * of the whole queue per point) cost the busiest key a quadratic amount of
38
+ * copying up to the cap, per local engine (field 2026-09-26). A trim advances
39
+ * a head cursor instead of shifting the array, and the dead prefix is
40
+ * compacted once per cap trims, so a push is O(1) amortized and the array
41
+ * behind the queue never holds more than twice the cap.
42
+ *
43
+ * Ownership: one appender (the intake) and one consumer (the drain), never at
44
+ * the same time. The drain detaches its batch from the coalesce map before it
45
+ * reads any queue, then drains each queue exactly once; a point that arrives
46
+ * after the detach starts the key's next queue, for the next drain. See
47
+ * scheduleCoalescedV2TechnicalScriptLiveUpdate in live-feed.service.ts.
48
+ */
49
+ export declare class V2LivePendingDataPointQueue {
50
+ private readonly cap;
51
+ private points;
52
+ private head;
53
+ constructor(cap?: number);
54
+ get size(): number;
55
+ /** Appends `point`; returns 1 when the oldest point was trimmed to keep the cap, else 0. */
56
+ push(point: unknown): 0 | 1;
57
+ /** Hands the pending points (oldest first) to the caller and empties the queue. */
58
+ drain(): unknown[];
59
+ }
60
+ /**
61
+ * True when a message of `sourceType` can never fold into this engine: it has
62
+ * initialised with a populated source cache that declares no source of that
63
+ * type. The router offers every subscribed symbol's messages to every local
64
+ * engine, so most (engine, source type) pairs it visits are foreign. The
65
+ * drain already skipped those without a worker round-trip (its zero-match
66
+ * cheap path); this is the same predicate at the intake, so a foreign type
67
+ * never queues a point or arms a drain. Anything less certain still queues
68
+ * (an uninitialised engine, an empty cache, a declared type whose variants
69
+ * reject the message's identity): those keep the drain's bootstrap and
70
+ * deep-lookup paths.
71
+ */
72
+ export declare function isV2LiveSourceTypeForeignToEngine(engine: {
73
+ hasInitialized?: boolean;
74
+ }, cachedSnapshots: KScriptLiveSourceSnapshotLike[] | undefined, sourceType: string): boolean;
75
+ export declare function v2LiveSeriesIdentityKey(exchange: string | undefined, symbol: string | undefined): string;
76
+ export declare function filterV2LiveDataPointsBySeries(points: unknown[], expectedExchange: string | undefined, expectedSymbol: string | undefined): unknown[];
@@ -0,0 +1,156 @@
1
+ import { hasKScriptLiveSourceSnapshotOfType, } from './kscript-live-source-identity.util.js';
2
+ // Live kScript source messages are increments for additive sources (buy/sell
3
+ // volume, liquidations, and the volume component of ohlcv trade ticks), so the
4
+ // per-source live coalescer must fold EVERY pending message into the merge base
5
+ // at drain time. Keeping only the newest message per window (the old behavior)
6
+ // silently discarded the volume of every clobbered message. BUY and SELL
7
+ // aggregations share one source type, so alternating sides alone lost most of a
8
+ // busy bar's volume between poll corrections, which is why the browser-run
9
+ // indicator read far lower volume/delta than the server-run one. Orderbook
10
+ // messages are full snapshots, so last-wins remains correct there.
11
+ // Memory guard only, sized for the holds the lane actually takes. A key's queue
12
+ // grows for as long as its script's window stays open: the 1s refresh gate,
13
+ // the pan hold, the hidden-tab floor, and a drain chain that is still awaiting
14
+ // the worker all keep it open (field dumps 2026-09-14: holds of 8 to 31 s at
15
+ // rest with up to 222 points on one key at 256). Trimming drops the OLDEST
16
+ // increments, which is volume the next poll has to resynchronise, so the cap
17
+ // must sit well above any hold a healthy session takes: 1024 covers about
18
+ // 50 s of the busiest BTC tape (20 buy/sell prints a second on one key). Each
19
+ // trim is counted on the flush ring event (`droppedPoints`).
20
+ export const V2_LIVE_PENDING_DATA_POINT_CAP = 1024;
21
+ // The hidden hold (rest-cost H6) keeps a key's window open for as long as the
22
+ // page stays hidden: a held script arms no timer and only folds. So that the
23
+ // cap above never trims a held point, a held key whose queue reaches this many
24
+ // points runs ONE drain at once (`coalesceSnap: 'hidden-backlog'`) and then
25
+ // holds again. Half the cap: the run leaves 512 points of headroom for the
26
+ // ticks that land while it is in flight (about 25 s of the busiest tape).
27
+ export const V2_LIVE_HIDDEN_BACKLOG_RUN_POINTS = 512;
28
+ const hiddenHoldStats = { kscriptHolds: 0, kscriptHiddenRuns: 0 };
29
+ export function noteLocalKScriptHiddenHold() {
30
+ hiddenHoldStats.kscriptHolds += 1;
31
+ }
32
+ export function noteLocalKScriptHiddenRun() {
33
+ hiddenHoldStats.kscriptHiddenRuns += 1;
34
+ }
35
+ export function getLocalKScriptHiddenHoldStats() {
36
+ return { ...hiddenHoldStats };
37
+ }
38
+ export function shouldAccumulateV2LiveDataPoints(sourceType) {
39
+ return !(typeof sourceType === 'string' && sourceType.toLowerCase() === 'orderbook');
40
+ }
41
+ /**
42
+ * The size floor a raw TRADE print must clear to fold into ANY `trades`
43
+ * source of an engine: the smallest declared minSize (0 when a source has
44
+ * none). Applied at intake, before the pending queue, so a busy feed's small
45
+ * prints cannot push a qualifying print out of the 1,024-message window.
46
+ */
47
+ export function v2LiveTradesSizeFloor(snapshots) {
48
+ let floor = Number.POSITIVE_INFINITY;
49
+ let any = false;
50
+ for (const snapshot of snapshots ?? []) {
51
+ if (snapshot.sourceType !== 'trades')
52
+ continue;
53
+ any = true;
54
+ const minSize = Number(snapshot.payload?.minSize);
55
+ floor = Math.min(floor, Number.isFinite(minSize) && minSize > 0 ? minSize : 0);
56
+ }
57
+ return any && Number.isFinite(floor) ? floor : 0;
58
+ }
59
+ /** True when a raw TRADE message carries a print below `floor` (a non-print message never is). */
60
+ export function v2LiveTradePrintBelowFloor(data, floor) {
61
+ if (!(floor > 0))
62
+ return false;
63
+ const amount = Number(data?.trade?.amount);
64
+ return Number.isFinite(amount) && amount < floor;
65
+ }
66
+ /**
67
+ * One coalesce key's pending live points, oldest first, bounded by the cap.
68
+ *
69
+ * The intake appends every point IN PLACE. The previous shape (a fresh copy
70
+ * of the whole queue per point) cost the busiest key a quadratic amount of
71
+ * copying up to the cap, per local engine (field 2026-09-26). A trim advances
72
+ * a head cursor instead of shifting the array, and the dead prefix is
73
+ * compacted once per cap trims, so a push is O(1) amortized and the array
74
+ * behind the queue never holds more than twice the cap.
75
+ *
76
+ * Ownership: one appender (the intake) and one consumer (the drain), never at
77
+ * the same time. The drain detaches its batch from the coalesce map before it
78
+ * reads any queue, then drains each queue exactly once; a point that arrives
79
+ * after the detach starts the key's next queue, for the next drain. See
80
+ * scheduleCoalescedV2TechnicalScriptLiveUpdate in live-feed.service.ts.
81
+ */
82
+ export class V2LivePendingDataPointQueue {
83
+ cap;
84
+ points = [];
85
+ head = 0;
86
+ constructor(cap = V2_LIVE_PENDING_DATA_POINT_CAP) {
87
+ this.cap = cap;
88
+ }
89
+ get size() {
90
+ return this.points.length - this.head;
91
+ }
92
+ /** Appends `point`; returns 1 when the oldest point was trimmed to keep the cap, else 0. */
93
+ push(point) {
94
+ this.points.push(point);
95
+ if (this.points.length - this.head <= this.cap)
96
+ return 0;
97
+ this.head += 1;
98
+ if (this.head >= this.cap) {
99
+ this.points.splice(0, this.head);
100
+ this.head = 0;
101
+ }
102
+ return 1;
103
+ }
104
+ /** Hands the pending points (oldest first) to the caller and empties the queue. */
105
+ drain() {
106
+ const points = this.head === 0 ? this.points : this.points.slice(this.head);
107
+ this.points = [];
108
+ this.head = 0;
109
+ return points;
110
+ }
111
+ }
112
+ /**
113
+ * True when a message of `sourceType` can never fold into this engine: it has
114
+ * initialised with a populated source cache that declares no source of that
115
+ * type. The router offers every subscribed symbol's messages to every local
116
+ * engine, so most (engine, source type) pairs it visits are foreign. The
117
+ * drain already skipped those without a worker round-trip (its zero-match
118
+ * cheap path); this is the same predicate at the intake, so a foreign type
119
+ * never queues a point or arms a drain. Anything less certain still queues
120
+ * (an uninitialised engine, an empty cache, a declared type whose variants
121
+ * reject the message's identity): those keep the drain's bootstrap and
122
+ * deep-lookup paths.
123
+ */
124
+ export function isV2LiveSourceTypeForeignToEngine(engine, cachedSnapshots, sourceType) {
125
+ return (engine.hasInitialized === true &&
126
+ Array.isArray(cachedSnapshots) &&
127
+ cachedSnapshots.length > 0 &&
128
+ !hasKScriptLiveSourceSnapshotOfType(cachedSnapshots, sourceType));
129
+ }
130
+ // The router offers every subscribed symbol's messages to every engine, so the
131
+ // per-engine accumulation MUST segregate by series identity: the drain resolves
132
+ // its merge target from the newest message's identity, then folds every queued
133
+ // point into those rows. One shared per-type queue let another chart's trade
134
+ // aggs ride along and merge into this source's bars (a foreign close becomes
135
+ // the bar's high/low through the max/min ratchet), or, with a foreign newest
136
+ // message, fail the lookup and drop the genuine increments queued behind it.
137
+ export function v2LiveSeriesIdentityKey(exchange, symbol) {
138
+ return `${exchange ?? ''}|${symbol ?? ''}`;
139
+ }
140
+ // Safety net behind the identity-keyed queue: any point that still reaches a
141
+ // fold with a different series identity must not touch these rows. Points
142
+ // without a series stay; some payload shapes carry none.
143
+ export function filterV2LiveDataPointsBySeries(points, expectedExchange, expectedSymbol) {
144
+ return points.filter((point) => {
145
+ const series = point?.series;
146
+ if (!series || typeof series !== 'object')
147
+ return true;
148
+ const pointExchange = typeof series.exchange === 'string' ? series.exchange : undefined;
149
+ const pointSymbol = typeof series.symbol === 'string' ? series.symbol : undefined;
150
+ if (pointExchange && expectedExchange && pointExchange !== expectedExchange)
151
+ return false;
152
+ if (pointSymbol && expectedSymbol && pointSymbol !== expectedSymbol)
153
+ return false;
154
+ return true;
155
+ });
156
+ }
@@ -0,0 +1,34 @@
1
+ /** At rest, live-source refresh engine runs drain at most once per this. */
2
+ export declare const LOCAL_KSCRIPT_LIVE_SOURCE_REST_REFRESH_MIN_INTERVAL_MS = 1000;
3
+ export declare function __setLocalKScriptLiveRestPaceClockForTests(fn: (() => number) | null): void;
4
+ /** Runtime kill switch; session-scoped, defaults to enabled. */
5
+ export declare function setLocalKScriptLiveRestPaceDisabled(disabled: boolean): void;
6
+ export declare function isLocalKScriptLiveRestPaceDisabled(): boolean;
7
+ export type LocalKScriptLiveRestPaceAdmitReason = 'disabled' | 'not-at-rest' | 'floor-open';
8
+ export type LocalKScriptLiveRestPaceDecision = {
9
+ admit: true;
10
+ reason: LocalKScriptLiveRestPaceAdmitReason;
11
+ } | {
12
+ admit: false;
13
+ retryInMs: number;
14
+ msSinceLastRun: number;
15
+ };
16
+ /**
17
+ * Drain-admission decision. Pure read: it never stamps (the caller stamps at
18
+ * actual dispatch via noteLocalKScriptLiveRestPacedRun), so a deferred drain
19
+ * re-deciding at its re-armed timer cannot push the floor out.
20
+ */
21
+ export declare function decideLocalKScriptLiveRestPacedDrain(args: {
22
+ chartIndex: number;
23
+ indicatorId: string;
24
+ /** Milliseconds since the chart's last viewport motion; Infinity when it never moved. */
25
+ msSinceViewportMotion: number;
26
+ }): LocalKScriptLiveRestPaceDecision;
27
+ /**
28
+ * Stamp an actually-dispatched engine run for this overlay. Called at the
29
+ * coalescer's dispatch point for EVERY run (gesture-time included), and also
30
+ * while the kill switch is off so re-enabling resumes from the last real run.
31
+ */
32
+ export declare function noteLocalKScriptLiveRestPacedRun(chartIndex: number, indicatorId: string): void;
33
+ export declare function clearAllLocalKScriptLiveRestPaceForTests(): void;
34
+ export declare function __getLocalKScriptLiveRestPaceStampCountForTests(): number;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * REST-PACING FLOOR for the local kScript live-source refresh lane.
3
+ *
4
+ * Field evidence (production dump, 2026-07-27, a container-native v2 script
5
+ * subscribed to buy_sell_volume + volume_profile + orderbook + ohlcv): in a
6
+ * 13.7s at-rest capture the live coalescer was a pass-through (308 schedules,
7
+ * 308 drains, up to 28 drains/second), driving 92 full engine re-runs (~7/s,
8
+ * 170-225ms each for that script) and 80 metadata callbacks, of which ~25
9
+ * survived the byte-identical fingerprint gate and repainted the whole scene
10
+ * (~2 visible repaints/second of band-fill flicker). The structural gap: the
11
+ * per-overlay coalescer state is DELETED once a drain leaves nothing pending,
12
+ * so the next tick recreates it with lastStartedAt 0 and dispatches with zero
13
+ * delay. Gestures are protected by the pan-hold and the settle-hold; AT REST
14
+ * nothing paced the drain.
15
+ *
16
+ * This module is that pacer. Keyed per overlay (chartIndex|indicatorId), the
17
+ * coalescer's drain admission consults it before dispatching an engine run
18
+ * while the viewport is at rest (motion clock quiet for at least the lane's
19
+ * idle window, the same LOCAL_TECHNICAL_SCRIPT_LIVE_APPLY_VIEWPORT_IDLE_MS
20
+ * threshold the paint-suppression path uses):
21
+ *
22
+ * - The first drain after at least
23
+ * LOCAL_KSCRIPT_LIVE_SOURCE_REST_REFRESH_MIN_INTERVAL_MS of quiet admits
24
+ * immediately, so a lone tick gains zero latency.
25
+ * - A drain inside the floor is deferred: the caller re-arms its own timer for
26
+ * the returned remainder while source messages keep folding into the
27
+ * coalescer's pending state (source-row merges stay per tick and lossless,
28
+ * ONLY the engine run + apply are paced), so exactly ONE drain runs at floor
29
+ * expiry with the newest merged state, latest wins.
30
+ * - Below the idle window the admission always passes: gestures are owned by
31
+ * the existing drain pan-hold and the settle-hold, and their semantics must
32
+ * not change. Every dispatched run stamps the floor clock (gesture-time runs
33
+ * included) so the first at-rest drain after a gesture cannot stack onto a
34
+ * run that just happened.
35
+ *
36
+ * The floor never touches WHAT is applied, only WHEN the engine re-runs: the
37
+ * single-owner supersession contract (the settle-hold drops coalescer live-lane
38
+ * pendings) and the live lane's no-maxWaitMs rule live downstream of this
39
+ * admission and are unaffected.
40
+ *
41
+ * Kill switch: setLocalKScriptLiveRestPaceDisabled(true), or from a console
42
+ * __disableKiyoKScriptLiveRestPace() / __enableKiyoKScriptLiveRestPace(),
43
+ * restores the pre-floor admission (every scheduled drain dispatches).
44
+ *
45
+ * Dependency-light on purpose (node specs import this directly), mirroring
46
+ * kscript-live-settle-hold.util: no service imports, injected clock.
47
+ */
48
+ import { LOCAL_TECHNICAL_SCRIPT_LIVE_APPLY_VIEWPORT_IDLE_MS } from './local-technical-script-live-apply-coalescer.util.js';
49
+ /** At rest, live-source refresh engine runs drain at most once per this. */
50
+ export const LOCAL_KSCRIPT_LIVE_SOURCE_REST_REFRESH_MIN_INTERVAL_MS = 1_000;
51
+ // Stamp-map bound. Entries are plain timestamps (no timers, no callbacks), so
52
+ // no teardown wiring is owed: a stale stamp can only defer a same-id overlay
53
+ // re-added within one floor interval of its last run by less than that
54
+ // interval. The cap just keeps pathological indicator-id churn from minting
55
+ // immortal entries; eviction is oldest-stamped-first via Map insertion order
56
+ // (noteLocalKScriptLiveRestPacedRun re-inserts on every stamp).
57
+ const LOCAL_KSCRIPT_LIVE_REST_PACE_MAX_KEYS = 512;
58
+ const lastRunAtByKey = new Map();
59
+ let restPaceDisabled = false;
60
+ let nowFn = () => Date.now();
61
+ export function __setLocalKScriptLiveRestPaceClockForTests(fn) {
62
+ nowFn = fn ?? (() => Date.now());
63
+ }
64
+ function paceKey(chartIndex, indicatorId) {
65
+ return `${chartIndex}:${indicatorId}`;
66
+ }
67
+ /** Runtime kill switch; session-scoped, defaults to enabled. */
68
+ export function setLocalKScriptLiveRestPaceDisabled(disabled) {
69
+ restPaceDisabled = disabled === true;
70
+ }
71
+ export function isLocalKScriptLiveRestPaceDisabled() {
72
+ return restPaceDisabled;
73
+ }
74
+ /**
75
+ * Drain-admission decision. Pure read: it never stamps (the caller stamps at
76
+ * actual dispatch via noteLocalKScriptLiveRestPacedRun), so a deferred drain
77
+ * re-deciding at its re-armed timer cannot push the floor out.
78
+ */
79
+ export function decideLocalKScriptLiveRestPacedDrain(args) {
80
+ if (restPaceDisabled)
81
+ return { admit: true, reason: 'disabled' };
82
+ // Written as a negated >= so a NaN input fails open to the pre-floor
83
+ // behavior instead of deferring a gesture-time drain.
84
+ if (!(args.msSinceViewportMotion >= LOCAL_TECHNICAL_SCRIPT_LIVE_APPLY_VIEWPORT_IDLE_MS)) {
85
+ return { admit: true, reason: 'not-at-rest' };
86
+ }
87
+ const lastRunAt = lastRunAtByKey.get(paceKey(args.chartIndex, args.indicatorId));
88
+ if (lastRunAt === undefined)
89
+ return { admit: true, reason: 'floor-open' };
90
+ const msSinceLastRun = nowFn() - lastRunAt;
91
+ if (msSinceLastRun >= LOCAL_KSCRIPT_LIVE_SOURCE_REST_REFRESH_MIN_INTERVAL_MS) {
92
+ return { admit: true, reason: 'floor-open' };
93
+ }
94
+ return {
95
+ admit: false,
96
+ retryInMs: Math.min(LOCAL_KSCRIPT_LIVE_SOURCE_REST_REFRESH_MIN_INTERVAL_MS, Math.max(1, Math.ceil(LOCAL_KSCRIPT_LIVE_SOURCE_REST_REFRESH_MIN_INTERVAL_MS - msSinceLastRun))),
97
+ msSinceLastRun: Math.max(0, Math.round(msSinceLastRun)),
98
+ };
99
+ }
100
+ /**
101
+ * Stamp an actually-dispatched engine run for this overlay. Called at the
102
+ * coalescer's dispatch point for EVERY run (gesture-time included), and also
103
+ * while the kill switch is off so re-enabling resumes from the last real run.
104
+ */
105
+ export function noteLocalKScriptLiveRestPacedRun(chartIndex, indicatorId) {
106
+ const key = paceKey(chartIndex, indicatorId);
107
+ if (lastRunAtByKey.has(key)) {
108
+ lastRunAtByKey.delete(key);
109
+ }
110
+ else if (lastRunAtByKey.size >= LOCAL_KSCRIPT_LIVE_REST_PACE_MAX_KEYS) {
111
+ const oldest = lastRunAtByKey.keys().next().value;
112
+ if (oldest !== undefined)
113
+ lastRunAtByKey.delete(oldest);
114
+ }
115
+ lastRunAtByKey.set(key, nowFn());
116
+ }
117
+ export function clearAllLocalKScriptLiveRestPaceForTests() {
118
+ lastRunAtByKey.clear();
119
+ restPaceDisabled = false;
120
+ }
121
+ export function __getLocalKScriptLiveRestPaceStampCountForTests() {
122
+ return lastRunAtByKey.size;
123
+ }
124
+ if (typeof window !== 'undefined') {
125
+ const win = window;
126
+ win.__disableKiyoKScriptLiveRestPace = () => {
127
+ setLocalKScriptLiveRestPaceDisabled(true);
128
+ return 'Kiyo kScript live-source rest-pacing floor DISABLED (drains dispatch per schedule)';
129
+ };
130
+ win.__enableKiyoKScriptLiveRestPace = () => {
131
+ setLocalKScriptLiveRestPaceDisabled(false);
132
+ return `Kiyo kScript live-source rest-pacing floor ENABLED (${LOCAL_KSCRIPT_LIVE_SOURCE_REST_REFRESH_MIN_INTERVAL_MS}ms at rest)`;
133
+ };
134
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * kScript live-source identity resolution: ONE authority for turning a source
3
+ * payload's symbol/exchange into the concrete identity it operates as.
4
+ *
5
+ * A v2 script-engine source payload may carry the literal placeholder strings
6
+ * `currentSymbol` / `currentExchange` instead of a concrete identity: the
7
+ * engine stores string-form declarations verbatim (`symbol="currentSymbol"`,
8
+ * the common form in v2-era community scripts and older saved CVD scripts),
9
+ * and only identifier-form declarations resolve at declaration time. Every
10
+ * consumer of these payloads must therefore resolve the placeholders against
11
+ * the chart identity before using them:
12
+ *
13
+ * - the engine dataFetch bridge (store/chart.ts) resolves them before fetching,
14
+ * - the live-feed subscription map (indicators/controls/technical-script)
15
+ * resolves them before subscribing, via resolveKScriptSourceIdentityValue,
16
+ * - the LIVE MESSAGE MATCH (services/live-feed.service.ts) resolves them here,
17
+ * via findAllMatchingKScriptLiveSourceSnapshots.
18
+ *
19
+ * The subscription and the match MUST share this resolver: the subscription
20
+ * decides which identity's messages arrive, the match decides whether they are
21
+ * accepted. When the two normalize differently (the 2026-07-26 field defect:
22
+ * the match compared the RAW payload strings), every message the subscription
23
+ * itself requested is rejected as `missing-source` forever, the indicator only
24
+ * advances on the ~30s source poll, and nothing can heal the loop because the
25
+ * declared-source gate forecloses the deeper lookups.
26
+ */
27
+ export declare const KSCRIPT_CURRENT_SYMBOL_SENTINEL = "currentSymbol";
28
+ export declare const KSCRIPT_CURRENT_EXCHANGE_SENTINEL = "currentExchange";
29
+ /**
30
+ * Resolve one payload identity value. Placeholder strings resolve to the chart
31
+ * fallback (either placeholder is accepted for either field, mirroring the
32
+ * historical subscription resolver); empty/non-string values resolve to
33
+ * undefined (identity not pinned by the payload).
34
+ */
35
+ export declare function resolveKScriptSourceIdentityValue(value: unknown, fallback: string | undefined): string | undefined;
36
+ export type KScriptLiveSourceIdentityContext = {
37
+ incomingExchange?: string;
38
+ incomingSymbol?: string;
39
+ chartMetadata?: {
40
+ exchange?: string;
41
+ symbol?: string;
42
+ };
43
+ /**
44
+ * The chart symbol, set by the router ONLY when the incoming frame is the
45
+ * chart's own resolved lead contract (NQZ6 for an NQ1! chart,
46
+ * symbolsMatchForLiveFeed). A source resolved to the continuous root accepts
47
+ * that frame too; a source pinned to the concrete contract keeps matching
48
+ * the frame's own symbol. Never a rewrite of the frame: pinned-contract
49
+ * sources, the coalesce key and the ring keep the wire identity.
50
+ */
51
+ leadAliasSymbol?: string;
52
+ };
53
+ /**
54
+ * Does a source payload's (resolved) identity accept a live message with the
55
+ * given series identity? Permissive on both sides: a payload that pins no
56
+ * symbol/exchange accepts any message (legacy behavior), and a missing
57
+ * incoming identity falls back to the chart identity.
58
+ */
59
+ export declare function matchKScriptLiveSourcePayloadIdentity(payload: unknown, context: KScriptLiveSourceIdentityContext): boolean;
60
+ export type KScriptLiveSourceSnapshotLike = {
61
+ sourceName?: string;
62
+ sourceType?: string;
63
+ payload?: unknown;
64
+ data?: unknown[][];
65
+ };
66
+ export type KScriptLiveSourceMatch<T extends KScriptLiveSourceSnapshotLike> = T & {
67
+ sourceNames?: string | string[];
68
+ data: unknown[][];
69
+ };
70
+ /**
71
+ * Select every cached/worker source snapshot a live message can feed. One live
72
+ * message can feed SEVERAL mounted variants of the same source type (e.g.
73
+ * buy_sell_volume in coin AND currency=USD): matching only the first starves
74
+ * the others until the next historical refetch, freezing their forming bar at
75
+ * the zero-fill. Identity comparison goes through the shared resolver above so
76
+ * placeholder-carrying payloads match the messages their own subscription
77
+ * requested.
78
+ */
79
+ export declare function findAllMatchingKScriptLiveSourceSnapshots<T extends KScriptLiveSourceSnapshotLike>(args: {
80
+ snapshots: T[] | undefined;
81
+ sourceType: string;
82
+ incomingExchange?: string;
83
+ incomingSymbol?: string;
84
+ chartMetadata?: {
85
+ exchange?: string;
86
+ symbol?: string;
87
+ };
88
+ leadAliasSymbol?: string;
89
+ includeData?: boolean;
90
+ }): KScriptLiveSourceMatch<T>[];
91
+ /**
92
+ * Whether the engine declares the source type at all (any identity). Splits
93
+ * the zero-match skip into its two honest reasons: `missing-source` (type not
94
+ * declared here, the routine cross-engine fan-out case) vs
95
+ * `source-identity-mismatch` (declared, but every variant rejected the
96
+ * message's series identity, the "lost" class a dump must surface).
97
+ */
98
+ export declare function hasKScriptLiveSourceSnapshotOfType(snapshots: KScriptLiveSourceSnapshotLike[] | undefined, sourceType: string): boolean;