@orangecharts/wrun-chart-host 0.4.0 → 0.6.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 (331) hide show
  1. package/README.md +17 -5
  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/feature-flags.constants.js +7 -2
  5. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
  6. package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
  7. package/dist/constants/opra-compliance.constants.d.ts +19 -0
  8. package/dist/constants/opra-compliance.constants.js +19 -0
  9. package/dist/constants/replay-ladder.leaf.d.ts +30 -0
  10. package/dist/constants/replay-ladder.leaf.js +99 -0
  11. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  12. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  13. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  14. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  15. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  16. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  17. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  18. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  19. package/dist/host-env.d.ts +301 -22
  20. package/dist/host-env.js +15 -0
  21. package/dist/host-ports.types.d.ts +853 -29
  22. package/dist/index.d.ts +140 -2
  23. package/dist/index.js +140 -2
  24. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  25. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  26. package/dist/interfaces/market-event.interface.d.ts +231 -0
  27. package/dist/interfaces/market-event.interface.js +15 -0
  28. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  29. package/dist/interfaces/opra-realtime.interface.js +34 -59
  30. package/dist/interfaces/replay.interface.d.ts +285 -0
  31. package/dist/interfaces/replay.interface.js +1 -0
  32. package/dist/interfaces/wrun-runtime.interface.d.ts +88 -13
  33. package/dist/interfaces/wrun-runtime.interface.js +17 -3
  34. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  35. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  36. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  37. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  38. package/dist/market-data/billing.interface.d.ts +219 -0
  39. package/dist/market-data/billing.interface.js +58 -0
  40. package/dist/market-data/venue-governed.util.d.ts +2 -0
  41. package/dist/market-data/venue-governed.util.js +10 -0
  42. package/dist/market-data/venue.d.ts +122 -0
  43. package/dist/market-data/venue.js +1 -0
  44. package/dist/market-data/venues/index.d.ts +97 -0
  45. package/dist/market-data/venues/index.js +33 -0
  46. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  47. package/dist/market-data/venues/opra.d.ts +70 -0
  48. package/dist/market-data/venues/opra.js +74 -0
  49. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  50. package/dist/replay/replayIndicatorRows.js +117 -0
  51. package/dist/replay/replayLadder.d.ts +85 -0
  52. package/dist/replay/replayLadder.js +388 -0
  53. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  54. package/dist/utility/auth/server-clock.util.js +238 -0
  55. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  56. package/dist/utility/chart/builtin-identity.util.js +51 -0
  57. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  58. package/dist/utility/chart/cache-alignment.util.js +926 -0
  59. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  60. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  61. package/dist/utility/chart/chart-mount-epoch.util.d.ts +17 -0
  62. package/dist/utility/chart/chart-mount-epoch.util.js +61 -0
  63. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  64. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  65. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  66. package/dist/utility/chart/color-customization.leaf.js +16 -0
  67. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  68. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  69. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  70. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  71. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  72. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  73. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  74. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  75. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  76. package/dist/utility/chart/index-host-tier.util.js +118 -0
  77. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  78. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  79. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  80. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  81. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  82. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  83. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  84. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  85. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  86. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  87. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  88. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  89. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  90. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  91. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  92. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  93. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  94. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  95. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  96. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  97. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  98. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  99. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  100. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  101. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  102. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  103. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  104. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  105. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  106. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  107. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  108. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  109. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  110. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  111. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  112. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  113. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  114. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  115. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  116. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  117. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  118. package/dist/utility/chart/live-cadence.util.js +37 -0
  119. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  120. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  121. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  122. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  123. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  124. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  125. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  126. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  127. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  128. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  129. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  130. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  131. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  132. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  133. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  134. package/dist/utility/chart/mixed-mode.util.js +139 -0
  135. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  136. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  137. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  138. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  139. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  140. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  141. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  142. package/dist/utility/chart/price-precision.util.js +70 -0
  143. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  144. package/dist/utility/chart/profile-block-size.util.js +141 -0
  145. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  146. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  147. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  148. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  149. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  150. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  151. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  152. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  153. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  154. package/dist/utility/chart/titan-constants.pin.js +18 -5
  155. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  156. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  157. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  158. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  159. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  160. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  161. package/dist/utility/common/data-processing.util.d.ts +138 -0
  162. package/dist/utility/common/data-processing.util.js +346 -0
  163. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  164. package/dist/utility/common/visible-timeout.util.js +23 -8
  165. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  166. package/dist/utility/exchange-format.leaf.js +47 -0
  167. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  168. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  169. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  170. package/dist/utility/market-events/market-events.util.js +392 -0
  171. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  172. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  173. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  174. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  175. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  176. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  177. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  178. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  179. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  180. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  181. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  182. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  183. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  184. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  185. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  186. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
  187. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
  188. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  189. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  190. package/dist/utility/wrun/wrun-bar-count.util.d.ts +94 -0
  191. package/dist/utility/wrun/wrun-bar-count.util.js +274 -0
  192. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  193. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  194. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  195. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  196. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  197. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  198. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  199. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  200. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  201. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  202. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  203. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  204. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  205. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  206. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  207. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  208. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  209. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  210. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  211. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  212. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  213. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  214. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  215. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  216. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  217. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  218. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  219. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  220. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  221. package/dist/utility/wrun/wrun-host.service.d.ts +330 -0
  222. package/dist/utility/wrun/wrun-host.service.js +855 -0
  223. package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
  224. package/dist/utility/wrun/wrun-hover.util.js +25 -4
  225. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  226. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  227. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  228. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  229. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  230. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  231. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  232. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  233. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  234. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  235. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  236. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  237. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  238. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  239. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  240. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  241. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  242. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  243. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  244. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  245. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  246. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  247. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  248. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  249. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  250. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  251. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  252. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  253. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  254. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  255. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  256. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  257. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  258. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  259. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  260. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  261. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  262. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  263. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  264. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  265. package/dist/utility/wrun/wrun-pack.util.d.ts +2 -1
  266. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
  267. package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
  268. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  269. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  270. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  271. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  272. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  273. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  274. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  275. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  276. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  277. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  278. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  279. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  280. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  281. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  282. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  283. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  284. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  285. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  286. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  287. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  288. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  289. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  290. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  291. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  292. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  293. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  294. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  295. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  296. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  297. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  298. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  299. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  300. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  301. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  302. package/dist/utility/wrun/wrun-sha256.leaf.d.ts +13 -0
  303. package/dist/utility/wrun/wrun-sha256.leaf.js +84 -0
  304. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  305. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  306. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  307. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  308. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  309. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  310. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  311. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  312. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  313. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  314. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  315. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  316. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  317. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  318. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  319. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  320. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  321. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  322. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  323. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  324. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  325. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  326. package/dist/utils/replay/replay-buffer-math.js +684 -0
  327. package/dist/workers/wrun/wrun-abi-host.d.ts +203 -0
  328. package/dist/workers/wrun/wrun-abi-host.js +1220 -0
  329. package/dist/workers/wrun/wrun-engine-handler.d.ts +20 -0
  330. package/dist/workers/wrun/wrun-engine-handler.js +380 -0
  331. package/package.json +3 -3
@@ -0,0 +1,68 @@
1
+ /**
2
+ * A secondary source's retry and budget numbers (a leaf of utility/chart/kscript-source-degrade.util.ts;
3
+ * P2/inventory.md section 1.1): the constants recovery reads and the budget the executor reads. The degrade registry and
4
+ * its mutators stay in the old module (the chart store and the engine manager share it) behind the chart-host members
5
+ * `chart.markSourcesTerminal`, `chart.markSourceDegraded` and the rest; this leaf holds no state, so it moves into the
6
+ * chart-host package with the phase 2 closure. The old module re-exports it.
7
+ */
8
+ /**
9
+ * SRCDEGRADE: per-source acquisition budget for browser-run kScript overlays.
10
+ *
11
+ * A secondary source (order flow, open interest, funding, orderbook, any
12
+ * non-ohlcv leg that does not own the timeline) that is slow or unavailable
13
+ * must never hold the whole run: after KSCRIPT_SECONDARY_SOURCE_BUDGET_MS the
14
+ * proxy answers the worker with ok:false for that request, the engine stores
15
+ * an EMPTY series for the source (engine 3.0.84 contract, pinned by
16
+ * tests/instances/script-engine-source-degrade.engine.spec.ts) and the run
17
+ * proceeds candles-only. Recovery rides the engine's own refresh(from, to,
18
+ * true), never a one-source injection.
19
+ *
20
+ * This module owns the pure rules (predicate, budget, ladder) and the
21
+ * per-overlay registry the legend chip is DERIVED from at the diagnostics
22
+ * choke point (chart.ts setIndicatorDiagnostics), so no diagnostics writer
23
+ * can drop the chip and no writer ever sets it directly.
24
+ */
25
+ /**
26
+ * Base budget (the floor). Provisional instrumented SLO (2026-09-03): the
27
+ * healthy field dump's 2.4s volume_profile wall was a replay-cache hit, so
28
+ * there was no wire p95; the first field read (dump 2026-09-03T07:30Z, two
29
+ * scripts, ~4-day 1m windows: volume_profile at 5 ticks/bar, liquidations,
30
+ * buy_sell_volume) showed 10 of 10 degrades at exactly this floor, so the
31
+ * budget now SCALES with the requested window (resolveSecondarySourceBudgetMs)
32
+ * and is anchored at wire dispatch (fetchOptions.onDispatched) instead of at
33
+ * request arrival. Against the failing dump the floor still lands ~7s before
34
+ * the attention probe convicts the socket and ~12.6s before it re-opens.
35
+ */
36
+ export const KSCRIPT_SECONDARY_SOURCE_BUDGET_MS = 10_000;
37
+ /** Extra budget per 1000 expected rows of the requested window (window / source interval). */
38
+ export const KSCRIPT_SECONDARY_SOURCE_BUDGET_PER_1K_ROWS_MS = 2_500;
39
+ /** Ceiling of the window-scaled budget: a dead socket after dispatch still degrades within this. */
40
+ export const KSCRIPT_SECONDARY_SOURCE_BUDGET_MAX_MS = 40_000;
41
+ /**
42
+ * The window-scaled budget: floor + PER_1K_ROWS per thousand expected rows
43
+ * of the requested window, capped at BUDGET_MAX. Anything unresolvable
44
+ * (missing or non-finite bounds, an empty or inverted window, no interval)
45
+ * yields the floor. A 250-bar window adds ~0.6s; a 4-day 1m window (5760
46
+ * rows) lands at ~24s; the cap holds everything past 12k rows.
47
+ */
48
+ export function resolveSecondarySourceBudgetMs(window) {
49
+ const { fromMs, toMs, intervalMs } = window;
50
+ const finite = (value) => typeof value === 'number' && Number.isFinite(value);
51
+ if (!finite(fromMs) || !finite(toMs) || !finite(intervalMs) || intervalMs <= 0 || toMs <= fromMs) {
52
+ return KSCRIPT_SECONDARY_SOURCE_BUDGET_MS;
53
+ }
54
+ const rows = (toMs - fromMs) / intervalMs;
55
+ const scaled = KSCRIPT_SECONDARY_SOURCE_BUDGET_MS + (rows / 1000) * KSCRIPT_SECONDARY_SOURCE_BUDGET_PER_1K_ROWS_MS;
56
+ return Math.round(Math.min(KSCRIPT_SECONDARY_SOURCE_BUDGET_MAX_MS, Math.max(KSCRIPT_SECONDARY_SOURCE_BUDGET_MS, scaled)));
57
+ }
58
+ /**
59
+ * Gaps between recovery attempts (each is one forced refetch of the overlay
60
+ * with retryAttempt stamped on the degraded names only): the first fires 15s
61
+ * after the degrade (~2.4s after the socket re-open in the failing dump), the
62
+ * second 20s after the first settles (the last attempt inside a minute). A
63
+ * stale-arrival recovery (the original request landing late with rows) fires
64
+ * after KSCRIPT_SECONDARY_SOURCE_STALE_ARRIVAL_RECOVERY_DELAY_MS instead.
65
+ */
66
+ export const KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS = [15_000, 20_000];
67
+ /** Total recovery attempts per degrade episode (ladder + stale-arrival), reset by a user rebuild. */
68
+ export const KSCRIPT_SECONDARY_SOURCE_MAX_RECOVERY_ATTEMPTS = 3;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Retention HINTS for locally-executed kScript per-source history rows.
3
+ *
4
+ * Division of labor (2026-07 adversarial review): the ENGINE owns the slide.
5
+ * engine.updateOHLCVData(sourceNames, rows, replaceFully, retention) stores the update FIRST,
6
+ * then drops timeline buckets strictly older than retention.floorTs, only once the timeline
7
+ * exceeds the row gate (engine-side hysteresis over maxTimelineRows with an absolute row floor),
8
+ * never cutting at or past floorTs, index mode and own-cadence HTF/LTF sources exempt, frontier
9
+ * heal recomputing outputs over the retained window. The FE must keep dispatching WHOLE merged
10
+ * arrays: the engine re-densifies short payloads to timeline length with NaN rows, so payload
11
+ * trimming stays destructive without the hint. The FE only (a) resolves the hint from the mounted
12
+ * chart and (b) bounds its OWN proxy cache copy at the same floor (trimSourceRowsBeforeTs).
13
+ *
14
+ * Floors are TIMESTAMP-based, never row counts: row-count floors break when a source's density
15
+ * differs from the chart cadence (a per-second book source holds 60x the rows of a 1m series).
16
+ *
17
+ * The hint fails OPEN: never hint with less information than the floor needs. An unreadable or
18
+ * empty main span, an unknown interval, or a main span that reads mid-rebuild-short against the
19
+ * mounted overlay all resolve to no hint, and every retention-less dispatch is byte-identical to
20
+ * the legacy engine path.
21
+ *
22
+ * This module is a pure leaf shared by the main thread and the engine worker: it must keep
23
+ * zero runtime imports (nothing that transitively touches window, Vue, the router, or Pinia).
24
+ */
25
+ export declare const KSCRIPT_SOURCE_RETENTION_MIN_BARS = 600;
26
+ export declare const KSCRIPT_SOURCE_RETENTION_LOOKBACK_MULT = 2;
27
+ export declare const KSCRIPT_SOURCE_RETENTION_FLOOR_MARGIN_BARS = 32;
28
+ export declare const KSCRIPT_SOURCE_RETENTION_SHORT_MAIN_GUARD_ROWS = 200;
29
+ /** Structural twin of the engine's SourceWindowRetention (pure leaf: no engine import). */
30
+ export interface KScriptSourceWindowRetention {
31
+ floorTs: number;
32
+ maxTimelineRows: number;
33
+ }
34
+ /**
35
+ * Reads the minimumBars lookback requirement from an indicator's lookbackInfo setting, which
36
+ * arrives either as an object or as a JSON-encoded string. Extracted verbatim from
37
+ * useDataPolling: invalid, missing, or non-finite values resolve to 0 (never null), and valid
38
+ * values are floored and clamped to >= 0.
39
+ */
40
+ export declare function parseLookbackMinimumBars(lookbackInfo: unknown): number;
41
+ /**
42
+ * Reads the anchorMinSpanMs term of a lookbackInfo (object or JSON-encoded string): the deepest
43
+ * `vwap(anchor=...)` calendar/number span, in ms, the engine's declaration pass found in the
44
+ * script. Missing, non-numeric, non-finite, or negative values resolve to 0 (no anchor).
45
+ */
46
+ export declare function parseLookbackAnchorMinSpanMs(lookbackInfo: unknown): number;
47
+ /**
48
+ * Ceiling on the bar count a vwap anchor span folds into. Mirrors the kscript backend's
49
+ * plus-tier lookback cap (its lookback-depth module folds the same span with the same shape): a
50
+ * yearly anchor on a 1m chart spans 527,040 bars and no host fetches that, while every consumer
51
+ * of the declared lookback here is bounded on its own (warmup pages by rounds, retention by its
52
+ * row gate), so the cap only keeps the number finite and comparable across the two hosts.
53
+ */
54
+ export declare const KSCRIPT_LOOKBACK_ANCHOR_CAP_BARS = 5000;
55
+ /**
56
+ * Folds a vwap calendar/number anchor span into a bar-count lookback at one chart interval, the
57
+ * conversion the engine leaves to its host. `dryRun().lookbackInfo.minimumBars` is
58
+ * interval-agnostic (5 for a script with no windowed builtin, whatever its anchors) and
59
+ * `anchorMinSpanMs` is the deepest `vwap(anchor=...)` span the script accumulates over chart
60
+ * bars: day 1d, week 7d, month 28d, quarter 92d, year 366d, a number anchor its own ms. The
61
+ * result is max(base, min(ceil(span / interval), cap)), so a script without anchors (span 0) or
62
+ * a caller without a usable interval reads exactly its base, and a base above the cap is never
63
+ * cut (only the anchor term is capped).
64
+ */
65
+ export declare function foldAnchorSpanIntoLookbackBars(baseBars: number, anchorMinSpanMs: number, intervalMs: number, cap?: number): number;
66
+ /**
67
+ * Declared lookback of a saved contract in bars of the given chart interval: its minimumBars
68
+ * folded with its vwap anchor span (foldAnchorSpanIntoLookbackBars). Without a usable interval
69
+ * or without an anchor the result is exactly parseLookbackMinimumBars.
70
+ */
71
+ export declare function resolveLookbackBarsForInterval(lookbackInfo: unknown, intervalMs: number | null | undefined): number;
72
+ /**
73
+ * Resolves the maxTimelineRows term of a retention hint: the largest of the script's lookback
74
+ * requirement (times a safety multiplier), the rows the main chart has loaded, and the rows the
75
+ * mounted overlay renders, with an absolute floor. Non-finite or non-positive terms are ignored.
76
+ * The result is always a positive integer >= KSCRIPT_SOURCE_RETENTION_MIN_BARS. This is only the
77
+ * engine's slide TRIGGER and minimum retained count; floorTs stays the authority on what
78
+ * survives.
79
+ */
80
+ export declare function resolveKScriptSourceRetentionBars(input: {
81
+ lookbackBars: number | null;
82
+ mainLoadedRows?: number;
83
+ overlayMountedRows?: number;
84
+ }): number;
85
+ /** Structural subset of a TitanCharts IMetaData entry; entries may be absent or malformed mid-teardown. */
86
+ type LiveKScriptChartMetadataEntry = {
87
+ id?: unknown;
88
+ rawData?: unknown;
89
+ settings?: unknown;
90
+ };
91
+ export interface LiveKScriptSourceRetentionResolution {
92
+ lookbackBars: number;
93
+ mainLoadedRows?: number;
94
+ overlayMountedRows?: number;
95
+ /** Oldest bucket timestamp (ms) the engine must keep. Undefined = fail open, no hint. */
96
+ floorTs?: number;
97
+ /** Slide trigger / minimum retained row count riding with floorTs. Undefined exactly when floorTs is. */
98
+ maxTimelineRows?: number;
99
+ }
100
+ /**
101
+ * Resolves the retention hint for one locally-executed kScript live dispatch from the mounted
102
+ * chart's metadata array: entry 0 is the main series, the overlay is the entry whose id equals
103
+ * the script's indicator id, and that overlay's settings.lookbackInfo carries the script's
104
+ * declared lookback: its minimumBars folded with its vwap anchor span at the chart interval
105
+ * (resolveLookbackBarsForInterval), so an anchored VWAP keeps its anchor's bars rather than the
106
+ * engine's 5-bar default. Null-safe throughout: live dispatch races
107
+ * chart teardown, and a missing chart, overlay, or rawData must never throw. Lives here (not in
108
+ * live-feed.service) so the resolution is unit-testable: importing live-feed.service in a node
109
+ * spec drags in window-bound modules.
110
+ *
111
+ * Fail-open conditions (floorTs and maxTimelineRows both undefined):
112
+ * - chart metadata or main rawData unreadable, or the main first-row timestamp is not finite;
113
+ * - mainLoadedRows < 1 (historical resync empties main rawData mid-rebuild);
114
+ * - intervalMs not a finite positive number;
115
+ * - short-but-nonempty main (review F5): mainLoadedRows <
116
+ * min(overlayMountedRows, KSCRIPT_SOURCE_RETENTION_SHORT_MAIN_GUARD_ROWS).
117
+ *
118
+ * Otherwise floorTs anchors at the OLDEST loaded span (min of main and overlay first timestamps)
119
+ * minus the lookback and a fixed margin, both in whole bars of the chart interval, and
120
+ * maxTimelineRows is the row-count floor set. Diagnostic fields keep their shape either way
121
+ * (0/undefined for unavailable terms) for the live-feed ring event.
122
+ */
123
+ export declare function resolveLiveKScriptSourceRetention(metadata: readonly LiveKScriptChartMetadataEntry[] | null | undefined, indicatorId: string, intervalMs: number | null | undefined): LiveKScriptSourceRetentionResolution;
124
+ /**
125
+ * Bounds the proxy's OWN cache copy at the retention floor: drops rows whose leading (bucket)
126
+ * timestamp is STRICTLY older than floorTs. A row at exactly floorTs is retained, matching the
127
+ * engine's never-cut-at-or-past-the-floor rule. Precondition: rows are timestamp-ascending with
128
+ * finite bucket timestamps (the source-row merge maintains this); on malformed timestamps the
129
+ * binary search stays cut-point-approximate but never throws. The SAME array reference comes
130
+ * back when nothing drops (steady-state appends stay allocation-free) or when floorTs is not a
131
+ * finite number (exempt caller). Never mutates the input array.
132
+ */
133
+ export declare function trimSourceRowsBeforeTs<T>(rows: readonly T[] | T[] | null | undefined, floorTs: number | null | undefined): T[];
134
+ export {};
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Retention HINTS for locally-executed kScript per-source history rows.
3
+ *
4
+ * Division of labor (2026-07 adversarial review): the ENGINE owns the slide.
5
+ * engine.updateOHLCVData(sourceNames, rows, replaceFully, retention) stores the update FIRST,
6
+ * then drops timeline buckets strictly older than retention.floorTs, only once the timeline
7
+ * exceeds the row gate (engine-side hysteresis over maxTimelineRows with an absolute row floor),
8
+ * never cutting at or past floorTs, index mode and own-cadence HTF/LTF sources exempt, frontier
9
+ * heal recomputing outputs over the retained window. The FE must keep dispatching WHOLE merged
10
+ * arrays: the engine re-densifies short payloads to timeline length with NaN rows, so payload
11
+ * trimming stays destructive without the hint. The FE only (a) resolves the hint from the mounted
12
+ * chart and (b) bounds its OWN proxy cache copy at the same floor (trimSourceRowsBeforeTs).
13
+ *
14
+ * Floors are TIMESTAMP-based, never row counts: row-count floors break when a source's density
15
+ * differs from the chart cadence (a per-second book source holds 60x the rows of a 1m series).
16
+ *
17
+ * The hint fails OPEN: never hint with less information than the floor needs. An unreadable or
18
+ * empty main span, an unknown interval, or a main span that reads mid-rebuild-short against the
19
+ * mounted overlay all resolve to no hint, and every retention-less dispatch is byte-identical to
20
+ * the legacy engine path.
21
+ *
22
+ * This module is a pure leaf shared by the main thread and the engine worker: it must keep
23
+ * zero runtime imports (nothing that transitively touches window, Vue, the router, or Pinia).
24
+ */
25
+ export const KSCRIPT_SOURCE_RETENTION_MIN_BARS = 600;
26
+ export const KSCRIPT_SOURCE_RETENTION_LOOKBACK_MULT = 2;
27
+ // Extra whole bars kept below the lookback floor so indicators warmed exactly at lookback depth
28
+ // never compute against a boundary bucket the slide just removed.
29
+ export const KSCRIPT_SOURCE_RETENTION_FLOOR_MARGIN_BARS = 32;
30
+ // Short-but-nonempty main guard (review F5): during a historical rebuild the main series remounts
31
+ // with a handful of rows while the overlay still renders thousands; a floor anchored there would
32
+ // slide away loaded overlay history. Below this row count the main span must at least match the
33
+ // overlay before it may anchor a floor.
34
+ export const KSCRIPT_SOURCE_RETENTION_SHORT_MAIN_GUARD_ROWS = 200;
35
+ /**
36
+ * Reads the minimumBars lookback requirement from an indicator's lookbackInfo setting, which
37
+ * arrives either as an object or as a JSON-encoded string. Extracted verbatim from
38
+ * useDataPolling: invalid, missing, or non-finite values resolve to 0 (never null), and valid
39
+ * values are floored and clamped to >= 0.
40
+ */
41
+ export function parseLookbackMinimumBars(lookbackInfo) {
42
+ if (lookbackInfo && typeof lookbackInfo === 'object' && !Array.isArray(lookbackInfo)) {
43
+ const minimumBars = lookbackInfo.minimumBars;
44
+ return typeof minimumBars === 'number' && Number.isFinite(minimumBars) ? Math.max(0, Math.floor(minimumBars)) : 0;
45
+ }
46
+ if (typeof lookbackInfo !== 'string' || !lookbackInfo.trim())
47
+ return 0;
48
+ try {
49
+ return parseLookbackMinimumBars(JSON.parse(lookbackInfo));
50
+ }
51
+ catch {
52
+ return 0;
53
+ }
54
+ }
55
+ /**
56
+ * Reads the anchorMinSpanMs term of a lookbackInfo (object or JSON-encoded string): the deepest
57
+ * `vwap(anchor=...)` calendar/number span, in ms, the engine's declaration pass found in the
58
+ * script. Missing, non-numeric, non-finite, or negative values resolve to 0 (no anchor).
59
+ */
60
+ export function parseLookbackAnchorMinSpanMs(lookbackInfo) {
61
+ if (lookbackInfo && typeof lookbackInfo === 'object' && !Array.isArray(lookbackInfo)) {
62
+ const anchorMinSpanMs = lookbackInfo.anchorMinSpanMs;
63
+ return typeof anchorMinSpanMs === 'number' && Number.isFinite(anchorMinSpanMs) && anchorMinSpanMs > 0
64
+ ? anchorMinSpanMs
65
+ : 0;
66
+ }
67
+ if (typeof lookbackInfo !== 'string' || !lookbackInfo.trim())
68
+ return 0;
69
+ try {
70
+ return parseLookbackAnchorMinSpanMs(JSON.parse(lookbackInfo));
71
+ }
72
+ catch {
73
+ return 0;
74
+ }
75
+ }
76
+ /**
77
+ * Ceiling on the bar count a vwap anchor span folds into. Mirrors the kscript backend's
78
+ * plus-tier lookback cap (its lookback-depth module folds the same span with the same shape): a
79
+ * yearly anchor on a 1m chart spans 527,040 bars and no host fetches that, while every consumer
80
+ * of the declared lookback here is bounded on its own (warmup pages by rounds, retention by its
81
+ * row gate), so the cap only keeps the number finite and comparable across the two hosts.
82
+ */
83
+ export const KSCRIPT_LOOKBACK_ANCHOR_CAP_BARS = 5000;
84
+ /**
85
+ * Folds a vwap calendar/number anchor span into a bar-count lookback at one chart interval, the
86
+ * conversion the engine leaves to its host. `dryRun().lookbackInfo.minimumBars` is
87
+ * interval-agnostic (5 for a script with no windowed builtin, whatever its anchors) and
88
+ * `anchorMinSpanMs` is the deepest `vwap(anchor=...)` span the script accumulates over chart
89
+ * bars: day 1d, week 7d, month 28d, quarter 92d, year 366d, a number anchor its own ms. The
90
+ * result is max(base, min(ceil(span / interval), cap)), so a script without anchors (span 0) or
91
+ * a caller without a usable interval reads exactly its base, and a base above the cap is never
92
+ * cut (only the anchor term is capped).
93
+ */
94
+ export function foldAnchorSpanIntoLookbackBars(baseBars, anchorMinSpanMs, intervalMs, cap = KSCRIPT_LOOKBACK_ANCHOR_CAP_BARS) {
95
+ const base = Number.isFinite(baseBars) ? Math.max(0, Math.floor(baseBars)) : 0;
96
+ const spanUsable = Number.isFinite(anchorMinSpanMs) && anchorMinSpanMs > 0;
97
+ const intervalUsable = Number.isFinite(intervalMs) && intervalMs > 0;
98
+ if (!spanUsable || !intervalUsable)
99
+ return base;
100
+ const anchorBars = Math.min(Math.ceil(anchorMinSpanMs / intervalMs), Math.max(0, Math.floor(cap)));
101
+ return Math.max(base, anchorBars);
102
+ }
103
+ /**
104
+ * Declared lookback of a saved contract in bars of the given chart interval: its minimumBars
105
+ * folded with its vwap anchor span (foldAnchorSpanIntoLookbackBars). Without a usable interval
106
+ * or without an anchor the result is exactly parseLookbackMinimumBars.
107
+ */
108
+ export function resolveLookbackBarsForInterval(lookbackInfo, intervalMs) {
109
+ const minimumBars = parseLookbackMinimumBars(lookbackInfo);
110
+ const anchorMinSpanMs = parseLookbackAnchorMinSpanMs(lookbackInfo);
111
+ if (anchorMinSpanMs <= 0 || typeof intervalMs !== 'number')
112
+ return minimumBars;
113
+ return foldAnchorSpanIntoLookbackBars(minimumBars, anchorMinSpanMs, intervalMs);
114
+ }
115
+ function wholePositiveRows(value) {
116
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.floor(value) : 0;
117
+ }
118
+ /**
119
+ * Resolves the maxTimelineRows term of a retention hint: the largest of the script's lookback
120
+ * requirement (times a safety multiplier), the rows the main chart has loaded, and the rows the
121
+ * mounted overlay renders, with an absolute floor. Non-finite or non-positive terms are ignored.
122
+ * The result is always a positive integer >= KSCRIPT_SOURCE_RETENTION_MIN_BARS. This is only the
123
+ * engine's slide TRIGGER and minimum retained count; floorTs stays the authority on what
124
+ * survives.
125
+ */
126
+ export function resolveKScriptSourceRetentionBars(input) {
127
+ const lookbackTerm = typeof input.lookbackBars === 'number' && Number.isFinite(input.lookbackBars) && input.lookbackBars > 0
128
+ ? input.lookbackBars * KSCRIPT_SOURCE_RETENTION_LOOKBACK_MULT
129
+ : 0;
130
+ return Math.ceil(Math.max(KSCRIPT_SOURCE_RETENTION_MIN_BARS, lookbackTerm, wholePositiveRows(input.mainLoadedRows), wholePositiveRows(input.overlayMountedRows)));
131
+ }
132
+ function mountedRowsOf(rawData) {
133
+ return Array.isArray(rawData) ? rawData.length : undefined;
134
+ }
135
+ function firstRowTs(rawData) {
136
+ if (!Array.isArray(rawData) || rawData.length === 0)
137
+ return undefined;
138
+ const ts = Number(rawData[0]?.[0]);
139
+ return Number.isFinite(ts) ? ts : undefined;
140
+ }
141
+ /**
142
+ * Resolves the retention hint for one locally-executed kScript live dispatch from the mounted
143
+ * chart's metadata array: entry 0 is the main series, the overlay is the entry whose id equals
144
+ * the script's indicator id, and that overlay's settings.lookbackInfo carries the script's
145
+ * declared lookback: its minimumBars folded with its vwap anchor span at the chart interval
146
+ * (resolveLookbackBarsForInterval), so an anchored VWAP keeps its anchor's bars rather than the
147
+ * engine's 5-bar default. Null-safe throughout: live dispatch races
148
+ * chart teardown, and a missing chart, overlay, or rawData must never throw. Lives here (not in
149
+ * live-feed.service) so the resolution is unit-testable: importing live-feed.service in a node
150
+ * spec drags in window-bound modules.
151
+ *
152
+ * Fail-open conditions (floorTs and maxTimelineRows both undefined):
153
+ * - chart metadata or main rawData unreadable, or the main first-row timestamp is not finite;
154
+ * - mainLoadedRows < 1 (historical resync empties main rawData mid-rebuild);
155
+ * - intervalMs not a finite positive number;
156
+ * - short-but-nonempty main (review F5): mainLoadedRows <
157
+ * min(overlayMountedRows, KSCRIPT_SOURCE_RETENTION_SHORT_MAIN_GUARD_ROWS).
158
+ *
159
+ * Otherwise floorTs anchors at the OLDEST loaded span (min of main and overlay first timestamps)
160
+ * minus the lookback and a fixed margin, both in whole bars of the chart interval, and
161
+ * maxTimelineRows is the row-count floor set. Diagnostic fields keep their shape either way
162
+ * (0/undefined for unavailable terms) for the live-feed ring event.
163
+ */
164
+ export function resolveLiveKScriptSourceRetention(metadata, indicatorId, intervalMs) {
165
+ const entries = Array.isArray(metadata) ? metadata : [];
166
+ const overlay = entries.find((entry) => !!entry && entry.id === indicatorId);
167
+ const overlaySettings = overlay?.settings;
168
+ const lookbackBars = resolveLookbackBarsForInterval(overlaySettings?.lookbackInfo, intervalMs);
169
+ const mainRawData = entries[0]?.rawData;
170
+ const mainLoadedRows = mountedRowsOf(mainRawData);
171
+ const overlayMountedRows = mountedRowsOf(overlay?.rawData);
172
+ const failOpen = { lookbackBars, mainLoadedRows, overlayMountedRows };
173
+ if (mainLoadedRows === undefined || mainLoadedRows < 1)
174
+ return failOpen;
175
+ if (typeof intervalMs !== 'number' || !Number.isFinite(intervalMs) || intervalMs <= 0)
176
+ return failOpen;
177
+ if (overlayMountedRows !== undefined &&
178
+ mainLoadedRows < Math.min(overlayMountedRows, KSCRIPT_SOURCE_RETENTION_SHORT_MAIN_GUARD_ROWS)) {
179
+ return failOpen;
180
+ }
181
+ const mainFirstTs = firstRowTs(mainRawData);
182
+ if (mainFirstTs === undefined)
183
+ return failOpen;
184
+ const overlayFirstTs = firstRowTs(overlay?.rawData);
185
+ const anchorTs = overlayFirstTs !== undefined ? Math.min(mainFirstTs, overlayFirstTs) : mainFirstTs;
186
+ const floorTs = anchorTs - (lookbackBars + KSCRIPT_SOURCE_RETENTION_FLOOR_MARGIN_BARS) * intervalMs;
187
+ const maxTimelineRows = resolveKScriptSourceRetentionBars({ lookbackBars, mainLoadedRows, overlayMountedRows });
188
+ return { lookbackBars, mainLoadedRows, overlayMountedRows, floorTs, maxTimelineRows };
189
+ }
190
+ /**
191
+ * Bounds the proxy's OWN cache copy at the retention floor: drops rows whose leading (bucket)
192
+ * timestamp is STRICTLY older than floorTs. A row at exactly floorTs is retained, matching the
193
+ * engine's never-cut-at-or-past-the-floor rule. Precondition: rows are timestamp-ascending with
194
+ * finite bucket timestamps (the source-row merge maintains this); on malformed timestamps the
195
+ * binary search stays cut-point-approximate but never throws. The SAME array reference comes
196
+ * back when nothing drops (steady-state appends stay allocation-free) or when floorTs is not a
197
+ * finite number (exempt caller). Never mutates the input array.
198
+ */
199
+ export function trimSourceRowsBeforeTs(rows, floorTs) {
200
+ if (!rows)
201
+ return [];
202
+ if (rows.length === 0 || typeof floorTs !== 'number' || !Number.isFinite(floorTs))
203
+ return rows;
204
+ let low = 0;
205
+ let high = rows.length;
206
+ // lower_bound: first index whose timestamp is >= floorTs (NaN reads as >= floorTs).
207
+ while (low < high) {
208
+ const mid = (low + high) >>> 1;
209
+ const ts = Number(rows[mid]?.[0]);
210
+ if (ts < floorTs)
211
+ low = mid + 1;
212
+ else
213
+ high = mid;
214
+ }
215
+ if (low <= 0)
216
+ return rows;
217
+ return rows.slice(low);
218
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The identity a kScript stand-in is keyed by (a leaf of utility/chart/kscript-standin.util.ts; P2/inventory.md section
3
+ * 1.1): the code a row's stand-in is the output of (a shipped built-in, a proven twin, or a pinned registry package),
4
+ * the tag a package's stand-in is written under, and the row, side and outcome types the wrun executor's stand-in write
5
+ * names. Pure: it reads the built-in identity and the wrun overlay identity, no state, so it moves into the chart-host
6
+ * package with the phase 2 closure. The output cache stays web (the members `chart.writeStandIn` and
7
+ * `chart.retractStandIn`); the stand-in module imports and re-exports every name.
8
+ */
9
+ import { type BuiltinIdentity } from './builtin-identity.util.js';
10
+ /** The workspace side a row is saved under: the pane its stand-in paints on. */
11
+ export type KScriptStandInSide = 'onchart' | 'offchart';
12
+ /** A published registry package at a pinned version: the third kind of stand-in identity. */
13
+ export interface KScriptStandInPackageIdentity {
14
+ kind: 'package';
15
+ package: string;
16
+ version: string;
17
+ }
18
+ export type KScriptStandInIdentity = BuiltinIdentity | KScriptStandInPackageIdentity;
19
+ export type KScriptStandInIdentityKind = KScriptStandInIdentity['kind'];
20
+ export type KScriptStandInPackageRefusal = 'draft' | 'dev-local' | 'unpinned';
21
+ /** One workspace row as the stand-in judges it, with the pane side it is saved under. */
22
+ export interface KScriptStandInRow {
23
+ id?: unknown;
24
+ type?: unknown;
25
+ settings?: Record<string, unknown> | null;
26
+ isHidden?: unknown;
27
+ /** The workspace side the row is saved under (`onchart` or `offchart`): the pane it paints on. */
28
+ side?: unknown;
29
+ }
30
+ export type KScriptStandInWriteOutcome = 'written' | 'throttled' | 'no-row' | 'no-key' | 'no-candles' | 'no-rows' | 'not-live-edge' | 'not-template' | 'incomplete' | `ineligible:${string}`;
31
+ /**
32
+ * Why a row's wrun identity names no package a stand-in can key, or null (also for a row with no
33
+ * wrun identity at all): a draft is the author's session-only run, a dev-local run serves bytes no
34
+ * registry pins, and an unpinned ref (version '') follows whatever the registry calls latest. A
35
+ * registry package keys its stand-in whichever row source its record names (the sandbox or the
36
+ * cloud's socket, WRUN-PARITY-PLAN C7): the pass writes the same whole picture for either.
37
+ */
38
+ export declare function packageStandInRefusal(settings: unknown): KScriptStandInPackageRefusal | null;
39
+ /** A published registry package at a pinned version that no other lane owns, or undefined. */
40
+ export declare function packageIdentityOf(settings: unknown): KScriptStandInPackageIdentity | undefined;
41
+ /**
42
+ * The code a row's stand-in is the output of: a shipped built-in first (its template, or its
43
+ * proven twin: builtinIdentityOf), else a pinned registry package. A twin stands in as its built-in
44
+ * only when the built-in runs on the run interval (NATIVE_RUN_INTERVAL_SUBTYPES): the twin path
45
+ * keys and projects on that semantics, and kscriptShippedBuiltinRefusal refuses any other twin. A
46
+ * twin of any other built-in (Big Trades) is the pinned registry package it is, keyed and written
47
+ * like one (its tag, its declared compute params, the chart's interval, the account), and an
48
+ * unpinned, hosted, draft or dev-local one has none (its package refusal). Undefined for every
49
+ * other row.
50
+ */
51
+ export declare function standInIdentityOf(settings: unknown): KScriptStandInIdentity | undefined;
52
+ /**
53
+ * The `engineScript` a proven twin's or a pinned package's stand-in is written under: its package
54
+ * at the version it is pinned to (WRUN-PARITY-P1 C7). The wrun run passes it to writeKScriptStandIn
55
+ * and the key hashes it, so a pin move or a template fix never serves a stale picture.
56
+ */
57
+ export declare function wrunStandInTag(packageName: string, version: string): string;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The identity a kScript stand-in is keyed by (a leaf of utility/chart/kscript-standin.util.ts; P2/inventory.md section
3
+ * 1.1): the code a row's stand-in is the output of (a shipped built-in, a proven twin, or a pinned registry package),
4
+ * the tag a package's stand-in is written under, and the row, side and outcome types the wrun executor's stand-in write
5
+ * names. Pure: it reads the built-in identity and the wrun overlay identity, no state, so it moves into the chart-host
6
+ * package with the phase 2 closure. The output cache stays web (the members `chart.writeStandIn` and
7
+ * `chart.retractStandIn`); the stand-in module imports and re-exports every name.
8
+ */
9
+ import { builtinIdentityOf } from './builtin-identity.util.js';
10
+ import { NATIVE_RUN_INTERVAL_SUBTYPES } from './indicator-run-interval.util.js';
11
+ import { isWrunDraftOverlaySettings, wrunRegistryRefOf } from '../wrun/wrun-overlay-identity.util.js';
12
+ function isRecord(value) {
13
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
14
+ }
15
+ /**
16
+ * Why a row's wrun identity names no package a stand-in can key, or null (also for a row with no
17
+ * wrun identity at all): a draft is the author's session-only run, a dev-local run serves bytes no
18
+ * registry pins, and an unpinned ref (version '') follows whatever the registry calls latest. A
19
+ * registry package keys its stand-in whichever row source its record names (the sandbox or the
20
+ * cloud's socket, WRUN-PARITY-PLAN C7): the pass writes the same whole picture for either.
21
+ */
22
+ export function packageStandInRefusal(settings) {
23
+ if (isWrunDraftOverlaySettings(settings))
24
+ return 'draft';
25
+ if (isRecord(settings) && settings.wrunDevLocal === true)
26
+ return 'dev-local';
27
+ if (wrunRegistryRefOf(settings)?.version === '')
28
+ return 'unpinned';
29
+ return null;
30
+ }
31
+ /** A published registry package at a pinned version that no other lane owns, or undefined. */
32
+ export function packageIdentityOf(settings) {
33
+ const ref = wrunRegistryRefOf(settings);
34
+ if (!ref || packageStandInRefusal(settings) !== null)
35
+ return undefined;
36
+ return { kind: 'package', package: ref.package, version: ref.version };
37
+ }
38
+ /**
39
+ * The code a row's stand-in is the output of: a shipped built-in first (its template, or its
40
+ * proven twin: builtinIdentityOf), else a pinned registry package. A twin stands in as its built-in
41
+ * only when the built-in runs on the run interval (NATIVE_RUN_INTERVAL_SUBTYPES): the twin path
42
+ * keys and projects on that semantics, and kscriptShippedBuiltinRefusal refuses any other twin. A
43
+ * twin of any other built-in (Big Trades) is the pinned registry package it is, keyed and written
44
+ * like one (its tag, its declared compute params, the chart's interval, the account), and an
45
+ * unpinned, hosted, draft or dev-local one has none (its package refusal). Undefined for every
46
+ * other row.
47
+ */
48
+ export function standInIdentityOf(settings) {
49
+ const builtin = builtinIdentityOf(settings);
50
+ if (builtin?.kind === 'twin' && !NATIVE_RUN_INTERVAL_SUBTYPES.has(builtin.key))
51
+ return packageIdentityOf(settings);
52
+ return builtin ?? packageIdentityOf(settings);
53
+ }
54
+ /**
55
+ * The `engineScript` a proven twin's or a pinned package's stand-in is written under: its package
56
+ * at the version it is pinned to (WRUN-PARITY-P1 C7). The wrun run passes it to writeKScriptStandIn
57
+ * and the key hashes it, so a pin move or a template fix never serves a stale picture.
58
+ */
59
+ export function wrunStandInTag(packageName, version) {
60
+ return `wrun:${packageName}@${version}`;
61
+ }
@@ -0,0 +1,15 @@
1
+ export type KScriptPreparationDropReason = 'declared-helper' | 'appearance-anchor';
2
+ export interface KScriptPreparationDropTraceEntry {
3
+ key: string;
4
+ path: string;
5
+ reason: KScriptPreparationDropReason;
6
+ plotType?: string;
7
+ outputRole?: string;
8
+ }
9
+ export declare function getKScriptPreparationDropTrace(runResult: unknown): KScriptPreparationDropTraceEntry[];
10
+ export declare function attachKScriptPreparationDropTrace(runResult: unknown, trace: KScriptPreparationDropTraceEntry[]): unknown;
11
+ export declare function dropDeclaredHelperOutputs(runResult: unknown, trace: KScriptPreparationDropTraceEntry[] | undefined): unknown;
12
+ export declare function dropTransparentOnchartCandleAnchors(runResult: unknown, meta: Record<string, unknown> | null | undefined, trace?: KScriptPreparationDropTraceEntry[]): unknown;
13
+ export declare function pruneTransparentOnchartCandleNestedAnchors(meta: Record<string, unknown>): void;
14
+ export declare function releaseOffchartForcedFillPane(runResult: unknown, meta: Record<string, unknown> | null | undefined): unknown;
15
+ export declare function annotateUnplottedKScriptFillRefs(runResult: unknown): unknown;