@orangecharts/wrun-chart-host 0.11.0 → 0.14.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 (311) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +3 -4
  3. package/dist/constants/feature-flags.constants.js +34 -52
  4. package/dist/constants/feature-limits.constants.d.ts +1 -1
  5. package/dist/constants/feature-limits.constants.js +5 -4
  6. package/dist/constants/interval.constants.d.ts +7 -0
  7. package/dist/constants/interval.constants.js +7 -0
  8. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +20 -149
  9. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +20 -309
  10. package/dist/constants/stocks-compliance.constants.d.ts +15 -0
  11. package/dist/constants/stocks-compliance.constants.js +15 -0
  12. package/dist/host-env.d.ts +55 -3
  13. package/dist/host-env.js +6 -0
  14. package/dist/host-ports.types.d.ts +36 -3
  15. package/dist/index.d.ts +18 -0
  16. package/dist/index.js +19 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +78 -15
  18. package/dist/indicators/controls/tpo-session.util.js +320 -242
  19. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +6 -0
  20. package/dist/instances/script-engine-worker-ohlcv-transfer.js +16 -0
  21. package/dist/interfaces/cme-realtime.interface.d.ts +8 -0
  22. package/dist/interfaces/cme-realtime.interface.js +2 -1
  23. package/dist/interfaces/feed.interface.d.ts +15 -1
  24. package/dist/interfaces/replay.interface.d.ts +5 -0
  25. package/dist/interfaces/stocks-realtime.interface.d.ts +4 -3
  26. package/dist/interfaces/stocks-realtime.interface.js +5 -4
  27. package/dist/interfaces/wrun-runtime.interface.d.ts +97 -19
  28. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +17 -0
  29. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +22 -0
  30. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +46 -40
  31. package/dist/kscript-data/controls/live-trades-merge.util.js +80 -107
  32. package/dist/market-data/billing.interface.d.ts +9 -1
  33. package/dist/market-data/venue.d.ts +1 -1
  34. package/dist/market-data/venues/index.d.ts +4 -4
  35. package/dist/market-data/venues/stocks.contract.copy.json +4 -4
  36. package/dist/market-data/venues/stocks.d.ts +4 -4
  37. package/dist/market-data/venues/stocks.js +15 -13
  38. package/dist/settings-templates/frvp-fields.d.ts +12 -1
  39. package/dist/settings-templates/frvp-fields.js +15 -4
  40. package/dist/settings-templates/index.js +12 -5
  41. package/dist/settings-templates/indicator-fields.js +28 -2
  42. package/dist/settings-templates/tool-rules.d.ts +17 -8
  43. package/dist/settings-templates/tool-rules.js +15 -8
  44. package/dist/settings-templates/tool-tables.generated.js +4 -2
  45. package/dist/utility/auth/server-clock.util.d.ts +3 -1
  46. package/dist/utility/auth/server-clock.util.js +3 -1
  47. package/dist/utility/chart/book-live-bucket.util.js +2 -2
  48. package/dist/utility/chart/cache-alignment.util.d.ts +15 -7
  49. package/dist/utility/chart/cache-alignment.util.js +14 -7
  50. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +2 -0
  51. package/dist/utility/chart/chart-data-fetch-generation.util.js +16 -0
  52. package/dist/utility/chart/cme-session-bucket.util.d.ts +18 -75
  53. package/dist/utility/chart/cme-session-bucket.util.js +25 -332
  54. package/dist/utility/chart/continuous-contracts.util.js +6 -5
  55. package/dist/utility/chart/display-offset.leaf.d.ts +24 -0
  56. package/dist/utility/chart/display-offset.leaf.js +41 -0
  57. package/dist/utility/chart/effective-chart-session.util.d.ts +2 -1
  58. package/dist/utility/chart/effective-chart-session.util.js +13 -5
  59. package/dist/utility/chart/feed-interval.util.d.ts +6 -20
  60. package/dist/utility/chart/feed-interval.util.js +13 -22
  61. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +27 -7
  62. package/dist/utility/chart/fetch-dedupe-policy.util.js +86 -11
  63. package/dist/utility/chart/host-bar-placement.util.d.ts +7 -4
  64. package/dist/utility/chart/host-bar-placement.util.js +8 -2
  65. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +32 -0
  66. package/dist/utility/chart/indicator-inflight-registry.util.js +52 -0
  67. package/dist/utility/chart/indicator-run-interval.util.d.ts +10 -4
  68. package/dist/utility/chart/indicator-run-interval.util.js +21 -12
  69. package/dist/utility/chart/interval-registry.util.d.ts +1 -1
  70. package/dist/utility/chart/interval-registry.util.js +1 -1
  71. package/dist/utility/chart/kscript-legend-entries.util.d.ts +12 -0
  72. package/dist/utility/chart/kscript-legend-entries.util.js +16 -0
  73. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +1 -1
  74. package/dist/utility/chart/kscript-run-interval-projection.util.js +4 -2
  75. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -62
  76. package/dist/utility/chart/kscript-venue-policy.util.js +85 -94
  77. package/dist/utility/chart/live-bucket.util.d.ts +39 -17
  78. package/dist/utility/chart/live-bucket.util.js +103 -57
  79. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +58 -20
  80. package/dist/utility/chart/local-kscript-source-revalidation.util.js +98 -23
  81. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +35 -11
  82. package/dist/utility/chart/local-kscript-warmup-depth.util.js +24 -3
  83. package/dist/utility/chart/market-session-schedule.util.d.ts +8 -0
  84. package/dist/utility/chart/market-session-schedule.util.js +39 -1
  85. package/dist/utility/chart/market-session.util.d.ts +136 -0
  86. package/dist/utility/chart/market-session.util.js +341 -0
  87. package/dist/utility/chart/market-sessions.util.d.ts +83 -0
  88. package/dist/utility/chart/market-sessions.util.js +220 -0
  89. package/dist/utility/chart/om-panel.util.d.ts +5 -3
  90. package/dist/utility/chart/om-panel.util.js +42 -7
  91. package/dist/utility/chart/om-target.util.d.ts +14 -1
  92. package/dist/utility/chart/om-target.util.js +22 -5
  93. package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
  94. package/dist/utility/chart/opra-read-access.leaf.js +22 -0
  95. package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
  96. package/dist/utility/chart/profile-row-height.util.js +74 -37
  97. package/dist/utility/chart/rth-session.util.d.ts +55 -20
  98. package/dist/utility/chart/rth-session.util.js +94 -46
  99. package/dist/utility/chart/session-interval.util.d.ts +2 -1
  100. package/dist/utility/chart/session-interval.util.js +1 -3
  101. package/dist/utility/chart/session-lattice.util.d.ts +150 -0
  102. package/dist/utility/chart/session-lattice.util.js +488 -0
  103. package/dist/utility/chart/trading-day.util.d.ts +40 -2
  104. package/dist/utility/chart/trading-day.util.js +84 -7
  105. package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
  106. package/dist/utility/chart/us-equities-session.util.js +44 -15
  107. package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
  108. package/dist/utility/chart/window-geometry.leaf.js +57 -8
  109. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
  110. package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
  111. package/dist/utility/chart/wrun-run-result.util.d.ts +29 -12
  112. package/dist/utility/chart/wrun-run-result.util.js +89 -25
  113. package/dist/utility/common/time.util.js +5 -4
  114. package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
  115. package/dist/utility/market-events/earnings-scope.util.js +17 -9
  116. package/dist/utility/market-events/market-events.util.d.ts +14 -7
  117. package/dist/utility/market-events/market-events.util.js +30 -17
  118. package/dist/utility/number-format.util.d.ts +14 -21
  119. package/dist/utility/number-format.util.js +38 -24
  120. package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
  121. package/dist/utility/options/option-venue-disclosure.util.js +71 -11
  122. package/dist/utility/options/option-venue.util.d.ts +1 -1
  123. package/dist/utility/options/option-venue.util.js +1 -1
  124. package/dist/utility/pool-symbol.leaf.d.ts +7 -0
  125. package/dist/utility/pool-symbol.leaf.js +50 -5
  126. package/dist/utility/stocks/stock-display.util.d.ts +15 -0
  127. package/dist/utility/stocks/stock-display.util.js +37 -0
  128. package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
  129. package/dist/utility/v2/gate-plane.util.d.ts +6 -0
  130. package/dist/utility/v2/gate-plane.util.js +11 -1
  131. package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
  132. package/dist/utility/v2/gate-session-latch.util.js +3 -3
  133. package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
  134. package/dist/utility/v2/governed-tier.leaf.js +17 -16
  135. package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
  136. package/dist/utility/v2/stocks-governed.util.js +14 -0
  137. package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
  138. package/dist/utility/v2/v2-enums.leaf.js +458 -0
  139. package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
  140. package/dist/utility/wrun/derived-roots.leaf.js +27 -1
  141. package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
  142. package/dist/utility/wrun/derived-roots.util.js +97 -56
  143. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
  144. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
  145. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
  146. package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
  147. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
  148. package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
  149. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
  150. package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
  151. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
  152. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
  153. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  154. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
  155. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
  156. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
  157. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
  158. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
  159. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
  160. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
  161. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
  162. package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
  163. package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
  164. package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
  165. package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
  166. package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
  167. package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
  168. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +41 -22
  169. package/dist/utility/wrun/wrun-batched-marks.util.js +255 -59
  170. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
  171. package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
  172. package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
  173. package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
  174. package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
  175. package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
  176. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
  177. package/dist/utility/wrun/wrun-canvases.util.js +7 -3
  178. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
  179. package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
  180. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
  181. package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
  182. package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
  183. package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
  184. package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
  185. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
  186. package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
  187. package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
  188. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
  189. package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
  190. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
  191. package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
  192. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
  193. package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
  194. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
  195. package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
  196. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
  197. package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
  198. package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
  199. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
  200. package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
  201. package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
  202. package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
  203. package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
  204. package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
  205. package/dist/utility/wrun/wrun-host.service.js +137 -27
  206. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
  207. package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
  208. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
  209. package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
  210. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
  211. package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
  212. package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
  213. package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
  214. package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
  215. package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
  216. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
  217. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
  218. package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
  219. package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
  220. package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
  221. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
  222. package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
  223. package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
  224. package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
  225. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
  226. package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
  227. package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
  228. package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
  229. package/dist/utility/wrun/wrun-live-tick.util.js +648 -97
  230. package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
  231. package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
  232. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
  233. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
  234. package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
  235. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
  236. package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
  237. package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
  238. package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
  239. package/dist/utility/wrun/wrun-option-views.util.js +5 -2
  240. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
  241. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
  242. package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
  243. package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
  244. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +75 -11
  245. package/dist/utility/wrun/wrun-overlay-drivers.util.js +176 -43
  246. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
  247. package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
  248. package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
  249. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
  250. package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
  251. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +239 -24
  252. package/dist/utility/wrun/wrun-overlay-run.util.js +2204 -405
  253. package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
  254. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +2 -1
  255. package/dist/utility/wrun/wrun-panel-mount.util.js +20 -14
  256. package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
  257. package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
  258. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
  259. package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
  260. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
  261. package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
  262. package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
  263. package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
  264. package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
  265. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
  266. package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
  267. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
  268. package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
  269. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
  270. package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
  271. package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
  272. package/dist/utility/wrun/wrun-refusal.util.js +103 -16
  273. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
  274. package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
  275. package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
  276. package/dist/utility/wrun/wrun-run-health.util.d.ts +89 -2
  277. package/dist/utility/wrun/wrun-run-health.util.js +204 -1
  278. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
  279. package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
  280. package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
  281. package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
  282. package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
  283. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -3
  284. package/dist/utility/wrun/wrun-script-inputs.util.js +51 -13
  285. package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
  286. package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
  287. package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
  288. package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
  289. package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
  290. package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
  291. package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
  292. package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
  293. package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
  294. package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
  295. package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
  296. package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
  297. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
  298. package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
  299. package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
  300. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
  301. package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
  302. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
  303. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
  304. package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
  305. package/dist/utility/wrun/wrun-visibility-table.js +9 -0
  306. package/dist/utility/wrun/wrun-volume-profile.util.js +44 -32
  307. package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
  308. package/dist/utils/replay/replay-buffer-math.js +60 -30
  309. package/dist/workers/constants/socket-slots.d.ts +11 -7
  310. package/dist/workers/constants/socket-slots.js +6 -5
  311. package/package.json +11 -11
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The history as-of of an overlay session: the instant every lane's declared history (a leg's `bars`, a tape's
3
+ * `history`) counts back from. Within one session the START of each lane's window never moves later; its END still
4
+ * reaches the server's now (a lane's newest closed bars, the live edge).
5
+ *
6
+ * Why: every run of the browser host captures its own clock (`serverNowMs()`, `Date.now()`), and a declared history
7
+ * counted back from it starts later on every run of a chart left open: a history page, a reseed (a revised bar, a late
8
+ * input), a wake that lost the session, a settings save or a retry asks the lane from a later start, and the cells a
9
+ * package drew from the lane's oldest rows go blank. Anchored VWAP 0.1.12's lane `m` (2,000 1m candles, the oldest
10
+ * loaded day's head) blanked 1,182 drawn cells after 10 hours and 24,157 after 35, all on the oldest loaded day.
11
+ *
12
+ * - One pin per lane (its identity: a leg's fetch key, the tape's acquisition key), set by the first run of the
13
+ * session that asks the lane: a lane a settings save adds or changes counts back from its own first run, and every
14
+ * lane the save leaves alone keeps its pin.
15
+ * - The session is the overlay on its chart, its market, the chart's interval and the run interval
16
+ * (`wrunHistoryAsOfIdentity`): a switch of any of them, or the overlay's teardown (`forgetWrunHistoryAsOf`), starts a
17
+ * new one. A page reload is a new session (nothing persists).
18
+ * - The readers: each leg's fetch counts its `bars` back from its own pin (`planWrunLegFetch`); the run's clock
19
+ * carries the earliest pin among its legs (`WrunAlignClock.historyAsOfMs`), which the row builder's declared depth
20
+ * counts back from (`buildWrunInputRows`: the leg core's backlog, `wrunLegFetchStart`); the tape's ask names its own
21
+ * pin (`SOURCE_HISTORY_AS_OF_FIELD`, which the K_TRADES control's seed and the reconcile's served start read); the
22
+ * session installs the clock's as-of on its live context, which the reseed and the wake recovery read.
23
+ * - The cost: a lane grows with the session. Lane `m` asks 2,000 1m candles at the first run, 3,440 a day later and
24
+ * 6,320 after three days (1,440 a day). The gateway's history wall (15,000 1m bars) moves with now and still clamps
25
+ * the ask (`wrunServedLegStart`, the legend's note), so a 1m lane stops growing about 9 days into a session.
26
+ *
27
+ * Pure state, no host env: the run pass reads and writes it, the drivers' teardown forgets it.
28
+ */
29
+ /** What makes two runs of an overlay one session: the chart, its market, the chart's interval, the run interval. */
30
+ export declare function wrunHistoryAsOfIdentity(parts: {
31
+ chartIndex: number;
32
+ marketIdentity: string;
33
+ chartIntervalMs: number;
34
+ runInterval?: string;
35
+ }): string;
36
+ /** The tape's lane key: its acquisition words (the floor and the declared history), so a save that changes the
37
+ * tape's ask pins it anew. A coins floor (C-COINS item 2) keys by its coins, never by the dollar floor its window
38
+ * priced, so a later run of the session pricing another window keeps the pin. */
39
+ export declare function wrunTapeHistoryAsOfLaneKey(acquisition: {
40
+ minSize?: unknown;
41
+ minValue?: unknown;
42
+ minCoins?: unknown;
43
+ history?: unknown;
44
+ large?: unknown;
45
+ }): string;
46
+ /**
47
+ * Each lane's as-of for a run of the overlay at `nowMs` (ms): the pin the session holds for the lane, else `nowMs`,
48
+ * which pins it there. A session whose identity changed starts over (every lane pinned at `nowMs`). A pin is never
49
+ * later than `nowMs` (a server clock that stepped back keeps a lane's start where it was or earlier).
50
+ */
51
+ export declare function pinWrunLaneHistoryAsOf(indicatorId: string, identity: string, laneKeys: Iterable<string>, nowMs: number): Map<string, number>;
52
+ /** The earliest of the pins, undefined when there is none. */
53
+ export declare function wrunEarliestHistoryAsOf(pins: Iterable<number>): number | undefined;
54
+ /** Forget an overlay's session (its teardown): its next run pins every lane afresh. */
55
+ export declare function forgetWrunHistoryAsOf(indicatorId: string): void;
56
+ /** An overlay's session as a warm switch's park holds it: its identity and a copy of its pins. */
57
+ export interface WrunHistoryAsOfSnapshot {
58
+ readonly identity: string;
59
+ readonly lanes: ReadonlyMap<string, number>;
60
+ }
61
+ /** Take an overlay's session out (the warm switch's park, wrun-overlay-drivers.util): forgotten here as a teardown
62
+ * forgets it, so every path but the adoption starts afresh, and handed back as a copy; undefined when it has none. */
63
+ export declare function takeWrunHistoryAsOf(indicatorId: string): WrunHistoryAsOfSnapshot | undefined;
64
+ /** Put a parked session back (its adoption): the adopted live session keeps counting each lane back from the pins it
65
+ * ran under, as if its overlay had never left. A run under another identity starts over as it always does. */
66
+ export declare function restoreWrunHistoryAsOf(indicatorId: string, snapshot: WrunHistoryAsOfSnapshot): void;
67
+ /** Specs only: forget every session. */
68
+ export declare function __resetWrunHistoryAsOfForTests(): void;
69
+ /**
70
+ * The instant a clock's declared histories count back from: its `historyAsOfMs` when one is set and earlier than its
71
+ * now (a session's pin, a replay's present), else its now. The leg fetch planner and the row builder read it, so a
72
+ * clock without an as-of reads exactly as before.
73
+ */
74
+ export declare function wrunClockHistoryAsOfMs(clock: {
75
+ nowMs: number;
76
+ historyAsOfMs?: number;
77
+ }): number;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The history as-of of an overlay session: the instant every lane's declared history (a leg's `bars`, a tape's
3
+ * `history`) counts back from. Within one session the START of each lane's window never moves later; its END still
4
+ * reaches the server's now (a lane's newest closed bars, the live edge).
5
+ *
6
+ * Why: every run of the browser host captures its own clock (`serverNowMs()`, `Date.now()`), and a declared history
7
+ * counted back from it starts later on every run of a chart left open: a history page, a reseed (a revised bar, a late
8
+ * input), a wake that lost the session, a settings save or a retry asks the lane from a later start, and the cells a
9
+ * package drew from the lane's oldest rows go blank. Anchored VWAP 0.1.12's lane `m` (2,000 1m candles, the oldest
10
+ * loaded day's head) blanked 1,182 drawn cells after 10 hours and 24,157 after 35, all on the oldest loaded day.
11
+ *
12
+ * - One pin per lane (its identity: a leg's fetch key, the tape's acquisition key), set by the first run of the
13
+ * session that asks the lane: a lane a settings save adds or changes counts back from its own first run, and every
14
+ * lane the save leaves alone keeps its pin.
15
+ * - The session is the overlay on its chart, its market, the chart's interval and the run interval
16
+ * (`wrunHistoryAsOfIdentity`): a switch of any of them, or the overlay's teardown (`forgetWrunHistoryAsOf`), starts a
17
+ * new one. A page reload is a new session (nothing persists).
18
+ * - The readers: each leg's fetch counts its `bars` back from its own pin (`planWrunLegFetch`); the run's clock
19
+ * carries the earliest pin among its legs (`WrunAlignClock.historyAsOfMs`), which the row builder's declared depth
20
+ * counts back from (`buildWrunInputRows`: the leg core's backlog, `wrunLegFetchStart`); the tape's ask names its own
21
+ * pin (`SOURCE_HISTORY_AS_OF_FIELD`, which the K_TRADES control's seed and the reconcile's served start read); the
22
+ * session installs the clock's as-of on its live context, which the reseed and the wake recovery read.
23
+ * - The cost: a lane grows with the session. Lane `m` asks 2,000 1m candles at the first run, 3,440 a day later and
24
+ * 6,320 after three days (1,440 a day). The gateway's history wall (15,000 1m bars) moves with now and still clamps
25
+ * the ask (`wrunServedLegStart`, the legend's note), so a 1m lane stops growing about 9 days into a session.
26
+ *
27
+ * Pure state, no host env: the run pass reads and writes it, the drivers' teardown forgets it.
28
+ */
29
+ /** The sessions by overlay id (an id names one overlay on one chart). */
30
+ const sessions = new Map();
31
+ /** The lane key the tape's pin is held under, beside its acquisition words (`wrunTapeHistoryAsOfLaneKey`). */
32
+ const WRUN_TAPE_AS_OF_LANE = 'tape';
33
+ /** What makes two runs of an overlay one session: the chart, its market, the chart's interval, the run interval. */
34
+ export function wrunHistoryAsOfIdentity(parts) {
35
+ return [parts.chartIndex, parts.marketIdentity, parts.chartIntervalMs, parts.runInterval ?? ''].join('|');
36
+ }
37
+ /** The tape's lane key: its acquisition words (the floor and the declared history), so a save that changes the
38
+ * tape's ask pins it anew. A coins floor (C-COINS item 2) keys by its coins, never by the dollar floor its window
39
+ * priced, so a later run of the session pricing another window keeps the pin. */
40
+ export function wrunTapeHistoryAsOfLaneKey(acquisition) {
41
+ const coins = acquisition.minCoins !== undefined;
42
+ return [
43
+ WRUN_TAPE_AS_OF_LANE,
44
+ String(acquisition.minSize ?? ''),
45
+ coins ? '' : String(acquisition.minValue ?? ''),
46
+ String(acquisition.history ?? ''),
47
+ acquisition.large === true ? 'large' : '',
48
+ ...(coins ? [`coins=${String(acquisition.minCoins)}`] : []),
49
+ ].join('|');
50
+ }
51
+ /**
52
+ * Each lane's as-of for a run of the overlay at `nowMs` (ms): the pin the session holds for the lane, else `nowMs`,
53
+ * which pins it there. A session whose identity changed starts over (every lane pinned at `nowMs`). A pin is never
54
+ * later than `nowMs` (a server clock that stepped back keeps a lane's start where it was or earlier).
55
+ */
56
+ export function pinWrunLaneHistoryAsOf(indicatorId, identity, laneKeys, nowMs) {
57
+ let session = sessions.get(indicatorId);
58
+ if (session === undefined || session.identity !== identity) {
59
+ session = { identity, lanes: new Map() };
60
+ sessions.set(indicatorId, session);
61
+ }
62
+ const pins = new Map();
63
+ for (const key of laneKeys) {
64
+ const held = session.lanes.get(key);
65
+ const pin = held !== undefined && Number.isFinite(held) ? Math.min(held, nowMs) : nowMs;
66
+ session.lanes.set(key, pin);
67
+ pins.set(key, pin);
68
+ }
69
+ return pins;
70
+ }
71
+ /** The earliest of the pins, undefined when there is none. */
72
+ export function wrunEarliestHistoryAsOf(pins) {
73
+ let earliest;
74
+ for (const pin of pins) {
75
+ if (Number.isFinite(pin) && (earliest === undefined || pin < earliest))
76
+ earliest = pin;
77
+ }
78
+ return earliest;
79
+ }
80
+ /** Forget an overlay's session (its teardown): its next run pins every lane afresh. */
81
+ export function forgetWrunHistoryAsOf(indicatorId) {
82
+ sessions.delete(indicatorId);
83
+ }
84
+ /** Take an overlay's session out (the warm switch's park, wrun-overlay-drivers.util): forgotten here as a teardown
85
+ * forgets it, so every path but the adoption starts afresh, and handed back as a copy; undefined when it has none. */
86
+ export function takeWrunHistoryAsOf(indicatorId) {
87
+ const session = sessions.get(indicatorId);
88
+ sessions.delete(indicatorId);
89
+ return session === undefined ? undefined : { identity: session.identity, lanes: new Map(session.lanes) };
90
+ }
91
+ /** Put a parked session back (its adoption): the adopted live session keeps counting each lane back from the pins it
92
+ * ran under, as if its overlay had never left. A run under another identity starts over as it always does. */
93
+ export function restoreWrunHistoryAsOf(indicatorId, snapshot) {
94
+ sessions.set(indicatorId, { identity: snapshot.identity, lanes: new Map(snapshot.lanes) });
95
+ }
96
+ /** Specs only: forget every session. */
97
+ export function __resetWrunHistoryAsOfForTests() {
98
+ sessions.clear();
99
+ }
100
+ /**
101
+ * The instant a clock's declared histories count back from: its `historyAsOfMs` when one is set and earlier than its
102
+ * now (a session's pin, a replay's present), else its now. The leg fetch planner and the row builder read it, so a
103
+ * clock without an as-of reads exactly as before.
104
+ */
105
+ export function wrunClockHistoryAsOfMs(clock) {
106
+ const asOf = clock.historyAsOfMs;
107
+ return typeof asOf === 'number' && Number.isFinite(asOf) && asOf < clock.nowMs ? asOf : clock.nowMs;
108
+ }
@@ -14,11 +14,25 @@
14
14
  * full run and live-start names the module by key and carries the bytes
15
15
  * again (copied, never transferred), so a respawned worker compiles them
16
16
  * anew; nothing here tracks which keys the worker holds. Each request has
17
- * two clocks of WRUN_RUN_TIMEOUT_MS: the start ceiling from the post (the
18
- * wait behind other requests, the compile and the instantiation), then the
19
- * run deadline from the worker's `{ id, running: true }`, posted once the
20
- * module is instantiated, when the request executes; a terminal answer
21
- * settles a request in either phase.
17
+ * two clocks of WRUN_RUN_TIMEOUT_MS: the start ceiling (the wait behind
18
+ * other requests, the compile and the instantiation), then the run deadline
19
+ * from the worker's `{ id, running: true }`, posted once the module is
20
+ * instantiated, when the request executes; a terminal answer settles a
21
+ * request in either phase.
22
+ *
23
+ * The worker's boot (FB27, the managed worker's ready-deadline fix applied to
24
+ * the request clocks): a request's start ceiling starts at the post only on a
25
+ * worker that has booted; one posted before arms it when the worker boots.
26
+ * Boot is the incarnation's first message, and its first post is a boot probe
27
+ * (a `live-end` under a key no overlay holds, answered as soon as the
28
+ * worker's script arrived and its entry evaluated, ahead of every request),
29
+ * so a slow script download (113 s on a weak line, 2026-11-06) waits instead
30
+ * of spending the requests' clocks. The boot itself is bounded once, by the
31
+ * worker factory's ready deadline (WRUN_WORKER_BOOT_DEADLINE_MS, visible
32
+ * time, armed again in full when the script arrives): a download that
33
+ * stalls with no answer and no error ends there as a death before the boot,
34
+ * which charges no package (below), and the next request, a Retry's
35
+ * included, spawns a fresh worker.
22
36
  *
23
37
  * Isolation: a death of the shared worker (the run timeout, or an error
24
38
  * event with a request in flight) rejects every pending request with
@@ -29,8 +43,11 @@
29
43
  * `WrunQuarantinedError` instead of killing the worker again, and throttles
30
44
  * the respawn to one per window so several spinning packages (or a Retry
31
45
  * that overrides the quarantine) cannot kill and respawn the worker on
32
- * every request. A Retry or a settings save passes `overrideQuarantine`;
33
- * its success clears the package's quarantine.
46
+ * every request. A worker that died before it booted ran nothing: its death
47
+ * is the environment's (the script did not load), so it quarantines no
48
+ * package and records no culprit, and the next request respawns and waits
49
+ * for the next worker to boot. A Retry or a settings save passes
50
+ * `overrideQuarantine`; its success clears the package's quarantine.
34
51
  *
35
52
  * wrun-3 (Indicator handles): the sheet's `handles` section and the other
36
53
  * wrun-3 sheet fields are checked here before every run (the same place the
@@ -62,6 +79,15 @@ import { WrunWorkerPoisonError } from './wrun-registry-errors.util.js';
62
79
  * that read evaluated 3.6 MB of authoring code, 836 ms on a measured add, for a table the kit ships empty).
63
80
  * The chart's own candle classes (`ohlcv`, `time`) are never daemon-only. */
64
81
  export declare function assertWrunBrowserSources(metadata: WrunIndicatorMetadata): void;
82
+ /** The session key of the boot probe, every incarnation's first post (a `live-end` the worker answers once its
83
+ * script arrived and its entry evaluated): no overlay can hold it, since a session key is an overlay id. */
84
+ export declare const WRUN_HOST_BOOT_PROBE_SESSION_KEY = "\0wrun-host-boot";
85
+ /** Visible time an incarnation gets to boot (the factory's ready deadline): its script's download from the spawn,
86
+ * then, armed again in full when the script arrives, its entry's evaluation and the boot probe's answer. Generous on
87
+ * purpose: a slow line's download must finish (113 s on a 46 KB/s line, 2026-11-06), so only a stalled one reaches it
88
+ * (a request that never reached the CDN, a body that stopped: no answer and no error, nothing else ends it). Longer
89
+ * than the respawn window, so a boot death never holds the next spawn. */
90
+ export declare const WRUN_WORKER_BOOT_DEADLINE_MS = 180000;
65
91
  /** One respawn of the shared worker per window (the kScript shared worker's
66
92
  * `restartWithReseedBackoff` rule, sized for this host's 20 s run timeout
67
93
  * instead of kScript's 90 s call timeouts): a second death inside the window
@@ -125,6 +151,11 @@ export { WrunLiveOrderError };
125
151
  export { attachWrunLive, wrunLiveOf };
126
152
  export declare class WrunBrowserHost {
127
153
  private worker;
154
+ /** The current incarnation said anything (its boot probe's answer comes first): its script arrived and its entry
155
+ * evaluated. Until then no request clock runs, and a death charges no package. */
156
+ private workerBooted;
157
+ /** When the current incarnation was spawned (the run clock), for the boot's debug ring. */
158
+ private workerSpawnedAt;
128
159
  private pending;
129
160
  /** One counter numbers loads, runs and live-ends: a retired incarnation's late answer names an id no entry holds. */
130
161
  private requestSeq;
@@ -245,6 +276,12 @@ export declare class WrunBrowserHost {
245
276
  /** Dispatch although the package is quarantined; a success clears it. */
246
277
  overrideQuarantine?: boolean;
247
278
  }): Promise<WrunOutputRow[]>;
279
+ /** Ring `wrun-run-done` with the wall time of one whole run as the main thread saw it (the pack, the worker
280
+ * dispatch, the module's run over every row, the unpack): a full run or a live-session open (`live-start`), a
281
+ * prefix page or a cold page (`series`). Live ticks ring nothing (a tick a bar would flood the ring). Until
282
+ * 2026-11-03 the field dumps carried no run duration, so a pan-back's full rerun could not be told from the
283
+ * waste around it (`wrun-run-planned` names the reason and the rows; this names the cost). */
284
+ private ringRunDone;
248
285
  /** One live tick: evaluate only `rows` (the new/revised forming-bar rows)
249
286
  * on the open session. Rejects with WrunLiveSessionLostError when the
250
287
  * worker no longer holds the session. A wrun-3 session answers the
@@ -267,6 +304,10 @@ export declare class WrunBrowserHost {
267
304
  * (a run ending what it opened never ends a newer owner's session under
268
305
  * the same key). Without, whatever the key holds (the teardown). */
269
306
  endLiveSeries(sessionKey: string, epoch?: number): void;
307
+ /** Whether the current worker still holds the live series `sessionKey` opened under `epoch`: installed by an ok
308
+ * live-start of that generation, with no newer start, no end and no worker death since. A warm switch's parked
309
+ * session (wrun-overlay-drivers.util) is adopted again only while this holds, else its overlay runs afresh. */
310
+ holdsLiveSeries(sessionKey: string, epoch: number): boolean;
270
311
  destroy(): void;
271
312
  /** Unpack the rows against the caller's axis and hang the handle set, the
272
313
  * run's skipped draw calls, the strategy output and the live block
@@ -286,17 +327,23 @@ export declare class WrunBrowserHost {
286
327
  private dispatch;
287
328
  /**
288
329
  * Post one request under a pending entry: the respawn hold first (a held death refuses it, nothing posted), then
289
- * the worker, the entry in its `start` phase with the start ceiling armed (the wait behind other requests, the
290
- * module's compile and its instantiation, bounded as the dispatch clock bounded the hold before 0.6.0), then the
291
- * post. A request the structured clone refuses fails alone (its entry and clock go with it).
330
+ * the worker, the entry in its `start` phase with the start ceiling (the wait behind other requests, the module's
331
+ * compile and its instantiation, bounded as the dispatch clock bounded the hold before 0.6.0) armed now on a booted
332
+ * worker, else at its boot (`bootWorker`: a script still downloading spends no request's clock), then the post. A
333
+ * request the structured clone refuses fails alone (its entry and clock go with it).
292
334
  */
293
335
  private post;
336
+ /** The incarnation's first message: its script arrived and its entry evaluated, so the start ceiling of every
337
+ * request posted while it booted is armed now, in full (the managed worker's ready deadline, armed again at the
338
+ * script's arrival, is the same rule). */
339
+ private bootWorker;
294
340
  /** A phase's clock: a request that outlives it means the worker is stuck (a guest spinning, a compile that never
295
341
  * ends), so the worker is poisoned and replaced and later requests start clean. */
296
342
  private armClock;
297
- /** One answer from the worker. `running` moves its request to the `run` phase on a fresh clock (a second one, one
298
- * for a load or for no pending request changes nothing); a terminal answer settles its request in either phase;
299
- * an answer for no pending request (an untracked live-end's, a retired incarnation's) is dropped. */
343
+ /** One answer from the worker. The incarnation's first one boots it (`bootWorker`). `running` moves its request to
344
+ * the `run` phase on a fresh clock (a second one, one for a load or for no pending request changes nothing); a
345
+ * terminal answer settles its request in either phase; an answer for no pending request (the boot probe's, an
346
+ * untracked live-end's, a retired incarnation's) is dropped. */
300
347
  private receive;
301
348
  /** A run's terminal answer: the package answered (an overridden quarantine is cleared by the success, and an
302
349
  * opened session is one the worker now holds), a lost session, a live-order refusal, or a failure. */
@@ -308,7 +355,10 @@ export declare class WrunBrowserHost {
308
355
  * respawn window, and reject every pending request (loads included) with
309
356
  * the poison error naming the live sessions lost with the worker. Nothing
310
357
  * in flight means nothing to quarantine (a worker that dies idle is only a
311
- * death for the window). `message` is what every casualty reads; the
358
+ * death for the window), and neither does a worker that never booted: no
359
+ * request ran in it, so its death is the environment's (its script or a
360
+ * chunk of it did not load), never a strike against a package, and its
361
+ * context names no culprit. `message` is what every casualty reads; the
312
362
  * culprit of a timeout keeps its own deadline sentence. The death's
313
363
  * context (cause, the culprit's package, session and phase, the budget a
314
364
  * timeout used up) is recorded here once, frozen, and rides every
@@ -14,11 +14,25 @@
14
14
  * full run and live-start names the module by key and carries the bytes
15
15
  * again (copied, never transferred), so a respawned worker compiles them
16
16
  * anew; nothing here tracks which keys the worker holds. Each request has
17
- * two clocks of WRUN_RUN_TIMEOUT_MS: the start ceiling from the post (the
18
- * wait behind other requests, the compile and the instantiation), then the
19
- * run deadline from the worker's `{ id, running: true }`, posted once the
20
- * module is instantiated, when the request executes; a terminal answer
21
- * settles a request in either phase.
17
+ * two clocks of WRUN_RUN_TIMEOUT_MS: the start ceiling (the wait behind
18
+ * other requests, the compile and the instantiation), then the run deadline
19
+ * from the worker's `{ id, running: true }`, posted once the module is
20
+ * instantiated, when the request executes; a terminal answer settles a
21
+ * request in either phase.
22
+ *
23
+ * The worker's boot (FB27, the managed worker's ready-deadline fix applied to
24
+ * the request clocks): a request's start ceiling starts at the post only on a
25
+ * worker that has booted; one posted before arms it when the worker boots.
26
+ * Boot is the incarnation's first message, and its first post is a boot probe
27
+ * (a `live-end` under a key no overlay holds, answered as soon as the
28
+ * worker's script arrived and its entry evaluated, ahead of every request),
29
+ * so a slow script download (113 s on a weak line, 2026-11-06) waits instead
30
+ * of spending the requests' clocks. The boot itself is bounded once, by the
31
+ * worker factory's ready deadline (WRUN_WORKER_BOOT_DEADLINE_MS, visible
32
+ * time, armed again in full when the script arrives): a download that
33
+ * stalls with no answer and no error ends there as a death before the boot,
34
+ * which charges no package (below), and the next request, a Retry's
35
+ * included, spawns a fresh worker.
22
36
  *
23
37
  * Isolation: a death of the shared worker (the run timeout, or an error
24
38
  * event with a request in flight) rejects every pending request with
@@ -29,8 +43,11 @@
29
43
  * `WrunQuarantinedError` instead of killing the worker again, and throttles
30
44
  * the respawn to one per window so several spinning packages (or a Retry
31
45
  * that overrides the quarantine) cannot kill and respawn the worker on
32
- * every request. A Retry or a settings save passes `overrideQuarantine`;
33
- * its success clears the package's quarantine.
46
+ * every request. A worker that died before it booted ran nothing: its death
47
+ * is the environment's (the script did not load), so it quarantines no
48
+ * package and records no culprit, and the next request respawns and waits
49
+ * for the next worker to boot. A Retry or a settings save passes
50
+ * `overrideQuarantine`; its success clears the package's quarantine.
34
51
  *
35
52
  * wrun-3 (Indicator handles): the sheet's `handles` section and the other
36
53
  * wrun-3 sheet fields are checked here before every run (the same place the
@@ -60,6 +77,8 @@ import { assertWrunSheetAbiCoupling, attachWrunDrawSkips, attachWrunHandles, rea
60
77
  import { packWrunRows, unpackWrunResponse, wrunAbiVersion } from './wrun-pack.util.js';
61
78
  import { WrunQuarantinedError, WrunWorkerPoisonError } from './wrun-registry-errors.util.js';
62
79
  import { bindWrunHostLiveSeriesEnd } from './wrun-overlay-drivers.util.js';
80
+ /** The ring's run clock: `performance.now()` where the platform has it (every browser), else the wall clock. */
81
+ const wrunRunClockMs = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
63
82
  /** Sources the kit marks daemon-only are computed by the daemon, which owns their dependencies: the first
64
83
  * input declaring one refuses the browser run by name, with the kit's words for it. Synchronous: the
65
84
  * table is the kit's, copied import-free (wrun-kit-run-tables.util, pinned to the kit's export by its
@@ -78,6 +97,15 @@ export function assertWrunBrowserSources(metadata) {
78
97
  }
79
98
  }
80
99
  const WRUN_RUN_TIMEOUT_MS = 20_000;
100
+ /** The session key of the boot probe, every incarnation's first post (a `live-end` the worker answers once its
101
+ * script arrived and its entry evaluated): no overlay can hold it, since a session key is an overlay id. */
102
+ export const WRUN_HOST_BOOT_PROBE_SESSION_KEY = '\u0000wrun-host-boot';
103
+ /** Visible time an incarnation gets to boot (the factory's ready deadline): its script's download from the spawn,
104
+ * then, armed again in full when the script arrives, its entry's evaluation and the boot probe's answer. Generous on
105
+ * purpose: a slow line's download must finish (113 s on a 46 KB/s line, 2026-11-06), so only a stalled one reaches it
106
+ * (a request that never reached the CDN, a body that stopped: no answer and no error, nothing else ends it). Longer
107
+ * than the respawn window, so a boot death never holds the next spawn. */
108
+ export const WRUN_WORKER_BOOT_DEADLINE_MS = 180_000;
81
109
  /** One respawn of the shared worker per window (the kScript shared worker's
82
110
  * `restartWithReseedBackoff` rule, sized for this host's 20 s run timeout
83
111
  * instead of kScript's 90 s call timeouts): a second death inside the window
@@ -256,6 +284,11 @@ function packWrunRunRequest(metadata, rows, initArgs, strategy, configure, textP
256
284
  }
257
285
  export class WrunBrowserHost {
258
286
  worker = null;
287
+ /** The current incarnation said anything (its boot probe's answer comes first): its script arrived and its entry
288
+ * evaluated. Until then no request clock runs, and a death charges no package. */
289
+ workerBooted = false;
290
+ /** When the current incarnation was spawned (the run clock), for the boot's debug ring. */
291
+ workerSpawnedAt = 0;
259
292
  pending = new Map();
260
293
  /** One counter numbers loads, runs and live-ends: a retired incarnation's late answer names an id no entry holds. */
261
294
  requestSeq = 0;
@@ -466,8 +499,11 @@ export class WrunBrowserHost {
466
499
  mode: input.mode ?? 'historical',
467
500
  ...packed,
468
501
  };
502
+ const startedAt = wrunRunClockMs();
469
503
  const response = await this.dispatchWithModule(request, transfer, lane, input.module);
470
- return this.unpack(response, input.metadata, input.rows);
504
+ const rows = this.unpack(response, input.metadata, input.rows);
505
+ this.ringRunDone('series', input, rows.length, startedAt);
506
+ return rows;
471
507
  }
472
508
  /** Full run that also opens (or replaces) a live forming-bar session under
473
509
  * `sessionKey` in the worker: the guest stays instantiated, so later
@@ -497,11 +533,34 @@ export class WrunBrowserHost {
497
533
  ...(input.epoch !== undefined ? { epoch: input.epoch } : {}),
498
534
  ...packed,
499
535
  };
536
+ const startedAt = wrunRunClockMs();
500
537
  const response = await this.dispatchWithModule(request, transfer, {
501
538
  ...lane,
502
539
  session: { key: input.sessionKey, opens: true },
503
540
  }, input.module);
504
- return this.unpack(response, input.metadata, input.rows);
541
+ const rows = this.unpack(response, input.metadata, input.rows);
542
+ this.ringRunDone('live-start', input, rows.length, startedAt);
543
+ return rows;
544
+ }
545
+ /** Ring `wrun-run-done` with the wall time of one whole run as the main thread saw it (the pack, the worker
546
+ * dispatch, the module's run over every row, the unpack): a full run or a live-session open (`live-start`), a
547
+ * prefix page or a cold page (`series`). Live ticks ring nothing (a tick a bar would flood the ring). Until
548
+ * 2026-11-03 the field dumps carried no run duration, so a pan-back's full rerun could not be told from the
549
+ * waste around it (`wrun-run-planned` names the reason and the rows; this names the cost). */
550
+ ringRunDone(op, input, outputRows, startedAt) {
551
+ const env = wrunChartHostEnv();
552
+ if (!env.diagnostics.debugEnabled())
553
+ return;
554
+ env.diagnostics.debug('wrun-run-done', {
555
+ op,
556
+ ...(input.sessionKey !== undefined ? { sessionKey: input.sessionKey } : {}),
557
+ mode: input.mode ?? (op === 'live-start' ? 'live' : 'historical'),
558
+ sheet: input.metadata.name,
559
+ sha256: typeof input.module.sha256 === 'string' ? input.module.sha256.slice(0, 12) : null,
560
+ rowsIn: input.rows.length,
561
+ rowsOut: outputRows,
562
+ ms: Math.round((wrunRunClockMs() - startedAt) * 10) / 10,
563
+ });
505
564
  }
506
565
  /** One live tick: evaluate only `rows` (the new/revised forming-bar rows)
507
566
  * on the open session. Rejects with WrunLiveSessionLostError when the
@@ -569,6 +628,12 @@ export class WrunBrowserHost {
569
628
  // from a worker respawn (both drop the session).
570
629
  this.worker.postMessage(request);
571
630
  }
631
+ /** Whether the current worker still holds the live series `sessionKey` opened under `epoch`: installed by an ok
632
+ * live-start of that generation, with no newer start, no end and no worker death since. A warm switch's parked
633
+ * session (wrun-overlay-drivers.util) is adopted again only while this holds, else its overlay runs afresh. */
634
+ holdsLiveSeries(sessionKey, epoch) {
635
+ return (this.worker !== null && this.liveSessionKeys.has(sessionKey) && this.liveStartEpochs.get(sessionKey) === epoch);
636
+ }
572
637
  destroy() {
573
638
  this.failAllPending(new Error('WRUN host destroyed'));
574
639
  this.liveSessionKeys.clear();
@@ -626,9 +691,10 @@ export class WrunBrowserHost {
626
691
  }
627
692
  /**
628
693
  * Post one request under a pending entry: the respawn hold first (a held death refuses it, nothing posted), then
629
- * the worker, the entry in its `start` phase with the start ceiling armed (the wait behind other requests, the
630
- * module's compile and its instantiation, bounded as the dispatch clock bounded the hold before 0.6.0), then the
631
- * post. A request the structured clone refuses fails alone (its entry and clock go with it).
694
+ * the worker, the entry in its `start` phase with the start ceiling (the wait behind other requests, the module's
695
+ * compile and its instantiation, bounded as the dispatch clock bounded the hold before 0.6.0) armed now on a booted
696
+ * worker, else at its boot (`bootWorker`: a script still downloading spends no request's clock), then the post. A
697
+ * request the structured clone refuses fails alone (its entry and clock go with it).
632
698
  */
633
699
  post(request, transfer, init) {
634
700
  const held = this.respawnHold();
@@ -637,7 +703,8 @@ export class WrunBrowserHost {
637
703
  return;
638
704
  }
639
705
  const worker = this.ensureWorker();
640
- const entry = { ...init, phase: 'start', runOrder: 0, timer: this.armClock(request.id) };
706
+ const timer = this.workerBooted ? this.armClock(request.id) : undefined;
707
+ const entry = { ...init, phase: 'start', runOrder: 0, timer };
641
708
  this.pending.set(request.id, entry);
642
709
  try {
643
710
  worker.postMessage(request, transfer);
@@ -650,15 +717,35 @@ export class WrunBrowserHost {
650
717
  entry.reject(error instanceof Error ? error : new Error(String(error)));
651
718
  }
652
719
  }
720
+ /** The incarnation's first message: its script arrived and its entry evaluated, so the start ceiling of every
721
+ * request posted while it booted is armed now, in full (the managed worker's ready deadline, armed again at the
722
+ * script's arrival, is the same rule). */
723
+ bootWorker() {
724
+ this.workerBooted = true;
725
+ for (const [id, entry] of this.pending) {
726
+ if (entry.timer === undefined)
727
+ entry.timer = this.armClock(id);
728
+ }
729
+ const env = wrunChartHostEnv();
730
+ if (!env.diagnostics.debugEnabled())
731
+ return;
732
+ env.diagnostics.debug('wrun-worker-booted', {
733
+ bootMs: Math.round(wrunRunClockMs() - this.workerSpawnedAt),
734
+ waiting: this.pending.size,
735
+ });
736
+ }
653
737
  /** A phase's clock: a request that outlives it means the worker is stuck (a guest spinning, a compile that never
654
738
  * ends), so the worker is poisoned and replaced and later requests start clean. */
655
739
  armClock(id) {
656
740
  return setTimeout(() => this.poisonWorker('timeout', 'WRUN worker terminated after a timed-out run', id), WRUN_RUN_TIMEOUT_MS);
657
741
  }
658
- /** One answer from the worker. `running` moves its request to the `run` phase on a fresh clock (a second one, one
659
- * for a load or for no pending request changes nothing); a terminal answer settles its request in either phase;
660
- * an answer for no pending request (an untracked live-end's, a retired incarnation's) is dropped. */
742
+ /** One answer from the worker. The incarnation's first one boots it (`bootWorker`). `running` moves its request to
743
+ * the `run` phase on a fresh clock (a second one, one for a load or for no pending request changes nothing); a
744
+ * terminal answer settles its request in either phase; an answer for no pending request (the boot probe's, an
745
+ * untracked live-end's, a retired incarnation's) is dropped. */
661
746
  receive(message) {
747
+ if (!this.workerBooted)
748
+ this.bootWorker();
662
749
  const entry = this.pending.get(message.id);
663
750
  if (entry === undefined)
664
751
  return;
@@ -714,12 +801,16 @@ export class WrunBrowserHost {
714
801
  // death must stay out of.
715
802
  if (this.lastDeath !== null)
716
803
  this.lastRespawnAt = Date.now();
804
+ this.workerBooted = false;
805
+ this.workerSpawnedAt = wrunRunClockMs();
717
806
  // The host's engine port spawns the sandbox worker (web: the worker factory, with the worker script's URL and
718
807
  // the factory's failure source, both the app's), synchronously, as the host's own call did.
719
808
  this.worker = wrunChartHostEnv().engine.spawnWorker({
720
- // The sandbox worker posts no handshake: any message proves it up. No ready deadline: the requests' clocks,
721
- // the quarantine and the respawn window own this worker's liveness.
722
- readiness: { mode: 'first-message' },
809
+ // The sandbox worker posts no handshake: any message proves it up, and the boot probe below makes the first one
810
+ // come as soon as the worker can answer. The request clocks start at the boot; the boot's one bound is this
811
+ // deadline (a stalled download dies here as the environment's, below), sized so a slow line's download is never
812
+ // cut.
813
+ readiness: { mode: 'first-message', deadlineMs: WRUN_WORKER_BOOT_DEADLINE_MS },
723
814
  onMessage: (event) => this.receive(event.data),
724
815
  // A worker-level error (a script or module chunk that would not load, an
725
816
  // uncaught throw in the worker script) leaves the Worker unable to answer
@@ -729,9 +820,20 @@ export class WrunBrowserHost {
729
820
  // mirror the timeout path: poison it now so the next run respawns a clean
730
821
  // worker and this failure fails fast. A replaced or terminated
731
822
  // incarnation's late events reach nobody, so a late one is never another
732
- // death.
733
- onDead: (death) => this.poisonWorker('worker-error', death.message || 'WRUN worker error'),
823
+ // death. A missed boot deadline is the same death (the factory already
824
+ // terminated it and beaconed the ready timeout, naming the file).
825
+ onDead: (death) => this.poisonWorker('worker-error', death.reason === 'ready-timeout'
826
+ ? `WRUN worker did not boot within ${WRUN_WORKER_BOOT_DEADLINE_MS / 1000}s`
827
+ : death.message || 'WRUN worker error'),
734
828
  });
829
+ // The boot probe, before any request: every handler version answers a `live-end` at once (it ends nothing under a
830
+ // key no overlay holds), so its answer is the incarnation's first message, sent as soon as the entry evaluated.
831
+ const probe = {
832
+ kind: 'live-end',
833
+ id: ++this.requestSeq,
834
+ sessionKey: WRUN_HOST_BOOT_PROBE_SESSION_KEY,
835
+ };
836
+ this.worker.postMessage(probe);
735
837
  return this.worker;
736
838
  }
737
839
  /**
@@ -740,7 +842,10 @@ export class WrunBrowserHost {
740
842
  * respawn window, and reject every pending request (loads included) with
741
843
  * the poison error naming the live sessions lost with the worker. Nothing
742
844
  * in flight means nothing to quarantine (a worker that dies idle is only a
743
- * death for the window). `message` is what every casualty reads; the
845
+ * death for the window), and neither does a worker that never booted: no
846
+ * request ran in it, so its death is the environment's (its script or a
847
+ * chunk of it did not load), never a strike against a package, and its
848
+ * context names no culprit. `message` is what every casualty reads; the
744
849
  * culprit of a timeout keeps its own deadline sentence. The death's
745
850
  * context (cause, the culprit's package, session and phase, the budget a
746
851
  * timeout used up) is recorded here once, frozen, and rides every
@@ -749,7 +854,9 @@ export class WrunBrowserHost {
749
854
  */
750
855
  poisonWorker(reason, message, expiredId) {
751
856
  const now = Date.now();
752
- const culprit = this.culpritOf(expiredId);
857
+ // A request clock runs only on a booted worker, so a timeout always has one; an error event before the boot has
858
+ // none.
859
+ const culprit = this.workerBooted ? this.culpritOf(expiredId) : undefined;
753
860
  if (culprit !== undefined)
754
861
  this.quarantine(culprit.quarantineKey, reason, now);
755
862
  const casualties = new Set(this.liveSessionKeys);
@@ -769,6 +876,7 @@ export class WrunBrowserHost {
769
876
  // A phase's clock (from the post for `start`, from `running` for `run`): the budget bounds the hold, not the
770
877
  // execution.
771
878
  ...(kind === 'timeout' ? { heldMs: WRUN_RUN_TIMEOUT_MS } : {}),
879
+ ...(this.workerBooted ? {} : { booted: false }),
772
880
  at: now,
773
881
  });
774
882
  const death = { reason, casualtySessionKeys, message, context };
@@ -837,11 +945,13 @@ export function getWrunBrowserHost() {
837
945
  return sharedHost;
838
946
  }
839
947
  // The overlay teardown ends a live series through this (wrun-overlay-drivers.util keeps no import
840
- // of the host): bound as the host evaluates, before its worker can open a session. A spec that
841
- // mocks the drivers util partially has no binder (reading a missing export of a mocked module
842
- // throws at access time), so the bind is skipped there rather than failing the import.
948
+ // of the host): bound as the host evaluates, before its worker can open a session. A parked
949
+ // session's end names its epoch (that generation only: a later run's session under the same key
950
+ // is another owner's). A spec that mocks the drivers util partially has no binder (reading a
951
+ // missing export of a mocked module throws at access time), so the bind is skipped there rather
952
+ // than failing the import.
843
953
  try {
844
- bindWrunHostLiveSeriesEnd((sessionKey) => getWrunBrowserHost().endLiveSeries(sessionKey));
954
+ bindWrunHostLiveSeriesEnd((sessionKey, epoch) => getWrunBrowserHost().endLiveSeries(sessionKey, epoch));
845
955
  }
846
956
  catch {
847
957
  // partial module mock (specs): no teardown door to bind