@orangecharts/wrun-chart-host 0.11.1 → 0.15.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 (319) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +4 -4
  3. package/dist/constants/feature-flags.constants.js +38 -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 +69 -3
  13. package/dist/host-env.js +21 -0
  14. package/dist/host-ports.types.d.ts +36 -3
  15. package/dist/index.d.ts +18 -0
  16. package/dist/index.js +19 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +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 +141 -20
  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 +5 -5
  35. package/dist/market-data/venues/opra.js +3 -3
  36. package/dist/market-data/venues/stocks.contract.copy.json +6 -5
  37. package/dist/market-data/venues/stocks.d.ts +5 -5
  38. package/dist/market-data/venues/stocks.js +21 -18
  39. package/dist/settings-templates/frvp-fields.d.ts +12 -1
  40. package/dist/settings-templates/frvp-fields.js +15 -4
  41. package/dist/settings-templates/index.js +12 -5
  42. package/dist/settings-templates/indicator-fields.js +43 -2
  43. package/dist/settings-templates/tool-rules.d.ts +17 -8
  44. package/dist/settings-templates/tool-rules.js +15 -8
  45. package/dist/settings-templates/tool-tables.generated.js +4 -2
  46. package/dist/utility/auth/server-clock.util.d.ts +3 -1
  47. package/dist/utility/auth/server-clock.util.js +3 -1
  48. package/dist/utility/chart/book-live-bucket.util.js +2 -2
  49. package/dist/utility/chart/cache-alignment.util.d.ts +38 -7
  50. package/dist/utility/chart/cache-alignment.util.js +50 -13
  51. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +2 -0
  52. package/dist/utility/chart/chart-data-fetch-generation.util.js +16 -0
  53. package/dist/utility/chart/cme-session-bucket.util.d.ts +18 -75
  54. package/dist/utility/chart/cme-session-bucket.util.js +25 -332
  55. package/dist/utility/chart/continuous-contracts.util.js +6 -5
  56. package/dist/utility/chart/display-offset.leaf.d.ts +24 -0
  57. package/dist/utility/chart/display-offset.leaf.js +41 -0
  58. package/dist/utility/chart/effective-chart-session.util.d.ts +2 -1
  59. package/dist/utility/chart/effective-chart-session.util.js +13 -5
  60. package/dist/utility/chart/feed-interval.util.d.ts +6 -20
  61. package/dist/utility/chart/feed-interval.util.js +13 -22
  62. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +27 -7
  63. package/dist/utility/chart/fetch-dedupe-policy.util.js +86 -11
  64. package/dist/utility/chart/footprint-band.util.d.ts +21 -5
  65. package/dist/utility/chart/footprint-band.util.js +53 -14
  66. package/dist/utility/chart/host-bar-placement.util.d.ts +7 -4
  67. package/dist/utility/chart/host-bar-placement.util.js +8 -2
  68. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +32 -0
  69. package/dist/utility/chart/indicator-inflight-registry.util.js +52 -0
  70. package/dist/utility/chart/indicator-run-interval.util.d.ts +10 -4
  71. package/dist/utility/chart/indicator-run-interval.util.js +21 -12
  72. package/dist/utility/chart/interval-registry.util.d.ts +1 -1
  73. package/dist/utility/chart/interval-registry.util.js +1 -1
  74. package/dist/utility/chart/kscript-legend-entries.util.d.ts +12 -0
  75. package/dist/utility/chart/kscript-legend-entries.util.js +16 -0
  76. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +1 -1
  77. package/dist/utility/chart/kscript-run-interval-projection.util.js +4 -2
  78. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -62
  79. package/dist/utility/chart/kscript-venue-policy.util.js +85 -94
  80. package/dist/utility/chart/live-bucket.util.d.ts +39 -17
  81. package/dist/utility/chart/live-bucket.util.js +103 -57
  82. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +58 -20
  83. package/dist/utility/chart/local-kscript-source-revalidation.util.js +98 -23
  84. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +35 -11
  85. package/dist/utility/chart/local-kscript-warmup-depth.util.js +24 -3
  86. package/dist/utility/chart/market-session-schedule.util.d.ts +8 -0
  87. package/dist/utility/chart/market-session-schedule.util.js +39 -1
  88. package/dist/utility/chart/market-session.util.d.ts +136 -0
  89. package/dist/utility/chart/market-session.util.js +341 -0
  90. package/dist/utility/chart/om-panel.util.d.ts +5 -3
  91. package/dist/utility/chart/om-panel.util.js +42 -7
  92. package/dist/utility/chart/om-target.util.d.ts +14 -1
  93. package/dist/utility/chart/om-target.util.js +22 -5
  94. package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
  95. package/dist/utility/chart/opra-read-access.leaf.js +22 -0
  96. package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
  97. package/dist/utility/chart/profile-row-height.util.js +74 -37
  98. package/dist/utility/chart/rth-session.util.d.ts +55 -20
  99. package/dist/utility/chart/rth-session.util.js +94 -46
  100. package/dist/utility/chart/session-lattice.util.d.ts +150 -0
  101. package/dist/utility/chart/session-lattice.util.js +488 -0
  102. package/dist/utility/chart/trading-day.util.d.ts +40 -2
  103. package/dist/utility/chart/trading-day.util.js +84 -7
  104. package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
  105. package/dist/utility/chart/us-equities-session.util.js +44 -15
  106. package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
  107. package/dist/utility/chart/window-geometry.leaf.js +57 -8
  108. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
  109. package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
  110. package/dist/utility/chart/wrun-run-result.util.d.ts +38 -13
  111. package/dist/utility/chart/wrun-run-result.util.js +97 -27
  112. package/dist/utility/common/time.util.js +5 -4
  113. package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
  114. package/dist/utility/market-events/earnings-scope.util.js +17 -9
  115. package/dist/utility/market-events/market-events.util.d.ts +14 -7
  116. package/dist/utility/market-events/market-events.util.js +30 -17
  117. package/dist/utility/number-format.util.d.ts +14 -21
  118. package/dist/utility/number-format.util.js +38 -24
  119. package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
  120. package/dist/utility/options/option-venue-disclosure.util.js +71 -11
  121. package/dist/utility/options/option-venue.util.d.ts +1 -1
  122. package/dist/utility/options/option-venue.util.js +1 -1
  123. package/dist/utility/pool-symbol.leaf.d.ts +7 -0
  124. package/dist/utility/pool-symbol.leaf.js +50 -5
  125. package/dist/utility/stocks/stock-display.util.d.ts +15 -0
  126. package/dist/utility/stocks/stock-display.util.js +37 -0
  127. package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
  128. package/dist/utility/v2/gate-plane.util.d.ts +6 -0
  129. package/dist/utility/v2/gate-plane.util.js +11 -1
  130. package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
  131. package/dist/utility/v2/gate-session-latch.util.js +3 -3
  132. package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
  133. package/dist/utility/v2/governed-tier.leaf.js +17 -16
  134. package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
  135. package/dist/utility/v2/stocks-governed.util.js +14 -0
  136. package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
  137. package/dist/utility/v2/v2-enums.leaf.js +458 -0
  138. package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
  139. package/dist/utility/wrun/derived-roots.leaf.js +27 -1
  140. package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
  141. package/dist/utility/wrun/derived-roots.util.js +97 -56
  142. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
  143. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
  144. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
  145. package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
  146. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
  147. package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
  148. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
  149. package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
  150. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
  151. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
  152. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  153. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
  154. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
  155. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
  156. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
  157. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
  158. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
  159. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
  160. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
  161. package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
  162. package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
  163. package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
  164. package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
  165. package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
  166. package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
  167. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +46 -23
  168. package/dist/utility/wrun/wrun-batched-marks.util.js +260 -62
  169. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
  170. package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
  171. package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
  172. package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
  173. package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
  174. package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
  175. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
  176. package/dist/utility/wrun/wrun-canvases.util.d.ts +24 -7
  177. package/dist/utility/wrun/wrun-canvases.util.js +99 -30
  178. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
  179. package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
  180. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
  181. package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
  182. package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
  183. package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
  184. package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
  185. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
  186. package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
  187. package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
  188. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
  189. package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
  190. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
  191. package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
  192. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
  193. package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
  194. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
  195. package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
  196. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
  197. package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
  198. package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
  199. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
  200. package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
  201. package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
  202. package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
  203. package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
  204. package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
  205. package/dist/utility/wrun/wrun-host.service.js +137 -27
  206. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
  207. package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
  208. package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
  209. package/dist/utility/wrun/wrun-hover.util.js +24 -13
  210. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
  211. package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
  212. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
  213. package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
  214. package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
  215. package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
  216. package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
  217. package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
  218. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
  219. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
  220. package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
  221. package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
  222. package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
  223. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
  224. package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
  225. package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
  226. package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
  227. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
  228. package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
  229. package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
  230. package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
  231. package/dist/utility/wrun/wrun-live-tick.util.js +655 -97
  232. package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
  233. package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
  234. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
  235. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
  236. package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
  237. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
  238. package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
  239. package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
  240. package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
  241. package/dist/utility/wrun/wrun-option-views.util.js +5 -2
  242. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
  243. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
  244. package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
  245. package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
  246. package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
  247. package/dist/utility/wrun/wrun-output-words.util.js +51 -0
  248. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +116 -11
  249. package/dist/utility/wrun/wrun-overlay-drivers.util.js +208 -43
  250. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
  251. package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
  252. package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
  253. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
  254. package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
  255. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
  256. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  257. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +247 -26
  258. package/dist/utility/wrun/wrun-overlay-run.util.js +2234 -408
  259. package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
  260. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +11 -2
  261. package/dist/utility/wrun/wrun-panel-mount.util.js +122 -19
  262. package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
  263. package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
  264. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
  265. package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
  266. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
  267. package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
  268. package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
  269. package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
  270. package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
  271. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
  272. package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
  273. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
  274. package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
  275. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
  276. package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
  277. package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
  278. package/dist/utility/wrun/wrun-refusal.util.js +103 -16
  279. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
  280. package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
  281. package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
  282. package/dist/utility/wrun/wrun-run-health.util.d.ts +95 -5
  283. package/dist/utility/wrun/wrun-run-health.util.js +209 -3
  284. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
  285. package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
  286. package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
  287. package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
  288. package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
  289. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +38 -11
  290. package/dist/utility/wrun/wrun-script-inputs.util.js +194 -56
  291. package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
  292. package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
  293. package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
  294. package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
  295. package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
  296. package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
  297. package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
  298. package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
  299. package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
  300. package/dist/utility/wrun/wrun-style-names.util.js +74 -0
  301. package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
  302. package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
  303. package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
  304. package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
  305. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
  306. package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
  307. package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
  308. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
  309. package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
  310. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
  311. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
  312. package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
  313. package/dist/utility/wrun/wrun-visibility-table.js +9 -0
  314. package/dist/utility/wrun/wrun-volume-profile.util.js +7 -3
  315. package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
  316. package/dist/utils/replay/replay-buffer-math.js +60 -30
  317. package/dist/workers/constants/socket-slots.d.ts +11 -7
  318. package/dist/workers/constants/socket-slots.js +6 -5
  319. 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, wrunPictureIdentityOf, } 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';
@@ -222,6 +239,7 @@ import { wrunCanvasChildId, wrunCellRowsOf } from './wrun-canvases.util.js';
222
239
  import { readWrunBatchedSections, wrunBatchedChildId, wrunSheetHasBatchedMarks } from './wrun-batched-marks.util.js';
223
240
  import { isWrunStyleTargetHidden } from './wrun-color-settings.util.js';
224
241
  import { buildWrunOverlayRunResult, closedLegCandles, forgetWrunOverlayCanvasState, openLegCandles, wrunLegReadsFormingOpen, wrunLegReadsLiveCandleOnly, cutWrunOddsLegRows, placeWrunResultTables, presentWrunIntegration, publishWrunRunHealth, publishWrunSessionCanvasNotices, recordWrunHostBuildMs, reseedWrunOverlayFromBuffers, wrunCandleAskSource, wrunCanvasHostFillFor, wrunChartPriceDigits, wrunHostFillContextFor, wrunLegFetchType, wrunLegPayloadExtras, wrunIntegratedRowsView, wrunSessionCanvasFillOf, wrunSessionPinnedSheet, wrunSessionRespelledSheet, wrunResultMarketUnits, wrunSessionRunHealth, } from './wrun-overlay-run.util.js';
242
+ import { builtinPortOf } from './wrun-builtin-twin.util.js';
225
243
  import { forgetWrunCanvasCache } from './wrun-canvas-cache.util.js';
226
244
  import { wrunLegNativeRowsOption } from './wrun-pin-venues.util.js';
227
245
  import { wrunSessionChartNamesOf } from './wrun-chart-context-names.util.js';
@@ -236,6 +254,7 @@ import { evictWrunRetainedOutputRows, ringWrunRunRetained, trimWrunRetainedCanva
236
254
  import { projectWrunRefusal, retractWrunRefusal, wrunRefusalRetractionCount } from './wrun-refusal-surface.util.js';
237
255
  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
256
  import { isWrunTradesLegLane, WRUN_TRADES_LANES, wrunTradesLegExtras } from './wrun-trades-lane.util.js';
257
+ import { WRUN_PINNED_LANE_SPECS, isWrunPinnedLaneId, wrunPinnedLaneExtras, wrunPinnedLaneOf, } from './wrun-pinned-lanes.util.js';
239
258
  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
259
  import { stampWrunLiveFrameOpra } from './wrun-cloud-opra-stamp.util.js';
241
260
  import { createWrunDownloadMeter, } from './wrun-download-meter.util.js';
@@ -245,6 +264,15 @@ const WRUN_BOOK_LIVE_UPDATE_MIN_MS = 1_000;
245
264
  /** Same pan-hold envelope as the kScript live drain. */
246
265
  const WRUN_LIVE_DRAIN_PAN_ACTIVE_MS = 750;
247
266
  const WRUN_LIVE_DRAIN_PAN_HOLD_MAX_MS = 2_500;
267
+ /** The settle gate's stillness (WRUN-PANBACK A2): a backward extension's episode hands off once the chart's view has
268
+ * not moved for this long on the motion clock (pan and zoom events, titan's probe), so a pointer-up pause this long
269
+ * rebuilds the pages so far and a shorter one stays inside the episode. The episode's own wake decides it, never the
270
+ * drain's cadence. */
271
+ export const WRUN_REBUILD_SETTLE_STILL_MS = 1_000;
272
+ /** The episode's wake polls this often (the pan-idle wait's poll) while titan's probe reads the button down (a held
273
+ * button stamps no pan event, so the motion clock the wake reads after the release is at most one poll old), and
274
+ * while the gate holds past the still period (a main fetch out, a run or a drain in flight). */
275
+ const WRUN_REBUILD_SETTLE_POLL_MS = 120;
248
276
  /** The reconcile window reaches this many bars behind the session watermark
249
277
  * (the kScript poll's 8-bar tail, V2_TECHNICAL_SOURCE_REFRESH_TAIL_BARS),
250
278
  * and a late point older than this many bars reseeds on its own gap. */
@@ -421,7 +449,7 @@ function readWrunLiveTickIdle(indicatorId) {
421
449
  const state = tickStates.get(indicatorId);
422
450
  if (state && (state.running || state.pending || state.timer !== undefined))
423
451
  return false;
424
- if (graceEndWakes.has(indicatorId))
452
+ if (graceEndWakes.has(indicatorId) || rebuildSettleWakes.has(indicatorId))
425
453
  return false;
426
454
  if (ledgers.get(indicatorId)?.inFlight)
427
455
  return false;
@@ -511,14 +539,20 @@ export function wrunLiveLanesOf(metadata) {
511
539
  /** Every lane a session's reconcile re-asks: the row builder's own lanes
512
540
  * the sheet declares, then the trades leg lanes the full run asked (kit 0.77.0:
513
541
  * 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. */
542
+ * asked is never re-asked), then the pinned lanes it asked (U9e: a book, oi,
543
+ * funding or liquidations input pinned to another market, by the buffers
544
+ * `context.pinnedLaneRows` holds; each re-asked on its own market, an oi lane's
545
+ * forming bucket by the same poll as the chart's own oi), then the registry
546
+ * poll lane instances the full run planned (`context.pollLanes`), then its row
547
+ * lane instances (`context.rowLanes`), in the full run's order. */
517
548
  export function wrunLiveLanesOfContext(context) {
518
- const tradeLegs = [...wrunDeclaredSourceLanes(context.metadata)].filter((lane) => isWrunTradesLegLane(lane) && context.tradeLegRows?.[lane] !== undefined);
549
+ const declared = [...wrunDeclaredSourceLanes(context.metadata)];
550
+ const tradeLegs = declared.filter((lane) => isWrunTradesLegLane(lane) && context.tradeLegRows?.[lane] !== undefined);
551
+ const pinnedLanes = declared.filter((lane) => isWrunPinnedLaneId(lane) && context.pinnedLaneRows?.[lane] !== undefined);
519
552
  return [
520
553
  ...wrunLiveLanesOf(context.metadata),
521
554
  ...tradeLegs,
555
+ ...pinnedLanes,
522
556
  ...(context.pollLanes ?? []).map((instance) => instance.key),
523
557
  ...(context.rowLanes ?? []).map((instance) => instance.key),
524
558
  ];
@@ -839,7 +873,9 @@ export function requestWrunOverlayLiveDrain(indicatorId) {
839
873
  const rearmedSessions = new WeakSet();
840
874
  /**
841
875
  * 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
876
+ * (landed, rejected, or skipped after planning), and on a warm switch's
877
+ * adoption (wrun-overlay-run.util adoptWrunParkedLiveSession), whose
878
+ * `session-start` drain can meet the adoption's own run in flight. A frame that arrived while
843
879
  * the prefix ran woke a drain the in-flight gate turned away
844
880
  * (`runWrunOverlayLiveTick` returns before its planner while any executor run
845
881
  * is active), and the scheduler then dropped its record with nothing pending,
@@ -862,6 +898,23 @@ export function rearmWrunLiveTickDrain(chartIndex, indicatorId) {
862
898
  rearmedSessions.add(context);
863
899
  requestWrunOverlayLiveDrain(indicatorId);
864
900
  }
901
+ /**
902
+ * The rows a session's evaluated bars read moved from `fromTs` on, with no lane point to say so: the host's session
903
+ * composition changed owner (web: an order-flow hand-back, or a new seam), so the bars it evaluated from the old
904
+ * seam read rows that are no longer the overlay's. It is the revised closed bar's obligation (`closedBarRevisions`):
905
+ * the next drain reseeds over the buffers, composed as they stand then, and no fetch is made. A session with no bar
906
+ * evaluated at or past `fromTs` owes nothing (the tail re-sends its forming bar anyway). Answers whether it owed.
907
+ */
908
+ export function reviseWrunOverlayLiveFrom(chartIndex, indicatorId, fromTs) {
909
+ const context = getWrunOverlayLiveContext(indicatorId);
910
+ if (!context || context.chartIndex !== chartIndex || !Number.isFinite(fromTs) || !(fromTs < context.lastRowTs)) {
911
+ return false;
912
+ }
913
+ context.dirtyFromTs = minTs(context.dirtyFromTs, fromTs);
914
+ closedBarRevisions.set(context, minTs(closedBarRevisions.get(context), fromTs));
915
+ requestWrunOverlayLiveDrain(indicatorId);
916
+ return true;
917
+ }
865
918
  /** Whether the drain that just ran met a run in flight while the overlay's session waits on it: a session a
866
919
  * prefix run re-armed, or a source-fed one with frames queued (the paint its install owes included). It owes
867
920
  * one more drain. */
@@ -1265,6 +1318,8 @@ function dropWrunLiveTickState(indicatorId) {
1265
1318
  ledgers.delete(indicatorId);
1266
1319
  dropWrunPinnedCloseTimer(indicatorId);
1267
1320
  dropWrunGraceEndWake(indicatorId);
1321
+ dropWrunRebuildSettleWake(indicatorId);
1322
+ wrunRunStarts.delete(indicatorId);
1268
1323
  if (chartIndex !== undefined) {
1269
1324
  wrunChartHostEnv().chart.clearLiveRefreshGate(chartIndex, indicatorId);
1270
1325
  wrunChartHostEnv().chart.clearLiveCoalesceWindow(chartIndex, indicatorId);
@@ -1433,8 +1488,13 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1433
1488
  // generations, so skip it (the rerun's fresh context resumes ticking; a
1434
1489
  // prefix run keeps the context and re-arms the drain on its outcome,
1435
1490
  // rearmWrunLiveTickDrain).
1436
- if (isWrunOverlayRerunInFlight(indicatorId))
1491
+ if (isWrunOverlayRerunInFlight(indicatorId)) {
1492
+ // An open rebuild episode (WRUN-PANBACK A2) keeps its wake coming past the run: a run that leaves this context
1493
+ // standing (a page, a failure) has the episode's pages handed off by the wake, with no frame to wake it.
1494
+ if (context.rebuildSettleSinceMs !== undefined)
1495
+ armWrunRebuildSettleWake(context);
1437
1496
  return;
1497
+ }
1438
1498
  // Past the gate: the drain a prefix's outcome re-armed is this one.
1439
1499
  rearmedSessions.delete(context);
1440
1500
  if (context.liveSuspended)
@@ -1545,7 +1605,8 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1545
1605
  rowLaneMoved: wrunRowLaneMovedInstance(context.rowLanes, context.acquisition) !== undefined ||
1546
1606
  wrunPollLaneMovedInstance(context.pollLanes, context.acquisition) !== undefined,
1547
1607
  reseedBudgetOpen: reseedBudgetOpen(ledger),
1548
- pollFloorBars: wrunReconcileFloorBars(chartMetadata?.exchange, intervalMs),
1608
+ // Keyed on the venue the chart's candles ride (a stock Trades chart's delayed tape, never POLYGON).
1609
+ pollFloorBars: wrunReconcileFloorBars(wrunChartStreamExchange(chartMetadata), intervalMs),
1549
1610
  nowMs,
1550
1611
  paceNowMs,
1551
1612
  etfFlowAnsweredAtMs: etfFlowAnsweredAt.get(context),
@@ -1557,6 +1618,11 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1557
1618
  });
1558
1619
  if (plan.kind === 'compute' && plan.reseedHeld === true)
1559
1620
  holdWrunReseedForPage(context);
1621
+ // A held backward extension's episode (WRUN-PANBACK A2) ends with any other plan: a prefix landed the page, the
1622
+ // session reaches the chart's first row again, or another rebuild hands off at once below.
1623
+ const backwardRebuild = plan.kind === 'rebuild' && plan.reason === 'history' && plan.extension === 'backward';
1624
+ if (!backwardRebuild)
1625
+ clearWrunRebuildSettle(context);
1560
1626
  if (plan.kind === 'rebuild') {
1561
1627
  // The rebuild goes to the overlay's full-run driver (it re-opens the
1562
1628
  // session), ONCE per chart shape: a failed rerun keeps this context
@@ -1566,10 +1632,30 @@ export async function runWrunOverlayLiveTick(indicatorId) {
1566
1632
  // successful rerun installs a fresh context, which carries no latch;
1567
1633
  // the chart moving to another shape hands off again.
1568
1634
  const shape = `${chartIdentity}|${firstTs}|${plan.reason}`;
1569
- if (context.rebuildHandoffShape !== shape) {
1635
+ if (context.rebuildHandoffShape === shape)
1636
+ return;
1637
+ if (!backwardRebuild) {
1570
1638
  context.rebuildHandoffShape = shape;
1571
1639
  noteWrunLiveRebuild(ledger, indicatorId);
1640
+ return;
1641
+ }
1642
+ // The settle gate (WRUN-PANBACK A2): a pan-back page is rarely the last one, and every handoff was a whole
1643
+ // rebuild whose result landed mid-drag (three pages in one 4.3 s gesture bought three, 2026-11-01 dump). While
1644
+ // the gesture is live, the view moved less than WRUN_REBUILD_SETTLE_STILL_MS ago or the main candle fetch is
1645
+ // out, the handoff waits; once all are quiet (or at the one ceiling) ONE handoff covers every page the episode
1646
+ // saw, carrying how long it held, and the latch takes the chart's shape at that handoff. The episode's wake
1647
+ // makes that handoff when no drain comes first; the two never decide at once (wrunRebuildSettleBusy).
1648
+ const since = context.rebuildSettleSinceMs;
1649
+ const atCeiling = since !== undefined && paceNowMs - since >= HEAVY_APPLY_GESTURE_CEILING_MS;
1650
+ const cause = atCeiling ? undefined : await wrunRebuildSettleCause(context.chartIndex);
1651
+ // A run that installed a fresh session (or a teardown) while the fetch state was read owns the overlay now.
1652
+ if (!wrunLiveContextCurrent(context, generation))
1653
+ return;
1654
+ if (cause !== undefined) {
1655
+ holdWrunBackwardRebuild(context, firstTs, paceNowMs, cause);
1656
+ return;
1572
1657
  }
1658
+ handOffWrunBackwardRebuild(context, ledger, firstTs, shape, paceNowMs, atCeiling ? 'ceiling' : 'quiet');
1573
1659
  return;
1574
1660
  }
1575
1661
  if (plan.kind === 'reseed') {
@@ -1848,8 +1934,14 @@ export async function integrateWrunOverlayLiveFrame(indicatorId, frame, cellRows
1848
1934
  : wrunHandlesOf(context.outputRows);
1849
1935
  if (handles !== undefined)
1850
1936
  attachWrunHandles(outputRows, handles);
1851
- if (frame.frames !== undefined)
1852
- attachWrunFrames(outputRows, frame.frames);
1937
+ // The frames snapshot replaces the session's (a frame without one keeps it): a frame the source did not take as
1938
+ // its newest snapshot carries none, and the session's held one IS the newer, so the frame-backed drawings keep
1939
+ // drawing from it instead of dropping for a tick, a fix of that tick's picture, and a repaint of the session (a
1940
+ // style save) builds its frame children from it. `framesReplaced` still reads the frame's own, so the children
1941
+ // stay as mounted.
1942
+ const frames = frame.frames ?? wrunFramesOf(context.outputRows);
1943
+ if (frames !== undefined)
1944
+ attachWrunFrames(outputRows, frames);
1853
1945
  // The run-level strategy output replaces the session's (a frame without one keeps it).
1854
1946
  const strategy = isWrunStrategyOutput(frame.strategy) ? frame.strategy : wrunStrategyOf(context.outputRows);
1855
1947
  if (strategy !== undefined)
@@ -1876,6 +1968,8 @@ export async function integrateWrunOverlayLiveFrame(indicatorId, frame, cellRows
1876
1968
  hostStartMs,
1877
1969
  cellRowsOf: () => cellRowsOf(ohlcvRows),
1878
1970
  });
1971
+ // The engine's ordering door took the frame's apply as a deferred unit (integrateWrunLiveTail): the frame is
1972
+ // taken, so its callers (the replay lane's cutoff) read it as applied rather than reopening the session.
1879
1973
  outcome = 'applied';
1880
1974
  });
1881
1975
  return outcome;
@@ -2037,11 +2131,258 @@ function handWrunLiveOverCapBack(context, ledger, lane, reason) {
2037
2131
  }
2038
2132
  /** A rebuild handoff to the full-run driver, counted here and in the intake's
2039
2133
  * 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) {
2134
+ * is never merged as a range refresh nor skipped as a duplicate range. A
2135
+ * backward extension's handoff carries how long its settle gate held
2136
+ * (`gestureHeldMs`, WRUN-PANBACK A2): the run's install hold waits only the
2137
+ * rest of the one ceiling. */
2138
+ function noteWrunLiveRebuild(ledger, indicatorId, gestureHeldMs) {
2042
2139
  ledger.stats.rebuilds += 1;
2043
2140
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'rebuild' });
2044
- void rerunWrunOverlayForChartWave(indicatorId, { reason: 'live-rebuild' });
2141
+ void rerunWrunOverlayForChartWave(indicatorId, {
2142
+ reason: 'live-rebuild',
2143
+ ...(gestureHeldMs !== undefined ? { gestureHeldMs } : {}),
2144
+ });
2145
+ }
2146
+ /** Why a backward extension's handoff waits now (WRUN-PANBACK A2): the chart is moving (`pan`, read first, in the
2147
+ * caller's task: its gesture is live, or its view moved less than WRUN_REBUILD_SETTLE_STILL_MS ago, so a pointer-up
2148
+ * pause shorter than that stays inside the pan), else its main candle fetch is in flight (`main-fetch`: a page is
2149
+ * still landing); undefined when all are quiet. A fetch state that cannot be read reads quiet. */
2150
+ async function wrunRebuildSettleCause(chartIndex) {
2151
+ if (wrunChartHostEnv().chart.isGestureLive(chartIndex) ||
2152
+ wrunSinceViewportMotionMs(chartIndex) < WRUN_REBUILD_SETTLE_STILL_MS) {
2153
+ return 'pan';
2154
+ }
2155
+ try {
2156
+ const dataFetching = await wrunChartHostEnv().chart.loadDataFetching();
2157
+ return dataFetching.isMainCandleFetchInFlight(chartIndex) === true ? 'main-fetch' : undefined;
2158
+ }
2159
+ catch {
2160
+ return undefined;
2161
+ }
2162
+ }
2163
+ /** Milliseconds since the chart's view last moved on the motion clock (its pan and zoom events and titan's probe: a
2164
+ * live probe reads as moving now, 0), Infinity when it never moved. */
2165
+ function wrunSinceViewportMotionMs(chartIndex) {
2166
+ const motionAt = wrunChartHostEnv().chart.motionAt(chartIndex);
2167
+ return motionAt > 0 ? Math.max(0, Date.now() - motionAt) : Number.POSITIVE_INFINITY;
2168
+ }
2169
+ /** Per overlay, the wake an open episode armed (WRUN-PANBACK A2): it hands the episode off itself once the view is
2170
+ * still and the main fetch quiet (or re-arms), whether or not a frame or a drain comes. Dropped with the episode and
2171
+ * on teardown. */
2172
+ const rebuildSettleWakes = new Map();
2173
+ /** Hold a backward extension's handoff (WRUN-PANBACK A2): the episode's start stamped once (the pacing clock), the
2174
+ * page added to the ones the handoff will collapse and rung once per page, and the episode's wake armed. */
2175
+ function holdWrunBackwardRebuild(context, firstTs, paceNowMs, cause) {
2176
+ const { chartIndex, indicatorId } = context;
2177
+ if (openWrunRebuildEpisode(context, firstTs, paceNowMs)) {
2178
+ wrunChartHostEnv().diagnostics.debug('wrun-rebuild-settle-held', { chartIndex, indicatorId, firstTs, cause });
2179
+ }
2180
+ }
2181
+ /** Open (or extend) a backward extension's episode (WRUN-PANBACK A2): its start stamped once, the page added to the
2182
+ * ones its handoff collapses, its wake armed. True when the page is new to the episode. */
2183
+ function openWrunRebuildEpisode(context, firstTs, paceNowMs) {
2184
+ context.rebuildSettleSinceMs ??= paceNowMs;
2185
+ const pages = (context.rebuildSettlePages ??= new Set());
2186
+ const added = !pages.has(firstTs);
2187
+ pages.add(firstTs);
2188
+ armWrunRebuildSettleWake(context);
2189
+ return added;
2190
+ }
2191
+ /** Arm an open episode's wake (WRUN-PANBACK A2): for the moment the view will have been still
2192
+ * WRUN_REBUILD_SETTLE_STILL_MS on the motion clock, else one poll on (titan's probe reads the button down, moving now,
2193
+ * or the gate holds past that moment). An armed wake stands: it fires no later than a deadline that motion moved on,
2194
+ * and re-arms for it. */
2195
+ function armWrunRebuildSettleWake(context) {
2196
+ const { chartIndex, indicatorId } = context;
2197
+ if (rebuildSettleWakes.has(indicatorId))
2198
+ return;
2199
+ const sinceMotionMs = wrunSinceViewportMotionMs(chartIndex);
2200
+ const delayMs = sinceMotionMs > 0 && sinceMotionMs < WRUN_REBUILD_SETTLE_STILL_MS
2201
+ ? WRUN_REBUILD_SETTLE_STILL_MS - sinceMotionMs
2202
+ : WRUN_REBUILD_SETTLE_POLL_MS;
2203
+ rebuildSettleWakes.set(indicatorId, setTimeout(() => {
2204
+ rebuildSettleWakes.delete(indicatorId);
2205
+ runWrunRebuildSettleWake(indicatorId).catch((error) => {
2206
+ console.warn(`[wrun] rebuild settle wake failed for '${indicatorId}' (the next drain decides):`, error);
2207
+ });
2208
+ }, delayMs));
2209
+ }
2210
+ /**
2211
+ * An open episode's wake (WRUN-PANBACK A2) decides the handoff itself. The drain read the gate on its own cadence: it
2212
+ * 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
2213
+ * pointer-up pause shorter than about 1.4 s was never seen and one episode spanned every drag until the final stop
2214
+ * (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
2215
+ * cheap gates go first and read none of the chart's rows: a drain mid-body or a run in flight that computes the
2216
+ * episode's pages (`wrunRebuildSettleBusy`), then the gate's cause (the gesture, the motion clock, the main candle
2217
+ * fetch). While one holds the wake only re-arms, at the poll for a fetch (the host gives no completion
2218
+ * signal), so a slow page costs one flag read a poll. Once all pass, ONE read of the chart's rows and the planner
2219
+ * hands the episode off (the latch, the generation). What only the drain decides goes to the drain, as before: a
2220
+ * session it plans under gates of its own, a page no longer read as a backward extension, a shape already handed off.
2221
+ */
2222
+ async function runWrunRebuildSettleWake(indicatorId) {
2223
+ const context = getWrunOverlayLiveContext(indicatorId);
2224
+ const since = context?.rebuildSettleSinceMs;
2225
+ // The episode ended (a handoff, another plan, a fresh run's context) or the overlay left.
2226
+ if (context === undefined || since === undefined)
2227
+ return;
2228
+ const { chartIndex, generation } = context;
2229
+ // A replay, a suspended, source-fed, paused or tripped session, the hidden hold and the settings oracle's freeze.
2230
+ if (wrunLiveHeld ||
2231
+ context.replay === true ||
2232
+ context.liveSuspended ||
2233
+ wrunSourceFedContexts.has(context) ||
2234
+ wrunChartHostEnv().clock.pageHidden() ||
2235
+ wrunOverlayPausedOrTripped(chartIndex, indicatorId)) {
2236
+ requestWrunOverlayLiveDrain(indicatorId);
2237
+ return;
2238
+ }
2239
+ if (wrunRebuildSettleBusy(context)) {
2240
+ armWrunRebuildSettleWake(context);
2241
+ return;
2242
+ }
2243
+ const paceNowMs = clock();
2244
+ const atCeiling = paceNowMs - since >= HEAVY_APPLY_GESTURE_CEILING_MS;
2245
+ const cause = atCeiling ? undefined : await wrunRebuildSettleCause(chartIndex);
2246
+ // The session moved on during the read: a fresh run's context, a teardown, the episode handed off or ended.
2247
+ if (!wrunLiveContextCurrent(context, generation) || context.rebuildSettleSinceMs !== since)
2248
+ return;
2249
+ // Moving (the button down, motion since the wake was armed), a fetch out, or a drain or a run started meanwhile.
2250
+ if (cause !== undefined || wrunRebuildSettleBusy(context)) {
2251
+ armWrunRebuildSettleWake(context);
2252
+ return;
2253
+ }
2254
+ const chartRows = wrunChartCandleRows(wrunChartHostEnv().chart.instance(chartIndex));
2255
+ const firstTs = chartRows.length > 0 ? Number(chartRows[0][0]) : undefined;
2256
+ const chartIdentity = wrunChartMarketIdentity(wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata);
2257
+ const shape = `${chartIdentity}|${firstTs}|history`;
2258
+ if (firstTs === undefined ||
2259
+ context.rebuildHandoffShape === shape ||
2260
+ !wrunBackwardExtensionNow(context, chartRows, chartIdentity, paceNowMs)) {
2261
+ requestWrunOverlayLiveDrain(indicatorId);
2262
+ return;
2263
+ }
2264
+ const handoffCause = atCeiling ? 'ceiling' : 'quiet';
2265
+ handOffWrunBackwardRebuild(context, ledgerFor(indicatorId), firstTs, shape, paceNowMs, handoffCause);
2266
+ }
2267
+ /** Whether the settle wake waits (WRUN-PANBACK A2): a drain is mid-body for the overlay (the ledger's `inFlight`: it
2268
+ * decides the episode itself, so the two never decide at once), or a run in flight computes the episode's pages (it
2269
+ * started on this market at or before the oldest page, so the session it installs holds them all and a handoff now
2270
+ * would rebuild them twice; a run whose start was not noted counts as one). A run that started before the pages loaded
2271
+ * never computes them, whether it still computes or holds its install for the gesture and the pacer (the last
2272
+ * episode's rebuild, field 2026-11-02: the final stop waited 1.4 to 1.7 s on those installs): the handoff goes now,
2273
+ * and the executor queues it as that run's one follow-up. */
2274
+ function wrunRebuildSettleBusy(context) {
2275
+ const { chartIndex, indicatorId } = context;
2276
+ if (ledgers.get(indicatorId)?.inFlight === true)
2277
+ return true;
2278
+ if (!isWrunOverlayRerunInFlight(indicatorId))
2279
+ return false;
2280
+ const start = wrunRunStarts.get(indicatorId);
2281
+ const pages = context.rebuildSettlePages;
2282
+ if (start === undefined || start.chartIndex !== chartIndex || pages === undefined || pages.size === 0)
2283
+ return true;
2284
+ const market = wrunChartMarketIdentity(wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata);
2285
+ return start.market !== market || start.firstTs <= Math.min(...pages);
2286
+ }
2287
+ /**
2288
+ * The lazy wave's second dispatcher, absorbed (WRUN-PANBACK A2): the chart's pan wave asks every overlay for a run per
2289
+ * lazy page, so a two-page gesture still bought two full runs per script beside the settle gate's one rebuild. The
2290
+ * executor offers each whole wave here before it queues or starts anything (`setWrunLazyWaveAbsorber`). While the
2291
+ * overlay's episode is open, or the chart's gesture is live, a wave for a page the gate will rebuild (the drain would
2292
+ * plan this session's rebuild as a backward extension now, under a latch that has not handed the shape off yet) is
2293
+ * taken in: the episode opens if none is yet, the page joins it, the request is rung, and the episode's one handoff
2294
+ * computes its rows. Anything else runs as before: an idle gesture with no episode, no session on this chart to
2295
+ * rebuild (none, a replay, a held or a source-fed one), a page the planner leaves to its prefix wave or reads otherwise.
2296
+ */
2297
+ function absorbWrunLazyWave(chartIndex, indicatorId, window) {
2298
+ const context = getWrunOverlayLiveContext(indicatorId);
2299
+ if (context === undefined || context.chartIndex !== chartIndex)
2300
+ return false;
2301
+ if (context.replay === true || context.liveSuspended || wrunSourceFedContexts.has(context))
2302
+ return false;
2303
+ if (context.rebuildSettleSinceMs === undefined && !wrunChartHostEnv().chart.isGestureLive(chartIndex))
2304
+ return false;
2305
+ const chartRows = wrunChartCandleRows(wrunChartHostEnv().chart.instance(chartIndex));
2306
+ if (chartRows.length === 0)
2307
+ return false;
2308
+ const firstTs = Number(chartRows[0][0]);
2309
+ const chartIdentity = wrunChartMarketIdentity(wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata);
2310
+ // A shape the latch handed off already never hands off again: its wave runs, as before.
2311
+ if (context.rebuildHandoffShape === `${chartIdentity}|${firstTs}|history`)
2312
+ return false;
2313
+ const paceNowMs = clock();
2314
+ if (!wrunBackwardExtensionNow(context, chartRows, chartIdentity, paceNowMs))
2315
+ return false;
2316
+ openWrunRebuildEpisode(context, firstTs, paceNowMs);
2317
+ wrunChartHostEnv().diagnostics.debug('wrun-rebuild-absorbed-wave', {
2318
+ chartIndex,
2319
+ indicatorId,
2320
+ firstTs,
2321
+ ...(window !== undefined ? { demandSpan: { fromMs: window.fromMs, toMs: window.toMs } } : {}),
2322
+ });
2323
+ return true;
2324
+ }
2325
+ /** Whether the drain would plan this session's rebuild as a backward extension now: the planner itself over the
2326
+ * chart's rows (a session at another interval: its run bars and its chart clock), with no gap and nothing folded, so
2327
+ * the waves the gate absorbs are the pages it holds. Reads only: the prefix grace's first sight is read, never
2328
+ * stamped. */
2329
+ function wrunBackwardExtensionNow(context, chartRows, chartIdentity, paceNowMs) {
2330
+ const firstTs = Number(chartRows[0][0]);
2331
+ const lastTs = Number(chartRows[chartRows.length - 1][0]);
2332
+ const runSession = wrunRunIntervalSessionOf(context);
2333
+ const seen = prefixPageSeen.get(context);
2334
+ const plan = decideWrunLiveTickPlan({
2335
+ context,
2336
+ mainRows: runSession ? wrunRunIntervalComputeRows(runSession.run, runSession.rows, lastTs) : chartRows,
2337
+ gaps: [],
2338
+ drained: { dirtyFromTs: null },
2339
+ chartIdentity,
2340
+ rowLaneMoved: wrunRowLaneMovedInstance(context.rowLanes, context.acquisition) !== undefined ||
2341
+ wrunPollLaneMovedInstance(context.pollLanes, context.acquisition) !== undefined,
2342
+ paceNowMs,
2343
+ prefixPageSeenAtMs: firstTs < context.firstRowTs ? (seen?.chartFirstTs === firstTs ? seen.atMs : paceNowMs) : undefined,
2344
+ ...(runSession ? { runClock: wrunLiveRunClockOf(runSession, context, chartRows) } : {}),
2345
+ });
2346
+ return plan.kind === 'rebuild' && plan.reason === 'history' && plan.extension === 'backward';
2347
+ }
2348
+ /** The one handoff of a backward extension's episode (WRUN-PANBACK A2), the drain's and the episode wake's: how long
2349
+ * the gate held (0 when it never did), rung with the pages it collapses (the held ones and this one), why it went now
2350
+ * and how long the view had been still (`sinceMotionMs`: 0 while it moves, at the ceiling; absent when the chart never
2351
+ * moved); the episode cleared, the latch taking the chart's shape, and ONE `live-rebuild` handed to the full-run
2352
+ * driver carrying the hold. */
2353
+ function handOffWrunBackwardRebuild(context, ledger, firstTs, shape, paceNowMs, cause) {
2354
+ const since = context.rebuildSettleSinceMs;
2355
+ const heldMs = since !== undefined ? Math.max(0, paceNowMs - since) : 0;
2356
+ const pages = new Set(context.rebuildSettlePages ?? []);
2357
+ pages.add(firstTs);
2358
+ const sinceMotionMs = wrunSinceViewportMotionMs(context.chartIndex);
2359
+ wrunChartHostEnv().diagnostics.debug('wrun-rebuild-handoff', {
2360
+ chartIndex: context.chartIndex,
2361
+ indicatorId: context.indicatorId,
2362
+ firstTs,
2363
+ heldMs,
2364
+ pagesCollapsed: pages.size,
2365
+ cause,
2366
+ ...(Number.isFinite(sinceMotionMs) ? { sinceMotionMs: Math.round(sinceMotionMs) } : {}),
2367
+ });
2368
+ clearWrunRebuildSettle(context);
2369
+ context.rebuildHandoffShape = shape;
2370
+ noteWrunLiveRebuild(ledger, context.indicatorId, heldMs);
2371
+ }
2372
+ /** End a backward extension's episode (WRUN-PANBACK A2): its fields and its wake go. */
2373
+ function clearWrunRebuildSettle(context) {
2374
+ if (context.rebuildSettleSinceMs === undefined && context.rebuildSettlePages === undefined)
2375
+ return;
2376
+ delete context.rebuildSettleSinceMs;
2377
+ delete context.rebuildSettlePages;
2378
+ dropWrunRebuildSettleWake(context.indicatorId);
2379
+ }
2380
+ function dropWrunRebuildSettleWake(indicatorId) {
2381
+ const wake = rebuildSettleWakes.get(indicatorId);
2382
+ if (wake === undefined)
2383
+ return;
2384
+ clearTimeout(wake);
2385
+ rebuildSettleWakes.delete(indicatorId);
2045
2386
  }
2046
2387
  /** A worker death's rebuild handoff to the casualty seam
2047
2388
  * (wrun-overlay-recovery.util), counted like any rebuild. The death's record
@@ -2290,8 +2631,22 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2290
2631
  // evaluation clock is this drain's: a pinned leg's candle that closed
2291
2632
  // since the last block is admitted by the re-sent forming row (the roll
2292
2633
  // 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() };
2634
+ // The session's as-of rides beside the drain's now (wrun-history-as-of.util): the carry already holds each
2635
+ // delivered stream's backlog start, so a tail reads it only through the session's own record.
2636
+ const clock = {
2637
+ intervalMs: wrunLiveIntervalMs(context, ohlcvRows),
2638
+ nowMs: serverNowMs(),
2639
+ historyAsOfMs: context.historyAsOfMs,
2640
+ };
2641
+ // The lanes the tail reads, composed where the host's session owns the overlay (wrun-session-composition.util):
2642
+ // the buffers stay OpenMarket's, and the token read here guards the answer below.
2643
+ const composition = composeWrunSessionSources({
2644
+ chartIndex: context.chartIndex,
2645
+ indicatorId,
2646
+ intervalMs: clock.intervalMs,
2647
+ lanes: wrunSessionLanesOfContext(context),
2648
+ }, laneSourcesOf(context, ohlcvRows));
2649
+ const sources = composition.sources;
2295
2650
  const tailRows = buildWrunInputTailRows(context.metadata, sources, tailFromTs, context.carrySeed, clock);
2296
2651
  if (tailRows.length === 0)
2297
2652
  return;
@@ -2348,6 +2703,14 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2348
2703
  // generation: nothing of it is touched.
2349
2704
  if (!wrunLiveContextCurrent(context, generation))
2350
2705
  return;
2706
+ // The session's composition moved while the block computed (an owner change): the answer read rows that are
2707
+ // no longer the overlay's. Nothing of it lands (no outputs, no watermark, no carry), and the drain runs again
2708
+ // over the composition as it stands; a roll the guest already took answers the next block with its order
2709
+ // error, whose reseed rebuilds over the buffers.
2710
+ if (composition.token !== wrunSessionCompositionToken(indicatorId)) {
2711
+ armWrunLiveDrain(context, false);
2712
+ return;
2713
+ }
2351
2714
  newestTs = tailRows[tailRows.length - 1].ts;
2352
2715
  outputRows = mergeWrunOutputTail(context.outputRows, tailOutputs, tailFromTs);
2353
2716
  // The block's answer carries the whole live handle set, the whole
@@ -2360,8 +2723,11 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2360
2723
  if (tickStrategy !== undefined)
2361
2724
  attachWrunStrategy(outputRows, tickStrategy);
2362
2725
  tickFrames = wrunFramesOf(tailOutputs);
2363
- if (tickFrames !== undefined)
2364
- attachWrunFrames(outputRows, tickFrames);
2726
+ // A block without a frames snapshot keeps the session's, the socket frame's rule: the rows never lose the
2727
+ // snapshot a repaint of the session builds its frame children from (`framesReplaced` reads the block's own).
2728
+ const frames = tickFrames ?? wrunFramesOf(context.outputRows);
2729
+ if (frames !== undefined)
2730
+ attachWrunFrames(outputRows, frames);
2365
2731
  // The run budget (design 5): past the session's cap its oldest rows go, so the merged result never passes
2366
2732
  // the worker's or the integrated-row budget; the whole window repaints once per crossing.
2367
2733
  const retained = wrunLiveRetainedRows(context, outputRows);
@@ -2429,6 +2795,59 @@ async function computeWrunOverlayTail(context, ledger, generation, tc, meta, ohl
2429
2795
  * socket row source's live frames (`integrateWrunOverlayLiveFrame`) both end here, so a frame costs
2430
2796
  * the cloud lane what a block costs the browser lane. Runs under the overlay's session lock. */
2431
2797
  async function integrateWrunLiveTail(tail) {
2798
+ if (deferWrunLiveTailWhileHeld(tail))
2799
+ return 'deferred';
2800
+ await integrateWrunLiveTailNow(tail);
2801
+ return 'applied';
2802
+ }
2803
+ /**
2804
+ * Ordered behind the overlay's queued updates: while the engine's ingest queue still holds updates of this overlay
2805
+ * (a gesture's sliced ingest), the WHOLE apply phase of this integrate waits behind them as one host unit owned by
2806
+ * the overlay: the parent's live ladder, the child overlays (their pack wait included), the presentation, the
2807
+ * painted watermark and repaint bookkeeping, and the failure path. Nothing of it runs now, so no mounted row (the
2808
+ * parent's or a lower-pane child's) moves before the queued updates land. The door is the chart's own
2809
+ * `enqueueHeldHostApply` (live-feed.service.ts `enqueueHeldOverlayApply` calls the same door; the package reaches
2810
+ * the chart): it answers false when nothing of the overlay is queued, and inside a queued unit, and the integrate
2811
+ * then runs in the tick as before. True when the queue took the unit.
2812
+ */
2813
+ function deferWrunLiveTailWhileHeld(tail) {
2814
+ const door = tail.tc.enqueueHeldHostApply;
2815
+ if (typeof door !== 'function')
2816
+ return false;
2817
+ try {
2818
+ return door.call(tail.tc, () => replayWrunLiveTail(tail), tail.context.indicatorId) === true;
2819
+ }
2820
+ catch {
2821
+ return false;
2822
+ }
2823
+ }
2824
+ /**
2825
+ * The queued unit when it runs. The tick's apply gates are read again (the context and its generation, replay, pause
2826
+ * or a tripped guard, the market identity, protection, the pane budget), and the chart must still be the tick's chart
2827
+ * mounting the tick's meta under the overlay id (a remount without a generation bump hands a fresh meta): a failing
2828
+ * recheck drops the unit, nothing applied. The integrate starts inside the engine's drain, in order with the overlay's
2829
+ * other queued units; it does not take the session lock (that wait is a promise, and the parent's apply must land inside
2830
+ * the unit), and a tick holding the lock meanwhile defers its own apply behind it while the engine still drains. A
2831
+ * failure runs the tick's own failure path: the repaint stays owed and a classified refusal is said once.
2832
+ */
2833
+ function replayWrunLiveTail(tail) {
2834
+ const { context, generation, tc, meta, ledger } = tail;
2835
+ const { chartIndex, indicatorId } = context;
2836
+ if (!wrunLiveTickEligible(context, generation))
2837
+ return;
2838
+ const current = wrunChartHostEnv().chart.instance(chartIndex);
2839
+ const mounted = current?.metadata?.find((candidate) => candidate.id === indicatorId);
2840
+ if (current !== tc || mounted !== meta)
2841
+ return;
2842
+ // The tick's clock stopped with the tick: the replay is its own apply sample.
2843
+ const mainClock = new MainThreadClock();
2844
+ void integrateWrunLiveTailNow({ ...tail, mainClock, hostStartMs: mainClock.read() }).catch((error) => {
2845
+ console.warn(`[wrun] queued live apply failed for '${indicatorId}' (keeping the last rendered result):`, error);
2846
+ void noteWrunLiveTickRefusal(context, ledger, generation, error);
2847
+ });
2848
+ }
2849
+ /** The integrate itself, now (`integrateWrunLiveTail` decides whether it waits behind queued updates first). */
2850
+ async function integrateWrunLiveTailNow(tail) {
2432
2851
  const { context, ledger, generation, tc, meta, outputRows, newestTs, tailFromTs, framesReplaced, holdsResult, evicted = false, runSession, mainClock, hostStartMs, cellRowsOf, } = tail;
2433
2852
  const { indicatorId } = context;
2434
2853
  // An eviction moved the session's first row: no tail of the shown result describes the mount any more.
@@ -2475,9 +2894,9 @@ async function integrateWrunLiveTail(tail) {
2475
2894
  // ran with, so a tick never flips a `{{label}}` back to the declared ones.
2476
2895
  texts: wrunTextParamValuesFromSettings(context.metadata, meta.settings),
2477
2896
  // 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),
2897
+ // tier off the session's chain acquisition, a Cloud session's off its newest frame's receipt, the delayed CME
2898
+ // legs the installing run read), so a tick never drops it.
2899
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, context.cloudOpraServed, context.cmeDelayed),
2481
2900
  position: context.position,
2482
2901
  axis: context.axis,
2483
2902
  colors: context.colors,
@@ -2512,6 +2931,8 @@ async function integrateWrunLiveTail(tail) {
2512
2931
  ...(hostFill.tickSize !== undefined ? { priceTick: hostFill.tickSize } : {}),
2513
2932
  ...(canvasFill.tpoBlockSize !== undefined ? { tpoBlockSize: canvasFill.tpoBlockSize } : {}),
2514
2933
  overlayId: indicatorId,
2934
+ // A built-in's port names its lines in its built-in's words, as its full run did (wrun-output-words.util).
2935
+ builtIn: builtinPortOf(meta.settings),
2515
2936
  };
2516
2937
  const projection = runSession
2517
2938
  ? wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange)
@@ -2566,6 +2987,10 @@ async function integrateWrunLiveTail(tail) {
2566
2987
  // The canvases' rows since the bar they last painted (or swapped whole).
2567
2988
  ...canvasPass.mount,
2568
2989
  ...(projection ? { projection } : {}),
2990
+ // What the session computed these rows for (its full run's settings generation and market, never the
2991
+ // settings' current ones: a save leaves the session ticking until its rerun installs): an eviction's or a
2992
+ // gap's swap, or a window that rolled past the mounted rows, keeps each heatmap's colour scale.
2993
+ pictureIdentity: wrunPictureIdentityOf(context),
2569
2994
  // OT29: the lower pane's legend prints prices at the chart's digits.
2570
2995
  priceDigits: () => wrunChartPriceDigits(context.chartIndex) ?? priceDigits ?? 2,
2571
2996
  onMainThreadMs: (ms) => mainClock.add(ms),
@@ -2942,7 +3367,8 @@ function wrunLiveBatchedMarksTail(tc, indicatorId, metadata, tailFromTs) {
2942
3367
  * at or after the block's first ts. Walks back from the end (rows are in
2943
3368
  * ts order), so the merge costs the tail, not a full re-walk by timestamp;
2944
3369
  * a fresh array so the previous rows' attachments (handles, strategy,
2945
- * frames) never leak onto the merged rows. */
3370
+ * frames) never leak onto the merged rows: each caller attaches what the
3371
+ * block answered and carries by name what it keeps. */
2946
3372
  function mergeWrunOutputTail(stored, tail, fromTs) {
2947
3373
  let keep = stored.length;
2948
3374
  while (keep > 0 && stored[keep - 1].ts >= fromTs)
@@ -2990,6 +3416,8 @@ function laneSourcesOf(context, ohlcvRows) {
2990
3416
  tradeLegRows: context.tradeLegRows,
2991
3417
  // Each trades leg's rows ride the tier its acquisition names (the full run's ask, the intake's fold).
2992
3418
  tradeLegIntervals: wrunTradeLegIntervals(context.acquisition),
3419
+ // The pinned lanes (U9e): each foreign ask of a class reads the lane of its market.
3420
+ pinnedLaneRows: context.pinnedLaneRows,
2993
3421
  // Each grid leg asked at a tier rides it (the full run's records).
2994
3422
  pinnedLegTierMs: wrunPinnedLegTierMs(context.pinnedLegs),
2995
3423
  pinnedCandleRows: context.pinnedCandleRows,
@@ -3006,10 +3434,11 @@ function laneSourcesOf(context, ohlcvRows) {
3006
3434
  // The market the session runs on, at the tail clock's interval: a new live bar reads its own
3007
3435
  // `time.trade_date` / `time.session`, and a grid leg lands on its bar grid (`barGrid`).
3008
3436
  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.
3437
+ // The chart's forming bar, on the chart's stream clock (a delayed chart's newest bar holds now less the delay):
3438
+ // a grid leg's row still forming past the chart's newest bar lands in the bar holding its open when that bar is
3439
+ // this one. A replay session's chart is historical.
3011
3440
  formingBarTs: wrunLiveChartIsLive(context)
3012
- ? hostBucketResolverFor(intervalMs, liveBucketVenueOf(context.market))(serverNowMs())
3441
+ ? wrunChartFormingBarTs(intervalMs, wrunChartStreamRefOf(context.chartIndex, context.market))
3013
3442
  : null,
3014
3443
  };
3015
3444
  }
@@ -3140,7 +3569,7 @@ lastMainTs) {
3140
3569
  console.warn(`[wrun] live reconcile lane '${lane}' failed for '${indicatorId}' (its buckets stay outstanding):`, outcome.reason);
3141
3570
  return;
3142
3571
  }
3143
- const merged = mergeWrunReconcileAnswer(context, lane, outcome.status === 'fulfilled' ? outcome.value : [], plan.fromTs, plan.toTs, lane === 'tape' ? tapeServedStartMs : undefined);
3572
+ const merged = mergeWrunReconcileAnswer(context, lane, outcome.status === 'fulfilled' ? outcome.value : [], plan.fromTs, plan.toTs, lane === 'tape' ? tapeServedStartMs : undefined, legNowMs);
3144
3573
  // The ETF lane's slow re-check counts from this answer's ask (wrunEtfFlowRecheckDue), and so
3145
3574
  // does a poll lane's own pace (wrunPollLaneRecheckDue).
3146
3575
  if (lane === 'etf_flow')
@@ -3343,11 +3772,20 @@ async function fetchWrunReconcileLane(context, ledger, lane, fromTs, toTs, meta)
3343
3772
  return fetchWrunOptionSummaryReconcileLane(context, ledger, lane, fromTs, toTs, meta);
3344
3773
  }
3345
3774
  // 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).
3775
+ // its id: the payload the full run recorded, else the one its id names (never the chart's own). A
3776
+ // pinned lane (U9e) re-asks its class's K source on its own market under its id the same way (an oi
3777
+ // lane's forming bucket by the poll that re-asks the chart's own oi).
3347
3778
  const leg = isWrunTradesLegLane(lane);
3348
- const spec = leg ? { type: 'buy_sell_volume', key: lane } : LANE_FETCH[lane];
3779
+ const pinned = wrunPinnedLaneOf(lane);
3780
+ const spec = leg
3781
+ ? { type: 'buy_sell_volume', key: lane }
3782
+ : pinned !== undefined
3783
+ ? { type: WRUN_PINNED_LANE_SPECS[pinned.cls].type, key: lane }
3784
+ : LANE_FETCH[lane];
3349
3785
  const acquisition = context.acquisition[lane];
3350
- const extras = acquisition ?? (leg ? wrunTradesLegExtras(lane) : {});
3786
+ // The payload extras over the current-market placeholders: a market only where the lane names one (a leg or a pinned
3787
+ // lane, its recorded acquisition), so the chart's own lanes keep asking `currentSymbol` / `currentExchange`.
3788
+ const extras = acquisition ?? (leg ? wrunTradesLegExtras(lane) : isWrunPinnedLaneId(lane) ? wrunPinnedLaneExtras(lane) : {});
3351
3789
  // A lane the full run asked on the fetch's native-rows path records it on its acquisition (a governed
3352
3790
  // options chain: its rows are its plane's, never the index-mode market's), so the reconcile asks the
3353
3791
  // same way.
@@ -3395,9 +3833,9 @@ async function fetchWrunReconcileLane(context, ledger, lane, fromTs, toTs, meta)
3395
3833
  return { rows, whole: wrunSourceVerdictWhole(verdict) };
3396
3834
  });
3397
3835
  }
3398
- if (lane !== 'book')
3836
+ if (lane !== 'book' && pinned?.cls !== 'book')
3399
3837
  return (await ask(nativeRows ? { nativeRows: true } : {})) ?? [];
3400
- // The full run asks the book packed-first unconditionally; an acquisition
3838
+ // The full run asks the book (a pinned book too) packed-first unconditionally; an acquisition
3401
3839
  // record that opts out of the packed worker is honored should the install
3402
3840
  // ever carry one.
3403
3841
  const packedFirst = acquisition?.preferPackedOrderbookWorker !== false;
@@ -3483,7 +3921,7 @@ async function fetchWrunPollLaneReconcile(context, ledger, laneId, fromTs, toTs,
3483
3921
  const askFromTs = wrunReconcileLaneWindowFrom(context, laneId, fromTs, toTs);
3484
3922
  // A daily lane on a chart coarser than a day asks through today when the
3485
3923
  // chart-bar window closed before it (the forming bar of a session grid).
3486
- const askToTs = wrunPollLaneReconcileTo(lane, toTs, context.intervalMs, Date.now());
3924
+ const askToTs = wrunPollLaneReconcileTo(lane, toTs, context.intervalMs, serverNowMs());
3487
3925
  // The run's recorded payload; an OPRA lane's asked again at the tier the read is routed to now, and a chain
3488
3926
  // instance's with the fields its own chain's plane names at that tier (`wrunPollLaneChainAsk`).
3489
3927
  const recorded = context.acquisition[laneId] ?? instance.extras;
@@ -3498,6 +3936,10 @@ async function fetchWrunPollLaneReconcile(context, ledger, laneId, fromTs, toTs,
3498
3936
  fromTs: askFromTs,
3499
3937
  toTs: askToTs,
3500
3938
  intervalMs: context.intervalMs,
3939
+ signal: wrunLaneFetchSignal(context.indicatorId, {
3940
+ chartIndex: context.chartIndex,
3941
+ generation: getChartDataFetchGeneration(context.chartIndex),
3942
+ }),
3501
3943
  }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun live reconcile fetch '${lane.kType}' (${instance.key}) for '${context.fetchKey}'`);
3502
3944
  }
3503
3945
  const askOnce = (askExtras, from, to) => askWrunReconcileSource(context, ledger, {
@@ -3551,12 +3993,27 @@ async function fetchWrunRowLaneReconcile(context, ledger, laneId, fromTs, toTs,
3551
3993
  ? wrunOpraLanePayloadAt(recorded, governedMarketDataTier('OPRA'))
3552
3994
  : wrunRowLaneChainAsk(lane, recorded, governedMarketDataTier);
3553
3995
  const laneFetch = lane.fetch;
3996
+ // Taken before the read's awaits, bound to the chart's dataset: a teardown or the dataset's end meanwhile aborts it.
3997
+ const laneSignal = laneFetch === undefined
3998
+ ? undefined
3999
+ : wrunLaneFetchSignal(context.indicatorId, {
4000
+ chartIndex: context.chartIndex,
4001
+ generation: getChartDataFetchGeneration(context.chartIndex),
4002
+ });
3554
4003
  const laneFromTs = wrunReconcileLaneWindowFrom(context, laneId, fromTs, toTs);
3555
4004
  const window = wrunReconcileHostGridWindow(context, laneFromTs, toTs);
3556
4005
  const rows = await fetchWrunRowLaneRows(lane, extras, replay === undefined ? window : { ...window, replayCursorMs: replay.cursorMs }, { fromTs: laneFromTs, toTs }, async (askExtras, from, to, whole) => {
3557
4006
  if (laneFetch !== undefined) {
3558
4007
  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}'`);
4008
+ const own = await withWrunDeadline(laneFetch({
4009
+ extras: askExtras,
4010
+ fromTs: from,
4011
+ toTs: to,
4012
+ intervalMs: context.intervalMs,
4013
+ nowMs: window.nowMs,
4014
+ hostBars: wrunHostBarSpansWithin(window, from, to),
4015
+ signal: laneSignal,
4016
+ }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun live reconcile fetch '${lane.kType}' (${instance.key}) for '${context.fetchKey}'`);
3560
4017
  // A lane's own fetch rides no chart transport (no synthetic completion): its answer is whole once it resolved.
3561
4018
  whole?.(true);
3562
4019
  return own;
@@ -3671,7 +4128,7 @@ async function fetchWrunEtfFlowReconcileLane(context, ledger, fromTs, toTs, meta
3671
4128
  fromTs: dayFrom,
3672
4129
  // Through today on a chart coarser than a day whose window closed
3673
4130
  // before it (the forming bar of a session grid).
3674
- toTs: wrunDailyLaneReconcileTo(toTs, context.intervalMs, Date.now()),
4131
+ toTs: wrunDailyLaneReconcileTo(toTs, context.intervalMs, serverNowMs()),
3675
4132
  interval: WRUN_ETF_FLOW_INTERVAL_KEY,
3676
4133
  }, meta);
3677
4134
  if (rows === null)
@@ -3922,7 +4379,9 @@ function mergeWrunReconcileAnswer(context, lane, answerRows, fromTs, toTs,
3922
4379
  /** Tape only: the first stamp the ask served prints from (the window start's bar open, the
3923
4380
  * aligned seed start, the retention horizon or the gateway's bar limit, whichever is latest); an
3924
4381
  * answered bucket that opened before it is PARTIAL. */
3925
- servedStartMs) {
4382
+ servedStartMs,
4383
+ /** The server's now the ask left at: a delayed stream's reply ends at the reader's cut of that instant. */
4384
+ askNowMs) {
3926
4385
  // A daily lane's rows are day-stamped and its ask opens before the
3927
4386
  // chart-bar window (the ETF lane, a registry lane with a daily join: the
3928
4387
  // window's day, the lane's lookback earlier): the answer is authoritative
@@ -3945,17 +4404,22 @@ servedStartMs) {
3945
4404
  // runs ahead of its 17:00 Chicago open) is partial: the answer holds only its later prints, so
3946
4405
  // it is dropped from the answer and read like a bucket before the horizon (the fed row stands,
3947
4406
  // 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'
4407
+ const answerWhole = lane === 'tape'
3949
4408
  ? wrunTapeAnswerUnion(servedStartMs === undefined
3950
4409
  ? answerRows
3951
4410
  : wrunTapeAnswerWithoutPartialHead(answerRows, servedStartMs, context.intervalMs, context.market?.exchange), before)
3952
4411
  : isWrunRowLaneId(lane)
3953
4412
  ? wrunRowLaneReconcileAnswer(context, lane, before, answerRowsInWindow)
3954
4413
  : answerRows;
3955
- const horizonTs = lane === 'tape' ? wrunTapeAnswerHorizonTs(answer) : Number.NEGATIVE_INFINITY;
3956
4414
  // A row lane fed live with a union rule of its own (`liveByCoin.reconcile`) keeps, like the tape, every held bar the
3957
4415
  // answer does not name: its reconcile only ever adds to a bar, so a print shown live never vanishes.
3958
4416
  const keepsHeld = lane === 'tape' || (isWrunRowLaneId(lane) && wrunRowLaneKeepsHeld(context, lane));
4417
+ // 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
4418
+ // row the live feed built (a fed bucket) stands and stays owed (`wrunReconcileHeldRowWins`). A union lane already
4419
+ // keeps what it held.
4420
+ const heldWins = keepsHeld ? new Set() : wrunLiveHeldRowsWinning(context, lane, before, askNowMs);
4421
+ const answer = heldWins.size === 0 ? answerWhole : answerWhole.filter((row) => !heldWins.has(Number(row[0])));
4422
+ const horizonTs = lane === 'tape' ? wrunTapeAnswerHorizonTs(answer) : Number.NEGATIVE_INFINITY;
3959
4423
  const answered = new Set();
3960
4424
  let earliestAnsweredTs = Number.POSITIVE_INFINITY;
3961
4425
  for (const row of answer) {
@@ -3973,7 +4437,7 @@ servedStartMs) {
3973
4437
  const ts = Number(row[0]);
3974
4438
  if (!Number.isFinite(ts) || ts < windowFrom || answered.has(ts))
3975
4439
  continue;
3976
- if (ts >= toTs || ts < horizonTs || keepsHeld) {
4440
+ if (ts >= toTs || ts < horizonTs || keepsHeld || heldWins.has(ts)) {
3977
4441
  keep.add(ts);
3978
4442
  continue;
3979
4443
  }
@@ -4039,7 +4503,7 @@ function laneRevisedFromTs(context, lane, before, merged, scanFromTs, endTs) {
4039
4503
  const revised = laneWindowRevisedFromTs(before, merged, Math.max(scanFromTs, firstDay), endTs);
4040
4504
  if (landing !== 'last' || scanFromTs >= firstDay)
4041
4505
  return revised;
4042
- return wrunDailyLaneHeadEqual(before, merged, firstDay, laneValuesEqual) ? revised : minTs(revised, firstDay);
4506
+ return wrunDailyLaneHeadEqual(before, merged, firstDay, wrunLaneValuesEqual) ? revised : minTs(revised, firstDay);
4043
4507
  }
4044
4508
  /** The landing of a lane whose rows are one per UTC day (the ETF flow lane,
4045
4509
  * a registry lane with a daily join), null for a lane joined per bar. */
@@ -4079,7 +4543,8 @@ function wrunReconcileLaneOwnFrom(context, lane, fromTs) {
4079
4543
  return descriptor === undefined ? fromTs : wrunPollLaneReconcileFrom(descriptor, fromTs, context.firstRowTs);
4080
4544
  }
4081
4545
  /** 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
4546
+ * `OPRA` for an OPRA row lane (`governed: 'opra'`) or poll lane (`opra`), on whatever chart hosts it; a `stocks` row
4547
+ * lane's tape (its acquisition's `exchange`); a chain
4083
4548
  * 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
4549
  * for every other lane (a plain chain included): it reads the chart's own market, whose poll window the plan's floor
4085
4550
  * already is, or no gate's. */
@@ -4090,6 +4555,10 @@ function wrunLaneGovernedPlane(context, lane) {
4090
4555
  if (instance !== undefined && descriptor?.chain !== undefined) {
4091
4556
  return wrunRowLaneChainGovernedExchange(descriptor, context.acquisition[lane] ?? instance.extras);
4092
4557
  }
4558
+ // A `stocks` lane reads its tape (its acquisition's exchange), whose delayed window the chart's own market may not.
4559
+ if (instance !== undefined && descriptor?.governed === 'stocks') {
4560
+ return wrunRowLaneStocksTapeOf(descriptor, context.acquisition[lane] ?? instance.extras);
4561
+ }
4093
4562
  return descriptor?.governed === 'opra' ? 'OPRA' : null;
4094
4563
  }
4095
4564
  if (isWrunPollLaneId(lane)) {
@@ -4127,11 +4596,35 @@ function laneRowsOf(context, lane) {
4127
4596
  return context.pollLaneRows?.[lane];
4128
4597
  if (isWrunRowLaneId(lane))
4129
4598
  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).
4599
+ // A trades leg lane's buffer rides its one record, as a poll lane's (LANE_ROWS_FIELD names the builtin buffers), and
4600
+ // so does a pinned lane's (U9e).
4131
4601
  if (isWrunTradesLegLane(lane))
4132
4602
  return context.tradeLegRows?.[lane];
4603
+ if (isWrunPinnedLaneId(lane))
4604
+ return context.pinnedLaneRows?.[lane];
4133
4605
  return context[LANE_ROWS_FIELD[lane]];
4134
4606
  }
4607
+ /** The held buckets of a lane whose live-built row wins over a reconcile answer (`wrunReconcileHeldRowWins`): fed
4608
+ * buckets still open at the reader's cut of the ask, on the delayed stream the lane reads (its governed plane, else
4609
+ * the venue the chart's candles ride). Empty on a real-time stream. */
4610
+ function wrunLiveHeldRowsWinning(context, lane, held, askNowMs) {
4611
+ const wins = new Set();
4612
+ const fed = context.fedBuckets[lane];
4613
+ if (askNowMs === undefined || !fed || fed.size === 0)
4614
+ return wins;
4615
+ const stream = wrunLaneGovernedPlane(context, lane) ??
4616
+ wrunChartStreamExchange(wrunChartStreamRefOf(context.chartIndex, context.market));
4617
+ const cutMs = wrunStreamCutMs(stream, askNowMs);
4618
+ if (cutMs === null)
4619
+ return wins;
4620
+ for (const row of held) {
4621
+ const bucketTs = Number(row[0]);
4622
+ if (wrunReconcileHeldRowWins({ bucketTs, intervalMs: context.intervalMs, cutMs, heldLiveBuilt: fed.has(bucketTs) })) {
4623
+ wins.add(bucketTs);
4624
+ }
4625
+ }
4626
+ return wins;
4627
+ }
4135
4628
  /** The first bucket a tape answer speaks for (its oldest row); +Infinity for an empty answer,
4136
4629
  * which speaks for no bucket at all. */
4137
4630
  function wrunTapeAnswerHorizonTs(answer) {
@@ -4201,6 +4694,9 @@ function wrunTapeServedStartMs(context, windowFromTs, nowMs) {
4201
4694
  retentionSec: lane.retentionSec,
4202
4695
  barLimitSec: lane.barLimitSec,
4203
4696
  exchange: context.market?.exchange,
4697
+ // The seed counts back from the instant the acquisition names (the session's pin, a replay's present), the one
4698
+ // the control's request builder reads on this re-ask (wrun-history-as-of.util).
4699
+ historyAsOfMs: context.acquisition.tape?.[SOURCE_HISTORY_AS_OF_FIELD],
4204
4700
  });
4205
4701
  }
4206
4702
  function setLaneRows(context, lane, rows) {
@@ -4220,6 +4716,10 @@ function setLaneRows(context, lane, rows) {
4220
4716
  context.tradeLegRows = { ...context.tradeLegRows, [lane]: rows };
4221
4717
  return;
4222
4718
  }
4719
+ if (isWrunPinnedLaneId(lane)) {
4720
+ context.pinnedLaneRows = { ...context.pinnedLaneRows, [lane]: rows };
4721
+ return;
4722
+ }
4223
4723
  context[LANE_ROWS_FIELD[lane]] = rows;
4224
4724
  }
4225
4725
  /** The earliest bucket in [fromTs, endTs) that differs between the two row
@@ -4286,35 +4786,11 @@ function laneRowsEqual(a, b) {
4286
4786
  return false;
4287
4787
  continue;
4288
4788
  }
4289
- if (!laneValuesEqual(x, y))
4789
+ if (!wrunLaneValuesEqual(x, y))
4290
4790
  return false;
4291
4791
  }
4292
4792
  return true;
4293
4793
  }
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
4794
  // ---------------------------------------------------------------------------
4319
4795
  // Reseed: a new session over the buffers, no fetch (the full run's owner).
4320
4796
  // ---------------------------------------------------------------------------
@@ -4367,10 +4843,15 @@ async function reseedWrunOverlay(context, ledger, reason, mainClock) {
4367
4843
  ledger.lastReseedAt = Date.now();
4368
4844
  // A reseed a page held is served.
4369
4845
  heldPageReseeds.delete(context);
4370
- // Every bar was evaluated again from the buffers: no revised closed bar is owed any more.
4371
- closedBarRevisions.delete(context);
4846
+ // Every bar was evaluated again from the buffers: no revised closed bar is owed any more, unless the host's
4847
+ // session changed owner while the reseed reopened (its revision from the old seam, which these rows never read,
4848
+ // stays owed for the next drain; wrun-session-composition.util).
4849
+ const ownerRevisionKept = takeWrunCompositionRevisionKept(context);
4850
+ if (!ownerRevisionKept)
4851
+ closedBarRevisions.delete(context);
4372
4852
  if (getWrunOverlayLiveContext(indicatorId) === context) {
4373
- context.dirtyFromTs = null;
4853
+ if (!ownerRevisionKept)
4854
+ context.dirtyFromTs = null;
4374
4855
  // The session re-evaluated the whole window from its primary rows (the
4375
4856
  // chart's, or a session's run bars at another interval).
4376
4857
  const rows = wrunRunIntervalSessionOf(context)?.rows ??
@@ -4564,7 +5045,8 @@ function wrunRowsHoldTs(rows, ts) {
4564
5045
  /**
4565
5046
  * Decide one drain's plan from the context, the chart's main rows, the gap
4566
5047
  * 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
5048
+ * moved row-lane acquisition, a coins tape whose market traded below its
5049
+ * priced low x 0.9, or history (a clamped session: a head rolled
4568
5050
  * past its first row; a pan-back page left to its wave is not one, C1), or a
4569
5051
  * gap wider than 250 bars, rebuilds; any reconcile trigger
4570
5052
  * (session-start, main-jump, wake, poll-due; main-jump is detected here from
@@ -4625,10 +5107,29 @@ export function decideWrunLiveTickPlan(input) {
4625
5107
  if (input.rowLaneMoved === true) {
4626
5108
  return { kind: 'rebuild', reason: 'acquisition' };
4627
5109
  }
5110
+ // A coins tape (C-COINS item 2) priced its dollar floor off the lowest price its window traded at: once the market
5111
+ // trades below that price x 0.9 the floor could drop a print of its coins, so the full run prices the window again
5112
+ // (wrun-tape-coins.util). The market's prices: the chart's bars the session has not passed where the run priced off
5113
+ // them (`priceFromChart`), else the prints the session took off the tape's channel (a formula chart's bars are
5114
+ // another series). Before any fold or reconcile reads the old floor.
5115
+ const tapeTradedLow = wrunCoinTapeGuardLow(context.acquisition.tape, mainRows, context.lastRowTs, context.tapePriceLow);
5116
+ if (wrunCoinTapeFloorBroken(context.acquisition.tape, tapeTradedLow)) {
5117
+ return { kind: 'rebuild', reason: 'tape-price' };
5118
+ }
4628
5119
  // History changed under the session (lazy-load prepend, dataset swap, a
4629
- // rolled-off head): a live session can only extend forward.
5120
+ // rolled-off head): a live session can only extend forward. A verified
5121
+ // backward extension (WRUN-PANBACK A2) is told apart on the chart's own bars,
5122
+ // the ones the history check compared: a session at another interval reads its
5123
+ // chart clock (its run bars do not move when the chart prepends a page).
4630
5124
  if (historyMoved) {
4631
- return { kind: 'rebuild', reason: 'history' };
5125
+ const backward = runClock !== undefined
5126
+ ? runClock.chartFirstTs < runClock.sessionChartFirstTs &&
5127
+ runClock.sessionChartFirstHeld === true &&
5128
+ runClock.formingTs >= context.lastRowTs
5129
+ : firstMainTs < context.firstRowTs &&
5130
+ wrunRowsHoldTs(mainRows, context.firstRowTs) &&
5131
+ lastMainTs >= context.lastRowTs;
5132
+ return { kind: 'rebuild', reason: 'history', extension: backward ? 'backward' : 'other' };
4632
5133
  }
4633
5134
  if (lastMainTs - context.lastRowTs > WRUN_LIVE_REBUILD_GAP_BARS * intervalMs) {
4634
5135
  return { kind: 'rebuild', reason: 'gap-too-wide' };
@@ -4776,6 +5277,7 @@ export function wrunLiveRunClockOf(session, context, chartRows) {
4776
5277
  return {
4777
5278
  chartFirstTs: Number(chartRows[0][0]),
4778
5279
  sessionChartFirstTs: session.chartFirstTs,
5280
+ sessionChartFirstHeld: wrunRowsHoldTs(chartRows, session.chartFirstTs),
4779
5281
  formingTs,
4780
5282
  lastMainTs,
4781
5283
  coveredThroughTs: session.coveredThroughTs,
@@ -4924,14 +5426,7 @@ function oldestOutstandingBucket(context, lanes) {
4924
5426
  * import graph. Read for the chart's own exchange (the plan's floor) and for
4925
5427
  * the governed plane a lane reads beside it (`wrunReconcileLaneWindowFrom`). */
4926
5428
  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));
5429
+ return WRUN_LIVE_RECONCILE_TAIL_BARS + wrunStreamDelayBars(exchange, intervalMs);
4935
5430
  }
4936
5431
  function minTs(...values) {
4937
5432
  let min = null;
@@ -5009,7 +5504,7 @@ function noteRevisedClosedCandles(context, rows) {
5009
5504
  for (const row of evaluated) {
5010
5505
  evaluatedTs.add(row[0]);
5011
5506
  const now = current.get(row[0]);
5012
- if (now !== undefined && !candleEqual(row, now) && (revised === null || row[0] < revised))
5507
+ if (now !== undefined && !wrunCandleEqual(row, now) && (revised === null || row[0] < revised))
5013
5508
  revised = row[0];
5014
5509
  }
5015
5510
  for (const ts of current.keys()) {
@@ -5022,13 +5517,6 @@ function noteRevisedClosedCandles(context, rows) {
5022
5517
  context.evaluatedMainTail = closedMainTail(rows, context.lastRowTs);
5023
5518
  return revised;
5024
5519
  }
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
5520
  // ---------------------------------------------------------------------------
5033
5521
  // Lane row merge (shared by the reconcile and the specs).
5034
5522
  // ---------------------------------------------------------------------------
@@ -5111,12 +5599,17 @@ export function __resetWrunLiveTickForTests() {
5111
5599
  for (const armed of graceEndWakes.values())
5112
5600
  clearTimeout(armed.timer);
5113
5601
  graceEndWakes.clear();
5602
+ for (const wake of rebuildSettleWakes.values())
5603
+ clearTimeout(wake);
5604
+ rebuildSettleWakes.clear();
5605
+ wrunRunStarts.clear();
5114
5606
  wrunLiveHeld = false;
5115
5607
  }
5116
5608
  /** Spec probe: the due time of the overlay's armed `pinned-close` timer, null when none. */
5117
5609
  export function wrunPinnedCloseTimerDueAt(indicatorId) {
5118
5610
  return pinnedCloseTimers.get(indicatorId)?.dueAt ?? null;
5119
5611
  }
5612
+ const wrunRunStarts = new Map();
5120
5613
  /** The chart's main-rows identity the executor's pan-wave coverage skip
5121
5614
  * compares runs by: the market, the first row, the newest closed row and the
5122
5615
  * row count. A forming-bar tick changes none of them; a prepended page, a
@@ -5128,7 +5621,10 @@ export function wrunPinnedCloseTimerDueAt(indicatorId) {
5128
5621
  * prefix has not landed reads no identity, so no earlier run's coverage
5129
5622
  * skips the wave that owes the page's rows; a run's own start (in flight)
5130
5623
  * reads the chart's identity, so a prefix that lands covers the waves over
5131
- * the same rows after it. Exported for the specs. */
5624
+ * the same rows after it, and is noted (`wrunRunStarts`). A coverage check
5625
+ * for an overlay whose live session carries the chart's tail reads the key
5626
+ * its latest run started on while the history it computed stands
5627
+ * (`wrunLiveCarriedCoverage`). Exported for the specs. */
5132
5628
  export function wrunChartRowsIdentity(chartIndex, indicatorId) {
5133
5629
  const rows = wrunChartCandleRows(wrunChartHostEnv().chart.instance(chartIndex));
5134
5630
  if (rows.length === 0)
@@ -5136,8 +5632,57 @@ export function wrunChartRowsIdentity(chartIndex, indicatorId) {
5136
5632
  if (indicatorId !== undefined && wrunPrefixUnlanded(chartIndex, indicatorId, rows[0][0]))
5137
5633
  return undefined;
5138
5634
  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}`;
5635
+ const newestClosedTs = rows.length > 1 ? rows[rows.length - 2][0] : undefined;
5636
+ const identity = `${market}|${rows[0][0]}|${newestClosedTs ?? 'none'}|${rows.length}`;
5637
+ if (indicatorId === undefined)
5638
+ return identity;
5639
+ if (isWrunOverlayRerunInFlight(indicatorId)) {
5640
+ wrunRunStarts.set(indicatorId, {
5641
+ chartIndex,
5642
+ market,
5643
+ firstTs: rows[0][0],
5644
+ newestClosedTs,
5645
+ closedRows: rows.length - 1,
5646
+ identity,
5647
+ });
5648
+ return identity;
5649
+ }
5650
+ return wrunLiveCarriedCoverage(chartIndex, indicatorId, rows, market) ?? identity;
5651
+ }
5652
+ /** The coverage key of an overlay whose live session carries the chart's tail (WRUN-PANBACK A2): the key its latest run
5653
+ * started on, while the chart still holds the history that run computed (the same market and first row, the same
5654
+ * rows through the newest bar it saw closed) and has only grown past it. The bars a roll appended are the live tick's
5655
+ * to compute, so a page's own wave that the chart held for its wire data past the run that computed the page reads
5656
+ * covered, instead of computing the same history again (field 2026-11-02: a second full run per script in one still,
5657
+ * `pages 0, reused true`, 4.1 s after the release and one bar roll later). Undefined, the chart's own key then, with no
5658
+ * live session the tick advances (none, a replay, a suspended one), no run start noted, or a history that moved (a
5659
+ * page, a filled gap, a switch, a rolled-off head). */
5660
+ function wrunLiveCarriedCoverage(chartIndex, indicatorId, rows, market) {
5661
+ const start = wrunRunStarts.get(indicatorId);
5662
+ if (start === undefined || start.newestClosedTs === undefined)
5663
+ return undefined;
5664
+ if (start.chartIndex !== chartIndex || start.market !== market || start.firstTs !== Number(rows[0][0])) {
5665
+ return undefined;
5666
+ }
5667
+ const context = getWrunOverlayLiveContext(indicatorId);
5668
+ if (context === undefined || context.chartIndex !== chartIndex || context.replay === true || context.liveSuspended) {
5669
+ return undefined;
5670
+ }
5671
+ const historyStands = rows.length > start.closedRows && wrunRowsThroughTs(rows, start.newestClosedTs) === start.closedRows;
5672
+ return historyStands ? start.identity : undefined;
5673
+ }
5674
+ /** How many rows ascending by stamp are stamped at or before `ts` (binary search). */
5675
+ function wrunRowsThroughTs(rows, ts) {
5676
+ let low = 0;
5677
+ let high = rows.length;
5678
+ while (low < high) {
5679
+ const mid = (low + high) >>> 1;
5680
+ if (Number(rows[mid][0]) <= ts)
5681
+ low = mid + 1;
5682
+ else
5683
+ high = mid;
5684
+ }
5685
+ return low;
5141
5686
  }
5142
5687
  // The cross-module seams (the intake never imports this module): a gap mark
5143
5688
  // wakes the drain through the requester, a teardown drops this lane's state
@@ -5153,6 +5698,7 @@ let drainRequesterRegistered = false;
5153
5698
  let liveChannelRequesterRegistered = false;
5154
5699
  let teardownHookRegistered = false;
5155
5700
  let rowsIdentityReaderRegistered = false;
5701
+ let lazyWaveAbsorberRegistered = false;
5156
5702
  let sheetReaderRegistered = false;
5157
5703
  let pageVisibleListenerRegistered = false;
5158
5704
  let hiddenPaceListenerRegistered = false;
@@ -5210,6 +5756,18 @@ function registerWrunLiveTickSeams() {
5210
5756
  // A partial mock of the drivers util: retried at the first schedule.
5211
5757
  }
5212
5758
  }
5759
+ if (!lazyWaveAbsorberRegistered) {
5760
+ try {
5761
+ // The executor offers each pan wave to the open rebuild episode (WRUN-PANBACK A2).
5762
+ if (typeof setWrunLazyWaveAbsorber === 'function') {
5763
+ setWrunLazyWaveAbsorber(absorbWrunLazyWave);
5764
+ lazyWaveAbsorberRegistered = true;
5765
+ }
5766
+ }
5767
+ catch {
5768
+ // A partial mock of the drivers util: retried at the first schedule.
5769
+ }
5770
+ }
5213
5771
  if (!sheetReaderRegistered) {
5214
5772
  try {
5215
5773
  if (typeof setWrunLiveSheetReader === 'function') {