@orangecharts/wrun-chart-host 0.11.1 → 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 (307) 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 +17 -0
  16. package/dist/index.js +18 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +52 -12
  18. package/dist/indicators/controls/tpo-session.util.js +113 -16
  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/om-panel.util.d.ts +5 -3
  88. package/dist/utility/chart/om-panel.util.js +42 -7
  89. package/dist/utility/chart/om-target.util.d.ts +14 -1
  90. package/dist/utility/chart/om-target.util.js +22 -5
  91. package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
  92. package/dist/utility/chart/opra-read-access.leaf.js +22 -0
  93. package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
  94. package/dist/utility/chart/profile-row-height.util.js +74 -37
  95. package/dist/utility/chart/rth-session.util.d.ts +55 -20
  96. package/dist/utility/chart/rth-session.util.js +94 -46
  97. package/dist/utility/chart/session-lattice.util.d.ts +150 -0
  98. package/dist/utility/chart/session-lattice.util.js +488 -0
  99. package/dist/utility/chart/trading-day.util.d.ts +40 -2
  100. package/dist/utility/chart/trading-day.util.js +84 -7
  101. package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
  102. package/dist/utility/chart/us-equities-session.util.js +44 -15
  103. package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
  104. package/dist/utility/chart/window-geometry.leaf.js +57 -8
  105. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
  106. package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
  107. package/dist/utility/chart/wrun-run-result.util.d.ts +29 -12
  108. package/dist/utility/chart/wrun-run-result.util.js +89 -25
  109. package/dist/utility/common/time.util.js +5 -4
  110. package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
  111. package/dist/utility/market-events/earnings-scope.util.js +17 -9
  112. package/dist/utility/market-events/market-events.util.d.ts +14 -7
  113. package/dist/utility/market-events/market-events.util.js +30 -17
  114. package/dist/utility/number-format.util.d.ts +14 -21
  115. package/dist/utility/number-format.util.js +38 -24
  116. package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
  117. package/dist/utility/options/option-venue-disclosure.util.js +71 -11
  118. package/dist/utility/options/option-venue.util.d.ts +1 -1
  119. package/dist/utility/options/option-venue.util.js +1 -1
  120. package/dist/utility/pool-symbol.leaf.d.ts +7 -0
  121. package/dist/utility/pool-symbol.leaf.js +50 -5
  122. package/dist/utility/stocks/stock-display.util.d.ts +15 -0
  123. package/dist/utility/stocks/stock-display.util.js +37 -0
  124. package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
  125. package/dist/utility/v2/gate-plane.util.d.ts +6 -0
  126. package/dist/utility/v2/gate-plane.util.js +11 -1
  127. package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
  128. package/dist/utility/v2/gate-session-latch.util.js +3 -3
  129. package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
  130. package/dist/utility/v2/governed-tier.leaf.js +17 -16
  131. package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
  132. package/dist/utility/v2/stocks-governed.util.js +14 -0
  133. package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
  134. package/dist/utility/v2/v2-enums.leaf.js +458 -0
  135. package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
  136. package/dist/utility/wrun/derived-roots.leaf.js +27 -1
  137. package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
  138. package/dist/utility/wrun/derived-roots.util.js +97 -56
  139. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
  140. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
  141. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
  142. package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
  143. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
  144. package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
  145. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
  146. package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
  147. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
  148. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
  149. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  150. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
  151. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
  152. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
  153. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
  154. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
  155. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
  156. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
  157. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
  158. package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
  159. package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
  160. package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
  161. package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
  162. package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
  163. package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
  164. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +41 -22
  165. package/dist/utility/wrun/wrun-batched-marks.util.js +255 -59
  166. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
  167. package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
  168. package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
  169. package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
  170. package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
  171. package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
  172. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
  173. package/dist/utility/wrun/wrun-canvases.util.js +7 -3
  174. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
  175. package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
  176. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
  177. package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
  178. package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
  179. package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
  180. package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
  181. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
  182. package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
  183. package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
  184. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
  185. package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
  186. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
  187. package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
  188. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
  189. package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
  190. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
  191. package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
  192. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
  193. package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
  194. package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
  195. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
  196. package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
  197. package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
  198. package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
  199. package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
  200. package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
  201. package/dist/utility/wrun/wrun-host.service.js +137 -27
  202. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
  203. package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
  204. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
  205. package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
  206. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
  207. package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
  208. package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
  209. package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
  210. package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
  211. package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
  212. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
  213. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
  214. package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
  215. package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
  216. package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
  217. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
  218. package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
  219. package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
  220. package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
  221. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
  222. package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
  223. package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
  224. package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
  225. package/dist/utility/wrun/wrun-live-tick.util.js +648 -97
  226. package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
  227. package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
  228. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
  229. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
  230. package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
  231. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
  232. package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
  233. package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
  234. package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
  235. package/dist/utility/wrun/wrun-option-views.util.js +5 -2
  236. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
  237. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
  238. package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
  239. package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
  240. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +75 -11
  241. package/dist/utility/wrun/wrun-overlay-drivers.util.js +176 -43
  242. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
  243. package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
  244. package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
  245. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
  246. package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
  247. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +239 -24
  248. package/dist/utility/wrun/wrun-overlay-run.util.js +2204 -405
  249. package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
  250. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +2 -1
  251. package/dist/utility/wrun/wrun-panel-mount.util.js +20 -14
  252. package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
  253. package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
  254. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
  255. package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
  256. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
  257. package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
  258. package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
  259. package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
  260. package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
  261. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
  262. package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
  263. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
  264. package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
  265. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
  266. package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
  267. package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
  268. package/dist/utility/wrun/wrun-refusal.util.js +103 -16
  269. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
  270. package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
  271. package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
  272. package/dist/utility/wrun/wrun-run-health.util.d.ts +89 -2
  273. package/dist/utility/wrun/wrun-run-health.util.js +204 -1
  274. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
  275. package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
  276. package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
  277. package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
  278. package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
  279. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -3
  280. package/dist/utility/wrun/wrun-script-inputs.util.js +51 -13
  281. package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
  282. package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
  283. package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
  284. package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
  285. package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
  286. package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
  287. package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
  288. package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
  289. package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
  290. package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
  291. package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
  292. package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
  293. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
  294. package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
  295. package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
  296. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
  297. package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
  298. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
  299. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
  300. package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
  301. package/dist/utility/wrun/wrun-visibility-table.js +9 -0
  302. package/dist/utility/wrun/wrun-volume-profile.util.js +7 -3
  303. package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
  304. package/dist/utils/replay/replay-buffer-math.js +60 -30
  305. package/dist/workers/constants/socket-slots.d.ts +11 -7
  306. package/dist/workers/constants/socket-slots.js +6 -5
  307. package/package.json +5 -5
@@ -98,7 +98,17 @@
98
98
  * its old rows), or a reconcile lane whose window held more than its read
99
99
  * takes (a refusal by name the leaf declares `over-cap`: the tape past the
100
100
  * trades worker's cap), whose window stays owed while the session is held
101
- * and hands ONE full run off (`handWrunLiveOverCapBack`). A pan-back page left to its wave
101
+ * and hands ONE full run off (`handWrunLiveOverCapBack`). A history move the
102
+ * planner reads as a verified backward extension (`extension: 'backward'`)
103
+ * waits at the settle gate while the gesture is live, the view moved less
104
+ * than WRUN_REBUILD_SETTLE_STILL_MS ago or the main candle fetch is out, so
105
+ * ONE handoff after the pan settles (or at the shared ceiling), which the
106
+ * episode's own wake decides on the motion clock, covers every page of the
107
+ * gesture and carries how long it held (WRUN-PANBACK A2); every other
108
+ * history move hands off at once. The chart's
109
+ * whole pan wave for such a page, offered by the executor while the episode
110
+ * is open or the gesture is live, is taken into it (`absorbWrunLazyWave`):
111
+ * it runs nothing, the episode's handoff rebuilds the page. A pan-back page left to its wave
102
112
  * (contract C1: a verified backward extension under an owner pending or
103
113
  * landed over it, or on a prefix-capable session within the grace its wave
104
114
  * has to stamp one) moves no history: the wave lands the page's rows into
@@ -176,10 +186,11 @@ import { recordKScriptPerfVolumeExtras } from '../chart/kscript-perf-tracker.uti
176
186
  import { diffWrunLiveResults, wrunLiveBuildMemoOf, wrunLiveBuildReusable, wrunLiveChartBarsEqual, wrunLiveChartBarsOf, wrunLiveCollapseKeyCrossesWindow, wrunLiveHeadlessOutputs, wrunLivePlotsIntact, wrunLivePlotsOf, wrunLiveTailWindowOf, wrunLiveWindowResult, } from './wrun-live-patch.util.js';
177
187
  import { OVERLAY_HISTORICAL_DRAWING_BUDGET, OVERLAY_HISTORICAL_ROW_BUDGET, shouldBlockOverlayHistoricalPreflightBudget, } from '../chart/overlay-output-budget.util.js';
178
188
  import { overlayExecutionGuardKey } from '../chart/overlay-execution-guard-key.leaf.js';
179
- import { cmeServedAccessForExchange } from '../chart/cme-cache-context.util.js';
180
189
  import { wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
181
190
  import { runBarSpan } from '../chart/indicator-run-interval.util.js';
182
- import { CME_DELAYED_EMBARGO_MARGIN_SECONDS, governedMarketDataTier, isGovernedExchange, servedDelaySecondsForAccess, } from '../v2/governed-tier.leaf.js';
191
+ import { HEAVY_APPLY_GESTURE_CEILING_MS } from '../chart/gesture-timing.leaf.js';
192
+ import { governedMarketDataTier } from '../v2/governed-tier.leaf.js';
193
+ import { wrunChartFormingBarTs, wrunChartStreamExchange, wrunChartStreamRefOf, wrunReconcileHeldRowWins, wrunStreamCutMs, wrunStreamDelayBars, } from './wrun-stream-clock.util.js';
183
194
  import { liveBucketStartsInRange, liveBucketVenueOf } from '../chart/live-bucket.util.js';
184
195
  import { hostBucketResolverFor } from '../chart/host-bar-placement.util.js';
185
196
  import { attachWrunStrategy, isWrunStrategySheet, wrunStrategyOf } from './wrun-box-segment.util.js';
@@ -193,7 +204,10 @@ import { wrunPollLaneByKey } from './sources/registry.js';
193
204
  import { isWrunPollLaneId } from './sources/wrun-poll-lane.types.js';
194
205
  import { wrunRowLaneByKey } from './sources/row-lane-registry.js';
195
206
  import { isWrunRowLaneId } from './sources/wrun-row-lane.types.js';
196
- import { fetchWrunRowLaneRows, mergeWrunReplayRowLaneRows, wrunReplayRowLaneExtensions, wrunRowLaneAddKey, wrunRowLaneChainAsk, wrunRowLaneChainGovernedExchange, wrunRowLaneFetchOptions, wrunRowLaneMovedInstance, } from './sources/wrun-row-lanes.util.js';
207
+ import { fetchWrunRowLaneRows, mergeWrunReplayRowLaneRows, wrunReplayRowLaneExtensions, wrunRowLaneAddKey, wrunRowLaneChainAsk, wrunRowLaneChainGovernedExchange, wrunRowLaneFetchOptions, wrunRowLaneMovedInstance, wrunRowLaneStocksTapeOf, } from './sources/wrun-row-lanes.util.js';
208
+ import { getChartDataFetchGeneration } from '../chart/chart-data-fetch-generation.util.js';
209
+ import { wrunLaneFetchSignal } from './sources/wrun-lane-fetch-abort.util.js';
210
+ import { wrunHostBarSpansWithin } from './wrun-tier-grid.util.js';
197
211
  import { wrunOpraLanePayloadAt } from './wrun-opra-lane.util.js';
198
212
  import { drainWrunPollLaneLiveRows, setWrunPollLaneLiveDrainRequester, wrunPollLaneLiveOwed, wrunPollLaneLiveUp, } from './wrun-series-stream.util.js';
199
213
  import { fetchWrunPollLaneHostGridRows, wrunPollLaneChainAsk, wrunPollLaneChainGovernedExchange, wrunPollLaneFetchOptions, wrunPollLaneMovedInstance, wrunPollLaneReconcileFrom, wrunPollLaneReconcileTo, } from './sources/wrun-poll-lanes.util.js';
@@ -203,15 +217,18 @@ import { selectWrunDebugLines, wrunDebugSlotIndex } from './wrun-debug-output.ut
203
217
  import { attachWrunHandles, wrunHandlesOf } from './wrun-handles.util.js';
204
218
  import { mergeWrunCandleEvidence, wrunCandleFingerprintsOf } from './wrun-prefix-proof.util.js';
205
219
  import { noteWrunLaneRevision } from './wrun-prefix-lanes.util.js';
220
+ import { wrunCandleEqual, wrunLaneValuesEqual } from './wrun-candle-equal.leaf.js';
206
221
  import { attachWrunFrames, WRUN_CELL_BLOCK_TOO_LARGE_CODE, wrunAbiVersion, wrunCellTupleWidths, wrunFramesOf, } from './wrun-pack.util.js';
207
222
  import { wrunCellBoundWords, wrunSheetCellBlockTuples } from './wrun-cell-capacity.leaf.js';
208
- import { LIVE_MAX_CELLS_PER_BAR, tradesBarOpenMs, tradesLaneLimits, tradesServedStartMs, } from '../../kscript-data/controls/live-trades-merge.util.js';
223
+ import { LIVE_MAX_CELLS_PER_BAR, SOURCE_HISTORY_AS_OF_FIELD, tradesBarOpenMs, tradesLaneLimits, tradesServedStartMs, } from '../../kscript-data/controls/live-trades-merge.util.js';
209
224
  import { isWrunAskedTapeSource, parseWrunTapeHistory, wrunTapeAcquisitionFloor, wrunTapeFloorSettings, wrunTapeFloorSettingWords, wrunTapeHistoryOf, } from './wrun-tape-source.util.js';
225
+ import { wrunCoinTapeFloorBroken, wrunCoinTapeGuardLow } from './wrun-tape-coins.util.js';
210
226
  import { serverNowMs } from '../auth/server-clock.util.js';
211
227
  import { wrunModuleReadsBarCount } from './wrun-bar-count.util.js';
212
228
  import { isWrunBatchedChildRefused, mountWrunChildOverlays } from './wrun-panel-mount.util.js';
213
229
  import { getWrunBrowserHost, wrunLiveOf, WrunLiveOrderError, WrunLiveSessionLostError, } from './wrun-host.service.js';
214
- import { getWrunOverlayLiveContext, isWrunOverlayRerunInFlight, onWrunOverlayLiveTeardown, rerunWrunOverlayForChartWave, setWrunChartRowsIdentityReader, setWrunLiveSheetReader, suspendWrunOverlayLiveSession, teardownWrunOverlay, withWrunOverlaySessionLock, wrunChartMarketIdentity, } from './wrun-overlay-drivers.util.js';
230
+ import { getWrunOverlayLiveContext, isWrunOverlayRerunInFlight, onWrunOverlayLiveTeardown, rerunWrunOverlayForChartWave, setWrunChartRowsIdentityReader, setWrunLazyWaveAbsorber, setWrunLiveSheetReader, suspendWrunOverlayLiveSession, teardownWrunOverlay, withWrunOverlaySessionLock, wrunChartMarketIdentity, } from './wrun-overlay-drivers.util.js';
231
+ import { composeWrunSessionSources, takeWrunCompositionRevisionKept, wrunSessionCompositionToken, wrunSessionLanesOfContext, } from './wrun-session-composition.util.js';
215
232
  import { withWrunOverlayExecutionMeasure } from './wrun-overlay-lifecycle.util.js';
216
233
  import { cutWrunReplayRows, cutWrunReplayRowsAfterApply } from './wrun-replay-rows.util.js';
217
234
  import { healWrunOverlayIfIdle, requestWrunCasualtyRebuilds } from './wrun-overlay-recovery.util.js';
@@ -236,6 +253,7 @@ import { evictWrunRetainedOutputRows, ringWrunRunRetained, trimWrunRetainedCanva
236
253
  import { projectWrunRefusal, retractWrunRefusal, wrunRefusalRetractionCount } from './wrun-refusal-surface.util.js';
237
254
  import { advanceWrunInputCarry, buildWrunInputTailRows, planWrunPinnedWires, wrunDeclaredSourceLanes, wrunDemandedSourceClass, wrunFormingBucketStart, wrunAskWirePieces, wrunChartIntervalKeyOf, wrunPinnedLegTierMs, wrunSourceVerdictWhole, wrunLaneAcquisitionIntervalMs, wrunLegRowHostBar, wrunLegRowVenue, wrunPinnedLegFetchSuffix, wrunTradeLegIntervals, wrunWireRowPieces, wrunChartCandleRows, wrunChartCandleRowsWithin, } from './wrun-source-rows.util.js';
238
255
  import { isWrunTradesLegLane, WRUN_TRADES_LANES, wrunTradesLegExtras } from './wrun-trades-lane.util.js';
256
+ import { WRUN_PINNED_LANE_SPECS, isWrunPinnedLaneId, wrunPinnedLaneExtras, wrunPinnedLaneOf, } from './wrun-pinned-lanes.util.js';
239
257
  import { drainWrunLiveIntake, dropWrunLiveQueuedBuckets, dropWrunLiveQueuedLegBuckets, enqueueWrunLiveFrame, markWrunLiveGap, noteWrunLiveIntakeEvent, setWrunLiveDrainRequester, takeWrunLiveGaps, wrunLaneAnswerCoversBucket, wrunLiveBucketTs, wrunLiveIntakeBacklogDue, wrunLiveIntakeStats, WRUN_LIVE_LANE_OF_SCRIPT_SOURCE, } from './wrun-live-intake.util.js';
240
258
  import { stampWrunLiveFrameOpra } from './wrun-cloud-opra-stamp.util.js';
241
259
  import { createWrunDownloadMeter, } from './wrun-download-meter.util.js';
@@ -245,6 +263,15 @@ const WRUN_BOOK_LIVE_UPDATE_MIN_MS = 1_000;
245
263
  /** Same pan-hold envelope as the kScript live drain. */
246
264
  const WRUN_LIVE_DRAIN_PAN_ACTIVE_MS = 750;
247
265
  const WRUN_LIVE_DRAIN_PAN_HOLD_MAX_MS = 2_500;
266
+ /** The settle gate's stillness (WRUN-PANBACK A2): a backward extension's episode hands off once the chart's view has
267
+ * not moved for this long on the motion clock (pan and zoom events, titan's probe), so a pointer-up pause this long
268
+ * rebuilds the pages so far and a shorter one stays inside the episode. The episode's own wake decides it, never the
269
+ * drain's cadence. */
270
+ export const WRUN_REBUILD_SETTLE_STILL_MS = 1_000;
271
+ /** The episode's wake polls this often (the pan-idle wait's poll) while titan's probe reads the button down (a held
272
+ * button stamps no pan event, so the motion clock the wake reads after the release is at most one poll old), and
273
+ * while the gate holds past the still period (a main fetch out, a run or a drain in flight). */
274
+ const WRUN_REBUILD_SETTLE_POLL_MS = 120;
248
275
  /** The reconcile window reaches this many bars behind the session watermark
249
276
  * (the kScript poll's 8-bar tail, V2_TECHNICAL_SOURCE_REFRESH_TAIL_BARS),
250
277
  * and a late point older than this many bars reseeds on its own gap. */
@@ -421,7 +448,7 @@ function readWrunLiveTickIdle(indicatorId) {
421
448
  const state = tickStates.get(indicatorId);
422
449
  if (state && (state.running || state.pending || state.timer !== undefined))
423
450
  return false;
424
- if (graceEndWakes.has(indicatorId))
451
+ if (graceEndWakes.has(indicatorId) || rebuildSettleWakes.has(indicatorId))
425
452
  return false;
426
453
  if (ledgers.get(indicatorId)?.inFlight)
427
454
  return false;
@@ -511,14 +538,20 @@ export function wrunLiveLanesOf(metadata) {
511
538
  /** Every lane a session's reconcile re-asks: the row builder's own lanes
512
539
  * the sheet declares, then the trades leg lanes the full run asked (kit 0.77.0:
513
540
  * the ones the session holds a buffer for, `context.tradeLegRows`; a leg never
514
- * asked is never re-asked), then the registry poll lane instances the full run
515
- * planned (`context.pollLanes`), then its row lane instances
516
- * (`context.rowLanes`), in the full run's order. */
541
+ * asked is never re-asked), then the pinned lanes it asked (U9e: a book, oi,
542
+ * funding or liquidations input pinned to another market, by the buffers
543
+ * `context.pinnedLaneRows` holds; each re-asked on its own market, an oi lane's
544
+ * forming bucket by the same poll as the chart's own oi), then the registry
545
+ * poll lane instances the full run planned (`context.pollLanes`), then its row
546
+ * lane instances (`context.rowLanes`), in the full run's order. */
517
547
  export function wrunLiveLanesOfContext(context) {
518
- const tradeLegs = [...wrunDeclaredSourceLanes(context.metadata)].filter((lane) => isWrunTradesLegLane(lane) && context.tradeLegRows?.[lane] !== undefined);
548
+ const declared = [...wrunDeclaredSourceLanes(context.metadata)];
549
+ const tradeLegs = declared.filter((lane) => isWrunTradesLegLane(lane) && context.tradeLegRows?.[lane] !== undefined);
550
+ const pinnedLanes = declared.filter((lane) => isWrunPinnedLaneId(lane) && context.pinnedLaneRows?.[lane] !== undefined);
519
551
  return [
520
552
  ...wrunLiveLanesOf(context.metadata),
521
553
  ...tradeLegs,
554
+ ...pinnedLanes,
522
555
  ...(context.pollLanes ?? []).map((instance) => instance.key),
523
556
  ...(context.rowLanes ?? []).map((instance) => instance.key),
524
557
  ];
@@ -839,7 +872,9 @@ export function requestWrunOverlayLiveDrain(indicatorId) {
839
872
  const rearmedSessions = new WeakSet();
840
873
  /**
841
874
  * Contract C7: re-arm the overlay's deferred drain on a prefix run's outcome
842
- * (landed, rejected, or skipped after planning). A frame that arrived while
875
+ * (landed, rejected, or skipped after planning), and on a warm switch's
876
+ * adoption (wrun-overlay-run.util adoptWrunParkedLiveSession), whose
877
+ * `session-start` drain can meet the adoption's own run in flight. A frame that arrived while
843
878
  * the prefix ran woke a drain the in-flight gate turned away
844
879
  * (`runWrunOverlayLiveTick` returns before its planner while any executor run
845
880
  * is active), and the scheduler then dropped its record with nothing pending,
@@ -862,6 +897,23 @@ export function rearmWrunLiveTickDrain(chartIndex, indicatorId) {
862
897
  rearmedSessions.add(context);
863
898
  requestWrunOverlayLiveDrain(indicatorId);
864
899
  }
900
+ /**
901
+ * The rows a session's evaluated bars read moved from `fromTs` on, with no lane point to say so: the host's session
902
+ * composition changed owner (web: an order-flow hand-back, or a new seam), so the bars it evaluated from the old
903
+ * seam read rows that are no longer the overlay's. It is the revised closed bar's obligation (`closedBarRevisions`):
904
+ * the next drain reseeds over the buffers, composed as they stand then, and no fetch is made. A session with no bar
905
+ * evaluated at or past `fromTs` owes nothing (the tail re-sends its forming bar anyway). Answers whether it owed.
906
+ */
907
+ export function reviseWrunOverlayLiveFrom(chartIndex, indicatorId, fromTs) {
908
+ const context = getWrunOverlayLiveContext(indicatorId);
909
+ if (!context || context.chartIndex !== chartIndex || !Number.isFinite(fromTs) || !(fromTs < context.lastRowTs)) {
910
+ return false;
911
+ }
912
+ context.dirtyFromTs = minTs(context.dirtyFromTs, fromTs);
913
+ closedBarRevisions.set(context, minTs(closedBarRevisions.get(context), fromTs));
914
+ requestWrunOverlayLiveDrain(indicatorId);
915
+ return true;
916
+ }
865
917
  /** Whether the drain that just ran met a run in flight while the overlay's session waits on it: a session a
866
918
  * prefix run re-armed, or a source-fed one with frames queued (the paint its install owes included). It owes
867
919
  * one more drain. */
@@ -1265,6 +1317,8 @@ function dropWrunLiveTickState(indicatorId) {
1265
1317
  ledgers.delete(indicatorId);
1266
1318
  dropWrunPinnedCloseTimer(indicatorId);
1267
1319
  dropWrunGraceEndWake(indicatorId);
1320
+ dropWrunRebuildSettleWake(indicatorId);
1321
+ wrunRunStarts.delete(indicatorId);
1268
1322
  if (chartIndex !== undefined) {
1269
1323
  wrunChartHostEnv().chart.clearLiveRefreshGate(chartIndex, indicatorId);
1270
1324
  wrunChartHostEnv().chart.clearLiveCoalesceWindow(chartIndex, indicatorId);
@@ -1433,8 +1487,13 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1433
1487
  // generations, so skip it (the rerun's fresh context resumes ticking; a
1434
1488
  // prefix run keeps the context and re-arms the drain on its outcome,
1435
1489
  // rearmWrunLiveTickDrain).
1436
- if (isWrunOverlayRerunInFlight(indicatorId))
1490
+ if (isWrunOverlayRerunInFlight(indicatorId)) {
1491
+ // An open rebuild episode (WRUN-PANBACK A2) keeps its wake coming past the run: a run that leaves this context
1492
+ // standing (a page, a failure) has the episode's pages handed off by the wake, with no frame to wake it.
1493
+ if (context.rebuildSettleSinceMs !== undefined)
1494
+ armWrunRebuildSettleWake(context);
1437
1495
  return;
1496
+ }
1438
1497
  // Past the gate: the drain a prefix's outcome re-armed is this one.
1439
1498
  rearmedSessions.delete(context);
1440
1499
  if (context.liveSuspended)
@@ -1545,7 +1604,8 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1545
1604
  rowLaneMoved: wrunRowLaneMovedInstance(context.rowLanes, context.acquisition) !== undefined ||
1546
1605
  wrunPollLaneMovedInstance(context.pollLanes, context.acquisition) !== undefined,
1547
1606
  reseedBudgetOpen: reseedBudgetOpen(ledger),
1548
- pollFloorBars: wrunReconcileFloorBars(chartMetadata?.exchange, intervalMs),
1607
+ // Keyed on the venue the chart's candles ride (a stock Trades chart's delayed tape, never POLYGON).
1608
+ pollFloorBars: wrunReconcileFloorBars(wrunChartStreamExchange(chartMetadata), intervalMs),
1549
1609
  nowMs,
1550
1610
  paceNowMs,
1551
1611
  etfFlowAnsweredAtMs: etfFlowAnsweredAt.get(context),
@@ -1557,6 +1617,11 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1557
1617
  });
1558
1618
  if (plan.kind === 'compute' && plan.reseedHeld === true)
1559
1619
  holdWrunReseedForPage(context);
1620
+ // A held backward extension's episode (WRUN-PANBACK A2) ends with any other plan: a prefix landed the page, the
1621
+ // session reaches the chart's first row again, or another rebuild hands off at once below.
1622
+ const backwardRebuild = plan.kind === 'rebuild' && plan.reason === 'history' && plan.extension === 'backward';
1623
+ if (!backwardRebuild)
1624
+ clearWrunRebuildSettle(context);
1560
1625
  if (plan.kind === 'rebuild') {
1561
1626
  // The rebuild goes to the overlay's full-run driver (it re-opens the
1562
1627
  // session), ONCE per chart shape: a failed rerun keeps this context
@@ -1566,10 +1631,30 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1566
1631
  // successful rerun installs a fresh context, which carries no latch;
1567
1632
  // the chart moving to another shape hands off again.
1568
1633
  const shape = `${chartIdentity}|${firstTs}|${plan.reason}`;
1569
- if (context.rebuildHandoffShape !== shape) {
1634
+ if (context.rebuildHandoffShape === shape)
1635
+ return;
1636
+ if (!backwardRebuild) {
1570
1637
  context.rebuildHandoffShape = shape;
1571
1638
  noteWrunLiveRebuild(ledger, indicatorId);
1639
+ return;
1640
+ }
1641
+ // The settle gate (WRUN-PANBACK A2): a pan-back page is rarely the last one, and every handoff was a whole
1642
+ // rebuild whose result landed mid-drag (three pages in one 4.3 s gesture bought three, 2026-11-01 dump). While
1643
+ // the gesture is live, the view moved less than WRUN_REBUILD_SETTLE_STILL_MS ago or the main candle fetch is
1644
+ // out, the handoff waits; once all are quiet (or at the one ceiling) ONE handoff covers every page the episode
1645
+ // saw, carrying how long it held, and the latch takes the chart's shape at that handoff. The episode's wake
1646
+ // makes that handoff when no drain comes first; the two never decide at once (wrunRebuildSettleBusy).
1647
+ const since = context.rebuildSettleSinceMs;
1648
+ const atCeiling = since !== undefined && paceNowMs - since >= HEAVY_APPLY_GESTURE_CEILING_MS;
1649
+ const cause = atCeiling ? undefined : await wrunRebuildSettleCause(context.chartIndex);
1650
+ // A run that installed a fresh session (or a teardown) while the fetch state was read owns the overlay now.
1651
+ if (!wrunLiveContextCurrent(context, generation))
1652
+ return;
1653
+ if (cause !== undefined) {
1654
+ holdWrunBackwardRebuild(context, firstTs, paceNowMs, cause);
1655
+ return;
1572
1656
  }
1657
+ handOffWrunBackwardRebuild(context, ledger, firstTs, shape, paceNowMs, atCeiling ? 'ceiling' : 'quiet');
1573
1658
  return;
1574
1659
  }
1575
1660
  if (plan.kind === 'reseed') {
@@ -1848,8 +1933,14 @@ export async function integrateWrunOverlayLiveFrame(indicatorId, frame, cellRows
1848
1933
  : wrunHandlesOf(context.outputRows);
1849
1934
  if (handles !== undefined)
1850
1935
  attachWrunHandles(outputRows, handles);
1851
- if (frame.frames !== undefined)
1852
- attachWrunFrames(outputRows, frame.frames);
1936
+ // The frames snapshot replaces the session's (a frame without one keeps it): a frame the source did not take as
1937
+ // its newest snapshot carries none, and the session's held one IS the newer, so the frame-backed drawings keep
1938
+ // drawing from it instead of dropping for a tick, a fix of that tick's picture, and a repaint of the session (a
1939
+ // style save) builds its frame children from it. `framesReplaced` still reads the frame's own, so the children
1940
+ // stay as mounted.
1941
+ const frames = frame.frames ?? wrunFramesOf(context.outputRows);
1942
+ if (frames !== undefined)
1943
+ attachWrunFrames(outputRows, frames);
1853
1944
  // The run-level strategy output replaces the session's (a frame without one keeps it).
1854
1945
  const strategy = isWrunStrategyOutput(frame.strategy) ? frame.strategy : wrunStrategyOf(context.outputRows);
1855
1946
  if (strategy !== undefined)
@@ -1876,6 +1967,8 @@ export async function integrateWrunOverlayLiveFrame(indicatorId, frame, cellRows
1876
1967
  hostStartMs,
1877
1968
  cellRowsOf: () => cellRowsOf(ohlcvRows),
1878
1969
  });
1970
+ // A held chart took the frame's apply as a deferred unit (integrateWrunLiveTail): the frame is taken, so its
1971
+ // callers (the replay lane's cutoff) read it as applied rather than reopening the session.
1879
1972
  outcome = 'applied';
1880
1973
  });
1881
1974
  return outcome;
@@ -2037,11 +2130,258 @@ function handWrunLiveOverCapBack(context, ledger, lane, reason) {
2037
2130
  }
2038
2131
  /** A rebuild handoff to the full-run driver, counted here and in the intake's
2039
2132
  * stats. Its reason is 'live-rebuild': the session cannot extend, so the run
2040
- * is never merged as a range refresh nor skipped as a duplicate range. */
2041
- function noteWrunLiveRebuild(ledger, indicatorId) {
2133
+ * is never merged as a range refresh nor skipped as a duplicate range. A
2134
+ * backward extension's handoff carries how long its settle gate held
2135
+ * (`gestureHeldMs`, WRUN-PANBACK A2): the run's install hold waits only the
2136
+ * rest of the one ceiling. */
2137
+ function noteWrunLiveRebuild(ledger, indicatorId, gestureHeldMs) {
2042
2138
  ledger.stats.rebuilds += 1;
2043
2139
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'rebuild' });
2044
- void rerunWrunOverlayForChartWave(indicatorId, { reason: 'live-rebuild' });
2140
+ void rerunWrunOverlayForChartWave(indicatorId, {
2141
+ reason: 'live-rebuild',
2142
+ ...(gestureHeldMs !== undefined ? { gestureHeldMs } : {}),
2143
+ });
2144
+ }
2145
+ /** Why a backward extension's handoff waits now (WRUN-PANBACK A2): the chart is moving (`pan`, read first, in the
2146
+ * caller's task: its gesture is live, or its view moved less than WRUN_REBUILD_SETTLE_STILL_MS ago, so a pointer-up
2147
+ * pause shorter than that stays inside the pan), else its main candle fetch is in flight (`main-fetch`: a page is
2148
+ * still landing); undefined when all are quiet. A fetch state that cannot be read reads quiet. */
2149
+ async function wrunRebuildSettleCause(chartIndex) {
2150
+ if (wrunChartHostEnv().chart.isGestureLive(chartIndex) ||
2151
+ wrunSinceViewportMotionMs(chartIndex) < WRUN_REBUILD_SETTLE_STILL_MS) {
2152
+ return 'pan';
2153
+ }
2154
+ try {
2155
+ const dataFetching = await wrunChartHostEnv().chart.loadDataFetching();
2156
+ return dataFetching.isMainCandleFetchInFlight(chartIndex) === true ? 'main-fetch' : undefined;
2157
+ }
2158
+ catch {
2159
+ return undefined;
2160
+ }
2161
+ }
2162
+ /** Milliseconds since the chart's view last moved on the motion clock (its pan and zoom events and titan's probe: a
2163
+ * live probe reads as moving now, 0), Infinity when it never moved. */
2164
+ function wrunSinceViewportMotionMs(chartIndex) {
2165
+ const motionAt = wrunChartHostEnv().chart.motionAt(chartIndex);
2166
+ return motionAt > 0 ? Math.max(0, Date.now() - motionAt) : Number.POSITIVE_INFINITY;
2167
+ }
2168
+ /** Per overlay, the wake an open episode armed (WRUN-PANBACK A2): it hands the episode off itself once the view is
2169
+ * still and the main fetch quiet (or re-arms), whether or not a frame or a drain comes. Dropped with the episode and
2170
+ * on teardown. */
2171
+ const rebuildSettleWakes = new Map();
2172
+ /** Hold a backward extension's handoff (WRUN-PANBACK A2): the episode's start stamped once (the pacing clock), the
2173
+ * page added to the ones the handoff will collapse and rung once per page, and the episode's wake armed. */
2174
+ function holdWrunBackwardRebuild(context, firstTs, paceNowMs, cause) {
2175
+ const { chartIndex, indicatorId } = context;
2176
+ if (openWrunRebuildEpisode(context, firstTs, paceNowMs)) {
2177
+ wrunChartHostEnv().diagnostics.debug('wrun-rebuild-settle-held', { chartIndex, indicatorId, firstTs, cause });
2178
+ }
2179
+ }
2180
+ /** Open (or extend) a backward extension's episode (WRUN-PANBACK A2): its start stamped once, the page added to the
2181
+ * ones its handoff collapses, its wake armed. True when the page is new to the episode. */
2182
+ function openWrunRebuildEpisode(context, firstTs, paceNowMs) {
2183
+ context.rebuildSettleSinceMs ??= paceNowMs;
2184
+ const pages = (context.rebuildSettlePages ??= new Set());
2185
+ const added = !pages.has(firstTs);
2186
+ pages.add(firstTs);
2187
+ armWrunRebuildSettleWake(context);
2188
+ return added;
2189
+ }
2190
+ /** Arm an open episode's wake (WRUN-PANBACK A2): for the moment the view will have been still
2191
+ * WRUN_REBUILD_SETTLE_STILL_MS on the motion clock, else one poll on (titan's probe reads the button down, moving now,
2192
+ * or the gate holds past that moment). An armed wake stands: it fires no later than a deadline that motion moved on,
2193
+ * and re-arms for it. */
2194
+ function armWrunRebuildSettleWake(context) {
2195
+ const { chartIndex, indicatorId } = context;
2196
+ if (rebuildSettleWakes.has(indicatorId))
2197
+ return;
2198
+ const sinceMotionMs = wrunSinceViewportMotionMs(chartIndex);
2199
+ const delayMs = sinceMotionMs > 0 && sinceMotionMs < WRUN_REBUILD_SETTLE_STILL_MS
2200
+ ? WRUN_REBUILD_SETTLE_STILL_MS - sinceMotionMs
2201
+ : WRUN_REBUILD_SETTLE_POLL_MS;
2202
+ rebuildSettleWakes.set(indicatorId, setTimeout(() => {
2203
+ rebuildSettleWakes.delete(indicatorId);
2204
+ runWrunRebuildSettleWake(indicatorId).catch((error) => {
2205
+ console.warn(`[wrun] rebuild settle wake failed for '${indicatorId}' (the next drain decides):`, error);
2206
+ });
2207
+ }, delayMs));
2208
+ }
2209
+ /**
2210
+ * An open episode's wake (WRUN-PANBACK A2) decides the handoff itself. The drain read the gate on its own cadence: it
2211
+ * woke 400 ms after the last pan (its pan hold), inside the 600 ms linger, and then not again for about a second, so a
2212
+ * pointer-up pause shorter than about 1.4 s was never seen and one episode spanned every drag until the final stop
2213
+ * (field 2026-11-01: 17 s without three scripts over 1,000 new bars, 14.4 s of it after the last page landed). The
2214
+ * cheap gates go first and read none of the chart's rows: a drain mid-body or a run in flight that computes the
2215
+ * episode's pages (`wrunRebuildSettleBusy`), then the gate's cause (the gesture, the motion clock, the main candle
2216
+ * fetch). While one holds the wake only re-arms, at the poll for a fetch (the host gives no completion
2217
+ * signal), so a slow page costs one flag read a poll. Once all pass, ONE read of the chart's rows and the planner
2218
+ * hands the episode off (the latch, the generation). What only the drain decides goes to the drain, as before: a
2219
+ * session it plans under gates of its own, a page no longer read as a backward extension, a shape already handed off.
2220
+ */
2221
+ async function runWrunRebuildSettleWake(indicatorId) {
2222
+ const context = getWrunOverlayLiveContext(indicatorId);
2223
+ const since = context?.rebuildSettleSinceMs;
2224
+ // The episode ended (a handoff, another plan, a fresh run's context) or the overlay left.
2225
+ if (context === undefined || since === undefined)
2226
+ return;
2227
+ const { chartIndex, generation } = context;
2228
+ // A replay, a suspended, source-fed, paused or tripped session, the hidden hold and the settings oracle's freeze.
2229
+ if (wrunLiveHeld ||
2230
+ context.replay === true ||
2231
+ context.liveSuspended ||
2232
+ wrunSourceFedContexts.has(context) ||
2233
+ wrunChartHostEnv().clock.pageHidden() ||
2234
+ wrunOverlayPausedOrTripped(chartIndex, indicatorId)) {
2235
+ requestWrunOverlayLiveDrain(indicatorId);
2236
+ return;
2237
+ }
2238
+ if (wrunRebuildSettleBusy(context)) {
2239
+ armWrunRebuildSettleWake(context);
2240
+ return;
2241
+ }
2242
+ const paceNowMs = clock();
2243
+ const atCeiling = paceNowMs - since >= HEAVY_APPLY_GESTURE_CEILING_MS;
2244
+ const cause = atCeiling ? undefined : await wrunRebuildSettleCause(chartIndex);
2245
+ // The session moved on during the read: a fresh run's context, a teardown, the episode handed off or ended.
2246
+ if (!wrunLiveContextCurrent(context, generation) || context.rebuildSettleSinceMs !== since)
2247
+ return;
2248
+ // Moving (the button down, motion since the wake was armed), a fetch out, or a drain or a run started meanwhile.
2249
+ if (cause !== undefined || wrunRebuildSettleBusy(context)) {
2250
+ armWrunRebuildSettleWake(context);
2251
+ return;
2252
+ }
2253
+ const chartRows = wrunChartCandleRows(wrunChartHostEnv().chart.instance(chartIndex));
2254
+ const firstTs = chartRows.length > 0 ? Number(chartRows[0][0]) : undefined;
2255
+ const chartIdentity = wrunChartMarketIdentity(wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata);
2256
+ const shape = `${chartIdentity}|${firstTs}|history`;
2257
+ if (firstTs === undefined ||
2258
+ context.rebuildHandoffShape === shape ||
2259
+ !wrunBackwardExtensionNow(context, chartRows, chartIdentity, paceNowMs)) {
2260
+ requestWrunOverlayLiveDrain(indicatorId);
2261
+ return;
2262
+ }
2263
+ const handoffCause = atCeiling ? 'ceiling' : 'quiet';
2264
+ handOffWrunBackwardRebuild(context, ledgerFor(indicatorId), firstTs, shape, paceNowMs, handoffCause);
2265
+ }
2266
+ /** Whether the settle wake waits (WRUN-PANBACK A2): a drain is mid-body for the overlay (the ledger's `inFlight`: it
2267
+ * decides the episode itself, so the two never decide at once), or a run in flight computes the episode's pages (it
2268
+ * started on this market at or before the oldest page, so the session it installs holds them all and a handoff now
2269
+ * would rebuild them twice; a run whose start was not noted counts as one). A run that started before the pages loaded
2270
+ * never computes them, whether it still computes or holds its install for the gesture and the pacer (the last
2271
+ * episode's rebuild, field 2026-11-02: the final stop waited 1.4 to 1.7 s on those installs): the handoff goes now,
2272
+ * and the executor queues it as that run's one follow-up. */
2273
+ function wrunRebuildSettleBusy(context) {
2274
+ const { chartIndex, indicatorId } = context;
2275
+ if (ledgers.get(indicatorId)?.inFlight === true)
2276
+ return true;
2277
+ if (!isWrunOverlayRerunInFlight(indicatorId))
2278
+ return false;
2279
+ const start = wrunRunStarts.get(indicatorId);
2280
+ const pages = context.rebuildSettlePages;
2281
+ if (start === undefined || start.chartIndex !== chartIndex || pages === undefined || pages.size === 0)
2282
+ return true;
2283
+ const market = wrunChartMarketIdentity(wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata);
2284
+ return start.market !== market || start.firstTs <= Math.min(...pages);
2285
+ }
2286
+ /**
2287
+ * The lazy wave's second dispatcher, absorbed (WRUN-PANBACK A2): the chart's pan wave asks every overlay for a run per
2288
+ * lazy page, so a two-page gesture still bought two full runs per script beside the settle gate's one rebuild. The
2289
+ * executor offers each whole wave here before it queues or starts anything (`setWrunLazyWaveAbsorber`). While the
2290
+ * overlay's episode is open, or the chart's gesture is live, a wave for a page the gate will rebuild (the drain would
2291
+ * plan this session's rebuild as a backward extension now, under a latch that has not handed the shape off yet) is
2292
+ * taken in: the episode opens if none is yet, the page joins it, the request is rung, and the episode's one handoff
2293
+ * computes its rows. Anything else runs as before: an idle gesture with no episode, no session on this chart to
2294
+ * rebuild (none, a replay, a held or a source-fed one), a page the planner leaves to its prefix wave or reads otherwise.
2295
+ */
2296
+ function absorbWrunLazyWave(chartIndex, indicatorId, window) {
2297
+ const context = getWrunOverlayLiveContext(indicatorId);
2298
+ if (context === undefined || context.chartIndex !== chartIndex)
2299
+ return false;
2300
+ if (context.replay === true || context.liveSuspended || wrunSourceFedContexts.has(context))
2301
+ return false;
2302
+ if (context.rebuildSettleSinceMs === undefined && !wrunChartHostEnv().chart.isGestureLive(chartIndex))
2303
+ return false;
2304
+ const chartRows = wrunChartCandleRows(wrunChartHostEnv().chart.instance(chartIndex));
2305
+ if (chartRows.length === 0)
2306
+ return false;
2307
+ const firstTs = Number(chartRows[0][0]);
2308
+ const chartIdentity = wrunChartMarketIdentity(wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata);
2309
+ // A shape the latch handed off already never hands off again: its wave runs, as before.
2310
+ if (context.rebuildHandoffShape === `${chartIdentity}|${firstTs}|history`)
2311
+ return false;
2312
+ const paceNowMs = clock();
2313
+ if (!wrunBackwardExtensionNow(context, chartRows, chartIdentity, paceNowMs))
2314
+ return false;
2315
+ openWrunRebuildEpisode(context, firstTs, paceNowMs);
2316
+ wrunChartHostEnv().diagnostics.debug('wrun-rebuild-absorbed-wave', {
2317
+ chartIndex,
2318
+ indicatorId,
2319
+ firstTs,
2320
+ ...(window !== undefined ? { demandSpan: { fromMs: window.fromMs, toMs: window.toMs } } : {}),
2321
+ });
2322
+ return true;
2323
+ }
2324
+ /** Whether the drain would plan this session's rebuild as a backward extension now: the planner itself over the
2325
+ * chart's rows (a session at another interval: its run bars and its chart clock), with no gap and nothing folded, so
2326
+ * the waves the gate absorbs are the pages it holds. Reads only: the prefix grace's first sight is read, never
2327
+ * stamped. */
2328
+ function wrunBackwardExtensionNow(context, chartRows, chartIdentity, paceNowMs) {
2329
+ const firstTs = Number(chartRows[0][0]);
2330
+ const lastTs = Number(chartRows[chartRows.length - 1][0]);
2331
+ const runSession = wrunRunIntervalSessionOf(context);
2332
+ const seen = prefixPageSeen.get(context);
2333
+ const plan = decideWrunLiveTickPlan({
2334
+ context,
2335
+ mainRows: runSession ? wrunRunIntervalComputeRows(runSession.run, runSession.rows, lastTs) : chartRows,
2336
+ gaps: [],
2337
+ drained: { dirtyFromTs: null },
2338
+ chartIdentity,
2339
+ rowLaneMoved: wrunRowLaneMovedInstance(context.rowLanes, context.acquisition) !== undefined ||
2340
+ wrunPollLaneMovedInstance(context.pollLanes, context.acquisition) !== undefined,
2341
+ paceNowMs,
2342
+ prefixPageSeenAtMs: firstTs < context.firstRowTs ? (seen?.chartFirstTs === firstTs ? seen.atMs : paceNowMs) : undefined,
2343
+ ...(runSession ? { runClock: wrunLiveRunClockOf(runSession, context, chartRows) } : {}),
2344
+ });
2345
+ return plan.kind === 'rebuild' && plan.reason === 'history' && plan.extension === 'backward';
2346
+ }
2347
+ /** The one handoff of a backward extension's episode (WRUN-PANBACK A2), the drain's and the episode wake's: how long
2348
+ * the gate held (0 when it never did), rung with the pages it collapses (the held ones and this one), why it went now
2349
+ * and how long the view had been still (`sinceMotionMs`: 0 while it moves, at the ceiling; absent when the chart never
2350
+ * moved); the episode cleared, the latch taking the chart's shape, and ONE `live-rebuild` handed to the full-run
2351
+ * driver carrying the hold. */
2352
+ function handOffWrunBackwardRebuild(context, ledger, firstTs, shape, paceNowMs, cause) {
2353
+ const since = context.rebuildSettleSinceMs;
2354
+ const heldMs = since !== undefined ? Math.max(0, paceNowMs - since) : 0;
2355
+ const pages = new Set(context.rebuildSettlePages ?? []);
2356
+ pages.add(firstTs);
2357
+ const sinceMotionMs = wrunSinceViewportMotionMs(context.chartIndex);
2358
+ wrunChartHostEnv().diagnostics.debug('wrun-rebuild-handoff', {
2359
+ chartIndex: context.chartIndex,
2360
+ indicatorId: context.indicatorId,
2361
+ firstTs,
2362
+ heldMs,
2363
+ pagesCollapsed: pages.size,
2364
+ cause,
2365
+ ...(Number.isFinite(sinceMotionMs) ? { sinceMotionMs: Math.round(sinceMotionMs) } : {}),
2366
+ });
2367
+ clearWrunRebuildSettle(context);
2368
+ context.rebuildHandoffShape = shape;
2369
+ noteWrunLiveRebuild(ledger, context.indicatorId, heldMs);
2370
+ }
2371
+ /** End a backward extension's episode (WRUN-PANBACK A2): its fields and its wake go. */
2372
+ function clearWrunRebuildSettle(context) {
2373
+ if (context.rebuildSettleSinceMs === undefined && context.rebuildSettlePages === undefined)
2374
+ return;
2375
+ delete context.rebuildSettleSinceMs;
2376
+ delete context.rebuildSettlePages;
2377
+ dropWrunRebuildSettleWake(context.indicatorId);
2378
+ }
2379
+ function dropWrunRebuildSettleWake(indicatorId) {
2380
+ const wake = rebuildSettleWakes.get(indicatorId);
2381
+ if (wake === undefined)
2382
+ return;
2383
+ clearTimeout(wake);
2384
+ rebuildSettleWakes.delete(indicatorId);
2045
2385
  }
2046
2386
  /** A worker death's rebuild handoff to the casualty seam
2047
2387
  * (wrun-overlay-recovery.util), counted like any rebuild. The death's record
@@ -2290,8 +2630,22 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2290
2630
  // evaluation clock is this drain's: a pinned leg's candle that closed
2291
2631
  // since the last block is admitted by the re-sent forming row (the roll
2292
2632
  // re-sends it, so the close-confirmed row sees its confirmed views).
2293
- const sources = laneSourcesOf(context, ohlcvRows);
2294
- const clock = { intervalMs: wrunLiveIntervalMs(context, ohlcvRows), nowMs: Date.now() };
2633
+ // The session's as-of rides beside the drain's now (wrun-history-as-of.util): the carry already holds each
2634
+ // delivered stream's backlog start, so a tail reads it only through the session's own record.
2635
+ const clock = {
2636
+ intervalMs: wrunLiveIntervalMs(context, ohlcvRows),
2637
+ nowMs: serverNowMs(),
2638
+ historyAsOfMs: context.historyAsOfMs,
2639
+ };
2640
+ // The lanes the tail reads, composed where the host's session owns the overlay (wrun-session-composition.util):
2641
+ // the buffers stay OpenMarket's, and the token read here guards the answer below.
2642
+ const composition = composeWrunSessionSources({
2643
+ chartIndex: context.chartIndex,
2644
+ indicatorId,
2645
+ intervalMs: clock.intervalMs,
2646
+ lanes: wrunSessionLanesOfContext(context),
2647
+ }, laneSourcesOf(context, ohlcvRows));
2648
+ const sources = composition.sources;
2295
2649
  const tailRows = buildWrunInputTailRows(context.metadata, sources, tailFromTs, context.carrySeed, clock);
2296
2650
  if (tailRows.length === 0)
2297
2651
  return;
@@ -2348,6 +2702,14 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2348
2702
  // generation: nothing of it is touched.
2349
2703
  if (!wrunLiveContextCurrent(context, generation))
2350
2704
  return;
2705
+ // The session's composition moved while the block computed (an owner change): the answer read rows that are
2706
+ // no longer the overlay's. Nothing of it lands (no outputs, no watermark, no carry), and the drain runs again
2707
+ // over the composition as it stands; a roll the guest already took answers the next block with its order
2708
+ // error, whose reseed rebuilds over the buffers.
2709
+ if (composition.token !== wrunSessionCompositionToken(indicatorId)) {
2710
+ armWrunLiveDrain(context, false);
2711
+ return;
2712
+ }
2351
2713
  newestTs = tailRows[tailRows.length - 1].ts;
2352
2714
  outputRows = mergeWrunOutputTail(context.outputRows, tailOutputs, tailFromTs);
2353
2715
  // The block's answer carries the whole live handle set, the whole
@@ -2360,8 +2722,11 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2360
2722
  if (tickStrategy !== undefined)
2361
2723
  attachWrunStrategy(outputRows, tickStrategy);
2362
2724
  tickFrames = wrunFramesOf(tailOutputs);
2363
- if (tickFrames !== undefined)
2364
- attachWrunFrames(outputRows, tickFrames);
2725
+ // A block without a frames snapshot keeps the session's, the socket frame's rule: the rows never lose the
2726
+ // snapshot a repaint of the session builds its frame children from (`framesReplaced` reads the block's own).
2727
+ const frames = tickFrames ?? wrunFramesOf(context.outputRows);
2728
+ if (frames !== undefined)
2729
+ attachWrunFrames(outputRows, frames);
2365
2730
  // The run budget (design 5): past the session's cap its oldest rows go, so the merged result never passes
2366
2731
  // the worker's or the integrated-row budget; the whole window repaints once per crossing.
2367
2732
  const retained = wrunLiveRetainedRows(context, outputRows);
@@ -2429,6 +2794,59 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2429
2794
  * socket row source's live frames (`integrateWrunOverlayLiveFrame`) both end here, so a frame costs
2430
2795
  * the cloud lane what a block costs the browser lane. Runs under the overlay's session lock. */
2431
2796
  async function integrateWrunLiveTail(tail) {
2797
+ if (deferWrunLiveTailWhileHeld(tail))
2798
+ return 'deferred';
2799
+ await integrateWrunLiveTailNow(tail);
2800
+ return 'applied';
2801
+ }
2802
+ /**
2803
+ * The live hold (LIVE-UPDATES-WAIT): while the chart is held (the engine's gesture live hold or motion mode, or its
2804
+ * release backlog still draining) the WHOLE apply phase of this integrate waits in the engine's ordered ingest log as
2805
+ * one host unit owned by the overlay: the parent's live ladder, the child overlays (their pack wait included), the
2806
+ * presentation, the painted watermark and repaint bookkeeping, and the failure path. Nothing of it runs now, so no
2807
+ * mounted row (the parent's or a lower-pane child's) moves under the hold and nothing is presented before its rows
2808
+ * land. The door is the chart's own `enqueueHeldHostApply` (the one gesture-motion-host.util `enqueueHeldOverlayApply`
2809
+ * calls; the package reaches the chart, not that module): it answers false when nothing is held, and inside a
2810
+ * replayed unit, and the integrate then runs in the tick as before. True when the log took the unit.
2811
+ */
2812
+ function deferWrunLiveTailWhileHeld(tail) {
2813
+ const door = tail.tc.enqueueHeldHostApply;
2814
+ if (typeof door !== 'function')
2815
+ return false;
2816
+ try {
2817
+ return door.call(tail.tc, () => replayWrunLiveTail(tail), tail.context.indicatorId) === true;
2818
+ }
2819
+ catch {
2820
+ return false;
2821
+ }
2822
+ }
2823
+ /**
2824
+ * The held unit at the replay. The tick's apply gates are read again (the context and its generation, replay, pause
2825
+ * or a tripped guard, the market identity, protection, the pane budget), and the chart must still be the tick's chart
2826
+ * mounting the tick's meta under the overlay id (a remount without a generation bump hands a fresh meta): a failing
2827
+ * recheck drops the unit, nothing applied. The integrate starts inside the engine's drain, in order with the overlay's
2828
+ * other held units; it does not take the session lock (that wait is a promise, and the parent's apply must land inside
2829
+ * the unit), and a tick holding the lock meanwhile defers its own apply behind it while the engine still drains. A
2830
+ * failure runs the tick's own failure path: the repaint stays owed and a classified refusal is said once.
2831
+ */
2832
+ function replayWrunLiveTail(tail) {
2833
+ const { context, generation, tc, meta, ledger } = tail;
2834
+ const { chartIndex, indicatorId } = context;
2835
+ if (!wrunLiveTickEligible(context, generation))
2836
+ return;
2837
+ const current = wrunChartHostEnv().chart.instance(chartIndex);
2838
+ const mounted = current?.metadata?.find((candidate) => candidate.id === indicatorId);
2839
+ if (current !== tc || mounted !== meta)
2840
+ return;
2841
+ // The tick's clock stopped with the tick: the replay is its own apply sample.
2842
+ const mainClock = new MainThreadClock();
2843
+ void integrateWrunLiveTailNow({ ...tail, mainClock, hostStartMs: mainClock.read() }).catch((error) => {
2844
+ console.warn(`[wrun] held live apply failed for '${indicatorId}' (keeping the last rendered result):`, error);
2845
+ void noteWrunLiveTickRefusal(context, ledger, generation, error);
2846
+ });
2847
+ }
2848
+ /** The integrate itself, now (`integrateWrunLiveTail` decides whether it waits for the hold first). */
2849
+ async function integrateWrunLiveTailNow(tail) {
2432
2850
  const { context, ledger, generation, tc, meta, outputRows, newestTs, tailFromTs, framesReplaced, holdsResult, evicted = false, runSession, mainClock, hostStartMs, cellRowsOf, } = tail;
2433
2851
  const { indicatorId } = context;
2434
2852
  // An eviction moved the session's first row: no tail of the shown result describes the mount any more.
@@ -2475,9 +2893,9 @@ async function integrateWrunLiveTail(tail) {
2475
2893
  // ran with, so a tick never flips a `{{label}}` back to the declared ones.
2476
2894
  texts: wrunTextParamValuesFromSettings(context.metadata, meta.settings),
2477
2895
  // And the legend note (wrun-draft-legend-note.util: the draft's word, an OPRA chain's served
2478
- // tier off the session's chain acquisition, a Cloud session's off its newest frame's receipt), so a tick
2479
- // never drops it.
2480
- legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, context.cloudOpraServed),
2896
+ // tier off the session's chain acquisition, a Cloud session's off its newest frame's receipt, the delayed CME
2897
+ // legs the installing run read), so a tick never drops it.
2898
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, context.cloudOpraServed, context.cmeDelayed),
2481
2899
  position: context.position,
2482
2900
  axis: context.axis,
2483
2901
  colors: context.colors,
@@ -2942,7 +3360,8 @@ function wrunLiveBatchedMarksTail(tc, indicatorId, metadata, tailFromTs) {
2942
3360
  * at or after the block's first ts. Walks back from the end (rows are in
2943
3361
  * ts order), so the merge costs the tail, not a full re-walk by timestamp;
2944
3362
  * a fresh array so the previous rows' attachments (handles, strategy,
2945
- * frames) never leak onto the merged rows. */
3363
+ * frames) never leak onto the merged rows: each caller attaches what the
3364
+ * block answered and carries by name what it keeps. */
2946
3365
  function mergeWrunOutputTail(stored, tail, fromTs) {
2947
3366
  let keep = stored.length;
2948
3367
  while (keep > 0 && stored[keep - 1].ts >= fromTs)
@@ -2990,6 +3409,8 @@ function laneSourcesOf(context, ohlcvRows) {
2990
3409
  tradeLegRows: context.tradeLegRows,
2991
3410
  // Each trades leg's rows ride the tier its acquisition names (the full run's ask, the intake's fold).
2992
3411
  tradeLegIntervals: wrunTradeLegIntervals(context.acquisition),
3412
+ // The pinned lanes (U9e): each foreign ask of a class reads the lane of its market.
3413
+ pinnedLaneRows: context.pinnedLaneRows,
2993
3414
  // Each grid leg asked at a tier rides it (the full run's records).
2994
3415
  pinnedLegTierMs: wrunPinnedLegTierMs(context.pinnedLegs),
2995
3416
  pinnedCandleRows: context.pinnedCandleRows,
@@ -3006,10 +3427,11 @@ function laneSourcesOf(context, ohlcvRows) {
3006
3427
  // The market the session runs on, at the tail clock's interval: a new live bar reads its own
3007
3428
  // `time.trade_date` / `time.session`, and a grid leg lands on its bar grid (`barGrid`).
3008
3429
  venue: wrunBarVenueOf(context.market, intervalMs),
3009
- // The chart's forming bar, on the server clock: a grid leg's row still forming past the chart's newest bar
3010
- // lands in the bar holding its open when that bar is this one. A replay session's chart is historical.
3430
+ // The chart's forming bar, on the chart's stream clock (a delayed chart's newest bar holds now less the delay):
3431
+ // a grid leg's row still forming past the chart's newest bar lands in the bar holding its open when that bar is
3432
+ // this one. A replay session's chart is historical.
3011
3433
  formingBarTs: wrunLiveChartIsLive(context)
3012
- ? hostBucketResolverFor(intervalMs, liveBucketVenueOf(context.market))(serverNowMs())
3434
+ ? wrunChartFormingBarTs(intervalMs, wrunChartStreamRefOf(context.chartIndex, context.market))
3013
3435
  : null,
3014
3436
  };
3015
3437
  }
@@ -3140,7 +3562,7 @@ lastMainTs) {
3140
3562
  console.warn(`[wrun] live reconcile lane '${lane}' failed for '${indicatorId}' (its buckets stay outstanding):`, outcome.reason);
3141
3563
  return;
3142
3564
  }
3143
- const merged = mergeWrunReconcileAnswer(context, lane, outcome.status === 'fulfilled' ? outcome.value : [], plan.fromTs, plan.toTs, lane === 'tape' ? tapeServedStartMs : undefined);
3565
+ const merged = mergeWrunReconcileAnswer(context, lane, outcome.status === 'fulfilled' ? outcome.value : [], plan.fromTs, plan.toTs, lane === 'tape' ? tapeServedStartMs : undefined, legNowMs);
3144
3566
  // The ETF lane's slow re-check counts from this answer's ask (wrunEtfFlowRecheckDue), and so
3145
3567
  // does a poll lane's own pace (wrunPollLaneRecheckDue).
3146
3568
  if (lane === 'etf_flow')
@@ -3343,11 +3765,20 @@ async function fetchWrunReconcileLane(context, ledger, lane, fromTs, toTs, meta)
3343
3765
  return fetchWrunOptionSummaryReconcileLane(context, ledger, lane, fromTs, toTs, meta);
3344
3766
  }
3345
3767
  // A trades leg lane (kit 0.77.0) re-asks K_BUY_SELL_VOLUME on its own market in its quote under
3346
- // its id: the payload the full run recorded, else the one its id names (never the chart's own).
3768
+ // its id: the payload the full run recorded, else the one its id names (never the chart's own). A
3769
+ // pinned lane (U9e) re-asks its class's K source on its own market under its id the same way (an oi
3770
+ // lane's forming bucket by the poll that re-asks the chart's own oi).
3347
3771
  const leg = isWrunTradesLegLane(lane);
3348
- const spec = leg ? { type: 'buy_sell_volume', key: lane } : LANE_FETCH[lane];
3772
+ const pinned = wrunPinnedLaneOf(lane);
3773
+ const spec = leg
3774
+ ? { type: 'buy_sell_volume', key: lane }
3775
+ : pinned !== undefined
3776
+ ? { type: WRUN_PINNED_LANE_SPECS[pinned.cls].type, key: lane }
3777
+ : LANE_FETCH[lane];
3349
3778
  const acquisition = context.acquisition[lane];
3350
- const extras = acquisition ?? (leg ? wrunTradesLegExtras(lane) : {});
3779
+ // The payload extras over the current-market placeholders: a market only where the lane names one (a leg or a pinned
3780
+ // lane, its recorded acquisition), so the chart's own lanes keep asking `currentSymbol` / `currentExchange`.
3781
+ const extras = acquisition ?? (leg ? wrunTradesLegExtras(lane) : isWrunPinnedLaneId(lane) ? wrunPinnedLaneExtras(lane) : {});
3351
3782
  // A lane the full run asked on the fetch's native-rows path records it on its acquisition (a governed
3352
3783
  // options chain: its rows are its plane's, never the index-mode market's), so the reconcile asks the
3353
3784
  // same way.
@@ -3395,9 +3826,9 @@ async function fetchWrunReconcileLane(context, ledger, lane, fromTs, toTs, meta)
3395
3826
  return { rows, whole: wrunSourceVerdictWhole(verdict) };
3396
3827
  });
3397
3828
  }
3398
- if (lane !== 'book')
3829
+ if (lane !== 'book' && pinned?.cls !== 'book')
3399
3830
  return (await ask(nativeRows ? { nativeRows: true } : {})) ?? [];
3400
- // The full run asks the book packed-first unconditionally; an acquisition
3831
+ // The full run asks the book (a pinned book too) packed-first unconditionally; an acquisition
3401
3832
  // record that opts out of the packed worker is honored should the install
3402
3833
  // ever carry one.
3403
3834
  const packedFirst = acquisition?.preferPackedOrderbookWorker !== false;
@@ -3483,7 +3914,7 @@ async function fetchWrunPollLaneReconcile(context, ledger, laneId, fromTs, toTs,
3483
3914
  const askFromTs = wrunReconcileLaneWindowFrom(context, laneId, fromTs, toTs);
3484
3915
  // A daily lane on a chart coarser than a day asks through today when the
3485
3916
  // chart-bar window closed before it (the forming bar of a session grid).
3486
- const askToTs = wrunPollLaneReconcileTo(lane, toTs, context.intervalMs, Date.now());
3917
+ const askToTs = wrunPollLaneReconcileTo(lane, toTs, context.intervalMs, serverNowMs());
3487
3918
  // The run's recorded payload; an OPRA lane's asked again at the tier the read is routed to now, and a chain
3488
3919
  // instance's with the fields its own chain's plane names at that tier (`wrunPollLaneChainAsk`).
3489
3920
  const recorded = context.acquisition[laneId] ?? instance.extras;
@@ -3498,6 +3929,10 @@ async function fetchWrunPollLaneReconcile(context, ledger, laneId, fromTs, toTs,
3498
3929
  fromTs: askFromTs,
3499
3930
  toTs: askToTs,
3500
3931
  intervalMs: context.intervalMs,
3932
+ signal: wrunLaneFetchSignal(context.indicatorId, {
3933
+ chartIndex: context.chartIndex,
3934
+ generation: getChartDataFetchGeneration(context.chartIndex),
3935
+ }),
3501
3936
  }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun live reconcile fetch '${lane.kType}' (${instance.key}) for '${context.fetchKey}'`);
3502
3937
  }
3503
3938
  const askOnce = (askExtras, from, to) => askWrunReconcileSource(context, ledger, {
@@ -3551,12 +3986,27 @@ async function fetchWrunRowLaneReconcile(context, ledger, laneId, fromTs, toTs,
3551
3986
  ? wrunOpraLanePayloadAt(recorded, governedMarketDataTier('OPRA'))
3552
3987
  : wrunRowLaneChainAsk(lane, recorded, governedMarketDataTier);
3553
3988
  const laneFetch = lane.fetch;
3989
+ // Taken before the read's awaits, bound to the chart's dataset: a teardown or the dataset's end meanwhile aborts it.
3990
+ const laneSignal = laneFetch === undefined
3991
+ ? undefined
3992
+ : wrunLaneFetchSignal(context.indicatorId, {
3993
+ chartIndex: context.chartIndex,
3994
+ generation: getChartDataFetchGeneration(context.chartIndex),
3995
+ });
3554
3996
  const laneFromTs = wrunReconcileLaneWindowFrom(context, laneId, fromTs, toTs);
3555
3997
  const window = wrunReconcileHostGridWindow(context, laneFromTs, toTs);
3556
3998
  const rows = await fetchWrunRowLaneRows(lane, extras, replay === undefined ? window : { ...window, replayCursorMs: replay.cursorMs }, { fromTs: laneFromTs, toTs }, async (askExtras, from, to, whole) => {
3557
3999
  if (laneFetch !== undefined) {
3558
4000
  ledger.stats.fetches += 1;
3559
- const own = await withWrunDeadline(laneFetch({ extras: askExtras, fromTs: from, toTs: to, intervalMs: context.intervalMs }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun live reconcile fetch '${lane.kType}' (${instance.key}) for '${context.fetchKey}'`);
4001
+ const own = await withWrunDeadline(laneFetch({
4002
+ extras: askExtras,
4003
+ fromTs: from,
4004
+ toTs: to,
4005
+ intervalMs: context.intervalMs,
4006
+ nowMs: window.nowMs,
4007
+ hostBars: wrunHostBarSpansWithin(window, from, to),
4008
+ signal: laneSignal,
4009
+ }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun live reconcile fetch '${lane.kType}' (${instance.key}) for '${context.fetchKey}'`);
3560
4010
  // A lane's own fetch rides no chart transport (no synthetic completion): its answer is whole once it resolved.
3561
4011
  whole?.(true);
3562
4012
  return own;
@@ -3671,7 +4121,7 @@ async function fetchWrunEtfFlowReconcileLane(context, ledger, fromTs, toTs, meta
3671
4121
  fromTs: dayFrom,
3672
4122
  // Through today on a chart coarser than a day whose window closed
3673
4123
  // before it (the forming bar of a session grid).
3674
- toTs: wrunDailyLaneReconcileTo(toTs, context.intervalMs, Date.now()),
4124
+ toTs: wrunDailyLaneReconcileTo(toTs, context.intervalMs, serverNowMs()),
3675
4125
  interval: WRUN_ETF_FLOW_INTERVAL_KEY,
3676
4126
  }, meta);
3677
4127
  if (rows === null)
@@ -3922,7 +4372,9 @@ function mergeWrunReconcileAnswer(context, lane, answerRows, fromTs, toTs,
3922
4372
  /** Tape only: the first stamp the ask served prints from (the window start's bar open, the
3923
4373
  * aligned seed start, the retention horizon or the gateway's bar limit, whichever is latest); an
3924
4374
  * answered bucket that opened before it is PARTIAL. */
3925
- servedStartMs) {
4375
+ servedStartMs,
4376
+ /** The server's now the ask left at: a delayed stream's reply ends at the reader's cut of that instant. */
4377
+ askNowMs) {
3926
4378
  // A daily lane's rows are day-stamped and its ask opens before the
3927
4379
  // chart-bar window (the ETF lane, a registry lane with a daily join: the
3928
4380
  // window's day, the lane's lookback earlier): the answer is authoritative
@@ -3945,17 +4397,22 @@ servedStartMs) {
3945
4397
  // runs ahead of its 17:00 Chicago open) is partial: the answer holds only its later prints, so
3946
4398
  // it is dropped from the answer and read like a bucket before the horizon (the fed row stands,
3947
4399
  // never a revised closed bar). An answered bucket keeps held orders the answer lacks: a live row can beat its table copy.
3948
- const answer = lane === 'tape'
4400
+ const answerWhole = lane === 'tape'
3949
4401
  ? wrunTapeAnswerUnion(servedStartMs === undefined
3950
4402
  ? answerRows
3951
4403
  : wrunTapeAnswerWithoutPartialHead(answerRows, servedStartMs, context.intervalMs, context.market?.exchange), before)
3952
4404
  : isWrunRowLaneId(lane)
3953
4405
  ? wrunRowLaneReconcileAnswer(context, lane, before, answerRowsInWindow)
3954
4406
  : answerRows;
3955
- const horizonTs = lane === 'tape' ? wrunTapeAnswerHorizonTs(answer) : Number.NEGATIVE_INFINITY;
3956
4407
  // A row lane fed live with a union rule of its own (`liveByCoin.reconcile`) keeps, like the tape, every held bar the
3957
4408
  // answer does not name: its reconcile only ever adds to a bar, so a print shown live never vanishes.
3958
4409
  const keepsHeld = lane === 'tape' || (isWrunRowLaneId(lane) && wrunRowLaneKeepsHeld(context, lane));
4410
+ // A delayed stream's reply ends at the reader's cut: its row for a bar still open there is a partial copy, so the
4411
+ // row the live feed built (a fed bucket) stands and stays owed (`wrunReconcileHeldRowWins`). A union lane already
4412
+ // keeps what it held.
4413
+ const heldWins = keepsHeld ? new Set() : wrunLiveHeldRowsWinning(context, lane, before, askNowMs);
4414
+ const answer = heldWins.size === 0 ? answerWhole : answerWhole.filter((row) => !heldWins.has(Number(row[0])));
4415
+ const horizonTs = lane === 'tape' ? wrunTapeAnswerHorizonTs(answer) : Number.NEGATIVE_INFINITY;
3959
4416
  const answered = new Set();
3960
4417
  let earliestAnsweredTs = Number.POSITIVE_INFINITY;
3961
4418
  for (const row of answer) {
@@ -3973,7 +4430,7 @@ servedStartMs) {
3973
4430
  const ts = Number(row[0]);
3974
4431
  if (!Number.isFinite(ts) || ts < windowFrom || answered.has(ts))
3975
4432
  continue;
3976
- if (ts >= toTs || ts < horizonTs || keepsHeld) {
4433
+ if (ts >= toTs || ts < horizonTs || keepsHeld || heldWins.has(ts)) {
3977
4434
  keep.add(ts);
3978
4435
  continue;
3979
4436
  }
@@ -4039,7 +4496,7 @@ function laneRevisedFromTs(context, lane, before, merged, scanFromTs, endTs) {
4039
4496
  const revised = laneWindowRevisedFromTs(before, merged, Math.max(scanFromTs, firstDay), endTs);
4040
4497
  if (landing !== 'last' || scanFromTs >= firstDay)
4041
4498
  return revised;
4042
- return wrunDailyLaneHeadEqual(before, merged, firstDay, laneValuesEqual) ? revised : minTs(revised, firstDay);
4499
+ return wrunDailyLaneHeadEqual(before, merged, firstDay, wrunLaneValuesEqual) ? revised : minTs(revised, firstDay);
4043
4500
  }
4044
4501
  /** The landing of a lane whose rows are one per UTC day (the ETF flow lane,
4045
4502
  * a registry lane with a daily join), null for a lane joined per bar. */
@@ -4079,7 +4536,8 @@ function wrunReconcileLaneOwnFrom(context, lane, fromTs) {
4079
4536
  return descriptor === undefined ? fromTs : wrunPollLaneReconcileFrom(descriptor, fromTs, context.firstRowTs);
4080
4537
  }
4081
4538
  /** The governed plane a lane reads beside its chart's own market, as the exchange its served access is read under:
4082
- * `OPRA` for an OPRA row lane (`governed: 'opra'`) or poll lane (`opra`), on whatever chart hosts it; a chain
4539
+ * `OPRA` for an OPRA row lane (`governed: 'opra'`) or poll lane (`opra`), on whatever chart hosts it; a `stocks` row
4540
+ * lane's tape (its acquisition's `exchange`); a chain
4083
4541
  * instance's chain exchange, a row lane's or a poll lane's, when a gate governs it (OPRA, a CME Group exchange). Null
4084
4542
  * for every other lane (a plain chain included): it reads the chart's own market, whose poll window the plan's floor
4085
4543
  * already is, or no gate's. */
@@ -4090,6 +4548,10 @@ function wrunLaneGovernedPlane(context, lane) {
4090
4548
  if (instance !== undefined && descriptor?.chain !== undefined) {
4091
4549
  return wrunRowLaneChainGovernedExchange(descriptor, context.acquisition[lane] ?? instance.extras);
4092
4550
  }
4551
+ // A `stocks` lane reads its tape (its acquisition's exchange), whose delayed window the chart's own market may not.
4552
+ if (instance !== undefined && descriptor?.governed === 'stocks') {
4553
+ return wrunRowLaneStocksTapeOf(descriptor, context.acquisition[lane] ?? instance.extras);
4554
+ }
4093
4555
  return descriptor?.governed === 'opra' ? 'OPRA' : null;
4094
4556
  }
4095
4557
  if (isWrunPollLaneId(lane)) {
@@ -4127,11 +4589,35 @@ function laneRowsOf(context, lane) {
4127
4589
  return context.pollLaneRows?.[lane];
4128
4590
  if (isWrunRowLaneId(lane))
4129
4591
  return context.rowLaneRows?.[lane];
4130
- // A trades leg lane's buffer rides its one record, as a poll lane's (LANE_ROWS_FIELD names the builtin buffers).
4592
+ // A trades leg lane's buffer rides its one record, as a poll lane's (LANE_ROWS_FIELD names the builtin buffers), and
4593
+ // so does a pinned lane's (U9e).
4131
4594
  if (isWrunTradesLegLane(lane))
4132
4595
  return context.tradeLegRows?.[lane];
4596
+ if (isWrunPinnedLaneId(lane))
4597
+ return context.pinnedLaneRows?.[lane];
4133
4598
  return context[LANE_ROWS_FIELD[lane]];
4134
4599
  }
4600
+ /** The held buckets of a lane whose live-built row wins over a reconcile answer (`wrunReconcileHeldRowWins`): fed
4601
+ * buckets still open at the reader's cut of the ask, on the delayed stream the lane reads (its governed plane, else
4602
+ * the venue the chart's candles ride). Empty on a real-time stream. */
4603
+ function wrunLiveHeldRowsWinning(context, lane, held, askNowMs) {
4604
+ const wins = new Set();
4605
+ const fed = context.fedBuckets[lane];
4606
+ if (askNowMs === undefined || !fed || fed.size === 0)
4607
+ return wins;
4608
+ const stream = wrunLaneGovernedPlane(context, lane) ??
4609
+ wrunChartStreamExchange(wrunChartStreamRefOf(context.chartIndex, context.market));
4610
+ const cutMs = wrunStreamCutMs(stream, askNowMs);
4611
+ if (cutMs === null)
4612
+ return wins;
4613
+ for (const row of held) {
4614
+ const bucketTs = Number(row[0]);
4615
+ if (wrunReconcileHeldRowWins({ bucketTs, intervalMs: context.intervalMs, cutMs, heldLiveBuilt: fed.has(bucketTs) })) {
4616
+ wins.add(bucketTs);
4617
+ }
4618
+ }
4619
+ return wins;
4620
+ }
4135
4621
  /** The first bucket a tape answer speaks for (its oldest row); +Infinity for an empty answer,
4136
4622
  * which speaks for no bucket at all. */
4137
4623
  function wrunTapeAnswerHorizonTs(answer) {
@@ -4201,6 +4687,9 @@ function wrunTapeServedStartMs(context, windowFromTs, nowMs) {
4201
4687
  retentionSec: lane.retentionSec,
4202
4688
  barLimitSec: lane.barLimitSec,
4203
4689
  exchange: context.market?.exchange,
4690
+ // The seed counts back from the instant the acquisition names (the session's pin, a replay's present), the one
4691
+ // the control's request builder reads on this re-ask (wrun-history-as-of.util).
4692
+ historyAsOfMs: context.acquisition.tape?.[SOURCE_HISTORY_AS_OF_FIELD],
4204
4693
  });
4205
4694
  }
4206
4695
  function setLaneRows(context, lane, rows) {
@@ -4220,6 +4709,10 @@ function setLaneRows(context, lane, rows) {
4220
4709
  context.tradeLegRows = { ...context.tradeLegRows, [lane]: rows };
4221
4710
  return;
4222
4711
  }
4712
+ if (isWrunPinnedLaneId(lane)) {
4713
+ context.pinnedLaneRows = { ...context.pinnedLaneRows, [lane]: rows };
4714
+ return;
4715
+ }
4223
4716
  context[LANE_ROWS_FIELD[lane]] = rows;
4224
4717
  }
4225
4718
  /** The earliest bucket in [fromTs, endTs) that differs between the two row
@@ -4286,35 +4779,11 @@ function laneRowsEqual(a, b) {
4286
4779
  return false;
4287
4780
  continue;
4288
4781
  }
4289
- if (!laneValuesEqual(x, y))
4782
+ if (!wrunLaneValuesEqual(x, y))
4290
4783
  return false;
4291
4784
  }
4292
4785
  return true;
4293
4786
  }
4294
- /** The rounding two answers for the same value can differ by, relative to
4295
- * the value, with an absolute floor for a value at zero: far below one price
4296
- * tick, one trade or one cent of notional on any series a lane serves. */
4297
- const WRUN_LANE_VALUE_NOISE = 1e-9;
4298
- const WRUN_LANE_VALUE_NOISE_FLOOR = 1e-12;
4299
- /**
4300
- * Whether a session cannot tell two lane values apart: the same value, both
4301
- * NaN, or two finite numbers within float rounding of each other. A control
4302
- * that sums or averages sub-rows rounds another way when its window moves
4303
- * (measured 2026-10-02: 1.9177000000000004 against 1.9177 on a long/short
4304
- * ratio, a candle volume one step apart), and read as a revision that
4305
- * reseeded the whole session on every poll.
4306
- */
4307
- function laneValuesEqual(x, y) {
4308
- if (x === y)
4309
- return true;
4310
- if (typeof x !== 'number' || typeof y !== 'number')
4311
- return false;
4312
- if (x !== x && y !== y)
4313
- return true;
4314
- if (!Number.isFinite(x) || !Number.isFinite(y))
4315
- return false;
4316
- return (Math.abs(x - y) <= Math.max(WRUN_LANE_VALUE_NOISE_FLOOR, WRUN_LANE_VALUE_NOISE * Math.max(Math.abs(x), Math.abs(y))));
4317
- }
4318
4787
  // ---------------------------------------------------------------------------
4319
4788
  // Reseed: a new session over the buffers, no fetch (the full run's owner).
4320
4789
  // ---------------------------------------------------------------------------
@@ -4367,10 +4836,15 @@ async function reseedWrunOverlay(context, ledger, reason, mainClock) {
4367
4836
  ledger.lastReseedAt = Date.now();
4368
4837
  // A reseed a page held is served.
4369
4838
  heldPageReseeds.delete(context);
4370
- // Every bar was evaluated again from the buffers: no revised closed bar is owed any more.
4371
- closedBarRevisions.delete(context);
4839
+ // Every bar was evaluated again from the buffers: no revised closed bar is owed any more, unless the host's
4840
+ // session changed owner while the reseed reopened (its revision from the old seam, which these rows never read,
4841
+ // stays owed for the next drain; wrun-session-composition.util).
4842
+ const ownerRevisionKept = takeWrunCompositionRevisionKept(context);
4843
+ if (!ownerRevisionKept)
4844
+ closedBarRevisions.delete(context);
4372
4845
  if (getWrunOverlayLiveContext(indicatorId) === context) {
4373
- context.dirtyFromTs = null;
4846
+ if (!ownerRevisionKept)
4847
+ context.dirtyFromTs = null;
4374
4848
  // The session re-evaluated the whole window from its primary rows (the
4375
4849
  // chart's, or a session's run bars at another interval).
4376
4850
  const rows = wrunRunIntervalSessionOf(context)?.rows ??
@@ -4564,7 +5038,8 @@ function wrunRowsHoldTs(rows, ts) {
4564
5038
  /**
4565
5039
  * Decide one drain's plan from the context, the chart's main rows, the gap
4566
5040
  * marks taken and what the fold reported. In order: a moved identity, a
4567
- * moved row-lane acquisition, or history (a clamped session: a head rolled
5041
+ * moved row-lane acquisition, a coins tape whose market traded below its
5042
+ * priced low x 0.9, or history (a clamped session: a head rolled
4568
5043
  * past its first row; a pan-back page left to its wave is not one, C1), or a
4569
5044
  * gap wider than 250 bars, rebuilds; any reconcile trigger
4570
5045
  * (session-start, main-jump, wake, poll-due; main-jump is detected here from
@@ -4625,10 +5100,29 @@ export function decideWrunLiveTickPlan(input) {
4625
5100
  if (input.rowLaneMoved === true) {
4626
5101
  return { kind: 'rebuild', reason: 'acquisition' };
4627
5102
  }
5103
+ // A coins tape (C-COINS item 2) priced its dollar floor off the lowest price its window traded at: once the market
5104
+ // trades below that price x 0.9 the floor could drop a print of its coins, so the full run prices the window again
5105
+ // (wrun-tape-coins.util). The market's prices: the chart's bars the session has not passed where the run priced off
5106
+ // them (`priceFromChart`), else the prints the session took off the tape's channel (a formula chart's bars are
5107
+ // another series). Before any fold or reconcile reads the old floor.
5108
+ const tapeTradedLow = wrunCoinTapeGuardLow(context.acquisition.tape, mainRows, context.lastRowTs, context.tapePriceLow);
5109
+ if (wrunCoinTapeFloorBroken(context.acquisition.tape, tapeTradedLow)) {
5110
+ return { kind: 'rebuild', reason: 'tape-price' };
5111
+ }
4628
5112
  // History changed under the session (lazy-load prepend, dataset swap, a
4629
- // rolled-off head): a live session can only extend forward.
5113
+ // rolled-off head): a live session can only extend forward. A verified
5114
+ // backward extension (WRUN-PANBACK A2) is told apart on the chart's own bars,
5115
+ // the ones the history check compared: a session at another interval reads its
5116
+ // chart clock (its run bars do not move when the chart prepends a page).
4630
5117
  if (historyMoved) {
4631
- return { kind: 'rebuild', reason: 'history' };
5118
+ const backward = runClock !== undefined
5119
+ ? runClock.chartFirstTs < runClock.sessionChartFirstTs &&
5120
+ runClock.sessionChartFirstHeld === true &&
5121
+ runClock.formingTs >= context.lastRowTs
5122
+ : firstMainTs < context.firstRowTs &&
5123
+ wrunRowsHoldTs(mainRows, context.firstRowTs) &&
5124
+ lastMainTs >= context.lastRowTs;
5125
+ return { kind: 'rebuild', reason: 'history', extension: backward ? 'backward' : 'other' };
4632
5126
  }
4633
5127
  if (lastMainTs - context.lastRowTs > WRUN_LIVE_REBUILD_GAP_BARS * intervalMs) {
4634
5128
  return { kind: 'rebuild', reason: 'gap-too-wide' };
@@ -4776,6 +5270,7 @@ export function wrunLiveRunClockOf(session, context, chartRows) {
4776
5270
  return {
4777
5271
  chartFirstTs: Number(chartRows[0][0]),
4778
5272
  sessionChartFirstTs: session.chartFirstTs,
5273
+ sessionChartFirstHeld: wrunRowsHoldTs(chartRows, session.chartFirstTs),
4779
5274
  formingTs,
4780
5275
  lastMainTs,
4781
5276
  coveredThroughTs: session.coveredThroughTs,
@@ -4924,14 +5419,7 @@ function oldestOutstandingBucket(context, lanes) {
4924
5419
  * import graph. Read for the chart's own exchange (the plan's floor) and for
4925
5420
  * the governed plane a lane reads beside it (`wrunReconcileLaneWindowFrom`). */
4926
5421
  function wrunReconcileFloorBars(exchange, intervalMs) {
4927
- const intervalSeconds = intervalMs / 1000;
4928
- if (!isGovernedExchange(exchange) || !(intervalSeconds > 0))
4929
- return WRUN_LIVE_RECONCILE_TAIL_BARS;
4930
- const access = cmeServedAccessForExchange(exchange);
4931
- if (access.status === 'known' && access.timing === 'realtime')
4932
- return WRUN_LIVE_RECONCILE_TAIL_BARS;
4933
- return (WRUN_LIVE_RECONCILE_TAIL_BARS +
4934
- Math.ceil((servedDelaySecondsForAccess(access, exchange) + CME_DELAYED_EMBARGO_MARGIN_SECONDS) / intervalSeconds));
5422
+ return WRUN_LIVE_RECONCILE_TAIL_BARS + wrunStreamDelayBars(exchange, intervalMs);
4935
5423
  }
4936
5424
  function minTs(...values) {
4937
5425
  let min = null;
@@ -5009,7 +5497,7 @@ function noteRevisedClosedCandles(context, rows) {
5009
5497
  for (const row of evaluated) {
5010
5498
  evaluatedTs.add(row[0]);
5011
5499
  const now = current.get(row[0]);
5012
- if (now !== undefined && !candleEqual(row, now) && (revised === null || row[0] < revised))
5500
+ if (now !== undefined && !wrunCandleEqual(row, now) && (revised === null || row[0] < revised))
5013
5501
  revised = row[0];
5014
5502
  }
5015
5503
  for (const ts of current.keys()) {
@@ -5022,13 +5510,6 @@ function noteRevisedClosedCandles(context, rows) {
5022
5510
  context.evaluatedMainTail = closedMainTail(rows, context.lastRowTs);
5023
5511
  return revised;
5024
5512
  }
5025
- function candleEqual(evaluated, current) {
5026
- for (let column = 1; column <= 5; column += 1) {
5027
- if (!laneValuesEqual(Number(evaluated[column]), Number(current[column])))
5028
- return false;
5029
- }
5030
- return true;
5031
- }
5032
5513
  // ---------------------------------------------------------------------------
5033
5514
  // Lane row merge (shared by the reconcile and the specs).
5034
5515
  // ---------------------------------------------------------------------------
@@ -5111,12 +5592,17 @@ export function __resetWrunLiveTickForTests() {
5111
5592
  for (const armed of graceEndWakes.values())
5112
5593
  clearTimeout(armed.timer);
5113
5594
  graceEndWakes.clear();
5595
+ for (const wake of rebuildSettleWakes.values())
5596
+ clearTimeout(wake);
5597
+ rebuildSettleWakes.clear();
5598
+ wrunRunStarts.clear();
5114
5599
  wrunLiveHeld = false;
5115
5600
  }
5116
5601
  /** Spec probe: the due time of the overlay's armed `pinned-close` timer, null when none. */
5117
5602
  export function wrunPinnedCloseTimerDueAt(indicatorId) {
5118
5603
  return pinnedCloseTimers.get(indicatorId)?.dueAt ?? null;
5119
5604
  }
5605
+ const wrunRunStarts = new Map();
5120
5606
  /** The chart's main-rows identity the executor's pan-wave coverage skip
5121
5607
  * compares runs by: the market, the first row, the newest closed row and the
5122
5608
  * row count. A forming-bar tick changes none of them; a prepended page, a
@@ -5128,7 +5614,10 @@ export function wrunPinnedCloseTimerDueAt(indicatorId) {
5128
5614
  * prefix has not landed reads no identity, so no earlier run's coverage
5129
5615
  * skips the wave that owes the page's rows; a run's own start (in flight)
5130
5616
  * reads the chart's identity, so a prefix that lands covers the waves over
5131
- * the same rows after it. Exported for the specs. */
5617
+ * the same rows after it, and is noted (`wrunRunStarts`). A coverage check
5618
+ * for an overlay whose live session carries the chart's tail reads the key
5619
+ * its latest run started on while the history it computed stands
5620
+ * (`wrunLiveCarriedCoverage`). Exported for the specs. */
5132
5621
  export function wrunChartRowsIdentity(chartIndex, indicatorId) {
5133
5622
  const rows = wrunChartCandleRows(wrunChartHostEnv().chart.instance(chartIndex));
5134
5623
  if (rows.length === 0)
@@ -5136,8 +5625,57 @@ export function wrunChartRowsIdentity(chartIndex, indicatorId) {
5136
5625
  if (indicatorId !== undefined && wrunPrefixUnlanded(chartIndex, indicatorId, rows[0][0]))
5137
5626
  return undefined;
5138
5627
  const market = wrunChartMarketIdentity(wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata);
5139
- const newestClosedTs = rows.length > 1 ? rows[rows.length - 2][0] : 'none';
5140
- return `${market}|${rows[0][0]}|${newestClosedTs}|${rows.length}`;
5628
+ const newestClosedTs = rows.length > 1 ? rows[rows.length - 2][0] : undefined;
5629
+ const identity = `${market}|${rows[0][0]}|${newestClosedTs ?? 'none'}|${rows.length}`;
5630
+ if (indicatorId === undefined)
5631
+ return identity;
5632
+ if (isWrunOverlayRerunInFlight(indicatorId)) {
5633
+ wrunRunStarts.set(indicatorId, {
5634
+ chartIndex,
5635
+ market,
5636
+ firstTs: rows[0][0],
5637
+ newestClosedTs,
5638
+ closedRows: rows.length - 1,
5639
+ identity,
5640
+ });
5641
+ return identity;
5642
+ }
5643
+ return wrunLiveCarriedCoverage(chartIndex, indicatorId, rows, market) ?? identity;
5644
+ }
5645
+ /** The coverage key of an overlay whose live session carries the chart's tail (WRUN-PANBACK A2): the key its latest run
5646
+ * started on, while the chart still holds the history that run computed (the same market and first row, the same
5647
+ * rows through the newest bar it saw closed) and has only grown past it. The bars a roll appended are the live tick's
5648
+ * to compute, so a page's own wave that the chart held for its wire data past the run that computed the page reads
5649
+ * covered, instead of computing the same history again (field 2026-11-02: a second full run per script in one still,
5650
+ * `pages 0, reused true`, 4.1 s after the release and one bar roll later). Undefined, the chart's own key then, with no
5651
+ * live session the tick advances (none, a replay, a suspended one), no run start noted, or a history that moved (a
5652
+ * page, a filled gap, a switch, a rolled-off head). */
5653
+ function wrunLiveCarriedCoverage(chartIndex, indicatorId, rows, market) {
5654
+ const start = wrunRunStarts.get(indicatorId);
5655
+ if (start === undefined || start.newestClosedTs === undefined)
5656
+ return undefined;
5657
+ if (start.chartIndex !== chartIndex || start.market !== market || start.firstTs !== Number(rows[0][0])) {
5658
+ return undefined;
5659
+ }
5660
+ const context = getWrunOverlayLiveContext(indicatorId);
5661
+ if (context === undefined || context.chartIndex !== chartIndex || context.replay === true || context.liveSuspended) {
5662
+ return undefined;
5663
+ }
5664
+ const historyStands = rows.length > start.closedRows && wrunRowsThroughTs(rows, start.newestClosedTs) === start.closedRows;
5665
+ return historyStands ? start.identity : undefined;
5666
+ }
5667
+ /** How many rows ascending by stamp are stamped at or before `ts` (binary search). */
5668
+ function wrunRowsThroughTs(rows, ts) {
5669
+ let low = 0;
5670
+ let high = rows.length;
5671
+ while (low < high) {
5672
+ const mid = (low + high) >>> 1;
5673
+ if (Number(rows[mid][0]) <= ts)
5674
+ low = mid + 1;
5675
+ else
5676
+ high = mid;
5677
+ }
5678
+ return low;
5141
5679
  }
5142
5680
  // The cross-module seams (the intake never imports this module): a gap mark
5143
5681
  // wakes the drain through the requester, a teardown drops this lane's state
@@ -5153,6 +5691,7 @@ let drainRequesterRegistered = false;
5153
5691
  let liveChannelRequesterRegistered = false;
5154
5692
  let teardownHookRegistered = false;
5155
5693
  let rowsIdentityReaderRegistered = false;
5694
+ let lazyWaveAbsorberRegistered = false;
5156
5695
  let sheetReaderRegistered = false;
5157
5696
  let pageVisibleListenerRegistered = false;
5158
5697
  let hiddenPaceListenerRegistered = false;
@@ -5210,6 +5749,18 @@ function registerWrunLiveTickSeams() {
5210
5749
  // A partial mock of the drivers util: retried at the first schedule.
5211
5750
  }
5212
5751
  }
5752
+ if (!lazyWaveAbsorberRegistered) {
5753
+ try {
5754
+ // The executor offers each pan wave to the open rebuild episode (WRUN-PANBACK A2).
5755
+ if (typeof setWrunLazyWaveAbsorber === 'function') {
5756
+ setWrunLazyWaveAbsorber(absorbWrunLazyWave);
5757
+ lazyWaveAbsorberRegistered = true;
5758
+ }
5759
+ }
5760
+ catch {
5761
+ // A partial mock of the drivers util: retried at the first schedule.
5762
+ }
5763
+ }
5213
5764
  if (!sheetReaderRegistered) {
5214
5765
  try {
5215
5766
  if (typeof setWrunLiveSheetReader === 'function') {