@orangecharts/wrun-chart-host 0.11.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +3 -4
  3. package/dist/constants/feature-flags.constants.js +34 -52
  4. package/dist/constants/feature-limits.constants.d.ts +1 -1
  5. package/dist/constants/feature-limits.constants.js +5 -4
  6. package/dist/constants/interval.constants.d.ts +7 -0
  7. package/dist/constants/interval.constants.js +7 -0
  8. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +20 -149
  9. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +20 -309
  10. package/dist/constants/stocks-compliance.constants.d.ts +15 -0
  11. package/dist/constants/stocks-compliance.constants.js +15 -0
  12. package/dist/host-env.d.ts +55 -3
  13. package/dist/host-env.js +6 -0
  14. package/dist/host-ports.types.d.ts +36 -3
  15. package/dist/index.d.ts +18 -0
  16. package/dist/index.js +19 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +78 -15
  18. package/dist/indicators/controls/tpo-session.util.js +320 -242
  19. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +6 -0
  20. package/dist/instances/script-engine-worker-ohlcv-transfer.js +16 -0
  21. package/dist/interfaces/cme-realtime.interface.d.ts +8 -0
  22. package/dist/interfaces/cme-realtime.interface.js +2 -1
  23. package/dist/interfaces/feed.interface.d.ts +15 -1
  24. package/dist/interfaces/replay.interface.d.ts +5 -0
  25. package/dist/interfaces/stocks-realtime.interface.d.ts +4 -3
  26. package/dist/interfaces/stocks-realtime.interface.js +5 -4
  27. package/dist/interfaces/wrun-runtime.interface.d.ts +97 -19
  28. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +17 -0
  29. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +22 -0
  30. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +46 -40
  31. package/dist/kscript-data/controls/live-trades-merge.util.js +80 -107
  32. package/dist/market-data/billing.interface.d.ts +9 -1
  33. package/dist/market-data/venue.d.ts +1 -1
  34. package/dist/market-data/venues/index.d.ts +4 -4
  35. package/dist/market-data/venues/stocks.contract.copy.json +4 -4
  36. package/dist/market-data/venues/stocks.d.ts +4 -4
  37. package/dist/market-data/venues/stocks.js +15 -13
  38. package/dist/settings-templates/frvp-fields.d.ts +12 -1
  39. package/dist/settings-templates/frvp-fields.js +15 -4
  40. package/dist/settings-templates/index.js +12 -5
  41. package/dist/settings-templates/indicator-fields.js +28 -2
  42. package/dist/settings-templates/tool-rules.d.ts +17 -8
  43. package/dist/settings-templates/tool-rules.js +15 -8
  44. package/dist/settings-templates/tool-tables.generated.js +4 -2
  45. package/dist/utility/auth/server-clock.util.d.ts +3 -1
  46. package/dist/utility/auth/server-clock.util.js +3 -1
  47. package/dist/utility/chart/book-live-bucket.util.js +2 -2
  48. package/dist/utility/chart/cache-alignment.util.d.ts +15 -7
  49. package/dist/utility/chart/cache-alignment.util.js +14 -7
  50. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +2 -0
  51. package/dist/utility/chart/chart-data-fetch-generation.util.js +16 -0
  52. package/dist/utility/chart/cme-session-bucket.util.d.ts +18 -75
  53. package/dist/utility/chart/cme-session-bucket.util.js +25 -332
  54. package/dist/utility/chart/continuous-contracts.util.js +6 -5
  55. package/dist/utility/chart/display-offset.leaf.d.ts +24 -0
  56. package/dist/utility/chart/display-offset.leaf.js +41 -0
  57. package/dist/utility/chart/effective-chart-session.util.d.ts +2 -1
  58. package/dist/utility/chart/effective-chart-session.util.js +13 -5
  59. package/dist/utility/chart/feed-interval.util.d.ts +6 -20
  60. package/dist/utility/chart/feed-interval.util.js +13 -22
  61. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +27 -7
  62. package/dist/utility/chart/fetch-dedupe-policy.util.js +86 -11
  63. package/dist/utility/chart/host-bar-placement.util.d.ts +7 -4
  64. package/dist/utility/chart/host-bar-placement.util.js +8 -2
  65. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +32 -0
  66. package/dist/utility/chart/indicator-inflight-registry.util.js +52 -0
  67. package/dist/utility/chart/indicator-run-interval.util.d.ts +10 -4
  68. package/dist/utility/chart/indicator-run-interval.util.js +21 -12
  69. package/dist/utility/chart/interval-registry.util.d.ts +1 -1
  70. package/dist/utility/chart/interval-registry.util.js +1 -1
  71. package/dist/utility/chart/kscript-legend-entries.util.d.ts +12 -0
  72. package/dist/utility/chart/kscript-legend-entries.util.js +16 -0
  73. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +1 -1
  74. package/dist/utility/chart/kscript-run-interval-projection.util.js +4 -2
  75. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -62
  76. package/dist/utility/chart/kscript-venue-policy.util.js +85 -94
  77. package/dist/utility/chart/live-bucket.util.d.ts +39 -17
  78. package/dist/utility/chart/live-bucket.util.js +103 -57
  79. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +58 -20
  80. package/dist/utility/chart/local-kscript-source-revalidation.util.js +98 -23
  81. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +35 -11
  82. package/dist/utility/chart/local-kscript-warmup-depth.util.js +24 -3
  83. package/dist/utility/chart/market-session-schedule.util.d.ts +8 -0
  84. package/dist/utility/chart/market-session-schedule.util.js +39 -1
  85. package/dist/utility/chart/market-session.util.d.ts +136 -0
  86. package/dist/utility/chart/market-session.util.js +341 -0
  87. package/dist/utility/chart/market-sessions.util.d.ts +83 -0
  88. package/dist/utility/chart/market-sessions.util.js +220 -0
  89. package/dist/utility/chart/om-panel.util.d.ts +5 -3
  90. package/dist/utility/chart/om-panel.util.js +42 -7
  91. package/dist/utility/chart/om-target.util.d.ts +14 -1
  92. package/dist/utility/chart/om-target.util.js +22 -5
  93. package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
  94. package/dist/utility/chart/opra-read-access.leaf.js +22 -0
  95. package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
  96. package/dist/utility/chart/profile-row-height.util.js +74 -37
  97. package/dist/utility/chart/rth-session.util.d.ts +55 -20
  98. package/dist/utility/chart/rth-session.util.js +94 -46
  99. package/dist/utility/chart/session-interval.util.d.ts +2 -1
  100. package/dist/utility/chart/session-interval.util.js +1 -3
  101. package/dist/utility/chart/session-lattice.util.d.ts +150 -0
  102. package/dist/utility/chart/session-lattice.util.js +488 -0
  103. package/dist/utility/chart/trading-day.util.d.ts +40 -2
  104. package/dist/utility/chart/trading-day.util.js +84 -7
  105. package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
  106. package/dist/utility/chart/us-equities-session.util.js +44 -15
  107. package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
  108. package/dist/utility/chart/window-geometry.leaf.js +57 -8
  109. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
  110. package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
  111. package/dist/utility/chart/wrun-run-result.util.d.ts +29 -12
  112. package/dist/utility/chart/wrun-run-result.util.js +89 -25
  113. package/dist/utility/common/time.util.js +5 -4
  114. package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
  115. package/dist/utility/market-events/earnings-scope.util.js +17 -9
  116. package/dist/utility/market-events/market-events.util.d.ts +14 -7
  117. package/dist/utility/market-events/market-events.util.js +30 -17
  118. package/dist/utility/number-format.util.d.ts +14 -21
  119. package/dist/utility/number-format.util.js +38 -24
  120. package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
  121. package/dist/utility/options/option-venue-disclosure.util.js +71 -11
  122. package/dist/utility/options/option-venue.util.d.ts +1 -1
  123. package/dist/utility/options/option-venue.util.js +1 -1
  124. package/dist/utility/pool-symbol.leaf.d.ts +7 -0
  125. package/dist/utility/pool-symbol.leaf.js +50 -5
  126. package/dist/utility/stocks/stock-display.util.d.ts +15 -0
  127. package/dist/utility/stocks/stock-display.util.js +37 -0
  128. package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
  129. package/dist/utility/v2/gate-plane.util.d.ts +6 -0
  130. package/dist/utility/v2/gate-plane.util.js +11 -1
  131. package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
  132. package/dist/utility/v2/gate-session-latch.util.js +3 -3
  133. package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
  134. package/dist/utility/v2/governed-tier.leaf.js +17 -16
  135. package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
  136. package/dist/utility/v2/stocks-governed.util.js +14 -0
  137. package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
  138. package/dist/utility/v2/v2-enums.leaf.js +458 -0
  139. package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
  140. package/dist/utility/wrun/derived-roots.leaf.js +27 -1
  141. package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
  142. package/dist/utility/wrun/derived-roots.util.js +97 -56
  143. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
  144. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
  145. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
  146. package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
  147. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
  148. package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
  149. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
  150. package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
  151. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
  152. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
  153. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  154. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
  155. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
  156. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
  157. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
  158. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
  159. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
  160. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
  161. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
  162. package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
  163. package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
  164. package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
  165. package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
  166. package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
  167. package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
  168. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +41 -22
  169. package/dist/utility/wrun/wrun-batched-marks.util.js +255 -59
  170. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
  171. package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
  172. package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
  173. package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
  174. package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
  175. package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
  176. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
  177. package/dist/utility/wrun/wrun-canvases.util.js +7 -3
  178. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
  179. package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
  180. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
  181. package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
  182. package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
  183. package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
  184. package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
  185. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
  186. package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
  187. package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
  188. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
  189. package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
  190. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
  191. package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
  192. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
  193. package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
  194. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
  195. package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
  196. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
  197. package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
  198. package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
  199. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
  200. package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
  201. package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
  202. package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
  203. package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
  204. package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
  205. package/dist/utility/wrun/wrun-host.service.js +137 -27
  206. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
  207. package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
  208. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
  209. package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
  210. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
  211. package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
  212. package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
  213. package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
  214. package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
  215. package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
  216. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
  217. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
  218. package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
  219. package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
  220. package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
  221. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
  222. package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
  223. package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
  224. package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
  225. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
  226. package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
  227. package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
  228. package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
  229. package/dist/utility/wrun/wrun-live-tick.util.js +648 -97
  230. package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
  231. package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
  232. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
  233. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
  234. package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
  235. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
  236. package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
  237. package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
  238. package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
  239. package/dist/utility/wrun/wrun-option-views.util.js +5 -2
  240. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
  241. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
  242. package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
  243. package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
  244. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +75 -11
  245. package/dist/utility/wrun/wrun-overlay-drivers.util.js +176 -43
  246. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
  247. package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
  248. package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
  249. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
  250. package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
  251. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +239 -24
  252. package/dist/utility/wrun/wrun-overlay-run.util.js +2204 -405
  253. package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
  254. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +2 -1
  255. package/dist/utility/wrun/wrun-panel-mount.util.js +20 -14
  256. package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
  257. package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
  258. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
  259. package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
  260. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
  261. package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
  262. package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
  263. package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
  264. package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
  265. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
  266. package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
  267. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
  268. package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
  269. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
  270. package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
  271. package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
  272. package/dist/utility/wrun/wrun-refusal.util.js +103 -16
  273. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
  274. package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
  275. package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
  276. package/dist/utility/wrun/wrun-run-health.util.d.ts +89 -2
  277. package/dist/utility/wrun/wrun-run-health.util.js +204 -1
  278. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
  279. package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
  280. package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
  281. package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
  282. package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
  283. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -3
  284. package/dist/utility/wrun/wrun-script-inputs.util.js +51 -13
  285. package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
  286. package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
  287. package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
  288. package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
  289. package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
  290. package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
  291. package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
  292. package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
  293. package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
  294. package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
  295. package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
  296. package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
  297. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
  298. package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
  299. package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
  300. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
  301. package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
  302. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
  303. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
  304. package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
  305. package/dist/utility/wrun/wrun-visibility-table.js +9 -0
  306. package/dist/utility/wrun/wrun-volume-profile.util.js +44 -32
  307. package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
  308. package/dist/utils/replay/replay-buffer-math.js +60 -30
  309. package/dist/workers/constants/socket-slots.d.ts +11 -7
  310. package/dist/workers/constants/socket-slots.js +6 -5
  311. package/package.json +11 -11
@@ -63,9 +63,10 @@
63
63
  */
64
64
  import cloneDeep from 'lodash-es/cloneDeep.js';
65
65
  import isEqual from 'lodash-es/isEqual.js';
66
- import { ensureWrunChartHostSharedHost, wrunChartHostEnv } from '../../host-env.js';
66
+ import { ensureWrunChartHostSharedHost, wrunChartHostEnv, wrunHostCarryWithBuild } from '../../host-env.js';
67
+ import { wrunCandleEqual } from './wrun-candle-equal.leaf.js';
67
68
  import { WRUN_CANVAS_NOTICE_ROW_CODES, wrunCanvasChildId, wrunCanvasNoticeDiagnostics, wrunCellRowsOf, wrunHeatmapChildren, } from './wrun-canvases.util.js';
68
- import { isWrunBatchedMarksKind, readWrunBatchedSections, wrunBatchedChildId, wrunBatchedMarksChildren, wrunBatchedRowsOf, } from './wrun-batched-marks.util.js';
69
+ import { isWrunBatchedMarksKind, readWrunBatchedSections, WRUN_BATCHED_MARKS_KINDS, wrunBatchedChildId, wrunBatchedMarksChildren, wrunBatchedRowsOf, } from './wrun-batched-marks.util.js';
69
70
  import { isPackedOhlcvRows, unpackOhlcvRows } from '../../instances/script-engine-worker-ohlcv-transfer.js';
70
71
  import { Intervals } from '../../constants/interval.constants.js';
71
72
  import { mountedPlotSetMatchesRunResult } from '../chart/kscript-mounted-plot-set.leaf.js';
@@ -90,6 +91,7 @@ import { placeWrunTablesOnChart } from './wrun-table-chrome.util.js';
90
91
  import { projectKScriptRunResultOntoChartBars } from '../chart/kscript-run-interval-projection.util.js';
91
92
  import { runBarSpan } from '../chart/indicator-run-interval.util.js';
92
93
  import { GESTURE_LINGER_MS, HEAVY_APPLY_GESTURE_CEILING_MS } from '../chart/gesture-timing.leaf.js';
94
+ import { LOCAL_KSCRIPT_WARMUP_DECLARED_SLACK_BARS, warmupSourceEntryLanding, } from '../chart/local-kscript-warmup-depth.util.js';
93
95
  import { getChartDataFetchGeneration } from '../chart/chart-data-fetch-generation.util.js';
94
96
  import { isWrunWindowOwner } from '../chart/window-owner.leaf.js';
95
97
  import { countOverlayOutputRows, OVERLAY_HISTORICAL_ROW_BUDGET } from '../chart/overlay-output-budget.util.js';
@@ -111,15 +113,17 @@ import { serveWrunOwnCandles, wrunChartCandleVenue, wrunMainCandleSourceOf, } fr
111
113
  import { wrunPollClassReadsChain, wrunRowClassReadsChain } from './run-schedule/wrun-gate-reader-warm.util.js';
112
114
  import { wrunPollLaneByKey, wrunPollLanesOfClass } from './sources/registry.js';
113
115
  import { wrunRowLaneByKey, wrunRowLaneOfClass, wrunRowLanes } from './sources/row-lane-registry.js';
114
- import { isWrunRowLaneId } from './sources/wrun-row-lane.types.js';
115
- import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneAddKey, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, wrunRowLanesReplayBounded, wrunRunSourceReachFromMs, } from './sources/wrun-row-lanes.util.js';
116
+ import { isWrunRowLaneId, } from './sources/wrun-row-lane.types.js';
117
+ import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneAddKey, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, wrunRowLanesReplayBounded, wrunRowLaneStocksTapeOf, wrunRunHistoryLanesOf, wrunRunSourceReachFromMs, } from './sources/wrun-row-lanes.util.js';
118
+ import { wrunLaneFetchSignal } from './sources/wrun-lane-fetch-abort.util.js';
119
+ import { wrunHostBarSpansWithin } from './wrun-tier-grid.util.js';
116
120
  import { wrunOpraLanePayloadFields } from './wrun-opra-lane.util.js';
117
- import { WRUN_LANE_REFUSED_SETTLE_REASON, wrunLaneRefusedCodeOf } from './wrun-lane-refusal.leaf.js';
118
- import { TRADES_HISTORY_MAX_CELLS } from '../../kscript-data/controls/live-trades-merge.util.js';
121
+ import { markWrunLaneRefusedHold, WRUN_LANE_REFUSALS, WRUN_LANE_REFUSED_SETTLE_REASON, WRUN_NO_ORDER_BOOK_CODE, wrunLaneRefusedCodeOf, wrunLaneRefusedHoldCodeOf, } from './wrun-lane-refusal.leaf.js';
122
+ import { SOURCE_HISTORY_AS_OF_FIELD, TRADES_HISTORY_MAX_CELLS, } from '../../kscript-data/controls/live-trades-merge.util.js';
119
123
  import { warmWrunEarningsFacts, wrunEarningsFactsFor, wrunReadsEarningsFacts, } from './wrun-earnings-facts.util.js';
120
124
  import { liveBucketStartsInRange, liveBucketVenueOf } from '../chart/live-bucket.util.js';
121
- import { hostBucketResolverFor } from '../chart/host-bar-placement.util.js';
122
- import { indexHostFetchTierMs, sourceRowsStraddleHostBars } from '../chart/index-host-tier.util.js';
125
+ import { indexHostFetchTierMs } from '../chart/index-host-tier.util.js';
126
+ import { wrunChartFormingBarTs, wrunChartStreamRefOf } from './wrun-stream-clock.util.js';
123
127
  import { isWrunPollLaneId, wrunPollCoinGateSeed, } from './sources/wrun-poll-lane.types.js';
124
128
  import { assertWrunLaneChainPlaneReadable, fetchWrunPollLaneHostGridRows, planWrunPollLanes, resolveWrunOptionSettingKnobs, wrunChainLaneContext, wrunLaneRowsRequired, wrunPollLaneChainAsk, wrunPollLaneFetchFrom, wrunPollLaneFetchOptions, wrunPollLaneFetchTo, wrunPollLaneInstanceReadsOpra, wrunPollLaneRequired, wrunPollLaneValuelessInput, } from './sources/wrun-poll-lanes.util.js';
125
129
  import { wrunDailyLaneFetchFrom, wrunDailyLaneFetchTo } from './wrun-daily-lane.util.js';
@@ -127,21 +131,24 @@ import { assertWrunEtfFlowCoin, planWrunEtfFlowColumns, planWrunEtfFlowLane, res
127
131
  import { planWrunOptionSummaryLane, WRUN_OPTION_SUMMARY_LANES, wrunOptionSummaryAskExtras, wrunOptionSummaryAskKey, zipWrunOptionSummaryRows, } from './wrun-option-summary-lane.util.js';
128
132
  import { selectWrunDebugLines, wrunDebugSlotIndex } from './wrun-debug-output.util.js';
129
133
  import { isWrunDraftOverlaySettings, wrunRegistryRefOf } from './wrun-overlay-identity.util.js';
134
+ import { isWrunAppLayerOverlaySettings } from './wrun-app-layer.leaf.js';
130
135
  import { wrunHostedParamsOf, wrunSheetParamsFromDeclarations } from './wrun-param-map.util.js';
131
136
  import { WRUN_SYMBOL_TEXT_SERVER_CAP } from './wrun-hosted-wire-caps.js';
132
137
  import { wrunSheetPositionOf } from './wrun-cloud-record.util.js';
133
138
  import { wrunRunComputeIdentity } from '../wrun-alert-params.leaf.js';
134
- import { sameWrunRunHealthVerdict, WRUN_LEG_ROW_CODES, WRUN_NO_READY_ROWS_CODE, WRUN_RUN_HEALTH_ROW_CODES, wrunEmptyLegDiagnostics, wrunFeedMissingDiagnostics, wrunNothingReadyRefusal, wrunRunHealth, wrunRunHealthDiagnostics, wrunUnservedLegDiagnostics, } from './wrun-run-health.util.js';
139
+ import { sameWrunRunHealthVerdict, WRUN_LEG_ROW_CODES, WRUN_NO_READY_ROWS_CODE, WRUN_NOTHING_DRAWN_ROW_CODES, WRUN_RUN_HEALTH_ROW_CODES, wrunEmptyLegDiagnostics, wrunFeedMissingDiagnostics, wrunNothingDrawnDiagnostics, wrunNothingReadyRefusal, wrunRunDrewSomething, wrunRunHealth, wrunRunHealthDiagnostics, wrunUnservedLegDiagnostics, wrunViewerNothingDrawn, } from './wrun-run-health.util.js';
140
+ import { wrunPinnedIntervalOf } from './wrun-pinned-interval.util.js';
135
141
  import { attachWrunDrawSkips, attachWrunHandles, WRUN3_HANDLE_ID_PREFIX, WRUN3_HANDLE_KINDS, wrunDrawSkipsFromWire, wrunDrawSkipsOf, wrunHandlesOf, } from './wrun-handles.util.js';
136
142
  import { WRUN_DRAW_SKIPPED_ROW_CODES } from './wrun-draw-skipped.leaf.js';
137
- import { resolveWrunPinnedSheetWithCatalog, WRUN_PIN_ROW_CODES, wrunPinRespelledDiagnostics, } from './wrun-pin-spelling.util.js';
143
+ import { resolveWrunPinnedSheetWithCatalog, WRUN_PIN_ROW_CODES, wrunPinRespelledDiagnostics, wrunPinSpellingReadsCme, } from './wrun-pin-spelling.util.js';
138
144
  import { attachWrunFrames, wrunAbiVersion, wrunFramesOf } from './wrun-pack.util.js';
139
145
  import { wrunVolumeProfileLaneExtras } from './wrun-volume-profile-lane.util.js';
140
146
  import { wrunOiLaneExtras } from './wrun-oi-lane.util.js';
147
+ import { WRUN_PINNED_LANE_SPECS, isWrunPinnedLaneId, wrunPinnedLaneExtras, wrunPinnedLaneOf, wrunPinnedLaneOfSource, } from './wrun-pinned-lanes.util.js';
141
148
  import { WRUN_LEG_STREAM_CLASSES, isWrunLegStreamClass, wrunLegStreamPayloadWords } from './wrun-leg-stream-classes.js';
142
- import { isWrunTradesLegLane, WRUN_TRADES_LANES, wrunTradesLegExtras, wrunTradesLegOf, } from './wrun-trades-lane.util.js';
149
+ import { isWrunTradesLegLane, planWrunTradeLegAsk, WRUN_TRADES_LANES, wrunLegPlacementLeadMs, wrunLegStraddlesChartBars, wrunLegVenueOf, wrunTradesLegOf, } from './wrun-trades-lane.util.js';
143
150
  import { substituteWrunChartNames, wrunChartContextHostFill, wrunChartIntervalMsOf, } from './wrun-chart-context.util.js';
144
- import { warmWrunMarketDollarFacts, warmWrunMarketFacts, wrunChartSizeUnit, wrunLaneDemandNeedsDirectory, wrunMarketDollarUnit, wrunMarketFactsFor, wrunMarketFactsNeedDirectory, wrunReadsDollarMultiplier, wrunReadsMarketFacts, wrunCoinLegsOf, wrunCoinLegVenues, wrunSheetWithCoinLegs, wrunSheetWithLaneCurrencies, wrunSheetWithLaneDemand, wrunSheetWithLaneGate, WRUN_DOLLAR_MULTIPLIER_FILL, WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE, } from './wrun-chart-market-facts.util.js';
151
+ import { forgetWrunMarketReadFailures, warmWrunMarketDollarFacts, warmWrunMarketFacts, wrunChartSizeUnit, wrunLaneDemandNeedsDirectory, wrunMarketDollarReadFailure, wrunMarketDollarUnit, wrunMarketReadMark, wrunMarketFactsFor, wrunMarketFactsNeedDirectory, wrunReadsDollarMultiplier, wrunReadsMarketFacts, wrunCoinLegsOf, wrunCoinLegVenues, wrunSheetWithCoinLegs, wrunSheetWithLaneCurrencies, wrunSheetWithLaneDemand, wrunSheetWithLaneGate, WRUN_DOLLAR_MULTIPLIER_FILL, WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE, } from './wrun-chart-market-facts.util.js';
145
152
  import { wrunFollowsCoin, wrunInputGateOn, wrunRowVisibleHere } from './wrun-market-facts.util.js';
146
153
  import { wrunRowsKeepingMarketDefaults } from './wrun-market-size-defaults.leaf.js';
147
154
  import { reconcileWrunMarketSizeDefaults } from './wrun-market-size-defaults.util.js';
@@ -150,22 +157,25 @@ import { assertWrunBrowserSources, getWrunBrowserHost, } from './wrun-host.servi
150
157
  import { applyWrunInertLegendState } from './wrun-inert-legend.util.js';
151
158
  import { annotateWrunErrorRefusal, attachWrunRefusal, serializeWrunRefusal, stampWrunRefusalTelemetry, wrunAuthorRuleSeed, wrunLeftOutRefusalSeed, wrunOptionsStopSeed, wrunOverlayEditable, wrunRefusalFor, wrunRefusalOf, wrunRefusalSeedFor, wrunRefusalSeedOf, WRUN_REFUSAL_EVENT_MARKET_KEY, } from './wrun-refusal.util.js';
152
159
  import { claimWrunRefusalNotice, emitWrunRefusalChange, liveWrunRefusalAttempt, projectWrunRefusal, retractWrunRefusal, } from './wrun-refusal-surface.util.js';
153
- import { WRUN_ETF_COVERED_COINS, wrunInputReadsFillOverEmptyLane, wrunInputRequirements, wrunPredictionMarketWalledInput, wrunRunMarketReadOfFetchType, wrunSheetReadsRunMarket, wrunUnservedLanes, } from './wrun-input-requirements.leaf.js';
160
+ import { WRUN_ETF_COVERED_COINS, wrunInputDrawsWithoutLane, wrunInputReadsFillOverEmptyLane, wrunInputRequirements, wrunPredictionMarketWalledInput, wrunRunMarketReadOfFetchType, wrunSheetReadsRunMarket, wrunUnservedLanes, } from './wrun-input-requirements.leaf.js';
154
161
  import { getWrunOverlayMetadata, rememberWrunOverlayMetadata } from './wrun-overlay-metadata.util.js';
155
162
  import { setWrunOverlayAlertOutputs } from './wrun-alert-outputs.registry.js';
156
163
  import { buildWrunScriptInputs, wrunParamValuesFromSettings, wrunRunOverlayPalette, } from './wrun-script-inputs.util.js';
157
164
  import { wrunDraftLegendNote, wrunOverlayLegendNote } from './wrun-draft-legend-note.util.js';
165
+ import { wrunCmeDelayedMarkets } from './wrun-cme-legs-note.util.js';
158
166
  import { wrunTextParamsForRun, wrunTextParamValuesFromSettings } from './wrun-text-params.util.js';
159
167
  import { wrunSheetWithSettings, wrunVisibilityOwnedOutputs } from './wrun-color-settings.util.js';
160
168
  import { wrunSheetDrawsOnlyStatsStrip, wrunStatsStripSettings } from './wrun-stats-strip.util.js';
161
169
  import { planWrunHeldLanes } from './wrun-held-lanes.util.js';
170
+ import { pinWrunLaneHistoryAsOf, restoreWrunHistoryAsOf, wrunClockHistoryAsOfMs, wrunEarliestHistoryAsOf, wrunHistoryAsOfIdentity, wrunTapeHistoryAsOfLaneKey, } from './wrun-history-as-of.util.js';
162
171
  import { createWrunDownloadMeter, wrunDownloadAnswerSize, } from './wrun-download-meter.util.js';
163
172
  import { createWrunLaneDownloadMeter, wrunDownloadKitInterval, wrunDownloadMarketOf, wrunDownloadPlanKeyOf, wrunDownloadPlanReadBytes, wrunRunDownloadMode, wrunRunDownloadReads, } from './wrun-download-plan.util.js';
164
173
  import { FeatureFlag } from '../../constants/feature-flags.constants.js';
165
174
  import { clearedColorCustomizationFlags } from '../chart/color-customization.leaf.js';
166
175
  import { WRUN_LATEST_HISTORY_LENGTH } from './wrun-latest-history.leaf.js';
167
176
  import { resolveChartPricePrecision } from '../chart/price-precision.util.js';
168
- import { currentWrunOverlayLiveGeneration, getWrunOverlayLiveContext, isWrunOverlayFullRerunInFlight, isWrunOverlayReplacementPending, markWrunOverlayComputeSucceeded, nextWrunOverlayLiveGeneration, noteWrunOverlayRunSettle, noteWrunOverlayWholeWindowDrawn, onWrunOverlayLiveTeardown, rerunWrunOverlayForChartWave, setWrunOverlayLiveContext, setWrunPrefixRuntime, setWrunUnansweredDropSurface, suspendWrunOverlayLiveSession, withWrunOverlaySessionLock, wrunChartMarketIdentity, } from './wrun-overlay-drivers.util.js';
177
+ import { currentWrunOverlayLiveGeneration, getWrunOverlayLiveContext, hasQueuedWrunUserRun, isWrunOverlayFullRerunInFlight, isWrunOverlayReplacementPending, markWrunOverlayComputeSucceeded, nextWrunOverlayLiveGeneration, noteWrunOverlayRunSettle, noteWrunOverlayWholeWindowDrawn, onWrunChartTeardown, onWrunOverlayLiveTeardown, rerunWrunOverlayForChartWave, setWrunOverlayLiveContext, setWrunPrefixRuntime, setWrunUnansweredDropSurface, suspendWrunOverlayLiveSession, withWrunOverlaySessionLock, wrunChartMarketIdentity, } from './wrun-overlay-drivers.util.js';
178
+ import { __resetWrunInstallPacerForTests, admitWrunInstall, dropWrunInstallPacer, noteWrunInstallWrite, wrunInstallLastAdmission, } from './wrun-install-pacer.util.js';
169
179
  import { claimWrunWarmupHead, readWrunWarmupHeadBars, readWrunWarmupHeadSpan, storeWrunWarmupHeadSpan, wrunWarmupHeadStored, } from './wrun-warmup-head-store.util.js';
170
180
  import { protectedKScriptMountedRowCount } from '../chart/protected-kscript-empty-output.util.js';
171
181
  import { kScriptSettingsRevision } from '../chart/kscript-settings-revision.leaf.js';
@@ -180,15 +190,18 @@ import { isCmeGoverned } from '../chart/cme-realtime.util.js';
180
190
  import { wrunBarSessionFactsResolver, wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
181
191
  import { wrunPresentIsPartial } from './wrun-present-bits.util.js';
182
192
  import { assertWrunPinnedLegVenues, partitionWrunLegsByVenue, wrunLegFetchedRowReaders, wrunLegRidesNativeRows, wrunPinMarketsOf, wrunPinnedLegRefusalOf, wrunPinVenueVerdict, } from './wrun-pin-venues.util.js';
183
- import { annotateWrunErrorFailureRow, annotateWrunErrorIndicatorId, isWrunOverlayPausedError, isWrunQuarantinedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunDeadlineError, WrunIntegrationError, WrunNoBarsError, WrunOverlayPausedError, WrunPredictionMarketBlockedError, WrunSourceDataUnavailableError, WrunStrategyVenueBlockedError, WrunVenueBlockedError, } from './wrun-registry-errors.util.js';
184
- import { createKScriptVenueBlockedError, isCmeUserScriptCandidate, isCmeUserScriptRun, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptCandidate, isOpraUserScriptRun, payloadTouchesCmeVenue, payloadTouchesOpraVenue, } from '../chart/kscript-venue-policy.util.js';
193
+ import { annotateWrunErrorFailureRow, annotateWrunErrorIndicatorId, isWrunOverlayPausedError, isWrunQuarantinedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunDeadlineError, WrunIntegrationError, WrunLaneVenueBlockedError, WrunNoBarsError, WrunOverlayPausedError, WrunPredictionMarketBlockedError, WrunSourceDataUnavailableError, WrunStrategyVenueBlockedError, WrunVenueBlockedError, } from './wrun-registry-errors.util.js';
194
+ import { cmePinRefusalVariant, createKScriptVenueBlockedError, isCmeChartStudyRun, isCmeReadableKScriptRun, isCmeUserScriptCandidate, isCmeUserScriptRun, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptCandidate, isOpraUserScriptRun, payloadTouchesCmeVenue, payloadTouchesOpraVenue, } from '../chart/kscript-venue-policy.util.js';
195
+ import { planeReadFactsOf } from '../chart/opra-read-access.leaf.js';
185
196
  import { isOpraUserScriptsFlagOn } from '../chart/opra-user-scripts-gate.util.js';
186
197
  import { captureCmeStudyAuth, cmeStudyStopReason, isCmeStudyAuthCurrent, isCmeUserScriptsFlagOn, } from '../chart/cme-user-scripts-gate.util.js';
187
198
  import { governedMarketDataTier, governedOptionSummaryTier } from '../v2/governed-tier.leaf.js';
188
199
  import { awaitWrunChildOverlays, mountWrunChildOverlays, prepareWrunHeatmapWindowLanding, WrunStaleLandingError, } from './wrun-panel-mount.util.js';
189
- import { planWrunFormingPreRoll, planWrunIntrabarLegFetch, planWrunLegFetch, wrunClampedLegDiagnostics, wrunIntrabarServedNotes, wrunLegFetchReads, } from './wrun-leg-fetch.util.js';
190
- import { barEndMs, isCalendarIntervalLabel, isCalendarIntervalMs } from '../chart/calendar-interval.util.js';
191
- import { resolveWrunTapeAcquisition, WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE, WRUN_TAPE_TOO_MANY_TRADES_CODE, WRUN_TAPE_VALUE_UNPROVEN_CODE, wrunTapeAcquisitionFloor, wrunTapeFloorOf, wrunTapeFloorSettingWords, wrunTapeFloorSettings, wrunTapeFloorWords, wrunTapeLaneExtras, } from './wrun-tape-source.util.js';
200
+ import { planWrunFormingPreRoll, planWrunIntrabarLegFetch, planWrunLegFetch, wrunClampedLegDiagnostics, wrunIntrabarServedNotes, wrunLegFetchReads, WRUN_COARSER_LEG_WARMUP_CANDLES, } from './wrun-leg-fetch.util.js';
201
+ import { barEndMs, isCalendarIntervalLabel } from '../chart/calendar-interval.util.js';
202
+ import { wrunCandlesLowAcross, wrunCoinTapeDayAsk, wrunCoinTapeWindow, wrunHeldCoinTapePriceLow, wrunPricedCoinTape, wrunTapeReadIdentity, WRUN_TAPE_COINS_DAY_INTERVAL, WRUN_TAPE_COINS_DAY_MS, } from './wrun-tape-coins.util.js';
203
+ import { normalizeTransformations, selfTransformationToken } from '../common/transformations.util.js';
204
+ import { resolveWrunTapeAcquisition, WRUN_TAPE_COINS_UNPRICED_CODE, WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE, WRUN_TAPE_TOO_MANY_TRADES_CODE, WRUN_TAPE_VALUE_UNPROVEN_CODE, wrunTapeAcquisitionFloor, wrunTapeFloorOf, wrunTapeFloorSettingWords, wrunTapeFloorSettings, wrunTapeFloorWords, wrunTapeLaneExtras, } from './wrun-tape-source.util.js';
192
205
  import { wrunChartSession, wrunLegCandleClose, wrunPrimaryRowBounds } from './wrun-leg-close.util.js';
193
206
  import { isWrunRowSourceTransientError, wrunRowBatchDeliveredSheet, wrunRowSourceSettingsLeftBy, } from './wrun-row-source.js';
194
207
  import { wrunOverlayOpraStamped } from './wrun-cloud-opra-stamp.util.js';
@@ -197,21 +210,24 @@ import { decideWrunRunOptionsMarket, noteWrunRunOptionsMarket, wrunDecidedOption
197
210
  import { wrunRowSourceFor } from './wrun-row-source-factory.js';
198
211
  import { __resetWrunSocketSessionLossesForTests, noteWrunSocketSessionLoss, wrunSocketSessionLossCause, wrunSocketSessionLossCount, } from './wrun-socket-session-losses.util.js';
199
212
  import { isWrunRunMountOnChart, raiseWrunSandboxLoading, wrunRowBatchCellRows, } from './wrun-sandbox-row-source.js';
200
- import { advanceWrunInputCarry, buildWrunInitArgs, buildWrunInputRows, emptyWrunInputCarry, planWrunPinnedWires, wrunChartIntervalKeyOf, wrunDeclaredSourceLanes, wrunDemandedSourceClass, wrunFormingBucketStart, WrunWirePiecesIncomplete, wrunAskWirePieces, wrunPinnedLegFetchSuffix, wrunSourceLane, wrunPinnedLegTierMs, wrunSourceVerdictWhole, wrunTradeLegIntervals, wrunWireRowPieces, wrunChartCandleRows, wrunChartCandleRowsAfterHead, wrunChartRowsOffIntervalGrid, wrunChartCandleRowsWithin, } from './wrun-source-rows.util.js';
213
+ import { advanceWrunInputCarry, buildWrunInitArgs, buildWrunInputRows, buildWrunInputRowsAndCarry, emptyWrunInputCarry, planWrunPinnedWires, wrunChartIntervalKeyOf, wrunDeclaredSourceLanes, wrunDemandedSourceClass, wrunFormingBucketStart, WrunWirePiecesIncomplete, wrunAskWirePieces, wrunPackedLaneRows, wrunPinnedLegFetchSuffix, wrunSourceLane, wrunPinnedLegTierMs, wrunSourceVerdictWhole, wrunTradeLegIntervals, wrunWireRowPieces, wrunChartCandleRows, wrunChartCandleRowsAfterHead, wrunChartRowsOffIntervalGrid, wrunChartCandleRowsWithin, } from './wrun-source-rows.util.js';
214
+ import { composeWrunSessionSources, wrunReseedServedComposition, wrunSessionCompositionToken, wrunSessionLanesOfContext, } from './wrun-session-composition.util.js';
201
215
  import { ringWrunRunRetained, wrunChartWalkedRows, wrunRetainedCanvasSources, wrunRunBlockRowsCap, wrunRunRetainedHeadFits, wrunRunRetainedRowsCap, wrunRunRetainedWindowOf, } from './wrun-run-retained.util.js';
202
216
  import { isWrunOptionsChainCryptoVenueWord, WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, WRUN_OPTIONS_CHAIN_VENUE_CODE, wrunOptionsChainExpiries, wrunOptionsChainIdentityKey, wrunOptionsChainLaneExtras, wrunOptionsChainOneVenueRefusal, } from './wrun-options-chain.util.js';
203
217
  import { adoptWrunLiveIntakeGeneration, markWrunLiveGap, noteWrunLiveIntakeEvent, wrunPushEligible, } from './wrun-live-intake.util.js';
204
218
  import { openWrunPollLaneLiveChannels } from './wrun-series-stream.util.js';
219
+ import { endWrunParkedLiveSeries, parkWrunOverlayLiveSession, takeWrunParkedLiveSession, } from './wrun-overlay-park.util.js';
205
220
  import { serverNowMs } from '../auth/server-clock.util.js';
206
221
  import { isWrunReplayRunCurrent, noteWrunReplayRun, wrunReplayRunPlanOf, } from './wrun-replay-lane.util.js';
207
222
  import { cutWrunReplayRowsAfterApply } from './wrun-replay-rows.util.js';
208
223
  import { builtinPortOf } from './wrun-builtin-twin.util.js';
209
- import { WRUN_HISTORY_WARMUP_MAX_BARS, wrunDeclaredWarmupBars, wrunDeclaredWarmupEndTs, wrunHistoryWarmupBars, } from './wrun-declared-warmup.util.js';
224
+ import { WRUN_HISTORY_WARMUP_MAX_BARS, wrunDeclaredWarmupBars, wrunDeclaredWarmupCovered, wrunDeclaredWarmupEndTs, wrunHistoryStampExactColumns, wrunHistoryWarmupBars, } from './wrun-declared-warmup.util.js';
210
225
  import { wrunLaneWarmupBars, wrunLaneWarmupFromMs } from './wrun-lane-warmup.util.js';
211
226
  import { orderWrunFirstRunHistory } from './wrun-first-run-depth.util.js';
212
227
  import { wrunTwinOriginalLookbackBars } from './wrun-twin-lookback.util.js';
213
228
  import { overlayWrunRunInterval, wrunSettingsForRunInterval, wrunTimeframeIsChartOrFiner, wrunTwinLookbackBars, } from './wrun-run-interval.util.js';
214
229
  import { planWrunRunIntervalRows, rememberWrunRunIntervalSession, wrunRunIntervalComputeRows, wrunRunIntervalCoverageKey, wrunRunIntervalProjectionOf, wrunRunIntervalRowsThrough, wrunRunIntervalSentRow, wrunRunIntervalSessionOf, } from './wrun-run-interval-session.util.js';
230
+ import { isWrunBandedBookSource } from './wrun-book-bands.leaf.js';
215
231
  import { attachWrunLive, wrunLiveOf, } from '../../interfaces/wrun-runtime.interface.js';
216
232
  import { normalizeRuntimeDiagnostics, shouldNoticeWrunRefusal, WRUN_RUN_FAILURE_ROW_CODES, WRUN_RUN_TIMEOUT_CODE, wrunAbortRuntimeDiagnostic, wrunRunFailureRuntimeDiagnostic, } from '../scriptEditor/wrun-runtime-diagnostics.leaf.js';
217
233
  import { buildWrunOverlayRunResult, withCanvasHostFill, } from './wrun-overlay-result.util.js';
@@ -304,7 +320,9 @@ export function cutWrunOddsLegRows(rows, lastChartTs) {
304
320
  }
305
321
  /**
306
322
  * The chart's forming bar for a build of its rows (`WrunChartSourceRows.formingBarTs`): the bar holding the
307
- * server clock's now on the chart's bar grid at `intervalMs` (`hostBucketResolverFor`), or null when the chart is
323
+ * chart's STREAM clock on its bar grid at `intervalMs` (`wrunChartFormingBarTs`: the server's now less the served
324
+ * delay on a delayed chart, whose newest bar holds `now - delay`; the venue its candles ride, a stock Trades chart's
325
+ * tape), or null when the chart is
308
326
  * not live (a replay, go-to-date history), whose last bar is closed: the fetch layer's rule (dataFetch's
309
327
  * `formingBarTs`). A row of a leg on another bar grid still forming past the chart's newest bar lands in the bar
310
328
  * holding its open only when that bar is this one, so a closed bar never shows a later value.
@@ -320,7 +338,7 @@ async function wrunFormingBarTsOf(chartIndex, intervalMs, market) {
320
338
  catch {
321
339
  // No chart store to read: the chart's own bars judge (a closed last bar never holds now).
322
340
  }
323
- return hostBucketResolverFor(intervalMs, liveBucketVenueOf(market))(serverNowMs());
341
+ return wrunChartFormingBarTs(intervalMs, wrunChartStreamRefOf(chartIndex, market));
324
342
  }
325
343
  /** Whether a build lands a leg's rows on the chart's bars (`WRUN_PINNED_WIRE_ROWS`: a grid leg, a trades leg): the
326
344
  * only rows its forming bar (`wrunFormingBarTsOf`) decides. */
@@ -353,12 +371,14 @@ const WRUN_LIVE_LANE_OF_FETCH_KEY = {
353
371
  tp: 'tape',
354
372
  };
355
373
  /** The live lane a fetch key feeds: the row builder's own lanes by their key, a registry poll
356
- * lane instance and a trades leg lane by its id (its fetch key IS its lane id, `poll:*`,
357
- * `trades@<exchange>|<symbol>`), undefined for a key that is no lane's own (a candle leg, a
358
- * per-ticker ETF ask). */
374
+ * lane instance, a trades leg lane and a pinned lane by its id (its fetch key IS its lane id,
375
+ * `poll:*`, `trades@<exchange>|<symbol>`, `book@<exchange>|<symbol>`), undefined for a key that is
376
+ * no lane's own (a candle leg, a per-ticker ETF ask). */
359
377
  function wrunLiveLaneOfFetchKey(key) {
360
378
  return (WRUN_LIVE_LANE_OF_FETCH_KEY[key] ??
361
- (isWrunPollLaneId(key) || isWrunRowLaneId(key) || isWrunTradesLegLane(key) ? key : undefined));
379
+ (isWrunPollLaneId(key) || isWrunRowLaneId(key) || isWrunTradesLegLane(key) || isWrunPinnedLaneId(key)
380
+ ? key
381
+ : undefined));
362
382
  }
363
383
  /** THE run market: where the chart's trades print for this run (a Trades chart's tape), null for the chart's own. */
364
384
  async function decideWrunRunMarket(chartMetadata, settings) {
@@ -373,6 +393,13 @@ async function decideWrunRunMarket(chartMetadata, settings) {
373
393
  return null;
374
394
  }
375
395
  }
396
+ /** The reasons a person's own request carries; a range wave, a heal or a recovery rung may borrow their attempt but is
397
+ * the chart's own, and must keep a failed read's rest. */
398
+ const WRUN_PERSON_RUN_REASONS = new Set(['initial', 'retry', 'settings']);
399
+ /** A collaborator's settings apply and a restore open a system attempt: only a person's own request reads again. */
400
+ function wrunRunAnswersPerson(reason, attempt) {
401
+ return attempt?.origin === 'user' && reason !== undefined && WRUN_PERSON_RUN_REASONS.has(reason);
402
+ }
376
403
  /** Recompute one mounted WRUN overlay over the chart's CURRENT loaded rows
377
404
  * and integrate the result through the shared adapter path. */
378
405
  export async function runWrunOverlayOnChart(target) {
@@ -473,6 +500,10 @@ export async function runWrunOverlayOnChart(target) {
473
500
  identity: wrunChartMarketIdentity(chartMetadata),
474
501
  read: readChartMetadata,
475
502
  };
503
+ // A person's Retry must not wait out a failed read's rest; the chart's own reruns keep it so as not to hammer it.
504
+ if (wrunRunAnswersPerson(target.reason, refusalAttempt))
505
+ forgetWrunMarketReadFailures(chartMetadata);
506
+ const marketReadsSince = wrunMarketReadMark();
476
507
  const chartExchange = chartMetadata?.exchange;
477
508
  // The refusal context every record of this run completes against (WRUN-REFUSALS U3a step 1):
478
509
  // the run's title (the declared name), this chart metadata's facts, and the effective sheet's
@@ -526,15 +557,22 @@ export async function runWrunOverlayOnChart(target) {
526
557
  if (!isOpraUserScriptsFlagOn())
527
558
  gate?.armOpraUserScriptsRejudge?.();
528
559
  }
529
- // A run the `cme-user-scripts` gate may open the CME plane to (a browser run the viewer wrote or added) that the
530
- // CME display wall refuses on this chart waits, bounded, for the flag map (the port's
531
- // `awaitCmeUserScriptsFlagHydration`), and the wall is asked again below: a restore can run before the map
532
- // hydrates, and an unhydrated map reads closed. Every other run never waits on the map. The bound ran out with the
533
- // flag still dark: the wall refuses this run now, and a gate that opens later judges the walled CME studies again
534
- // (`armCmeUserScriptsRejudge`). A host that binds neither port judges by the map as it stands.
535
- if (isCmeUserScriptCandidate(provenance) &&
536
- payloadTouchesCmeVenue(chartExchange) &&
537
- isKScriptDisplayBlockedOnExchange(chartExchange, provenance)) {
560
+ // A run the `cme-user-scripts` gate may open the CME plane to (a browser run the viewer wrote or added) that a CME
561
+ // wall refuses waits, bounded, for the flag map (the port's `awaitCmeUserScriptsFlagHydration`), and the wall is
562
+ // asked again below: on a CME chart the display wall, off one the pin judge of a package pinning a CME market
563
+ // (`sheetPinsCme`). A restore can run before the map hydrates, and an unhydrated map reads closed. Every other run
564
+ // never waits on the map. The bound ran out with the flag still dark: the wall refuses this run now, and a gate
565
+ // that opens later judges the walled CME studies again (`armCmeUserScriptsRejudge`). A host that binds neither port
566
+ // judges by the map as it stands.
567
+ const cmeCandidate = isCmeUserScriptCandidate(provenance);
568
+ // The sheet as the prediction wall reads it pins a CME market: read for a browser user run alone, the runs a CME
569
+ // pin's flag wait and authorisation are for (an OpenMarket package reads CME as first-party).
570
+ const sheetPinsCme = cmeCandidate &&
571
+ wrunSheetPinsCme(wrunSheetWithLaneDemand(wrunSheetWithSettings(target.metadata, meta.settings), wrunChartSizeUnit(chartMetadata), meta.settings), typeof chartExchange === 'string' ? chartExchange : undefined);
572
+ const cmeWallAhead = payloadTouchesCmeVenue(chartExchange)
573
+ ? isKScriptDisplayBlockedOnExchange(chartExchange, provenance)
574
+ : sheetPinsCme && !isCmeUserScriptRun(provenance);
575
+ if (cmeCandidate && cmeWallAhead) {
538
576
  const gate = await wrunChartHostEnv()
539
577
  .market.loadOptionsGate()
540
578
  .then(async (loaded) => {
@@ -548,14 +586,14 @@ export async function runWrunOverlayOnChart(target) {
548
586
  // The market the candles came from: a chart riding a tape walls what that tape's own chart walls.
549
587
  const candleVenue = wrunChartCandleVenue(chartMetadata);
550
588
  if (isKScriptDisplayBlockedOnExchange(candleVenue, provenance)) {
551
- throw withCmeStudyStopSeed(new WrunVenueBlockedError(createKScriptVenueBlockedError(String(candleVenue)).message), target.chartIndex, target.indicatorId, candleVenue);
589
+ throw withCmeStudyStopSeed(new WrunVenueBlockedError(createKScriptVenueBlockedError(String(candleVenue)).message, candleVenue), target.chartIndex, target.indicatorId, candleVenue);
552
590
  }
553
591
  // Strategy testing is no CME chart study (Kyle 2026-10-29): on a CME chart every strategy sheet is refused, an
554
592
  // OpenMarket package's included, here at the head before the loader is raised, a lane is asked or the sandbox is
555
593
  // touched (the broker feed, `wrunStrategyRunInputFor`, is never built), on every lane. A venue refusal held like
556
594
  // the wall's, with its own record on the legend (`cme-wall` `strategy`: no wall painter stands behind it).
557
595
  if (payloadTouchesCmeVenue(chartExchange) && isWrunStrategySheet(target.metadata)) {
558
- throw attachWrunRefusal(new WrunStrategyVenueBlockedError(createKScriptVenueBlockedError(String(chartExchange)).message), WRUN_CME_STRATEGY_REFUSAL_SEED);
596
+ throw attachWrunRefusal(new WrunStrategyVenueBlockedError(createKScriptVenueBlockedError(String(chartExchange)).message, chartExchange), WRUN_CME_STRATEGY_REFUSAL_SEED);
559
597
  }
560
598
  // The prediction-market wall (Kyle 2026-10-29: options indicators on a Polymarket chart make no sense): on a
561
599
  // Polymarket or HIP4 chart an input read by the chart's coin (the options chain and its lanes, a provider lane, a
@@ -566,17 +604,22 @@ export async function runWrunOverlayOnChart(target) {
566
604
  // strategy refusal, with its own record (`cme-wall` `prediction`): the run after the chart leaves the prediction
567
605
  // market computes.
568
606
  const predictionWalled = typeof chartExchange === 'string' && isPredictionExchangeName(chartExchange)
569
- ? wrunPredictionMarketWalledInput(wrunSheetWithLaneDemand(wrunSheetWithSettings(target.metadata, meta.settings), wrunChartSizeUnit(chartMetadata)), chartExchange)
607
+ ? wrunPredictionMarketWalledInput(wrunSheetWithLaneDemand(wrunSheetWithSettings(target.metadata, meta.settings), wrunChartSizeUnit(chartMetadata), meta.settings), chartExchange)
570
608
  : undefined;
571
609
  if (predictionWalled !== undefined) {
572
- throw attachWrunRefusal(new WrunPredictionMarketBlockedError(`Input '${predictionWalled.name}' (${predictionWalled.sourceClass}) reads by the chart's coin, which ${String(chartExchange)} does not have`), WRUN_PREDICTION_MARKET_REFUSAL_SEED);
573
- }
574
- // A CME chart study (`isCmeUserScriptRun`: the gate opened the CME plane to this browser run) computes under the
575
- // authorisation the wall just read, captured in the same task (cme-user-scripts-gate.util `captureCmeStudyAuth`):
576
- // a move of the viewer's access since (the account, the CME data terms, the served access, the flag, the session)
577
- // retires the run (`isCurrent`), and its answer never lands (`assertWrunCmeStudyAuthCurrent`). An OpenMarket
578
- // package reads CME as first-party: the mark alone, no token.
579
- if (computed.cme === true && isCmeUserScriptRun(provenance))
610
+ throw attachWrunRefusal(new WrunPredictionMarketBlockedError(`Input '${predictionWalled.name}' (${predictionWalled.sourceClass}) reads by the chart's coin, which ${String(chartExchange)} does not have`, chartExchange), WRUN_PREDICTION_MARKET_REFUSAL_SEED);
611
+ }
612
+ // The gate's own answer for this run, whatever the chart: the chain wall words its refusal by it, and the pin judge
613
+ // admits a CME pin on any chart by it (`mayReadCmePin`).
614
+ const cmeUserScripts = isCmeUserScriptRun(provenance);
615
+ // A browser run the gate opened the CME plane to that reads CME (a CME chart study, `isCmeChartStudyRun`, or a run
616
+ // pinning a CME market on any chart) computes under the authorisation the gate just read, captured in the same task
617
+ // (cme-user-scripts-gate.util `captureCmeStudyAuth`): a move of the viewer's access since (the account, the CME data
618
+ // terms, the served access, the flag, the session) retires the run (`isCurrent`), and its answer never lands
619
+ // (`assertWrunCmeStudyAuthCurrent`). An OpenMarket package reads CME as first-party: the mark alone, no token.
620
+ // The one fact every CME chain wall reads (`mayReadCmeChain`): a token-less run off a CME chart reads no CME chain.
621
+ const cmeStudyChain = isCmeChartStudyRun(provenance, chartExchange);
622
+ if (cmeStudyChain || (cmeUserScripts && sheetPinsCme))
580
623
  computed.cmeAuth = captureCmeStudyAuth();
581
624
  // The package's provenance, read once beside the wall's door: an OpenMarket package reads the US
582
625
  // options chain of a stock, ETF or OPRA contract chart, and so does a package the viewer wrote or
@@ -624,7 +667,7 @@ export async function runWrunOverlayOnChart(target) {
624
667
  // undemanded input past this point; a switch re-runs the overlay through here, so the legs
625
668
  // follow the new coin. A failed listing lookup refuses the run by name.
626
669
  const coinLegs = await resolveWrunCoinLegs(target.metadata, chartMetadata, meta.settings);
627
- const marketTarget = wrunRunTargetOnMarket(target, chartMetadata, coinLegs);
670
+ const marketTarget = wrunRunTargetOnMarket(target, chartMetadata, meta.settings, coinLegs);
628
671
  // Loading for the whole compute pass, in the vocabulary a cloud run's fetch speaks: the row source
629
672
  // raises the legend loader and the store's kScript loading flag before its lanes fetch and lowers
630
673
  // them once the pass landed its batch, on success, failure, abort and the deadline alike
@@ -652,7 +695,9 @@ export async function runWrunOverlayOnChart(target) {
652
695
  isCurrent,
653
696
  official,
654
697
  opraUserScripts,
655
- ...(isCmeUserScriptCandidate(provenance) ? { cmeUserStudy: true } : {}),
698
+ cmeStudyChain,
699
+ cmeUserScripts,
700
+ marketReadsSince,
656
701
  ...(options !== undefined ? { options } : {}),
657
702
  }));
658
703
  }
@@ -746,6 +791,13 @@ export async function runWrunOverlayOnChart(target) {
746
791
  token: refusalAttempt,
747
792
  isCurrent,
748
793
  });
794
+ // A CME pin the closed gate refused, the gate open by now: it opened after the judge read it, maybe before the
795
+ // armed watch could find this record, so the run is asked again behind this one (the executor's follow-up).
796
+ if (wrunRefusalSeedOf(error)?.cls === 'pin-refused' &&
797
+ isCurrent() &&
798
+ isCmeReadableKScriptRun(mount.meta?.settings)) {
799
+ void requestWrunOverlayRerun(target.chartIndex, target.indicatorId, 'switch');
800
+ }
749
801
  }
750
802
  retractWrunStandInOnRunFailure(target.chartIndex, target.indicatorId, error, computedFor);
751
803
  // The rejection names the overlay it failed on: the editor's Run awaits
@@ -844,8 +896,9 @@ const WRUN_CME_STOP_VARIANT = Object.freeze({
844
896
  * The display wall's refusal at the run head for a CME chart study the lifecycle stopped in place: it carries the
845
897
  * stopped row's seed (`WRUN_CME_STOP_VARIANT`), the words Door H paints over the same study, so a rerun (a pan, an
846
898
  * interval change, an access recheck) reads why it stopped wherever its record is made (the editor console, the
847
- * loader's catch), never today's wall. Any other wall refusal rides no seed: every reader words it as the wall, as
848
- * before. The register is main-thread state; a study it holds no row for has none.
899
+ * loader's catch), never today's wall. Any other wall refusal rides no seed: every reader words it by its `venue`'s
900
+ * gate plane (wrun-refusal.util `wrunVenueWallSeed`). The register is main-thread state; a study it holds no row for
901
+ * has none.
849
902
  */
850
903
  function withCmeStudyStopSeed(error, chartIndex, indicatorId, exchange) {
851
904
  if (!payloadTouchesCmeVenue(exchange))
@@ -880,7 +933,8 @@ function wrunRunOutputProvenance(computed) {
880
933
  function isWrunVenueWallPainted(error) {
881
934
  return (error instanceof WrunVenueBlockedError &&
882
935
  !(error instanceof WrunStrategyVenueBlockedError) &&
883
- !(error instanceof WrunPredictionMarketBlockedError));
936
+ !(error instanceof WrunPredictionMarketBlockedError) &&
937
+ !(error instanceof WrunLaneVenueBlockedError));
884
938
  }
885
939
  /** A run's runtime trap row with the run's console provenance on it (`RuntimeDiagnostic.opra` and `.cme`): the row as
886
940
  * it is for a run that read neither plane. */
@@ -933,7 +987,7 @@ function wrunRunSettleOf(error) {
933
987
  if (isWrunSourceHold(error)) {
934
988
  return {
935
989
  outcome: 'held',
936
- reason: wrunRefusedSourceHolds.has(error) ? WRUN_LANE_REFUSED_SETTLE_REASON : 'source-hold',
990
+ reason: wrunLaneRefusedHoldCodeOf(error) !== undefined ? WRUN_LANE_REFUSED_SETTLE_REASON : 'source-hold',
937
991
  };
938
992
  }
939
993
  return { outcome: 'failed', reason: error instanceof Error ? error.message : String(error) };
@@ -1014,6 +1068,8 @@ export async function surfaceWrunRunFailureOnLegend(chartIndex, indicatorId, err
1014
1068
  // rows this run never produced. A stale failure touches neither them nor the legend.
1015
1069
  if (!isCurrent())
1016
1070
  return;
1071
+ // A nothing-drawn raise an earlier result still holds for its warm-up verdict goes with them.
1072
+ forgetWrunNothingDrawn(chartIndex, indicatorId);
1017
1073
  await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_REFUSAL_NOTE_ROW_CODES, []);
1018
1074
  if (!isCurrent())
1019
1075
  return;
@@ -1113,9 +1169,6 @@ catch {
1113
1169
  /** The source holds this pass threw (a degraded lane an input reads under a
1114
1170
  * carry or zero policy): retryable, with no toast and no chip of their own. */
1115
1171
  const wrunSourceHolds = new WeakSet();
1116
- /** The source holds on a lane the data plane refused by name (wrun-lane-refusal.leaf): the same settings meet
1117
- * the same refusal, so they settle as `WRUN_LANE_REFUSED_SETTLE_REASON` (wrunRunSettleOf). */
1118
- const wrunRefusedSourceHolds = new WeakSet();
1119
1172
  function isWrunSourceHold(error) {
1120
1173
  return typeof error === 'object' && error !== null && wrunSourceHolds.has(error);
1121
1174
  }
@@ -1139,13 +1192,32 @@ function wrunPinReadsOpra(market) {
1139
1192
  return false;
1140
1193
  return wrunPinMarketsOf(market.exchange ?? '', market.symbol ?? '').some((leg) => payloadTouchesOpraVenue(leg.exchange));
1141
1194
  }
1142
- /** Whether a pin names a market on the CME plane (`wrunPinReadsOpra`'s twin): only a CME chart's own family admits one
1143
- * (the kit refuses a CME pin from any other chart, whoever wrote the package). */
1195
+ /** Whether a pin names a market on the CME plane (`wrunPinReadsOpra`'s twin): on any chart, for a run the pin judge
1196
+ * opened it to (`mayReadCmePin`). */
1144
1197
  function wrunPinReadsCme(market) {
1145
1198
  if (market === undefined)
1146
1199
  return false;
1147
1200
  return wrunPinMarketsOf(market.exchange ?? '', market.symbol ?? '').some((leg) => payloadTouchesCmeVenue(leg.exchange));
1148
1201
  }
1202
+ /**
1203
+ * Whether the sheet a run reads (its settings painted, its lane demand applied) pins a CME market: a secondary input's
1204
+ * pinned market (an ohlcv or leg-stream pin, a trades leg, a coin leg's venue) on the CME plane (`wrunPinReadsCme`), or
1205
+ * a spelling the pin step respells onto one (`wrunPinSpellingReadsCme`: a TradingView CME prefix, our key in the
1206
+ * symbol half, our escape). Read at the run head before the pin step and the host load (no catalog, no shared host):
1207
+ * the head's best reading, for its flag wait and a prefix page's authorisation; the full run's lanes capture the
1208
+ * authorisation again from the resolved legs.
1209
+ */
1210
+ export function wrunSheetPinsCme(metadata, chartExchange) {
1211
+ return metadata.inputs.some((input) => {
1212
+ const source = metadata.inputSources[input.name];
1213
+ if (input.index === 0 || source === undefined || source.undemanded === true)
1214
+ return false;
1215
+ if (source.exchange === undefined && source.symbol === undefined)
1216
+ return false;
1217
+ const market = { exchange: source.exchange, symbol: source.symbol };
1218
+ return wrunPinReadsCme(market) || wrunPinSpellingReadsCme(market, chartExchange);
1219
+ });
1220
+ }
1149
1221
  function wrunSheetReadsOpraLane(metadata) {
1150
1222
  return wrunPollPlanReadsChain(metadata) || wrunRowPlanReadsChain(metadata);
1151
1223
  }
@@ -1522,8 +1594,7 @@ async function planWrunRunDownload(args) {
1522
1594
  sourceClass: lane.sourceClass,
1523
1595
  indexMode: chart.indexMode,
1524
1596
  cryptoVenue: isWrunCryptoVenueExchange(chart.exchange),
1525
- official: args.facts.official,
1526
- opraUserScripts: args.facts.opraUserScripts,
1597
+ ...args.facts,
1527
1598
  };
1528
1599
  // A chain lane forecasts the chain its plan reads, under the run's one decision (a twin's stock by its ticker).
1529
1600
  const ctx = lane.chain !== undefined ? wrunChainLaneContext(chartCtx, args.options) : chartCtx;
@@ -1567,6 +1638,7 @@ async function planWrunRunDownload(args) {
1567
1638
  const WRUN_REFUSAL_NOTE_ROW_CODES = new Set([
1568
1639
  ...WRUN_LEG_ROW_CODES,
1569
1640
  ...WRUN_RUN_HEALTH_ROW_CODES,
1641
+ ...WRUN_NOTHING_DRAWN_ROW_CODES,
1570
1642
  ...WRUN_DRAW_SKIPPED_ROW_CODES,
1571
1643
  ...WRUN_PIN_ROW_CODES,
1572
1644
  ...WRUN_ROW_BUDGET_ROW_CODES,
@@ -1646,8 +1718,12 @@ exchangeOf) {
1646
1718
  if (key === undefined || outcome.kind !== 'rows' || outcome.rows.length > 0 || unsettled.has(key))
1647
1719
  return [];
1648
1720
  const exchange = exchangeOf(lane);
1649
- // The lane's own readers: a trades input pinned to another market reads its leg lane instead.
1650
- const readers = wrunInputNamesOfClass(metadata, lane, (source) => !isWrunTradesLegLane(wrunSourceLane(source)));
1721
+ // The lane's own readers: a trades input pinned to another market reads its leg lane instead, and a book, oi,
1722
+ // funding or liquidations input pinned to another market its pinned lane (U9e).
1723
+ const readers = wrunInputNamesOfClass(metadata, lane, (source) => {
1724
+ const read = wrunSourceLane(source);
1725
+ return !isWrunTradesLegLane(read) && !isWrunPinnedLaneId(read);
1726
+ });
1651
1727
  const type = WRUN_BUILTIN_LANE_FETCH_TYPES[lane];
1652
1728
  return [
1653
1729
  {
@@ -1764,10 +1840,13 @@ function enterWrunRefusalRun(guardKey) {
1764
1840
  }
1765
1841
  function leaveWrunRefusalRun(guardKey) {
1766
1842
  const left = (wrunRefusalRunsInFlight.get(guardKey) ?? 1) - 1;
1767
- if (left > 0)
1843
+ if (left > 0) {
1768
1844
  wrunRefusalRunsInFlight.set(guardKey, left);
1769
- else
1770
- wrunRefusalRunsInFlight.delete(guardKey);
1845
+ return;
1846
+ }
1847
+ wrunRefusalRunsInFlight.delete(guardKey);
1848
+ // The run's own arm may have turned its sources terminal while it was in flight: a held warm-up ask reads that now.
1849
+ wrunWarmupLandingListener(guardKey);
1771
1850
  }
1772
1851
  function dropWrunTerminalDegradeWatch(guardKey) {
1773
1852
  wrunTerminalDegradeWatches.delete(guardKey);
@@ -1854,6 +1933,10 @@ function wrunSourceGivenUpOf(outcome) {
1854
1933
  * refuses by name names its record here.
1855
1934
  */
1856
1935
  const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1936
+ // No order book on the market: feed-missing (a note beside drawn rows, paused on a hold), never Remove or Retry.
1937
+ book: {
1938
+ [WRUN_NO_ORDER_BOOK_CODE]: () => ({ cls: 'feed-missing', params: { feed: 'book' } }),
1939
+ },
1857
1940
  // The tape's history held more prints at its floor than the trades worker reads (k-trades.worker, the large lane):
1858
1941
  // too much data, with the cap, the floor and the history's days (seven for Big Trades), and the way out raises the
1859
1942
  // floor in the settings. Never Remove: the market serves the tape, the floor was too low for it.
@@ -1866,7 +1949,9 @@ const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1866
1949
  setting: wrunTapeFloorSettingWords(metadata),
1867
1950
  // The floor in its own unit: the raw number under `min_size` (as it always was), a dollar amount under
1868
1951
  // `min_value` ($500,000).
1869
- min: tape?.minValue === undefined ? (tape?.minSize ?? 0) : wrunTapeFloorWords(tape),
1952
+ min: tape?.minValue === undefined && tape?.minCoins === undefined
1953
+ ? (tape?.minSize ?? 0)
1954
+ : wrunTapeFloorWords(tape),
1870
1955
  n: tape === undefined ? 0 : Math.round((tape.historySeconds / 86_400) * 10) / 10,
1871
1956
  },
1872
1957
  out: { kind: 'open-settings' },
@@ -1875,10 +1960,18 @@ const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1875
1960
  };
1876
1961
  /** The seed a row-builder lane declares for a refusal by name, or undefined (a poll lane, an undeclared code). */
1877
1962
  function wrunBuiltinLaneRefusedSeed(lane, code, facts) {
1878
- if (!Object.hasOwn(WRUN_BUILTIN_LANE_REFUSED_ANSWERS, lane))
1963
+ // A pinned lane (U9e) answers in its class's record, naming its own market rather than the chart's.
1964
+ const pinned = wrunPinnedLaneOf(lane);
1965
+ const builtin = pinned?.cls ?? lane;
1966
+ if (!Object.hasOwn(WRUN_BUILTIN_LANE_REFUSED_ANSWERS, builtin))
1967
+ return undefined;
1968
+ const answers = WRUN_BUILTIN_LANE_REFUSED_ANSWERS[builtin];
1969
+ if (answers === undefined || !Object.hasOwn(answers, code))
1879
1970
  return undefined;
1880
- const answers = WRUN_BUILTIN_LANE_REFUSED_ANSWERS[lane];
1881
- return answers !== undefined && Object.hasOwn(answers, code) ? answers[code](facts) : undefined;
1971
+ const seed = answers[code](facts);
1972
+ if (pinned === undefined)
1973
+ return seed;
1974
+ return { ...seed, market: { exchange: pinned.exchange, symbol: pinned.symbol, label: pinned.symbol } };
1882
1975
  }
1883
1976
  /**
1884
1977
  * The record a degraded lane shows once the source ladder gives up on it: the code of what it was
@@ -1961,10 +2054,10 @@ async function settleWrunRefusalsOnHold(guardKey, target, refusal, token, isCurr
1961
2054
  }
1962
2055
  /** A reseed's refusals (a full run over the buffers): every owner's verdict retracted, then the last
1963
2056
  * full run's terminal lane said again (the reseed computed over the same empty lane). */
1964
- async function settleWrunRefusalsOnReseed(chartIndex, indicatorId) {
2057
+ async function settleWrunRefusalsOnReseed(chartIndex, indicatorId, isCurrent) {
1965
2058
  try {
1966
2059
  const target = { chartIndex, indicatorId };
1967
- await retractWrunRefusal(target, 'all');
2060
+ await retractWrunRefusal(target, 'all', isCurrent !== undefined ? { isCurrent } : {});
1968
2061
  const guardKey = overlayExecutionGuardKey(chartIndex, indicatorId);
1969
2062
  const watch = wrunTerminalDegradeWatches.get(guardKey);
1970
2063
  const terminal = watch ? wrunTerminalDegradeRefusalOf(guardKey, watch) : undefined;
@@ -1972,7 +2065,7 @@ async function settleWrunRefusalsOnReseed(chartIndex, indicatorId) {
1972
2065
  await projectWrunRefusal(watch.target, terminal, {
1973
2066
  owner: 'run',
1974
2067
  notify: false,
1975
- isCurrent: () => wrunTerminalDegradeWatches.get(guardKey) === watch,
2068
+ isCurrent: () => wrunTerminalDegradeWatches.get(guardKey) === watch && isCurrent?.() !== false,
1976
2069
  });
1977
2070
  }
1978
2071
  }
@@ -2065,6 +2158,82 @@ async function publishWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, diagnos
2065
2158
  export async function publishWrunRunHealth(chartIndex, indicatorId, diagnostics, options = {}) {
2066
2159
  return publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_RUN_HEALTH_ROW_CODES, diagnostics, options);
2067
2160
  }
2161
+ /** The overlays whose viewer note `WRUN_NOTHING_DRAWN` stands, by chart and overlay id: an integrate that draws (a
2162
+ * live tick's included) lowers it without a store read on every tick. */
2163
+ const wrunNothingDrawnRaised = new Set();
2164
+ /** The newest note decision of each overlay (same key): a raise held for the warm-up verdict publishes only while it is
2165
+ * the newest, and an integrate that draws drops it. */
2166
+ const wrunNothingDrawnDecisions = new Map();
2167
+ function wrunNothingDrawnKey(chartIndex, indicatorId) {
2168
+ return `${chartIndex}:${indicatorId}`;
2169
+ }
2170
+ /** The leg rule the note's cause is read with: the interval pin vocabulary, and the warm-up floor the leg fetch gives a
2171
+ * coarser leg (a reach under it is short). */
2172
+ const WRUN_NOTHING_DRAWN_LEG_RULE = {
2173
+ intervalOf: wrunPinnedIntervalOf,
2174
+ floor: WRUN_COARSER_LEG_WARMUP_CANDLES,
2175
+ };
2176
+ /**
2177
+ * The viewer's nothing-drawn note (wrun-run-health.util, FB27) after a full run, a reseed, an adoption or a landed
2178
+ * page: raised when a published Indicator's settled run drew nothing over its whole loaded window (with the cause when
2179
+ * the run knows it), cleared by one that drew and on a draft (whose own rows speak to its author); a run that is not
2180
+ * settled (a partial window, a first slice still filling, a lane unanswered, a source with a note of its own) leaves
2181
+ * it as it stands. A run that asks the warm-up decider (`warmup`) holds its raise until the decider says no older page
2182
+ * is coming: a page it buys reruns the overlay, and that run decides, so no load in flight is ever named empty. The
2183
+ * refusal context is built only for a note. Advisory like the health rows.
2184
+ */
2185
+ export async function publishWrunNothingDrawn(chartIndex, indicatorId, run, refusalContext, options = {}) {
2186
+ try {
2187
+ const verdict = wrunViewerNothingDrawn({ ...run, legs: WRUN_NOTHING_DRAWN_LEG_RULE });
2188
+ if (verdict === undefined)
2189
+ return;
2190
+ const key = wrunNothingDrawnKey(chartIndex, indicatorId);
2191
+ const decision = Symbol(key);
2192
+ wrunNothingDrawnDecisions.set(key, decision);
2193
+ const publish = async () => {
2194
+ if (wrunNothingDrawnDecisions.get(key) !== decision)
2195
+ return;
2196
+ const rows = verdict === null ? [] : wrunNothingDrawnDiagnostics(verdict, await refusalContext());
2197
+ // A newer run decided, or a draw dropped the raise, while the context was built.
2198
+ if (wrunNothingDrawnDecisions.get(key) !== decision)
2199
+ return;
2200
+ wrunNothingDrawnDecisions.delete(key);
2201
+ const standing = await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_NOTHING_DRAWN_ROW_CODES, rows, options.isCurrent !== undefined ? { isCurrent: options.isCurrent } : {});
2202
+ if (standing)
2203
+ wrunNothingDrawnRaised.add(key);
2204
+ else
2205
+ wrunNothingDrawnRaised.delete(key);
2206
+ };
2207
+ if (verdict !== null && options.warmup !== undefined) {
2208
+ options.warmup.whenNoPage(() => void publish().catch(() => undefined));
2209
+ return;
2210
+ }
2211
+ await publish();
2212
+ }
2213
+ catch {
2214
+ /* advisory rows: never a second failure on the run path */
2215
+ }
2216
+ }
2217
+ /** Drop the overlay's note bookkeeping (a failed run clears the note's row with the run's other notes): a raise held
2218
+ * for the warm-up verdict never lands after it. */
2219
+ function forgetWrunNothingDrawn(chartIndex, indicatorId) {
2220
+ const key = wrunNothingDrawnKey(chartIndex, indicatorId);
2221
+ wrunNothingDrawnDecisions.delete(key);
2222
+ wrunNothingDrawnRaised.delete(key);
2223
+ }
2224
+ /** A nothing-drawn note goes the moment an integrate draws, standing or held for the warm-up verdict: the presentation
2225
+ * of every integrate calls this (a live tick's too, which re-reads only the health rows). */
2226
+ function lowerWrunNothingDrawnOnDraw(chartIndex, indicatorId, metadata, outputRows) {
2227
+ const key = wrunNothingDrawnKey(chartIndex, indicatorId);
2228
+ if (!wrunNothingDrawnRaised.has(key) && !wrunNothingDrawnDecisions.has(key))
2229
+ return;
2230
+ if (!wrunRunDrewSomething(metadata, outputRows, wrunHandlesOf(outputRows)?.length))
2231
+ return;
2232
+ wrunNothingDrawnDecisions.delete(key);
2233
+ if (!wrunNothingDrawnRaised.delete(key))
2234
+ return;
2235
+ void publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_NOTHING_DRAWN_ROW_CODES, []);
2236
+ }
2068
2237
  /** The unserved-leg rows of a run (the venue soft refusals, `WRUN_LEG_UNSERVED`): their own
2069
2238
  * owned set beside the health rows, replaced by every full run, cleared by a run that served
2070
2239
  * every leg. Advisory like the health rows. */
@@ -2076,9 +2245,9 @@ export async function publishWrunUnservedLegDiagnostics(chartIndex, indicatorId,
2076
2245
  * refine, a reseed and a live tick alike, the last two through
2077
2246
  * publishWrunSessionCanvasNotices), a set with none clears a stale one, and a set equal to the
2078
2247
  * published one writes nothing; drafts and registry Indicators alike. */
2079
- async function publishWrunCanvasNotices(chartIndex, indicatorId, runResult) {
2248
+ async function publishWrunCanvasNotices(chartIndex, indicatorId, runResult, isCurrent) {
2080
2249
  try {
2081
- await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_CANVAS_NOTICE_ROW_CODES, wrunCanvasNoticeDiagnostics(wrunRunNoticesOf(runResult)), { unlessSame: sameWrunCanvasNotices });
2250
+ await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_CANVAS_NOTICE_ROW_CODES, wrunCanvasNoticeDiagnostics(wrunRunNoticesOf(runResult)), { unlessSame: sameWrunCanvasNotices, ...(isCurrent !== undefined ? { isCurrent } : {}) });
2082
2251
  }
2083
2252
  catch {
2084
2253
  /* advisory rows (a spec's partial mock of the canvas seams too): never a second failure on the run path */
@@ -2121,17 +2290,22 @@ export async function publishWrunSessionCanvasNotices(session, runResult, option
2121
2290
  if (options.tick && last.length === lines.length && last.every((line, at) => line === lines[at]))
2122
2291
  return;
2123
2292
  wrunSessionCanvasNoticeLines.set(session, lines);
2124
- await publishWrunCanvasNotices(session.chartIndex, session.indicatorId, runResult);
2293
+ await publishWrunCanvasNotices(session.chartIndex, session.indicatorId, runResult, options.isCurrent);
2125
2294
  }
2126
2295
  /** Replace the rows of one owned code set on the overlay's diagnostics (every other row is
2127
2296
  * kept), the shared body of the publishers above and of the canvas cost rows
2128
2297
  * (wrun-canvas-cost-notice.util). */
2129
2298
  export async function publishWrunOwnedDiagnostics(chartIndex, indicatorId, ownedCodes, diagnostics, options = {}) {
2130
2299
  try {
2131
- const mounted = wrunChartHostEnv().chart.instance(chartIndex)?.metadata?.some((candidate) => candidate.id === indicatorId);
2132
- if (!mounted)
2300
+ const tc = wrunChartHostEnv().chart.instance(chartIndex);
2301
+ const meta = tc?.metadata?.find((candidate) => candidate.id === indicatorId);
2302
+ if (!meta)
2133
2303
  return false;
2134
2304
  const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
2305
+ // Judged again after the wait, right before the write: the rows are the mount's they were asked for, never a
2306
+ // same-id remount's (a teardown and a remount meanwhile is another mount, whose own run publishes its rows).
2307
+ if (!isWrunRunMountOnChart(chartIndex, { tc, meta }) || options.isCurrent?.() === false)
2308
+ return false;
2135
2309
  const store = useChartStore();
2136
2310
  const current = store.getIndicatorDiagnostics(indicatorId, chartIndex);
2137
2311
  const published = current.filter((row) => ownedCodes.has(row.code));
@@ -2154,9 +2328,12 @@ export async function publishWrunOwnedDiagnostics(chartIndex, indicatorId, owned
2154
2328
  }
2155
2329
  /** Drop the run-failure rows this seam owns (only those: a trap, the output contract, the
2156
2330
  * no-growth rule, an unlinkable import) once a run of the same overlay succeeds. */
2157
- export async function clearWrunRuntimeTrapDiagnostic(chartIndex, indicatorId) {
2331
+ export async function clearWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, isCurrent) {
2158
2332
  try {
2159
2333
  const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
2334
+ // The caller's ownership, read after the wait: a successor's trap row is its own run's to clear.
2335
+ if (isCurrent?.() === false)
2336
+ return;
2160
2337
  const store = useChartStore();
2161
2338
  const current = store.getIndicatorDiagnostics(indicatorId, chartIndex);
2162
2339
  if (!current.some((row) => WRUN_RUN_FAILURE_ROW_CODES.has(row.code)))
@@ -2264,25 +2441,58 @@ export function wrunSessionRespelledSheet(context, sheet, settings) {
2264
2441
  const pins = wrunSessionRespelledPins.get(context);
2265
2442
  return pins === undefined ? undefined : wrunSheetWithRespelledPins(wrunSheetWithSettings(sheet, settings), pins);
2266
2443
  }
2444
+ /** The pauses before the run head asks a failed dollar read again: a passing failure clears before anyone sees it. */
2445
+ const WRUN_DOLLAR_READ_REASK_PAUSES_MS = [1_000, 2_000];
2446
+ /** The run head's dollar unit, settled once per run: only a read that failed in this run (after `since`) is asked
2447
+ * again, never a rest an earlier run left (the chart's own reruns keep it) nor a lead contract not known yet. */
2448
+ async function settleWrunRunDollarUnit(market, since, isCurrent) {
2449
+ await warmWrunMarketDollarFacts(market);
2450
+ let unit = wrunMarketDollarUnit(market);
2451
+ for (const pause of WRUN_DOLLAR_READ_REASK_PAUSES_MS) {
2452
+ if (unit.kind === 'dollars' || !unit.transient)
2453
+ break;
2454
+ if (wrunMarketDollarReadFailure(market, since) !== 'read-failed')
2455
+ break;
2456
+ await new Promise((resolve) => setTimeout(resolve, pause));
2457
+ if (!isCurrent())
2458
+ break;
2459
+ forgetWrunMarketReadFailures(market);
2460
+ await warmWrunMarketDollarFacts(market);
2461
+ unit = wrunMarketDollarUnit(market);
2462
+ }
2463
+ return unit;
2464
+ }
2465
+ /** The refusal words must tell a read that failed (the person's Retry reads it again) from a lead contract not known
2466
+ * yet and from a fact no read can prove. */
2467
+ function wrunDollarUnitWhy(unit, chartMetadata) {
2468
+ if (!unit.transient) {
2469
+ return unit.reason === 'point-value'
2470
+ ? 'no point value is known for its contracts'
2471
+ : 'it is not quoted in US dollars or a dollar stablecoin';
2472
+ }
2473
+ const failure = wrunMarketDollarReadFailure(chartMetadata);
2474
+ if (failure === 'contract-unknown')
2475
+ return 'its lead contract is not known yet';
2476
+ if (unit.reason === 'point-value') {
2477
+ return failure === 'read-failed'
2478
+ ? "the instrument registry's read of its point value failed"
2479
+ : "the instrument registry's point value for it has not been read yet";
2480
+ }
2481
+ return failure === 'read-failed' ? 'the read of its quote failed' : 'its quote has not been read yet';
2482
+ }
2267
2483
  /**
2268
2484
  * The run head's refusal of a sheet that reads the market's dollar multiplier (kit 0.95.0) on a market whose dollar
2269
2485
  * unit is not proven (wrunMarketDollarUnit), by name and before any fetch: a unit no read can ever prove (no point
2270
2486
  * value for its contracts, a quote that is no dollar) reads as the dollar tape's own refusal does (`feed-missing`,
2271
2487
  * the market has no tape to value), and one a later read can still prove as a source that did not answer
2272
- * (`service-no-answer`, Retry; the reads retry on their own windows), so the module never runs over a 0 it would
2273
- * keep for the session.
2488
+ * (`service-no-answer`, Retry: a person's rerun reads the failed reads again at once), so the module never runs over
2489
+ * a 0 it would keep for the session.
2274
2490
  */
2275
2491
  function wrunDollarMultiplierRefusal(metadata, chartMetadata, unit, tape) {
2276
2492
  const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
2277
2493
  const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
2278
2494
  const param = metadata.params.find((candidate) => candidate.host_fill === WRUN_DOLLAR_MULTIPLIER_FILL)?.name;
2279
- const why = unit.transient
2280
- ? unit.reason === 'point-value'
2281
- ? "the instrument registry's point value for it has not been read yet"
2282
- : 'its quote has not been read yet'
2283
- : unit.reason === 'point-value'
2284
- ? 'no point value is known for its contracts'
2285
- : 'it is not quoted in US dollars or a dollar stablecoin';
2495
+ const why = wrunDollarUnitWhy(unit, chartMetadata);
2286
2496
  // The tape's own feed where the run asks one (Big Trades), else the trades the fact values.
2287
2497
  const params = { feed: tape !== undefined ? 'tape' : 'trades' };
2288
2498
  return attachWrunRefusal(new Error(`WRUN ${metadata.id}: ${WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE}: param '${param ?? 'market_dollar_multiplier'}' ` +
@@ -2381,11 +2591,19 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2381
2591
  // The open-interest lane's units (`currency` on the `oi` inputs, wrun-oi-lane.util): "Coin" asks the lane in the
2382
2592
  // market's native units, USD asks it exactly as before (no extras); two units refuse by name here.
2383
2593
  const oiLane = wrunOiLaneExtras(target.metadata);
2594
+ // Each pinned oi lane's units the same way, one lane per market (U9e): two units on one market refuse here.
2595
+ const pinnedOiLanes = new Map();
2596
+ for (const input of target.metadata.inputs) {
2597
+ const lane = wrunPinnedLaneOfSource(target.metadata.inputSources[input.name]);
2598
+ if (lane !== undefined && wrunPinnedLaneOf(lane)?.cls === 'oi' && !pinnedOiLanes.has(lane)) {
2599
+ pinnedOiLanes.set(lane, wrunOiLaneExtras(target.metadata, lane));
2600
+ }
2601
+ }
2384
2602
  // Asked again before the rows leave: a flip onto a tape since the head must not hand that tape's bars over.
2385
2603
  const candleSource = wrunMainCandleSourceOf(head.chartMetadata);
2386
2604
  const provenance = view.settings;
2387
2605
  if (candleSource && isKScriptDisplayBlockedOnExchange(candleSource.exchange, provenance)) {
2388
- throw new WrunVenueBlockedError(createKScriptVenueBlockedError(candleSource.exchange).message);
2606
+ throw new WrunVenueBlockedError(createKScriptVenueBlockedError(candleSource.exchange).message, candleSource.exchange);
2389
2607
  }
2390
2608
  const loadedRows = wrunChartCandleRows(tc);
2391
2609
  if (loadedRows.length === 0)
@@ -2422,6 +2640,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2422
2640
  // The chart's data generation the run's window was read under: the warm-up ask after the
2423
2641
  // integrate stands down when a switch or a refetch cancelled the chart's fetches meanwhile.
2424
2642
  const planGeneration = getChartDataFetchGeneration(target.chartIndex);
2643
+ // The run's own-fetch signal, taken before the plan's awaits (a lane identity waits for the flag and a tape lookup): a
2644
+ // teardown or the dataset's end meanwhile aborts what this run holds instead of a fresh one minted at the fetch.
2645
+ const laneSignal = wrunLaneFetchSignal(target.indicatorId, {
2646
+ chartIndex: target.chartIndex,
2647
+ generation: planGeneration,
2648
+ isCurrent: head.isCurrent,
2649
+ });
2425
2650
  // Every declared pin is classified against the chart BEFORE any fetch
2426
2651
  // (`planWrunPinnedWires`): an ohlcv pin coarser than the chart, on the
2427
2652
  // chart's own market or on a pinned one, becomes a PERIOD leg fetched at
@@ -2448,26 +2673,33 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2448
2673
  : Promise.resolve(null);
2449
2674
  // A dollar tape (C-DOLLAR) prices its live prints in its history's unit: the dollar unit of the market's own facts
2450
2675
  // (wrunMarketDollarUnit: a CME contract's registry point value, else the point value on a market quoted in dollars).
2451
- // Its reads are the directory row's quote and the instrument registry's units, each waited on once
2452
- // (warmWrunMarketDollarFacts never rejects). A unit no read can ever prove (a quote that is no dollar, a venue or a
2453
- // contract with no point value) refuses the tape by name before any fetch, the daemon's `wrun_tape_value_unproven`:
2454
- // none of its live prints could fold, so it never draws silently stopped. A unit a later read can still prove is
2676
+ // Its reads are the directory row's quote and the instrument registry's units, settled once (a read that failed in
2677
+ // this run asked again twice, settleWrunRunDollarUnit never rejects). A unit no read can ever prove (a quote that
2678
+ // is no dollar, a venue or a contract with no point value) refuses the tape by name before any fetch, the daemon's
2679
+ // `wrun_tape_value_unproven`: none of its live prints could fold, so it never draws silently stopped. A unit a
2680
+ // later read can still prove is
2455
2681
  // never frozen into the acquisition: the payload carries no `valuePerUnit`, and the live intake resolves it again on
2456
- // its prints (wrun-live-intake.util `wrunTapeLiveFloorOf`).
2682
+ // its prints (wrun-live-intake.util `wrunTapeLiveFloorOf`). A coins tape (C-COINS item 2) asks the same dollar table,
2683
+ // its floor priced in the same unit (wrun-tape-coins.util), so it cannot wait: a unit a later read can still prove
2684
+ // refuses it as a source that did not answer (`service-no-answer`, Retry), never a floor priced on a guess.
2685
+ // Settled once for the tape floor and the dollar multiplier alike, or their re-asks would double.
2686
+ let dollarUnit;
2687
+ const settleDollarUnit = async () => (dollarUnit ??= await settleWrunRunDollarUnit(chartMetadata, head.marketReadsSince, head.isCurrent));
2457
2688
  let tapeValuePerUnit;
2458
- if (tape?.minValue !== undefined) {
2459
- await warmWrunMarketDollarFacts(chartMetadata);
2460
- const unit = wrunMarketDollarUnit(chartMetadata);
2689
+ if (tape?.minValue !== undefined || tape?.minCoins !== undefined) {
2690
+ const unit = await settleDollarUnit();
2461
2691
  tapeValuePerUnit = unit.kind === 'dollars' ? unit.unit : undefined;
2462
- if (unit.kind === 'unproven' && !unit.transient) {
2692
+ const coins = tape.minCoins !== undefined;
2693
+ if (unit.kind === 'unproven' && (!unit.transient || coins)) {
2463
2694
  const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
2464
2695
  const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
2465
- const why = unit.reason === 'point-value'
2466
- ? 'no point value is known for its contracts'
2467
- : 'it is not quoted in US dollars or a dollar stablecoin';
2696
+ const why = wrunDollarUnitWhy(unit, chartMetadata);
2468
2697
  // The host's words lead with the code (`<code>: <sentence>`), as every host refusal reads.
2469
2698
  throw attachWrunRefusal(new Error(`WRUN ${target.metadata.id}: ${WRUN_TAPE_VALUE_UNPROVEN_CODE}: input '${tape.inputNames[0]}' (tape) floors ` +
2470
- `${exchange}:${symbol} by dollar value (min_value), and ${why}, so no print can be valued`), { cls: 'feed-missing', variant: 'market-paused', params: { feed: 'tape' }, severity: 'paused' });
2699
+ `${exchange}:${symbol} by ${coins ? 'coins over dollar values (min_coins)' : 'dollar value (min_value)'}, ` +
2700
+ `and ${why}, so no print can be valued`), unit.transient
2701
+ ? { cls: 'service-no-answer', variant: 'lane', params: { feed: 'tape' }, severity: 'paused' }
2702
+ : { cls: 'feed-missing', variant: 'market-paused', params: { feed: 'tape' }, severity: 'paused' });
2471
2703
  }
2472
2704
  }
2473
2705
  // A package that reads the market's dollar multiplier (kit 0.95.0, `market.dollar_multiplier()`: Big Trades 0.8.0
@@ -2476,10 +2708,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2476
2708
  // and the hover. The module takes it once, at init(), so the run never computes over a unit it could not prove (0
2477
2709
  // values no trade): its reads are waited on here, a unit no read can ever prove refuses by name before any fetch,
2478
2710
  // and one a later read can still prove (a failed registry read, a continuous chart's lead not known yet) refuses as
2479
- // a source that did not answer (retried, `service-no-answer`), never frozen into the session this run installs.
2711
+ // a source that did not answer (`service-no-answer`: its Retry reads again), never frozen into the session.
2480
2712
  if (wrunReadsDollarMultiplier(target.metadata)) {
2481
- await warmWrunMarketDollarFacts(chartMetadata);
2482
- const unit = wrunMarketDollarUnit(chartMetadata);
2713
+ const unit = await settleDollarUnit();
2483
2714
  if (unit.kind === 'unproven')
2484
2715
  throw wrunDollarMultiplierRefusal(target.metadata, chartMetadata, unit, tape);
2485
2716
  }
@@ -2578,9 +2809,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2578
2809
  // An exact warm-up session (round A of the warm-up program), judged from the module and the sheet before any
2579
2810
  // context exists (D4): the run starts with a hidden head of W candles before its first landed row (a clamped
2580
2811
  // window's head included), the chart's own candles asked through the main candle request. Any `history_warmup`
2581
- // key reaches the verdict (a torn stamp answers `warmup-invalid` there, never reads as no stamp), and W reads the
2582
- // settings the package computes with (`wrunWarmupSettings`: a run at another interval, and a twin whose Timeframe
2583
- // is at or below the chart's, take their chart arm, as the init args below send them).
2812
+ // key reaches the verdict (a torn stamp answers `warmup-invalid` there, never reads as no stamp; a converging one
2813
+ // reads as no stamp there before anything else while `wrun-converging-prefix` is off, so no head is planned), and W
2814
+ // reads the settings the package computes with (`wrunWarmupSettings`: a run at another interval, and a twin whose
2815
+ // Timeframe is at or below the chart's, take their chart arm, as the init args below send them).
2584
2816
  const warmupVerdict = target.metadata.history_warmup === undefined
2585
2817
  ? null
2586
2818
  : wrunWarmupVerdictOf({
@@ -2648,8 +2880,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2648
2880
  // Not this interval's candles yet: a switch's cached paint and its commit replace the main series
2649
2881
  // in steps, and a run planned between them would ask its warm-up on the new clock over the
2650
2882
  // previous interval's bars (the host refuses the mixed phases, "Could not draw"). Wait for the next
2651
- // chart trigger instead, as for no rows at all (wrunChartRowsOffIntervalGrid).
2652
- const offGrid = wrunChartRowsOffIntervalGrid(chartRows, chartIntervalMs);
2883
+ // chart trigger instead, as for no rows at all (wrunChartRowsOffIntervalGrid). Judged on the chart's own bar grid: a
2884
+ // stock's 3d groups sit at no fixed phase of the interval, and its 8h bars one a session, a day apart.
2885
+ const offGrid = wrunChartRowsOffIntervalGrid(chartRows, chartIntervalMs, liveBucketVenueOf(chartMetadata));
2653
2886
  if (wrunChartHostEnv().diagnostics.debugEnabled()) {
2654
2887
  wrunChartHostEnv().diagnostics.debug('wrun-run-planned', {
2655
2888
  chartIndex: target.chartIndex,
@@ -2671,11 +2904,52 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2671
2904
  // plan, the poll plans and the push eligibility read it), else the chart's. A replay run's
2672
2905
  // `now` is the end its lanes are fetched through: every row's as-of read stays at its own close.
2673
2906
  // The now is the server's: the lanes plan their windows over the gateway's bars.
2907
+ const clockIntervalMs = run ? run.intervalMs : chartIntervalMs;
2908
+ const clockNowMs = replay
2909
+ ? Math.min(serverNowMs(), Math.max(replay.toMs, chartLastTs + chartIntervalMs))
2910
+ : serverNowMs();
2911
+ const { legs: plannedLegs, wires: plannedWires } = planWrunPinnedWires(target.metadata, clockIntervalMs);
2912
+ // The instant a replay run's declared histories count back from: the replay's present, the close of the newest
2913
+ // completed bar the replay shows (the open of the bar its playhead is in). Its lanes still run on to the window's end
2914
+ // (the forward runway, a thousand steps past the playhead), but a history counted back from there, or from today,
2915
+ // left the bars before the playhead with none (a Big Trades tape's seven days in a replay older than a week). Every
2916
+ // lane's ask names it (SOURCE_HISTORY_AS_OF_FIELD, `fetchLane`).
2917
+ const replayPresentMs = replay ? Math.min(clockNowMs, chartLastTs + chartIntervalMs) : undefined;
2918
+ // A live run's declared histories count back from the session's pins (wrun-history-as-of.util): each lane's, set by
2919
+ // the session's first run that asked it, so a later run of the session (a history page, a settings save, a retry)
2920
+ // never asks a lane from a later start; its window still ends at the server's now. The session is the overlay on
2921
+ // this chart, market, chart interval and run interval.
2922
+ const tapeAsOfKey = tape !== undefined ? wrunTapeHistoryAsOfLaneKey(tape) : undefined;
2923
+ const lanePins = replay === undefined
2924
+ ? pinWrunLaneHistoryAsOf(target.indicatorId, wrunHistoryAsOfIdentity({
2925
+ chartIndex: target.chartIndex,
2926
+ marketIdentity,
2927
+ chartIntervalMs,
2928
+ runInterval: run?.interval,
2929
+ }), [...plannedLegs.map((leg) => leg.fetchKey), ...(tapeAsOfKey !== undefined ? [tapeAsOfKey] : [])], clockNowMs)
2930
+ : undefined;
2931
+ // The clock's as-of: a replay's present, or the earliest pin among the legs (the instant the row builder counts each
2932
+ // backlog back from; each leg's fetch reads its own pin, `legClockOf`). The session installs it.
2674
2933
  const clock = {
2675
- intervalMs: run ? run.intervalMs : chartIntervalMs,
2676
- nowMs: replay ? Math.min(serverNowMs(), Math.max(replay.toMs, chartLastTs + chartIntervalMs)) : serverNowMs(),
2934
+ intervalMs: clockIntervalMs,
2935
+ nowMs: clockNowMs,
2936
+ historyAsOfMs: replayPresentMs ??
2937
+ wrunEarliestHistoryAsOf(plannedLegs.map((leg) => lanePins?.get(leg.fetchKey) ?? clockNowMs)) ??
2938
+ clockNowMs,
2939
+ };
2940
+ // A leg's clock for its fetch plan: the run's, its declared depth counted back from the leg's own pin.
2941
+ const legClockOf = (leg) => {
2942
+ const pin = lanePins?.get(leg.fetchKey);
2943
+ return pin === undefined ? clock : { ...clock, historyAsOfMs: pin };
2677
2944
  };
2678
- const { legs: plannedLegs, wires: plannedWires } = planWrunPinnedWires(target.metadata, clock.intervalMs);
2945
+ // The ask's as-of where a declared history is counted back by the lane's control (the tape's K_TRADES seed): a
2946
+ // replay names its present on every lane; a live run names the tape's pin on the tape's ask once it is earlier than
2947
+ // the run's now (a first run names none, so its ask is the payload it always was and joins another overlay's).
2948
+ const historyAsOfAsk = replayPresentMs === undefined ? {} : { [SOURCE_HISTORY_AS_OF_FIELD]: replayPresentMs };
2949
+ const tapePinMs = tapeAsOfKey !== undefined ? lanePins?.get(tapeAsOfKey) : undefined;
2950
+ const tapeAsOfAsk = tapePinMs !== undefined && tapePinMs < clockNowMs ? { [SOURCE_HISTORY_AS_OF_FIELD]: tapePinMs } : {};
2951
+ // The instant the tape's declared history counts back from (its budget below): the replay's present, else its pin.
2952
+ const tapeHistoryAsOfMs = replayPresentMs ?? tapePinMs;
2679
2953
  // The chart's head store for this run's first bar (wrun-warmup-head-store.util): one per chart, so every overlay
2680
2954
  // over the same first bar reads the candles one run fetched. A clamped window takes none (its head lies inside the
2681
2955
  // loaded rows).
@@ -2797,11 +3071,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2797
3071
  // Each group dispatches the moment its own plan resolves (`scheduleWrunLaneGroups` below); a plan's refusal still
2798
3072
  // fails the run by name, judged in the order the plans were read (the local plans, then the chain-reading poll
2799
3073
  // lanes, row lanes and the options chain), and retracts what the run already dispatched.
2800
- // The run's OPRA facts reach every lane's plan (`ctx.official`, `ctx.opraUserScripts`): an OPRA lane is refused
2801
- // by name before its plan for a run that may not read the plane (`mayReadOpra`, opra-official-only:<class>).
3074
+ // The run's plane facts reach every lane's plan (`ctx.official`, `ctx.opraUserScripts`, `ctx.cmeStudyChain`): an OPRA
3075
+ // lane is refused by name before its plan for a run that may not read the plane (`mayReadOpra`,
3076
+ // opra-official-only:<class>), a CME chain instance after it (`mayReadCmeChain`).
2802
3077
  // The OPRA-plane predicate an OPRA lane is admitted by (loaded only when the sheet reads one).
2803
3078
  const opraPlaneFacts = wrunOpraPlaneFacts(target.metadata, head.options);
2804
- const opraFacts = { official: head.official, opraUserScripts: head.opraUserScripts };
3079
+ const planeFacts = planeReadFactsOf(head);
2805
3080
  // Every chain lane plans under the head's one decision: its plane, and a stock twin's lane market (`head.options`).
2806
3081
  const runOptions = head.options;
2807
3082
  // The overlay's current setting values, read once for both planners: an option knob naming a setting
@@ -2820,7 +3095,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2820
3095
  category: chartMetadata?.category,
2821
3096
  intervalMs: clock.intervalMs,
2822
3097
  }, checkIsIndexMode, isWrunCryptoVenueExchange, {
2823
- ...opraFacts,
3098
+ ...planeFacts,
2824
3099
  ...(opraPlane !== undefined ? opraPlane : {}),
2825
3100
  paramValues: laneParamValues,
2826
3101
  ...(runOptions !== undefined ? { options: runOptions } : {}),
@@ -2849,8 +3124,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2849
3124
  isCryptoVenueExchange: isWrunCryptoVenueExchange,
2850
3125
  isOpraPlaneExchange: opraPlane?.isOpraPlaneExchange,
2851
3126
  opraPlaneStop: opraPlane?.opraPlaneStop,
3127
+ // The chart whole: a `stocks` lane's identity asks the chart port for its tape market and feed.
3128
+ ...(chartMetadata !== undefined ? { chartMetadata: chartMetadata } : {}),
2852
3129
  }, {
2853
- ...opraFacts,
3130
+ ...planeFacts,
2854
3131
  paramValues: laneParamValues,
2855
3132
  ...(runOptions !== undefined ? { options: runOptions } : {}),
2856
3133
  }));
@@ -2866,7 +3143,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2866
3143
  // The options_chain lane's identity (wrunOptionsChainLaneExtrasFor), decided before its own fetch like every plan:
2867
3144
  // a refusal by name fails the run, never reads as a degraded lane.
2868
3145
  const optionsChainPlanned = declaredClasses.has('options_chain')
2869
- ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts, laneParamValues, head.options, head.cmeUserStudy === true)
3146
+ ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, planeFacts, laneParamValues, head.options)
2870
3147
  : Promise.resolve(undefined);
2871
3148
  // The OPRA provenance the native options overlays carry (`settings.metaExchange`, the field the chart read
2872
3149
  // withholds an overlay by and the tier moves refetch it by, options-overlay-provenance.util): every OPRA lane
@@ -2901,10 +3178,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2901
3178
  // Every source-lane instance a degrade names (a poll lane's or a row lane's): the chips, the holds, the records.
2902
3179
  // Filled as the plans resolve, in the plans' order once both did.
2903
3180
  const laneInstances = [];
2904
- // The pinned legs by venue (wrun-pin-venues.util), before any fetch: a pin
2905
- // on a CME Group venue refuses by name with the sheet contract's own words
2906
- // (the chart's own market may still be one, the display wall decides that
2907
- // above), and so does a venue word the chart's lanes cannot ask (AMEX, SP,
3181
+ // The pinned legs by venue (wrun-pin-venues.util), before any fetch, under
3182
+ // the run's CME pin facts (`pinFacts` below): a pin on a CME Group venue is
3183
+ // served on any chart to a run the data wall lets read CME and refuses by
3184
+ // name with the sheet contract's own words for any other (the chart's own
3185
+ // market is the display wall's above), and so does a venue word the
3186
+ // chart's lanes cannot ask (AMEX, SP,
2908
3187
  // a stock listing: wrun_pin_venue_unknown, a failed run, whether the sheet,
2909
3188
  // a default or a saved pick names it); a pin on an index venue the
2910
3189
  // gateway serves no series for to
@@ -2925,25 +3204,51 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2925
3204
  // A leg a symbol setting pins (`symbol_param`) offers the settings as the way out of a venue
2926
3205
  // the chart's lanes cannot ask.
2927
3206
  const settingBoundAt = (index) => typeof target.metadata.inputSources[inputNameAt(index)]?.symbol_param === 'string';
2928
- assertWrunPinnedLegVenues(plannedLegs, inputNameAt, chartExchange, settingBoundAt);
3207
+ // The run's CME pin facts, read once for every leg and trades leg, from the live gate at the judge (a gate that opened
3208
+ // since the head serves the pin): open where the data wall lets the run read CME (`isCmeReadableKScriptRun`, which
3209
+ // reads `mayReadCmePin`, on any chart), else the words the closed gate's refusal takes (`cmePinRefusalVariant`).
3210
+ const cmeUserScriptsAtJudge = isCmeUserScriptRun(provenance);
3211
+ const pinFacts = {
3212
+ cmeOpen: isCmeReadableKScriptRun(provenance),
3213
+ cmeClosed: cmePinRefusalVariant(provenance),
3214
+ };
3215
+ // A pin the closed gate refused: a study the lifecycle stopped reads its stop's words (a plain Error, never the
3216
+ // wall's: no painter swallows it off a CME chart), and a browser run arms the late re-judgment, so access that
3217
+ // returns runs it again (the run head's flag-wait shape, through the market port).
3218
+ const refusePinnedLeg = async (error) => {
3219
+ if (pinFacts.cmeOpen || wrunRefusalSeedOf(error)?.cls !== 'pin-refused')
3220
+ return error;
3221
+ if (isCmeUserScriptCandidate(provenance)) {
3222
+ const gate = await wrunChartHostEnv()
3223
+ .market.loadOptionsGate()
3224
+ .catch(() => undefined);
3225
+ gate?.armCmeUserScriptsRejudge?.();
3226
+ }
3227
+ const stop = cmeStudyStopReason(target.chartIndex, target.indicatorId);
3228
+ return stop === undefined
3229
+ ? error
3230
+ : attachWrunRefusal(new Error(error.message), { cls: 'cme-wall', variant: WRUN_CME_STOP_VARIANT[stop] });
3231
+ };
3232
+ try {
3233
+ assertWrunPinnedLegVenues(plannedLegs, inputNameAt, chartExchange, settingBoundAt, pinFacts);
3234
+ }
3235
+ catch (error) {
3236
+ throw error instanceof Error ? await refusePinnedLeg(error) : error;
3237
+ }
2929
3238
  const { served: servedLegs, unserved: unservedLegs } = partitionWrunLegsByVenue(plannedLegs, plannedWires, inputNameAt);
2930
- // A leg whose rows straddle the chart's bars (`sourceRowsStraddleHostBars`: a 24/7 market's :00 hours under a
2931
- // stock's 09:30-anchored bars, a crypto market's 4h bars on a CME chart's session lattice, or the reverse) is
2932
- // placed on the chart's bars by the row builder alone (`wrunLegRowsOnHostBars`). So its asks ride dataFetch's
2933
- // native-rows path: the fetch never places its rows first (its straddle path does for a plain ask, on a
3239
+ // A leg whose rows straddle the chart's bars (wrun-trades-lane.util `wrunLegStraddlesChartBars`: a 24/7 market's :00
3240
+ // hours under a stock's 09:30-anchored bars, a crypto market's 4h bars on a CME chart's session lattice, or the
3241
+ // reverse) is placed on the chart's bars by the row builder alone (`wrunLegRowsOnHostBars`). So its asks ride
3242
+ // dataFetch's native-rows path: the fetch never places its rows first (its straddle path does for a plain ask, on a
2934
3243
  // timestamp-mode chart too), and its history, its reconciles and its live folds all carry the leg's own stamps,
2935
3244
  // each row landed once. The chart's first bar is owed the row opening up to one leg span before it, so the window
2936
- // opens that span early. A leg on the chart's own grid, or on a finer one dividing it, keeps its plain ask (a 24/7
2937
- // leg on a 24/7 chart, a CME leg on a CME chart), and a leg coarser than the chart is never placed.
2938
- const legVenueOf = (market) => liveBucketVenueOf({
2939
- exchange: market?.exchange ?? chartExchange,
2940
- symbol: market?.symbol ?? chartMetadata?.symbol,
2941
- sessionType: chartSessionType,
2942
- });
2943
- const legStraddlesChartBars = (legMs, market) => legMs > 0 &&
2944
- legMs <= clock.intervalMs &&
2945
- !isCalendarIntervalMs(legMs) &&
2946
- sourceRowsStraddleHostBars(clock.intervalMs, liveBucketVenueOf(chartMetadata), legMs, legVenueOf(market));
3245
+ // opens that span early (`wrunLegPlacementLeadMs`). A leg on the chart's own grid, or on a finer one dividing it,
3246
+ // keeps its plain ask (a 24/7 leg on a 24/7 chart, a CME leg on a CME chart), and a leg coarser than the chart is
3247
+ // never placed. The rules are shared with the trades legs' planner (`planWrunTradeLegAsk`, which a pan-back page
3248
+ // asks its legs through too), all planned against the run clock and the chart (`legAskChart`).
3249
+ const legAskChart = { intervalMs: clock.intervalMs, venue: chartMetadata };
3250
+ const legVenueOf = (market) => wrunLegVenueOf(legAskChart, market);
3251
+ const legStraddlesChartBars = (legMs, market) => wrunLegStraddlesChartBars(legAskChart, legMs, market);
2947
3252
  // A grid leg whose own bars at the chart's interval do not nest in the chart's bars is asked at the tier that fits
2948
3253
  // both grids (`indexHostFetchTierMs`, the comparison overlays' rule on an index-mode chart: 30m under a stock's
2949
3254
  // 09:30-anchored 45m to 12h bars), where its 12h bars, ending at 12:00 and 24:00 UTC, would fall outside every
@@ -2957,7 +3262,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2957
3262
  const tierMs = indexHostFetchTierMs(clock.intervalMs, liveBucketVenueOf(chartMetadata), [legVenueOf(leg.market)]);
2958
3263
  return tierMs > 0 && tierMs < leg.legMs ? tierMs : undefined;
2959
3264
  };
2960
- const legPlacementLeadMs = (legMs, market) => legStraddlesChartBars(legMs, market) ? legMs : 0;
3265
+ const legPlacementLeadMs = (legMs, market) => wrunLegPlacementLeadMs(legAskChart, legMs, market);
2961
3266
  // Each leg records how its ask rides (`WrunPinnedLeg.nativeRows`: an index-mode market or chart, a straddling
2962
3267
  // grid): the full run asks it so, and the live session's reconcile reads the installed record.
2963
3268
  const legs = servedLegs.map((leg) => {
@@ -2971,10 +3276,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2971
3276
  });
2972
3277
  // The trades leg lanes (kit 0.77.0, wrun-trades-lane.util): one per (quote, market) a trades
2973
3278
  // input pinned to another market reads (a literal pin, or a coin leg resolved at the market seam).
2974
- // Each leg's market is judged like any pin's, before any fetch: a CME Group venue, a pin that is
2975
- // no literal market or a venue word the lanes cannot ask refuses by name; a venue the gateway
2976
- // serves no series for to scripts yet is never asked (its inputs read their fill, the unserved-leg
2977
- // note names them).
3279
+ // Each leg's market is judged like any pin's, before any fetch and under the same `pinFacts`: a
3280
+ // CME Group venue the run may not read, a pin that is no literal market or a venue word the lanes
3281
+ // cannot ask refuses by name; a venue the gateway serves no series for to scripts yet is never
3282
+ // asked (its inputs read their fill, the unserved-leg note names them).
2978
3283
  const tradeLegLanes = [...wrunDeclaredSourceLanes(target.metadata)].filter(isWrunTradesLegLane);
2979
3284
  const softRefusedTradeLegs = new Set();
2980
3285
  for (const lane of tradeLegLanes) {
@@ -2984,9 +3289,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2984
3289
  const readers = target.metadata.inputs
2985
3290
  .filter((input) => wrunSourceLane(target.metadata.inputSources[input.name]) === lane)
2986
3291
  .sort((a, b) => a.index - b.index);
2987
- const refusal = wrunPinnedLegRefusalOf({ market: { exchange: leg.exchange, symbol: leg.symbol }, intervalKey: '', legMs: 0 }, readers[0]?.name ?? lane, chartExchange, readers.some((input) => settingBoundAt(input.index)));
3292
+ const refusal = wrunPinnedLegRefusalOf({ market: { exchange: leg.exchange, symbol: leg.symbol }, intervalKey: '', legMs: 0 }, readers[0]?.name ?? lane, chartExchange, readers.some((input) => settingBoundAt(input.index)), pinFacts);
2988
3293
  if (refusal !== null)
2989
- throw attachWrunRefusal(new Error(refusal.message), refusal.seed);
3294
+ throw await refusePinnedLeg(attachWrunRefusal(new Error(refusal.message), refusal.seed));
2990
3295
  if (wrunPinVenueVerdict(leg.exchange) !== 'unserved')
2991
3296
  continue;
2992
3297
  softRefusedTradeLegs.add(lane);
@@ -2999,6 +3304,35 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2999
3304
  reason: 'venue-unserved',
3000
3305
  });
3001
3306
  }
3307
+ // The pinned lanes (U9e, wrun-pinned-lanes.util): one per (class, market) a book, oi, funding or liquidations input
3308
+ // pinned to another market reads. Each lane's market is judged like a trades leg's above, before any fetch: a CME
3309
+ // Group venue, a pin that is no literal market or a venue word the lanes cannot ask refuses by name; a venue the
3310
+ // gateway serves no series for to scripts yet is never asked (its inputs read their fill, the unserved-leg note names
3311
+ // them). A CME Group market pinned by a typed lane keeps the venue-name refusal (this judge call carries no plane
3312
+ // facts on purpose, named in tests/hygiene/wrun-pin-judge-facts.spec.ts): the typed-lane fetch path is proven for
3313
+ // ohlcv and trades legs only.
3314
+ const pinnedLaneIds = [...wrunDeclaredSourceLanes(target.metadata)].filter(isWrunPinnedLaneId);
3315
+ const softRefusedPinnedLanes = new Set();
3316
+ for (const lane of pinnedLaneIds) {
3317
+ const pinned = wrunPinnedLaneOf(lane);
3318
+ const readers = target.metadata.inputs
3319
+ .filter((input) => wrunSourceLane(target.metadata.inputSources[input.name]) === lane)
3320
+ .sort((a, b) => a.index - b.index);
3321
+ const refusal = wrunPinnedLegRefusalOf({ market: { exchange: pinned.exchange, symbol: pinned.symbol }, intervalKey: '', legMs: 0 }, readers[0]?.name ?? lane, chartExchange, readers.some((input) => settingBoundAt(input.index)));
3322
+ if (refusal !== null)
3323
+ throw attachWrunRefusal(new Error(refusal.message), refusal.seed);
3324
+ if (wrunPinVenueVerdict(pinned.exchange) !== 'unserved')
3325
+ continue;
3326
+ softRefusedPinnedLanes.add(lane);
3327
+ unservedLegs.push({
3328
+ inputNames: readers.map((input) => input.name),
3329
+ intervalKey: chartInterval || wrunChartIntervalKeyOf(clock.intervalMs),
3330
+ exchange: pinned.exchange,
3331
+ symbol: pinned.symbol,
3332
+ market: `${pinned.exchange}/${pinned.symbol}`,
3333
+ reason: 'venue-unserved',
3334
+ });
3335
+ }
3002
3336
  // The chart's forming bar on the server clock (`wrunFormingBarTsOf`), read when the run lands a leg on the chart's
3003
3337
  // bars (a grid leg, a trades leg) and opens a live session at the chart's newest bar: a leg's row still forming
3004
3338
  // past that bar lands in it. A replay, a clamped window and a run with no live session have none: their last bar
@@ -3007,13 +3341,26 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3007
3341
  // pin one, and the dataFetch door admits it) reads OPRA data like the chart's own market would: the run's console
3008
3342
  // provenance from here (`computed.opra`), before anything computes. A soft-refused trades leg is never asked.
3009
3343
  if (legs.some((leg) => wrunPinReadsOpra(leg.market)) ||
3010
- tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsOpra(wrunTradesLegOf(lane)))) {
3344
+ tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsOpra(wrunTradesLegOf(lane))) ||
3345
+ pinnedLaneIds.some((lane) => !softRefusedPinnedLanes.has(lane) && wrunPinReadsOpra(wrunPinnedLaneOf(lane)))) {
3011
3346
  computed.opra = true;
3012
3347
  }
3013
- // The same for a leg on the CME plane (`computed.cme`): a leg the run admitted reads CME data.
3348
+ // The same for a leg on the CME plane (`computed.cme`): a leg the run admitted reads CME data, on any chart.
3014
3349
  if (legs.some((leg) => wrunPinReadsCme(leg.market)) ||
3015
- tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsCme(wrunTradesLegOf(lane)))) {
3350
+ tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsCme(wrunTradesLegOf(lane))) ||
3351
+ pinnedLaneIds.some((lane) => !softRefusedPinnedLanes.has(lane) && wrunPinReadsCme(wrunPinnedLaneOf(lane)))) {
3016
3352
  computed.cme = true;
3353
+ // A browser run the gate opened the plane to computes its admitted CME legs under the authorisation the judge read,
3354
+ // in the same task: the resolved legs are the one sure reading (a pin the step respelled onto CME included).
3355
+ if (cmeUserScriptsAtJudge && computed.cmeAuth === undefined)
3356
+ computed.cmeAuth = captureCmeStudyAuth();
3357
+ // The delayed ones off the chart's own exchange (its badge names none of them): the legend's delay note.
3358
+ const delayed = wrunCmeDelayedMarkets([
3359
+ ...legs.map((leg) => leg.market),
3360
+ ...tradeLegLanes.filter((lane) => !softRefusedTradeLegs.has(lane)).map(wrunTradesLegOf),
3361
+ ], chartExchange);
3362
+ if (delayed !== undefined)
3363
+ computed.cmeDelayed = delayed;
3017
3364
  }
3018
3365
  const formingBarTs = live && replay === undefined && wrunLandsLegsOnBars(legs, tradeLegLanes)
3019
3366
  ? await wrunFormingBarTsOf(target.chartIndex, clock.intervalMs, chartMetadata)
@@ -3060,7 +3407,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3060
3407
  indexMode: checkIsIndexMode(chartExchange ?? ''),
3061
3408
  },
3062
3409
  paramValues: laneParamValues,
3063
- facts: { official: head.official, opraUserScripts: head.opraUserScripts },
3410
+ facts: planeReadFactsOf(head),
3064
3411
  ...(head.options !== undefined ? { options: head.options } : {}),
3065
3412
  });
3066
3413
  })().then((plan) => {
@@ -3152,8 +3499,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3152
3499
  severity: 'paused',
3153
3500
  });
3154
3501
  }
3155
- // Every lane the rule judges is one of the row builder's own, or a trades leg lane on the
3156
- // market it judged (its readers' leg lanes).
3502
+ // Every lane the rule judges is one of the row builder's own, or a trades leg lane or a pinned
3503
+ // lane on the market it judged (its readers' own lanes).
3157
3504
  if (market === undefined)
3158
3505
  unservedLanes.push(lane);
3159
3506
  else {
@@ -3236,11 +3583,26 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3236
3583
  if (source === null)
3237
3584
  return {};
3238
3585
  // A flip onto a tape the run may not read since the rows handoff walls the ask, as the handoff itself does.
3239
- if (walled)
3240
- throw new WrunVenueBlockedError(createKScriptVenueBlockedError(source.exchange).message);
3586
+ if (walled) {
3587
+ throw new WrunVenueBlockedError(createKScriptVenueBlockedError(source.exchange).message, source.exchange);
3588
+ }
3241
3589
  // The series ref alone (the main stream's rule): the session, the index mode and the bar grid stay the chart's.
3242
3590
  return { candleSource: source };
3243
3591
  };
3592
+ // A lane's acquisition: the payload its ask carries, kept on the run (the legend's delay words, the reconcile, the live
3593
+ // session and the add memo's fingerprint read it). Recorded by the read, whether or not an ask leaves: a row lane the
3594
+ // add memo serves whole asks nothing (a theme's rerun of a stock chart's Dark pool prints), and its run must still name
3595
+ // the tape it read (wrun-draft-legend-note.util `wrunStocksLanesServedTierNote`).
3596
+ const recordLaneAcquisition = (type, key, payloadExtras) => {
3597
+ const askExtras = { ...askMarketOf(type, payloadExtras), ...payloadExtras };
3598
+ // Every lane's ask names the instant its declared history counts back from when the run's is not the server's now
3599
+ // (`historyAsOfAsk`: a replay's present), so no lane counts a history back from today in a replay.
3600
+ const payload = { symbol: 'currentSymbol', exchange: 'currentExchange', ...askExtras, ...historyAsOfAsk };
3601
+ const lane = wrunLiveLaneOfFetchKey(key);
3602
+ if (lane !== undefined)
3603
+ acquisitionByLane[lane] = payload;
3604
+ return { lane, payload };
3605
+ };
3244
3606
  const fetchLane = async (type, key, fetchOptions,
3245
3607
  // Lane-specific payload fields beyond the current-market placeholders
3246
3608
  // (the Deribit option-summary lanes key by coin, skew also by delta),
@@ -3257,16 +3619,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3257
3619
  const meter = fetchOptions?.meter ?? download;
3258
3620
  // The market every ask naming no pin of its own reads (its acquisition keeps it, so the reconcile and live agree).
3259
3621
  const askExtras = { ...askMarketOf(type, payloadExtras), ...payloadExtras };
3260
- const payload = { symbol: 'currentSymbol', exchange: 'currentExchange', ...askExtras };
3261
- const lane = wrunLiveLaneOfFetchKey(key);
3262
- if (lane !== undefined)
3263
- acquisitionByLane[lane] = payload;
3622
+ const { lane, payload } = recordLaneAcquisition(type, key, payloadExtras);
3264
3623
  const held = fromTs === from && toTs === to ? takeHeldLane(lane, payload) : undefined;
3265
3624
  if (held !== undefined)
3266
3625
  return held;
3267
3626
  // The chart's own series at the chart's interval, over bars the chart holds, answers from the chart's rows with no
3268
3627
  // ask (run-schedule/wrun-own-candles.util).
3269
- const own = fetchOptions?.ownFetch === undefined
3628
+ const own = fetchOptions?.ownFetch === undefined && fetchOptions?.marketRows !== true
3270
3629
  ? serveWrunOwnCandles({
3271
3630
  type,
3272
3631
  payloadExtras: askExtras,
@@ -3329,11 +3688,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3329
3688
  meter.charge({ key: `${target.fetchKey}-${key}`, kType: type, ...wrunDownloadAnswerSize(fetched) });
3330
3689
  }
3331
3690
  // Packed-lane SUCCESS arrives as the packed transport object (only the
3332
- // kScript engine worker consumes it un-unpacked); unpack it here, or a
3691
+ // kScript engine worker consumes it un-unpacked); read it here, or a
3333
3692
  // real success misclassifies as a decline and re-fetches on the plain
3334
- // legacy lane.
3693
+ // legacy lane. The book keeps the worker's block (its rows are views of
3694
+ // it, WRUN-PANBACK-2 S2); every other lane unpacks.
3335
3695
  if (isPackedOhlcvRows(fetched))
3336
- return unpackOhlcvRows(fetched);
3696
+ return wrunPackedLaneRows(type, fetched, target);
3337
3697
  if (Array.isArray(fetched))
3338
3698
  return fetched;
3339
3699
  // A declined packed ask (dataFetch returns null when the packed worker is
@@ -3384,6 +3744,36 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3384
3744
  acquisitionByLane.book = { ...acquisitionByLane.book, preferPackedOrderbookWorker: false };
3385
3745
  return plain;
3386
3746
  };
3747
+ // A pinned lane (U9e, wrun-pinned-lanes.util): its class's K source asked on its market under the lane id as its
3748
+ // fetch key (its own cache entry and its own live lane: fetchLane keeps the payload, the market among it, as the
3749
+ // lane's acquisition, so the reconcile and the live channel ask that market again), in the units its inputs declare
3750
+ // (an oi lane's currency, one lane per market, `pinnedOiLanes`). A book rides the packed orderbook worker first and
3751
+ // the plain lane on a decline, as the chart's own book does, its transport on its acquisition; a funding lane an
3752
+ // input reads under carry degrades on an empty answer, as the chart's own does. Never the chart's own lane's rows.
3753
+ const fetchPinnedLaneRows = async (lane) => {
3754
+ const pinned = wrunPinnedLaneOf(lane);
3755
+ const { type, label } = WRUN_PINNED_LANE_SPECS[pinned.cls];
3756
+ const market = wrunPinnedLaneExtras(lane);
3757
+ if (pinned.cls === 'book') {
3758
+ const packed = await fetchLane(type, lane, { preferPackedOrderbookWorker: true }, market);
3759
+ if (heldCoverage[lane] !== undefined)
3760
+ return packed ?? [];
3761
+ if (packed !== null) {
3762
+ acquisitionByLane[lane] = { ...acquisitionByLane[lane], preferPackedOrderbookWorker: true };
3763
+ return packed;
3764
+ }
3765
+ const plain = (await fetchLane(type, lane, undefined, market)) ?? [];
3766
+ acquisitionByLane[lane] = { ...acquisitionByLane[lane], preferPackedOrderbookWorker: false };
3767
+ return plain;
3768
+ }
3769
+ if (pinned.cls === 'oi') {
3770
+ return (await fetchLane(type, lane, undefined, { ...market, ...pinnedOiLanes.get(lane) })) ?? [];
3771
+ }
3772
+ if (pinned.cls === 'funding' && wrunFundingLaneRequired(target.metadata, lane)) {
3773
+ return fetchDegradableLane(type, lane, `${label} on ${pinned.exchange} ${pinned.symbol}`, market);
3774
+ }
3775
+ return (await fetchLane(type, lane, undefined, market)) ?? [];
3776
+ };
3387
3777
  // The volume-profile, trade-volume-by-size, liquidations, funding,
3388
3778
  // implied-volatility, and skew lanes mirror the ENGINE's acquisition for TECHNICAL_SCRIPT sources
3389
3779
  // (fetchSourceDataPayload in script-engine-worker-manager): the engine's
@@ -3680,7 +4070,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3680
4070
  : fetchQuietLeg(leg, readers, key, label, marketExtras, native, windowFrom, to);
3681
4071
  }
3682
4072
  const reads = wrunLegFetchReads(target.metadata, leg, plannedWires);
3683
- const plan = planWrunLegFetch({ leg, reads, clock, headMs: from });
4073
+ // The leg's declared depth counts back from its own pin (`legClockOf`), its window still ends at the run's now.
4074
+ const plan = planWrunLegFetch({ leg, reads, clock: legClockOf(leg), headMs: from });
3684
4075
  clampedLegs.push(...plan.clamped);
3685
4076
  const windowFrom = plan.fromTs;
3686
4077
  // A live-candle reading asks through now whatever the chart's last row: on a chart whose
@@ -3791,7 +4182,14 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3791
4182
  ? await fetchWrunPollLaneHostGridRows(lane, extras, hostGridWindow(), { fromTs: from, toTs: to }, async (askExtras, fromTs, toTs) => (await fetchLane(lane.kType, instance.key, wrunPollLaneFetchOptions(lane), { ...askExtras }, fromTs, toTs)) ?? [])
3792
4183
  : ((await fetchLane(lane.kType, instance.key, laneFetch
3793
4184
  ? {
3794
- ownFetch: (fromTs, toTs) => laneFetch({ extras: instance.extras, fromTs, toTs, intervalMs: clock.intervalMs }),
4185
+ ownFetch: (fromTs, toTs) => laneFetch({
4186
+ extras: instance.extras,
4187
+ fromTs,
4188
+ toTs,
4189
+ intervalMs: clock.intervalMs,
4190
+ nowMs: clock.nowMs,
4191
+ signal: laneSignal,
4192
+ }),
3795
4193
  }
3796
4194
  : wrunPollLaneFetchOptions(lane), extras, wrunPollLaneFetchFrom(lane, from), wrunPollLaneFetchTo(lane, to, clock.intervalMs, clock.nowMs))) ?? []);
3797
4195
  if (!wrunPollLaneRequired(target.metadata, instance))
@@ -3873,6 +4271,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3873
4271
  const extras = lane.governed === 'opra'
3874
4272
  ? { ...instance.extras, ...wrunOpraLanePayloadFields(governedMarketDataTier('OPRA')) }
3875
4273
  : wrunRowLaneChainAsk(lane, instance.extras, governedMarketDataTier);
4274
+ // The instance's acquisition stands before the read: the add memo can serve every bar whole, and then no ask leaves.
4275
+ recordLaneAcquisition(lane.kType, instance.key, extras);
3876
4276
  const laneFetch = lane.fetch;
3877
4277
  const tradeDateOf = chartTradeDateOf();
3878
4278
  // A budgeted run's hold on the read (R2): its share, its slice's declared rows, its fold cap and its own meter.
@@ -3905,6 +4305,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3905
4305
  fromTs: askFrom,
3906
4306
  toTs: askTo,
3907
4307
  intervalMs: clock.intervalMs,
4308
+ nowMs: clock.nowMs,
4309
+ hostBars: wrunHostBarSpansWithin(hostGridWindow(), askFrom, askTo),
4310
+ signal: laneSignal,
3908
4311
  }));
3909
4312
  own.answered = true;
3910
4313
  return answered;
@@ -4015,52 +4418,33 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4015
4418
  const { key, extras } = WRUN_TRADES_LANES[lane];
4016
4419
  return async () => (await fetchLane('buy_sell_volume', key, undefined, extras ? { ...extras } : undefined)) ?? [];
4017
4420
  };
4018
- // A trades leg rides the grid-leg model: its rows stay on its own market's grid and the row builder sums them
4019
- // into the chart bars holding them (wrun-source-rows `tradeLegRowsOf`). On an index-mode chart or market, and
4020
- // wherever its rows straddle the chart's bars (`legStraddlesChartBars`), its ask takes dataFetch's native-rows path
4021
- // (its rows at their own stamps, never placed on the chart's bars by the fetch) at the tier that fits every chart
4022
- // bar and every leg bar (`indexHostFetchTierMs`: 30m under a stock's :30 hours, so each bar sums whole tier rows;
4023
- // the chart's interval on a timestamp-mode chart), the chart's bars asked whole (through the last bar's close,
4024
- // from one tier row early where the rows straddle) in pieces of wire rows (`wrunWireRowPieces`). The tier and the
4025
- // path ride its acquisition, which the intake folds the live prints at and the reconcile asks again. Elsewhere (a
4026
- // 24/7 leg on a 24/7 chart) the ask is the chart's own, as before.
4027
- const tradeLegAskOf = (lane) => {
4028
- const leg = wrunTradesLegOf(lane);
4029
- if (leg === undefined)
4030
- return undefined;
4031
- const tierMs = indexHostFetchTierMs(clock.intervalMs, liveBucketVenueOf(chartMetadata), [
4032
- liveBucketVenueOf({ exchange: leg.exchange, symbol: leg.symbol, sessionType: chartMetadata?.sessionType }),
4033
- ]);
4034
- const native = wrunLegRidesNativeRows({ market: { exchange: leg.exchange } }, chartExchange) ||
4035
- legStraddlesChartBars(tierMs, leg);
4036
- if (!native)
4037
- return undefined;
4038
- const options = { interval: wrunChartIntervalKeyOf(tierMs), nativeRows: true };
4039
- return {
4040
- tierMs,
4041
- options,
4042
- extras: { ...wrunTradesLegExtras(lane), ...options },
4043
- fromMs: from - legPlacementLeadMs(tierMs, leg),
4044
- toMs: barEndMs(to, clock.intervalMs),
4045
- };
4046
- };
4421
+ // A trades leg's ask over the run's window (wrun-trades-lane.util `planWrunTradeLegAsk`, the planner a pan-back page
4422
+ // asks its legs through too): a 24/7 leg on a 24/7 chart rides the chart's own ask; on an index-mode chart or
4423
+ // market, and wherever its rows straddle the chart's bars, it is asked at the tier that fits every chart bar and
4424
+ // every leg bar on dataFetch's native-rows path, the chart's bars asked whole (through the last bar's close, from one
4425
+ // tier row early where the rows straddle) in pieces of wire rows (`wrunWireRowPieces`). The tier and the path ride
4426
+ // its acquisition, which the intake folds the live prints at and the reconcile asks again.
4427
+ const tradeLegAskOf = (lane) => planWrunTradeLegAsk(lane, legAskChart, { fromMs: from, toMs: to });
4047
4428
  // A trades leg asked in pieces is one family with one commit (`wrunAskWirePieces`): a piece the chart's fetch did
4048
4429
  // not answer whole (its verdict, `wrunSourceVerdictWhole`) commits nothing, and the lane degrades as declined (the
4049
4430
  // source ladder asks it again); the lane's budget running out (`abandoned`) asks no further piece.
4050
4431
  const fetchTradeLegRows = async (lane, abandoned) => {
4051
4432
  const ask = tradeLegAskOf(lane);
4052
- if (ask === undefined) {
4053
- return (await fetchLane('buy_sell_volume', lane, undefined, wrunTradesLegExtras(lane))) ?? [];
4054
- }
4433
+ // Every lane here passed `isWrunTradesLegLane`, so it names a market; one that does not fails its own lane.
4434
+ if (ask === undefined)
4435
+ throw new Error(`the trades leg lane '${lane}' names no market`);
4436
+ if (ask.tier === null)
4437
+ return (await fetchLane(ask.type, lane, undefined, ask.extras, ask.fromMs, ask.toMs)) ?? [];
4438
+ const tier = ask.tier;
4055
4439
  const held = takeHeldLane(wrunLiveLaneOfFetchKey(lane), {
4056
4440
  symbol: 'currentSymbol',
4057
4441
  exchange: 'currentExchange',
4058
- ...ask.extras,
4442
+ ...tier.extras,
4059
4443
  });
4060
4444
  if (held !== undefined)
4061
4445
  return held;
4062
4446
  try {
4063
- return await fetchTierPieces('buy_sell_volume', lane, ask.tierMs, ask.extras, ask.fromMs, ask.toMs, abandoned);
4447
+ return await fetchTierPieces(ask.type, lane, tier.tierMs, tier.extras, ask.fromMs, ask.toMs, abandoned);
4064
4448
  }
4065
4449
  catch (error) {
4066
4450
  if (error instanceof WrunWirePiecesIncomplete) {
@@ -4070,8 +4454,80 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4070
4454
  throw error;
4071
4455
  }
4072
4456
  };
4457
+ // A coins tape (C-COINS item 2) asks the dollar table at its coins x the lowest price its request's window traded at
4458
+ // x 0.9 (wrun-tape-coins.util), priced here before any lane dispatches: off the chart's own candles (with the warm-up
4459
+ // head in hand, never one still to fetch) where they are the tape market's prices and hold the window whole, else off
4460
+ // that market's day candles over it, asked through this run's one lane door (`fetchLane`) and folded with the chart's
4461
+ // own bars inside the window. No candle pricing the window refuses the run by name, never a floor on a guess.
4462
+ const priceWrunCoinTape = async (coins) => {
4463
+ const span = wrunCoinTapeWindow({
4464
+ fromMs: from,
4465
+ toMs: to,
4466
+ asOfMs: tapeHistoryAsOfMs ?? clock.nowMs,
4467
+ historySeconds: coins.historySeconds,
4468
+ barMs: clock.intervalMs,
4469
+ });
4470
+ // The tape reads the run market where the sheet reads one (a Trades chart's tape), else the chart's own market.
4471
+ const tapeMarket = runMarket ?? undefined;
4472
+ const transformations = typeof chartMetadata?.transformations === 'string' ? chartMetadata.transformations : '';
4473
+ const formula = normalizeTransformations(transformations);
4474
+ const ownCandles = (tapeMarket === undefined || (tapeMarket.exchange === chartExchange && tapeMarket.symbol === chartSymbol)) &&
4475
+ wrunMainCandleSourceOf(chartMetadata) === null &&
4476
+ (formula === '' || formula === normalizeTransformations(selfTransformationToken(chartExchange, chartSymbol)));
4477
+ // The warm-up head's candles the run holds without a fetch, before the loaded rows (the tape asks from its start).
4478
+ const headInHand = laneHeadArgs !== undefined ? peekWrunLaneWarmupHead(laneHeadArgs) : undefined;
4479
+ const headRows = (headInHand?.rows ?? []).filter((row) => row[0] < loadedRows[0][0]);
4480
+ const ownRows = headRows.length > 0 ? [...headRows, ...loadedRows] : loadedRows;
4481
+ let low = ownCandles ? wrunCandlesLowAcross(ownRows, span, chartIntervalMs, true) : undefined;
4482
+ if (low === undefined) {
4483
+ const ask = wrunCoinTapeDayAsk(span);
4484
+ let verdict;
4485
+ const days = (await fetchLane('ohlcv', 'tp-price', {
4486
+ interval: WRUN_TAPE_COINS_DAY_INTERVAL,
4487
+ // On a formula chart at 1d the chart's rows are the formula's: the floor reads the market's own days.
4488
+ marketRows: true,
4489
+ onSourceVerdict: (heard) => {
4490
+ verdict = heard;
4491
+ },
4492
+ }, tapeMarket !== undefined ? { exchange: tapeMarket.exchange, symbol: tapeMarket.symbol } : undefined, ask.fromMs, ask.toMs)) ?? [];
4493
+ const dayLow = wrunSourceVerdictWhole(verdict)
4494
+ ? wrunCandlesLowAcross(days, span, WRUN_TAPE_COINS_DAY_MS, false)
4495
+ : undefined;
4496
+ // The chart's own bars inside the window price its part too (the forming day an answer may lack).
4497
+ const held = { fromMs: Math.max(span.fromMs, ownRows[0][0]), toMs: span.toMs };
4498
+ const ownLow = ownCandles ? wrunCandlesLowAcross(ownRows, held, chartIntervalMs, true) : undefined;
4499
+ low = dayLow === undefined || ownLow === undefined ? dayLow : Math.min(dayLow, ownLow);
4500
+ }
4501
+ // The live session this run replaces saw the tape market print lower (its `tapePriceLow`, the guard's prices where
4502
+ // the chart's bars are not the market's): that low prices this window too, so the re-plan its guard asked for never
4503
+ // loops on a candle answer still missing the fall. Its tape on the same market only (the ask's placeholders, else
4504
+ // the run market, as `fetchLane` names them).
4505
+ const heldLow = hasGoodResult && heldContext.marketIdentity === marketIdentity
4506
+ ? wrunHeldCoinTapePriceLow(heldContext, tapeMarket ?? { exchange: 'currentExchange', symbol: 'currentSymbol' })
4507
+ : undefined;
4508
+ if (low !== undefined && heldLow !== undefined)
4509
+ low = Math.min(low, heldLow);
4510
+ // The live guard reads the chart's bars only where they are the market's prices (`ownCandles`), else the prints.
4511
+ const priced = low === undefined ? undefined : wrunPricedCoinTape(coins, low, tapeValuePerUnit ?? Number.NaN, ownCandles);
4512
+ if (priced !== undefined)
4513
+ return priced;
4514
+ const market = tapeMarket ?? { exchange: chartExchange ?? '', symbol: chartSymbol };
4515
+ throw attachWrunRefusal(new Error(`WRUN ${target.metadata.id}: ${WRUN_TAPE_COINS_UNPRICED_CODE}: input '${coins.inputNames[0]}' (tape) floors ` +
4516
+ `${market.exchange}:${market.symbol} by coins (min_coins), and no candle priced its window ` +
4517
+ `[${new Date(span.fromMs).toISOString()}, ${new Date(span.toMs).toISOString()}], so its dollar floor is not set`), {
4518
+ cls: 'service-no-answer',
4519
+ variant: 'lane',
4520
+ params: { feed: 'ohlcv' },
4521
+ ...(chartMarket !== undefined ? { market: chartMarket } : {}),
4522
+ severity: 'paused',
4523
+ });
4524
+ };
4525
+ // The tape's ask: a coins floor priced over its window, every other floor as resolved.
4526
+ const tapeAsked = tape?.minCoins !== undefined ? await priceWrunCoinTape(tape) : tape;
4073
4527
  const laneThunks = {
4074
- book: declaredClasses.has('book') ? fetchBookRows : undefined,
4528
+ // The chart's own lanes of the book, oi, liquidations and funding classes: asked when an input reads the chart's
4529
+ // own market (a pinned input reads its own lane, `pinnedLanes` below).
4530
+ book: declaredLanes.has('book') ? fetchBookRows : undefined,
4075
4531
  // One buy_sell_volume lane per quote the trades inputs read (wrun-trades-lane.util, C1.4): the
4076
4532
  // coin lane asks as it always did, the dollar lane carries `currency: "USD"` in the payload the
4077
4533
  // kScript buy_sell_volume(currency="USD") source carries it in, and each payload stays its live
@@ -4080,7 +4536,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4080
4536
  trades_usd: tradesLaneThunk('trades_usd'),
4081
4537
  // The open-interest lane in the units its inputs declare (wrun-oi-lane.util): a Coin lane's `currency` rides the
4082
4538
  // payload the K_OPEN_INTEREST control reads, and the payload stays the lane's acquisition (the reconcile's re-ask).
4083
- oi: declaredClasses.has('oi')
4539
+ oi: declaredLanes.has('oi')
4084
4540
  ? async () => (await fetchLane('open_interest', 'oi', undefined, oiLane ? { ...oiLane } : undefined)) ?? []
4085
4541
  : undefined,
4086
4542
  volume_profile: declaredClasses.has('volume_profile')
@@ -4119,7 +4575,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4119
4575
  trade_volume_by_size: declaredClasses.has('trade_volume_by_size')
4120
4576
  ? () => fetchDegradableLane('trade_volume_by_size', 'tvbs', 'Trade volume by size')
4121
4577
  : undefined,
4122
- liquidations: declaredClasses.has('liquidations')
4578
+ liquidations: declaredLanes.has('liquidations')
4123
4579
  ? async () => (await fetchLane('liquidations', 'liq')) ?? []
4124
4580
  : undefined,
4125
4581
  // Funding exists on perps only. A funding input that declares `missing:
@@ -4127,7 +4583,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4127
4583
  // FX or prediction market the lane answers empty QUIETLY (like oi) and
4128
4584
  // the row builder fills the policy; only an input on the default carry
4129
4585
  // policy (nothing to carry) reads an empty answer as a degraded lane.
4130
- funding: declaredClasses.has('funding')
4586
+ funding: declaredLanes.has('funding')
4131
4587
  ? wrunFundingLaneRequired(target.metadata)
4132
4588
  ? () => fetchDegradableLane('funding_rate', 'fr', 'Funding rate')
4133
4589
  : async () => (await fetchLane('funding_rate', 'fr')) ?? []
@@ -4139,22 +4595,25 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4139
4595
  // The options_chain lane dispatches in its own group, once its identity resolved (below).
4140
4596
  etf_flow: etfLanePlan !== undefined ? () => fetchEtfFlowRows(etfLanePlan) : undefined,
4141
4597
  // The trade tape (C2): the K_TRADES lane asked for the large-print table (`large: true`, the
4142
- // TRADE_LARGE type) wherever the table holds the market the tape reads, else for the raw tape (a
4143
- // CME root the collector does not copy: two hours and the raw live channel, wrunTapeLaneExtras),
4598
+ // TRADE_LARGE type) on every market, never the raw tape (wrunTapeLaneExtras),
4144
4599
  // at the acquisition's facets, the one floor pushed down to the gateway
4145
4600
  // (`minSize` as `minAmount`, a dollar `minValue` as `minQuoteAmount`, C-DOLLAR) and `history`
4146
4601
  // passed as declared: the control serves the history start aligned to the bar inside the
4147
- // chart's window, clamped to the table's 90-day retention. A history of "0" answers EMPTY by
4602
+ // chart's window, counted back from the run's as-of (`historyAsOfAsk`: a replay's present; on a
4603
+ // live run `tapeAsOfAsk`, the session's pin for the tape, so a later run of the session never
4604
+ // seeds it from a later start), clamped to the table's 90-day retention and the gateway's bar
4605
+ // limit, its window still ending at the server's now. A history of "0" answers EMPTY by
4148
4606
  // contract (the live edge only) and a quiet filtered window answers empty on a clean wire, so an
4149
4607
  // empty answer computes (present empty blocks on every bar), a quiet lane like trades; a lane
4150
4608
  // error (the worker's 300k-cell cap, a refused stream) degrades it. The payload stays the lane's
4151
4609
  // acquisition: the live fold's floor (a dollar floor with the market's `valuePerUnit`, the
4152
4610
  // market facts' dollar unit, so a live print is priced in the history's unit, never guessed)
4153
4611
  // and the reconcile's re-ask.
4154
- tape: tape !== undefined
4155
- ? async () =>
4156
- // The lane follows the market the tape reads (the run market fetchLane writes, else the chart's).
4157
- (await fetchLane('trades', 'tp', undefined, wrunTapeLaneExtras(tape, tapeValuePerUnit, runMarket ?? chartMetadata))) ?? []
4612
+ tape: tapeAsked !== undefined
4613
+ ? async () => (await fetchLane('trades', 'tp', undefined, {
4614
+ ...wrunTapeLaneExtras(tapeAsked, tapeValuePerUnit),
4615
+ ...tapeAsOfAsk,
4616
+ })) ?? []
4158
4617
  : undefined,
4159
4618
  // The trades leg lanes (kit 0.77.0), one thunk per (quote, market): K_BUY_SELL_VOLUME asked on
4160
4619
  // the leg's market in its quote, under the lane id as its fetch key (its own cache entry and
@@ -4165,6 +4624,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4165
4624
  tradeLegs: tradeLegLanes
4166
4625
  .filter((lane) => !softRefusedTradeLegs.has(lane) && !unservedTradeLegs.has(lane))
4167
4626
  .map((lane) => [lane, (abandoned) => fetchTradeLegRows(lane, abandoned)]),
4627
+ // The pinned lanes (U9e), one thunk per (class, market): quiet like the chart's own lanes of their classes (a
4628
+ // required funding lane degrades). A lane on a venue the gateway does not serve yet, or one the capability rule
4629
+ // judged unserved on its market, is never asked: its inputs read their fill.
4630
+ pinnedLanes: pinnedLaneIds
4631
+ .filter((lane) => !softRefusedPinnedLanes.has(lane) && !unservedTradeLegs.has(lane))
4632
+ .map((lane) => [lane, () => fetchPinnedLaneRows(lane)]),
4168
4633
  // The registry poll lanes and the row lanes dispatch in their own groups, once their plans resolved (below).
4169
4634
  };
4170
4635
  // A lane the chart's fetch never serves here is not dispatched (the capability rule above).
@@ -4174,12 +4639,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4174
4639
  // it degrades, its fetch abandoned, never aborted (the late answer lands in the fetch cache a
4175
4640
  // recovery reads).
4176
4641
  const chartBudgetMs = resolveSecondarySourceBudgetMs({ fromMs: from, toMs: to, intervalMs: clock.intervalMs });
4177
- // The tape asks TRADE_LARGE from its seed start (the declared history back from the window's end)
4178
- // on the minute grid, whatever the chart's bars: its budget is sized by the minutes it asks, never
4179
- // below the chart's (a 7-day history waits 35.2 s where a 500-bar chart's lanes wait 11.25 s).
4642
+ // The tape asks TRADE_LARGE from its seed start (the declared history back from its as-of: the session's pin for
4643
+ // the tape, a replay's present, else the window's end, `tapeHistoryAsOfMs`) through the window's end on the minute
4644
+ // grid, whatever the chart's bars: its budget is sized by the minutes it asks, never below the chart's (a 7-day
4645
+ // history waits 35.2 s where a 500-bar chart's lanes wait 11.25 s).
4180
4646
  const tapeBudgetMs = tape !== undefined && tape.historySeconds > 0
4181
4647
  ? Math.max(chartBudgetMs, resolveSecondarySourceBudgetMs({
4182
- fromMs: to - tape.historySeconds * 1000,
4648
+ fromMs: Math.min(tapeHistoryAsOfMs ?? to, to) - tape.historySeconds * 1000,
4183
4649
  toMs: to,
4184
4650
  intervalMs: Intervals.MINUTE,
4185
4651
  }))
@@ -4190,9 +4656,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4190
4656
  const tradeLegBudgetMs = new Map();
4191
4657
  for (const lane of tradeLegLanes) {
4192
4658
  const ask = tradeLegAskOf(lane);
4193
- if (ask === undefined)
4659
+ if (ask === undefined || ask.tier === null)
4194
4660
  continue;
4195
- tradeLegBudgetMs.set(lane, Math.max(chartBudgetMs, resolveSecondarySourceBudgetMs({ fromMs: ask.fromMs, toMs: ask.toMs, intervalMs: ask.tierMs })));
4661
+ tradeLegBudgetMs.set(lane, Math.max(chartBudgetMs, resolveSecondarySourceBudgetMs({ fromMs: ask.fromMs, toMs: ask.toMs, intervalMs: ask.tier.tierMs })));
4196
4662
  }
4197
4663
  if (laneThunks.tape !== undefined &&
4198
4664
  tapeBudgetMs !== chartBudgetMs &&
@@ -4219,6 +4685,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4219
4685
  run?.interval ?? '',
4220
4686
  generationAtStart,
4221
4687
  ].join('|');
4688
+ // The tape's identity names its ask too (`wrunTapeReadIdentity`): a coins floor priced off another low asks other
4689
+ // rows, so a read an earlier run left out at its floor is never joined or adopted at this one's.
4690
+ const laneReadIdentity = (lane) => lane === 'tape' && tapeAsked !== undefined ? wrunTapeReadIdentity(lateReadIdentity, tapeAsked) : lateReadIdentity;
4222
4691
  // The policy every group's lanes ride: the budget, counted from each lane's dispatch until its send re-anchors it (its
4223
4692
  // anchor goes to `fetchLane`, which hands it to the transport), the pending mark at dispatch (the degrade registry the
4224
4693
  // legend chips derive from: the budget stays the chip's authority), and the read a lane's budget abandoned, noted for
@@ -4249,7 +4718,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4249
4718
  noteWrunLateRead({
4250
4719
  indicatorId: target.indicatorId,
4251
4720
  lane,
4252
- identity: lateReadIdentity,
4721
+ identity: laneReadIdentity(lane),
4253
4722
  answer,
4254
4723
  acquisition: () => acquisitionByLane[lane],
4255
4724
  });
@@ -4258,7 +4727,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4258
4727
  // A lane whose read an earlier run left out under this run's identity joins that read (still out) or adopts its
4259
4728
  // answer: the lane sends no second ask. The acquisition the earlier run recorded is the lane's here.
4260
4729
  const joinLateRead = (lane) => {
4261
- const taken = takeWrunLateRead(target.indicatorId, lane, lateReadIdentity);
4730
+ const taken = takeWrunLateRead(target.indicatorId, lane, laneReadIdentity(lane));
4262
4731
  if (taken === undefined)
4263
4732
  return undefined;
4264
4733
  if (wrunChartHostEnv().diagnostics.debugEnabled()) {
@@ -4404,6 +4873,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4404
4873
  if ([...gatePlanes.values()].includes('cme'))
4405
4874
  computed.cme = true;
4406
4875
  const writeOpraProvenance = await opraProvenanceWriter;
4876
+ // The US stocks tape's provenance of every `stocks` row lane the sheet declares (it reads the tape through its own
4877
+ // fetch, past the chart's fetch door that stamps a tape read): its tape on the overlay's settings while its instance is
4878
+ // planned, taken off once none is (an input dropped with its fill), before any row is drawn.
4879
+ await syncWrunStocksLaneProvenance(target.chartIndex, target.indicatorId, target.metadata, rowLanes, () => head.isCurrent());
4407
4880
  // A degrade entry of a lane this run does not dispatch is settled now: a trades leg the coin switch moved, or a lane
4408
4881
  // a setting gate, a unit pick, `needed_by` or the capability rule dropped. No later run of this sheet asks that lane
4409
4882
  // again, so its chip would stand over a picture that never reads it; only a teardown would clear it.
@@ -4442,7 +4915,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4442
4915
  // 2.3): the run proceeds with a degraded lane EMPTY only when every input
4443
4916
  // reading it declares `missing: 'nan'`, or `missing: 'empty'` on a celled
4444
4917
  // input (the outputs it feeds read blank or over EMPTY blocks, nothing
4445
- // wrong-but-plausible is drawn); otherwise it holds below.
4918
+ // wrong-but-plausible is drawn); otherwise it holds below. A lane the
4919
+ // market does not serve reads as the capability rule reads it instead
4920
+ // (wrunDegradedLaneDrawable: the book of a market with no order book).
4446
4921
  const degraded = laneRun.degraded.map(({ lane, outcome }) => ({
4447
4922
  lane,
4448
4923
  ...wrunLaneSourceOf(lane, laneInstances),
@@ -4451,7 +4926,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4451
4926
  }));
4452
4927
  // A lane another screen's session stopped also holds while the overlay shows a good picture: that picture's data is
4453
4928
  // still true, and the take-back reruns the overlay (wrun-overlay-recovery.util), so the stop never blanks it.
4454
- const holding = laneRun.degraded.filter(({ lane }) => !wrunLaneReadByNanInputsOnly(target.metadata, lane, laneInstances) || (gateStops.has(lane) && hasGoodResult));
4929
+ const holding = laneRun.degraded.filter(({ lane, outcome }) => !wrunDegradedLaneDrawable(target.metadata, lane, outcome, laneInstances) ||
4930
+ (gateStops.has(lane) && hasGoodResult));
4455
4931
  // Each degraded lane's record for the moment the source ladder gives up on it (the run's settle
4456
4932
  // and the degrade registry's listener project it): a note when the run draws around the lane,
4457
4933
  // paused when it holds on it.
@@ -4534,6 +5010,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4534
5010
  const rowLaneRows = (laneResults.rowLaneRows ?? {});
4535
5011
  // The trades leg lanes' rows by lane id: a leg never asked holds none (its inputs read their fill).
4536
5012
  const tradeLegRows = laneResults.tradeLegRows ?? {};
5013
+ // The pinned lanes' rows by lane id (U9e): a lane never asked holds none (its inputs read their fill).
5014
+ const pinnedLaneRows = laneResults.pinnedLaneRows ?? {};
4537
5015
  // The run bars (fetched or held, the forming one included): the session's buffer.
4538
5016
  const fetchedRunBars = runRowsPlan
4539
5017
  ? (runRowsPlan.held ?? (await runRowsPromise))
@@ -4595,14 +5073,15 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4595
5073
  const stopped = holding.find(({ lane }) => gateStops.has(lane));
4596
5074
  // A lane the data plane refused by name names the hold the same way (its record: the tape over the trades
4597
5075
  // worker's cap reads too much data with Open the settings, never a Retry), and the hold settles as a refusal
4598
- // the same settings meet again (`wrunRefusedSourceHolds`): the settings reconcile spends no rerun on it.
5076
+ // the same settings meet again (`markWrunLaneRefusedHold`): neither the settings reconcile nor the heal reruns it.
4599
5077
  const refused = stopped === undefined
4600
5078
  ? holding.find(({ outcome }) => wrunLaneRefusedCodeOf(outcome.error) !== undefined)
4601
5079
  : undefined;
4602
5080
  const shown = stopped ?? refused ?? holding[0];
4603
5081
  const hold = wrunSourceHoldError(target.title, wrunLaneSourceOf(shown.lane, laneInstances), shown.outcome);
4604
- if (refused !== undefined)
4605
- wrunRefusedSourceHolds.add(hold);
5082
+ const refusedCode = refused === undefined ? undefined : wrunLaneRefusedCodeOf(refused.outcome.error);
5083
+ if (refusedCode !== undefined)
5084
+ markWrunLaneRefusedHold(hold, refusedCode);
4606
5085
  const named = stopped ?? refused;
4607
5086
  const namedRecord = named !== undefined ? refusal.degraded?.find(({ lane }) => lane === named.lane)?.refusal : undefined;
4608
5087
  throw namedRecord !== undefined ? annotateWrunErrorRefusal(hold, namedRecord) : hold;
@@ -4731,12 +5210,16 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4731
5210
  tapeRows,
4732
5211
  // The plan resolves a param-bound tape floor from the settings it is handed: the floor the
4733
5212
  // lane was asked at (the param's current value).
4734
- ...(tape !== undefined ? { settings: wrunTapeFloorSettings(target.metadata, wrunTapeFloorOf(tape)) } : {}),
5213
+ ...(tapeAsked !== undefined
5214
+ ? { settings: wrunTapeFloorSettings(target.metadata, wrunTapeFloorOf(tapeAsked)) }
5215
+ : {}),
4735
5216
  ...(pollLanes.length > 0 ? { pollLanes, pollLaneRows } : {}),
4736
5217
  ...(rowLanes.length > 0 ? { rowLanes, rowLaneRows } : {}),
4737
5218
  ...(Object.keys(tradeLegRows).length > 0
4738
5219
  ? { tradeLegRows, tradeLegIntervals: wrunTradeLegIntervals(acquisitionByLane) }
4739
5220
  : {}),
5221
+ // Each foreign ask of a book, oi, funding or liquidations input reads the pinned lane of its market (U9e).
5222
+ ...(Object.keys(pinnedLaneRows).length > 0 ? { pinnedLaneRows } : {}),
4740
5223
  ...(hasPinnedLegs ? { pinnedCandleRows, pinnedLegTierMs: wrunPinnedLegTierMs(legs) } : {}),
4741
5224
  ...(hasLiveCandleLegs ? { pinnedLiveCandleRows } : {}),
4742
5225
  ...(hasIntrabarLegs ? { intrabarRows } : {}),
@@ -4755,9 +5238,31 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4755
5238
  formingBarTs,
4756
5239
  };
4757
5240
  // Only the row builder (and the carry it seeds) sees the head: the canvases' rows, the presentation and every
4758
- // landing read the chart's own bars.
4759
- const computeSourceRows = computeOhlcvRows === ohlcvRows ? sourceRows : { ...sourceRows, ohlcvRows: computeOhlcvRows };
4760
- const rows = buildWrunInputRows(target.metadata, computeSourceRows, clock);
5241
+ // landing read the chart's own bars. The same for the host session's composition (wrun-session-composition.util):
5242
+ // the compute reads the session's tape and trades rows from its seam on, while the lanes this run installs on its
5243
+ // live context stay OpenMarket's.
5244
+ const composition = composeWrunSessionSources({
5245
+ chartIndex: target.chartIndex,
5246
+ indicatorId: target.indicatorId,
5247
+ intervalMs: clock.intervalMs,
5248
+ lanes: {
5249
+ metadata: target.metadata,
5250
+ acquisition: acquisitionByLane,
5251
+ market: wrunChartStreamIdentity(chartMetadata),
5252
+ },
5253
+ }, computeOhlcvRows === ohlcvRows ? sourceRows : { ...sourceRows, ohlcvRows: computeOhlcvRows });
5254
+ const computeSourceRows = composition.sources;
5255
+ // The host's token the rows were composed under: the install compares it (an owner change in flight owes a revision).
5256
+ const compositionToken = composition.token;
5257
+ // A live run seeds its session's carry from these rows (the integrate's install). On the host's `carryWithBuild`
5258
+ // (web: the engine arm `webkit-wrun-carry-with-build`) the rows and that carry come from one conversion of the
5259
+ // window's lanes, here, before any await; else the install advances the carry from the empty seed, converting the
5260
+ // window again over the sources as the awaits left them.
5261
+ const builtWithCarry = live && wrunHostCarryWithBuild()
5262
+ ? buildWrunInputRowsAndCarry(target.metadata, computeSourceRows, clock)
5263
+ : undefined;
5264
+ const carryAtBuild = wrunCarryAtBuildOf(builtWithCarry, ohlcvRows, computeSourceRows);
5265
+ const rows = builtWithCarry?.rows ?? buildWrunInputRows(target.metadata, computeSourceRows, clock);
4761
5266
  // An exact warm-up session's candle evidence (D2), fingerprinted in the same synchronous block as the guest's
4762
5267
  // input rows (C3): the candles the guest reads, never a chart row an await below could see rewritten in place.
4763
5268
  // Installed on the session only once its run succeeded warm.
@@ -4881,6 +5386,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4881
5386
  bookRows,
4882
5387
  buySellVolumeRows,
4883
5388
  buySellVolumeUsdRows,
5389
+ // The carry the session takes, from the build's own conversion (`carryWithBuild`), with what that build read; the
5390
+ // install keeps it only while none of that moved, else advances it as without the switch.
5391
+ carryAtBuild,
4884
5392
  chartExchange,
4885
5393
  chartFirstTs,
4886
5394
  chartInterval,
@@ -4890,6 +5398,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4890
5398
  chartRows,
4891
5399
  clampedLegs,
4892
5400
  clock,
5401
+ compositionToken,
4893
5402
  computeIdentity,
4894
5403
  computeSourceRows,
4895
5404
  cryptoVenue,
@@ -4925,6 +5434,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4925
5434
  optionsChainRows,
4926
5435
  paramValues,
4927
5436
  pinnedCandleRows,
5437
+ pinnedLaneRows,
4928
5438
  pinnedLiveCandleRows,
4929
5439
  planGeneration,
4930
5440
  pollLaneRows,
@@ -4984,6 +5494,14 @@ const WRUN_ROW_SOURCE_TRANSIENT_SEED = {
4984
5494
  variant: 'generic',
4985
5495
  out: { kind: 'retry' },
4986
5496
  };
5497
+ /** The guest memory a live-start block reported (`WrunLiveBlockStats.memoryBytes`), as a live context field: what a
5498
+ * warm switch's park counts for the worker's share of the session. Empty when the worker named none. */
5499
+ function wrunWorkerMemoryOf(outputRows) {
5500
+ const memoryBytes = wrunLiveOf(outputRows)?.memoryBytes;
5501
+ return typeof memoryBytes === 'number' && Number.isFinite(memoryBytes) && memoryBytes > 0
5502
+ ? { workerMemoryBytes: memoryBytes }
5503
+ : {};
5504
+ }
4987
5505
  /** The overlay's live frames as the pass takes its sandbox session (C7): the sandbox tick integrates
4988
5506
  * its own frames (the browser drain), so the stream it hands the pass carries none. */
4989
5507
  const wrunTickOwnedFrames = () => undefined;
@@ -5448,6 +5966,16 @@ export function __resetWrunHeldRowSourcesForTests() {
5448
5966
  wrunHeldRowSources.clear();
5449
5967
  __resetWrunSocketSessionLossesForTests();
5450
5968
  wrunPendingRowSourceAsks.clear();
5969
+ // The install pacer's turns too (every waiter released): a spec's first install goes at once.
5970
+ __resetWrunInstallPacerForTests();
5971
+ }
5972
+ // Chart teardown (`teardownWrunOverlaysForChart`, through its chart hooks, after it dropped every live context of the
5973
+ // chart) drops the chart's install turn: its waiters go at once and meet their commit checks on a chart that left.
5974
+ try {
5975
+ onWrunChartTeardown(dropWrunInstallPacer);
5976
+ }
5977
+ catch {
5978
+ // partial module mock (specs)
5451
5979
  }
5452
5980
  // A session that ends (the overlay leaves, a Pause suspends it) releases the source it held. An overlay that leaves
5453
5981
  // (never a Pause: its run stands down on the pause itself) cancels the fresh asks it has pending first.
@@ -5642,12 +6170,16 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5642
6170
  await integrateWrunRowSourceBatch(runTarget, tc, meta, refusal, computed, owner, head, ask, batch);
5643
6171
  return;
5644
6172
  }
5645
- const { acquisitionByLane, writeOpraProvenance, readsOpraPlane, bookRows, buySellVolumeRows, buySellVolumeUsdRows, chartExchange, chartFirstTs, chartInterval, chartIntervalMs, chartMetadata, chartNames, chartRows, clampedLegs, clock, computeIdentity, computeSourceRows, cryptoVenue, degraded, emptyLegs, etfFlowRows, evaluatedCandles, fetchedRunBars, fillingFrom, fillingLanes, formingPreRoll, from, fundingRateRows, generationAtStart, hasGoodResult, hasIntrabarLegs, hasLiveCandleLegs, hasPinnedLegs, headWarm, heldCoverage, impliedVolatilityRows, initArgs, intrabarRows, laneHead, laneRun, legs, liquidationRows, live, loadedRows, marketIdentity, missingFeeds, ohlcvRows, openInterestRows, optionsChainRows, paramValues, pinnedCandleRows, pinnedLiveCandleRows, planGeneration, pollLaneRows, pollLanes, rowLaneRows, rowLanes, projection, reason, replay, replayChartRows, replayHeadRows, retainedRowsCap, retainedWindow, rows, run, runBars, runBlockRowsCap, runKey, runRowsPlan, skewRows, strategy, tapeRows, target, textParams, to, tradeLegRows, tradeVolumeBySizeRows, twinAtChart, unservedLanes, unservedLegs, unservedTradeLegs, unsettledLanes, volumeProfileRows, warmupBarsNow, warmupHead, warmupMiss, warmupWall, window, headsDeferred, epoch: generation, pinNotes, respelledPins, rowBudgetCuts, downloadBudgetCut, } = prepared;
6173
+ const { acquisitionByLane, writeOpraProvenance, readsOpraPlane, bookRows, buySellVolumeRows, buySellVolumeUsdRows, carryAtBuild, chartExchange, chartFirstTs, chartInterval, chartIntervalMs, chartMetadata, chartNames, chartRows, clampedLegs, clock, compositionToken, computeIdentity, computeSourceRows, cryptoVenue, degraded, emptyLegs, etfFlowRows, evaluatedCandles, fetchedRunBars, fillingFrom, fillingLanes, formingPreRoll, from, fundingRateRows, generationAtStart, hasGoodResult, hasIntrabarLegs, hasLiveCandleLegs, hasPinnedLegs, headWarm, heldCoverage, impliedVolatilityRows, initArgs, intrabarRows, laneHead, laneRun, legs, liquidationRows, live, loadedRows, marketIdentity, missingFeeds, ohlcvRows, openInterestRows, optionsChainRows, paramValues, pinnedCandleRows, pinnedLaneRows, pinnedLiveCandleRows, planGeneration, pollLaneRows, pollLanes, rowLaneRows, rowLanes, projection, reason, replay, replayChartRows, replayHeadRows, retainedRowsCap, retainedWindow, rows, run, runBars, runBlockRowsCap, runKey, runRowsPlan, skewRows, strategy, tapeRows, target, textParams, to, tradeLegRows, tradeVolumeBySizeRows, twinAtChart, unservedLanes, unservedLegs, unservedTradeLegs, unsettledLanes, volumeProfileRows, warmupBarsNow, warmupHead, warmupMiss, warmupWall, window, headsDeferred, epoch: generation, pinNotes, respelledPins, rowBudgetCuts, downloadBudgetCut, } = prepared;
5646
6174
  // The filling chip (`fillingLanes`, a first-slice picture): raised right before the integrate, lowered if the run
5647
6175
  // fails after it.
5648
6176
  const fillingGuardKey = overlayExecutionGuardKey(target.chartIndex, target.indicatorId);
5649
6177
  let fillingRaised = false;
5650
6178
  try {
6179
+ // The gesture's idle edge (WRUN-PANBACK A1): a held reason's result waits here, before anything below reads the
6180
+ // chart, the overlay, its settings or its session. A user run queued meanwhile drops this result as superseded (the
6181
+ // catch releases what the ask opened).
6182
+ const edge = await awaitWrunInstallGestureEdge(runTarget, reason);
5651
6183
  // The module's rows, the batch's own array (its frames, handles and strategy ride on it). A hidden head's rows
5652
6184
  // are cut by timestamp here (D4), where the pass receives them from the row source, before the integrate, the
5653
6185
  // warm-up ask, the health verdict and the live context read anything: the guest ran them, nothing shows them.
@@ -5656,17 +6188,24 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5656
6188
  const retained = retainedWindow !== undefined && retainedWindow.droppedBars > 0
5657
6189
  ? { cap: retainedWindow.cap, calculatedBars: outputRows.length, droppedBars: retainedWindow.droppedBars }
5658
6190
  : undefined;
5659
- // The engine tick and the price canvases' fill (G1: the served TPO block
5660
- // for the chart market), read at integrate time and before the route's
5661
- // facts below (the catalog read may await); on a mirror miss the block the
5662
- // overlay's live session holds for this market (the reseed's rule), so a
5663
- // mirror entry that aged out never moves the grid.
6191
+ // Every await the install needs comes before its turn: the price canvases' served TPO block (G1, for the chart
6192
+ // market; the catalog read may await) and the chart store the write boundary's checks read in the turn's task.
6193
+ const canvasHostFill = await wrunCanvasHostFillFor(target.metadata, chartMetadata);
6194
+ const readChartMetadata = await wrunChartMetadataReaderFor(target.chartIndex);
6195
+ const readOverlayPaused = await wrunOverlayPausedReaderFor(target.chartIndex, target.indicatorId);
6196
+ // The write boundary (WRUN-PANBACK-2 S1): the chart's install turn, one install per WRUN_INSTALL_MIN_GAP_MS, so the
6197
+ // results one idle edge released paint one after another; a drag that started while the turn waited holds the
6198
+ // result again (a fresh turn after it) while the episode's ceiling lasts. Nothing below awaits until the titan
6199
+ // write, so the write lands in the task that took the turn and every commit check judges what stands there.
6200
+ const { heldMs, pacedMs } = await awaitWrunInstallWriteTurn(runTarget, reason, edge);
6201
+ // The engine tick and the price canvases' fill, read at integrate time: on a mirror miss the block the overlay's
6202
+ // live session holds for this market (the reseed's rule), so a mirror entry that aged out never moves the grid.
5664
6203
  const integrateHostFill = wrunHostFillContextFor(tc, chartExchange, clock.intervalMs);
5665
- const canvasFill = wrunCanvasFillWithSessionBlock(await wrunCanvasHostFillFor(target.metadata, chartMetadata), target.metadata, target.indicatorId, chartMetadata);
6204
+ const canvasFill = wrunCanvasFillWithSessionBlock(canvasHostFill, target.metadata, target.indicatorId, chartMetadata);
5666
6205
  // The route's facts, read again now that the worker answered (D2 2.6):
5667
6206
  // the chart, the overlay and the market the run computed for, and the
5668
6207
  // settings it computed with.
5669
- const identityLeft = await wrunRunIdentityLeft(target.chartIndex, tc, meta, marketIdentity);
6208
+ const identityLeft = wrunRunIdentityLeft(target.chartIndex, tc, meta, marketIdentity, readChartMetadata);
5670
6209
  // The settings the run computed with are still the overlay's only while no compute save landed
5671
6210
  // since the run started: a generation only grows, so a save between the start and the params
5672
6211
  // read made the run a mix of two, and one after the read made it old. Never by content: ON, OFF,
@@ -5695,8 +6234,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5695
6234
  fills: target.fills,
5696
6235
  candles: target.candles,
5697
6236
  chartNames,
5698
- // The draft's word and an OPRA chain's served tier (wrun-draft-legend-note.util); every tick repeats it.
5699
- legendNote: wrunOverlayLegendNote(meta.settings, acquisitionByLane.options_chain, acquisitionByLane),
6237
+ // The draft's word, an OPRA chain's served tier and the delayed CME legs (wrun-draft-legend-note.util); every
6238
+ // tick repeats it.
6239
+ legendNote: wrunOverlayLegendNote(meta.settings, acquisitionByLane.options_chain, acquisitionByLane, undefined, computed.cmeDelayed),
5700
6240
  // The market's size unit (an output its `visible_by` leaves out here mounts nothing) and its dollar unit (the
5701
6241
  // batched marks' `units`).
5702
6242
  ...wrunResultMarketUnits(chartMetadata),
@@ -5714,7 +6254,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5714
6254
  // A pause (or a later install or teardown that moved the live generation) landed while the
5715
6255
  // worker answered: the returned output is dropped and no live context installs; the
5716
6256
  // retained picture stays (the run leaves the way the head's pause does, silently).
5717
- if ((await isWrunOverlayPaused(target.chartIndex, target.indicatorId)) ||
6257
+ if (readOverlayPaused() ||
5718
6258
  (generation !== undefined && currentWrunOverlayLiveGeneration(target.indicatorId) !== generation)) {
5719
6259
  throw new WrunOverlayPausedError('paused');
5720
6260
  }
@@ -5734,6 +6274,10 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5734
6274
  // A CME chart study lands only under the authorisation its head captured, judged in the task that applies it.
5735
6275
  assertWrunCmeStudyAuthCurrent(computed, target.indicatorId);
5736
6276
  const runSerial = nextWrunCanvasRunSerial(target.indicatorId);
6277
+ // A result still the overlay's own reaches the route's write (a superseded one skips it below).
6278
+ if (!identityLeft && !settingsStale) {
6279
+ ringWrunInstallApplied(target.chartIndex, target.indicatorId, reason, heldMs, pacedMs);
6280
+ }
5737
6281
  const integration = integrateWrunRunThroughRoute({
5738
6282
  ...integrateOptions,
5739
6283
  integration: {
@@ -5785,6 +6329,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5785
6329
  // The stamp stands until a later run can clear it.
5786
6330
  }
5787
6331
  }
6332
+ // A result that asks nothing still supersedes an older one held on its sources.
6333
+ wrunWarmupAsksOnLanding.delete(fillingGuardKey);
5788
6334
  // The result asks once whether older candles are owed for its warm-up (the engine lane's own
5789
6335
  // ask; a result the route skipped as unchanged is the picture the chart shows, so it asks
5790
6336
  // too). A full run only: the tick and the reseed integrate without this pass. Never under
@@ -5792,6 +6338,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5792
6338
  // Nor for a run its budget clamped: older candles cannot reach a window the budget decided (design 5). Nor for a
5793
6339
  // run that drew first: its heads were deferred, so it holds no credit, and the warm rerun the landed head owes the
5794
6340
  // overlay asks with the credit (a cold ask here would buy a visible page the head covers).
6341
+ // The ask's verdict also holds the viewer's nothing-drawn note below (FB27): a page it buys reruns the overlay
6342
+ // before the note could say the Indicator drew nothing.
6343
+ const warmupPage = replay ? undefined : wrunWarmupPageVerdict();
5795
6344
  if (!replay && retainedWindow === undefined && !headsDeferred)
5796
6345
  askWrunWarmupBackfillIfOwed({
5797
6346
  chartIndex: target.chartIndex,
@@ -5817,12 +6366,18 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5817
6366
  lookbackBars: wrunTwinLookbackBars(meta.settings) ?? (await wrunTwinOriginalLookbackBars(meta.settings, chartIntervalMs)),
5818
6367
  unsettledLanes,
5819
6368
  planGeneration,
5820
- // Where the history the run read begins: its row lanes', unless it read another source beside the candles (a
5821
- // pinned leg, or any lane that is no row lane: none of those names its reach).
6369
+ // Where the history the run read begins: every lane it asked and every leg, from the bar its lanes asked from.
5822
6370
  historySources: {
5823
- rowLanes,
5824
- readsOtherSources: legs.length > 0 || laneRun.outcomes.some(({ lane }) => !isWrunRowLaneId(lane)),
6371
+ lanes: wrunRunHistoryLanesOf({
6372
+ lanes: laneRun.outcomes.map(({ lane, outcome }) => ({ lane, rows: outcome.rows })),
6373
+ rowLanes,
6374
+ pollLanes,
6375
+ legs,
6376
+ legRows: (fetchKey) => pinnedCandleRows[fetchKey] ?? intrabarRows[fetchKey],
6377
+ }),
6378
+ askedFromMs: from,
5825
6379
  },
6380
+ onNoPage: warmupPage?.noPage,
5826
6381
  });
5827
6382
  // The presentation that follows every integrate (the parent and its
5828
6383
  // lower-pane children mounted): nested output visibility from the sheet
@@ -5842,8 +6397,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5842
6397
  // healthy run clears the rows a previous one raised, and the live session below keeps the
5843
6398
  // verdict honest once the overlay starts drawing. The chip policy (`wrunChartRunHealth`):
5844
6399
  // only the outputs a viewer sees are watched, and none while a source the run reads is absent
5845
- // on this market (its own note says so once).
5846
- const draft = isWrunDraftOverlaySettings(meta.settings);
6400
+ // on this market (its own note says so once). An app layer (wrun-app-layer.leaf) is read as a viewer reads it: it
6401
+ // rides the draft lane, but nobody authored it here.
6402
+ const draft = isWrunDraftOverlaySettings(meta.settings) && !isWrunAppLayerOverlaySettings(meta.settings);
5847
6403
  const emptySeries = wrunEmptySeriesFeeds(laneRun, unsettledLanes, target.metadata, cryptoVenue, (lane) => {
5848
6404
  const asked = acquisitionByLane[lane]?.exchange;
5849
6405
  return typeof asked === 'string' && asked !== 'currentExchange' ? asked : chartExchange;
@@ -5858,6 +6414,29 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5858
6414
  emptySeries.length > 0;
5859
6415
  const { watched, health } = wrunChartRunHealth(sheetNow, meta.settings, outputRows, sourceAbsent, wrunChartSizeUnit(chartMetadata));
5860
6416
  const runHealthWarned = await publishWrunRunHealth(target.chartIndex, target.indicatorId, wrunRunHealthRowsFor(health, draft, wrunNothingReadyRefusal(health, refusal.ctx)));
6417
+ // A viewer's note when this published Indicator drew nothing over the whole loaded window (FB27), judged only on
6418
+ // the picture the chart now shows and only once the run is settled: a window of the range, a first slice still
6419
+ // filling, a lane unanswered, a source with its own note (`sourceAbsent`), a budget-clamped window or a deferred
6420
+ // head's rerun still owed leaves the note as it stands, and a raise waits for the warm-up ask's verdict.
6421
+ if (integration.applied || (route.action === 'skip' && route.reason === 'render-equal')) {
6422
+ await publishWrunNothingDrawn(target.chartIndex, target.indicatorId, {
6423
+ draft,
6424
+ settled: window?.partial !== true &&
6425
+ fillingLanes.length === 0 &&
6426
+ unsettledLanes.size === 0 &&
6427
+ !sourceAbsent &&
6428
+ retainedWindow === undefined &&
6429
+ !headsDeferred,
6430
+ metadata: sheetNow,
6431
+ rows: outputRows,
6432
+ drawings: wrunHandlesOf(outputRows)?.length,
6433
+ runIntervalMs: run ? run.intervalMs : chartIntervalMs,
6434
+ }, () => refusal.ctx, {
6435
+ // A raise the warm-up verdict holds lands on this run's mount only, never a same-id remount's.
6436
+ isCurrent: () => isWrunRunMountOnChart(target.chartIndex, { tc, meta }),
6437
+ ...(warmupPage !== undefined ? { warmup: warmupPage } : {}),
6438
+ });
6439
+ }
5861
6440
  // A leg the chart could not serve is not a failure (the run drew what it
5862
6441
  // could): one note per pinned market says why its inputs read their fill,
5863
6442
  // on a draft and on a registry Indicator alike, replaced by every run and
@@ -5921,6 +6500,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5921
6500
  window,
5922
6501
  executedVersion: target.version,
5923
6502
  firstSlice: fillingLanes.length > 0,
6503
+ readsCme: computed.cme === true,
5924
6504
  });
5925
6505
  }
5926
6506
  if (live && generation !== undefined && rows.length > 0) {
@@ -5959,6 +6539,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5959
6539
  // The run's console provenance: every debug line the session's ticks and reseeds publish states it.
5960
6540
  ...(computed.opra === true ? { opraRead: true } : {}),
5961
6541
  ...(computed.cme === true ? { cmeRead: true } : {}),
6542
+ // The delayed CME legs its legend names: every tick and reseed names them alike.
6543
+ ...(computed.cmeDelayed !== undefined ? { cmeDelayed: computed.cmeDelayed } : {}),
5962
6544
  // The current paint (above): the ticks and the reseeds keep the look.
5963
6545
  metadata: sheetNow,
5964
6546
  title: target.title,
@@ -5986,7 +6568,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5986
6568
  ...(retainedRowsCap !== undefined ? { retainedRowsCap } : {}),
5987
6569
  ...(runBlockRowsCap !== undefined ? { runBlockRowsCap } : {}),
5988
6570
  ...(retained !== undefined ? { retained } : {}),
5989
- bookRows: bookRows ? [...bookRows] : undefined,
6571
+ // The book lane's own rows, never copied (WRUN-PANBACK-2 S2: on the packed lane, views of the worker's block):
6572
+ // the push intake's folds and every other writer replace the array, none writes into it.
6573
+ bookRows,
5990
6574
  buySellVolumeRows: buySellVolumeRows ? [...buySellVolumeRows] : undefined,
5991
6575
  buySellVolumeUsdRows: buySellVolumeUsdRows ? [...buySellVolumeUsdRows] : undefined,
5992
6576
  openInterestRows: openInterestRows ? [...openInterestRows] : undefined,
@@ -6027,6 +6611,14 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
6027
6611
  tradeLegRows: Object.fromEntries(Object.entries(tradeLegRows).map(([lane, rows]) => [lane, [...rows]])),
6028
6612
  }
6029
6613
  : {}),
6614
+ // The pinned lanes the run asked (U9e): a copy of each one's rows by lane id. The push intake folds each lane
6615
+ // market's frames into it (book, funding, liquidations), the reconcile re-asks it (an oi lane by the poll),
6616
+ // and the live channels follow these keys (a lane never asked holds none and is never subscribed).
6617
+ ...(Object.keys(pinnedLaneRows).length > 0
6618
+ ? {
6619
+ pinnedLaneRows: Object.fromEntries(Object.entries(pinnedLaneRows).map(([lane, rows]) => [lane, [...rows]])),
6620
+ }
6621
+ : {}),
6030
6622
  ...(legs.length > 0 ? { pinnedLegs } : {}),
6031
6623
  ...(hasPinnedLegs ? { pinnedCandleRows } : {}),
6032
6624
  ...(hasLiveCandleLegs ? { pinnedLiveCandleRows } : {}),
@@ -6034,9 +6626,17 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
6034
6626
  // The forming pre-roll rows: the reseed rebuilds the head's bucket from them.
6035
6627
  ...(formingPreRoll !== undefined ? { formingPreRoll } : {}),
6036
6628
  generation,
6629
+ // The live-start above opened the worker's series under this generation.
6630
+ seriesEpoch: generation,
6037
6631
  intervalMs: clock.intervalMs,
6038
6632
  acquisition: acquisitionByLane,
6039
- carrySeed: advanceWrunInputCarry(target.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock),
6633
+ // The guest memory the live-start reported: what a warm switch's park counts for the worker's share.
6634
+ ...wrunWorkerMemoryOf(outputRows),
6635
+ carrySeed: wrunCarryAtBuildStill(carryAtBuild, ohlcvRows) ??
6636
+ advanceWrunInputCarry(target.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock, carryAtBuild === undefined ? 'advance' : 'recovered'),
6637
+ // The instant the session's declared depth counts back from (wrun-history-as-of.util): its reseeds and wake
6638
+ // recoveries rebuild under it, never under their own now alone.
6639
+ historyAsOfMs: wrunClockHistoryAsOfMs(clock),
6040
6640
  fedBuckets: {},
6041
6641
  pushEligible: wrunPushEligible(target.metadata, run ? run.interval : chartInterval),
6042
6642
  paintedThroughTs: lastRowTs,
@@ -6141,7 +6741,15 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
6141
6741
  indicatorId: target.indicatorId,
6142
6742
  ...capability,
6143
6743
  });
6744
+ // The context this one replaces: an owner change while the run computed revised it, not this one.
6745
+ const replacedDirtyFromTs = getWrunOverlayLiveContext(target.indicatorId)?.dirtyFromTs ?? null;
6144
6746
  setWrunOverlayLiveContext(liveContext);
6747
+ // The host's session changed owner while the run computed (a hand-back, a new seam): its rows read a
6748
+ // composition that is no longer the overlay's, so the revision the replaced context owed is carried onto this
6749
+ // one (the whole window when it owed none): the drain reseeds over the composition as it stands.
6750
+ if (compositionToken !== wrunSessionCompositionToken(target.indicatorId)) {
6751
+ oweWrunCompositionRevision(liveContext, replacedDirtyFromTs ?? liveContext.firstRowTs);
6752
+ }
6145
6753
  if (replay) {
6146
6754
  noteWrunReplayRun(liveContext, {
6147
6755
  generation: replay.generation,
@@ -6571,6 +7179,10 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6571
7179
  let declarationsMoved = false;
6572
7180
  try {
6573
7181
  const reason = runTarget.reason ?? 'loaded-range-refresh';
7182
+ // The gesture's idle edge (WRUN-PANBACK A1), as on the browser lane: before the batch's sheet is remembered and
7183
+ // before every commit check below. A user run queued meanwhile drops the batch as superseded (the catch releases
7184
+ // what the ask opened). A frame the source merges meanwhile joins the session the install reads under the lock.
7185
+ const edge = await awaitWrunInstallGestureEdge(runTarget, reason);
6574
7186
  const replay = reason === 'replay' ? wrunReplayRunPlanOf(chartIndex, indicatorId) : undefined;
6575
7187
  if (reason === 'replay' && replay === undefined) {
6576
7188
  throw new WrunChartGoneError(`wrun overlay '${indicatorId}' was superseded (no replay lane)`);
@@ -6606,17 +7218,12 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6606
7218
  wrunReadsMarketFacts(delivered) ? wrunCloudFactsMarket(chartMetadata) : undefined);
6607
7219
  const chartNames = await resolveWrunChartNames(chartIndex);
6608
7220
  const canvasFill = wrunCanvasFillWithSessionBlock(await wrunCanvasHostFillFor(delivered, chartMetadata), delivered, indicatorId, chartMetadata);
6609
- const identityLeft = await wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity);
6610
- const settingsStale = kScriptSettingsRevision(meta.settings) !== computed.generation;
6611
- // The sheet and the params as the overlay's settings read NOW (a paint-only save restyled the
6612
- // mounted outputs in place while the source answered).
6613
- const sheetNow = wrunSheetWithSettings(delivered, meta.settings);
6614
- const paramValues = wrunParamValuesFromSettings(sheetNow, meta.settings, hostFill);
6615
- // What the source computed: the version and the params of the settings it ran with.
6616
- const computeIdentity = wrunSourceComputeIdentityOf(sheetNow, ask.computedWith, hostFill, chartInterval);
7221
+ // The chart store the write boundary's checks read in the turn's own task, loaded before the turn.
7222
+ const readChartMetadata = await wrunChartMetadataReaderFor(chartIndex);
7223
+ const readOverlayPaused = await wrunOverlayPausedReaderFor(chartIndex, indicatorId);
6617
7224
  const outputRows = wrunOutputRowsOfBatch(batch);
6618
7225
  assertWrunRunMayPaint(chartIndex, indicatorId, replay);
6619
- if (await isWrunOverlayPaused(chartIndex, indicatorId))
7226
+ if (readOverlayPaused())
6620
7227
  throw new WrunOverlayPausedError('paused');
6621
7228
  // The cloud's OPRA mark (contract opra-server-lanes 10b, wrun-cloud-opra-stamp.util): a result whose run reads
6622
7229
  // OPRA is stamped through the run's own provenance writer before any row of the batch lands, read back off the
@@ -6631,9 +7238,27 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6631
7238
  // The cloud read OPRA for these rows (its mark): the run's console provenance from here (`computed.opra`).
6632
7239
  if (batch.opra === true)
6633
7240
  computed.opra = true;
7241
+ // The write boundary (WRUN-PANBACK-2 S1), as on the browser lane: the chart's install turn after the last await,
7242
+ // the gesture read again (a drag that started while the turn waited holds the batch again while the episode's
7243
+ // ceiling lasts), then the commit checks and the titan write with no await between them.
7244
+ const { heldMs, pacedMs } = await awaitWrunInstallWriteTurn(runTarget, reason, edge);
7245
+ const identityLeft = wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity, readChartMetadata);
7246
+ const settingsStale = kScriptSettingsRevision(meta.settings) !== computed.generation;
7247
+ // The sheet and the params as the overlay's settings read NOW (a paint-only save restyled the
7248
+ // mounted outputs in place while the source answered).
7249
+ const sheetNow = wrunSheetWithSettings(delivered, meta.settings);
7250
+ const paramValues = wrunParamValuesFromSettings(sheetNow, meta.settings, hostFill);
7251
+ // What the source computed: the version and the params of the settings it ran with.
7252
+ const computeIdentity = wrunSourceComputeIdentityOf(sheetNow, ask.computedWith, hostFill, chartInterval);
7253
+ assertWrunRunMayPaint(chartIndex, indicatorId, replay);
7254
+ if (readOverlayPaused())
7255
+ throw new WrunOverlayPausedError('paused');
6634
7256
  const heldContext = getWrunOverlayLiveContext(indicatorId);
6635
7257
  const window = runTarget.window;
6636
7258
  nextWrunCanvasRunSerial(indicatorId);
7259
+ // A batch still the overlay's own reaches the route's write (a superseded one skips it below).
7260
+ if (!identityLeft && !settingsStale)
7261
+ ringWrunInstallApplied(chartIndex, indicatorId, reason, heldMs, pacedMs);
6637
7262
  const integration = integrateWrunRunThroughRoute({
6638
7263
  tc,
6639
7264
  meta,
@@ -6712,9 +7337,23 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6712
7337
  : undefined);
6713
7338
  await publishWrunStrategyRunResult(chartIndex, indicatorId, runResult, { tc, meta });
6714
7339
  await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows, wrunRunOutputProvenance(computed));
6715
- const draft = isWrunDraftOverlaySettings(meta.settings);
7340
+ // An app layer is read as a viewer reads it (wrun-app-layer.leaf), as on the browser lane above.
7341
+ const draft = isWrunDraftOverlaySettings(meta.settings) && !isWrunAppLayerOverlaySettings(meta.settings);
6716
7342
  const { health } = wrunChartRunHealth(sheetNow, meta.settings, outputRows, false, wrunChartSizeUnit(chartMetadata));
6717
7343
  const runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, draft, wrunNothingReadyRefusal(health, refusal.ctx)));
7344
+ // The viewer's nothing-drawn note (FB27), as on the browser lane: a whole window the cloud computed and the chart
7345
+ // shows; this lane asks no warm-up page. It judges the sheet the author declared, never the delivered copy that
7346
+ // left a refused family out: a refused section speaks through its own refusal, and the rows cannot show it.
7347
+ if (integration.applied || (route.action === 'skip' && route.reason === 'render-equal')) {
7348
+ await publishWrunNothingDrawn(chartIndex, indicatorId, {
7349
+ draft,
7350
+ settled: window?.partial !== true,
7351
+ metadata: wrunSheetWithSettings(batch.sheet ?? runTarget.metadata, meta.settings),
7352
+ rows: outputRows,
7353
+ drawings: wrunHandlesOf(outputRows)?.length,
7354
+ runIntervalMs: chartIntervalMs,
7355
+ }, () => refusal.ctx, { isCurrent: () => isWrunRunMountOnChart(chartIndex, { tc, meta }) });
7356
+ }
6718
7357
  // A run computed elsewhere served every leg it read: no leg note of an earlier run stands, no pin note this
6719
7358
  // lane respelled (the cloud resolves its own pins), and no row budget cut of a browser read.
6720
7359
  await publishWrunUnservedLegDiagnostics(chartIndex, indicatorId, []);
@@ -7042,17 +7681,26 @@ function wrunWarmupEvidenceOutputs(runResult) {
7042
7681
  * warm-up end that many evaluated rows into the run's window, read beside the outputs' own (the
7043
7682
  * later wins; a drawings-only sheet has only it), so the decider asks for the history the
7044
7683
  * declaration owes before the viewport, under its own rounds and page size (ring
7045
- * `declaredWarmupBars`). It is never the declared lookback: that would change the all-NaN rules (an
7046
- * empty run's second page, QA 235). A proven twin keeps its built-in's lookback and never reads its
7684
+ * `declaredWarmupBars`). It is never the declared lookback; an empty run over rows that hold the
7685
+ * declaration and its slack buys no page (`declaredWarmupCovered`), and an undeclared one keeps its
7686
+ * probe pages (QA 235). A proven twin keeps its built-in's lookback and never reads its
7047
7687
  * sheet's warm-up (that window is the hosted lanes' fetch; on the chart the twin stays at its
7048
- * built-in's history cost).
7688
+ * built-in's history cost). Only a source still landing holds a result with values: its degrade
7689
+ * entry pending, or degraded with its ladder not terminal (warmupSourceEntryLanding), and the ask held
7690
+ * on one asks again once none is (holdWrunWarmupAskOnLanding). Where every lane and leg begins, as a
7691
+ * declaration or an every-bar answer names it (wrunRunSourceReachFromMs), explains a first value no page can move.
7049
7692
  * The ask lands where the kScript lane's lands: at the end of a gesture the run integrated under
7050
7693
  * (askWrunWarmupAtGestureEnd).
7051
7694
  */
7052
7695
  function askWrunWarmupBackfillIfOwed(args) {
7053
7696
  const { chartIndex, indicatorId, tc, meta, runResult, unsettledLanes } = args;
7054
- if (args.run !== null || isWrunWindowOwner(meta))
7697
+ const guardKey = overlayExecutionGuardKey(chartIndex, indicatorId);
7698
+ // This result supersedes any older one held on its sources.
7699
+ wrunWarmupAsksOnLanding.delete(guardKey);
7700
+ if (args.run !== null || isWrunWindowOwner(meta)) {
7701
+ args.onNoPage?.();
7055
7702
  return;
7703
+ }
7056
7704
  const text = (value) => (typeof value === 'string' ? value : undefined);
7057
7705
  const ringDetails = { lane: 'wrun' };
7058
7706
  if (unsettledLanes.size > 0)
@@ -7064,6 +7712,12 @@ function askWrunWarmupBackfillIfOwed(args) {
7064
7712
  ringDetails.declaredWarmupBars = declaredWarmupBars;
7065
7713
  if (declaredWarmupBars !== null && creditedBars > 0)
7066
7714
  ringDetails.warmupHeadCredit = creditedBars;
7715
+ // A declaration is trusted: rows that hold it and a bucket of slack and print nothing buy no page.
7716
+ const declaredWarmupCovered = declaredWarmupBars === null
7717
+ ? null
7718
+ : wrunDeclaredWarmupCovered(runRows, declaredWarmupBars, LOCAL_KSCRIPT_WARMUP_DECLARED_SLACK_BARS, creditedBars);
7719
+ if (declaredWarmupCovered !== null)
7720
+ ringDetails.declaredWarmupCovered = declaredWarmupCovered;
7067
7721
  // The result is the chart's only while the engine and the data generation the run read its
7068
7722
  // window under still stand. Checked before the ask, before each gesture retry, and again when
7069
7723
  // the lazily loaded loader is about to dispatch: a switch or a refetch can land while the
@@ -7071,32 +7725,126 @@ function askWrunWarmupBackfillIfOwed(args) {
7071
7725
  const isCurrent = () => wrunChartHostEnv().chart.instance(chartIndex) === tc &&
7072
7726
  getChartDataFetchGeneration(chartIndex) === args.planGeneration;
7073
7727
  const { lookbackBars } = args;
7074
- const ask = () => wrunChartHostEnv().chart.askWarmupBackfill({
7075
- chartIndex,
7076
- indicatorId,
7077
- tc,
7078
- chartMeta: {
7079
- exchange: text(args.chartMetadata?.exchange),
7080
- symbol: text(args.chartMetadata?.symbol),
7081
- interval: args.chartInterval,
7082
- },
7083
- readEvidence: () => ({
7084
- outputs: wrunWarmupEvidenceOutputs(runResult),
7085
- lookbackBars,
7086
- sourcesSettled: unsettledLanes.size === 0,
7087
- runWindowStartTs: args.runWindowStartTs,
7088
- declaredWarmupEndTs: declaredWarmupBars === null
7089
- ? null
7090
- : wrunDeclaredWarmupEndTs(runRows, declaredWarmupBars, intervalMs, creditedBars),
7091
- sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: serverNowMs() }),
7092
- }),
7093
- requestOlderHistory: wrunWarmupPageRequester(chartIndex, indicatorId, tc, isCurrent, ringDetails),
7094
- ringDetails,
7095
- isCurrent,
7096
- });
7097
7728
  // A wait outlives nothing: the overlay must still be the one this result painted when it ends.
7098
7729
  const isStillMounted = () => isWrunRunMountOnChart(chartIndex, { tc, meta });
7099
- askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, () => isCurrent() && isStillMounted(), ringDetails);
7730
+ const isAskCurrent = () => isCurrent() && isStillMounted();
7731
+ // Read at each ask: the ladder may turn a source terminal after this run settled.
7732
+ let landingAtAsk = [];
7733
+ const ask = () => {
7734
+ const outcome = wrunChartHostEnv().chart.askWarmupBackfill({
7735
+ chartIndex,
7736
+ indicatorId,
7737
+ tc,
7738
+ chartMeta: {
7739
+ exchange: text(args.chartMetadata?.exchange),
7740
+ symbol: text(args.chartMetadata?.symbol),
7741
+ interval: args.chartInterval,
7742
+ },
7743
+ readEvidence: () => {
7744
+ landingAtAsk = wrunWarmupLandingSources(guardKey);
7745
+ return {
7746
+ outputs: wrunWarmupEvidenceOutputs(runResult),
7747
+ lookbackBars,
7748
+ sourcesSettled: unsettledLanes.size === 0,
7749
+ sourcesLanding: landingAtAsk.length > 0,
7750
+ declaredWarmupCovered,
7751
+ runWindowStartTs: args.runWindowStartTs,
7752
+ declaredWarmupEndTs: declaredWarmupBars === null
7753
+ ? null
7754
+ : wrunDeclaredWarmupEndTs(runRows, declaredWarmupBars, intervalMs, creditedBars),
7755
+ sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: serverNowMs() }),
7756
+ };
7757
+ },
7758
+ requestOlderHistory: wrunWarmupPageRequester(chartIndex, indicatorId, tc, isCurrent, ringDetails),
7759
+ ringDetails,
7760
+ isCurrent,
7761
+ });
7762
+ // A host port may answer nothing at all (undefined), as the line below already reads it: both mean no decision.
7763
+ if (outcome != null && !outcome.requested && !WRUN_WARMUP_UNDECIDED_REASONS.has(outcome.reason)) {
7764
+ args.onNoPage?.();
7765
+ }
7766
+ if (outcome?.reason !== 'sources-pending' || landingAtAsk.length === 0)
7767
+ return;
7768
+ holdWrunWarmupAskOnLanding(guardKey, () => {
7769
+ if (isAskCurrent())
7770
+ askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, isAskCurrent, ringDetails);
7771
+ });
7772
+ wrunChartHostEnv().diagnostics.debug('local-kscript-warmup-backfill-held-for-sources', {
7773
+ chartIndex,
7774
+ indicatorId,
7775
+ ...ringDetails,
7776
+ landingSources: landingAtAsk,
7777
+ });
7778
+ };
7779
+ askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, isAskCurrent, ringDetails);
7780
+ }
7781
+ /** The decider's answers that buy no page yet decide nothing for the result: a source still landing (held, asked
7782
+ * again once it lands), a page of an earlier ask still in flight (its landing reruns the overlay), a view still moving
7783
+ * (the shared ask re-asks a few times). */
7784
+ const WRUN_WARMUP_UNDECIDED_REASONS = new Set([
7785
+ 'sources-pending',
7786
+ 'page-pending',
7787
+ 'gesture-active',
7788
+ ]);
7789
+ export function wrunWarmupPageVerdict() {
7790
+ let decided = false;
7791
+ let held;
7792
+ return {
7793
+ noPage: () => {
7794
+ if (decided)
7795
+ return;
7796
+ decided = true;
7797
+ const raise = held;
7798
+ held = undefined;
7799
+ raise?.();
7800
+ },
7801
+ whenNoPage: (raise) => {
7802
+ if (decided)
7803
+ raise();
7804
+ else
7805
+ held = raise;
7806
+ },
7807
+ };
7808
+ }
7809
+ /** The overlay's sources still landing in the degrade registry (`warmupSourceEntryLanding`), by name. */
7810
+ function wrunWarmupLandingSources(guardKey) {
7811
+ try {
7812
+ return wrunChartHostEnv()
7813
+ .chart.sourceDegradeEntries(guardKey)
7814
+ .filter(warmupSourceEntryLanding)
7815
+ .map((entry) => entry.sourceName);
7816
+ }
7817
+ catch {
7818
+ // A registry without the read door (a partial module mock): nothing reads as landing.
7819
+ return [];
7820
+ }
7821
+ }
7822
+ /**
7823
+ * The newest warm-up ask of each overlay held on a source still landing, by guard key: asked again once the degrade
7824
+ * registry shows none landing (a rung landed it, or the ladder gave it up), outside any run of the overlay, since a run
7825
+ * asks for itself. The ladder's last rung turns its sources terminal after its run settles, so without this the page a
7826
+ * visible warm-up owes is never bought.
7827
+ */
7828
+ const wrunWarmupAsksOnLanding = new Map();
7829
+ function holdWrunWarmupAskOnLanding(guardKey, reask) {
7830
+ wrunWarmupAsksOnLanding.set(guardKey, reask);
7831
+ try {
7832
+ wrunChartHostEnv().chart.onSourceDegradeChange(wrunWarmupLandingListener);
7833
+ }
7834
+ catch {
7835
+ // A registry without the listener door (a partial module mock): the overlay's next run asks again.
7836
+ }
7837
+ }
7838
+ /** The degrade registry's change listener for held warm-up asks (one stable function: re-subscribing is a no-op). */
7839
+ function wrunWarmupLandingListener(guardKey) {
7840
+ const reask = wrunWarmupAsksOnLanding.get(guardKey);
7841
+ if (reask === undefined || wrunRefusalRunsInFlight.has(guardKey))
7842
+ return;
7843
+ if (wrunWarmupLandingSources(guardKey).length > 0)
7844
+ return;
7845
+ wrunWarmupAsksOnLanding.delete(guardKey);
7846
+ // A registry reset (a teardown, a chart reset) leaves no entry: the reask's own checks see the overlay gone.
7847
+ setTimeout(reask, 0);
7100
7848
  }
7101
7849
  /**
7102
7850
  * The newest warm-up ask of each overlay that is waiting for a gesture to end: a full run that
@@ -7149,6 +7897,213 @@ function askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, isCurrent, ring
7149
7897
  ask();
7150
7898
  });
7151
7899
  }
7900
+ /**
7901
+ * The run reasons whose result waits for the gesture's idle edge before its commit checks and its install
7902
+ * (WRUN-PANBACK A1): the chart's own reruns (a live rebuild, a pan page, a range refresh, a heal, a source-recovery
7903
+ * rung, a budget lift). The deleted kScript engine held such a result until the idle edge (its worker's
7904
+ * `releaseHeldEngine`, at most KSCRIPT_GESTURE_HOLD_MAX_MS); a wrun install landed mid-drag instead (a 294 ms apply
7905
+ * inside a 190 s pan, 2026-11-01 dump). A run a person asked for (a settings save, a switch, a theme, a Resume, a
7906
+ * Retry), the mount's first run and the replay lane's never wait.
7907
+ */
7908
+ export const WRUN_GESTURE_HELD_RUN_REASONS = new Set([
7909
+ 'live-rebuild',
7910
+ 'lazy-range-refresh',
7911
+ 'loaded-range-refresh',
7912
+ 'history-range',
7913
+ 'heal',
7914
+ 'source-recovery',
7915
+ 'budget-lift',
7916
+ ]);
7917
+ /** How often a held install looks for a queued user run while it waits: the pan idle wait's own poll. */
7918
+ const WRUN_INSTALL_GESTURE_POLL_MS = 120;
7919
+ /**
7920
+ * Hold a finished run's install until the gesture's idle edge (WRUN-PANBACK A1), the way the warm-up ask waits
7921
+ * (`askWrunWarmupAtGestureEnd`): at once (`none`) for a reason that is not held or a chart whose gesture is not live;
7922
+ * else until the view stays still for GESTURE_LINGER_MS (`waitPanIdle`), bounded by `ceilingMs` (what the episode has
7923
+ * left of its one ceiling), and raced every WRUN_INSTALL_GESTURE_POLL_MS against a queued user run
7924
+ * (`hasQueuedWrunUserRun`): the run that follows replaces this result, so it yields (`yielded`) instead of making that
7925
+ * run wait out the pan. The idle wait answers the time it waited at the idle edge and at its bound alike, so an answer
7926
+ * within one poll of the bound reads `ceiling`. `waitedMs` is on the pacing clock. Rings the hold and its end; never
7927
+ * throws.
7928
+ */
7929
+ export async function holdWrunInstallForGesture(chartIndex, indicatorId, reason, { ceilingMs }) {
7930
+ const env = wrunChartHostEnv();
7931
+ if (!WRUN_GESTURE_HELD_RUN_REASONS.has(reason) || !env.chart.isGestureLive(chartIndex)) {
7932
+ return { waitedMs: 0, outcome: 'none' };
7933
+ }
7934
+ env.diagnostics.debug('wrun-install-held-for-gesture', { chartIndex, indicatorId, reason, ceilingMs });
7935
+ const startedAt = wrunHostClockMs();
7936
+ let poll;
7937
+ const yielded = new Promise((resolve) => {
7938
+ // Read from a timer: a queue that cannot be read (a spec's partial mock) holds no user run.
7939
+ const look = () => {
7940
+ if (readOptionalExport(() => hasQueuedWrunUserRun(indicatorId)) === true)
7941
+ resolve('yielded');
7942
+ else
7943
+ poll = setTimeout(look, WRUN_INSTALL_GESTURE_POLL_MS);
7944
+ };
7945
+ look();
7946
+ });
7947
+ const idle = env.chart
7948
+ .waitPanIdle(chartIndex, { idleMs: GESTURE_LINGER_MS, maxWaitMs: ceilingMs })
7949
+ // A wait that fails holds the install no longer: it reads as the bound.
7950
+ .catch(() => ceilingMs);
7951
+ const ended = await Promise.race([idle, yielded]);
7952
+ if (poll !== undefined)
7953
+ clearTimeout(poll);
7954
+ const outcome = ended === 'yielded' ? 'yielded' : ended >= ceilingMs - WRUN_INSTALL_GESTURE_POLL_MS ? 'ceiling' : 'idle';
7955
+ const waitedMs = Math.max(0, wrunHostClockMs() - startedAt);
7956
+ env.diagnostics.debug('wrun-install-gesture-ended', { chartIndex, indicatorId, reason, waitedMs, outcome });
7957
+ return { waitedMs, outcome };
7958
+ }
7959
+ /** The install hold's budget (WRUN-PANBACK A1, one ceiling per rebuild episode): HEAVY_APPLY_GESTURE_CEILING_MS less
7960
+ * what the episode already held (`gestureHeldMs`: the live tick's settle gate, a prefix page's own hold), never below
7961
+ * zero. A run without the field holds up to the full ceiling. */
7962
+ function wrunInstallGestureCeilingMs(gestureHeldMs) {
7963
+ const held = gestureHeldMs !== undefined && Number.isFinite(gestureHeldMs) ? Math.max(0, gestureHeldMs) : 0;
7964
+ return Math.max(0, HEAVY_APPLY_GESTURE_CEILING_MS - held);
7965
+ }
7966
+ /**
7967
+ * A whole run's result at the gesture's idle edge (`holdWrunInstallForGesture` under the run's own budget), held before
7968
+ * the integrate reads anything. Answers how long it held and how the hold ended (the write boundary,
7969
+ * `awaitWrunInstallWriteTurn`, holds no more after one that ran to its ceiling). A user run queued meanwhile supersedes
7970
+ * the result: it is dropped with the quiet superseded rejection (no titan write, no stand-in, no live context; the
7971
+ * caller releases what the run's ask opened) and the executor's follow-up runs the queued one.
7972
+ */
7973
+ async function awaitWrunInstallGestureEdge(target, reason) {
7974
+ const { chartIndex, indicatorId } = target;
7975
+ const hold = await holdWrunInstallForGesture(chartIndex, indicatorId, reason, {
7976
+ ceilingMs: wrunInstallGestureCeilingMs(target.gestureHeldMs),
7977
+ });
7978
+ if (hold.outcome === 'yielded') {
7979
+ wrunChartHostEnv().diagnostics.debug('wrun-install-yielded', { chartIndex, indicatorId, reason });
7980
+ throw new WrunChartGoneError(`wrun overlay '${indicatorId}' yielded its result to a queued user run (superseded)`);
7981
+ }
7982
+ return hold;
7983
+ }
7984
+ /**
7985
+ * The install's write boundary (WRUN-PANBACK-2 S1), after every await of its preparation: the chart's install turn
7986
+ * (`admitWrunInstall`), then the gesture read again. A held reason whose gesture went live while the turn waited holds
7987
+ * again (the bounded hold, on what the episode's ceiling has left after its holds and its turns) and takes a fresh turn
7988
+ * after it, while that budget lasts; with the budget spent (by the clock, or by a hold that ran to its ceiling: the idle
7989
+ * wait's own word) it writes, gesture or not. A user run queued meanwhile supersedes the result (`wrun-install-yielded`,
7990
+ * the quiet superseded rejection). Answers what the install held and was paced in all, `heldMs` counting the hold at
7991
+ * the idle edge (`edge`) too. The caller's current-state checks and its titan write follow with no await, so the write
7992
+ * lands in the task that took the turn.
7993
+ */
7994
+ async function awaitWrunInstallWriteTurn(target, reason, edge) {
7995
+ const { chartIndex, indicatorId } = target;
7996
+ const ceilingMs = wrunInstallGestureCeilingMs(target.gestureHeldMs);
7997
+ let heldMs = edge.waitedMs;
7998
+ let pacedMs = 0;
7999
+ let spent = edge.outcome === 'ceiling';
8000
+ for (;;) {
8001
+ pacedMs += (await admitWrunInstall(chartIndex, indicatorId, reason)).waitedMs;
8002
+ const budgetMs = ceilingMs - heldMs - pacedMs;
8003
+ if (spent ||
8004
+ !WRUN_GESTURE_HELD_RUN_REASONS.has(reason) ||
8005
+ budgetMs <= 0 ||
8006
+ !wrunChartHostEnv().chart.isGestureLive(chartIndex)) {
8007
+ return { heldMs, pacedMs };
8008
+ }
8009
+ const hold = await holdWrunInstallForGesture(chartIndex, indicatorId, reason, { ceilingMs: budgetMs });
8010
+ heldMs += hold.waitedMs;
8011
+ if (hold.outcome === 'yielded') {
8012
+ wrunChartHostEnv().diagnostics.debug('wrun-install-yielded', { chartIndex, indicatorId, reason });
8013
+ throw new WrunChartGoneError(`wrun overlay '${indicatorId}' yielded its result to a queued user run (superseded)`);
8014
+ }
8015
+ // A hold that waited nothing (the gesture ended before it began) leaves the turn just taken current.
8016
+ if (hold.outcome === 'none')
8017
+ return { heldMs, pacedMs };
8018
+ spent = hold.outcome === 'ceiling';
8019
+ }
8020
+ }
8021
+ /** A reader of the overlay's pause (`isWrunOverlayPaused`'s read) that answers in the caller's task: the store is loaded
8022
+ * once here, so an install's write boundary reads it with no await before its titan write. A store that cannot be read
8023
+ * reads as not paused. */
8024
+ async function wrunOverlayPausedReaderFor(chartIndex, indicatorId) {
8025
+ try {
8026
+ const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
8027
+ return () => {
8028
+ try {
8029
+ return useChartStore().isKScriptOverlayPaused(chartIndex, indicatorId) === true;
8030
+ }
8031
+ catch {
8032
+ return false;
8033
+ }
8034
+ };
8035
+ }
8036
+ catch {
8037
+ return () => false;
8038
+ }
8039
+ }
8040
+ /** The ring right before an install's titan write (WRUN-PANBACK A1): whether the gesture is live as the result lands,
8041
+ * how long its install held for it, and how long the install pacer held it after (`pacedMs`, WRUN-PANBACK-2 S1; 0
8042
+ * when it went at once). */
8043
+ function ringWrunInstallApplied(chartIndex, indicatorId, reason, heldMs, pacedMs) {
8044
+ wrunChartHostEnv().diagnostics.debug('wrun-install-applied', {
8045
+ chartIndex,
8046
+ indicatorId,
8047
+ reason,
8048
+ gestureLive: wrunChartHostEnv().chart.isGestureLive(chartIndex),
8049
+ heldMs,
8050
+ pacedMs,
8051
+ });
8052
+ }
8053
+ /**
8054
+ * A prefix page's commit at the gesture's idle edge (WRUN-PANBACK A1): the hold runs BEFORE the overlay's session lock
8055
+ * and `commit` runs synchronously at the lock's grant, so the commit stays one synchronous transaction. The lock can
8056
+ * wait on an async holder (a live block holds it across a worker call), so the gesture may start again between the
8057
+ * hold and the grant: a live gesture at the grant with budget left (`ceilingMs` less what the page held and was paced)
8058
+ * lets the lock go and the page waits again outside it; with the budget spent it commits. A user run queued meanwhile
8059
+ * yields: nothing commits. Each hold that did not yield takes the chart's install turn (`admitWrunInstall`,
8060
+ * WRUN-PANBACK-2 S1) before the lock is asked, so the lock is never held while the page waits for it; the lock may grant
8061
+ * long after the turn, so at the grant the page writes on it only while no other install of the chart was admitted
8062
+ * since (`wrunInstallLastAdmission`), else it lets the lock go and takes a fresh turn (while the budget lasts), and it
8063
+ * notes its write (`noteWrunInstallWrite`) so the chart's next turn counts its gap from the commit. `commit` receives how
8064
+ * long the page held and how long the pacer held it.
8065
+ */
8066
+ export async function commitWrunPrefixAtGestureEdge(chartIndex, indicatorId, reason, { ceilingMs }, commit) {
8067
+ let heldMs = 0;
8068
+ let pacedMs = 0;
8069
+ let resumes = 0;
8070
+ // A hold that ran to its ceiling spent the budget (the idle wait's own word), whatever the clock says.
8071
+ let spent = false;
8072
+ for (;;) {
8073
+ const hold = await holdWrunInstallForGesture(chartIndex, indicatorId, reason, {
8074
+ ceilingMs: Math.max(0, ceilingMs - heldMs - pacedMs),
8075
+ });
8076
+ heldMs += hold.waitedMs;
8077
+ if (hold.outcome === 'yielded')
8078
+ return { kind: 'yielded', heldMs };
8079
+ if (hold.outcome === 'ceiling')
8080
+ spent = true;
8081
+ pacedMs += (await admitWrunInstall(chartIndex, indicatorId, reason)).waitedMs;
8082
+ // The admission the page's turn stands on (the lock may grant long after it).
8083
+ const turn = wrunInstallLastAdmission(chartIndex);
8084
+ // A page goes back to wait only after its first hold or after a hold that waited: a hold that answered at once
8085
+ // right after the grant saw motion read the gesture otherwise in the same task, and looping on it would spin
8086
+ // without ever yielding to the page.
8087
+ const mayWaitAgain = resumes === 0 || hold.outcome !== 'none';
8088
+ const granted = await withWrunOverlaySessionLock(indicatorId, () => {
8089
+ // Read at the grant, in the same task as the commit, while the budget (its holds and its turns) lasts: motion
8090
+ // that resumed while the lock waited holds the page again, and another install that took the chart's turn
8091
+ // meanwhile sends the page to a fresh turn, both outside the lock.
8092
+ const budgetLeft = !spent && heldMs + pacedMs < ceilingMs;
8093
+ const gestureResumed = mayWaitAgain &&
8094
+ WRUN_GESTURE_HELD_RUN_REASONS.has(reason) &&
8095
+ wrunChartHostEnv().chart.isGestureLive(chartIndex);
8096
+ if (budgetLeft && (gestureResumed || wrunInstallLastAdmission(chartIndex) !== turn))
8097
+ return { resumed: true };
8098
+ // The write lands now, after the turn: the chart's next turn counts its gap from here.
8099
+ noteWrunInstallWrite(chartIndex);
8100
+ return { resumed: false, value: commit(heldMs, pacedMs) };
8101
+ });
8102
+ if (!granted.resumed)
8103
+ return { kind: 'committed', value: granted.value, heldMs };
8104
+ resumes += 1;
8105
+ }
8106
+ }
7152
8107
  /**
7153
8108
  * The page dispatch of the wrun lane's warm-up asks. The lazy loader is reached lazily:
7154
8109
  * data-fetching.util's graph pulls in the live feed and, through it, this lane (see the ask's module
@@ -7332,14 +8287,16 @@ function wrunRunOwnerLeft(owner, chartMetadata, marketIdentity) {
7332
8287
  }
7333
8288
  /** Whether the chart moved off what a run computed for while it ran: the
7334
8289
  * chart rebuilt at its index, the overlay remounted (a new meta), or another
7335
- * market or interval on the main series. */
7336
- async function wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity) {
8290
+ * market or interval on the main series. Read in the caller's task: the
8291
+ * market through a loaded reader (`wrunChartMetadataReaderFor`), so an
8292
+ * install's write boundary judges it with no await before its titan write. */
8293
+ function wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity, readChartMetadata) {
7337
8294
  if (wrunChartHostEnv().chart.instance(chartIndex) !== tc)
7338
8295
  return true;
7339
8296
  const mounted = tc.metadata;
7340
8297
  if (Array.isArray(mounted) && !mounted.includes(meta))
7341
8298
  return true;
7342
- return wrunChartMarketIdentity(await wrunChartMetadataFor(chartIndex)) !== marketIdentity;
8299
+ return wrunChartMarketIdentity(readChartMetadata()) !== marketIdentity;
7343
8300
  }
7344
8301
  /** Replay took the chart while a run computed: its replay lane owns the
7345
8302
  * rows (it blanked the overlay and reopens it over the replay's bars; the
@@ -7446,7 +8403,11 @@ export function wrunReplayRunBars(runBars, chartRows, cutoffTs, run, chartInterv
7446
8403
  * (pinForThisSession falls back to an older official while the row keeps the
7447
8404
  * newer pin) would store that version's picture under the pin's key, so it
7448
8405
  * stores nothing (`version-mismatch`; the next boot misses, the safe
7449
- * outcome). The stand-in util judges the rest (the live edge on the candles
8406
+ * outcome). Never a run that read CME off a CME chart (`cme-pin`: its own CME
8407
+ * mark, a pinned CME market the judge admitted on a crypto chart, whoever wrote
8408
+ * the run): the store outlives the viewer's CME access, which the run's judge
8409
+ * decides at each run; the stand-in util refuses the overlay's CME stamp alike.
8410
+ * The stand-in util judges the rest (the live edge on the candles
7450
8411
  * and run bar this hands it, a partial picture stored marked, a child overlay
7451
8412
  * never).
7452
8413
  * Advisory: a refusal or a failure stores nothing. Each of the run's own
@@ -7478,6 +8439,8 @@ async function writeWrunStandIn(args) {
7478
8439
  return refuse('window-partial');
7479
8440
  if (args.firstSlice === true)
7480
8441
  return refuse('first-slice');
8442
+ if (args.readsCme === true && !payloadTouchesCmeVenue(args.chartMetadata?.exchange))
8443
+ return refuse('cme-pin');
7481
8444
  if (args.executedVersion !== undefined && args.executedVersion !== identity.version) {
7482
8445
  return refuse('version-mismatch');
7483
8446
  }
@@ -7610,8 +8573,9 @@ function isWrunFormingOpenWire(wire) {
7610
8573
  * to carry, so an empty lane refuses loud); a package whose every funding
7611
8574
  * input declares `missing: "nan"` or `"zero"` reads its fill on markets
7612
8575
  * without funding and the lane stays quiet, like oi. */
7613
- export function wrunFundingLaneRequired(metadata) {
7614
- return wrunLaneRowsRequired(metadata, (_input, source) => source.source === 'funding');
8576
+ export function wrunFundingLaneRequired(metadata, lane) {
8577
+ // One funding lane's readers: the chart's own lane's (no pin), or one pinned lane's (U9e, `lane`).
8578
+ return wrunLaneRowsRequired(metadata, (_input, source) => source.source === 'funding' && wrunPinnedLaneOfSource(source) === lane);
7615
8579
  }
7616
8580
  function wrunInputNameAt(metadata, index) {
7617
8581
  return metadata.inputs.find((input) => input.index === index)?.name ?? String(index);
@@ -7626,6 +8590,44 @@ function wrunEvaluatedMainTail(ohlcvRows) {
7626
8590
  tail.push(Array.from(ohlcvRows[at]));
7627
8591
  return tail;
7628
8592
  }
8593
+ /** The leg records the live tick writes by key (its leg answer merge and its live candle refresh). */
8594
+ const WRUN_KEYED_LEG_SOURCES = ['pinnedCandleRows', 'pinnedLiveCandleRows', 'intrabarRows'];
8595
+ /** A combined build's carry with what it read (above), taken in the build's own synchronous block. */
8596
+ function wrunCarryAtBuildOf(built, ohlcvRows, sources) {
8597
+ if (built === undefined)
8598
+ return undefined;
8599
+ const legBuffers = WRUN_KEYED_LEG_SOURCES.flatMap((field) => {
8600
+ const record = sources[field];
8601
+ return record === undefined ? [] : [[record, Object.entries(record)]];
8602
+ });
8603
+ return { carry: built.carry, mainTail: wrunEvaluatedMainTail(ohlcvRows), legBuffers };
8604
+ }
8605
+ /**
8606
+ * The carry built with the rows, while nothing it rests on moved since the build: every closed candle of the
8607
+ * evaluated tail reads the same under the drain's comparison (`wrunCandleEqual`, the same stamps), and every leg
8608
+ * record holds the arrays it held. Else undefined: the install advances the carry from the empty seed over the
8609
+ * sources as the awaits left them, the two steps exactly, and the drain's next comparison starts from the same rows.
8610
+ */
8611
+ function wrunCarryAtBuildStill(atBuild, ohlcvRows) {
8612
+ if (atBuild === undefined)
8613
+ return undefined;
8614
+ const tail = wrunEvaluatedMainTail(ohlcvRows);
8615
+ if (tail.length !== atBuild.mainTail.length)
8616
+ return undefined;
8617
+ for (let at = 0; at < tail.length; at += 1) {
8618
+ const built = atBuild.mainTail[at];
8619
+ if (tail[at][0] !== built[0] || !wrunCandleEqual(built, tail[at]))
8620
+ return undefined;
8621
+ }
8622
+ for (const [record, entries] of atBuild.legBuffers) {
8623
+ if (Object.keys(record).length !== entries.length)
8624
+ return undefined;
8625
+ for (const [key, rows] of entries)
8626
+ if (record[key] !== rows)
8627
+ return undefined;
8628
+ }
8629
+ return atBuild.carry;
8630
+ }
7629
8631
  /** The volume-profile block size the history lane computed on: the metadata
7630
8632
  * block size for the chart's market, resolved through the same service
7631
8633
  * K_VOLUME_PROFILE's getReqPayload resolves it (its private
@@ -7898,8 +8900,14 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7898
8900
  });
7899
8901
  }
7900
8902
  // The reseed's own clock: the legs re-align as-of the server's now over the
7901
- // buffers (a candle that closed since the last build is admitted by it).
7902
- const clock = { intervalMs: context.intervalMs, nowMs: serverNowMs() };
8903
+ // buffers (a candle that closed since the last build is admitted by it), each
8904
+ // declared depth still counted back from the session's as-of (its first run's
8905
+ // now, wrun-history-as-of.util), so the rebuilt rows keep the blocks they had.
8906
+ const clock = {
8907
+ intervalMs: context.intervalMs,
8908
+ nowMs: serverNowMs(),
8909
+ historyAsOfMs: context.historyAsOfMs,
8910
+ };
7903
8911
  const sourceRows = {
7904
8912
  ohlcvRows,
7905
8913
  bookRows: context.bookRows,
@@ -7923,6 +8931,8 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7923
8931
  tradeLegRows: context.tradeLegRows,
7924
8932
  // Each trades leg's rows ride the tier its acquisition names (the full run's ask, the intake's fold).
7925
8933
  tradeLegIntervals: wrunTradeLegIntervals(context.acquisition),
8934
+ // The pinned lanes (U9e): each foreign ask reads the lane of its market.
8935
+ pinnedLaneRows: context.pinnedLaneRows,
7926
8936
  pinnedCandleRows: context.pinnedCandleRows,
7927
8937
  // Each grid leg asked at a tier rides it (the full run's records).
7928
8938
  pinnedLegTierMs: wrunPinnedLegTierMs(context.pinnedLegs),
@@ -7972,8 +8982,24 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7972
8982
  delete context.laneWarmupHead;
7973
8983
  const headRows = reseedHead?.rows ?? laneReseedHead;
7974
8984
  const computeOhlcvRows = headRows !== undefined && headRows.length > 0 ? wrunChartCandleRowsAfterHead(headRows, sessionRows) : ohlcvRows;
7975
- const computeSourceRows = computeOhlcvRows === ohlcvRows ? sourceRows : { ...sourceRows, ohlcvRows: computeOhlcvRows };
7976
- const rows = buildWrunInputRows(context.metadata, computeSourceRows, clock);
8985
+ // The host session's composition, as the full run reads it (wrun-session-composition.util): the reseed rebuilds
8986
+ // over the buffers composed as the session stands now, so an owner change since the run lands on every bar.
8987
+ const composition = composeWrunSessionSources({
8988
+ chartIndex: context.chartIndex,
8989
+ indicatorId,
8990
+ intervalMs: clock.intervalMs,
8991
+ lanes: wrunSessionLanesOfContext(context),
8992
+ }, computeOhlcvRows === ohlcvRows ? sourceRows : { ...sourceRows, ohlcvRows: computeOhlcvRows });
8993
+ const computeSourceRows = composition.sources;
8994
+ // On the host's `carryWithBuild` (web: the engine arm `webkit-wrun-carry-with-build`) the rows and the carry the
8995
+ // session takes below come from one conversion of the window's lanes, here: the carry then rests on the buffers as
8996
+ // they stand here, as the outputs and the lane revisions read below do. Else the carry is advanced after the
8997
+ // worker answered, from the empty seed, converting the window again.
8998
+ const builtWithCarry = wrunHostCarryWithBuild()
8999
+ ? buildWrunInputRowsAndCarry(context.metadata, computeSourceRows, clock)
9000
+ : undefined;
9001
+ const carryAtBuild = wrunCarryAtBuildOf(builtWithCarry, ohlcvRows, computeSourceRows);
9002
+ const rows = builtWithCarry?.rows ?? buildWrunInputRows(context.metadata, computeSourceRows, clock);
7977
9003
  if (rows.length === 0)
7978
9004
  return 'skipped';
7979
9005
  // The lane revisions these rows already read (wrun-prefix-lanes.util): once the outputs are committed below they
@@ -7990,6 +9016,8 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7990
9016
  // under the previous one still belong to these buffers.
7991
9017
  const generation = nextWrunOverlayLiveGeneration(indicatorId);
7992
9018
  context.generation = generation;
9019
+ // The reopen below opens the worker's series under it.
9020
+ context.seriesEpoch = generation;
7993
9021
  adoptWrunLiveIntakeGeneration(indicatorId, generation);
7994
9022
  // The chart names this session's text will read, resolved beside the
7995
9023
  // reopen and awaited BEFORE the post-start rechecks below (a context the
@@ -8087,7 +9115,12 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8087
9115
  }
8088
9116
  else
8089
9117
  delete context.retained;
8090
- context.carrySeed = advanceWrunInputCarry(context.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock);
9118
+ // The built carry while nothing it read moved during the awaits (a closed candle folded in place, a leg answer
9119
+ // merged), else the advance over the sources as they stand now, as without the switch (counted under `recovered`):
9120
+ // the evaluated tail below reads them now too.
9121
+ context.carrySeed =
9122
+ wrunCarryAtBuildStill(carryAtBuild, ohlcvRows) ??
9123
+ advanceWrunInputCarry(context.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock, carryAtBuild === undefined ? 'advance' : 'recovered');
8091
9124
  // The reopened guest's evidence and warmth (D2, D4), an exact warm-up session's alone: every candle it
8092
9125
  // evaluated, the head included, when it ran the head; a cold reopen drops all three (the head no longer
8093
9126
  // precedes what the session landed, and its rows rest on no running start).
@@ -8108,11 +9141,19 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8108
9141
  delete context.warmupHead;
8109
9142
  delete context.candleEvidence;
8110
9143
  }
8111
- context.dirtyFromTs = null;
9144
+ // Every bar was evaluated again from the buffers, so nothing is owed: unless the host's session changed owner
9145
+ // while the session reopened, whose revision (reviseWrunOverlayLiveFrom, from the old seam) these rows never
9146
+ // read. It stays owed, and the drain keeps its closed-bar revision (it clears only what this left null).
9147
+ if (wrunReseedServedComposition(indicatorId, context, composition.token))
9148
+ context.dirtyFromTs = null;
8112
9149
  context.evaluatedMainTail = wrunEvaluatedMainTail(ohlcvRows);
8113
9150
  if (runSession)
8114
9151
  runSession.lastSentRow = wrunRunIntervalSentRow(rows[rows.length - 1]);
8115
9152
  rememberWrunSessionChartNames(context, chartNames);
9153
+ // The reopened guest's memory, as its live-start reported it (a warm switch's park counts it).
9154
+ const reopened = wrunWorkerMemoryOf(outputRows).workerMemoryBytes;
9155
+ if (reopened !== undefined)
9156
+ context.workerMemoryBytes = reopened;
8116
9157
  // Exactly one reseed note per reopened session, plus its first snapshot.
8117
9158
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'reseed' });
8118
9159
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'session-start', live: wrunLiveOf(outputRows) });
@@ -8147,7 +9188,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8147
9188
  fills: context.fills,
8148
9189
  candles: context.candles,
8149
9190
  chartNames,
8150
- legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
9191
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, undefined, context.cmeDelayed),
8151
9192
  ...wrunResultMarketUnits(context.market),
8152
9193
  ...(runSession
8153
9194
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
@@ -8195,6 +9236,21 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8195
9236
  }))
8196
9237
  : null;
8197
9238
  context.runHealthWarned = await publishWrunRunHealth(context.chartIndex, indicatorId, wrunRunHealthRowsFor(health, context.draft === true, nothingReady));
9239
+ // The viewer's nothing-drawn note follows the reseed like the health rows (FB27): the session's whole window,
9240
+ // unless the reseed was clamped to a window of it or the session's run read a source that is absent here.
9241
+ await publishWrunNothingDrawn(context.chartIndex, indicatorId, {
9242
+ draft: context.draft === true,
9243
+ settled: clamped === undefined && wrunSessionSourceAbsent.get(context) !== true,
9244
+ metadata: context.metadata,
9245
+ rows: outputRows,
9246
+ drawings: wrunHandlesOf(outputRows)?.length,
9247
+ runIntervalMs: runSession?.run?.intervalMs ?? context.intervalMs,
9248
+ }, async () => wrunRefusalContextFor({
9249
+ title: context.title,
9250
+ metadata: context.metadata,
9251
+ settings: meta.settings,
9252
+ chartMetadata: await wrunChartMetadataFor(context.chartIndex),
9253
+ }));
8198
9254
  context.paintedThroughTs = lastRowTs;
8199
9255
  context.repaintOwed = false;
8200
9256
  // The session drew its whole window again: an unanswered drop's run deadline (and a surface it already handed
@@ -8239,20 +9295,27 @@ const WRUN_SOURCE_LANE_ORDER = [
8239
9295
  * with a thunk, then the trades leg lanes and the registry poll lane instances by their ids. */
8240
9296
  function wrunDispatchedLaneIds(thunks) {
8241
9297
  const lanes = new Set(WRUN_SOURCE_LANE_ORDER.filter((lane) => typeof thunks[lane] === 'function'));
8242
- for (const [lane] of [...(thunks.tradeLegs ?? []), ...(thunks.pollLanes ?? []), ...(thunks.rowLanes ?? [])]) {
9298
+ for (const [lane] of [
9299
+ ...(thunks.tradeLegs ?? []),
9300
+ ...(thunks.pinnedLanes ?? []),
9301
+ ...(thunks.pollLanes ?? []),
9302
+ ...(thunks.rowLanes ?? []),
9303
+ ]) {
8243
9304
  lanes.add(lane);
8244
9305
  }
8245
9306
  return lanes;
8246
9307
  }
8247
9308
  /** A lane's place in declaration order: the row builder's own lanes in their order, then the trades leg lanes, the
8248
- * registry poll lanes and the row lanes. */
9309
+ * pinned lanes, the registry poll lanes and the row lanes. */
8249
9310
  function wrunSourceLaneRank(lane) {
8250
9311
  const builtin = WRUN_SOURCE_LANE_ORDER.indexOf(lane);
8251
9312
  if (builtin >= 0)
8252
9313
  return builtin;
8253
9314
  if (isWrunTradesLegLane(lane))
8254
9315
  return WRUN_SOURCE_LANE_ORDER.length;
8255
- return WRUN_SOURCE_LANE_ORDER.length + (isWrunRowLaneId(lane) ? 2 : 1);
9316
+ if (isWrunPinnedLaneId(lane))
9317
+ return WRUN_SOURCE_LANE_ORDER.length + 1;
9318
+ return WRUN_SOURCE_LANE_ORDER.length + (isWrunRowLaneId(lane) ? 3 : 2);
8256
9319
  }
8257
9320
  /**
8258
9321
  * The lane runs of one run's groups (`scheduleWrunLaneGroups`: the lanes known at the plan, then each group as its
@@ -8263,10 +9326,13 @@ function wrunSourceLaneRank(lane) {
8263
9326
  export function mergeWrunSourceLaneRuns(runs) {
8264
9327
  const merged = { results: {}, outcomes: [], degraded: [] };
8265
9328
  for (const run of runs) {
8266
- const { tradeLegRows, pollLaneRows, rowLaneRows, ...builtin } = run.results;
9329
+ const { tradeLegRows, pinnedLaneRows, pollLaneRows, rowLaneRows, ...builtin } = run.results;
8267
9330
  Object.assign(merged.results, builtin);
8268
9331
  if (tradeLegRows !== undefined)
8269
9332
  merged.results.tradeLegRows = { ...merged.results.tradeLegRows, ...tradeLegRows };
9333
+ if (pinnedLaneRows !== undefined) {
9334
+ merged.results.pinnedLaneRows = { ...merged.results.pinnedLaneRows, ...pinnedLaneRows };
9335
+ }
8270
9336
  if (pollLaneRows !== undefined)
8271
9337
  merged.results.pollLaneRows = { ...merged.results.pollLaneRows, ...pollLaneRows };
8272
9338
  if (rowLaneRows !== undefined)
@@ -8423,7 +9489,13 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
8423
9489
  const run = thunks[lane];
8424
9490
  return typeof run === 'function' ? [[lane, run]] : [];
8425
9491
  });
8426
- const declared = [...builtin, ...(thunks.tradeLegs ?? []), ...(thunks.pollLanes ?? []), ...(thunks.rowLanes ?? [])];
9492
+ const declared = [
9493
+ ...builtin,
9494
+ ...(thunks.tradeLegs ?? []),
9495
+ ...(thunks.pinnedLanes ?? []),
9496
+ ...(thunks.pollLanes ?? []),
9497
+ ...(thunks.rowLanes ?? []),
9498
+ ];
8427
9499
  const filling = new Set();
8428
9500
  const settled = await Promise.allSettled(declared.map(([lane, run]) => {
8429
9501
  const laneBudgetMs = typeof policy.budgetMs === 'function' ? policy.budgetMs(lane) : policy.budgetMs;
@@ -8482,6 +9554,8 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
8482
9554
  run.results[lane] = outcome.rows;
8483
9555
  else if (isWrunTradesLegLane(lane))
8484
9556
  (run.results.tradeLegRows ??= {})[lane] = outcome.rows;
9557
+ else if (isWrunPinnedLaneId(lane))
9558
+ (run.results.pinnedLaneRows ??= {})[lane] = outcome.rows;
8485
9559
  else if (isWrunRowLaneId(lane))
8486
9560
  (run.results.rowLaneRows ??= {})[lane] = outcome.rows;
8487
9561
  else
@@ -8577,6 +9651,12 @@ function wrunLaneSourceOf(lane, pollLanes) {
8577
9651
  const { kType, label } = WRUN_DEGRADABLE_LANE_SOURCES[leg.lane];
8578
9652
  return { kType, label: `${label} on ${leg.exchange} ${leg.symbol}` };
8579
9653
  }
9654
+ // A pinned lane (U9e): its class's lane, labelled with the market it reads.
9655
+ const pinned = wrunPinnedLaneOf(lane);
9656
+ if (pinned !== undefined) {
9657
+ const { kType, label } = WRUN_DEGRADABLE_LANE_SOURCES[pinned.cls];
9658
+ return { kType, label: `${label} on ${pinned.exchange} ${pinned.symbol}` };
9659
+ }
8580
9660
  const instance = pollLanes.find((candidate) => candidate.key === lane);
8581
9661
  // A poll lane instance, or a row lane's (its descriptor names its K type and label the same way).
8582
9662
  const pollLane = instance ? (wrunPollLaneByKey(instance.laneKey) ?? wrunRowLaneByKey(instance.laneKey)) : undefined;
@@ -8595,6 +9675,25 @@ function wrunLaneReadByNanInputsOnly(metadata, lane, pollLanes) {
8595
9675
  return !reads || wrunInputReadsFillOverEmptyLane(input, source);
8596
9676
  });
8597
9677
  }
9678
+ /** The row-builder class a refusal by name says the market does not serve (`nothing-served`), else undefined. */
9679
+ function wrunLaneUnservedClassOf(lane, error) {
9680
+ const code = wrunLaneRefusedCodeOf(error);
9681
+ if (code === undefined || !Object.hasOwn(WRUN_LANE_REFUSALS, code) || WRUN_LANE_REFUSALS[code] !== 'nothing-served') {
9682
+ return undefined;
9683
+ }
9684
+ const cls = wrunPinnedLaneOf(lane)?.cls ?? lane;
9685
+ return WRUN_SOURCE_LANE_ORDER.includes(cls) ? cls : undefined;
9686
+ }
9687
+ /** Whether the run draws over a degraded lane: an unserved one by the capability rule, else the honest picture. */
9688
+ function wrunDegradedLaneDrawable(metadata, lane, outcome, pollLanes) {
9689
+ const unserved = wrunLaneUnservedClassOf(lane, outcome.error);
9690
+ if (unserved === undefined)
9691
+ return wrunLaneReadByNanInputsOnly(metadata, lane, pollLanes);
9692
+ return metadata.inputs.every((input) => {
9693
+ const source = metadata.inputSources[input.name];
9694
+ return wrunSourceLane(source) !== lane || wrunInputDrawsWithoutLane(unserved, input, source);
9695
+ });
9696
+ }
8598
9697
  /** A degraded lane's words: its own sentence (an empty answer's), else the same sentence naming
8599
9698
  * the budget or the failure. The hold's message and the terminal record's details. */
8600
9699
  function wrunLaneDegradeMessage(title, source, outcome) {
@@ -8670,10 +9769,11 @@ function wrunOptionsChainExtrasGoverned(extras) {
8670
9769
  * fetch; two inputs must agree on one chain. The chart's chain and each word's
8671
9770
  * decision are the ones every chain class reads (opra-option-lanes.util
8672
9771
  * `resolveWrunChartChain`, `decideWrunLaneChainIdentity`), so the
8673
- * `option_surface` lane reads the same venue. `official` is the overlay's
8674
- * provenance (the wall's door read it): `auto` reads an OPRA chain for an
9772
+ * `option_surface` lane reads the same venue. `facts` are the run's plane
9773
+ * facts (the wall's door read them): `auto` reads an OPRA chain for an
8675
9774
  * OpenMarket package, and for a run `opraUserScripts` says the
8676
- * `opra-user-scripts` flag opened the plane to. A governed identity carries
9775
+ * `opra-user-scripts` flag opened the plane to; a CME chain by the chain
9776
+ * wall's `mayReadCmeChain`. A governed identity carries
8677
9777
  * the tier the viewer is served now (`governedOptionSummaryTier`, the
8678
9778
  * routing's own rule: the lane's acquisition names it and the legend follows
8679
9779
  * it). Returns the lane's payload extras (`chain*` fields).
@@ -8708,7 +9808,7 @@ function wrunOptionsChainExtrasGoverned(extras) {
8708
9808
  * user script; a pinned crypto word still reads that venue's chain of the
8709
9809
  * coin). Without a decision the chart's own market reads exactly as before.
8710
9810
  */
8711
- async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts, paramValues, options, cmeUserStudy = false) {
9811
+ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, facts, paramValues, options) {
8712
9812
  const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues }, { WRUN_OPTION_VIEWS_ONE_ASK_CODE, WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE, wrunHeldOpraPlaneChain, wrunOptionsChainImplicitViewFields, wrunOptionViewLaneFields, wrunOptionViewsOfSource, wrunOptionViewsUnion, }, { wrunUnderlyingOptionsChainDecision },] = await Promise.all([
8713
9813
  import('./sources/opra-option-lanes.util.js'),
8714
9814
  wrunChartHostEnv().market.loadDeribitOptions(),
@@ -8748,7 +9848,7 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
8748
9848
  let resolved;
8749
9849
  for (const input of chainInputs) {
8750
9850
  const source = metadata.inputSources[input.name];
8751
- const who = { ...chartMarket, inputName: input.name, official, opraUserScripts, marketLabel };
9851
+ const who = { ...chartMarket, inputName: input.name, ...facts, marketLabel };
8752
9852
  // The ONE venue decision every chain class reads (`decideWrunLaneChainIdentity`), so a package reading
8753
9853
  // `option_surface` beside the chain reads one venue; over another root's chain for an `underlying` root.
8754
9854
  const decision = (await wrunUnderlyingOptionsChainDecision(source, who, metadata.params ?? [], paramValues, chain)) ?? decideWrunLaneChainIdentity({ chain, cryptoVenues, deribitListed: hasDeribitOptions }, source.venue, who);
@@ -8764,13 +9864,12 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
8764
9864
  if (resolved === undefined)
8765
9865
  throw new Error(`WRUN ${metadata.id}: no options_chain input to resolve a chain for`);
8766
9866
  const { identity } = resolved;
8767
- // The CME chain wall of every chain lane (`assertWrunLaneChainPlaneReadable`), here too: a CME chain is CME options
8768
- // data, OpenMarket's own whatever the `cme-user-scripts` gate says. Before that gate no run but a first-party one
8769
- // reached a CME chart's chain (the display wall refused every other at the head); the runs the gate brings there
8770
- // (`cmeUserStudy`, a browser user run) read their chart's futures data, never CME options data (no implied
8771
- // expansion), refused by name before any fetch with the wall's own words and record.
8772
- if (identity.venue === 'cme' && cmeUserStudy) {
8773
- assertWrunLaneChainPlaneReadable('cme', identity.exchange, { official, opraUserScripts }, { inputName: resolved.inputName, sourceClass: 'options_chain' });
9867
+ // Every CME identity meets the chain lanes' one CME chain wall by the run's facts, before any fetch.
9868
+ if (identity.venue === 'cme') {
9869
+ assertWrunLaneChainPlaneReadable('cme', identity.exchange, facts, {
9870
+ inputName: resolved.inputName,
9871
+ sourceClass: 'options_chain',
9872
+ });
8774
9873
  }
8775
9874
  const laneInputs = chainInputs.map((input) => ({
8776
9875
  expiries: wrunOptionsChainExpiries(metadata.inputSources[input.name]?.expiries),
@@ -8861,15 +9960,45 @@ async function wrunOpraProvenanceWriter(chartIndex, indicatorId, ownership) {
8861
9960
  return true;
8862
9961
  };
8863
9962
  }
9963
+ /**
9964
+ * The tape provenance of the `stocks` row lanes a sheet declares (governed: 'stocks', the `dark_pool` lane), synced on
9965
+ * the overlay's settings through the host's provenance module (web: titan-charts' per-source tape sync, the one the
9966
+ * chart's fetch door runs for a tape read): each lane, by its lane key, names the tape its planned instance reads, or
9967
+ * none when the plan holds no instance of it. Written only while the run is the overlay's (`isCurrent`); a host that
9968
+ * binds no writer keeps no stamp. A sheet that declares no `stocks` lane loads nothing.
9969
+ */
9970
+ async function syncWrunStocksLaneProvenance(chartIndex, indicatorId, metadata, rowLanes, isCurrent) {
9971
+ const lanes = new Map();
9972
+ for (const input of metadata.inputs) {
9973
+ const lane = wrunRowLaneOfClass(metadata.inputSources[input.name]?.source);
9974
+ if (lane?.governed === 'stocks')
9975
+ lanes.set(lane.laneKey, lane);
9976
+ }
9977
+ if (lanes.size === 0)
9978
+ return;
9979
+ try {
9980
+ const provenance = await wrunChartHostEnv().chart.loadOptionsOverlayProvenance();
9981
+ if (provenance.setOverlayStockTapeProvenance === undefined || !isCurrent())
9982
+ return;
9983
+ for (const lane of lanes.values()) {
9984
+ const instance = rowLanes.find((candidate) => candidate.laneKey === lane.laneKey);
9985
+ provenance.setOverlayStockTapeProvenance(chartIndex, indicatorId, lane.laneKey, instance === undefined ? null : wrunRowLaneStocksTapeOf(lane, instance.extras));
9986
+ }
9987
+ }
9988
+ catch {
9989
+ // The stamp stands until a later run can write it: withholding is the safe direction.
9990
+ }
9991
+ }
8864
9992
  /** A run target whose sheet is the sheet on the chart's market (wrunChartSizeUnit): a lane's
8865
9993
  * `currency: "Auto"` reads the unit it resolves to there (wrunSheetWithLaneCurrencies), an input
8866
- * whose `needed_by` leaves the market's size unit out is not demanded (wrunSheetWithLaneDemand), and
8867
- * neither is a `candles` lane its `chart_interval_below` gates off on the chart's interval
8868
- * (wrunSheetWithLaneGate, the kit's rule off the shared host, which the caller loads first; an
8869
- * unknown interval gates nothing). The target itself when none of them changes the sheet. */
8870
- function wrunRunTargetOnMarket(target, chartMetadata, coinLegs) {
9994
+ * whose `needed_by` leaves the market's size unit out, or names a setting whose value `settings` do
9995
+ * not list (C-COINS item 1), is not demanded (wrunSheetWithLaneDemand), and neither is a `candles`
9996
+ * lane its `chart_interval_below` gates off on the chart's interval (wrunSheetWithLaneGate, the kit's
9997
+ * rule off the shared host, which the caller loads first; an unknown interval gates nothing). The
9998
+ * target itself when none of them changes the sheet. */
9999
+ function wrunRunTargetOnMarket(target, chartMetadata, settings, coinLegs) {
8871
10000
  const sizeUnit = wrunChartSizeUnit(chartMetadata);
8872
- const metadata = wrunSheetWithLaneGate(wrunSheetWithLaneDemand(wrunSheetWithLaneCurrencies(wrunSheetWithCoinLegs(target.metadata, coinLegs), sizeUnit), sizeUnit), wrunChartIntervalMsOf(chartMetadata?.interval));
10001
+ const metadata = wrunSheetWithLaneGate(wrunSheetWithLaneDemand(wrunSheetWithLaneCurrencies(wrunSheetWithCoinLegs(target.metadata, coinLegs), sizeUnit), sizeUnit, settings), wrunChartIntervalMsOf(chartMetadata?.interval));
8873
10002
  return metadata === target.metadata ? target : { ...target, metadata };
8874
10003
  }
8875
10004
  /**
@@ -8888,7 +10017,7 @@ async function resolveWrunCoinLegs(sheet, chartMetadata, settings) {
8888
10017
  if (wrunCoinLegVenues(sheet).length === 0)
8889
10018
  return undefined;
8890
10019
  const values = wrunParamValuesFromSettings(sheet, settings);
8891
- const read = Object.entries(wrunSheetWithLaneDemand(sheet, wrunChartSizeUnit(chartMetadata)).inputSources).filter(([, source]) => source !== undefined &&
10020
+ const read = Object.entries(wrunSheetWithLaneDemand(sheet, wrunChartSizeUnit(chartMetadata), settings).inputSources).filter(([, source]) => source !== undefined &&
8892
10021
  source.undemanded !== true &&
8893
10022
  wrunInputGateOn(source, typeof source.when === 'string' ? values[source.when] : undefined));
8894
10023
  const venues = wrunCoinLegVenues({ inputSources: Object.fromEntries(read) });
@@ -9186,6 +10315,13 @@ applied) {
9186
10315
  catch (error) {
9187
10316
  console.warn(`[wrun] latest values publish failed for '${indicatorId}' (chart ${chartIndex}):`, error);
9188
10317
  }
10318
+ // A viewer's nothing-drawn note stands until the chart draws: this integrate's rows lower it when they do.
10319
+ try {
10320
+ lowerWrunNothingDrawnOnDraw(chartIndex, indicatorId, metadata, outputRows);
10321
+ }
10322
+ catch (error) {
10323
+ console.warn(`[wrun] nothing-drawn note failed for '${indicatorId}' (chart ${chartIndex}):`, error);
10324
+ }
9189
10325
  // The run reached the chart: a registry Indicator is marked seen (never throws, a set lookup once noted).
9190
10326
  wrunChartHostEnv().diagnostics.noteRegistryRun(chartIndex, indicatorId, settings);
9191
10327
  }
@@ -9422,7 +10558,7 @@ async function reintegrateWrunSession(indicatorId, context, fill, current, optio
9422
10558
  fills: context.fills,
9423
10559
  candles: context.candles,
9424
10560
  chartNames,
9425
- legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
10561
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, undefined, context.cmeDelayed),
9426
10562
  ...wrunResultMarketUnits(context.market),
9427
10563
  ...(runSession
9428
10564
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
@@ -9467,27 +10603,28 @@ async function reintegrateWrunSession(indicatorId, context, fill, current, optio
9467
10603
  * A repaint of the mounted session under a new sheet: the style-only save's
9468
10604
  * door (wrun-style-patch.util) for the paint its in-place plot patch cannot
9469
10605
  * reach. A `skip` target's Visible row (the selection builds the target again
9470
- * from the session's rows, whose frames the module writes whatever the sheet
9471
- * hides, or leaves it out), the colour of a level, a renderer or a batched
9472
- * section, a band, a fill, a box, a segment, and every look the adapter
9473
- * derives from an output's colour. The caller swaps the new sheet into the
9474
- * context first (`context.metadata`); this integrates the session's own rows
9475
- * and buffers under it with the canvas fill the session was drawn with (no
9476
- * worker call, no fetch: reintegrateWrunSession) and presents the result as
9477
- * a republish, under the overlay's session lock. A full run in flight
10606
+ * from the frames snapshot the session's rows carry, or leaves it out: the
10607
+ * module writes its frames whatever the sheet hides, and a slot it never wrote
10608
+ * builds nothing, as a run of it would), the colour of a level, a renderer or
10609
+ * a batched section, a band, a fill, a box, a segment, and every look the
10610
+ * adapter derives from an output's colour. The caller swaps the new sheet into
10611
+ * the context first (`context.metadata`); this integrates the session's own
10612
+ * rows and buffers under it with the canvas fill the session was drawn with
10613
+ * (no worker call, no fetch: reintegrateWrunSession) and presents the result
10614
+ * as a republish, under the overlay's session lock. A full run in flight
9478
10615
  * replaces the session when it lands, so the repaint stands down and the
9479
10616
  * save's rerun joins that run. False (the save keeps its rerun): no live
9480
10617
  * session, the context replaced or suspended, a full run in flight, the
9481
10618
  * reseed's gates refuse the chart (replay, protection, the pane budget, the
9482
- * pause, the market), no candle to land on, or a failed integrate (the
9483
- * session then owes its repaint, as after a failed tick). `preview` (a
9484
- * settings gesture's frame, under the previewed sheet) writes nothing to the
9485
- * overlay's settings. A replay session stands down too: only its lane bounds
9486
- * its candles at the replay's cutoff (the run and the tick paths), so the save
9487
- * reruns there. A session whose row source holds its own session (a cloud
9488
- * run) repaints with the cells that source keeps (`cellRowsOf`, as its full
9489
- * run and its frames read them); a sheet drawing price canvases whose cells
9490
- * neither such a source nor the context's lane buffers hold stands down.
10619
+ * pause, the market), no candle to land on, or a failed integrate (the session
10620
+ * then owes its repaint, as after a failed tick). `preview` (a settings
10621
+ * gesture's frame, under the previewed sheet) writes nothing to the overlay's
10622
+ * settings. A replay session stands down too: only its lane bounds its candles
10623
+ * at the replay's cutoff (the run and the tick paths), so the save reruns
10624
+ * there. A session whose row source holds its own session (a cloud run)
10625
+ * repaints with the cells that source keeps (`cellRowsOf`, as its full run and
10626
+ * its frames read them); a sheet drawing price canvases whose cells neither
10627
+ * such a source nor the context's lane buffers hold stands down.
9491
10628
  */
9492
10629
  export async function repaintWrunSessionUnderSheet(indicatorId, context, options = {}) {
9493
10630
  const standing = () => getWrunOverlayLiveContext(indicatorId) === context && !isWrunOverlayFullRerunInFlight(indicatorId);
@@ -9524,6 +10661,381 @@ export async function repaintWrunSessionUnderSheet(indicatorId, context, options
9524
10661
  }
9525
10662
  });
9526
10663
  }
10664
+ // ---------------------------------------------------------------------------
10665
+ // The warm switch's park and re-attach (SWITCH-COST U1)
10666
+ // ---------------------------------------------------------------------------
10667
+ /**
10668
+ * Park one overlay's live session at a warm workspace switch's teardown (the registry loader's capture door, while the
10669
+ * outgoing chart still stands): the picture its chart shows (`wrunMountedRunResultOf`, the stand-in capture's read)
10670
+ * goes with the session to the park (wrun-overlay-park.util parkWrunOverlayLiveSession), which keeps the worker's
10671
+ * series and the context and releases everything chart-bound. Undefined, with nothing released, when the chart shows no whole
10672
+ * picture of the session (no result known to show, a page) or the drivers refuse it.
10673
+ */
10674
+ export function parkWrunOverlayForSwitch(chartIndex, indicatorId) {
10675
+ const tc = wrunChartHostEnv().chart.instance(chartIndex);
10676
+ const meta = tc?.metadata?.find((candidate) => candidate.id === indicatorId);
10677
+ if (!tc || !meta)
10678
+ return undefined;
10679
+ const shown = wrunMountedRunResultOf(indicatorId, meta);
10680
+ if (shown === undefined || shown.window?.partial === true)
10681
+ return undefined;
10682
+ const bars = wrunParkedBarsOf(wrunChartCandleRows(tc));
10683
+ if (bars === undefined)
10684
+ return undefined;
10685
+ // A session that read CME (its own mark, or the stamp Door C put on the overlay, the web leaf's key and value) keeps
10686
+ // the authorisation it was parked under: its adoption takes nothing back once the gate closed or the epoch moved.
10687
+ const readCme = getWrunOverlayLiveContext(indicatorId)?.cmeRead === true ||
10688
+ meta.settings?.metaCmeExchange === 'CME';
10689
+ return parkWrunOverlayLiveSession(indicatorId, shown, bars, Date.now(), readCme ? captureCmeStudyAuth() : undefined);
10690
+ }
10691
+ /** A chart's bars as a park and its adoption compare them: the first, the newest closed (the one before the newest)
10692
+ * and the newest. Undefined while the chart holds none. */
10693
+ function wrunParkedBarsOf(rows) {
10694
+ if (rows.length === 0)
10695
+ return undefined;
10696
+ return {
10697
+ firstTs: Number(rows[0][0]),
10698
+ lastClosedTs: rows.length > 1 ? Number(rows[rows.length - 2][0]) : null,
10699
+ lastTs: Number(rows[rows.length - 1][0]),
10700
+ };
10701
+ }
10702
+ /** Cut an adopted session to the chart's rows from `firstTs` on: its first row and its output rows, and every fact a
10703
+ * prefix run would read about the bars before (its guest evaluated them: no prefix proof stands over the cut). */
10704
+ function trimWrunAdoptedSession(context, firstTs) {
10705
+ // By timestamp, the run-level attachments (the handle set, the frames, the strategy, the draw skips, the live
10706
+ // block's accounting) carried to the cut rows: a filtered copy is a new array the WeakMap attachments never follow.
10707
+ context.outputRows = wrunLandedOutputRows(context.outputRows, firstTs);
10708
+ context.firstRowTs = firstTs;
10709
+ // It holds every bar the chart shows now: no budget clamps it.
10710
+ delete context.retained;
10711
+ context.prefixCapable = false;
10712
+ delete context.prefixOwner;
10713
+ delete context.candleEvidence;
10714
+ delete context.warmupHead;
10715
+ delete context.warmRun;
10716
+ delete context.laneWarmupHead;
10717
+ }
10718
+ /** The overlay provenance writers (the env's loader), or undefined when they cannot load. */
10719
+ async function wrunProvenanceWritersOrNone() {
10720
+ try {
10721
+ return await wrunChartHostEnv().chart.loadOptionsOverlayProvenance();
10722
+ }
10723
+ catch {
10724
+ return undefined;
10725
+ }
10726
+ }
10727
+ function ringWrunParkAdopt(target, fields) {
10728
+ if (!wrunChartHostEnv().diagnostics.debugEnabled())
10729
+ return;
10730
+ wrunChartHostEnv().diagnostics.debug('wrun-run-park-adopt', { ...target, ...fields });
10731
+ }
10732
+ /** Whether the overlay's mount still stands on the chart the adoption read: the same engine at its index, holding the
10733
+ * same meta. */
10734
+ function wrunAdoptMountStands(chartIndex, tc, meta) {
10735
+ const metadata = tc?.metadata;
10736
+ return wrunChartHostEnv().chart.instance(chartIndex) === tc && Array.isArray(metadata) && metadata.includes(meta);
10737
+ }
10738
+ /**
10739
+ * The warm switch's re-attach: the overlay's first run on the chart that mounts it again takes its parked live session
10740
+ * back (wrun-overlay-park.util parkWrunOverlayLiveSession) in place of running the package over the whole history.
10741
+ * The registry loader calls it from the run its driver's first request starts (the executor's single flight, so a wave
10742
+ * meanwhile waits for it, and the executor counts its success as the run's: the good result, the coverage the next
10743
+ * same-rows wave skips on, the attempt and the settings settle).
10744
+ *
10745
+ * Judged on the chart, the host and the session as they stand (`refusalNow`): once before the waits (the hold reads,
10746
+ * the session lock) for an early answer, and again under the lock right before the install, with no await between that
10747
+ * judgment and the install, since a settings save, a symbol switch, a pause, a teardown or the worker can move while
10748
+ * the adoption waits. The mount stands; the worker still holds the series under the parked epoch; the chart's newest
10749
+ * closed bar is the one it was at the park (no bar closed since: the forming bar may differ, the live tick covers it)
10750
+ * and the session covers the chart's rows (its first bar no later than the chart's first; a chart that came back with
10751
+ * fewer bars than it lazy-loaded before the park, the cached boot window, is covered); the market and the settings
10752
+ * revision are the session's; a session that read CME may still read it under the authorisation of its park (the gate
10753
+ * open to the run, the epoch unmoved: no picture computed from CME returns past a closed gate); nothing holds the
10754
+ * overlay (a pause, a trip, replay). Any refusal ends the parked series and answers why; the caller then runs the
10755
+ * package as today.
10756
+ *
10757
+ * A session that covers more bars than the chart shows is cut to the chart's rows before it is adopted
10758
+ * (`trimWrunAdoptedSession`, the run-level attachments riding the cut rows): its first row becomes the chart's, the
10759
+ * output rows before it go, and it plans no prefix run (its guest evaluated the bars before its new first row, so no
10760
+ * prefix proof stands over it), so older bars the chart lazy-loads later go through the history path a fresh run's
10761
+ * would. Its picture is then built again over the rows it kept.
10762
+ *
10763
+ * Adopted, the session is the overlay's again, as if it had never left: the context goes back into the registry under
10764
+ * this chart and a fresh generation (the series keeps its epoch), with its history as-of pins, and a session that read
10765
+ * CME gets back the CME stamp its run's fetch door put on the overlay (both settings copies, before its picture
10766
+ * installs: the remount shed it; by the doors' rule, so a first-party run on a CME chart stays unstamped); its picture
10767
+ * integrates through the route a first run takes (`integrateWrunRunThroughRoute`, reason 'initial': the remount,
10768
+ * `mode: 'metadata'`, the mount memo written), prebuilt (the result the chart showed, built already: no build) when it
10769
+ * was not cut, carries no child overlays and runs at the chart's interval, else built again from the session's own
10770
+ * rows and buffers (`reintegrateWrunSession`, the style repaint's door). Then, still under the lock and with no await
10771
+ * in between, what a first run settles with its picture: the stand-in it replaces retracts (`replaced`), the retained
10772
+ * range, the overlay's live and poll channels open again, a `session-start` gap mark has the first drain reconcile
10773
+ * every lane over the time the tab was away and then tick the kept worker series, and the run settles under the
10774
+ * settings revision the session computed. A teardown, a pause or another switch after that closes what opened here.
10775
+ * The canvas notices, the Strategy Tester payload, the run health and the refusal verdicts publish after the lock,
10776
+ * each only while the session is still this chart's under the generation it was installed with.
10777
+ */
10778
+ export async function adoptWrunParkedLiveSession(parked, target) {
10779
+ const { chartIndex, indicatorId } = target;
10780
+ const startedAt = wrunHostClockMs();
10781
+ const taken = parked.indicatorId === indicatorId ? takeWrunParkedLiveSession(parked) : undefined;
10782
+ if (taken === undefined) {
10783
+ ringWrunParkAdopt(target, { adopted: false, reason: 'not-parked' });
10784
+ return { adopted: false, reason: 'not-parked' };
10785
+ }
10786
+ const { context, shown, historyAsOf } = taken;
10787
+ // Every refusal past the take ends the series the handle held: nothing will tick it again.
10788
+ const refuse = (reason) => {
10789
+ endWrunParkedLiveSeries(parked);
10790
+ ringWrunParkAdopt(target, { adopted: false, reason, parkedForMs: Date.now() - parked.parkedAt });
10791
+ return { adopted: false, reason };
10792
+ };
10793
+ // The attempt this run answers (the loader opened it at the mount): its first run starts here, as a run's does.
10794
+ const attempt = wrunChartHostEnv().diagnostics.liveAttemptToken(chartIndex, indicatorId);
10795
+ if (attempt)
10796
+ wrunChartHostEnv().diagnostics.markAttemptRunStart(attempt);
10797
+ const tc = wrunChartHostEnv().chart.instance(chartIndex);
10798
+ const meta = tc?.metadata?.find((candidate) => candidate.id === indicatorId);
10799
+ if (!tc || !meta)
10800
+ return refuse('chart-gone');
10801
+ // The chart's first bar when the session covers it (see the header), else undefined. The session covers the chart
10802
+ // from its first row on; one its run budget clamped (`retained`: it never held the chart's oldest bars) also covers
10803
+ // the window it was clamped in, the chart's first bar at the park.
10804
+ const coveredFirstTs = () => {
10805
+ const bars = wrunParkedBarsOf(wrunChartCandleRows(tc));
10806
+ if (bars === undefined || bars.lastClosedTs !== parked.bars.lastClosedTs || context.lastRowTs > bars.lastTs) {
10807
+ return undefined;
10808
+ }
10809
+ const covered = bars.firstTs >= context.firstRowTs || (context.retained !== undefined && bars.firstTs === parked.bars.firstTs);
10810
+ return covered ? bars.firstTs : undefined;
10811
+ };
10812
+ const chartFirstTs = coveredFirstTs();
10813
+ // Why the session cannot be adopted on the chart as it stands now, null when it can (see the header). Synchronous,
10814
+ // so the read under the lock is the one the install acts on.
10815
+ const refusalNow = () => {
10816
+ if (!wrunAdoptMountStands(chartIndex, tc, meta))
10817
+ return 'chart-gone';
10818
+ if (!getWrunBrowserHost().holdsLiveSeries(indicatorId, parked.epoch))
10819
+ return 'session-lost';
10820
+ if (chartFirstTs === undefined || coveredFirstTs() !== chartFirstTs)
10821
+ return 'bars-moved';
10822
+ const chartMetadata = wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata;
10823
+ if ((context.marketIdentity !== undefined && context.marketIdentity !== wrunChartMarketIdentity(chartMetadata)) ||
10824
+ kScriptSettingsRevision(meta.settings) !== (context.settingsRevision ?? 0)) {
10825
+ return 'identity-changed';
10826
+ }
10827
+ if (parked.cmeAuth !== undefined &&
10828
+ (!isCmeStudyAuthCurrent(parked.cmeAuth) ||
10829
+ !isCmeReadableKScriptRun(meta.settings))) {
10830
+ return 'cme-access';
10831
+ }
10832
+ if (wrunChartHostEnv().chart.isReplaying(chartIndex) ||
10833
+ wrunChartHostEnv().chart.chartStore().isKScriptOverlayPaused?.(chartIndex, indicatorId) === true ||
10834
+ wrunChartHostEnv().chart.isOverlayTripped(overlayExecutionGuardKey(chartIndex, indicatorId))) {
10835
+ return 'held';
10836
+ }
10837
+ return null;
10838
+ };
10839
+ const early = refusalNow();
10840
+ if (early !== null || chartFirstTs === undefined)
10841
+ return refuse(early ?? 'bars-moved');
10842
+ // A first run's hold read (it pauses a tripped overlay) and the user's pause.
10843
+ const held = await isWrunOverlayHeldForRun(chartIndex, indicatorId).catch(() => null);
10844
+ if (held || (await isWrunOverlayPaused(chartIndex, indicatorId)))
10845
+ return refuse('held');
10846
+ // The provenance writers for a session that read CME, loaded before the lock (the install restores its CME stamp); a
10847
+ // load that fails adopts nothing that read CME (`cme-access` under the lock).
10848
+ const provenance = parked.cmeAuth === undefined ? undefined : await wrunProvenanceWritersOrNone();
10849
+ // A child overlay or a run interval rebuilds from the session's rows; a sheet whose canvases' cells the context does
10850
+ // not hold could only rebuild them empty (the style repaint's rule).
10851
+ const runSession = wrunRunIntervalSessionOf(context);
10852
+ // The chart shows fewer bars than the session covers: the session is cut to them (a run at another interval keeps
10853
+ // its own bars and is never cut: it runs again).
10854
+ const trim = chartFirstTs > context.firstRowTs;
10855
+ if (trim && runSession !== undefined)
10856
+ return refuse('bars-moved');
10857
+ const rebuild = trim || runSession !== undefined || (shown.runResult.childOverlays?.length ?? 0) > 0;
10858
+ if (rebuild && wrunSheetDrawsCanvases(context.metadata) && !wrunHoldsCanvasCells(context)) {
10859
+ return refuse('integrate-failed');
10860
+ }
10861
+ // The session is this chart's while it is the registered context under the generation it was installed with, on the
10862
+ // mount the adoption read. A teardown, a pause or another switch takes it away; whoever took it holds the overlay.
10863
+ let installed = Number.NaN;
10864
+ const owned = () => getWrunOverlayLiveContext(indicatorId) === context &&
10865
+ context.generation === installed &&
10866
+ wrunAdoptMountStands(chartIndex, tc, meta);
10867
+ // Why a session taken away while its picture landed answers: a pause or a trip leaves the mount standing.
10868
+ const left = () => (wrunAdoptMountStands(chartIndex, tc, meta) ? 'held' : 'chart-gone');
10869
+ const adopted = await withWrunOverlaySessionLock(indicatorId, async () => {
10870
+ if (getWrunOverlayLiveContext(indicatorId) !== undefined)
10871
+ return 'integrate-failed';
10872
+ // Judged again on the chart as it stands after the waits; nothing awaits from here to the install.
10873
+ const late = refusalNow();
10874
+ if (late !== null)
10875
+ return late;
10876
+ // The stamp the fetch door gave what the session drew (cme-overlay-provenance.util: a CME user study's on any
10877
+ // chart, any run's CME read off a CME chart), on both settings copies before its picture installs: the remount
10878
+ // shed it, and no fetch door runs for an adopted session. A host that cannot write it adopts nothing that read
10879
+ // CME.
10880
+ const chartExchangeNow = wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata?.exchange;
10881
+ if (parked.cmeAuth !== undefined &&
10882
+ (isCmeUserScriptRun(meta.settings) ||
10883
+ !payloadTouchesCmeVenue(chartExchangeNow))) {
10884
+ if (provenance?.setOverlayCmeProvenance === undefined)
10885
+ return 'cme-access';
10886
+ provenance.setOverlayCmeProvenance(chartIndex, indicatorId, true);
10887
+ }
10888
+ if (trim)
10889
+ trimWrunAdoptedSession(context, chartFirstTs);
10890
+ // The session is this chart's now, under a fresh generation: frames and drains of its old chart are discarded.
10891
+ // The worker's series keeps the epoch it was opened under, which a later park names it by.
10892
+ context.chartIndex = chartIndex;
10893
+ context.seriesEpoch = parked.epoch;
10894
+ context.generation = nextWrunOverlayLiveGeneration(indicatorId);
10895
+ installed = context.generation;
10896
+ context.liveApplied = undefined;
10897
+ context.rebuildHandoffShape = undefined;
10898
+ if (historyAsOf !== undefined)
10899
+ restoreWrunHistoryAsOf(indicatorId, historyAsOf);
10900
+ setWrunOverlayLiveContext(context);
10901
+ let runResult;
10902
+ try {
10903
+ if (rebuild) {
10904
+ // The row builder reads the shared host, as the style repaint's rebuild does.
10905
+ const hostLoading = ensureWrunChartHostSharedHost();
10906
+ if (hostLoading)
10907
+ await hostLoading;
10908
+ const fill = wrunSessionCanvasFillOf(context) ?? (await wrunCanvasHostFillFor(context.metadata, context.market));
10909
+ if (!(await reintegrateWrunSession(indicatorId, context, fill, owned))) {
10910
+ if (!owned())
10911
+ return left();
10912
+ throw new Error('not rebuilt');
10913
+ }
10914
+ runResult = wrunMountedRunResultOf(indicatorId, meta)?.runResult ?? shown.runResult;
10915
+ }
10916
+ else {
10917
+ const integration = integrateWrunRunThroughRoute({
10918
+ tc,
10919
+ meta,
10920
+ chartIndex,
10921
+ indicatorId,
10922
+ metadata: context.metadata,
10923
+ outputRows: context.outputRows,
10924
+ prebuilt: shown.runResult,
10925
+ title: context.title,
10926
+ position: context.position,
10927
+ axis: context.axis,
10928
+ colors: context.colors,
10929
+ fills: context.fills,
10930
+ candles: context.candles,
10931
+ integration: { reason: 'initial', hasGoodResult: false, identityLeft: false, settingsStale: false },
10932
+ });
10933
+ if (!integration.applied)
10934
+ throw new Error(`not applied (${integration.route.action})`);
10935
+ // A result that names its children (none here, at most an empty list) settles their mount as a run's does.
10936
+ if (integration.runResult.childOverlays !== undefined &&
10937
+ !(await awaitWrunChildOverlays(tc, indicatorId))) {
10938
+ throw new Error('children not mounted');
10939
+ }
10940
+ if (!owned())
10941
+ return left();
10942
+ presentWrunIntegration(chartIndex, indicatorId, context.metadata, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), undefined, 'run', { emptyTargets: integration.runResult.emptyTargets, partial: false });
10943
+ context.paintedThroughTs = context.lastRowTs;
10944
+ context.repaintOwed = false;
10945
+ runResult = integration.runResult;
10946
+ }
10947
+ }
10948
+ catch (error) {
10949
+ // The picture did not land: the context leaves again (a pause's release, which also ends the series), and
10950
+ // the caller's run computes the overlay as a first mount does.
10951
+ console.warn(`[wrun] the parked session of '${indicatorId}' was not adopted (running it):`, error);
10952
+ if (getWrunOverlayLiveContext(indicatorId) === context)
10953
+ suspendWrunOverlayLiveSession(indicatorId);
10954
+ return 'integrate-failed';
10955
+ }
10956
+ if (!owned())
10957
+ return left();
10958
+ // The picture is the chart's: what a first run settles with it, before any further await (see the header). The
10959
+ // adopted picture replaces the stand-in the switch back painted.
10960
+ wrunChartHostEnv().chart.retractStandIn(chartIndex, indicatorId, 'replaced', tc);
10961
+ noteWrunRunRetained(tc, indicatorId, context.retained ?? null);
10962
+ // Live again: the overlay's own channels and its poll lanes' streams, and one reconcile over the time away.
10963
+ void subscribeWrunOverlayLiveFeed(indicatorId, meta.settings, chartIndex);
10964
+ openWrunPollLaneLiveChannels(context);
10965
+ markWrunLiveGap(indicatorId, 'session-start');
10966
+ // The drain that mark wakes can meet this run still in flight (the executor counts the adoption as the
10967
+ // overlay's first run until its publications end) and be turned away: re-armed, it drains again on the cadence
10968
+ // until it gets past that gate, so a quiet market's reconcile never waits for the next frame.
10969
+ rearmWrunLiveTick(chartIndex, indicatorId);
10970
+ markWrunOverlayComputeSucceeded(indicatorId);
10971
+ // The run computed the settings revision the session holds (judged the mount's own above, under this lock).
10972
+ noteWrunOverlayRunSettle(indicatorId, { generation: context.settingsRevision ?? 0, outcome: 'applied' });
10973
+ return runResult;
10974
+ });
10975
+ if (typeof adopted === 'string')
10976
+ return refuse(adopted);
10977
+ // What a first run publishes beside its picture, each only while the session is still this chart's: whoever took
10978
+ // it during one of them (a teardown, a pause, another switch) holds the overlay, and the rest is theirs.
10979
+ const publications = [
10980
+ () => publishWrunSessionCanvasNotices(context, adopted, { isCurrent: owned }),
10981
+ () => publishWrunStrategyRunResult(chartIndex, indicatorId, adopted, { tc, meta }),
10982
+ async () => {
10983
+ // The overlay's health follows the session by the full run's rule (a reseed's: its context read only when
10984
+ // every bar was warm-up).
10985
+ const health = wrunSessionRunHealth(context, meta.settings, context.outputRows);
10986
+ const nothingReady = health.bars > 0 && health.ready === 0
10987
+ ? wrunNothingReadyRefusal(health, await wrunRefusalContextFor({
10988
+ title: context.title,
10989
+ metadata: context.metadata,
10990
+ settings: meta.settings,
10991
+ chartMetadata: await wrunChartMetadataFor(chartIndex),
10992
+ }))
10993
+ : null;
10994
+ if (!owned())
10995
+ return;
10996
+ context.runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, context.draft === true, nothingReady), { isCurrent: owned });
10997
+ // The viewer's nothing-drawn note follows the adopted session's whole window like a reseed's (FB27).
10998
+ if (!owned())
10999
+ return;
11000
+ await publishWrunNothingDrawn(chartIndex, indicatorId, {
11001
+ draft: context.draft === true,
11002
+ settled: context.window?.partial !== true && wrunSessionSourceAbsent.get(context) !== true,
11003
+ metadata: context.metadata,
11004
+ rows: context.outputRows,
11005
+ drawings: wrunHandlesOf(context.outputRows)?.length,
11006
+ runIntervalMs: wrunRunIntervalSessionOf(context)?.run.intervalMs ?? context.intervalMs,
11007
+ }, async () => wrunRefusalContextFor({
11008
+ title: context.title,
11009
+ metadata: context.metadata,
11010
+ settings: meta.settings,
11011
+ chartMetadata: await wrunChartMetadataFor(chartIndex),
11012
+ }), { isCurrent: owned });
11013
+ },
11014
+ () => {
11015
+ noteWrunWholeWindowDrawnSafely(indicatorId);
11016
+ return settleWrunRefusalsOnReseed(chartIndex, indicatorId, owned);
11017
+ },
11018
+ () => void clearWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, owned),
11019
+ ];
11020
+ for (const publish of publications) {
11021
+ if (!owned())
11022
+ break;
11023
+ await publish();
11024
+ }
11025
+ const ownerLeft = !owned();
11026
+ wrunChartHostEnv().diagnostics.settleAttempt(attempt, { ok: true });
11027
+ const path = rebuild ? 'rebuilt' : 'prebuilt';
11028
+ ringWrunParkAdopt(target, {
11029
+ adopted: true,
11030
+ path,
11031
+ ...(trim ? { trimmedToTs: chartFirstTs } : {}),
11032
+ ...(ownerLeft ? { ownerLeft: true } : {}),
11033
+ rows: context.outputRows.length,
11034
+ parkedForMs: Date.now() - parked.parkedAt,
11035
+ ms: Math.round(wrunHostClockMs() - startedAt),
11036
+ });
11037
+ return { adopted: true, path };
11038
+ }
9527
11039
  /** Drop an overlay's canvas run state (its refine latches, its run serial):
9528
11040
  * called from the live tick lane's teardown hook beside the canvas cache. */
9529
11041
  export function forgetWrunOverlayCanvasState(indicatorId) {
@@ -10027,17 +11539,18 @@ function integrateWrunRunThroughRouteOnce(options, childMount) {
10027
11539
  // selection text and the children print with them.
10028
11540
  const priceDigits = options.priceDigits ?? wrunChartPriceDigits(options.chartIndex);
10029
11541
  // The overlay's flat param settings are what the rows were computed with
10030
- // (the run's init() arguments derive from them the same way).
10031
- const runResult = buildWrunOverlayRunResult({
10032
- ...options,
10033
- params: options.params ?? wrunParamValuesFromSettings(options.metadata, options.meta.settings),
10034
- texts: options.texts ?? wrunTextParamValuesFromSettings(options.metadata, options.meta.settings),
10035
- // An editor draft's legend says it is one (and only in this browser); the tick repeats it.
10036
- legendNote: options.legendNote ?? wrunDraftLegendNote(options.meta.settings),
10037
- ...(options.projection ? { runTimeline: true } : {}),
10038
- ...(priceDigits !== undefined ? { priceDigits } : {}),
10039
- overlayId: options.overlayId ?? options.indicatorId,
10040
- });
11542
+ // (the run's init() arguments derive from them the same way). An adoption hands the picture its session showed.
11543
+ const runResult = options.prebuilt ??
11544
+ buildWrunOverlayRunResult({
11545
+ ...options,
11546
+ params: options.params ?? wrunParamValuesFromSettings(options.metadata, options.meta.settings),
11547
+ texts: options.texts ?? wrunTextParamValuesFromSettings(options.metadata, options.meta.settings),
11548
+ // An editor draft's legend says it is one (and only in this browser); the tick repeats it.
11549
+ legendNote: options.legendNote ?? wrunDraftLegendNote(options.meta.settings),
11550
+ ...(options.projection ? { runTimeline: true } : {}),
11551
+ ...(priceDigits !== undefined ? { priceDigits } : {}),
11552
+ overlayId: options.overlayId ?? options.indicatorId,
11553
+ });
10041
11554
  if (runResult.failureReason !== undefined)
10042
11555
  throw new WrunIntegrationError(runResult.failureReason);
10043
11556
  const { tc, meta, indicatorId, projection, chartIndex } = options;
@@ -10310,12 +11823,14 @@ function wrunWarmupStampCorroborated(module, sheet) {
10310
11823
  wrunStampCorroborated(module) &&
10311
11824
  wrunWarmupSheetRefusal(sheet) === undefined);
10312
11825
  }
10313
- /** A torn exact warm-up stamp (4b): the sheet's `history_warmup` is no record at all, or a record of kind "exact"
10314
- * that no frozen shape reads off (a term whose multiplier is not a number, a window without its terms list:
11826
+ /** A torn warm-up stamp (4b): the sheet's `history_warmup` is no record at all, or a record of kind "exact" or
11827
+ * "converges" that no frozen shape reads off (a term whose multiplier is not a number, a window without its terms
11828
+ * list; a converging one with another tolerance, another corpus, a count below its floor or no gate:
10315
11829
  * `wrunWarmupStampOf` reads none). Named `warmup-invalid` by the full run's verdict, the plan's admission (its skip
10316
11830
  * reason) and the capability line, where it used to read as no stamp at all (the roster's silent `not-audited`); it
10317
11831
  * still corroborates nothing (no W reads off it, and the per-bar stamp refuses any sheet carrying the key). A record
10318
- * of another kind is a later round's stamp and reads as no stamp, as it always has (`wrunHistoryWarmupOf`). */
11832
+ * of another kind is a later round's stamp and reads as no stamp, as it always has (`wrunHistoryWarmupOf`), and so
11833
+ * does a converging one while its flag is off: every caller asks `wrunConvergingStampDark` first (R2-13). */
10319
11834
  function wrunWarmupStampTorn(sheet) {
10320
11835
  if (sheet === null || typeof sheet !== 'object')
10321
11836
  return false;
@@ -10324,7 +11839,48 @@ function wrunWarmupStampTorn(sheet) {
10324
11839
  return false;
10325
11840
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
10326
11841
  return true;
10327
- return raw.kind === 'exact' && wrunWarmupStampOf(sheet) === undefined;
11842
+ const kind = raw.kind;
11843
+ return (kind === 'exact' || kind === 'converges') && wrunWarmupStampOf(sheet) === undefined;
11844
+ }
11845
+ /** Whether the chart honors a converging warm-up stamp (`FeatureFlag.WrunConvergingPrefix`, STAMPS round A, default
11846
+ * off); a host whose flag store is not up reads off. */
11847
+ function wrunConvergingPrefixOn() {
11848
+ try {
11849
+ return wrunChartHostEnv().user.isFeatureOn(FeatureFlag.WrunConvergingPrefix);
11850
+ }
11851
+ catch {
11852
+ return false;
11853
+ }
11854
+ }
11855
+ /** Whether a sheet's `history_warmup` is a record of kind "converges", whatever else it holds. */
11856
+ function wrunWarmupStampConverges(sheet) {
11857
+ const raw = sheet !== null && typeof sheet === 'object' ? sheet.history_warmup : undefined;
11858
+ return (raw !== null && typeof raw === 'object' && !Array.isArray(raw) && raw.kind === 'converges');
11859
+ }
11860
+ /** A converging stamp its flag leaves unread (STAMPS round A, R2-13): while `wrun-converging-prefix` is off, a
11861
+ * `converges` record of ANY shape reads as no stamp, exactly as an unknown kind always has (never torn, never
11862
+ * planned, never admitted), so the run, its head, its rows and its admission are today's. Asked first by every reader
11863
+ * that plans or admits on a stamp, before any other reading of it (the torn check included). */
11864
+ function wrunConvergingStampDark(sheet) {
11865
+ return wrunWarmupStampConverges(sheet) && !wrunConvergingPrefixOn();
11866
+ }
11867
+ /** A converging stamp's tolerance as the plan and the admission carry it (`{ tolerance }`), none for an exact stamp. */
11868
+ function wrunWarmupToleranceOf(sheet) {
11869
+ const stamp = wrunWarmupStampOf(sheet);
11870
+ return stamp?.kind === 'converges' ? { tolerance: stamp.tolerance } : {};
11871
+ }
11872
+ /** The first candle of a hidden head with a field that is not finite (open, high, low, close or volume), else
11873
+ * undefined: a converging session's W counts ACCEPTED inputs (its recursions skip a non-finite input without
11874
+ * advancing, Codex 5), so a head holding one gives its guest fewer than W and the running start falls short of the
11875
+ * bound the gate certified (`warmup-gaps`). */
11876
+ function wrunWarmupHeadGapAt(rows) {
11877
+ for (const row of rows) {
11878
+ for (let column = 1; column <= 5; column += 1) {
11879
+ if (!Number.isFinite(Number(row[column])))
11880
+ return Number(row[0]);
11881
+ }
11882
+ }
11883
+ return undefined;
10328
11884
  }
10329
11885
  /** The settings W is sized from (4b): the ones the package computes with. A run at another interval and a built-in
10330
11886
  * twin whose Timeframe is at or below the chart's (`chartArm`) run their chart arm, the Timeframe forced to the chart
@@ -10361,12 +11917,16 @@ function wrunWarmupBarsOf(sheet, settings) {
10361
11917
  return { miss: answer.refusal };
10362
11918
  return answer.bars > WRUN_HISTORY_WARMUP_MAX_BARS ? { miss: 'warmup-cap' } : { bars: answer.bars };
10363
11919
  }
10364
- /** The exact warm-up verdict (D4): a torn stamp first (`warmup-invalid`, 4b), then corroborated
11920
+ /** The warm-up verdict (D4): a converging stamp its flag leaves unread first (null before anything else reads it,
11921
+ * R2-13: no head is planned or fetched), a torn stamp (`warmup-invalid`, 4b), then corroborated
10365
11922
  * (`wrunWarmupStampCorroborated`, else null), candles-only (`warmup-lanes`), W from the settings the package
10366
11923
  * computes with (`wrunWarmupBarsOf` over `wrunWarmupSettings`: `warmup-cap`, `warmup-unresolved`), and a run the
10367
- * head can join (`warmup-mode`: a replay run, a run at another interval). Whether the chart's candles are asked as a
10368
- * plain time window is the head request's question (`wrunWarmupHeadRequestOf`). */
11924
+ * head can join (`warmup-mode`: a replay run, a run at another interval). The plan is W, and a converging stamp's
11925
+ * tolerance beside it (STAMPS round A; an exact plan is what it always was). Whether the chart's candles are asked as
11926
+ * a plain time window is the head request's question (`wrunWarmupHeadRequestOf`). */
10369
11927
  function wrunWarmupVerdictOf(input) {
11928
+ if (wrunConvergingStampDark(input.sheet))
11929
+ return null;
10370
11930
  if (wrunWarmupStampTorn(input.sheet))
10371
11931
  return { miss: 'warmup-invalid' };
10372
11932
  if (!wrunWarmupStampCorroborated(input.module, input.sheet))
@@ -10380,7 +11940,7 @@ function wrunWarmupVerdictOf(input) {
10380
11940
  return { miss: bars.miss };
10381
11941
  if (input.replay || input.runInterval)
10382
11942
  return { miss: 'warmup-mode' };
10383
- return { plan: { bars: bars.bars } };
11943
+ return { plan: { bars: bars.bars, ...wrunWarmupToleranceOf(input.sheet) } };
10384
11944
  }
10385
11945
  /** The main candle lane, loaded lazily (data-fetching.util's graph pulls in the live feed and, through it, this
10386
11946
  * lane); null when an export is missing (a spec's partial module) or the load failed. */
@@ -10962,19 +12522,27 @@ function wrunSandboxLandedRows(prepared, rows) {
10962
12522
  : rows;
10963
12523
  }
10964
12524
  /**
10965
- * A session's exact warm-up admission at a plan (D4, per guest): `warmup-invalid` for a torn stamp (4b, the skip
10966
- * reason the roster's `not-audited` used to hide), null when the sheet carries no stamp the module and the sheet
10967
- * corroborate (the per-bar stamp and the roster decide), the W when every warm-up rule holds and the LIVE guest's
10968
- * warmth record matches the live generation, the settings generation and the W the settings ask now (a guest warm
10969
- * at a history wall matches any W) with its head and evidence held, else the reason: `warmup-lanes` (an input beyond
10970
- * the chart's candles), `warmup-cap`, `warmup-unresolved`, the install's miss (`warmup-mode`, `warmup-short`) or
10971
- * `warmup-cold` (the guest ran no head under these settings, as after a reseed that could not take one). W reads the
10972
- * settings the package computes with (`wrunWarmupSettings`), as the install's warmth record did.
12525
+ * A session's warm-up admission at a plan (D4, per guest): null for a converging stamp its flag leaves unread (asked
12526
+ * first, R2-13), `warmup-invalid` for a torn stamp (4b, the skip reason the roster's `not-audited` used to hide), null
12527
+ * when the sheet carries no stamp the module and the sheet corroborate (the per-bar stamp and the roster decide), the
12528
+ * W when every warm-up rule holds and the LIVE guest's warmth record matches the live generation, the settings
12529
+ * generation and the W the settings ask now (a guest warm at a history wall matches any W) with its head and evidence
12530
+ * held, else the reason: `warmup-lanes` (an input beyond the chart's candles), `warmup-cap`, `warmup-unresolved`, the
12531
+ * install's miss (`warmup-mode`, `warmup-short`) or `warmup-cold` (the guest ran no head under these settings, as
12532
+ * after a reseed that could not take one). W reads the settings the package computes with (`wrunWarmupSettings`), as
12533
+ * the install's warmth record did. A converging session (STAMPS round A) is admitted with its tolerance, and only
12534
+ * while its held head (`warmupHead`: the candles before its first landed row, which the next reseed runs first; the
12535
+ * full run's head, or once a page landed that page's own head, which its prepare already held to the same rule)
12536
+ * holds no candle field that is not finite (`warmup-gaps`: W counts accepted inputs, so a gap there leaves the
12537
+ * session's first landed rows short of the bound, and their overlap with a page would then fail as the module's
12538
+ * fault).
10973
12539
  */
10974
12540
  function wrunPrefixWarmupAdmission(context, meta) {
10975
12541
  const seed = context.sessionSeed;
10976
12542
  if (seed === undefined)
10977
12543
  return null;
12544
+ if (wrunConvergingStampDark(context.metadata))
12545
+ return null;
10978
12546
  if (wrunWarmupStampTorn(context.metadata))
10979
12547
  return 'warmup-invalid';
10980
12548
  if (!wrunWarmupStampCorroborated(seed.module, context.metadata))
@@ -10995,7 +12563,11 @@ function wrunPrefixWarmupAdmission(context, meta) {
10995
12563
  (warm.wall !== true && warm.warmupBars !== bars.bars)) {
10996
12564
  return context.warmupMiss ?? 'warmup-cold';
10997
12565
  }
10998
- return { bars: bars.bars };
12566
+ const tolerance = wrunWarmupToleranceOf(context.metadata);
12567
+ if (tolerance.tolerance !== undefined && wrunWarmupHeadGapAt(context.warmupHead.rows) !== undefined) {
12568
+ return 'warmup-gaps';
12569
+ }
12570
+ return { bars: bars.bars, ...tolerance };
10999
12571
  }
11000
12572
  /** Whether a warm-up admission admits the session (`wrunPrefixWarmupAdmission`'s W). */
11001
12573
  function isWrunWarmAdmission(admission) {
@@ -11055,9 +12627,13 @@ function latchWrunPrefixRefusal(indicatorId, identityKey) {
11055
12627
  }
11056
12628
  latched.add(identityKey);
11057
12629
  }
11058
- /** Whether the sheet paints a heatmap over book cells (a book-cells heatmap child). */
12630
+ /** Whether the sheet paints a heatmap over book cells (a book-cells heatmap child). A banded book input's block is
12631
+ * band sums, which no canvas paints (`isWrunBandedBookSource`). */
11059
12632
  function wrunSheetPaintsBookCells(sheet) {
11060
- return (sheet.heatmaps ?? []).some((heatmap) => heatmap.cells !== undefined && sheet.inputSources?.[heatmap.cells]?.source === 'book');
12633
+ return (sheet.heatmaps ?? []).some((heatmap) => {
12634
+ const source = heatmap.cells === undefined ? undefined : sheet.inputSources?.[heatmap.cells];
12635
+ return source?.source === 'book' && !isWrunBandedBookSource(source);
12636
+ });
11061
12637
  }
11062
12638
  /** Whether a book row (`[ts, price, size, ...]`) holds a level the module reads as a cell: a pair
11063
12639
  * of finite numbers (the host's book cells keep exactly those, a zero size included). */
@@ -11101,6 +12677,43 @@ function wrunPrefixClosedBookObserved(context) {
11101
12677
  }
11102
12678
  return false;
11103
12679
  }
12680
+ /** The sheet sections a converging session refuses in round A (`unsupported-outputs:converging-drawings`, Codex 2):
12681
+ * batched drawings (`marks`, `spans`, `rays`, `flags`: every batched kind), batched records (`boxes`, `segments`:
12682
+ * their `when` gates read an output discretely, and a 1e-6 slack on their `start` and `end` epoch fields is about
12683
+ * 28 minutes), canvas children
12684
+ * (`heatmaps`, `profiles`, `matrices`) and handles or drawings (`handles`, `handle_defaults`, `drawings`). Present
12685
+ * means not undefined, the stamp's own sheet-fact rule: an empty section refuses too. */
12686
+ const WRUN_CONVERGING_REFUSED_SHEET_KEYS = [
12687
+ ...WRUN_BATCHED_MARKS_KINDS,
12688
+ 'boxes',
12689
+ 'segments',
12690
+ 'heatmaps',
12691
+ 'profiles',
12692
+ 'matrices',
12693
+ 'handles',
12694
+ 'handle_defaults',
12695
+ 'drawings',
12696
+ ];
12697
+ /** Whether a sheet declares a batched drawing or record, a canvas child or a handle
12698
+ * (`WRUN_CONVERGING_REFUSED_SHEET_KEYS`). */
12699
+ function wrunSheetDeclaresConvergingDrawings(sheet) {
12700
+ const record = sheet;
12701
+ return WRUN_CONVERGING_REFUSED_SHEET_KEYS.some((key) => record[key] !== undefined);
12702
+ }
12703
+ /** The share of a whole run's work at or past which a converging page runs whole (`prefix-costlier`): a measured
12704
+ * performance heuristic (Codex 15), never a correctness threshold. */
12705
+ const WRUN_CONVERGING_PREFIX_COST_SHARE = 0.9;
12706
+ /** Whether a converging page costs about what the whole run it stands in for does (`prefix-costlier`, Codex 15): its
12707
+ * hidden head and the rows it walks over its window (the page, the overlap of up to 32 session rows, the missing
12708
+ * bars between them) at or past 0.9 of a whole run's (the same head, and the rows it walks over the whole loaded
12709
+ * range). Rows are walked rows (`wrunChartWalkedRows`), the run budget's own count, so a gap costs what it costs a
12710
+ * run. `loadedRows` is the chart's `wrunChartCandleRows` array (its recorded missing bars ride its identity). */
12711
+ function wrunConvergingPrefixCostlier(loadedRows, window, warmupBars) {
12712
+ const rows = loadedRows;
12713
+ const page = warmupBars + wrunChartWalkedRows(wrunChartCandleRowsWithin(rows, window.fromMs, window.toMs));
12714
+ const whole = warmupBars + wrunChartWalkedRows(rows);
12715
+ return page >= WRUN_CONVERGING_PREFIX_COST_SHARE * whole;
12716
+ }
11104
12717
  /**
11105
12718
  * The candidate rules but the backward extension and its owner (C1 v3), null when they hold: no
11106
12719
  * replay, no refused proof (the session's own or the latched one), no clamped window, the chart's
@@ -11116,9 +12729,13 @@ function wrunPrefixClosedBookObserved(context) {
11116
12729
  * may carry state across bars, a corroborated stamp proves the module carries none, or none past its
11117
12730
  * running start). A full run's install stamps the answer as `prefixCapable` (the live tick leaves a page
11118
12731
  * in front of a capable session to its pan wave for a grace), and the planner checks it again against
11119
- * the chart now.
12732
+ * the chart now. A session admitted on a converging stamp (STAMPS round A: its admission carries a tolerance) answers
12733
+ * two rules more: no batched drawing or record, canvas child or handle on its sheet
12734
+ * (`unsupported-outputs:converging-drawings`, Codex 2: their rows hold timed endpoints, gates, packed records and cells
12735
+ * the proof compares exactly, never a level a recursion converges on), and, given the planned `window`, a page that
12736
+ * costs nearly what the whole run it stands in for does (`prefix-costlier`, Codex 15).
11120
12737
  */
11121
- function wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup = null) {
12738
+ function wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup = null, window) {
11122
12739
  if (context.replay === true || wrunChartHostEnv().chart.isReplaying(context.chartIndex))
11123
12740
  return 'replay';
11124
12741
  const identity = wrunPrefixPackageIdentity(context, meta);
@@ -11155,12 +12772,21 @@ function wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup =
11155
12772
  if (!admission.safe)
11156
12773
  return typeof warmup === 'string' ? warmup : admission.reason;
11157
12774
  }
12775
+ // A converging session (STAMPS round A) lands rows within its tolerance of a whole run, never equal to one: no
12776
+ // drawing rides it in round A, and a page that costs about what the whole run does runs whole (exact, and no dearer).
12777
+ if (isWrunWarmAdmission(warmup) && warmup.tolerance !== undefined) {
12778
+ if (wrunSheetDeclaresConvergingDrawings(context.metadata))
12779
+ return 'unsupported-outputs:converging-drawings';
12780
+ if (window !== undefined && wrunConvergingPrefixCostlier(loadedRows, window, warmup.bars))
12781
+ return 'prefix-costlier';
12782
+ }
11158
12783
  // The mounted picture is what this lane applied last; a mount it never applied cannot be judged.
11159
12784
  const mounted = wrunMountMemos.get(meta)?.lastResult;
11160
12785
  if (mounted === undefined)
11161
12786
  return 'no-context';
11162
- // Frames ride the rows by index: an older bar in front would shift every one of them.
11163
- if (wrunFramesOf(context.outputRows) !== undefined)
12787
+ // Frames ride the rows by index: an older bar in front would shift every one of them. The sheet's slots say whether
12788
+ // the module writes any (its every run answers them), never the rows' attachment, which a copy of the rows drops.
12789
+ if ((context.metadata.frames?.length ?? 0) > 0)
11164
12790
  return 'unsupported-outputs:frames';
11165
12791
  const cohort = wrunPrefixMountedCohort(context, mounted);
11166
12792
  if (!cohort.supported)
@@ -11191,7 +12817,18 @@ function wrunPrefixCapability(context, meta, loadedRows) {
11191
12817
  }
11192
12818
  else if (admission !== null) {
11193
12819
  const bars = wrunWarmupBarsOf(context.metadata, wrunSessionWarmupSettings(context, meta.settings));
11194
- warmup = { warmup: { kind: 'exact', bars: bars !== null && 'bars' in bars ? bars.bars : null } };
12820
+ const counted = bars !== null && 'bars' in bars ? bars.bars : null;
12821
+ const { tolerance } = wrunWarmupToleranceOf(context.metadata);
12822
+ warmup = {
12823
+ warmup: tolerance !== undefined ? { kind: 'converges', bars: counted, tolerance } : { kind: 'exact', bars: counted },
12824
+ };
12825
+ }
12826
+ else if (wrunConvergingStampDark(context.metadata)) {
12827
+ // A converging stamp its flag leaves unread (R2-13): the line names the kind and the tolerance it carries, no W.
12828
+ const stamp = wrunWarmupStampOf(context.metadata);
12829
+ if (stamp?.kind === 'converges') {
12830
+ warmup = { warmup: { kind: 'converges', bars: null, tolerance: stamp.tolerance } };
12831
+ }
11195
12832
  }
11196
12833
  const refusal = wrunPrefixIncapacity(context, meta, loadedRows, corroborated, admission);
11197
12834
  return { capable: refusal === null, reason: refusal ?? 'ok', ...identity, stamp, corroborated, ...warmup };
@@ -11231,7 +12868,7 @@ function planWrunPrefixRun(chartIndex, indicatorId) {
11231
12868
  return skip('not-backward-extension');
11232
12869
  const corroborated = wrunPrefixStampCorroborated(context, wrunHistoryStampOf(context.metadata));
11233
12870
  const warmup = corroborated ? null : wrunPrefixWarmupAdmission(context, meta);
11234
- const incapacity = wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup);
12871
+ const incapacity = wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup, decision.window);
11235
12872
  if (incapacity !== null)
11236
12873
  return skip(incapacity);
11237
12874
  // The options chain lands its snapshot on the build's last row: a window reaching the session's live row would land
@@ -11278,9 +12915,29 @@ function loadWrunLiveTickModule() {
11278
12915
  });
11279
12916
  return liveTickModule;
11280
12917
  }
11281
- /** The live tick drain's re-arm (C7) after a prefix outcome. Reached lazily: the tick lane imports
11282
- * this module (and the chart store), so a static import would close that loop. */
11283
- function rearmWrunLiveTickAfterPrefix(chartIndex, indicatorId) {
12918
+ /** An owner change of the host's session the installed context's rows never read: owed from `fromTs` at once (the
12919
+ * drain's late-point mark), and as the revised closed bar's obligation once the tick lane is loaded
12920
+ * (reviseWrunOverlayLiveFrom: the next drain reseeds as soon as the budget allows). */
12921
+ function oweWrunCompositionRevision(context, fromTs) {
12922
+ if (!Number.isFinite(fromTs))
12923
+ return;
12924
+ context.dirtyFromTs = context.dirtyFromTs === null ? fromTs : Math.min(context.dirtyFromTs, fromTs);
12925
+ const { chartIndex, indicatorId } = context;
12926
+ void loadWrunLiveTickModule()
12927
+ .then((tick) => {
12928
+ const revise = readOptionalExport(() => tick.reviseWrunOverlayLiveFrom);
12929
+ if (typeof revise === 'function' && getWrunOverlayLiveContext(indicatorId) === context) {
12930
+ revise(chartIndex, indicatorId, fromTs);
12931
+ }
12932
+ })
12933
+ .catch((error) => {
12934
+ console.warn(`[wrun] composition revision unavailable for '${indicatorId}':`, error);
12935
+ });
12936
+ }
12937
+ /** The live tick drain's re-arm (C7): after a prefix outcome, and after an adoption's session start, whose drain can
12938
+ * meet the adoption's own run still in flight. Reached lazily: the tick lane imports this module (and the chart
12939
+ * store), so a static import would close that loop. */
12940
+ function rearmWrunLiveTick(chartIndex, indicatorId) {
11284
12941
  void loadWrunLiveTickModule()
11285
12942
  .then((tick) => {
11286
12943
  const rearm = readOptionalExport(() => tick.rearmWrunLiveTickDrain);
@@ -11420,7 +13077,7 @@ function dropWrunPrefixRequest(chartIndex, indicatorId, tag, why) {
11420
13077
  if (!pendingHere && why !== 'covered' && !replaced)
11421
13078
  return;
11422
13079
  ringWrunPrefix('wrun-prefix-run-dropped', { chartIndex, indicatorId, requestId: tag.requestId, reason: why });
11423
- rearmWrunLiveTickAfterPrefix(chartIndex, indicatorId);
13080
+ rearmWrunLiveTick(chartIndex, indicatorId);
11424
13081
  }
11425
13082
  /**
11426
13083
  * A rejected prefix's full run (C1 v3), for the surviving owner only: the session the prefix was
@@ -11428,12 +13085,14 @@ function dropWrunPrefixRequest(chartIndex, indicatorId, tag, why) {
11428
13085
  * queued as a full pan wave. A newer plan that took the owner is queued already (it replans when it
11429
13086
  * starts), and a newer session's run computed the rows it stands on. True when queued.
11430
13087
  */
11431
- function queueWrunPrefixFallbackRun(indicatorId, context, requestId, fallback) {
13088
+ function queueWrunPrefixFallbackRun(indicatorId, context, requestId, fallback, gestureHeldMs = 0) {
11432
13089
  if (getWrunOverlayLiveContext(indicatorId) !== context || context.prefixOwner?.requestId !== requestId)
11433
13090
  return false;
11434
13091
  const work = rerunWrunOverlayForChartWave(indicatorId, {
11435
13092
  reason: 'lazy-range-refresh',
11436
13093
  ...(fallback ? { window: fallback } : {}),
13094
+ // One ceiling per episode (WRUN-PANBACK A1): the whole run holds only what the page left of it.
13095
+ ...(gestureHeldMs > 0 ? { gestureHeldMs } : {}),
11437
13096
  });
11438
13097
  return work !== undefined;
11439
13098
  }
@@ -11576,13 +13235,16 @@ function wrunPrefixBatchedGapRows(mountedMetas, context, sheet, child, childId,
11576
13235
  * reconcile). Packed only: the session the candidate rules admitted rode it, and a decline hands
11577
13236
  * the page to the full run.
11578
13237
  */
11579
- async function fetchWrunPrefixBookRows(context, meta, fromTs, toTs, meter) {
11580
- const { preferPackedOrderbookWorker: _packed, ...acquisition } = (context.acquisition.book ?? {});
11581
- const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, 'orderbook', { symbol: 'currentSymbol', exchange: 'currentExchange', ...acquisition }, fromTs, toTs, meta, `${context.fetchKey}-prefix-ob`, false,
13238
+ async function fetchWrunPrefixBookRows(context, meta, fromTs, toTs, meter,
13239
+ // A pinned book (U9e) asks its own market under its own lane id, with its own recorded acquisition.
13240
+ lane = 'book') {
13241
+ const { preferPackedOrderbookWorker: _packed, ...acquisition } = (context.acquisition[lane] ?? {});
13242
+ const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, 'orderbook', { symbol: 'currentSymbol', exchange: 'currentExchange', ...acquisition }, fromTs, toTs, meta, `${context.fetchKey}-prefix-${lane === 'book' ? 'ob' : lane}`, false,
11582
13243
  // The full run stamped the legend; a prefix page never restamps it.
11583
13244
  { preferPackedOrderbookWorker: true, silentLegend: true, meter }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun prefix source fetch 'orderbook' for '${context.fetchKey}'`);
13245
+ // The page's book keeps the worker's block, as the whole run's does (WRUN-PANBACK-2 S2).
11584
13246
  if (isPackedOhlcvRows(fetched))
11585
- return unpackOhlcvRows(fetched);
13247
+ return wrunPackedLaneRows('orderbook', fetched, context);
11586
13248
  if (Array.isArray(fetched))
11587
13249
  return fetched;
11588
13250
  throw new Error('the packed orderbook lane declined the prefix window');
@@ -11629,11 +13291,25 @@ function wrunPrefixDegradedPageDetail(lane, outcome) {
11629
13291
  * asks the days before its buffer from its lookback before the page (none when the buffer reaches back that far), an
11630
13292
  * asked row lane the page's host bars through the lane's own host-grid read; each degrades on an empty answer only
11631
13293
  * when the session's buffer holds none either (the page of an old stretch, a lane's horizon past it, reads empty as a
11632
- * whole run's older bars do).
13294
+ * whole run's older bars do). A trades leg on the chart's own grid (wrun-prefix-lanes.util `planWrunPrefixLanes`,
13295
+ * WRUN-PANBACK C) asks its market over the page with the request the whole run asks it with (wrun-trades-lane.util
13296
+ * `planWrunTradeLegAsk`: its payload extras, `pinnedMarket` among them) under its own fetch key
13297
+ * (`<fetchKey>-prefix-<lane id>`), quiet like the whole run's leg; a leg the planner asks at a tier on the chart now
13298
+ * declines the page (a page asks no tier).
11633
13299
  */
11634
- async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata, meter) {
13300
+ export async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata, meter) {
11635
13301
  const pages = new Map();
11636
- if (plan.builtin.length === 0 && plan.poll.length === 0 && plan.daily.length === 0 && plan.rows.length === 0) {
13302
+ // A page's own fetches take one signal, before the page's awaits, bound to the chart's dataset.
13303
+ const prefixLaneSignal = wrunLaneFetchSignal(context.indicatorId, {
13304
+ chartIndex: context.chartIndex,
13305
+ generation: getChartDataFetchGeneration(context.chartIndex),
13306
+ });
13307
+ if (plan.builtin.length === 0 &&
13308
+ plan.legs.length === 0 &&
13309
+ plan.pinned.length === 0 &&
13310
+ plan.poll.length === 0 &&
13311
+ plan.daily.length === 0 &&
13312
+ plan.rows.length === 0) {
11637
13313
  return { pages };
11638
13314
  }
11639
13315
  const toTs = beforeTs - 1;
@@ -11677,6 +13353,35 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
11677
13353
  return required ? refuseEmpty(type, rows) : rows;
11678
13354
  };
11679
13355
  }
13356
+ // A trades leg on the chart's own grid: its market over the page, the whole run's request (`planWrunTradeLegAsk` on
13357
+ // the chart now), quiet like the whole run's leg (an empty page is a quiet stretch). A leg the planner asks at a tier
13358
+ // now (the chart's grid moved under the plan) declines the page: a tier ask is the whole run's.
13359
+ thunks.tradeLegs = plan.legs.map((lane) => {
13360
+ const run = async () => {
13361
+ const legAsk = planWrunTradeLegAsk(lane, { intervalMs: context.intervalMs, venue: chartMetadata }, { fromMs, toMs: toTs });
13362
+ if (legAsk === undefined || legAsk.tier !== null) {
13363
+ throw new WrunLaneEmptyAnswer('declined', `the ${lane} source lane is asked at a tier on the chart now`);
13364
+ }
13365
+ return ask(legAsk.type, lane, legAsk.extras, undefined, { fromTs: legAsk.fromMs, toTs: legAsk.toMs });
13366
+ };
13367
+ return [lane, run];
13368
+ });
13369
+ // A pinned lane (U9e): its market over the page with the session's recorded acquisition under its own key
13370
+ // (`<fetchKey>-prefix-<lane id>`), quiet like the whole run's (a required funding lane's empty page degrades); a pinned
13371
+ // book through the packed worker its whole run rode (a decline is no page), as the chart's own book's page.
13372
+ thunks.pinnedLanes = plan.pinned.map((lane) => {
13373
+ const run = async () => {
13374
+ const pinned = wrunPinnedLaneOf(lane);
13375
+ if (pinned.cls === 'book')
13376
+ return fetchWrunPrefixBookRows(context, meta, fromMs, toTs, meter, lane);
13377
+ const { type } = WRUN_PINNED_LANE_SPECS[pinned.cls];
13378
+ const rows = await ask(type, lane, context.acquisition[lane] ?? wrunPinnedLaneExtras(lane));
13379
+ return pinned.cls === 'funding' && wrunFundingLaneRequired(context.metadata, lane)
13380
+ ? refuseEmpty(type, rows)
13381
+ : rows;
13382
+ };
13383
+ return [lane, run];
13384
+ });
11680
13385
  // A lane's own fetch (a relay feed) over a window, whole only when it says so (`onComplete`).
11681
13386
  const ownPage = async (fetch, kType, extras, window) => {
11682
13387
  let whole;
@@ -11688,6 +13393,7 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
11688
13393
  onComplete: (complete) => {
11689
13394
  whole = complete;
11690
13395
  },
13396
+ signal: prefixLaneSignal,
11691
13397
  }), WRUN_SOURCE_FETCH_DEADLINE_MS, deadlineLabel(kType)), kType);
11692
13398
  if (whole !== true) {
11693
13399
  throw new WrunLaneEmptyAnswer('declined', `the ${kType} source answered the page short of its end`);
@@ -11754,7 +13460,7 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
11754
13460
  barOpens: liveBucketStartsInRange(fromMs, toTs, context.intervalMs, barGrid),
11755
13461
  intervalMs: context.intervalMs,
11756
13462
  barGrid,
11757
- nowMs: Date.now(),
13463
+ nowMs: serverNowMs(),
11758
13464
  };
11759
13465
  thunks.rowLanes = plan.rows.map((instance) => {
11760
13466
  const run = async () => {
@@ -12101,7 +13807,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12101
13807
  const store = useChartStore();
12102
13808
  const chartMetadata = store.mergedAllCharts[chartIndex]?.metadata;
12103
13809
  // The chart's forming bar on the server clock when the session lands a leg on the chart's bars (a replay
12104
- // session's chart has none); a page builds no leg today (`planWrunPrefixFeeds` refuses them).
13810
+ // session's chart has none); a page builds a same-grid trades leg only (`planWrunPrefixLanes`, 2026-11-01); pinned legs stay refused.
12105
13811
  const formingBarTs = context.replay !== true && wrunLandsLegsOnBars(context.pinnedLegs, Object.keys(context.tradeLegRows ?? {}))
12106
13812
  ? await wrunFormingBarTsOf(chartIndex, context.intervalMs, chartMetadata)
12107
13813
  : null;
@@ -12143,6 +13849,9 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12143
13849
  }
12144
13850
  const warmSession = isWrunWarmAdmission(admission);
12145
13851
  const warmupBars = warmSession ? admission.bars : 0;
13852
+ // A converging session's tolerance (STAMPS round A): the page's own head is held to the gaps rule below and its
13853
+ // overlap proof compares the row outputs within it; an exact session has none and is proven as it always was.
13854
+ const convergingTolerance = warmSession ? admission.tolerance : undefined;
12146
13855
  let headRows = [];
12147
13856
  let head;
12148
13857
  if (warmSession) {
@@ -12163,6 +13872,18 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12163
13872
  warmupRows: 0,
12164
13873
  });
12165
13874
  }
13875
+ // A converging page's running start must hold W ACCEPTED inputs (the gaps rule the admission holds the session's
13876
+ // held head to; once this page lands, its head is that held head): a head candle with a field that is not finite
13877
+ // would leave the page's first rows short of the bound, and the overlap proof never reads them. The data's, never
13878
+ // the module's: no latch, the full run follows.
13879
+ const gapAt = convergingTolerance !== undefined ? wrunWarmupHeadGapAt(acquired.rows) : undefined;
13880
+ if (gapAt !== undefined) {
13881
+ return wrunPrefixRejected('warmup-gaps', `the running start holds a candle field that is not finite at ${gapAt}`, {
13882
+ firstMismatchTs: null,
13883
+ warmupBars,
13884
+ warmupRows: acquired.rows.length,
13885
+ });
13886
+ }
12166
13887
  head = acquired;
12167
13888
  headRows = acquired.rows;
12168
13889
  if (headRows.length > 0)
@@ -12192,7 +13913,14 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12192
13913
  return wrunPrefixRejected('stale', lanePages.degraded);
12193
13914
  const laneWindow = wrunPrefixFeedWindowLanes(context, lanePlan, lanePages.pages, firstRowTs, window.toMs);
12194
13915
  const chartExchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : undefined;
12195
- const clock = { intervalMs: context.intervalMs, nowMs: Date.now() };
13916
+ // The session's as-of beside the page's now (wrun-history-as-of.util): the lanes rule admits no declared depth into a
13917
+ // page today (`lanes:legs`, `tape-history`), so it splits nothing, and a page that one day reads one counts it back
13918
+ // from the session's instant, as the whole run it stands in for does.
13919
+ const clock = {
13920
+ intervalMs: context.intervalMs,
13921
+ nowMs: serverNowMs(),
13922
+ historyAsOfMs: context.historyAsOfMs,
13923
+ };
12196
13924
  const sourceRows = {
12197
13925
  ohlcvRows: windowRows,
12198
13926
  ...(bookRows !== undefined ? { bookRows } : {}),
@@ -12205,8 +13933,15 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12205
13933
  venue: wrunBarVenueOf(chartMetadata, clock.intervalMs),
12206
13934
  formingBarTs,
12207
13935
  };
12208
- // Only the row builder sees the head: the canvases' rows and every landing read the window's own.
12209
- const rows = buildWrunInputRows(context.metadata, headRows.length > 0 ? { ...sourceRows, ohlcvRows: computeRows } : sourceRows, clock);
13936
+ // Only the row builder sees the head: the canvases' rows and every landing read the window's own. A page is every
13937
+ // bar before the session's first row, so the host session's composition (wrun-session-composition.util) answers
13938
+ // its OpenMarket rows there; it is read here all the same, so no read point of the lanes skips it.
13939
+ const rows = buildWrunInputRows(context.metadata, composeWrunSessionSources({
13940
+ chartIndex: context.chartIndex,
13941
+ indicatorId: context.indicatorId,
13942
+ intervalMs: clock.intervalMs,
13943
+ lanes: wrunSessionLanesOfContext(context),
13944
+ }, headRows.length > 0 ? { ...sourceRows, ohlcvRows: computeRows } : sourceRows).sources, clock);
12210
13945
  if (rows.length === 0)
12211
13946
  return wrunPrefixRejected('stale', 'the window holds no input rows');
12212
13947
  // An exact warm-up session's evaluated candles, fingerprinted in the same synchronous block as the guest's input
@@ -12248,7 +13983,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12248
13983
  title: runTarget.title,
12249
13984
  params: paramValues,
12250
13985
  texts: wrunTextParamValuesFromSettings(sheetNow, meta.settings),
12251
- legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
13986
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, undefined, context.cmeDelayed),
12252
13987
  position: runTarget.position,
12253
13988
  axis: runTarget.axis ?? true,
12254
13989
  colors: runTarget.colors,
@@ -12389,6 +14124,21 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12389
14124
  ...(warmup !== undefined
12390
14125
  ? { candleEvidence: { warmupBars, prefix: warmup.evaluated, mounted: context.candleEvidence } }
12391
14126
  : {}),
14127
+ // The one place a converging session hands its tolerance over (STAMPS round A): the row outputs alone compare
14128
+ // within it, every selector column (an output any `*_by` or `*_where` field, a `where` gate, `badges` or a hover
14129
+ // block's `output` names, and a barcolor output, on the stamped sheet or the one the settings paint) exactly, and
14130
+ // so does everything else the proof reads.
14131
+ ...(convergingTolerance !== undefined
14132
+ ? {
14133
+ outputTolerance: {
14134
+ tolerance: convergingTolerance,
14135
+ exactColumns: new Set([
14136
+ ...wrunHistoryStampExactColumns(context.metadata),
14137
+ ...wrunHistoryStampExactColumns(sheetNow),
14138
+ ]),
14139
+ },
14140
+ }
14141
+ : {}),
12392
14142
  });
12393
14143
  // Whether the mounted rows over the overlap may rest on inputs the session's buffers no longer hold (a lane row a
12394
14144
  // reconcile revised since they were computed, an owed reseed, a chain snapshot stamped inside it): no mismatch there
@@ -12651,9 +14401,10 @@ function wrunPrefixStaleReason(prepared, tc, meta, chartOwner, indicatorId) {
12651
14401
  * the same way, each prepared heatmap landing, and the session extended (its first row, its rows
12652
14402
  * and book prefixed, its lanes' start, its window gone, the owner landed). A failure after the
12653
14403
  * parent applied puts the overlay's own rows back (an owner-scoped rollback) and the landings that
12654
- * did not commit are discarded.
14404
+ * did not commit are discarded. `beforeApply` runs right before the first chart write, once every validation passed
14405
+ * (the install ring, WRUN-PANBACK A1).
12655
14406
  */
12656
- function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
14407
+ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId, beforeApply) {
12657
14408
  const commitStartedAt = wrunHostClockMs();
12658
14409
  const stale = wrunPrefixStaleReason(prepared, tc, meta, chartOwner, indicatorId);
12659
14410
  if (stale !== null) {
@@ -12712,6 +14463,7 @@ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
12712
14463
  };
12713
14464
  const span = { fromMs: window.fromMs, toMs: window.toMs };
12714
14465
  let parentApplied = false;
14466
+ beforeApply?.();
12715
14467
  try {
12716
14468
  withWrunOverlayExecutionMeasure(chartIndex, indicatorId, 'wrun-integrate', () => {
12717
14469
  const refresh = wrunChartHostEnv().chart.refreshMountedRows({
@@ -12828,6 +14580,8 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12828
14580
  const landings = [];
12829
14581
  let prepared;
12830
14582
  let outcome;
14583
+ // How long the page held for the gesture (WRUN-PANBACK A1): a whole run it falls back to holds only the rest.
14584
+ let gestureHeldMs = 0;
12831
14585
  try {
12832
14586
  const ready = await prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt, computed);
12833
14587
  if (ready.kind === 'rejected') {
@@ -12835,12 +14589,29 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12835
14589
  }
12836
14590
  else {
12837
14591
  prepared = ready;
12838
- outcome = await withWrunOverlaySessionLock(indicatorId, () => {
14592
+ // The page waits for the gesture's idle edge before the session lock, then commits synchronously at the grant
14593
+ // (a gesture that started again while the lock waited holds it again outside the lock, while the budget lasts).
14594
+ const reason = runTarget.reason ?? 'loaded-range-refresh';
14595
+ const committed = await commitWrunPrefixAtGestureEdge(chartIndex, indicatorId, reason, { ceilingMs: wrunInstallGestureCeilingMs(runTarget.gestureHeldMs) }, (heldMs, pacedMs) => {
14596
+ gestureHeldMs = heldMs;
12839
14597
  // A CME chart study's page lands only under the authorisation its head captured (a refusal here goes to the
12840
14598
  // full run, which judges the wall again).
12841
14599
  assertWrunCmeStudyAuthCurrent(computed, indicatorId);
12842
- return commitWrunPrefixRun(ready, tc, meta, owner, indicatorId);
14600
+ return commitWrunPrefixRun(ready, tc, meta, owner, indicatorId, () => ringWrunInstallApplied(chartIndex, indicatorId, reason, heldMs, pacedMs));
12843
14601
  });
14602
+ if (committed.kind === 'committed') {
14603
+ outcome = committed.value;
14604
+ }
14605
+ else {
14606
+ // A user run queued during the hold replaces the session: the page is dropped as superseded, quietly (no full
14607
+ // run follows it), and the queued run proceeds.
14608
+ gestureHeldMs = committed.heldMs;
14609
+ wrunChartHostEnv().diagnostics.debug('wrun-install-yielded', { chartIndex, indicatorId, reason });
14610
+ outcome = wrunPrefixRejected('stale', 'a run a person asked for is queued (yielded at the gesture hold)', {
14611
+ firstMismatchTs: null,
14612
+ quiet: true,
14613
+ });
14614
+ }
12844
14615
  }
12845
14616
  }
12846
14617
  catch (error) {
@@ -12883,9 +14654,9 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12883
14654
  });
12884
14655
  }
12885
14656
  if (!outcome.quiet && context !== undefined) {
12886
- queueWrunPrefixFallbackRun(indicatorId, context, window.prefix.requestId, window.prefix.fallback);
14657
+ queueWrunPrefixFallbackRun(indicatorId, context, window.prefix.requestId, window.prefix.fallback, (runTarget.gestureHeldMs ?? 0) + gestureHeldMs);
12887
14658
  }
12888
- rearmWrunLiveTickAfterPrefix(chartIndex, indicatorId);
14659
+ rearmWrunLiveTick(chartIndex, indicatorId);
12889
14660
  return;
12890
14661
  }
12891
14662
  if (wrunChartHostEnv().diagnostics.debugEnabled()) {
@@ -12911,7 +14682,7 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12911
14682
  : {}),
12912
14683
  });
12913
14684
  }
12914
- rearmWrunLiveTickAfterPrefix(chartIndex, indicatorId);
14685
+ rearmWrunLiveTick(chartIndex, indicatorId);
12915
14686
  if (prepared === undefined)
12916
14687
  return;
12917
14688
  // One apply sample for the host's main-thread work, the full run's integrate's rule (G3a).
@@ -12935,6 +14706,17 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
12935
14706
  catch (error) {
12936
14707
  console.warn(`[wrun] run health after a prefix run failed for '${indicatorId}':`, error);
12937
14708
  }
14709
+ // The viewer's nothing-drawn note over the session's rows with the older bars (FB27), held for the warm-up ask
14710
+ // below like a full run's: a page it buys reruns the overlay first.
14711
+ const warmupPage = wrunWarmupPageVerdict();
14712
+ await publishWrunNothingDrawn(chartIndex, indicatorId, {
14713
+ draft: context.draft === true,
14714
+ settled: context.window?.partial !== true && wrunSessionSourceAbsent.get(context) !== true,
14715
+ metadata: sheetNow,
14716
+ rows: context.outputRows,
14717
+ drawings: wrunHandlesOf(context.outputRows)?.length,
14718
+ runIntervalMs: context.intervalMs,
14719
+ }, () => refusal.ctx, { warmup: warmupPage, isCurrent: () => isWrunRunMountOnChart(chartIndex, { tc, meta }) });
12938
14720
  const chartInterval = typeof prepared.chartMetadata?.interval === 'string' ? prepared.chartMetadata.interval : '';
12939
14721
  askWrunWarmupBackfillIfOwed({
12940
14722
  chartIndex,
@@ -12957,12 +14739,29 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
12957
14739
  lookbackBars: wrunTwinLookbackBars(meta.settings) ?? (await wrunTwinOriginalLookbackBars(meta.settings, context.intervalMs)),
12958
14740
  unsettledLanes: new Set(),
12959
14741
  planGeneration: prepared.planGeneration,
12960
- // Where the history the session read begins: its row lanes', unless it read another source beside the candles (a
12961
- // pinned leg, or any lane its acquisitions name that is no row lane).
12962
- historySources: {
12963
- rowLanes: context.rowLanes ?? [],
12964
- readsOtherSources: (context.pinnedLegs?.length ?? 0) > 0 ||
12965
- Object.keys(context.acquisition).some((lane) => !isWrunRowLaneId(lane)),
12966
- },
14742
+ // Where the history the session read begins: every lane its acquisitions name and every leg, from its first row.
14743
+ historySources: { lanes: wrunSessionHistoryLanesOf(context), askedFromMs: context.firstRowTs },
14744
+ onNoPage: warmupPage.noPage,
14745
+ });
14746
+ }
14747
+ /** A session's lanes (its acquisitions name each) and legs, with the rows it keeps by lane id; a built-in lane names
14748
+ * no reach, so it reads as unknown whatever its buffer holds. */
14749
+ function wrunSessionHistoryLanesOf(context) {
14750
+ const lanes = Object.keys(context.acquisition).map((lane) => ({
14751
+ lane,
14752
+ rows: isWrunRowLaneId(lane)
14753
+ ? context.rowLaneRows?.[lane]
14754
+ : isWrunTradesLegLane(lane)
14755
+ ? context.tradeLegRows?.[lane]
14756
+ : isWrunPinnedLaneId(lane)
14757
+ ? context.pinnedLaneRows?.[lane]
14758
+ : context.pollLaneRows?.[lane],
14759
+ }));
14760
+ return wrunRunHistoryLanesOf({
14761
+ lanes,
14762
+ rowLanes: context.rowLanes ?? [],
14763
+ pollLanes: context.pollLanes ?? [],
14764
+ legs: context.pinnedLegs ?? [],
14765
+ legRows: (fetchKey) => context.pinnedCandleRows?.[fetchKey] ?? context.intrabarRows?.[fetchKey],
12967
14766
  });
12968
14767
  }