@orangecharts/wrun-chart-host 0.11.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +4 -4
  3. package/dist/constants/feature-flags.constants.js +38 -52
  4. package/dist/constants/feature-limits.constants.d.ts +1 -1
  5. package/dist/constants/feature-limits.constants.js +5 -4
  6. package/dist/constants/interval.constants.d.ts +7 -0
  7. package/dist/constants/interval.constants.js +7 -0
  8. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +20 -149
  9. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +20 -309
  10. package/dist/constants/stocks-compliance.constants.d.ts +15 -0
  11. package/dist/constants/stocks-compliance.constants.js +15 -0
  12. package/dist/host-env.d.ts +69 -3
  13. package/dist/host-env.js +21 -0
  14. package/dist/host-ports.types.d.ts +36 -3
  15. package/dist/index.d.ts +18 -0
  16. package/dist/index.js +19 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +52 -12
  18. package/dist/indicators/controls/tpo-session.util.js +113 -16
  19. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +6 -0
  20. package/dist/instances/script-engine-worker-ohlcv-transfer.js +16 -0
  21. package/dist/interfaces/cme-realtime.interface.d.ts +8 -0
  22. package/dist/interfaces/cme-realtime.interface.js +2 -1
  23. package/dist/interfaces/feed.interface.d.ts +15 -1
  24. package/dist/interfaces/replay.interface.d.ts +5 -0
  25. package/dist/interfaces/stocks-realtime.interface.d.ts +4 -3
  26. package/dist/interfaces/stocks-realtime.interface.js +5 -4
  27. package/dist/interfaces/wrun-runtime.interface.d.ts +141 -20
  28. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +17 -0
  29. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +22 -0
  30. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +46 -40
  31. package/dist/kscript-data/controls/live-trades-merge.util.js +80 -107
  32. package/dist/market-data/billing.interface.d.ts +9 -1
  33. package/dist/market-data/venue.d.ts +1 -1
  34. package/dist/market-data/venues/index.d.ts +5 -5
  35. package/dist/market-data/venues/opra.js +3 -3
  36. package/dist/market-data/venues/stocks.contract.copy.json +6 -5
  37. package/dist/market-data/venues/stocks.d.ts +5 -5
  38. package/dist/market-data/venues/stocks.js +21 -18
  39. package/dist/settings-templates/frvp-fields.d.ts +12 -1
  40. package/dist/settings-templates/frvp-fields.js +15 -4
  41. package/dist/settings-templates/index.js +12 -5
  42. package/dist/settings-templates/indicator-fields.js +43 -2
  43. package/dist/settings-templates/tool-rules.d.ts +17 -8
  44. package/dist/settings-templates/tool-rules.js +15 -8
  45. package/dist/settings-templates/tool-tables.generated.js +4 -2
  46. package/dist/utility/auth/server-clock.util.d.ts +3 -1
  47. package/dist/utility/auth/server-clock.util.js +3 -1
  48. package/dist/utility/chart/book-live-bucket.util.js +2 -2
  49. package/dist/utility/chart/cache-alignment.util.d.ts +38 -7
  50. package/dist/utility/chart/cache-alignment.util.js +50 -13
  51. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +2 -0
  52. package/dist/utility/chart/chart-data-fetch-generation.util.js +16 -0
  53. package/dist/utility/chart/cme-session-bucket.util.d.ts +18 -75
  54. package/dist/utility/chart/cme-session-bucket.util.js +25 -332
  55. package/dist/utility/chart/continuous-contracts.util.js +6 -5
  56. package/dist/utility/chart/display-offset.leaf.d.ts +24 -0
  57. package/dist/utility/chart/display-offset.leaf.js +41 -0
  58. package/dist/utility/chart/effective-chart-session.util.d.ts +2 -1
  59. package/dist/utility/chart/effective-chart-session.util.js +13 -5
  60. package/dist/utility/chart/feed-interval.util.d.ts +6 -20
  61. package/dist/utility/chart/feed-interval.util.js +13 -22
  62. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +27 -7
  63. package/dist/utility/chart/fetch-dedupe-policy.util.js +86 -11
  64. package/dist/utility/chart/footprint-band.util.d.ts +21 -5
  65. package/dist/utility/chart/footprint-band.util.js +53 -14
  66. package/dist/utility/chart/host-bar-placement.util.d.ts +7 -4
  67. package/dist/utility/chart/host-bar-placement.util.js +8 -2
  68. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +32 -0
  69. package/dist/utility/chart/indicator-inflight-registry.util.js +52 -0
  70. package/dist/utility/chart/indicator-run-interval.util.d.ts +10 -4
  71. package/dist/utility/chart/indicator-run-interval.util.js +21 -12
  72. package/dist/utility/chart/interval-registry.util.d.ts +1 -1
  73. package/dist/utility/chart/interval-registry.util.js +1 -1
  74. package/dist/utility/chart/kscript-legend-entries.util.d.ts +12 -0
  75. package/dist/utility/chart/kscript-legend-entries.util.js +16 -0
  76. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +1 -1
  77. package/dist/utility/chart/kscript-run-interval-projection.util.js +4 -2
  78. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -62
  79. package/dist/utility/chart/kscript-venue-policy.util.js +85 -94
  80. package/dist/utility/chart/live-bucket.util.d.ts +39 -17
  81. package/dist/utility/chart/live-bucket.util.js +103 -57
  82. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +58 -20
  83. package/dist/utility/chart/local-kscript-source-revalidation.util.js +98 -23
  84. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +35 -11
  85. package/dist/utility/chart/local-kscript-warmup-depth.util.js +24 -3
  86. package/dist/utility/chart/market-session-schedule.util.d.ts +8 -0
  87. package/dist/utility/chart/market-session-schedule.util.js +39 -1
  88. package/dist/utility/chart/market-session.util.d.ts +136 -0
  89. package/dist/utility/chart/market-session.util.js +341 -0
  90. package/dist/utility/chart/om-panel.util.d.ts +5 -3
  91. package/dist/utility/chart/om-panel.util.js +42 -7
  92. package/dist/utility/chart/om-target.util.d.ts +14 -1
  93. package/dist/utility/chart/om-target.util.js +22 -5
  94. package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
  95. package/dist/utility/chart/opra-read-access.leaf.js +22 -0
  96. package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
  97. package/dist/utility/chart/profile-row-height.util.js +74 -37
  98. package/dist/utility/chart/rth-session.util.d.ts +55 -20
  99. package/dist/utility/chart/rth-session.util.js +94 -46
  100. package/dist/utility/chart/session-lattice.util.d.ts +150 -0
  101. package/dist/utility/chart/session-lattice.util.js +488 -0
  102. package/dist/utility/chart/trading-day.util.d.ts +40 -2
  103. package/dist/utility/chart/trading-day.util.js +84 -7
  104. package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
  105. package/dist/utility/chart/us-equities-session.util.js +44 -15
  106. package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
  107. package/dist/utility/chart/window-geometry.leaf.js +57 -8
  108. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
  109. package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
  110. package/dist/utility/chart/wrun-run-result.util.d.ts +38 -13
  111. package/dist/utility/chart/wrun-run-result.util.js +97 -27
  112. package/dist/utility/common/time.util.js +5 -4
  113. package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
  114. package/dist/utility/market-events/earnings-scope.util.js +17 -9
  115. package/dist/utility/market-events/market-events.util.d.ts +14 -7
  116. package/dist/utility/market-events/market-events.util.js +30 -17
  117. package/dist/utility/number-format.util.d.ts +14 -21
  118. package/dist/utility/number-format.util.js +38 -24
  119. package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
  120. package/dist/utility/options/option-venue-disclosure.util.js +71 -11
  121. package/dist/utility/options/option-venue.util.d.ts +1 -1
  122. package/dist/utility/options/option-venue.util.js +1 -1
  123. package/dist/utility/pool-symbol.leaf.d.ts +7 -0
  124. package/dist/utility/pool-symbol.leaf.js +50 -5
  125. package/dist/utility/stocks/stock-display.util.d.ts +15 -0
  126. package/dist/utility/stocks/stock-display.util.js +37 -0
  127. package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
  128. package/dist/utility/v2/gate-plane.util.d.ts +6 -0
  129. package/dist/utility/v2/gate-plane.util.js +11 -1
  130. package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
  131. package/dist/utility/v2/gate-session-latch.util.js +3 -3
  132. package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
  133. package/dist/utility/v2/governed-tier.leaf.js +17 -16
  134. package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
  135. package/dist/utility/v2/stocks-governed.util.js +14 -0
  136. package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
  137. package/dist/utility/v2/v2-enums.leaf.js +458 -0
  138. package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
  139. package/dist/utility/wrun/derived-roots.leaf.js +27 -1
  140. package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
  141. package/dist/utility/wrun/derived-roots.util.js +97 -56
  142. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
  143. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
  144. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
  145. package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
  146. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
  147. package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
  148. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
  149. package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
  150. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
  151. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
  152. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  153. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
  154. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
  155. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
  156. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
  157. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
  158. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
  159. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
  160. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
  161. package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
  162. package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
  163. package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
  164. package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
  165. package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
  166. package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
  167. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +46 -23
  168. package/dist/utility/wrun/wrun-batched-marks.util.js +260 -62
  169. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
  170. package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
  171. package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
  172. package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
  173. package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
  174. package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
  175. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
  176. package/dist/utility/wrun/wrun-canvases.util.d.ts +24 -7
  177. package/dist/utility/wrun/wrun-canvases.util.js +99 -30
  178. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
  179. package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
  180. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
  181. package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
  182. package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
  183. package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
  184. package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
  185. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
  186. package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
  187. package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
  188. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
  189. package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
  190. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
  191. package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
  192. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
  193. package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
  194. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
  195. package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
  196. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
  197. package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
  198. package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
  199. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
  200. package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
  201. package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
  202. package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
  203. package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
  204. package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
  205. package/dist/utility/wrun/wrun-host.service.js +137 -27
  206. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
  207. package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
  208. package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
  209. package/dist/utility/wrun/wrun-hover.util.js +24 -13
  210. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
  211. package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
  212. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
  213. package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
  214. package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
  215. package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
  216. package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
  217. package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
  218. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
  219. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
  220. package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
  221. package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
  222. package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
  223. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
  224. package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
  225. package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
  226. package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
  227. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
  228. package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
  229. package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
  230. package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
  231. package/dist/utility/wrun/wrun-live-tick.util.js +655 -97
  232. package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
  233. package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
  234. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
  235. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
  236. package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
  237. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
  238. package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
  239. package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
  240. package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
  241. package/dist/utility/wrun/wrun-option-views.util.js +5 -2
  242. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
  243. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
  244. package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
  245. package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
  246. package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
  247. package/dist/utility/wrun/wrun-output-words.util.js +51 -0
  248. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +116 -11
  249. package/dist/utility/wrun/wrun-overlay-drivers.util.js +208 -43
  250. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
  251. package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
  252. package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
  253. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
  254. package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
  255. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
  256. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  257. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +247 -26
  258. package/dist/utility/wrun/wrun-overlay-run.util.js +2234 -408
  259. package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
  260. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +11 -2
  261. package/dist/utility/wrun/wrun-panel-mount.util.js +122 -19
  262. package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
  263. package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
  264. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
  265. package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
  266. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
  267. package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
  268. package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
  269. package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
  270. package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
  271. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
  272. package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
  273. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
  274. package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
  275. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
  276. package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
  277. package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
  278. package/dist/utility/wrun/wrun-refusal.util.js +103 -16
  279. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
  280. package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
  281. package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
  282. package/dist/utility/wrun/wrun-run-health.util.d.ts +95 -5
  283. package/dist/utility/wrun/wrun-run-health.util.js +209 -3
  284. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
  285. package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
  286. package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
  287. package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
  288. package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
  289. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +38 -11
  290. package/dist/utility/wrun/wrun-script-inputs.util.js +194 -56
  291. package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
  292. package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
  293. package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
  294. package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
  295. package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
  296. package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
  297. package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
  298. package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
  299. package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
  300. package/dist/utility/wrun/wrun-style-names.util.js +74 -0
  301. package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
  302. package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
  303. package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
  304. package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
  305. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
  306. package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
  307. package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
  308. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
  309. package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
  310. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
  311. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
  312. package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
  313. package/dist/utility/wrun/wrun-visibility-table.js +9 -0
  314. package/dist/utility/wrun/wrun-volume-profile.util.js +7 -3
  315. package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
  316. package/dist/utils/replay/replay-buffer-math.js +60 -30
  317. package/dist/workers/constants/socket-slots.d.ts +11 -7
  318. package/dist/workers/constants/socket-slots.js +6 -5
  319. package/package.json +5 -5
@@ -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, wrunPictureIdentityOf, } 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,
@@ -1605,7 +1677,9 @@ export function wrunChartRunHealth(metadata, settings, outputRows, sourceAbsent,
1605
1677
  ...output,
1606
1678
  visible: wrunOutputShownOnChart(output, settings, owned) && wrunRowVisibleHere(output.visible_by, sizeUnit),
1607
1679
  })),
1608
- }, outputRows);
1680
+ }, outputRows,
1681
+ // The chip names a silent line by the words the legend does: a built-in's port in its built-in's words.
1682
+ builtinPortOf(settings));
1609
1683
  if (!sourceAbsent || watched.silentOutputs.length === 0)
1610
1684
  return { watched, health: watched };
1611
1685
  return {
@@ -1646,8 +1720,12 @@ exchangeOf) {
1646
1720
  if (key === undefined || outcome.kind !== 'rows' || outcome.rows.length > 0 || unsettled.has(key))
1647
1721
  return [];
1648
1722
  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)));
1723
+ // The lane's own readers: a trades input pinned to another market reads its leg lane instead, and a book, oi,
1724
+ // funding or liquidations input pinned to another market its pinned lane (U9e).
1725
+ const readers = wrunInputNamesOfClass(metadata, lane, (source) => {
1726
+ const read = wrunSourceLane(source);
1727
+ return !isWrunTradesLegLane(read) && !isWrunPinnedLaneId(read);
1728
+ });
1651
1729
  const type = WRUN_BUILTIN_LANE_FETCH_TYPES[lane];
1652
1730
  return [
1653
1731
  {
@@ -1764,10 +1842,13 @@ function enterWrunRefusalRun(guardKey) {
1764
1842
  }
1765
1843
  function leaveWrunRefusalRun(guardKey) {
1766
1844
  const left = (wrunRefusalRunsInFlight.get(guardKey) ?? 1) - 1;
1767
- if (left > 0)
1845
+ if (left > 0) {
1768
1846
  wrunRefusalRunsInFlight.set(guardKey, left);
1769
- else
1770
- wrunRefusalRunsInFlight.delete(guardKey);
1847
+ return;
1848
+ }
1849
+ wrunRefusalRunsInFlight.delete(guardKey);
1850
+ // The run's own arm may have turned its sources terminal while it was in flight: a held warm-up ask reads that now.
1851
+ wrunWarmupLandingListener(guardKey);
1771
1852
  }
1772
1853
  function dropWrunTerminalDegradeWatch(guardKey) {
1773
1854
  wrunTerminalDegradeWatches.delete(guardKey);
@@ -1854,6 +1935,10 @@ function wrunSourceGivenUpOf(outcome) {
1854
1935
  * refuses by name names its record here.
1855
1936
  */
1856
1937
  const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1938
+ // No order book on the market: feed-missing (a note beside drawn rows, paused on a hold), never Remove or Retry.
1939
+ book: {
1940
+ [WRUN_NO_ORDER_BOOK_CODE]: () => ({ cls: 'feed-missing', params: { feed: 'book' } }),
1941
+ },
1857
1942
  // The tape's history held more prints at its floor than the trades worker reads (k-trades.worker, the large lane):
1858
1943
  // too much data, with the cap, the floor and the history's days (seven for Big Trades), and the way out raises the
1859
1944
  // floor in the settings. Never Remove: the market serves the tape, the floor was too low for it.
@@ -1866,7 +1951,9 @@ const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1866
1951
  setting: wrunTapeFloorSettingWords(metadata),
1867
1952
  // The floor in its own unit: the raw number under `min_size` (as it always was), a dollar amount under
1868
1953
  // `min_value` ($500,000).
1869
- min: tape?.minValue === undefined ? (tape?.minSize ?? 0) : wrunTapeFloorWords(tape),
1954
+ min: tape?.minValue === undefined && tape?.minCoins === undefined
1955
+ ? (tape?.minSize ?? 0)
1956
+ : wrunTapeFloorWords(tape),
1870
1957
  n: tape === undefined ? 0 : Math.round((tape.historySeconds / 86_400) * 10) / 10,
1871
1958
  },
1872
1959
  out: { kind: 'open-settings' },
@@ -1875,10 +1962,18 @@ const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1875
1962
  };
1876
1963
  /** The seed a row-builder lane declares for a refusal by name, or undefined (a poll lane, an undeclared code). */
1877
1964
  function wrunBuiltinLaneRefusedSeed(lane, code, facts) {
1878
- if (!Object.hasOwn(WRUN_BUILTIN_LANE_REFUSED_ANSWERS, lane))
1965
+ // A pinned lane (U9e) answers in its class's record, naming its own market rather than the chart's.
1966
+ const pinned = wrunPinnedLaneOf(lane);
1967
+ const builtin = pinned?.cls ?? lane;
1968
+ if (!Object.hasOwn(WRUN_BUILTIN_LANE_REFUSED_ANSWERS, builtin))
1969
+ return undefined;
1970
+ const answers = WRUN_BUILTIN_LANE_REFUSED_ANSWERS[builtin];
1971
+ if (answers === undefined || !Object.hasOwn(answers, code))
1879
1972
  return undefined;
1880
- const answers = WRUN_BUILTIN_LANE_REFUSED_ANSWERS[lane];
1881
- return answers !== undefined && Object.hasOwn(answers, code) ? answers[code](facts) : undefined;
1973
+ const seed = answers[code](facts);
1974
+ if (pinned === undefined)
1975
+ return seed;
1976
+ return { ...seed, market: { exchange: pinned.exchange, symbol: pinned.symbol, label: pinned.symbol } };
1882
1977
  }
1883
1978
  /**
1884
1979
  * The record a degraded lane shows once the source ladder gives up on it: the code of what it was
@@ -1961,10 +2056,10 @@ async function settleWrunRefusalsOnHold(guardKey, target, refusal, token, isCurr
1961
2056
  }
1962
2057
  /** A reseed's refusals (a full run over the buffers): every owner's verdict retracted, then the last
1963
2058
  * full run's terminal lane said again (the reseed computed over the same empty lane). */
1964
- async function settleWrunRefusalsOnReseed(chartIndex, indicatorId) {
2059
+ async function settleWrunRefusalsOnReseed(chartIndex, indicatorId, isCurrent) {
1965
2060
  try {
1966
2061
  const target = { chartIndex, indicatorId };
1967
- await retractWrunRefusal(target, 'all');
2062
+ await retractWrunRefusal(target, 'all', isCurrent !== undefined ? { isCurrent } : {});
1968
2063
  const guardKey = overlayExecutionGuardKey(chartIndex, indicatorId);
1969
2064
  const watch = wrunTerminalDegradeWatches.get(guardKey);
1970
2065
  const terminal = watch ? wrunTerminalDegradeRefusalOf(guardKey, watch) : undefined;
@@ -1972,7 +2067,7 @@ async function settleWrunRefusalsOnReseed(chartIndex, indicatorId) {
1972
2067
  await projectWrunRefusal(watch.target, terminal, {
1973
2068
  owner: 'run',
1974
2069
  notify: false,
1975
- isCurrent: () => wrunTerminalDegradeWatches.get(guardKey) === watch,
2070
+ isCurrent: () => wrunTerminalDegradeWatches.get(guardKey) === watch && isCurrent?.() !== false,
1976
2071
  });
1977
2072
  }
1978
2073
  }
@@ -2065,6 +2160,82 @@ async function publishWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, diagnos
2065
2160
  export async function publishWrunRunHealth(chartIndex, indicatorId, diagnostics, options = {}) {
2066
2161
  return publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_RUN_HEALTH_ROW_CODES, diagnostics, options);
2067
2162
  }
2163
+ /** The overlays whose viewer note `WRUN_NOTHING_DRAWN` stands, by chart and overlay id: an integrate that draws (a
2164
+ * live tick's included) lowers it without a store read on every tick. */
2165
+ const wrunNothingDrawnRaised = new Set();
2166
+ /** The newest note decision of each overlay (same key): a raise held for the warm-up verdict publishes only while it is
2167
+ * the newest, and an integrate that draws drops it. */
2168
+ const wrunNothingDrawnDecisions = new Map();
2169
+ function wrunNothingDrawnKey(chartIndex, indicatorId) {
2170
+ return `${chartIndex}:${indicatorId}`;
2171
+ }
2172
+ /** The leg rule the note's cause is read with: the interval pin vocabulary, and the warm-up floor the leg fetch gives a
2173
+ * coarser leg (a reach under it is short). */
2174
+ const WRUN_NOTHING_DRAWN_LEG_RULE = {
2175
+ intervalOf: wrunPinnedIntervalOf,
2176
+ floor: WRUN_COARSER_LEG_WARMUP_CANDLES,
2177
+ };
2178
+ /**
2179
+ * The viewer's nothing-drawn note (wrun-run-health.util, FB27) after a full run, a reseed, an adoption or a landed
2180
+ * page: raised when a published Indicator's settled run drew nothing over its whole loaded window (with the cause when
2181
+ * 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
2182
+ * settled (a partial window, a first slice still filling, a lane unanswered, a source with a note of its own) leaves
2183
+ * it as it stands. A run that asks the warm-up decider (`warmup`) holds its raise until the decider says no older page
2184
+ * is coming: a page it buys reruns the overlay, and that run decides, so no load in flight is ever named empty. The
2185
+ * refusal context is built only for a note. Advisory like the health rows.
2186
+ */
2187
+ export async function publishWrunNothingDrawn(chartIndex, indicatorId, run, refusalContext, options = {}) {
2188
+ try {
2189
+ const verdict = wrunViewerNothingDrawn({ ...run, legs: WRUN_NOTHING_DRAWN_LEG_RULE });
2190
+ if (verdict === undefined)
2191
+ return;
2192
+ const key = wrunNothingDrawnKey(chartIndex, indicatorId);
2193
+ const decision = Symbol(key);
2194
+ wrunNothingDrawnDecisions.set(key, decision);
2195
+ const publish = async () => {
2196
+ if (wrunNothingDrawnDecisions.get(key) !== decision)
2197
+ return;
2198
+ const rows = verdict === null ? [] : wrunNothingDrawnDiagnostics(verdict, await refusalContext());
2199
+ // A newer run decided, or a draw dropped the raise, while the context was built.
2200
+ if (wrunNothingDrawnDecisions.get(key) !== decision)
2201
+ return;
2202
+ wrunNothingDrawnDecisions.delete(key);
2203
+ const standing = await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_NOTHING_DRAWN_ROW_CODES, rows, options.isCurrent !== undefined ? { isCurrent: options.isCurrent } : {});
2204
+ if (standing)
2205
+ wrunNothingDrawnRaised.add(key);
2206
+ else
2207
+ wrunNothingDrawnRaised.delete(key);
2208
+ };
2209
+ if (verdict !== null && options.warmup !== undefined) {
2210
+ options.warmup.whenNoPage(() => void publish().catch(() => undefined));
2211
+ return;
2212
+ }
2213
+ await publish();
2214
+ }
2215
+ catch {
2216
+ /* advisory rows: never a second failure on the run path */
2217
+ }
2218
+ }
2219
+ /** Drop the overlay's note bookkeeping (a failed run clears the note's row with the run's other notes): a raise held
2220
+ * for the warm-up verdict never lands after it. */
2221
+ function forgetWrunNothingDrawn(chartIndex, indicatorId) {
2222
+ const key = wrunNothingDrawnKey(chartIndex, indicatorId);
2223
+ wrunNothingDrawnDecisions.delete(key);
2224
+ wrunNothingDrawnRaised.delete(key);
2225
+ }
2226
+ /** A nothing-drawn note goes the moment an integrate draws, standing or held for the warm-up verdict: the presentation
2227
+ * of every integrate calls this (a live tick's too, which re-reads only the health rows). */
2228
+ function lowerWrunNothingDrawnOnDraw(chartIndex, indicatorId, metadata, outputRows) {
2229
+ const key = wrunNothingDrawnKey(chartIndex, indicatorId);
2230
+ if (!wrunNothingDrawnRaised.has(key) && !wrunNothingDrawnDecisions.has(key))
2231
+ return;
2232
+ if (!wrunRunDrewSomething(metadata, outputRows, wrunHandlesOf(outputRows)?.length))
2233
+ return;
2234
+ wrunNothingDrawnDecisions.delete(key);
2235
+ if (!wrunNothingDrawnRaised.delete(key))
2236
+ return;
2237
+ void publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_NOTHING_DRAWN_ROW_CODES, []);
2238
+ }
2068
2239
  /** The unserved-leg rows of a run (the venue soft refusals, `WRUN_LEG_UNSERVED`): their own
2069
2240
  * owned set beside the health rows, replaced by every full run, cleared by a run that served
2070
2241
  * every leg. Advisory like the health rows. */
@@ -2076,9 +2247,9 @@ export async function publishWrunUnservedLegDiagnostics(chartIndex, indicatorId,
2076
2247
  * refine, a reseed and a live tick alike, the last two through
2077
2248
  * publishWrunSessionCanvasNotices), a set with none clears a stale one, and a set equal to the
2078
2249
  * published one writes nothing; drafts and registry Indicators alike. */
2079
- async function publishWrunCanvasNotices(chartIndex, indicatorId, runResult) {
2250
+ async function publishWrunCanvasNotices(chartIndex, indicatorId, runResult, isCurrent) {
2080
2251
  try {
2081
- await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_CANVAS_NOTICE_ROW_CODES, wrunCanvasNoticeDiagnostics(wrunRunNoticesOf(runResult)), { unlessSame: sameWrunCanvasNotices });
2252
+ await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_CANVAS_NOTICE_ROW_CODES, wrunCanvasNoticeDiagnostics(wrunRunNoticesOf(runResult)), { unlessSame: sameWrunCanvasNotices, ...(isCurrent !== undefined ? { isCurrent } : {}) });
2082
2253
  }
2083
2254
  catch {
2084
2255
  /* advisory rows (a spec's partial mock of the canvas seams too): never a second failure on the run path */
@@ -2121,17 +2292,22 @@ export async function publishWrunSessionCanvasNotices(session, runResult, option
2121
2292
  if (options.tick && last.length === lines.length && last.every((line, at) => line === lines[at]))
2122
2293
  return;
2123
2294
  wrunSessionCanvasNoticeLines.set(session, lines);
2124
- await publishWrunCanvasNotices(session.chartIndex, session.indicatorId, runResult);
2295
+ await publishWrunCanvasNotices(session.chartIndex, session.indicatorId, runResult, options.isCurrent);
2125
2296
  }
2126
2297
  /** Replace the rows of one owned code set on the overlay's diagnostics (every other row is
2127
2298
  * kept), the shared body of the publishers above and of the canvas cost rows
2128
2299
  * (wrun-canvas-cost-notice.util). */
2129
2300
  export async function publishWrunOwnedDiagnostics(chartIndex, indicatorId, ownedCodes, diagnostics, options = {}) {
2130
2301
  try {
2131
- const mounted = wrunChartHostEnv().chart.instance(chartIndex)?.metadata?.some((candidate) => candidate.id === indicatorId);
2132
- if (!mounted)
2302
+ const tc = wrunChartHostEnv().chart.instance(chartIndex);
2303
+ const meta = tc?.metadata?.find((candidate) => candidate.id === indicatorId);
2304
+ if (!meta)
2133
2305
  return false;
2134
2306
  const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
2307
+ // Judged again after the wait, right before the write: the rows are the mount's they were asked for, never a
2308
+ // same-id remount's (a teardown and a remount meanwhile is another mount, whose own run publishes its rows).
2309
+ if (!isWrunRunMountOnChart(chartIndex, { tc, meta }) || options.isCurrent?.() === false)
2310
+ return false;
2135
2311
  const store = useChartStore();
2136
2312
  const current = store.getIndicatorDiagnostics(indicatorId, chartIndex);
2137
2313
  const published = current.filter((row) => ownedCodes.has(row.code));
@@ -2154,9 +2330,12 @@ export async function publishWrunOwnedDiagnostics(chartIndex, indicatorId, owned
2154
2330
  }
2155
2331
  /** Drop the run-failure rows this seam owns (only those: a trap, the output contract, the
2156
2332
  * no-growth rule, an unlinkable import) once a run of the same overlay succeeds. */
2157
- export async function clearWrunRuntimeTrapDiagnostic(chartIndex, indicatorId) {
2333
+ export async function clearWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, isCurrent) {
2158
2334
  try {
2159
2335
  const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
2336
+ // The caller's ownership, read after the wait: a successor's trap row is its own run's to clear.
2337
+ if (isCurrent?.() === false)
2338
+ return;
2160
2339
  const store = useChartStore();
2161
2340
  const current = store.getIndicatorDiagnostics(indicatorId, chartIndex);
2162
2341
  if (!current.some((row) => WRUN_RUN_FAILURE_ROW_CODES.has(row.code)))
@@ -2264,25 +2443,58 @@ export function wrunSessionRespelledSheet(context, sheet, settings) {
2264
2443
  const pins = wrunSessionRespelledPins.get(context);
2265
2444
  return pins === undefined ? undefined : wrunSheetWithRespelledPins(wrunSheetWithSettings(sheet, settings), pins);
2266
2445
  }
2446
+ /** The pauses before the run head asks a failed dollar read again: a passing failure clears before anyone sees it. */
2447
+ const WRUN_DOLLAR_READ_REASK_PAUSES_MS = [1_000, 2_000];
2448
+ /** The run head's dollar unit, settled once per run: only a read that failed in this run (after `since`) is asked
2449
+ * again, never a rest an earlier run left (the chart's own reruns keep it) nor a lead contract not known yet. */
2450
+ async function settleWrunRunDollarUnit(market, since, isCurrent) {
2451
+ await warmWrunMarketDollarFacts(market);
2452
+ let unit = wrunMarketDollarUnit(market);
2453
+ for (const pause of WRUN_DOLLAR_READ_REASK_PAUSES_MS) {
2454
+ if (unit.kind === 'dollars' || !unit.transient)
2455
+ break;
2456
+ if (wrunMarketDollarReadFailure(market, since) !== 'read-failed')
2457
+ break;
2458
+ await new Promise((resolve) => setTimeout(resolve, pause));
2459
+ if (!isCurrent())
2460
+ break;
2461
+ forgetWrunMarketReadFailures(market);
2462
+ await warmWrunMarketDollarFacts(market);
2463
+ unit = wrunMarketDollarUnit(market);
2464
+ }
2465
+ return unit;
2466
+ }
2467
+ /** The refusal words must tell a read that failed (the person's Retry reads it again) from a lead contract not known
2468
+ * yet and from a fact no read can prove. */
2469
+ function wrunDollarUnitWhy(unit, chartMetadata) {
2470
+ if (!unit.transient) {
2471
+ return unit.reason === 'point-value'
2472
+ ? 'no point value is known for its contracts'
2473
+ : 'it is not quoted in US dollars or a dollar stablecoin';
2474
+ }
2475
+ const failure = wrunMarketDollarReadFailure(chartMetadata);
2476
+ if (failure === 'contract-unknown')
2477
+ return 'its lead contract is not known yet';
2478
+ if (unit.reason === 'point-value') {
2479
+ return failure === 'read-failed'
2480
+ ? "the instrument registry's read of its point value failed"
2481
+ : "the instrument registry's point value for it has not been read yet";
2482
+ }
2483
+ return failure === 'read-failed' ? 'the read of its quote failed' : 'its quote has not been read yet';
2484
+ }
2267
2485
  /**
2268
2486
  * 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
2487
  * unit is not proven (wrunMarketDollarUnit), by name and before any fetch: a unit no read can ever prove (no point
2270
2488
  * value for its contracts, a quote that is no dollar) reads as the dollar tape's own refusal does (`feed-missing`,
2271
2489
  * 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.
2490
+ * (`service-no-answer`, Retry: a person's rerun reads the failed reads again at once), so the module never runs over
2491
+ * a 0 it would keep for the session.
2274
2492
  */
2275
2493
  function wrunDollarMultiplierRefusal(metadata, chartMetadata, unit, tape) {
2276
2494
  const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
2277
2495
  const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
2278
2496
  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';
2497
+ const why = wrunDollarUnitWhy(unit, chartMetadata);
2286
2498
  // The tape's own feed where the run asks one (Big Trades), else the trades the fact values.
2287
2499
  const params = { feed: tape !== undefined ? 'tape' : 'trades' };
2288
2500
  return attachWrunRefusal(new Error(`WRUN ${metadata.id}: ${WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE}: param '${param ?? 'market_dollar_multiplier'}' ` +
@@ -2381,11 +2593,19 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2381
2593
  // The open-interest lane's units (`currency` on the `oi` inputs, wrun-oi-lane.util): "Coin" asks the lane in the
2382
2594
  // market's native units, USD asks it exactly as before (no extras); two units refuse by name here.
2383
2595
  const oiLane = wrunOiLaneExtras(target.metadata);
2596
+ // Each pinned oi lane's units the same way, one lane per market (U9e): two units on one market refuse here.
2597
+ const pinnedOiLanes = new Map();
2598
+ for (const input of target.metadata.inputs) {
2599
+ const lane = wrunPinnedLaneOfSource(target.metadata.inputSources[input.name]);
2600
+ if (lane !== undefined && wrunPinnedLaneOf(lane)?.cls === 'oi' && !pinnedOiLanes.has(lane)) {
2601
+ pinnedOiLanes.set(lane, wrunOiLaneExtras(target.metadata, lane));
2602
+ }
2603
+ }
2384
2604
  // Asked again before the rows leave: a flip onto a tape since the head must not hand that tape's bars over.
2385
2605
  const candleSource = wrunMainCandleSourceOf(head.chartMetadata);
2386
2606
  const provenance = view.settings;
2387
2607
  if (candleSource && isKScriptDisplayBlockedOnExchange(candleSource.exchange, provenance)) {
2388
- throw new WrunVenueBlockedError(createKScriptVenueBlockedError(candleSource.exchange).message);
2608
+ throw new WrunVenueBlockedError(createKScriptVenueBlockedError(candleSource.exchange).message, candleSource.exchange);
2389
2609
  }
2390
2610
  const loadedRows = wrunChartCandleRows(tc);
2391
2611
  if (loadedRows.length === 0)
@@ -2422,6 +2642,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2422
2642
  // The chart's data generation the run's window was read under: the warm-up ask after the
2423
2643
  // integrate stands down when a switch or a refetch cancelled the chart's fetches meanwhile.
2424
2644
  const planGeneration = getChartDataFetchGeneration(target.chartIndex);
2645
+ // The run's own-fetch signal, taken before the plan's awaits (a lane identity waits for the flag and a tape lookup): a
2646
+ // teardown or the dataset's end meanwhile aborts what this run holds instead of a fresh one minted at the fetch.
2647
+ const laneSignal = wrunLaneFetchSignal(target.indicatorId, {
2648
+ chartIndex: target.chartIndex,
2649
+ generation: planGeneration,
2650
+ isCurrent: head.isCurrent,
2651
+ });
2425
2652
  // Every declared pin is classified against the chart BEFORE any fetch
2426
2653
  // (`planWrunPinnedWires`): an ohlcv pin coarser than the chart, on the
2427
2654
  // chart's own market or on a pinned one, becomes a PERIOD leg fetched at
@@ -2448,26 +2675,33 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2448
2675
  : Promise.resolve(null);
2449
2676
  // A dollar tape (C-DOLLAR) prices its live prints in its history's unit: the dollar unit of the market's own facts
2450
2677
  // (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
2678
+ // Its reads are the directory row's quote and the instrument registry's units, settled once (a read that failed in
2679
+ // this run asked again twice, settleWrunRunDollarUnit never rejects). A unit no read can ever prove (a quote that
2680
+ // is no dollar, a venue or a contract with no point value) refuses the tape by name before any fetch, the daemon's
2681
+ // `wrun_tape_value_unproven`: none of its live prints could fold, so it never draws silently stopped. A unit a
2682
+ // later read can still prove is
2455
2683
  // 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`).
2684
+ // its prints (wrun-live-intake.util `wrunTapeLiveFloorOf`). A coins tape (C-COINS item 2) asks the same dollar table,
2685
+ // its floor priced in the same unit (wrun-tape-coins.util), so it cannot wait: a unit a later read can still prove
2686
+ // refuses it as a source that did not answer (`service-no-answer`, Retry), never a floor priced on a guess.
2687
+ // Settled once for the tape floor and the dollar multiplier alike, or their re-asks would double.
2688
+ let dollarUnit;
2689
+ const settleDollarUnit = async () => (dollarUnit ??= await settleWrunRunDollarUnit(chartMetadata, head.marketReadsSince, head.isCurrent));
2457
2690
  let tapeValuePerUnit;
2458
- if (tape?.minValue !== undefined) {
2459
- await warmWrunMarketDollarFacts(chartMetadata);
2460
- const unit = wrunMarketDollarUnit(chartMetadata);
2691
+ if (tape?.minValue !== undefined || tape?.minCoins !== undefined) {
2692
+ const unit = await settleDollarUnit();
2461
2693
  tapeValuePerUnit = unit.kind === 'dollars' ? unit.unit : undefined;
2462
- if (unit.kind === 'unproven' && !unit.transient) {
2694
+ const coins = tape.minCoins !== undefined;
2695
+ if (unit.kind === 'unproven' && (!unit.transient || coins)) {
2463
2696
  const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
2464
2697
  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';
2698
+ const why = wrunDollarUnitWhy(unit, chartMetadata);
2468
2699
  // The host's words lead with the code (`<code>: <sentence>`), as every host refusal reads.
2469
2700
  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' });
2701
+ `${exchange}:${symbol} by ${coins ? 'coins over dollar values (min_coins)' : 'dollar value (min_value)'}, ` +
2702
+ `and ${why}, so no print can be valued`), unit.transient
2703
+ ? { cls: 'service-no-answer', variant: 'lane', params: { feed: 'tape' }, severity: 'paused' }
2704
+ : { cls: 'feed-missing', variant: 'market-paused', params: { feed: 'tape' }, severity: 'paused' });
2471
2705
  }
2472
2706
  }
2473
2707
  // A package that reads the market's dollar multiplier (kit 0.95.0, `market.dollar_multiplier()`: Big Trades 0.8.0
@@ -2476,10 +2710,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2476
2710
  // and the hover. The module takes it once, at init(), so the run never computes over a unit it could not prove (0
2477
2711
  // values no trade): its reads are waited on here, a unit no read can ever prove refuses by name before any fetch,
2478
2712
  // 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.
2713
+ // a source that did not answer (`service-no-answer`: its Retry reads again), never frozen into the session.
2480
2714
  if (wrunReadsDollarMultiplier(target.metadata)) {
2481
- await warmWrunMarketDollarFacts(chartMetadata);
2482
- const unit = wrunMarketDollarUnit(chartMetadata);
2715
+ const unit = await settleDollarUnit();
2483
2716
  if (unit.kind === 'unproven')
2484
2717
  throw wrunDollarMultiplierRefusal(target.metadata, chartMetadata, unit, tape);
2485
2718
  }
@@ -2578,9 +2811,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2578
2811
  // An exact warm-up session (round A of the warm-up program), judged from the module and the sheet before any
2579
2812
  // context exists (D4): the run starts with a hidden head of W candles before its first landed row (a clamped
2580
2813
  // 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).
2814
+ // key reaches the verdict (a torn stamp answers `warmup-invalid` there, never reads as no stamp; a converging one
2815
+ // reads as no stamp there before anything else while `wrun-converging-prefix` is off, so no head is planned), and W
2816
+ // reads the settings the package computes with (`wrunWarmupSettings`: a run at another interval, and a twin whose
2817
+ // Timeframe is at or below the chart's, take their chart arm, as the init args below send them).
2584
2818
  const warmupVerdict = target.metadata.history_warmup === undefined
2585
2819
  ? null
2586
2820
  : wrunWarmupVerdictOf({
@@ -2648,8 +2882,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2648
2882
  // Not this interval's candles yet: a switch's cached paint and its commit replace the main series
2649
2883
  // in steps, and a run planned between them would ask its warm-up on the new clock over the
2650
2884
  // 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);
2885
+ // chart trigger instead, as for no rows at all (wrunChartRowsOffIntervalGrid). Judged on the chart's own bar grid: a
2886
+ // stock's 3d groups sit at no fixed phase of the interval, and its 8h bars one a session, a day apart.
2887
+ const offGrid = wrunChartRowsOffIntervalGrid(chartRows, chartIntervalMs, liveBucketVenueOf(chartMetadata));
2653
2888
  if (wrunChartHostEnv().diagnostics.debugEnabled()) {
2654
2889
  wrunChartHostEnv().diagnostics.debug('wrun-run-planned', {
2655
2890
  chartIndex: target.chartIndex,
@@ -2671,11 +2906,52 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2671
2906
  // plan, the poll plans and the push eligibility read it), else the chart's. A replay run's
2672
2907
  // `now` is the end its lanes are fetched through: every row's as-of read stays at its own close.
2673
2908
  // The now is the server's: the lanes plan their windows over the gateway's bars.
2909
+ const clockIntervalMs = run ? run.intervalMs : chartIntervalMs;
2910
+ const clockNowMs = replay
2911
+ ? Math.min(serverNowMs(), Math.max(replay.toMs, chartLastTs + chartIntervalMs))
2912
+ : serverNowMs();
2913
+ const { legs: plannedLegs, wires: plannedWires } = planWrunPinnedWires(target.metadata, clockIntervalMs);
2914
+ // The instant a replay run's declared histories count back from: the replay's present, the close of the newest
2915
+ // completed bar the replay shows (the open of the bar its playhead is in). Its lanes still run on to the window's end
2916
+ // (the forward runway, a thousand steps past the playhead), but a history counted back from there, or from today,
2917
+ // left the bars before the playhead with none (a Big Trades tape's seven days in a replay older than a week). Every
2918
+ // lane's ask names it (SOURCE_HISTORY_AS_OF_FIELD, `fetchLane`).
2919
+ const replayPresentMs = replay ? Math.min(clockNowMs, chartLastTs + chartIntervalMs) : undefined;
2920
+ // A live run's declared histories count back from the session's pins (wrun-history-as-of.util): each lane's, set by
2921
+ // the session's first run that asked it, so a later run of the session (a history page, a settings save, a retry)
2922
+ // never asks a lane from a later start; its window still ends at the server's now. The session is the overlay on
2923
+ // this chart, market, chart interval and run interval.
2924
+ const tapeAsOfKey = tape !== undefined ? wrunTapeHistoryAsOfLaneKey(tape) : undefined;
2925
+ const lanePins = replay === undefined
2926
+ ? pinWrunLaneHistoryAsOf(target.indicatorId, wrunHistoryAsOfIdentity({
2927
+ chartIndex: target.chartIndex,
2928
+ marketIdentity,
2929
+ chartIntervalMs,
2930
+ runInterval: run?.interval,
2931
+ }), [...plannedLegs.map((leg) => leg.fetchKey), ...(tapeAsOfKey !== undefined ? [tapeAsOfKey] : [])], clockNowMs)
2932
+ : undefined;
2933
+ // The clock's as-of: a replay's present, or the earliest pin among the legs (the instant the row builder counts each
2934
+ // backlog back from; each leg's fetch reads its own pin, `legClockOf`). The session installs it.
2674
2935
  const clock = {
2675
- intervalMs: run ? run.intervalMs : chartIntervalMs,
2676
- nowMs: replay ? Math.min(serverNowMs(), Math.max(replay.toMs, chartLastTs + chartIntervalMs)) : serverNowMs(),
2936
+ intervalMs: clockIntervalMs,
2937
+ nowMs: clockNowMs,
2938
+ historyAsOfMs: replayPresentMs ??
2939
+ wrunEarliestHistoryAsOf(plannedLegs.map((leg) => lanePins?.get(leg.fetchKey) ?? clockNowMs)) ??
2940
+ clockNowMs,
2941
+ };
2942
+ // A leg's clock for its fetch plan: the run's, its declared depth counted back from the leg's own pin.
2943
+ const legClockOf = (leg) => {
2944
+ const pin = lanePins?.get(leg.fetchKey);
2945
+ return pin === undefined ? clock : { ...clock, historyAsOfMs: pin };
2677
2946
  };
2678
- const { legs: plannedLegs, wires: plannedWires } = planWrunPinnedWires(target.metadata, clock.intervalMs);
2947
+ // The ask's as-of where a declared history is counted back by the lane's control (the tape's K_TRADES seed): a
2948
+ // 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
2949
+ // the run's now (a first run names none, so its ask is the payload it always was and joins another overlay's).
2950
+ const historyAsOfAsk = replayPresentMs === undefined ? {} : { [SOURCE_HISTORY_AS_OF_FIELD]: replayPresentMs };
2951
+ const tapePinMs = tapeAsOfKey !== undefined ? lanePins?.get(tapeAsOfKey) : undefined;
2952
+ const tapeAsOfAsk = tapePinMs !== undefined && tapePinMs < clockNowMs ? { [SOURCE_HISTORY_AS_OF_FIELD]: tapePinMs } : {};
2953
+ // The instant the tape's declared history counts back from (its budget below): the replay's present, else its pin.
2954
+ const tapeHistoryAsOfMs = replayPresentMs ?? tapePinMs;
2679
2955
  // The chart's head store for this run's first bar (wrun-warmup-head-store.util): one per chart, so every overlay
2680
2956
  // over the same first bar reads the candles one run fetched. A clamped window takes none (its head lies inside the
2681
2957
  // loaded rows).
@@ -2797,11 +3073,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2797
3073
  // Each group dispatches the moment its own plan resolves (`scheduleWrunLaneGroups` below); a plan's refusal still
2798
3074
  // fails the run by name, judged in the order the plans were read (the local plans, then the chain-reading poll
2799
3075
  // 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>).
3076
+ // The run's plane facts reach every lane's plan (`ctx.official`, `ctx.opraUserScripts`, `ctx.cmeStudyChain`): an OPRA
3077
+ // lane is refused by name before its plan for a run that may not read the plane (`mayReadOpra`,
3078
+ // opra-official-only:<class>), a CME chain instance after it (`mayReadCmeChain`).
2802
3079
  // The OPRA-plane predicate an OPRA lane is admitted by (loaded only when the sheet reads one).
2803
3080
  const opraPlaneFacts = wrunOpraPlaneFacts(target.metadata, head.options);
2804
- const opraFacts = { official: head.official, opraUserScripts: head.opraUserScripts };
3081
+ const planeFacts = planeReadFactsOf(head);
2805
3082
  // Every chain lane plans under the head's one decision: its plane, and a stock twin's lane market (`head.options`).
2806
3083
  const runOptions = head.options;
2807
3084
  // The overlay's current setting values, read once for both planners: an option knob naming a setting
@@ -2820,7 +3097,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2820
3097
  category: chartMetadata?.category,
2821
3098
  intervalMs: clock.intervalMs,
2822
3099
  }, checkIsIndexMode, isWrunCryptoVenueExchange, {
2823
- ...opraFacts,
3100
+ ...planeFacts,
2824
3101
  ...(opraPlane !== undefined ? opraPlane : {}),
2825
3102
  paramValues: laneParamValues,
2826
3103
  ...(runOptions !== undefined ? { options: runOptions } : {}),
@@ -2849,8 +3126,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2849
3126
  isCryptoVenueExchange: isWrunCryptoVenueExchange,
2850
3127
  isOpraPlaneExchange: opraPlane?.isOpraPlaneExchange,
2851
3128
  opraPlaneStop: opraPlane?.opraPlaneStop,
3129
+ // The chart whole: a `stocks` lane's identity asks the chart port for its tape market and feed.
3130
+ ...(chartMetadata !== undefined ? { chartMetadata: chartMetadata } : {}),
2852
3131
  }, {
2853
- ...opraFacts,
3132
+ ...planeFacts,
2854
3133
  paramValues: laneParamValues,
2855
3134
  ...(runOptions !== undefined ? { options: runOptions } : {}),
2856
3135
  }));
@@ -2866,7 +3145,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2866
3145
  // The options_chain lane's identity (wrunOptionsChainLaneExtrasFor), decided before its own fetch like every plan:
2867
3146
  // a refusal by name fails the run, never reads as a degraded lane.
2868
3147
  const optionsChainPlanned = declaredClasses.has('options_chain')
2869
- ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts, laneParamValues, head.options, head.cmeUserStudy === true)
3148
+ ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, planeFacts, laneParamValues, head.options)
2870
3149
  : Promise.resolve(undefined);
2871
3150
  // The OPRA provenance the native options overlays carry (`settings.metaExchange`, the field the chart read
2872
3151
  // withholds an overlay by and the tier moves refetch it by, options-overlay-provenance.util): every OPRA lane
@@ -2901,10 +3180,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2901
3180
  // Every source-lane instance a degrade names (a poll lane's or a row lane's): the chips, the holds, the records.
2902
3181
  // Filled as the plans resolve, in the plans' order once both did.
2903
3182
  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,
3183
+ // The pinned legs by venue (wrun-pin-venues.util), before any fetch, under
3184
+ // the run's CME pin facts (`pinFacts` below): a pin on a CME Group venue is
3185
+ // served on any chart to a run the data wall lets read CME and refuses by
3186
+ // name with the sheet contract's own words for any other (the chart's own
3187
+ // market is the display wall's above), and so does a venue word the
3188
+ // chart's lanes cannot ask (AMEX, SP,
2908
3189
  // a stock listing: wrun_pin_venue_unknown, a failed run, whether the sheet,
2909
3190
  // a default or a saved pick names it); a pin on an index venue the
2910
3191
  // gateway serves no series for to
@@ -2925,25 +3206,51 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2925
3206
  // A leg a symbol setting pins (`symbol_param`) offers the settings as the way out of a venue
2926
3207
  // the chart's lanes cannot ask.
2927
3208
  const settingBoundAt = (index) => typeof target.metadata.inputSources[inputNameAt(index)]?.symbol_param === 'string';
2928
- assertWrunPinnedLegVenues(plannedLegs, inputNameAt, chartExchange, settingBoundAt);
3209
+ // 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
3210
+ // since the head serves the pin): open where the data wall lets the run read CME (`isCmeReadableKScriptRun`, which
3211
+ // reads `mayReadCmePin`, on any chart), else the words the closed gate's refusal takes (`cmePinRefusalVariant`).
3212
+ const cmeUserScriptsAtJudge = isCmeUserScriptRun(provenance);
3213
+ const pinFacts = {
3214
+ cmeOpen: isCmeReadableKScriptRun(provenance),
3215
+ cmeClosed: cmePinRefusalVariant(provenance),
3216
+ };
3217
+ // A pin the closed gate refused: a study the lifecycle stopped reads its stop's words (a plain Error, never the
3218
+ // wall's: no painter swallows it off a CME chart), and a browser run arms the late re-judgment, so access that
3219
+ // returns runs it again (the run head's flag-wait shape, through the market port).
3220
+ const refusePinnedLeg = async (error) => {
3221
+ if (pinFacts.cmeOpen || wrunRefusalSeedOf(error)?.cls !== 'pin-refused')
3222
+ return error;
3223
+ if (isCmeUserScriptCandidate(provenance)) {
3224
+ const gate = await wrunChartHostEnv()
3225
+ .market.loadOptionsGate()
3226
+ .catch(() => undefined);
3227
+ gate?.armCmeUserScriptsRejudge?.();
3228
+ }
3229
+ const stop = cmeStudyStopReason(target.chartIndex, target.indicatorId);
3230
+ return stop === undefined
3231
+ ? error
3232
+ : attachWrunRefusal(new Error(error.message), { cls: 'cme-wall', variant: WRUN_CME_STOP_VARIANT[stop] });
3233
+ };
3234
+ try {
3235
+ assertWrunPinnedLegVenues(plannedLegs, inputNameAt, chartExchange, settingBoundAt, pinFacts);
3236
+ }
3237
+ catch (error) {
3238
+ throw error instanceof Error ? await refusePinnedLeg(error) : error;
3239
+ }
2929
3240
  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
3241
+ // A leg whose rows straddle the chart's bars (wrun-trades-lane.util `wrunLegStraddlesChartBars`: a 24/7 market's :00
3242
+ // hours under a stock's 09:30-anchored bars, a crypto market's 4h bars on a CME chart's session lattice, or the
3243
+ // reverse) is placed on the chart's bars by the row builder alone (`wrunLegRowsOnHostBars`). So its asks ride
3244
+ // dataFetch's native-rows path: the fetch never places its rows first (its straddle path does for a plain ask, on a
2934
3245
  // timestamp-mode chart too), and its history, its reconciles and its live folds all carry the leg's own stamps,
2935
3246
  // 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));
3247
+ // opens that span early (`wrunLegPlacementLeadMs`). A leg on the chart's own grid, or on a finer one dividing it,
3248
+ // 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
3249
+ // never placed. The rules are shared with the trades legs' planner (`planWrunTradeLegAsk`, which a pan-back page
3250
+ // asks its legs through too), all planned against the run clock and the chart (`legAskChart`).
3251
+ const legAskChart = { intervalMs: clock.intervalMs, venue: chartMetadata };
3252
+ const legVenueOf = (market) => wrunLegVenueOf(legAskChart, market);
3253
+ const legStraddlesChartBars = (legMs, market) => wrunLegStraddlesChartBars(legAskChart, legMs, market);
2947
3254
  // 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
3255
  // both grids (`indexHostFetchTierMs`, the comparison overlays' rule on an index-mode chart: 30m under a stock's
2949
3256
  // 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 +3264,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2957
3264
  const tierMs = indexHostFetchTierMs(clock.intervalMs, liveBucketVenueOf(chartMetadata), [legVenueOf(leg.market)]);
2958
3265
  return tierMs > 0 && tierMs < leg.legMs ? tierMs : undefined;
2959
3266
  };
2960
- const legPlacementLeadMs = (legMs, market) => legStraddlesChartBars(legMs, market) ? legMs : 0;
3267
+ const legPlacementLeadMs = (legMs, market) => wrunLegPlacementLeadMs(legAskChart, legMs, market);
2961
3268
  // Each leg records how its ask rides (`WrunPinnedLeg.nativeRows`: an index-mode market or chart, a straddling
2962
3269
  // grid): the full run asks it so, and the live session's reconcile reads the installed record.
2963
3270
  const legs = servedLegs.map((leg) => {
@@ -2971,10 +3278,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2971
3278
  });
2972
3279
  // The trades leg lanes (kit 0.77.0, wrun-trades-lane.util): one per (quote, market) a trades
2973
3280
  // 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).
3281
+ // Each leg's market is judged like any pin's, before any fetch and under the same `pinFacts`: a
3282
+ // CME Group venue the run may not read, a pin that is no literal market or a venue word the lanes
3283
+ // cannot ask refuses by name; a venue the gateway serves no series for to scripts yet is never
3284
+ // asked (its inputs read their fill, the unserved-leg note names them).
2978
3285
  const tradeLegLanes = [...wrunDeclaredSourceLanes(target.metadata)].filter(isWrunTradesLegLane);
2979
3286
  const softRefusedTradeLegs = new Set();
2980
3287
  for (const lane of tradeLegLanes) {
@@ -2984,9 +3291,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2984
3291
  const readers = target.metadata.inputs
2985
3292
  .filter((input) => wrunSourceLane(target.metadata.inputSources[input.name]) === lane)
2986
3293
  .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)));
3294
+ 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
3295
  if (refusal !== null)
2989
- throw attachWrunRefusal(new Error(refusal.message), refusal.seed);
3296
+ throw await refusePinnedLeg(attachWrunRefusal(new Error(refusal.message), refusal.seed));
2990
3297
  if (wrunPinVenueVerdict(leg.exchange) !== 'unserved')
2991
3298
  continue;
2992
3299
  softRefusedTradeLegs.add(lane);
@@ -2999,6 +3306,35 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2999
3306
  reason: 'venue-unserved',
3000
3307
  });
3001
3308
  }
3309
+ // The pinned lanes (U9e, wrun-pinned-lanes.util): one per (class, market) a book, oi, funding or liquidations input
3310
+ // pinned to another market reads. Each lane's market is judged like a trades leg's above, before any fetch: a CME
3311
+ // Group venue, a pin that is no literal market or a venue word the lanes cannot ask refuses by name; a venue the
3312
+ // gateway serves no series for to scripts yet is never asked (its inputs read their fill, the unserved-leg note names
3313
+ // them). A CME Group market pinned by a typed lane keeps the venue-name refusal (this judge call carries no plane
3314
+ // facts on purpose, named in tests/hygiene/wrun-pin-judge-facts.spec.ts): the typed-lane fetch path is proven for
3315
+ // ohlcv and trades legs only.
3316
+ const pinnedLaneIds = [...wrunDeclaredSourceLanes(target.metadata)].filter(isWrunPinnedLaneId);
3317
+ const softRefusedPinnedLanes = new Set();
3318
+ for (const lane of pinnedLaneIds) {
3319
+ const pinned = wrunPinnedLaneOf(lane);
3320
+ const readers = target.metadata.inputs
3321
+ .filter((input) => wrunSourceLane(target.metadata.inputSources[input.name]) === lane)
3322
+ .sort((a, b) => a.index - b.index);
3323
+ const refusal = wrunPinnedLegRefusalOf({ market: { exchange: pinned.exchange, symbol: pinned.symbol }, intervalKey: '', legMs: 0 }, readers[0]?.name ?? lane, chartExchange, readers.some((input) => settingBoundAt(input.index)));
3324
+ if (refusal !== null)
3325
+ throw attachWrunRefusal(new Error(refusal.message), refusal.seed);
3326
+ if (wrunPinVenueVerdict(pinned.exchange) !== 'unserved')
3327
+ continue;
3328
+ softRefusedPinnedLanes.add(lane);
3329
+ unservedLegs.push({
3330
+ inputNames: readers.map((input) => input.name),
3331
+ intervalKey: chartInterval || wrunChartIntervalKeyOf(clock.intervalMs),
3332
+ exchange: pinned.exchange,
3333
+ symbol: pinned.symbol,
3334
+ market: `${pinned.exchange}/${pinned.symbol}`,
3335
+ reason: 'venue-unserved',
3336
+ });
3337
+ }
3002
3338
  // The chart's forming bar on the server clock (`wrunFormingBarTsOf`), read when the run lands a leg on the chart's
3003
3339
  // 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
3340
  // 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 +3343,26 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3007
3343
  // pin one, and the dataFetch door admits it) reads OPRA data like the chart's own market would: the run's console
3008
3344
  // provenance from here (`computed.opra`), before anything computes. A soft-refused trades leg is never asked.
3009
3345
  if (legs.some((leg) => wrunPinReadsOpra(leg.market)) ||
3010
- tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsOpra(wrunTradesLegOf(lane)))) {
3346
+ tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsOpra(wrunTradesLegOf(lane))) ||
3347
+ pinnedLaneIds.some((lane) => !softRefusedPinnedLanes.has(lane) && wrunPinReadsOpra(wrunPinnedLaneOf(lane)))) {
3011
3348
  computed.opra = true;
3012
3349
  }
3013
- // The same for a leg on the CME plane (`computed.cme`): a leg the run admitted reads CME data.
3350
+ // The same for a leg on the CME plane (`computed.cme`): a leg the run admitted reads CME data, on any chart.
3014
3351
  if (legs.some((leg) => wrunPinReadsCme(leg.market)) ||
3015
- tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsCme(wrunTradesLegOf(lane)))) {
3352
+ tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsCme(wrunTradesLegOf(lane))) ||
3353
+ pinnedLaneIds.some((lane) => !softRefusedPinnedLanes.has(lane) && wrunPinReadsCme(wrunPinnedLaneOf(lane)))) {
3016
3354
  computed.cme = true;
3355
+ // A browser run the gate opened the plane to computes its admitted CME legs under the authorisation the judge read,
3356
+ // in the same task: the resolved legs are the one sure reading (a pin the step respelled onto CME included).
3357
+ if (cmeUserScriptsAtJudge && computed.cmeAuth === undefined)
3358
+ computed.cmeAuth = captureCmeStudyAuth();
3359
+ // The delayed ones off the chart's own exchange (its badge names none of them): the legend's delay note.
3360
+ const delayed = wrunCmeDelayedMarkets([
3361
+ ...legs.map((leg) => leg.market),
3362
+ ...tradeLegLanes.filter((lane) => !softRefusedTradeLegs.has(lane)).map(wrunTradesLegOf),
3363
+ ], chartExchange);
3364
+ if (delayed !== undefined)
3365
+ computed.cmeDelayed = delayed;
3017
3366
  }
3018
3367
  const formingBarTs = live && replay === undefined && wrunLandsLegsOnBars(legs, tradeLegLanes)
3019
3368
  ? await wrunFormingBarTsOf(target.chartIndex, clock.intervalMs, chartMetadata)
@@ -3060,7 +3409,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3060
3409
  indexMode: checkIsIndexMode(chartExchange ?? ''),
3061
3410
  },
3062
3411
  paramValues: laneParamValues,
3063
- facts: { official: head.official, opraUserScripts: head.opraUserScripts },
3412
+ facts: planeReadFactsOf(head),
3064
3413
  ...(head.options !== undefined ? { options: head.options } : {}),
3065
3414
  });
3066
3415
  })().then((plan) => {
@@ -3152,8 +3501,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3152
3501
  severity: 'paused',
3153
3502
  });
3154
3503
  }
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).
3504
+ // Every lane the rule judges is one of the row builder's own, or a trades leg lane or a pinned
3505
+ // lane on the market it judged (its readers' own lanes).
3157
3506
  if (market === undefined)
3158
3507
  unservedLanes.push(lane);
3159
3508
  else {
@@ -3236,11 +3585,26 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3236
3585
  if (source === null)
3237
3586
  return {};
3238
3587
  // 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);
3588
+ if (walled) {
3589
+ throw new WrunVenueBlockedError(createKScriptVenueBlockedError(source.exchange).message, source.exchange);
3590
+ }
3241
3591
  // The series ref alone (the main stream's rule): the session, the index mode and the bar grid stay the chart's.
3242
3592
  return { candleSource: source };
3243
3593
  };
3594
+ // A lane's acquisition: the payload its ask carries, kept on the run (the legend's delay words, the reconcile, the live
3595
+ // session and the add memo's fingerprint read it). Recorded by the read, whether or not an ask leaves: a row lane the
3596
+ // add memo serves whole asks nothing (a theme's rerun of a stock chart's Dark pool prints), and its run must still name
3597
+ // the tape it read (wrun-draft-legend-note.util `wrunStocksLanesServedTierNote`).
3598
+ const recordLaneAcquisition = (type, key, payloadExtras) => {
3599
+ const askExtras = { ...askMarketOf(type, payloadExtras), ...payloadExtras };
3600
+ // Every lane's ask names the instant its declared history counts back from when the run's is not the server's now
3601
+ // (`historyAsOfAsk`: a replay's present), so no lane counts a history back from today in a replay.
3602
+ const payload = { symbol: 'currentSymbol', exchange: 'currentExchange', ...askExtras, ...historyAsOfAsk };
3603
+ const lane = wrunLiveLaneOfFetchKey(key);
3604
+ if (lane !== undefined)
3605
+ acquisitionByLane[lane] = payload;
3606
+ return { lane, payload };
3607
+ };
3244
3608
  const fetchLane = async (type, key, fetchOptions,
3245
3609
  // Lane-specific payload fields beyond the current-market placeholders
3246
3610
  // (the Deribit option-summary lanes key by coin, skew also by delta),
@@ -3257,16 +3621,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3257
3621
  const meter = fetchOptions?.meter ?? download;
3258
3622
  // The market every ask naming no pin of its own reads (its acquisition keeps it, so the reconcile and live agree).
3259
3623
  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;
3624
+ const { lane, payload } = recordLaneAcquisition(type, key, payloadExtras);
3264
3625
  const held = fromTs === from && toTs === to ? takeHeldLane(lane, payload) : undefined;
3265
3626
  if (held !== undefined)
3266
3627
  return held;
3267
3628
  // The chart's own series at the chart's interval, over bars the chart holds, answers from the chart's rows with no
3268
3629
  // ask (run-schedule/wrun-own-candles.util).
3269
- const own = fetchOptions?.ownFetch === undefined
3630
+ const own = fetchOptions?.ownFetch === undefined && fetchOptions?.marketRows !== true
3270
3631
  ? serveWrunOwnCandles({
3271
3632
  type,
3272
3633
  payloadExtras: askExtras,
@@ -3329,11 +3690,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3329
3690
  meter.charge({ key: `${target.fetchKey}-${key}`, kType: type, ...wrunDownloadAnswerSize(fetched) });
3330
3691
  }
3331
3692
  // Packed-lane SUCCESS arrives as the packed transport object (only the
3332
- // kScript engine worker consumes it un-unpacked); unpack it here, or a
3693
+ // kScript engine worker consumes it un-unpacked); read it here, or a
3333
3694
  // real success misclassifies as a decline and re-fetches on the plain
3334
- // legacy lane.
3695
+ // legacy lane. The book keeps the worker's block (its rows are views of
3696
+ // it, WRUN-PANBACK-2 S2); every other lane unpacks.
3335
3697
  if (isPackedOhlcvRows(fetched))
3336
- return unpackOhlcvRows(fetched);
3698
+ return wrunPackedLaneRows(type, fetched, target);
3337
3699
  if (Array.isArray(fetched))
3338
3700
  return fetched;
3339
3701
  // A declined packed ask (dataFetch returns null when the packed worker is
@@ -3384,6 +3746,36 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3384
3746
  acquisitionByLane.book = { ...acquisitionByLane.book, preferPackedOrderbookWorker: false };
3385
3747
  return plain;
3386
3748
  };
3749
+ // A pinned lane (U9e, wrun-pinned-lanes.util): its class's K source asked on its market under the lane id as its
3750
+ // fetch key (its own cache entry and its own live lane: fetchLane keeps the payload, the market among it, as the
3751
+ // lane's acquisition, so the reconcile and the live channel ask that market again), in the units its inputs declare
3752
+ // (an oi lane's currency, one lane per market, `pinnedOiLanes`). A book rides the packed orderbook worker first and
3753
+ // the plain lane on a decline, as the chart's own book does, its transport on its acquisition; a funding lane an
3754
+ // input reads under carry degrades on an empty answer, as the chart's own does. Never the chart's own lane's rows.
3755
+ const fetchPinnedLaneRows = async (lane) => {
3756
+ const pinned = wrunPinnedLaneOf(lane);
3757
+ const { type, label } = WRUN_PINNED_LANE_SPECS[pinned.cls];
3758
+ const market = wrunPinnedLaneExtras(lane);
3759
+ if (pinned.cls === 'book') {
3760
+ const packed = await fetchLane(type, lane, { preferPackedOrderbookWorker: true }, market);
3761
+ if (heldCoverage[lane] !== undefined)
3762
+ return packed ?? [];
3763
+ if (packed !== null) {
3764
+ acquisitionByLane[lane] = { ...acquisitionByLane[lane], preferPackedOrderbookWorker: true };
3765
+ return packed;
3766
+ }
3767
+ const plain = (await fetchLane(type, lane, undefined, market)) ?? [];
3768
+ acquisitionByLane[lane] = { ...acquisitionByLane[lane], preferPackedOrderbookWorker: false };
3769
+ return plain;
3770
+ }
3771
+ if (pinned.cls === 'oi') {
3772
+ return (await fetchLane(type, lane, undefined, { ...market, ...pinnedOiLanes.get(lane) })) ?? [];
3773
+ }
3774
+ if (pinned.cls === 'funding' && wrunFundingLaneRequired(target.metadata, lane)) {
3775
+ return fetchDegradableLane(type, lane, `${label} on ${pinned.exchange} ${pinned.symbol}`, market);
3776
+ }
3777
+ return (await fetchLane(type, lane, undefined, market)) ?? [];
3778
+ };
3387
3779
  // The volume-profile, trade-volume-by-size, liquidations, funding,
3388
3780
  // implied-volatility, and skew lanes mirror the ENGINE's acquisition for TECHNICAL_SCRIPT sources
3389
3781
  // (fetchSourceDataPayload in script-engine-worker-manager): the engine's
@@ -3680,7 +4072,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3680
4072
  : fetchQuietLeg(leg, readers, key, label, marketExtras, native, windowFrom, to);
3681
4073
  }
3682
4074
  const reads = wrunLegFetchReads(target.metadata, leg, plannedWires);
3683
- const plan = planWrunLegFetch({ leg, reads, clock, headMs: from });
4075
+ // The leg's declared depth counts back from its own pin (`legClockOf`), its window still ends at the run's now.
4076
+ const plan = planWrunLegFetch({ leg, reads, clock: legClockOf(leg), headMs: from });
3684
4077
  clampedLegs.push(...plan.clamped);
3685
4078
  const windowFrom = plan.fromTs;
3686
4079
  // A live-candle reading asks through now whatever the chart's last row: on a chart whose
@@ -3791,7 +4184,14 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3791
4184
  ? 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
4185
  : ((await fetchLane(lane.kType, instance.key, laneFetch
3793
4186
  ? {
3794
- ownFetch: (fromTs, toTs) => laneFetch({ extras: instance.extras, fromTs, toTs, intervalMs: clock.intervalMs }),
4187
+ ownFetch: (fromTs, toTs) => laneFetch({
4188
+ extras: instance.extras,
4189
+ fromTs,
4190
+ toTs,
4191
+ intervalMs: clock.intervalMs,
4192
+ nowMs: clock.nowMs,
4193
+ signal: laneSignal,
4194
+ }),
3795
4195
  }
3796
4196
  : wrunPollLaneFetchOptions(lane), extras, wrunPollLaneFetchFrom(lane, from), wrunPollLaneFetchTo(lane, to, clock.intervalMs, clock.nowMs))) ?? []);
3797
4197
  if (!wrunPollLaneRequired(target.metadata, instance))
@@ -3873,6 +4273,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3873
4273
  const extras = lane.governed === 'opra'
3874
4274
  ? { ...instance.extras, ...wrunOpraLanePayloadFields(governedMarketDataTier('OPRA')) }
3875
4275
  : wrunRowLaneChainAsk(lane, instance.extras, governedMarketDataTier);
4276
+ // The instance's acquisition stands before the read: the add memo can serve every bar whole, and then no ask leaves.
4277
+ recordLaneAcquisition(lane.kType, instance.key, extras);
3876
4278
  const laneFetch = lane.fetch;
3877
4279
  const tradeDateOf = chartTradeDateOf();
3878
4280
  // 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 +4307,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3905
4307
  fromTs: askFrom,
3906
4308
  toTs: askTo,
3907
4309
  intervalMs: clock.intervalMs,
4310
+ nowMs: clock.nowMs,
4311
+ hostBars: wrunHostBarSpansWithin(hostGridWindow(), askFrom, askTo),
4312
+ signal: laneSignal,
3908
4313
  }));
3909
4314
  own.answered = true;
3910
4315
  return answered;
@@ -4015,52 +4420,33 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4015
4420
  const { key, extras } = WRUN_TRADES_LANES[lane];
4016
4421
  return async () => (await fetchLane('buy_sell_volume', key, undefined, extras ? { ...extras } : undefined)) ?? [];
4017
4422
  };
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
- };
4423
+ // A trades leg's ask over the run's window (wrun-trades-lane.util `planWrunTradeLegAsk`, the planner a pan-back page
4424
+ // 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
4425
+ // market, and wherever its rows straddle the chart's bars, it is asked at the tier that fits every chart bar and
4426
+ // every leg bar on dataFetch's native-rows path, the chart's bars asked whole (through the last bar's close, from one
4427
+ // tier row early where the rows straddle) in pieces of wire rows (`wrunWireRowPieces`). The tier and the path ride
4428
+ // its acquisition, which the intake folds the live prints at and the reconcile asks again.
4429
+ const tradeLegAskOf = (lane) => planWrunTradeLegAsk(lane, legAskChart, { fromMs: from, toMs: to });
4047
4430
  // A trades leg asked in pieces is one family with one commit (`wrunAskWirePieces`): a piece the chart's fetch did
4048
4431
  // not answer whole (its verdict, `wrunSourceVerdictWhole`) commits nothing, and the lane degrades as declined (the
4049
4432
  // source ladder asks it again); the lane's budget running out (`abandoned`) asks no further piece.
4050
4433
  const fetchTradeLegRows = async (lane, abandoned) => {
4051
4434
  const ask = tradeLegAskOf(lane);
4052
- if (ask === undefined) {
4053
- return (await fetchLane('buy_sell_volume', lane, undefined, wrunTradesLegExtras(lane))) ?? [];
4054
- }
4435
+ // Every lane here passed `isWrunTradesLegLane`, so it names a market; one that does not fails its own lane.
4436
+ if (ask === undefined)
4437
+ throw new Error(`the trades leg lane '${lane}' names no market`);
4438
+ if (ask.tier === null)
4439
+ return (await fetchLane(ask.type, lane, undefined, ask.extras, ask.fromMs, ask.toMs)) ?? [];
4440
+ const tier = ask.tier;
4055
4441
  const held = takeHeldLane(wrunLiveLaneOfFetchKey(lane), {
4056
4442
  symbol: 'currentSymbol',
4057
4443
  exchange: 'currentExchange',
4058
- ...ask.extras,
4444
+ ...tier.extras,
4059
4445
  });
4060
4446
  if (held !== undefined)
4061
4447
  return held;
4062
4448
  try {
4063
- return await fetchTierPieces('buy_sell_volume', lane, ask.tierMs, ask.extras, ask.fromMs, ask.toMs, abandoned);
4449
+ return await fetchTierPieces(ask.type, lane, tier.tierMs, tier.extras, ask.fromMs, ask.toMs, abandoned);
4064
4450
  }
4065
4451
  catch (error) {
4066
4452
  if (error instanceof WrunWirePiecesIncomplete) {
@@ -4070,8 +4456,80 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4070
4456
  throw error;
4071
4457
  }
4072
4458
  };
4459
+ // A coins tape (C-COINS item 2) asks the dollar table at its coins x the lowest price its request's window traded at
4460
+ // x 0.9 (wrun-tape-coins.util), priced here before any lane dispatches: off the chart's own candles (with the warm-up
4461
+ // head in hand, never one still to fetch) where they are the tape market's prices and hold the window whole, else off
4462
+ // that market's day candles over it, asked through this run's one lane door (`fetchLane`) and folded with the chart's
4463
+ // own bars inside the window. No candle pricing the window refuses the run by name, never a floor on a guess.
4464
+ const priceWrunCoinTape = async (coins) => {
4465
+ const span = wrunCoinTapeWindow({
4466
+ fromMs: from,
4467
+ toMs: to,
4468
+ asOfMs: tapeHistoryAsOfMs ?? clock.nowMs,
4469
+ historySeconds: coins.historySeconds,
4470
+ barMs: clock.intervalMs,
4471
+ });
4472
+ // The tape reads the run market where the sheet reads one (a Trades chart's tape), else the chart's own market.
4473
+ const tapeMarket = runMarket ?? undefined;
4474
+ const transformations = typeof chartMetadata?.transformations === 'string' ? chartMetadata.transformations : '';
4475
+ const formula = normalizeTransformations(transformations);
4476
+ const ownCandles = (tapeMarket === undefined || (tapeMarket.exchange === chartExchange && tapeMarket.symbol === chartSymbol)) &&
4477
+ wrunMainCandleSourceOf(chartMetadata) === null &&
4478
+ (formula === '' || formula === normalizeTransformations(selfTransformationToken(chartExchange, chartSymbol)));
4479
+ // The warm-up head's candles the run holds without a fetch, before the loaded rows (the tape asks from its start).
4480
+ const headInHand = laneHeadArgs !== undefined ? peekWrunLaneWarmupHead(laneHeadArgs) : undefined;
4481
+ const headRows = (headInHand?.rows ?? []).filter((row) => row[0] < loadedRows[0][0]);
4482
+ const ownRows = headRows.length > 0 ? [...headRows, ...loadedRows] : loadedRows;
4483
+ let low = ownCandles ? wrunCandlesLowAcross(ownRows, span, chartIntervalMs, true) : undefined;
4484
+ if (low === undefined) {
4485
+ const ask = wrunCoinTapeDayAsk(span);
4486
+ let verdict;
4487
+ const days = (await fetchLane('ohlcv', 'tp-price', {
4488
+ interval: WRUN_TAPE_COINS_DAY_INTERVAL,
4489
+ // On a formula chart at 1d the chart's rows are the formula's: the floor reads the market's own days.
4490
+ marketRows: true,
4491
+ onSourceVerdict: (heard) => {
4492
+ verdict = heard;
4493
+ },
4494
+ }, tapeMarket !== undefined ? { exchange: tapeMarket.exchange, symbol: tapeMarket.symbol } : undefined, ask.fromMs, ask.toMs)) ?? [];
4495
+ const dayLow = wrunSourceVerdictWhole(verdict)
4496
+ ? wrunCandlesLowAcross(days, span, WRUN_TAPE_COINS_DAY_MS, false)
4497
+ : undefined;
4498
+ // The chart's own bars inside the window price its part too (the forming day an answer may lack).
4499
+ const held = { fromMs: Math.max(span.fromMs, ownRows[0][0]), toMs: span.toMs };
4500
+ const ownLow = ownCandles ? wrunCandlesLowAcross(ownRows, held, chartIntervalMs, true) : undefined;
4501
+ low = dayLow === undefined || ownLow === undefined ? dayLow : Math.min(dayLow, ownLow);
4502
+ }
4503
+ // The live session this run replaces saw the tape market print lower (its `tapePriceLow`, the guard's prices where
4504
+ // the chart's bars are not the market's): that low prices this window too, so the re-plan its guard asked for never
4505
+ // loops on a candle answer still missing the fall. Its tape on the same market only (the ask's placeholders, else
4506
+ // the run market, as `fetchLane` names them).
4507
+ const heldLow = hasGoodResult && heldContext.marketIdentity === marketIdentity
4508
+ ? wrunHeldCoinTapePriceLow(heldContext, tapeMarket ?? { exchange: 'currentExchange', symbol: 'currentSymbol' })
4509
+ : undefined;
4510
+ if (low !== undefined && heldLow !== undefined)
4511
+ low = Math.min(low, heldLow);
4512
+ // The live guard reads the chart's bars only where they are the market's prices (`ownCandles`), else the prints.
4513
+ const priced = low === undefined ? undefined : wrunPricedCoinTape(coins, low, tapeValuePerUnit ?? Number.NaN, ownCandles);
4514
+ if (priced !== undefined)
4515
+ return priced;
4516
+ const market = tapeMarket ?? { exchange: chartExchange ?? '', symbol: chartSymbol };
4517
+ throw attachWrunRefusal(new Error(`WRUN ${target.metadata.id}: ${WRUN_TAPE_COINS_UNPRICED_CODE}: input '${coins.inputNames[0]}' (tape) floors ` +
4518
+ `${market.exchange}:${market.symbol} by coins (min_coins), and no candle priced its window ` +
4519
+ `[${new Date(span.fromMs).toISOString()}, ${new Date(span.toMs).toISOString()}], so its dollar floor is not set`), {
4520
+ cls: 'service-no-answer',
4521
+ variant: 'lane',
4522
+ params: { feed: 'ohlcv' },
4523
+ ...(chartMarket !== undefined ? { market: chartMarket } : {}),
4524
+ severity: 'paused',
4525
+ });
4526
+ };
4527
+ // The tape's ask: a coins floor priced over its window, every other floor as resolved.
4528
+ const tapeAsked = tape?.minCoins !== undefined ? await priceWrunCoinTape(tape) : tape;
4073
4529
  const laneThunks = {
4074
- book: declaredClasses.has('book') ? fetchBookRows : undefined,
4530
+ // The chart's own lanes of the book, oi, liquidations and funding classes: asked when an input reads the chart's
4531
+ // own market (a pinned input reads its own lane, `pinnedLanes` below).
4532
+ book: declaredLanes.has('book') ? fetchBookRows : undefined,
4075
4533
  // One buy_sell_volume lane per quote the trades inputs read (wrun-trades-lane.util, C1.4): the
4076
4534
  // coin lane asks as it always did, the dollar lane carries `currency: "USD"` in the payload the
4077
4535
  // kScript buy_sell_volume(currency="USD") source carries it in, and each payload stays its live
@@ -4080,7 +4538,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4080
4538
  trades_usd: tradesLaneThunk('trades_usd'),
4081
4539
  // The open-interest lane in the units its inputs declare (wrun-oi-lane.util): a Coin lane's `currency` rides the
4082
4540
  // 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')
4541
+ oi: declaredLanes.has('oi')
4084
4542
  ? async () => (await fetchLane('open_interest', 'oi', undefined, oiLane ? { ...oiLane } : undefined)) ?? []
4085
4543
  : undefined,
4086
4544
  volume_profile: declaredClasses.has('volume_profile')
@@ -4119,7 +4577,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4119
4577
  trade_volume_by_size: declaredClasses.has('trade_volume_by_size')
4120
4578
  ? () => fetchDegradableLane('trade_volume_by_size', 'tvbs', 'Trade volume by size')
4121
4579
  : undefined,
4122
- liquidations: declaredClasses.has('liquidations')
4580
+ liquidations: declaredLanes.has('liquidations')
4123
4581
  ? async () => (await fetchLane('liquidations', 'liq')) ?? []
4124
4582
  : undefined,
4125
4583
  // Funding exists on perps only. A funding input that declares `missing:
@@ -4127,7 +4585,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4127
4585
  // FX or prediction market the lane answers empty QUIETLY (like oi) and
4128
4586
  // the row builder fills the policy; only an input on the default carry
4129
4587
  // policy (nothing to carry) reads an empty answer as a degraded lane.
4130
- funding: declaredClasses.has('funding')
4588
+ funding: declaredLanes.has('funding')
4131
4589
  ? wrunFundingLaneRequired(target.metadata)
4132
4590
  ? () => fetchDegradableLane('funding_rate', 'fr', 'Funding rate')
4133
4591
  : async () => (await fetchLane('funding_rate', 'fr')) ?? []
@@ -4139,22 +4597,25 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4139
4597
  // The options_chain lane dispatches in its own group, once its identity resolved (below).
4140
4598
  etf_flow: etfLanePlan !== undefined ? () => fetchEtfFlowRows(etfLanePlan) : undefined,
4141
4599
  // 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),
4600
+ // TRADE_LARGE type) on every market, never the raw tape (wrunTapeLaneExtras),
4144
4601
  // at the acquisition's facets, the one floor pushed down to the gateway
4145
4602
  // (`minSize` as `minAmount`, a dollar `minValue` as `minQuoteAmount`, C-DOLLAR) and `history`
4146
4603
  // 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
4604
+ // chart's window, counted back from the run's as-of (`historyAsOfAsk`: a replay's present; on a
4605
+ // live run `tapeAsOfAsk`, the session's pin for the tape, so a later run of the session never
4606
+ // seeds it from a later start), clamped to the table's 90-day retention and the gateway's bar
4607
+ // limit, its window still ending at the server's now. A history of "0" answers EMPTY by
4148
4608
  // contract (the live edge only) and a quiet filtered window answers empty on a clean wire, so an
4149
4609
  // empty answer computes (present empty blocks on every bar), a quiet lane like trades; a lane
4150
4610
  // error (the worker's 300k-cell cap, a refused stream) degrades it. The payload stays the lane's
4151
4611
  // acquisition: the live fold's floor (a dollar floor with the market's `valuePerUnit`, the
4152
4612
  // market facts' dollar unit, so a live print is priced in the history's unit, never guessed)
4153
4613
  // 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))) ?? []
4614
+ tape: tapeAsked !== undefined
4615
+ ? async () => (await fetchLane('trades', 'tp', undefined, {
4616
+ ...wrunTapeLaneExtras(tapeAsked, tapeValuePerUnit),
4617
+ ...tapeAsOfAsk,
4618
+ })) ?? []
4158
4619
  : undefined,
4159
4620
  // The trades leg lanes (kit 0.77.0), one thunk per (quote, market): K_BUY_SELL_VOLUME asked on
4160
4621
  // the leg's market in its quote, under the lane id as its fetch key (its own cache entry and
@@ -4165,6 +4626,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4165
4626
  tradeLegs: tradeLegLanes
4166
4627
  .filter((lane) => !softRefusedTradeLegs.has(lane) && !unservedTradeLegs.has(lane))
4167
4628
  .map((lane) => [lane, (abandoned) => fetchTradeLegRows(lane, abandoned)]),
4629
+ // The pinned lanes (U9e), one thunk per (class, market): quiet like the chart's own lanes of their classes (a
4630
+ // required funding lane degrades). A lane on a venue the gateway does not serve yet, or one the capability rule
4631
+ // judged unserved on its market, is never asked: its inputs read their fill.
4632
+ pinnedLanes: pinnedLaneIds
4633
+ .filter((lane) => !softRefusedPinnedLanes.has(lane) && !unservedTradeLegs.has(lane))
4634
+ .map((lane) => [lane, () => fetchPinnedLaneRows(lane)]),
4168
4635
  // The registry poll lanes and the row lanes dispatch in their own groups, once their plans resolved (below).
4169
4636
  };
4170
4637
  // A lane the chart's fetch never serves here is not dispatched (the capability rule above).
@@ -4174,12 +4641,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4174
4641
  // it degrades, its fetch abandoned, never aborted (the late answer lands in the fetch cache a
4175
4642
  // recovery reads).
4176
4643
  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).
4644
+ // The tape asks TRADE_LARGE from its seed start (the declared history back from its as-of: the session's pin for
4645
+ // the tape, a replay's present, else the window's end, `tapeHistoryAsOfMs`) through the window's end on the minute
4646
+ // grid, whatever the chart's bars: its budget is sized by the minutes it asks, never below the chart's (a 7-day
4647
+ // history waits 35.2 s where a 500-bar chart's lanes wait 11.25 s).
4180
4648
  const tapeBudgetMs = tape !== undefined && tape.historySeconds > 0
4181
4649
  ? Math.max(chartBudgetMs, resolveSecondarySourceBudgetMs({
4182
- fromMs: to - tape.historySeconds * 1000,
4650
+ fromMs: Math.min(tapeHistoryAsOfMs ?? to, to) - tape.historySeconds * 1000,
4183
4651
  toMs: to,
4184
4652
  intervalMs: Intervals.MINUTE,
4185
4653
  }))
@@ -4190,9 +4658,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4190
4658
  const tradeLegBudgetMs = new Map();
4191
4659
  for (const lane of tradeLegLanes) {
4192
4660
  const ask = tradeLegAskOf(lane);
4193
- if (ask === undefined)
4661
+ if (ask === undefined || ask.tier === null)
4194
4662
  continue;
4195
- tradeLegBudgetMs.set(lane, Math.max(chartBudgetMs, resolveSecondarySourceBudgetMs({ fromMs: ask.fromMs, toMs: ask.toMs, intervalMs: ask.tierMs })));
4663
+ tradeLegBudgetMs.set(lane, Math.max(chartBudgetMs, resolveSecondarySourceBudgetMs({ fromMs: ask.fromMs, toMs: ask.toMs, intervalMs: ask.tier.tierMs })));
4196
4664
  }
4197
4665
  if (laneThunks.tape !== undefined &&
4198
4666
  tapeBudgetMs !== chartBudgetMs &&
@@ -4219,6 +4687,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4219
4687
  run?.interval ?? '',
4220
4688
  generationAtStart,
4221
4689
  ].join('|');
4690
+ // The tape's identity names its ask too (`wrunTapeReadIdentity`): a coins floor priced off another low asks other
4691
+ // rows, so a read an earlier run left out at its floor is never joined or adopted at this one's.
4692
+ const laneReadIdentity = (lane) => lane === 'tape' && tapeAsked !== undefined ? wrunTapeReadIdentity(lateReadIdentity, tapeAsked) : lateReadIdentity;
4222
4693
  // The policy every group's lanes ride: the budget, counted from each lane's dispatch until its send re-anchors it (its
4223
4694
  // anchor goes to `fetchLane`, which hands it to the transport), the pending mark at dispatch (the degrade registry the
4224
4695
  // legend chips derive from: the budget stays the chip's authority), and the read a lane's budget abandoned, noted for
@@ -4249,7 +4720,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4249
4720
  noteWrunLateRead({
4250
4721
  indicatorId: target.indicatorId,
4251
4722
  lane,
4252
- identity: lateReadIdentity,
4723
+ identity: laneReadIdentity(lane),
4253
4724
  answer,
4254
4725
  acquisition: () => acquisitionByLane[lane],
4255
4726
  });
@@ -4258,7 +4729,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4258
4729
  // A lane whose read an earlier run left out under this run's identity joins that read (still out) or adopts its
4259
4730
  // answer: the lane sends no second ask. The acquisition the earlier run recorded is the lane's here.
4260
4731
  const joinLateRead = (lane) => {
4261
- const taken = takeWrunLateRead(target.indicatorId, lane, lateReadIdentity);
4732
+ const taken = takeWrunLateRead(target.indicatorId, lane, laneReadIdentity(lane));
4262
4733
  if (taken === undefined)
4263
4734
  return undefined;
4264
4735
  if (wrunChartHostEnv().diagnostics.debugEnabled()) {
@@ -4404,6 +4875,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4404
4875
  if ([...gatePlanes.values()].includes('cme'))
4405
4876
  computed.cme = true;
4406
4877
  const writeOpraProvenance = await opraProvenanceWriter;
4878
+ // The US stocks tape's provenance of every `stocks` row lane the sheet declares (it reads the tape through its own
4879
+ // fetch, past the chart's fetch door that stamps a tape read): its tape on the overlay's settings while its instance is
4880
+ // planned, taken off once none is (an input dropped with its fill), before any row is drawn.
4881
+ await syncWrunStocksLaneProvenance(target.chartIndex, target.indicatorId, target.metadata, rowLanes, () => head.isCurrent());
4407
4882
  // 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
4883
  // a setting gate, a unit pick, `needed_by` or the capability rule dropped. No later run of this sheet asks that lane
4409
4884
  // again, so its chip would stand over a picture that never reads it; only a teardown would clear it.
@@ -4442,7 +4917,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4442
4917
  // 2.3): the run proceeds with a degraded lane EMPTY only when every input
4443
4918
  // reading it declares `missing: 'nan'`, or `missing: 'empty'` on a celled
4444
4919
  // input (the outputs it feeds read blank or over EMPTY blocks, nothing
4445
- // wrong-but-plausible is drawn); otherwise it holds below.
4920
+ // wrong-but-plausible is drawn); otherwise it holds below. A lane the
4921
+ // market does not serve reads as the capability rule reads it instead
4922
+ // (wrunDegradedLaneDrawable: the book of a market with no order book).
4446
4923
  const degraded = laneRun.degraded.map(({ lane, outcome }) => ({
4447
4924
  lane,
4448
4925
  ...wrunLaneSourceOf(lane, laneInstances),
@@ -4451,7 +4928,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4451
4928
  }));
4452
4929
  // A lane another screen's session stopped also holds while the overlay shows a good picture: that picture's data is
4453
4930
  // 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));
4931
+ const holding = laneRun.degraded.filter(({ lane, outcome }) => !wrunDegradedLaneDrawable(target.metadata, lane, outcome, laneInstances) ||
4932
+ (gateStops.has(lane) && hasGoodResult));
4455
4933
  // Each degraded lane's record for the moment the source ladder gives up on it (the run's settle
4456
4934
  // and the degrade registry's listener project it): a note when the run draws around the lane,
4457
4935
  // paused when it holds on it.
@@ -4534,6 +5012,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4534
5012
  const rowLaneRows = (laneResults.rowLaneRows ?? {});
4535
5013
  // The trades leg lanes' rows by lane id: a leg never asked holds none (its inputs read their fill).
4536
5014
  const tradeLegRows = laneResults.tradeLegRows ?? {};
5015
+ // The pinned lanes' rows by lane id (U9e): a lane never asked holds none (its inputs read their fill).
5016
+ const pinnedLaneRows = laneResults.pinnedLaneRows ?? {};
4537
5017
  // The run bars (fetched or held, the forming one included): the session's buffer.
4538
5018
  const fetchedRunBars = runRowsPlan
4539
5019
  ? (runRowsPlan.held ?? (await runRowsPromise))
@@ -4595,14 +5075,15 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4595
5075
  const stopped = holding.find(({ lane }) => gateStops.has(lane));
4596
5076
  // A lane the data plane refused by name names the hold the same way (its record: the tape over the trades
4597
5077
  // 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.
5078
+ // the same settings meet again (`markWrunLaneRefusedHold`): neither the settings reconcile nor the heal reruns it.
4599
5079
  const refused = stopped === undefined
4600
5080
  ? holding.find(({ outcome }) => wrunLaneRefusedCodeOf(outcome.error) !== undefined)
4601
5081
  : undefined;
4602
5082
  const shown = stopped ?? refused ?? holding[0];
4603
5083
  const hold = wrunSourceHoldError(target.title, wrunLaneSourceOf(shown.lane, laneInstances), shown.outcome);
4604
- if (refused !== undefined)
4605
- wrunRefusedSourceHolds.add(hold);
5084
+ const refusedCode = refused === undefined ? undefined : wrunLaneRefusedCodeOf(refused.outcome.error);
5085
+ if (refusedCode !== undefined)
5086
+ markWrunLaneRefusedHold(hold, refusedCode);
4606
5087
  const named = stopped ?? refused;
4607
5088
  const namedRecord = named !== undefined ? refusal.degraded?.find(({ lane }) => lane === named.lane)?.refusal : undefined;
4608
5089
  throw namedRecord !== undefined ? annotateWrunErrorRefusal(hold, namedRecord) : hold;
@@ -4731,12 +5212,16 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4731
5212
  tapeRows,
4732
5213
  // The plan resolves a param-bound tape floor from the settings it is handed: the floor the
4733
5214
  // lane was asked at (the param's current value).
4734
- ...(tape !== undefined ? { settings: wrunTapeFloorSettings(target.metadata, wrunTapeFloorOf(tape)) } : {}),
5215
+ ...(tapeAsked !== undefined
5216
+ ? { settings: wrunTapeFloorSettings(target.metadata, wrunTapeFloorOf(tapeAsked)) }
5217
+ : {}),
4735
5218
  ...(pollLanes.length > 0 ? { pollLanes, pollLaneRows } : {}),
4736
5219
  ...(rowLanes.length > 0 ? { rowLanes, rowLaneRows } : {}),
4737
5220
  ...(Object.keys(tradeLegRows).length > 0
4738
5221
  ? { tradeLegRows, tradeLegIntervals: wrunTradeLegIntervals(acquisitionByLane) }
4739
5222
  : {}),
5223
+ // Each foreign ask of a book, oi, funding or liquidations input reads the pinned lane of its market (U9e).
5224
+ ...(Object.keys(pinnedLaneRows).length > 0 ? { pinnedLaneRows } : {}),
4740
5225
  ...(hasPinnedLegs ? { pinnedCandleRows, pinnedLegTierMs: wrunPinnedLegTierMs(legs) } : {}),
4741
5226
  ...(hasLiveCandleLegs ? { pinnedLiveCandleRows } : {}),
4742
5227
  ...(hasIntrabarLegs ? { intrabarRows } : {}),
@@ -4755,9 +5240,31 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4755
5240
  formingBarTs,
4756
5241
  };
4757
5242
  // 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);
5243
+ // landing read the chart's own bars. The same for the host session's composition (wrun-session-composition.util):
5244
+ // the compute reads the session's tape and trades rows from its seam on, while the lanes this run installs on its
5245
+ // live context stay OpenMarket's.
5246
+ const composition = composeWrunSessionSources({
5247
+ chartIndex: target.chartIndex,
5248
+ indicatorId: target.indicatorId,
5249
+ intervalMs: clock.intervalMs,
5250
+ lanes: {
5251
+ metadata: target.metadata,
5252
+ acquisition: acquisitionByLane,
5253
+ market: wrunChartStreamIdentity(chartMetadata),
5254
+ },
5255
+ }, computeOhlcvRows === ohlcvRows ? sourceRows : { ...sourceRows, ohlcvRows: computeOhlcvRows });
5256
+ const computeSourceRows = composition.sources;
5257
+ // The host's token the rows were composed under: the install compares it (an owner change in flight owes a revision).
5258
+ const compositionToken = composition.token;
5259
+ // A live run seeds its session's carry from these rows (the integrate's install). On the host's `carryWithBuild`
5260
+ // (web: the engine arm `webkit-wrun-carry-with-build`) the rows and that carry come from one conversion of the
5261
+ // window's lanes, here, before any await; else the install advances the carry from the empty seed, converting the
5262
+ // window again over the sources as the awaits left them.
5263
+ const builtWithCarry = live && wrunHostCarryWithBuild()
5264
+ ? buildWrunInputRowsAndCarry(target.metadata, computeSourceRows, clock)
5265
+ : undefined;
5266
+ const carryAtBuild = wrunCarryAtBuildOf(builtWithCarry, ohlcvRows, computeSourceRows);
5267
+ const rows = builtWithCarry?.rows ?? buildWrunInputRows(target.metadata, computeSourceRows, clock);
4761
5268
  // An exact warm-up session's candle evidence (D2), fingerprinted in the same synchronous block as the guest's
4762
5269
  // input rows (C3): the candles the guest reads, never a chart row an await below could see rewritten in place.
4763
5270
  // Installed on the session only once its run succeeded warm.
@@ -4881,6 +5388,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4881
5388
  bookRows,
4882
5389
  buySellVolumeRows,
4883
5390
  buySellVolumeUsdRows,
5391
+ // The carry the session takes, from the build's own conversion (`carryWithBuild`), with what that build read; the
5392
+ // install keeps it only while none of that moved, else advances it as without the switch.
5393
+ carryAtBuild,
4884
5394
  chartExchange,
4885
5395
  chartFirstTs,
4886
5396
  chartInterval,
@@ -4890,6 +5400,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4890
5400
  chartRows,
4891
5401
  clampedLegs,
4892
5402
  clock,
5403
+ compositionToken,
4893
5404
  computeIdentity,
4894
5405
  computeSourceRows,
4895
5406
  cryptoVenue,
@@ -4925,6 +5436,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4925
5436
  optionsChainRows,
4926
5437
  paramValues,
4927
5438
  pinnedCandleRows,
5439
+ pinnedLaneRows,
4928
5440
  pinnedLiveCandleRows,
4929
5441
  planGeneration,
4930
5442
  pollLaneRows,
@@ -4984,6 +5496,14 @@ const WRUN_ROW_SOURCE_TRANSIENT_SEED = {
4984
5496
  variant: 'generic',
4985
5497
  out: { kind: 'retry' },
4986
5498
  };
5499
+ /** The guest memory a live-start block reported (`WrunLiveBlockStats.memoryBytes`), as a live context field: what a
5500
+ * warm switch's park counts for the worker's share of the session. Empty when the worker named none. */
5501
+ function wrunWorkerMemoryOf(outputRows) {
5502
+ const memoryBytes = wrunLiveOf(outputRows)?.memoryBytes;
5503
+ return typeof memoryBytes === 'number' && Number.isFinite(memoryBytes) && memoryBytes > 0
5504
+ ? { workerMemoryBytes: memoryBytes }
5505
+ : {};
5506
+ }
4987
5507
  /** The overlay's live frames as the pass takes its sandbox session (C7): the sandbox tick integrates
4988
5508
  * its own frames (the browser drain), so the stream it hands the pass carries none. */
4989
5509
  const wrunTickOwnedFrames = () => undefined;
@@ -5448,6 +5968,16 @@ export function __resetWrunHeldRowSourcesForTests() {
5448
5968
  wrunHeldRowSources.clear();
5449
5969
  __resetWrunSocketSessionLossesForTests();
5450
5970
  wrunPendingRowSourceAsks.clear();
5971
+ // The install pacer's turns too (every waiter released): a spec's first install goes at once.
5972
+ __resetWrunInstallPacerForTests();
5973
+ }
5974
+ // Chart teardown (`teardownWrunOverlaysForChart`, through its chart hooks, after it dropped every live context of the
5975
+ // chart) drops the chart's install turn: its waiters go at once and meet their commit checks on a chart that left.
5976
+ try {
5977
+ onWrunChartTeardown(dropWrunInstallPacer);
5978
+ }
5979
+ catch {
5980
+ // partial module mock (specs)
5451
5981
  }
5452
5982
  // A session that ends (the overlay leaves, a Pause suspends it) releases the source it held. An overlay that leaves
5453
5983
  // (never a Pause: its run stands down on the pause itself) cancels the fresh asks it has pending first.
@@ -5642,12 +6172,16 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5642
6172
  await integrateWrunRowSourceBatch(runTarget, tc, meta, refusal, computed, owner, head, ask, batch);
5643
6173
  return;
5644
6174
  }
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;
6175
+ 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
6176
  // The filling chip (`fillingLanes`, a first-slice picture): raised right before the integrate, lowered if the run
5647
6177
  // fails after it.
5648
6178
  const fillingGuardKey = overlayExecutionGuardKey(target.chartIndex, target.indicatorId);
5649
6179
  let fillingRaised = false;
5650
6180
  try {
6181
+ // The gesture's idle edge (WRUN-PANBACK A1): a held reason's result waits here, before anything below reads the
6182
+ // chart, the overlay, its settings or its session. A user run queued meanwhile drops this result as superseded (the
6183
+ // catch releases what the ask opened).
6184
+ const edge = await awaitWrunInstallGestureEdge(runTarget, reason);
5651
6185
  // The module's rows, the batch's own array (its frames, handles and strategy ride on it). A hidden head's rows
5652
6186
  // are cut by timestamp here (D4), where the pass receives them from the row source, before the integrate, the
5653
6187
  // warm-up ask, the health verdict and the live context read anything: the guest ran them, nothing shows them.
@@ -5656,17 +6190,24 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5656
6190
  const retained = retainedWindow !== undefined && retainedWindow.droppedBars > 0
5657
6191
  ? { cap: retainedWindow.cap, calculatedBars: outputRows.length, droppedBars: retainedWindow.droppedBars }
5658
6192
  : 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.
6193
+ // Every await the install needs comes before its turn: the price canvases' served TPO block (G1, for the chart
6194
+ // market; the catalog read may await) and the chart store the write boundary's checks read in the turn's task.
6195
+ const canvasHostFill = await wrunCanvasHostFillFor(target.metadata, chartMetadata);
6196
+ const readChartMetadata = await wrunChartMetadataReaderFor(target.chartIndex);
6197
+ const readOverlayPaused = await wrunOverlayPausedReaderFor(target.chartIndex, target.indicatorId);
6198
+ // The write boundary (WRUN-PANBACK-2 S1): the chart's install turn, one install per WRUN_INSTALL_MIN_GAP_MS, so the
6199
+ // results one idle edge released paint one after another; a drag that started while the turn waited holds the
6200
+ // result again (a fresh turn after it) while the episode's ceiling lasts. Nothing below awaits until the titan
6201
+ // write, so the write lands in the task that took the turn and every commit check judges what stands there.
6202
+ const { heldMs, pacedMs } = await awaitWrunInstallWriteTurn(runTarget, reason, edge);
6203
+ // The engine tick and the price canvases' fill, read at integrate time: on a mirror miss the block the overlay's
6204
+ // live session holds for this market (the reseed's rule), so a mirror entry that aged out never moves the grid.
5664
6205
  const integrateHostFill = wrunHostFillContextFor(tc, chartExchange, clock.intervalMs);
5665
- const canvasFill = wrunCanvasFillWithSessionBlock(await wrunCanvasHostFillFor(target.metadata, chartMetadata), target.metadata, target.indicatorId, chartMetadata);
6206
+ const canvasFill = wrunCanvasFillWithSessionBlock(canvasHostFill, target.metadata, target.indicatorId, chartMetadata);
5666
6207
  // The route's facts, read again now that the worker answered (D2 2.6):
5667
6208
  // the chart, the overlay and the market the run computed for, and the
5668
6209
  // settings it computed with.
5669
- const identityLeft = await wrunRunIdentityLeft(target.chartIndex, tc, meta, marketIdentity);
6210
+ const identityLeft = wrunRunIdentityLeft(target.chartIndex, tc, meta, marketIdentity, readChartMetadata);
5670
6211
  // The settings the run computed with are still the overlay's only while no compute save landed
5671
6212
  // since the run started: a generation only grows, so a save between the start and the params
5672
6213
  // read made the run a mix of two, and one after the read made it old. Never by content: ON, OFF,
@@ -5680,6 +6221,11 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5680
6221
  // run's copy only), so the live context's ticks and reseeds plan the legs this run fetched.
5681
6222
  const sheetNow = wrunSheetWithRespelledPins(wrunSheetWithSettings(runTarget.metadata, meta.settings), respelledPins);
5682
6223
  assertWrunRunMayPaint(target.chartIndex, target.indicatorId, replay);
6224
+ // A picture over a lane still filling (a row lane's first-paint slice, its older bars loading) or degraded to
6225
+ // empty is not final: the fill's or the recovery's run (a whole run, same generation and market) completes it.
6226
+ // It names no picture, and neither does the session it installs, so no heatmap scale decided from the partial
6227
+ // rows is held as the final picture's (wrunPictureIdentityOf).
6228
+ const picturePartial = fillingLanes.length > 0 || degraded.length > 0;
5683
6229
  const integrateOptions = {
5684
6230
  tc,
5685
6231
  meta,
@@ -5687,6 +6233,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5687
6233
  indicatorId: target.indicatorId,
5688
6234
  metadata: sheetNow,
5689
6235
  outputRows,
6236
+ // What these rows were computed for (the settings generation and the market the run read, the live
6237
+ // context's identity below): a mounted heatmap keeps its colour scale through a rerun of the same picture.
6238
+ pictureIdentity: wrunPictureIdentityOf({ settingsRevision: computed.generation, marketIdentity, picturePartial }),
5690
6239
  params: paramValues,
5691
6240
  title: target.title,
5692
6241
  position: target.position,
@@ -5695,8 +6244,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5695
6244
  fills: target.fills,
5696
6245
  candles: target.candles,
5697
6246
  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),
6247
+ // The draft's word, an OPRA chain's served tier and the delayed CME legs (wrun-draft-legend-note.util); every
6248
+ // tick repeats it.
6249
+ legendNote: wrunOverlayLegendNote(meta.settings, acquisitionByLane.options_chain, acquisitionByLane, undefined, computed.cmeDelayed),
5700
6250
  // The market's size unit (an output its `visible_by` leaves out here mounts nothing) and its dollar unit (the
5701
6251
  // batched marks' `units`).
5702
6252
  ...wrunResultMarketUnits(chartMetadata),
@@ -5714,7 +6264,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5714
6264
  // A pause (or a later install or teardown that moved the live generation) landed while the
5715
6265
  // worker answered: the returned output is dropped and no live context installs; the
5716
6266
  // retained picture stays (the run leaves the way the head's pause does, silently).
5717
- if ((await isWrunOverlayPaused(target.chartIndex, target.indicatorId)) ||
6267
+ if (readOverlayPaused() ||
5718
6268
  (generation !== undefined && currentWrunOverlayLiveGeneration(target.indicatorId) !== generation)) {
5719
6269
  throw new WrunOverlayPausedError('paused');
5720
6270
  }
@@ -5734,6 +6284,10 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5734
6284
  // A CME chart study lands only under the authorisation its head captured, judged in the task that applies it.
5735
6285
  assertWrunCmeStudyAuthCurrent(computed, target.indicatorId);
5736
6286
  const runSerial = nextWrunCanvasRunSerial(target.indicatorId);
6287
+ // A result still the overlay's own reaches the route's write (a superseded one skips it below).
6288
+ if (!identityLeft && !settingsStale) {
6289
+ ringWrunInstallApplied(target.chartIndex, target.indicatorId, reason, heldMs, pacedMs);
6290
+ }
5737
6291
  const integration = integrateWrunRunThroughRoute({
5738
6292
  ...integrateOptions,
5739
6293
  integration: {
@@ -5785,6 +6339,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5785
6339
  // The stamp stands until a later run can clear it.
5786
6340
  }
5787
6341
  }
6342
+ // A result that asks nothing still supersedes an older one held on its sources.
6343
+ wrunWarmupAsksOnLanding.delete(fillingGuardKey);
5788
6344
  // The result asks once whether older candles are owed for its warm-up (the engine lane's own
5789
6345
  // ask; a result the route skipped as unchanged is the picture the chart shows, so it asks
5790
6346
  // too). A full run only: the tick and the reseed integrate without this pass. Never under
@@ -5792,6 +6348,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5792
6348
  // Nor for a run its budget clamped: older candles cannot reach a window the budget decided (design 5). Nor for a
5793
6349
  // run that drew first: its heads were deferred, so it holds no credit, and the warm rerun the landed head owes the
5794
6350
  // overlay asks with the credit (a cold ask here would buy a visible page the head covers).
6351
+ // The ask's verdict also holds the viewer's nothing-drawn note below (FB27): a page it buys reruns the overlay
6352
+ // before the note could say the Indicator drew nothing.
6353
+ const warmupPage = replay ? undefined : wrunWarmupPageVerdict();
5795
6354
  if (!replay && retainedWindow === undefined && !headsDeferred)
5796
6355
  askWrunWarmupBackfillIfOwed({
5797
6356
  chartIndex: target.chartIndex,
@@ -5817,12 +6376,18 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5817
6376
  lookbackBars: wrunTwinLookbackBars(meta.settings) ?? (await wrunTwinOriginalLookbackBars(meta.settings, chartIntervalMs)),
5818
6377
  unsettledLanes,
5819
6378
  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).
6379
+ // Where the history the run read begins: every lane it asked and every leg, from the bar its lanes asked from.
5822
6380
  historySources: {
5823
- rowLanes,
5824
- readsOtherSources: legs.length > 0 || laneRun.outcomes.some(({ lane }) => !isWrunRowLaneId(lane)),
6381
+ lanes: wrunRunHistoryLanesOf({
6382
+ lanes: laneRun.outcomes.map(({ lane, outcome }) => ({ lane, rows: outcome.rows })),
6383
+ rowLanes,
6384
+ pollLanes,
6385
+ legs,
6386
+ legRows: (fetchKey) => pinnedCandleRows[fetchKey] ?? intrabarRows[fetchKey],
6387
+ }),
6388
+ askedFromMs: from,
5825
6389
  },
6390
+ onNoPage: warmupPage?.noPage,
5826
6391
  });
5827
6392
  // The presentation that follows every integrate (the parent and its
5828
6393
  // lower-pane children mounted): nested output visibility from the sheet
@@ -5842,8 +6407,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5842
6407
  // healthy run clears the rows a previous one raised, and the live session below keeps the
5843
6408
  // verdict honest once the overlay starts drawing. The chip policy (`wrunChartRunHealth`):
5844
6409
  // 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);
6410
+ // on this market (its own note says so once). An app layer (wrun-app-layer.leaf) is read as a viewer reads it: it
6411
+ // rides the draft lane, but nobody authored it here.
6412
+ const draft = isWrunDraftOverlaySettings(meta.settings) && !isWrunAppLayerOverlaySettings(meta.settings);
5847
6413
  const emptySeries = wrunEmptySeriesFeeds(laneRun, unsettledLanes, target.metadata, cryptoVenue, (lane) => {
5848
6414
  const asked = acquisitionByLane[lane]?.exchange;
5849
6415
  return typeof asked === 'string' && asked !== 'currentExchange' ? asked : chartExchange;
@@ -5858,6 +6424,29 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5858
6424
  emptySeries.length > 0;
5859
6425
  const { watched, health } = wrunChartRunHealth(sheetNow, meta.settings, outputRows, sourceAbsent, wrunChartSizeUnit(chartMetadata));
5860
6426
  const runHealthWarned = await publishWrunRunHealth(target.chartIndex, target.indicatorId, wrunRunHealthRowsFor(health, draft, wrunNothingReadyRefusal(health, refusal.ctx)));
6427
+ // A viewer's note when this published Indicator drew nothing over the whole loaded window (FB27), judged only on
6428
+ // the picture the chart now shows and only once the run is settled: a window of the range, a first slice still
6429
+ // filling, a lane unanswered, a source with its own note (`sourceAbsent`), a budget-clamped window or a deferred
6430
+ // head's rerun still owed leaves the note as it stands, and a raise waits for the warm-up ask's verdict.
6431
+ if (integration.applied || (route.action === 'skip' && route.reason === 'render-equal')) {
6432
+ await publishWrunNothingDrawn(target.chartIndex, target.indicatorId, {
6433
+ draft,
6434
+ settled: window?.partial !== true &&
6435
+ fillingLanes.length === 0 &&
6436
+ unsettledLanes.size === 0 &&
6437
+ !sourceAbsent &&
6438
+ retainedWindow === undefined &&
6439
+ !headsDeferred,
6440
+ metadata: sheetNow,
6441
+ rows: outputRows,
6442
+ drawings: wrunHandlesOf(outputRows)?.length,
6443
+ runIntervalMs: run ? run.intervalMs : chartIntervalMs,
6444
+ }, () => refusal.ctx, {
6445
+ // A raise the warm-up verdict holds lands on this run's mount only, never a same-id remount's.
6446
+ isCurrent: () => isWrunRunMountOnChart(target.chartIndex, { tc, meta }),
6447
+ ...(warmupPage !== undefined ? { warmup: warmupPage } : {}),
6448
+ });
6449
+ }
5861
6450
  // A leg the chart could not serve is not a failure (the run drew what it
5862
6451
  // could): one note per pinned market says why its inputs read their fill,
5863
6452
  // on a draft and on a registry Indicator alike, replaced by every run and
@@ -5921,6 +6510,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5921
6510
  window,
5922
6511
  executedVersion: target.version,
5923
6512
  firstSlice: fillingLanes.length > 0,
6513
+ readsCme: computed.cme === true,
5924
6514
  });
5925
6515
  }
5926
6516
  if (live && generation !== undefined && rows.length > 0) {
@@ -5959,6 +6549,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5959
6549
  // The run's console provenance: every debug line the session's ticks and reseeds publish states it.
5960
6550
  ...(computed.opra === true ? { opraRead: true } : {}),
5961
6551
  ...(computed.cme === true ? { cmeRead: true } : {}),
6552
+ // The delayed CME legs its legend names: every tick and reseed names them alike.
6553
+ ...(computed.cmeDelayed !== undefined ? { cmeDelayed: computed.cmeDelayed } : {}),
5962
6554
  // The current paint (above): the ticks and the reseeds keep the look.
5963
6555
  metadata: sheetNow,
5964
6556
  title: target.title,
@@ -5986,7 +6578,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5986
6578
  ...(retainedRowsCap !== undefined ? { retainedRowsCap } : {}),
5987
6579
  ...(runBlockRowsCap !== undefined ? { runBlockRowsCap } : {}),
5988
6580
  ...(retained !== undefined ? { retained } : {}),
5989
- bookRows: bookRows ? [...bookRows] : undefined,
6581
+ // The book lane's own rows, never copied (WRUN-PANBACK-2 S2: on the packed lane, views of the worker's block):
6582
+ // the push intake's folds and every other writer replace the array, none writes into it.
6583
+ bookRows,
5990
6584
  buySellVolumeRows: buySellVolumeRows ? [...buySellVolumeRows] : undefined,
5991
6585
  buySellVolumeUsdRows: buySellVolumeUsdRows ? [...buySellVolumeUsdRows] : undefined,
5992
6586
  openInterestRows: openInterestRows ? [...openInterestRows] : undefined,
@@ -6027,6 +6621,14 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
6027
6621
  tradeLegRows: Object.fromEntries(Object.entries(tradeLegRows).map(([lane, rows]) => [lane, [...rows]])),
6028
6622
  }
6029
6623
  : {}),
6624
+ // The pinned lanes the run asked (U9e): a copy of each one's rows by lane id. The push intake folds each lane
6625
+ // market's frames into it (book, funding, liquidations), the reconcile re-asks it (an oi lane by the poll),
6626
+ // and the live channels follow these keys (a lane never asked holds none and is never subscribed).
6627
+ ...(Object.keys(pinnedLaneRows).length > 0
6628
+ ? {
6629
+ pinnedLaneRows: Object.fromEntries(Object.entries(pinnedLaneRows).map(([lane, rows]) => [lane, [...rows]])),
6630
+ }
6631
+ : {}),
6030
6632
  ...(legs.length > 0 ? { pinnedLegs } : {}),
6031
6633
  ...(hasPinnedLegs ? { pinnedCandleRows } : {}),
6032
6634
  ...(hasLiveCandleLegs ? { pinnedLiveCandleRows } : {}),
@@ -6034,9 +6636,17 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
6034
6636
  // The forming pre-roll rows: the reseed rebuilds the head's bucket from them.
6035
6637
  ...(formingPreRoll !== undefined ? { formingPreRoll } : {}),
6036
6638
  generation,
6639
+ // The live-start above opened the worker's series under this generation.
6640
+ seriesEpoch: generation,
6037
6641
  intervalMs: clock.intervalMs,
6038
6642
  acquisition: acquisitionByLane,
6039
- carrySeed: advanceWrunInputCarry(target.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock),
6643
+ // The guest memory the live-start reported: what a warm switch's park counts for the worker's share.
6644
+ ...wrunWorkerMemoryOf(outputRows),
6645
+ carrySeed: wrunCarryAtBuildStill(carryAtBuild, ohlcvRows) ??
6646
+ advanceWrunInputCarry(target.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock, carryAtBuild === undefined ? 'advance' : 'recovered'),
6647
+ // The instant the session's declared depth counts back from (wrun-history-as-of.util): its reseeds and wake
6648
+ // recoveries rebuild under it, never under their own now alone.
6649
+ historyAsOfMs: wrunClockHistoryAsOfMs(clock),
6040
6650
  fedBuckets: {},
6041
6651
  pushEligible: wrunPushEligible(target.metadata, run ? run.interval : chartInterval),
6042
6652
  paintedThroughTs: lastRowTs,
@@ -6061,6 +6671,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
6061
6671
  // degraded ones, and the ones the capability rule never dispatched.
6062
6672
  ...(window ? { window } : {}),
6063
6673
  ...(degradedLanes.size > 0 ? { degradedLanes } : {}),
6674
+ // The run drew a partial picture (a filling or degraded lane): the session's passes name none either.
6675
+ ...(picturePartial ? { picturePartial: true } : {}),
6064
6676
  ...(unservedLanes.length > 0 || unservedTradeLegs.size > 0
6065
6677
  ? { unservedLanes: new Set([...unservedLanes, ...unservedTradeLegs]) }
6066
6678
  : {}),
@@ -6141,7 +6753,15 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
6141
6753
  indicatorId: target.indicatorId,
6142
6754
  ...capability,
6143
6755
  });
6756
+ // The context this one replaces: an owner change while the run computed revised it, not this one.
6757
+ const replacedDirtyFromTs = getWrunOverlayLiveContext(target.indicatorId)?.dirtyFromTs ?? null;
6144
6758
  setWrunOverlayLiveContext(liveContext);
6759
+ // The host's session changed owner while the run computed (a hand-back, a new seam): its rows read a
6760
+ // composition that is no longer the overlay's, so the revision the replaced context owed is carried onto this
6761
+ // one (the whole window when it owed none): the drain reseeds over the composition as it stands.
6762
+ if (compositionToken !== wrunSessionCompositionToken(target.indicatorId)) {
6763
+ oweWrunCompositionRevision(liveContext, replacedDirtyFromTs ?? liveContext.firstRowTs);
6764
+ }
6145
6765
  if (replay) {
6146
6766
  noteWrunReplayRun(liveContext, {
6147
6767
  generation: replay.generation,
@@ -6571,6 +7191,10 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6571
7191
  let declarationsMoved = false;
6572
7192
  try {
6573
7193
  const reason = runTarget.reason ?? 'loaded-range-refresh';
7194
+ // The gesture's idle edge (WRUN-PANBACK A1), as on the browser lane: before the batch's sheet is remembered and
7195
+ // before every commit check below. A user run queued meanwhile drops the batch as superseded (the catch releases
7196
+ // what the ask opened). A frame the source merges meanwhile joins the session the install reads under the lock.
7197
+ const edge = await awaitWrunInstallGestureEdge(runTarget, reason);
6574
7198
  const replay = reason === 'replay' ? wrunReplayRunPlanOf(chartIndex, indicatorId) : undefined;
6575
7199
  if (reason === 'replay' && replay === undefined) {
6576
7200
  throw new WrunChartGoneError(`wrun overlay '${indicatorId}' was superseded (no replay lane)`);
@@ -6606,17 +7230,12 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6606
7230
  wrunReadsMarketFacts(delivered) ? wrunCloudFactsMarket(chartMetadata) : undefined);
6607
7231
  const chartNames = await resolveWrunChartNames(chartIndex);
6608
7232
  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);
7233
+ // The chart store the write boundary's checks read in the turn's own task, loaded before the turn.
7234
+ const readChartMetadata = await wrunChartMetadataReaderFor(chartIndex);
7235
+ const readOverlayPaused = await wrunOverlayPausedReaderFor(chartIndex, indicatorId);
6617
7236
  const outputRows = wrunOutputRowsOfBatch(batch);
6618
7237
  assertWrunRunMayPaint(chartIndex, indicatorId, replay);
6619
- if (await isWrunOverlayPaused(chartIndex, indicatorId))
7238
+ if (readOverlayPaused())
6620
7239
  throw new WrunOverlayPausedError('paused');
6621
7240
  // The cloud's OPRA mark (contract opra-server-lanes 10b, wrun-cloud-opra-stamp.util): a result whose run reads
6622
7241
  // OPRA is stamped through the run's own provenance writer before any row of the batch lands, read back off the
@@ -6631,9 +7250,27 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6631
7250
  // The cloud read OPRA for these rows (its mark): the run's console provenance from here (`computed.opra`).
6632
7251
  if (batch.opra === true)
6633
7252
  computed.opra = true;
7253
+ // The write boundary (WRUN-PANBACK-2 S1), as on the browser lane: the chart's install turn after the last await,
7254
+ // the gesture read again (a drag that started while the turn waited holds the batch again while the episode's
7255
+ // ceiling lasts), then the commit checks and the titan write with no await between them.
7256
+ const { heldMs, pacedMs } = await awaitWrunInstallWriteTurn(runTarget, reason, edge);
7257
+ const identityLeft = wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity, readChartMetadata);
7258
+ const settingsStale = kScriptSettingsRevision(meta.settings) !== computed.generation;
7259
+ // The sheet and the params as the overlay's settings read NOW (a paint-only save restyled the
7260
+ // mounted outputs in place while the source answered).
7261
+ const sheetNow = wrunSheetWithSettings(delivered, meta.settings);
7262
+ const paramValues = wrunParamValuesFromSettings(sheetNow, meta.settings, hostFill);
7263
+ // What the source computed: the version and the params of the settings it ran with.
7264
+ const computeIdentity = wrunSourceComputeIdentityOf(sheetNow, ask.computedWith, hostFill, chartInterval);
7265
+ assertWrunRunMayPaint(chartIndex, indicatorId, replay);
7266
+ if (readOverlayPaused())
7267
+ throw new WrunOverlayPausedError('paused');
6634
7268
  const heldContext = getWrunOverlayLiveContext(indicatorId);
6635
7269
  const window = runTarget.window;
6636
7270
  nextWrunCanvasRunSerial(indicatorId);
7271
+ // A batch still the overlay's own reaches the route's write (a superseded one skips it below).
7272
+ if (!identityLeft && !settingsStale)
7273
+ ringWrunInstallApplied(chartIndex, indicatorId, reason, heldMs, pacedMs);
6637
7274
  const integration = integrateWrunRunThroughRoute({
6638
7275
  tc,
6639
7276
  meta,
@@ -6641,6 +7278,8 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6641
7278
  indicatorId,
6642
7279
  metadata: sheetNow,
6643
7280
  outputRows,
7281
+ // What the batch was computed for, as on the browser lane (the session installs the same identity).
7282
+ pictureIdentity: wrunPictureIdentityOf({ settingsRevision: computed.generation, marketIdentity }),
6644
7283
  params: paramValues,
6645
7284
  title: runTarget.title,
6646
7285
  position: runTarget.position,
@@ -6712,9 +7351,23 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6712
7351
  : undefined);
6713
7352
  await publishWrunStrategyRunResult(chartIndex, indicatorId, runResult, { tc, meta });
6714
7353
  await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows, wrunRunOutputProvenance(computed));
6715
- const draft = isWrunDraftOverlaySettings(meta.settings);
7354
+ // An app layer is read as a viewer reads it (wrun-app-layer.leaf), as on the browser lane above.
7355
+ const draft = isWrunDraftOverlaySettings(meta.settings) && !isWrunAppLayerOverlaySettings(meta.settings);
6716
7356
  const { health } = wrunChartRunHealth(sheetNow, meta.settings, outputRows, false, wrunChartSizeUnit(chartMetadata));
6717
7357
  const runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, draft, wrunNothingReadyRefusal(health, refusal.ctx)));
7358
+ // The viewer's nothing-drawn note (FB27), as on the browser lane: a whole window the cloud computed and the chart
7359
+ // shows; this lane asks no warm-up page. It judges the sheet the author declared, never the delivered copy that
7360
+ // left a refused family out: a refused section speaks through its own refusal, and the rows cannot show it.
7361
+ if (integration.applied || (route.action === 'skip' && route.reason === 'render-equal')) {
7362
+ await publishWrunNothingDrawn(chartIndex, indicatorId, {
7363
+ draft,
7364
+ settled: window?.partial !== true,
7365
+ metadata: wrunSheetWithSettings(batch.sheet ?? runTarget.metadata, meta.settings),
7366
+ rows: outputRows,
7367
+ drawings: wrunHandlesOf(outputRows)?.length,
7368
+ runIntervalMs: chartIntervalMs,
7369
+ }, () => refusal.ctx, { isCurrent: () => isWrunRunMountOnChart(chartIndex, { tc, meta }) });
7370
+ }
6718
7371
  // A run computed elsewhere served every leg it read: no leg note of an earlier run stands, no pin note this
6719
7372
  // lane respelled (the cloud resolves its own pins), and no row budget cut of a browser read.
6720
7373
  await publishWrunUnservedLegDiagnostics(chartIndex, indicatorId, []);
@@ -7042,17 +7695,26 @@ function wrunWarmupEvidenceOutputs(runResult) {
7042
7695
  * warm-up end that many evaluated rows into the run's window, read beside the outputs' own (the
7043
7696
  * later wins; a drawings-only sheet has only it), so the decider asks for the history the
7044
7697
  * 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
7698
+ * `declaredWarmupBars`). It is never the declared lookback; an empty run over rows that hold the
7699
+ * declaration and its slack buys no page (`declaredWarmupCovered`), and an undeclared one keeps its
7700
+ * probe pages (QA 235). A proven twin keeps its built-in's lookback and never reads its
7047
7701
  * 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).
7702
+ * built-in's history cost). Only a source still landing holds a result with values: its degrade
7703
+ * entry pending, or degraded with its ladder not terminal (warmupSourceEntryLanding), and the ask held
7704
+ * on one asks again once none is (holdWrunWarmupAskOnLanding). Where every lane and leg begins, as a
7705
+ * declaration or an every-bar answer names it (wrunRunSourceReachFromMs), explains a first value no page can move.
7049
7706
  * The ask lands where the kScript lane's lands: at the end of a gesture the run integrated under
7050
7707
  * (askWrunWarmupAtGestureEnd).
7051
7708
  */
7052
7709
  function askWrunWarmupBackfillIfOwed(args) {
7053
7710
  const { chartIndex, indicatorId, tc, meta, runResult, unsettledLanes } = args;
7054
- if (args.run !== null || isWrunWindowOwner(meta))
7711
+ const guardKey = overlayExecutionGuardKey(chartIndex, indicatorId);
7712
+ // This result supersedes any older one held on its sources.
7713
+ wrunWarmupAsksOnLanding.delete(guardKey);
7714
+ if (args.run !== null || isWrunWindowOwner(meta)) {
7715
+ args.onNoPage?.();
7055
7716
  return;
7717
+ }
7056
7718
  const text = (value) => (typeof value === 'string' ? value : undefined);
7057
7719
  const ringDetails = { lane: 'wrun' };
7058
7720
  if (unsettledLanes.size > 0)
@@ -7064,6 +7726,12 @@ function askWrunWarmupBackfillIfOwed(args) {
7064
7726
  ringDetails.declaredWarmupBars = declaredWarmupBars;
7065
7727
  if (declaredWarmupBars !== null && creditedBars > 0)
7066
7728
  ringDetails.warmupHeadCredit = creditedBars;
7729
+ // A declaration is trusted: rows that hold it and a bucket of slack and print nothing buy no page.
7730
+ const declaredWarmupCovered = declaredWarmupBars === null
7731
+ ? null
7732
+ : wrunDeclaredWarmupCovered(runRows, declaredWarmupBars, LOCAL_KSCRIPT_WARMUP_DECLARED_SLACK_BARS, creditedBars);
7733
+ if (declaredWarmupCovered !== null)
7734
+ ringDetails.declaredWarmupCovered = declaredWarmupCovered;
7067
7735
  // The result is the chart's only while the engine and the data generation the run read its
7068
7736
  // window under still stand. Checked before the ask, before each gesture retry, and again when
7069
7737
  // the lazily loaded loader is about to dispatch: a switch or a refetch can land while the
@@ -7071,32 +7739,126 @@ function askWrunWarmupBackfillIfOwed(args) {
7071
7739
  const isCurrent = () => wrunChartHostEnv().chart.instance(chartIndex) === tc &&
7072
7740
  getChartDataFetchGeneration(chartIndex) === args.planGeneration;
7073
7741
  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
7742
  // A wait outlives nothing: the overlay must still be the one this result painted when it ends.
7098
7743
  const isStillMounted = () => isWrunRunMountOnChart(chartIndex, { tc, meta });
7099
- askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, () => isCurrent() && isStillMounted(), ringDetails);
7744
+ const isAskCurrent = () => isCurrent() && isStillMounted();
7745
+ // Read at each ask: the ladder may turn a source terminal after this run settled.
7746
+ let landingAtAsk = [];
7747
+ const ask = () => {
7748
+ const outcome = wrunChartHostEnv().chart.askWarmupBackfill({
7749
+ chartIndex,
7750
+ indicatorId,
7751
+ tc,
7752
+ chartMeta: {
7753
+ exchange: text(args.chartMetadata?.exchange),
7754
+ symbol: text(args.chartMetadata?.symbol),
7755
+ interval: args.chartInterval,
7756
+ },
7757
+ readEvidence: () => {
7758
+ landingAtAsk = wrunWarmupLandingSources(guardKey);
7759
+ return {
7760
+ outputs: wrunWarmupEvidenceOutputs(runResult),
7761
+ lookbackBars,
7762
+ sourcesSettled: unsettledLanes.size === 0,
7763
+ sourcesLanding: landingAtAsk.length > 0,
7764
+ declaredWarmupCovered,
7765
+ runWindowStartTs: args.runWindowStartTs,
7766
+ declaredWarmupEndTs: declaredWarmupBars === null
7767
+ ? null
7768
+ : wrunDeclaredWarmupEndTs(runRows, declaredWarmupBars, intervalMs, creditedBars),
7769
+ sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: serverNowMs() }),
7770
+ };
7771
+ },
7772
+ requestOlderHistory: wrunWarmupPageRequester(chartIndex, indicatorId, tc, isCurrent, ringDetails),
7773
+ ringDetails,
7774
+ isCurrent,
7775
+ });
7776
+ // A host port may answer nothing at all (undefined), as the line below already reads it: both mean no decision.
7777
+ if (outcome != null && !outcome.requested && !WRUN_WARMUP_UNDECIDED_REASONS.has(outcome.reason)) {
7778
+ args.onNoPage?.();
7779
+ }
7780
+ if (outcome?.reason !== 'sources-pending' || landingAtAsk.length === 0)
7781
+ return;
7782
+ holdWrunWarmupAskOnLanding(guardKey, () => {
7783
+ if (isAskCurrent())
7784
+ askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, isAskCurrent, ringDetails);
7785
+ });
7786
+ wrunChartHostEnv().diagnostics.debug('local-kscript-warmup-backfill-held-for-sources', {
7787
+ chartIndex,
7788
+ indicatorId,
7789
+ ...ringDetails,
7790
+ landingSources: landingAtAsk,
7791
+ });
7792
+ };
7793
+ askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, isAskCurrent, ringDetails);
7794
+ }
7795
+ /** The decider's answers that buy no page yet decide nothing for the result: a source still landing (held, asked
7796
+ * again once it lands), a page of an earlier ask still in flight (its landing reruns the overlay), a view still moving
7797
+ * (the shared ask re-asks a few times). */
7798
+ const WRUN_WARMUP_UNDECIDED_REASONS = new Set([
7799
+ 'sources-pending',
7800
+ 'page-pending',
7801
+ 'gesture-active',
7802
+ ]);
7803
+ export function wrunWarmupPageVerdict() {
7804
+ let decided = false;
7805
+ let held;
7806
+ return {
7807
+ noPage: () => {
7808
+ if (decided)
7809
+ return;
7810
+ decided = true;
7811
+ const raise = held;
7812
+ held = undefined;
7813
+ raise?.();
7814
+ },
7815
+ whenNoPage: (raise) => {
7816
+ if (decided)
7817
+ raise();
7818
+ else
7819
+ held = raise;
7820
+ },
7821
+ };
7822
+ }
7823
+ /** The overlay's sources still landing in the degrade registry (`warmupSourceEntryLanding`), by name. */
7824
+ function wrunWarmupLandingSources(guardKey) {
7825
+ try {
7826
+ return wrunChartHostEnv()
7827
+ .chart.sourceDegradeEntries(guardKey)
7828
+ .filter(warmupSourceEntryLanding)
7829
+ .map((entry) => entry.sourceName);
7830
+ }
7831
+ catch {
7832
+ // A registry without the read door (a partial module mock): nothing reads as landing.
7833
+ return [];
7834
+ }
7835
+ }
7836
+ /**
7837
+ * The newest warm-up ask of each overlay held on a source still landing, by guard key: asked again once the degrade
7838
+ * registry shows none landing (a rung landed it, or the ladder gave it up), outside any run of the overlay, since a run
7839
+ * asks for itself. The ladder's last rung turns its sources terminal after its run settles, so without this the page a
7840
+ * visible warm-up owes is never bought.
7841
+ */
7842
+ const wrunWarmupAsksOnLanding = new Map();
7843
+ function holdWrunWarmupAskOnLanding(guardKey, reask) {
7844
+ wrunWarmupAsksOnLanding.set(guardKey, reask);
7845
+ try {
7846
+ wrunChartHostEnv().chart.onSourceDegradeChange(wrunWarmupLandingListener);
7847
+ }
7848
+ catch {
7849
+ // A registry without the listener door (a partial module mock): the overlay's next run asks again.
7850
+ }
7851
+ }
7852
+ /** The degrade registry's change listener for held warm-up asks (one stable function: re-subscribing is a no-op). */
7853
+ function wrunWarmupLandingListener(guardKey) {
7854
+ const reask = wrunWarmupAsksOnLanding.get(guardKey);
7855
+ if (reask === undefined || wrunRefusalRunsInFlight.has(guardKey))
7856
+ return;
7857
+ if (wrunWarmupLandingSources(guardKey).length > 0)
7858
+ return;
7859
+ wrunWarmupAsksOnLanding.delete(guardKey);
7860
+ // A registry reset (a teardown, a chart reset) leaves no entry: the reask's own checks see the overlay gone.
7861
+ setTimeout(reask, 0);
7100
7862
  }
7101
7863
  /**
7102
7864
  * The newest warm-up ask of each overlay that is waiting for a gesture to end: a full run that
@@ -7149,6 +7911,213 @@ function askWrunWarmupAtGestureEnd(chartIndex, indicatorId, ask, isCurrent, ring
7149
7911
  ask();
7150
7912
  });
7151
7913
  }
7914
+ /**
7915
+ * The run reasons whose result waits for the gesture's idle edge before its commit checks and its install
7916
+ * (WRUN-PANBACK A1): the chart's own reruns (a live rebuild, a pan page, a range refresh, a heal, a source-recovery
7917
+ * rung, a budget lift). The deleted kScript engine held such a result until the idle edge (its worker's
7918
+ * `releaseHeldEngine`, at most KSCRIPT_GESTURE_HOLD_MAX_MS); a wrun install landed mid-drag instead (a 294 ms apply
7919
+ * 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
7920
+ * Retry), the mount's first run and the replay lane's never wait.
7921
+ */
7922
+ export const WRUN_GESTURE_HELD_RUN_REASONS = new Set([
7923
+ 'live-rebuild',
7924
+ 'lazy-range-refresh',
7925
+ 'loaded-range-refresh',
7926
+ 'history-range',
7927
+ 'heal',
7928
+ 'source-recovery',
7929
+ 'budget-lift',
7930
+ ]);
7931
+ /** How often a held install looks for a queued user run while it waits: the pan idle wait's own poll. */
7932
+ const WRUN_INSTALL_GESTURE_POLL_MS = 120;
7933
+ /**
7934
+ * Hold a finished run's install until the gesture's idle edge (WRUN-PANBACK A1), the way the warm-up ask waits
7935
+ * (`askWrunWarmupAtGestureEnd`): at once (`none`) for a reason that is not held or a chart whose gesture is not live;
7936
+ * else until the view stays still for GESTURE_LINGER_MS (`waitPanIdle`), bounded by `ceilingMs` (what the episode has
7937
+ * left of its one ceiling), and raced every WRUN_INSTALL_GESTURE_POLL_MS against a queued user run
7938
+ * (`hasQueuedWrunUserRun`): the run that follows replaces this result, so it yields (`yielded`) instead of making that
7939
+ * 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
7940
+ * within one poll of the bound reads `ceiling`. `waitedMs` is on the pacing clock. Rings the hold and its end; never
7941
+ * throws.
7942
+ */
7943
+ export async function holdWrunInstallForGesture(chartIndex, indicatorId, reason, { ceilingMs }) {
7944
+ const env = wrunChartHostEnv();
7945
+ if (!WRUN_GESTURE_HELD_RUN_REASONS.has(reason) || !env.chart.isGestureLive(chartIndex)) {
7946
+ return { waitedMs: 0, outcome: 'none' };
7947
+ }
7948
+ env.diagnostics.debug('wrun-install-held-for-gesture', { chartIndex, indicatorId, reason, ceilingMs });
7949
+ const startedAt = wrunHostClockMs();
7950
+ let poll;
7951
+ const yielded = new Promise((resolve) => {
7952
+ // Read from a timer: a queue that cannot be read (a spec's partial mock) holds no user run.
7953
+ const look = () => {
7954
+ if (readOptionalExport(() => hasQueuedWrunUserRun(indicatorId)) === true)
7955
+ resolve('yielded');
7956
+ else
7957
+ poll = setTimeout(look, WRUN_INSTALL_GESTURE_POLL_MS);
7958
+ };
7959
+ look();
7960
+ });
7961
+ const idle = env.chart
7962
+ .waitPanIdle(chartIndex, { idleMs: GESTURE_LINGER_MS, maxWaitMs: ceilingMs })
7963
+ // A wait that fails holds the install no longer: it reads as the bound.
7964
+ .catch(() => ceilingMs);
7965
+ const ended = await Promise.race([idle, yielded]);
7966
+ if (poll !== undefined)
7967
+ clearTimeout(poll);
7968
+ const outcome = ended === 'yielded' ? 'yielded' : ended >= ceilingMs - WRUN_INSTALL_GESTURE_POLL_MS ? 'ceiling' : 'idle';
7969
+ const waitedMs = Math.max(0, wrunHostClockMs() - startedAt);
7970
+ env.diagnostics.debug('wrun-install-gesture-ended', { chartIndex, indicatorId, reason, waitedMs, outcome });
7971
+ return { waitedMs, outcome };
7972
+ }
7973
+ /** The install hold's budget (WRUN-PANBACK A1, one ceiling per rebuild episode): HEAVY_APPLY_GESTURE_CEILING_MS less
7974
+ * what the episode already held (`gestureHeldMs`: the live tick's settle gate, a prefix page's own hold), never below
7975
+ * zero. A run without the field holds up to the full ceiling. */
7976
+ function wrunInstallGestureCeilingMs(gestureHeldMs) {
7977
+ const held = gestureHeldMs !== undefined && Number.isFinite(gestureHeldMs) ? Math.max(0, gestureHeldMs) : 0;
7978
+ return Math.max(0, HEAVY_APPLY_GESTURE_CEILING_MS - held);
7979
+ }
7980
+ /**
7981
+ * A whole run's result at the gesture's idle edge (`holdWrunInstallForGesture` under the run's own budget), held before
7982
+ * the integrate reads anything. Answers how long it held and how the hold ended (the write boundary,
7983
+ * `awaitWrunInstallWriteTurn`, holds no more after one that ran to its ceiling). A user run queued meanwhile supersedes
7984
+ * the result: it is dropped with the quiet superseded rejection (no titan write, no stand-in, no live context; the
7985
+ * caller releases what the run's ask opened) and the executor's follow-up runs the queued one.
7986
+ */
7987
+ async function awaitWrunInstallGestureEdge(target, reason) {
7988
+ const { chartIndex, indicatorId } = target;
7989
+ const hold = await holdWrunInstallForGesture(chartIndex, indicatorId, reason, {
7990
+ ceilingMs: wrunInstallGestureCeilingMs(target.gestureHeldMs),
7991
+ });
7992
+ if (hold.outcome === 'yielded') {
7993
+ wrunChartHostEnv().diagnostics.debug('wrun-install-yielded', { chartIndex, indicatorId, reason });
7994
+ throw new WrunChartGoneError(`wrun overlay '${indicatorId}' yielded its result to a queued user run (superseded)`);
7995
+ }
7996
+ return hold;
7997
+ }
7998
+ /**
7999
+ * The install's write boundary (WRUN-PANBACK-2 S1), after every await of its preparation: the chart's install turn
8000
+ * (`admitWrunInstall`), then the gesture read again. A held reason whose gesture went live while the turn waited holds
8001
+ * again (the bounded hold, on what the episode's ceiling has left after its holds and its turns) and takes a fresh turn
8002
+ * after it, while that budget lasts; with the budget spent (by the clock, or by a hold that ran to its ceiling: the idle
8003
+ * wait's own word) it writes, gesture or not. A user run queued meanwhile supersedes the result (`wrun-install-yielded`,
8004
+ * the quiet superseded rejection). Answers what the install held and was paced in all, `heldMs` counting the hold at
8005
+ * the idle edge (`edge`) too. The caller's current-state checks and its titan write follow with no await, so the write
8006
+ * lands in the task that took the turn.
8007
+ */
8008
+ async function awaitWrunInstallWriteTurn(target, reason, edge) {
8009
+ const { chartIndex, indicatorId } = target;
8010
+ const ceilingMs = wrunInstallGestureCeilingMs(target.gestureHeldMs);
8011
+ let heldMs = edge.waitedMs;
8012
+ let pacedMs = 0;
8013
+ let spent = edge.outcome === 'ceiling';
8014
+ for (;;) {
8015
+ pacedMs += (await admitWrunInstall(chartIndex, indicatorId, reason)).waitedMs;
8016
+ const budgetMs = ceilingMs - heldMs - pacedMs;
8017
+ if (spent ||
8018
+ !WRUN_GESTURE_HELD_RUN_REASONS.has(reason) ||
8019
+ budgetMs <= 0 ||
8020
+ !wrunChartHostEnv().chart.isGestureLive(chartIndex)) {
8021
+ return { heldMs, pacedMs };
8022
+ }
8023
+ const hold = await holdWrunInstallForGesture(chartIndex, indicatorId, reason, { ceilingMs: budgetMs });
8024
+ heldMs += hold.waitedMs;
8025
+ if (hold.outcome === 'yielded') {
8026
+ wrunChartHostEnv().diagnostics.debug('wrun-install-yielded', { chartIndex, indicatorId, reason });
8027
+ throw new WrunChartGoneError(`wrun overlay '${indicatorId}' yielded its result to a queued user run (superseded)`);
8028
+ }
8029
+ // A hold that waited nothing (the gesture ended before it began) leaves the turn just taken current.
8030
+ if (hold.outcome === 'none')
8031
+ return { heldMs, pacedMs };
8032
+ spent = hold.outcome === 'ceiling';
8033
+ }
8034
+ }
8035
+ /** A reader of the overlay's pause (`isWrunOverlayPaused`'s read) that answers in the caller's task: the store is loaded
8036
+ * once here, so an install's write boundary reads it with no await before its titan write. A store that cannot be read
8037
+ * reads as not paused. */
8038
+ async function wrunOverlayPausedReaderFor(chartIndex, indicatorId) {
8039
+ try {
8040
+ const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
8041
+ return () => {
8042
+ try {
8043
+ return useChartStore().isKScriptOverlayPaused(chartIndex, indicatorId) === true;
8044
+ }
8045
+ catch {
8046
+ return false;
8047
+ }
8048
+ };
8049
+ }
8050
+ catch {
8051
+ return () => false;
8052
+ }
8053
+ }
8054
+ /** The ring right before an install's titan write (WRUN-PANBACK A1): whether the gesture is live as the result lands,
8055
+ * how long its install held for it, and how long the install pacer held it after (`pacedMs`, WRUN-PANBACK-2 S1; 0
8056
+ * when it went at once). */
8057
+ function ringWrunInstallApplied(chartIndex, indicatorId, reason, heldMs, pacedMs) {
8058
+ wrunChartHostEnv().diagnostics.debug('wrun-install-applied', {
8059
+ chartIndex,
8060
+ indicatorId,
8061
+ reason,
8062
+ gestureLive: wrunChartHostEnv().chart.isGestureLive(chartIndex),
8063
+ heldMs,
8064
+ pacedMs,
8065
+ });
8066
+ }
8067
+ /**
8068
+ * A prefix page's commit at the gesture's idle edge (WRUN-PANBACK A1): the hold runs BEFORE the overlay's session lock
8069
+ * and `commit` runs synchronously at the lock's grant, so the commit stays one synchronous transaction. The lock can
8070
+ * wait on an async holder (a live block holds it across a worker call), so the gesture may start again between the
8071
+ * hold and the grant: a live gesture at the grant with budget left (`ceilingMs` less what the page held and was paced)
8072
+ * lets the lock go and the page waits again outside it; with the budget spent it commits. A user run queued meanwhile
8073
+ * yields: nothing commits. Each hold that did not yield takes the chart's install turn (`admitWrunInstall`,
8074
+ * 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
8075
+ * long after the turn, so at the grant the page writes on it only while no other install of the chart was admitted
8076
+ * since (`wrunInstallLastAdmission`), else it lets the lock go and takes a fresh turn (while the budget lasts), and it
8077
+ * notes its write (`noteWrunInstallWrite`) so the chart's next turn counts its gap from the commit. `commit` receives how
8078
+ * long the page held and how long the pacer held it.
8079
+ */
8080
+ export async function commitWrunPrefixAtGestureEdge(chartIndex, indicatorId, reason, { ceilingMs }, commit) {
8081
+ let heldMs = 0;
8082
+ let pacedMs = 0;
8083
+ let resumes = 0;
8084
+ // A hold that ran to its ceiling spent the budget (the idle wait's own word), whatever the clock says.
8085
+ let spent = false;
8086
+ for (;;) {
8087
+ const hold = await holdWrunInstallForGesture(chartIndex, indicatorId, reason, {
8088
+ ceilingMs: Math.max(0, ceilingMs - heldMs - pacedMs),
8089
+ });
8090
+ heldMs += hold.waitedMs;
8091
+ if (hold.outcome === 'yielded')
8092
+ return { kind: 'yielded', heldMs };
8093
+ if (hold.outcome === 'ceiling')
8094
+ spent = true;
8095
+ pacedMs += (await admitWrunInstall(chartIndex, indicatorId, reason)).waitedMs;
8096
+ // The admission the page's turn stands on (the lock may grant long after it).
8097
+ const turn = wrunInstallLastAdmission(chartIndex);
8098
+ // A page goes back to wait only after its first hold or after a hold that waited: a hold that answered at once
8099
+ // right after the grant saw motion read the gesture otherwise in the same task, and looping on it would spin
8100
+ // without ever yielding to the page.
8101
+ const mayWaitAgain = resumes === 0 || hold.outcome !== 'none';
8102
+ const granted = await withWrunOverlaySessionLock(indicatorId, () => {
8103
+ // Read at the grant, in the same task as the commit, while the budget (its holds and its turns) lasts: motion
8104
+ // that resumed while the lock waited holds the page again, and another install that took the chart's turn
8105
+ // meanwhile sends the page to a fresh turn, both outside the lock.
8106
+ const budgetLeft = !spent && heldMs + pacedMs < ceilingMs;
8107
+ const gestureResumed = mayWaitAgain &&
8108
+ WRUN_GESTURE_HELD_RUN_REASONS.has(reason) &&
8109
+ wrunChartHostEnv().chart.isGestureLive(chartIndex);
8110
+ if (budgetLeft && (gestureResumed || wrunInstallLastAdmission(chartIndex) !== turn))
8111
+ return { resumed: true };
8112
+ // The write lands now, after the turn: the chart's next turn counts its gap from here.
8113
+ noteWrunInstallWrite(chartIndex);
8114
+ return { resumed: false, value: commit(heldMs, pacedMs) };
8115
+ });
8116
+ if (!granted.resumed)
8117
+ return { kind: 'committed', value: granted.value, heldMs };
8118
+ resumes += 1;
8119
+ }
8120
+ }
7152
8121
  /**
7153
8122
  * The page dispatch of the wrun lane's warm-up asks. The lazy loader is reached lazily:
7154
8123
  * data-fetching.util's graph pulls in the live feed and, through it, this lane (see the ask's module
@@ -7332,14 +8301,16 @@ function wrunRunOwnerLeft(owner, chartMetadata, marketIdentity) {
7332
8301
  }
7333
8302
  /** Whether the chart moved off what a run computed for while it ran: the
7334
8303
  * 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) {
8304
+ * market or interval on the main series. Read in the caller's task: the
8305
+ * market through a loaded reader (`wrunChartMetadataReaderFor`), so an
8306
+ * install's write boundary judges it with no await before its titan write. */
8307
+ function wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity, readChartMetadata) {
7337
8308
  if (wrunChartHostEnv().chart.instance(chartIndex) !== tc)
7338
8309
  return true;
7339
8310
  const mounted = tc.metadata;
7340
8311
  if (Array.isArray(mounted) && !mounted.includes(meta))
7341
8312
  return true;
7342
- return wrunChartMarketIdentity(await wrunChartMetadataFor(chartIndex)) !== marketIdentity;
8313
+ return wrunChartMarketIdentity(readChartMetadata()) !== marketIdentity;
7343
8314
  }
7344
8315
  /** Replay took the chart while a run computed: its replay lane owns the
7345
8316
  * rows (it blanked the overlay and reopens it over the replay's bars; the
@@ -7446,7 +8417,11 @@ export function wrunReplayRunBars(runBars, chartRows, cutoffTs, run, chartInterv
7446
8417
  * (pinForThisSession falls back to an older official while the row keeps the
7447
8418
  * newer pin) would store that version's picture under the pin's key, so it
7448
8419
  * 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
8420
+ * outcome). Never a run that read CME off a CME chart (`cme-pin`: its own CME
8421
+ * mark, a pinned CME market the judge admitted on a crypto chart, whoever wrote
8422
+ * the run): the store outlives the viewer's CME access, which the run's judge
8423
+ * decides at each run; the stand-in util refuses the overlay's CME stamp alike.
8424
+ * The stand-in util judges the rest (the live edge on the candles
7450
8425
  * and run bar this hands it, a partial picture stored marked, a child overlay
7451
8426
  * never).
7452
8427
  * Advisory: a refusal or a failure stores nothing. Each of the run's own
@@ -7478,6 +8453,8 @@ async function writeWrunStandIn(args) {
7478
8453
  return refuse('window-partial');
7479
8454
  if (args.firstSlice === true)
7480
8455
  return refuse('first-slice');
8456
+ if (args.readsCme === true && !payloadTouchesCmeVenue(args.chartMetadata?.exchange))
8457
+ return refuse('cme-pin');
7481
8458
  if (args.executedVersion !== undefined && args.executedVersion !== identity.version) {
7482
8459
  return refuse('version-mismatch');
7483
8460
  }
@@ -7610,8 +8587,9 @@ function isWrunFormingOpenWire(wire) {
7610
8587
  * to carry, so an empty lane refuses loud); a package whose every funding
7611
8588
  * input declares `missing: "nan"` or `"zero"` reads its fill on markets
7612
8589
  * without funding and the lane stays quiet, like oi. */
7613
- export function wrunFundingLaneRequired(metadata) {
7614
- return wrunLaneRowsRequired(metadata, (_input, source) => source.source === 'funding');
8590
+ export function wrunFundingLaneRequired(metadata, lane) {
8591
+ // One funding lane's readers: the chart's own lane's (no pin), or one pinned lane's (U9e, `lane`).
8592
+ return wrunLaneRowsRequired(metadata, (_input, source) => source.source === 'funding' && wrunPinnedLaneOfSource(source) === lane);
7615
8593
  }
7616
8594
  function wrunInputNameAt(metadata, index) {
7617
8595
  return metadata.inputs.find((input) => input.index === index)?.name ?? String(index);
@@ -7626,6 +8604,44 @@ function wrunEvaluatedMainTail(ohlcvRows) {
7626
8604
  tail.push(Array.from(ohlcvRows[at]));
7627
8605
  return tail;
7628
8606
  }
8607
+ /** The leg records the live tick writes by key (its leg answer merge and its live candle refresh). */
8608
+ const WRUN_KEYED_LEG_SOURCES = ['pinnedCandleRows', 'pinnedLiveCandleRows', 'intrabarRows'];
8609
+ /** A combined build's carry with what it read (above), taken in the build's own synchronous block. */
8610
+ function wrunCarryAtBuildOf(built, ohlcvRows, sources) {
8611
+ if (built === undefined)
8612
+ return undefined;
8613
+ const legBuffers = WRUN_KEYED_LEG_SOURCES.flatMap((field) => {
8614
+ const record = sources[field];
8615
+ return record === undefined ? [] : [[record, Object.entries(record)]];
8616
+ });
8617
+ return { carry: built.carry, mainTail: wrunEvaluatedMainTail(ohlcvRows), legBuffers };
8618
+ }
8619
+ /**
8620
+ * The carry built with the rows, while nothing it rests on moved since the build: every closed candle of the
8621
+ * evaluated tail reads the same under the drain's comparison (`wrunCandleEqual`, the same stamps), and every leg
8622
+ * record holds the arrays it held. Else undefined: the install advances the carry from the empty seed over the
8623
+ * sources as the awaits left them, the two steps exactly, and the drain's next comparison starts from the same rows.
8624
+ */
8625
+ function wrunCarryAtBuildStill(atBuild, ohlcvRows) {
8626
+ if (atBuild === undefined)
8627
+ return undefined;
8628
+ const tail = wrunEvaluatedMainTail(ohlcvRows);
8629
+ if (tail.length !== atBuild.mainTail.length)
8630
+ return undefined;
8631
+ for (let at = 0; at < tail.length; at += 1) {
8632
+ const built = atBuild.mainTail[at];
8633
+ if (tail[at][0] !== built[0] || !wrunCandleEqual(built, tail[at]))
8634
+ return undefined;
8635
+ }
8636
+ for (const [record, entries] of atBuild.legBuffers) {
8637
+ if (Object.keys(record).length !== entries.length)
8638
+ return undefined;
8639
+ for (const [key, rows] of entries)
8640
+ if (record[key] !== rows)
8641
+ return undefined;
8642
+ }
8643
+ return atBuild.carry;
8644
+ }
7629
8645
  /** The volume-profile block size the history lane computed on: the metadata
7630
8646
  * block size for the chart's market, resolved through the same service
7631
8647
  * K_VOLUME_PROFILE's getReqPayload resolves it (its private
@@ -7898,8 +8914,14 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7898
8914
  });
7899
8915
  }
7900
8916
  // 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() };
8917
+ // buffers (a candle that closed since the last build is admitted by it), each
8918
+ // declared depth still counted back from the session's as-of (its first run's
8919
+ // now, wrun-history-as-of.util), so the rebuilt rows keep the blocks they had.
8920
+ const clock = {
8921
+ intervalMs: context.intervalMs,
8922
+ nowMs: serverNowMs(),
8923
+ historyAsOfMs: context.historyAsOfMs,
8924
+ };
7903
8925
  const sourceRows = {
7904
8926
  ohlcvRows,
7905
8927
  bookRows: context.bookRows,
@@ -7923,6 +8945,8 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7923
8945
  tradeLegRows: context.tradeLegRows,
7924
8946
  // Each trades leg's rows ride the tier its acquisition names (the full run's ask, the intake's fold).
7925
8947
  tradeLegIntervals: wrunTradeLegIntervals(context.acquisition),
8948
+ // The pinned lanes (U9e): each foreign ask reads the lane of its market.
8949
+ pinnedLaneRows: context.pinnedLaneRows,
7926
8950
  pinnedCandleRows: context.pinnedCandleRows,
7927
8951
  // Each grid leg asked at a tier rides it (the full run's records).
7928
8952
  pinnedLegTierMs: wrunPinnedLegTierMs(context.pinnedLegs),
@@ -7972,8 +8996,24 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7972
8996
  delete context.laneWarmupHead;
7973
8997
  const headRows = reseedHead?.rows ?? laneReseedHead;
7974
8998
  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);
8999
+ // The host session's composition, as the full run reads it (wrun-session-composition.util): the reseed rebuilds
9000
+ // over the buffers composed as the session stands now, so an owner change since the run lands on every bar.
9001
+ const composition = composeWrunSessionSources({
9002
+ chartIndex: context.chartIndex,
9003
+ indicatorId,
9004
+ intervalMs: clock.intervalMs,
9005
+ lanes: wrunSessionLanesOfContext(context),
9006
+ }, computeOhlcvRows === ohlcvRows ? sourceRows : { ...sourceRows, ohlcvRows: computeOhlcvRows });
9007
+ const computeSourceRows = composition.sources;
9008
+ // On the host's `carryWithBuild` (web: the engine arm `webkit-wrun-carry-with-build`) the rows and the carry the
9009
+ // session takes below come from one conversion of the window's lanes, here: the carry then rests on the buffers as
9010
+ // they stand here, as the outputs and the lane revisions read below do. Else the carry is advanced after the
9011
+ // worker answered, from the empty seed, converting the window again.
9012
+ const builtWithCarry = wrunHostCarryWithBuild()
9013
+ ? buildWrunInputRowsAndCarry(context.metadata, computeSourceRows, clock)
9014
+ : undefined;
9015
+ const carryAtBuild = wrunCarryAtBuildOf(builtWithCarry, ohlcvRows, computeSourceRows);
9016
+ const rows = builtWithCarry?.rows ?? buildWrunInputRows(context.metadata, computeSourceRows, clock);
7977
9017
  if (rows.length === 0)
7978
9018
  return 'skipped';
7979
9019
  // The lane revisions these rows already read (wrun-prefix-lanes.util): once the outputs are committed below they
@@ -7990,6 +9030,8 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7990
9030
  // under the previous one still belong to these buffers.
7991
9031
  const generation = nextWrunOverlayLiveGeneration(indicatorId);
7992
9032
  context.generation = generation;
9033
+ // The reopen below opens the worker's series under it.
9034
+ context.seriesEpoch = generation;
7993
9035
  adoptWrunLiveIntakeGeneration(indicatorId, generation);
7994
9036
  // The chart names this session's text will read, resolved beside the
7995
9037
  // reopen and awaited BEFORE the post-start rechecks below (a context the
@@ -8087,7 +9129,12 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8087
9129
  }
8088
9130
  else
8089
9131
  delete context.retained;
8090
- context.carrySeed = advanceWrunInputCarry(context.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock);
9132
+ // The built carry while nothing it read moved during the awaits (a closed candle folded in place, a leg answer
9133
+ // merged), else the advance over the sources as they stand now, as without the switch (counted under `recovered`):
9134
+ // the evaluated tail below reads them now too.
9135
+ context.carrySeed =
9136
+ wrunCarryAtBuildStill(carryAtBuild, ohlcvRows) ??
9137
+ advanceWrunInputCarry(context.metadata, emptyWrunInputCarry(), rows.slice(0, -1), computeSourceRows, clock, carryAtBuild === undefined ? 'advance' : 'recovered');
8091
9138
  // The reopened guest's evidence and warmth (D2, D4), an exact warm-up session's alone: every candle it
8092
9139
  // evaluated, the head included, when it ran the head; a cold reopen drops all three (the head no longer
8093
9140
  // precedes what the session landed, and its rows rest on no running start).
@@ -8108,11 +9155,19 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8108
9155
  delete context.warmupHead;
8109
9156
  delete context.candleEvidence;
8110
9157
  }
8111
- context.dirtyFromTs = null;
9158
+ // Every bar was evaluated again from the buffers, so nothing is owed: unless the host's session changed owner
9159
+ // while the session reopened, whose revision (reviseWrunOverlayLiveFrom, from the old seam) these rows never
9160
+ // read. It stays owed, and the drain keeps its closed-bar revision (it clears only what this left null).
9161
+ if (wrunReseedServedComposition(indicatorId, context, composition.token))
9162
+ context.dirtyFromTs = null;
8112
9163
  context.evaluatedMainTail = wrunEvaluatedMainTail(ohlcvRows);
8113
9164
  if (runSession)
8114
9165
  runSession.lastSentRow = wrunRunIntervalSentRow(rows[rows.length - 1]);
8115
9166
  rememberWrunSessionChartNames(context, chartNames);
9167
+ // The reopened guest's memory, as its live-start reported it (a warm switch's park counts it).
9168
+ const reopened = wrunWorkerMemoryOf(outputRows).workerMemoryBytes;
9169
+ if (reopened !== undefined)
9170
+ context.workerMemoryBytes = reopened;
8116
9171
  // Exactly one reseed note per reopened session, plus its first snapshot.
8117
9172
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'reseed' });
8118
9173
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'session-start', live: wrunLiveOf(outputRows) });
@@ -8140,6 +9195,8 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8140
9195
  indicatorId,
8141
9196
  metadata: context.metadata,
8142
9197
  outputRows,
9198
+ // The session's own picture: a reseed redraws what the session computed, so a heatmap keeps its scale.
9199
+ pictureIdentity: wrunPictureIdentityOf(context),
8143
9200
  title: context.title,
8144
9201
  position: context.position,
8145
9202
  axis: context.axis,
@@ -8147,7 +9204,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8147
9204
  fills: context.fills,
8148
9205
  candles: context.candles,
8149
9206
  chartNames,
8150
- legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
9207
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, undefined, context.cmeDelayed),
8151
9208
  ...wrunResultMarketUnits(context.market),
8152
9209
  ...(runSession
8153
9210
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
@@ -8195,6 +9252,21 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
8195
9252
  }))
8196
9253
  : null;
8197
9254
  context.runHealthWarned = await publishWrunRunHealth(context.chartIndex, indicatorId, wrunRunHealthRowsFor(health, context.draft === true, nothingReady));
9255
+ // The viewer's nothing-drawn note follows the reseed like the health rows (FB27): the session's whole window,
9256
+ // unless the reseed was clamped to a window of it or the session's run read a source that is absent here.
9257
+ await publishWrunNothingDrawn(context.chartIndex, indicatorId, {
9258
+ draft: context.draft === true,
9259
+ settled: clamped === undefined && wrunSessionSourceAbsent.get(context) !== true,
9260
+ metadata: context.metadata,
9261
+ rows: outputRows,
9262
+ drawings: wrunHandlesOf(outputRows)?.length,
9263
+ runIntervalMs: runSession?.run?.intervalMs ?? context.intervalMs,
9264
+ }, async () => wrunRefusalContextFor({
9265
+ title: context.title,
9266
+ metadata: context.metadata,
9267
+ settings: meta.settings,
9268
+ chartMetadata: await wrunChartMetadataFor(context.chartIndex),
9269
+ }));
8198
9270
  context.paintedThroughTs = lastRowTs;
8199
9271
  context.repaintOwed = false;
8200
9272
  // The session drew its whole window again: an unanswered drop's run deadline (and a surface it already handed
@@ -8239,20 +9311,27 @@ const WRUN_SOURCE_LANE_ORDER = [
8239
9311
  * with a thunk, then the trades leg lanes and the registry poll lane instances by their ids. */
8240
9312
  function wrunDispatchedLaneIds(thunks) {
8241
9313
  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 ?? [])]) {
9314
+ for (const [lane] of [
9315
+ ...(thunks.tradeLegs ?? []),
9316
+ ...(thunks.pinnedLanes ?? []),
9317
+ ...(thunks.pollLanes ?? []),
9318
+ ...(thunks.rowLanes ?? []),
9319
+ ]) {
8243
9320
  lanes.add(lane);
8244
9321
  }
8245
9322
  return lanes;
8246
9323
  }
8247
9324
  /** 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. */
9325
+ * pinned lanes, the registry poll lanes and the row lanes. */
8249
9326
  function wrunSourceLaneRank(lane) {
8250
9327
  const builtin = WRUN_SOURCE_LANE_ORDER.indexOf(lane);
8251
9328
  if (builtin >= 0)
8252
9329
  return builtin;
8253
9330
  if (isWrunTradesLegLane(lane))
8254
9331
  return WRUN_SOURCE_LANE_ORDER.length;
8255
- return WRUN_SOURCE_LANE_ORDER.length + (isWrunRowLaneId(lane) ? 2 : 1);
9332
+ if (isWrunPinnedLaneId(lane))
9333
+ return WRUN_SOURCE_LANE_ORDER.length + 1;
9334
+ return WRUN_SOURCE_LANE_ORDER.length + (isWrunRowLaneId(lane) ? 3 : 2);
8256
9335
  }
8257
9336
  /**
8258
9337
  * The lane runs of one run's groups (`scheduleWrunLaneGroups`: the lanes known at the plan, then each group as its
@@ -8263,10 +9342,13 @@ function wrunSourceLaneRank(lane) {
8263
9342
  export function mergeWrunSourceLaneRuns(runs) {
8264
9343
  const merged = { results: {}, outcomes: [], degraded: [] };
8265
9344
  for (const run of runs) {
8266
- const { tradeLegRows, pollLaneRows, rowLaneRows, ...builtin } = run.results;
9345
+ const { tradeLegRows, pinnedLaneRows, pollLaneRows, rowLaneRows, ...builtin } = run.results;
8267
9346
  Object.assign(merged.results, builtin);
8268
9347
  if (tradeLegRows !== undefined)
8269
9348
  merged.results.tradeLegRows = { ...merged.results.tradeLegRows, ...tradeLegRows };
9349
+ if (pinnedLaneRows !== undefined) {
9350
+ merged.results.pinnedLaneRows = { ...merged.results.pinnedLaneRows, ...pinnedLaneRows };
9351
+ }
8270
9352
  if (pollLaneRows !== undefined)
8271
9353
  merged.results.pollLaneRows = { ...merged.results.pollLaneRows, ...pollLaneRows };
8272
9354
  if (rowLaneRows !== undefined)
@@ -8423,7 +9505,13 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
8423
9505
  const run = thunks[lane];
8424
9506
  return typeof run === 'function' ? [[lane, run]] : [];
8425
9507
  });
8426
- const declared = [...builtin, ...(thunks.tradeLegs ?? []), ...(thunks.pollLanes ?? []), ...(thunks.rowLanes ?? [])];
9508
+ const declared = [
9509
+ ...builtin,
9510
+ ...(thunks.tradeLegs ?? []),
9511
+ ...(thunks.pinnedLanes ?? []),
9512
+ ...(thunks.pollLanes ?? []),
9513
+ ...(thunks.rowLanes ?? []),
9514
+ ];
8427
9515
  const filling = new Set();
8428
9516
  const settled = await Promise.allSettled(declared.map(([lane, run]) => {
8429
9517
  const laneBudgetMs = typeof policy.budgetMs === 'function' ? policy.budgetMs(lane) : policy.budgetMs;
@@ -8482,6 +9570,8 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
8482
9570
  run.results[lane] = outcome.rows;
8483
9571
  else if (isWrunTradesLegLane(lane))
8484
9572
  (run.results.tradeLegRows ??= {})[lane] = outcome.rows;
9573
+ else if (isWrunPinnedLaneId(lane))
9574
+ (run.results.pinnedLaneRows ??= {})[lane] = outcome.rows;
8485
9575
  else if (isWrunRowLaneId(lane))
8486
9576
  (run.results.rowLaneRows ??= {})[lane] = outcome.rows;
8487
9577
  else
@@ -8577,6 +9667,12 @@ function wrunLaneSourceOf(lane, pollLanes) {
8577
9667
  const { kType, label } = WRUN_DEGRADABLE_LANE_SOURCES[leg.lane];
8578
9668
  return { kType, label: `${label} on ${leg.exchange} ${leg.symbol}` };
8579
9669
  }
9670
+ // A pinned lane (U9e): its class's lane, labelled with the market it reads.
9671
+ const pinned = wrunPinnedLaneOf(lane);
9672
+ if (pinned !== undefined) {
9673
+ const { kType, label } = WRUN_DEGRADABLE_LANE_SOURCES[pinned.cls];
9674
+ return { kType, label: `${label} on ${pinned.exchange} ${pinned.symbol}` };
9675
+ }
8580
9676
  const instance = pollLanes.find((candidate) => candidate.key === lane);
8581
9677
  // A poll lane instance, or a row lane's (its descriptor names its K type and label the same way).
8582
9678
  const pollLane = instance ? (wrunPollLaneByKey(instance.laneKey) ?? wrunRowLaneByKey(instance.laneKey)) : undefined;
@@ -8595,6 +9691,25 @@ function wrunLaneReadByNanInputsOnly(metadata, lane, pollLanes) {
8595
9691
  return !reads || wrunInputReadsFillOverEmptyLane(input, source);
8596
9692
  });
8597
9693
  }
9694
+ /** The row-builder class a refusal by name says the market does not serve (`nothing-served`), else undefined. */
9695
+ function wrunLaneUnservedClassOf(lane, error) {
9696
+ const code = wrunLaneRefusedCodeOf(error);
9697
+ if (code === undefined || !Object.hasOwn(WRUN_LANE_REFUSALS, code) || WRUN_LANE_REFUSALS[code] !== 'nothing-served') {
9698
+ return undefined;
9699
+ }
9700
+ const cls = wrunPinnedLaneOf(lane)?.cls ?? lane;
9701
+ return WRUN_SOURCE_LANE_ORDER.includes(cls) ? cls : undefined;
9702
+ }
9703
+ /** Whether the run draws over a degraded lane: an unserved one by the capability rule, else the honest picture. */
9704
+ function wrunDegradedLaneDrawable(metadata, lane, outcome, pollLanes) {
9705
+ const unserved = wrunLaneUnservedClassOf(lane, outcome.error);
9706
+ if (unserved === undefined)
9707
+ return wrunLaneReadByNanInputsOnly(metadata, lane, pollLanes);
9708
+ return metadata.inputs.every((input) => {
9709
+ const source = metadata.inputSources[input.name];
9710
+ return wrunSourceLane(source) !== lane || wrunInputDrawsWithoutLane(unserved, input, source);
9711
+ });
9712
+ }
8598
9713
  /** A degraded lane's words: its own sentence (an empty answer's), else the same sentence naming
8599
9714
  * the budget or the failure. The hold's message and the terminal record's details. */
8600
9715
  function wrunLaneDegradeMessage(title, source, outcome) {
@@ -8670,10 +9785,11 @@ function wrunOptionsChainExtrasGoverned(extras) {
8670
9785
  * fetch; two inputs must agree on one chain. The chart's chain and each word's
8671
9786
  * decision are the ones every chain class reads (opra-option-lanes.util
8672
9787
  * `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
9788
+ * `option_surface` lane reads the same venue. `facts` are the run's plane
9789
+ * facts (the wall's door read them): `auto` reads an OPRA chain for an
8675
9790
  * OpenMarket package, and for a run `opraUserScripts` says the
8676
- * `opra-user-scripts` flag opened the plane to. A governed identity carries
9791
+ * `opra-user-scripts` flag opened the plane to; a CME chain by the chain
9792
+ * wall's `mayReadCmeChain`. A governed identity carries
8677
9793
  * the tier the viewer is served now (`governedOptionSummaryTier`, the
8678
9794
  * routing's own rule: the lane's acquisition names it and the legend follows
8679
9795
  * it). Returns the lane's payload extras (`chain*` fields).
@@ -8708,7 +9824,7 @@ function wrunOptionsChainExtrasGoverned(extras) {
8708
9824
  * user script; a pinned crypto word still reads that venue's chain of the
8709
9825
  * coin). Without a decision the chart's own market reads exactly as before.
8710
9826
  */
8711
- async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts, paramValues, options, cmeUserStudy = false) {
9827
+ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, facts, paramValues, options) {
8712
9828
  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
9829
  import('./sources/opra-option-lanes.util.js'),
8714
9830
  wrunChartHostEnv().market.loadDeribitOptions(),
@@ -8748,7 +9864,7 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
8748
9864
  let resolved;
8749
9865
  for (const input of chainInputs) {
8750
9866
  const source = metadata.inputSources[input.name];
8751
- const who = { ...chartMarket, inputName: input.name, official, opraUserScripts, marketLabel };
9867
+ const who = { ...chartMarket, inputName: input.name, ...facts, marketLabel };
8752
9868
  // The ONE venue decision every chain class reads (`decideWrunLaneChainIdentity`), so a package reading
8753
9869
  // `option_surface` beside the chain reads one venue; over another root's chain for an `underlying` root.
8754
9870
  const decision = (await wrunUnderlyingOptionsChainDecision(source, who, metadata.params ?? [], paramValues, chain)) ?? decideWrunLaneChainIdentity({ chain, cryptoVenues, deribitListed: hasDeribitOptions }, source.venue, who);
@@ -8764,13 +9880,12 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
8764
9880
  if (resolved === undefined)
8765
9881
  throw new Error(`WRUN ${metadata.id}: no options_chain input to resolve a chain for`);
8766
9882
  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' });
9883
+ // Every CME identity meets the chain lanes' one CME chain wall by the run's facts, before any fetch.
9884
+ if (identity.venue === 'cme') {
9885
+ assertWrunLaneChainPlaneReadable('cme', identity.exchange, facts, {
9886
+ inputName: resolved.inputName,
9887
+ sourceClass: 'options_chain',
9888
+ });
8774
9889
  }
8775
9890
  const laneInputs = chainInputs.map((input) => ({
8776
9891
  expiries: wrunOptionsChainExpiries(metadata.inputSources[input.name]?.expiries),
@@ -8861,15 +9976,45 @@ async function wrunOpraProvenanceWriter(chartIndex, indicatorId, ownership) {
8861
9976
  return true;
8862
9977
  };
8863
9978
  }
9979
+ /**
9980
+ * The tape provenance of the `stocks` row lanes a sheet declares (governed: 'stocks', the `dark_pool` lane), synced on
9981
+ * the overlay's settings through the host's provenance module (web: titan-charts' per-source tape sync, the one the
9982
+ * chart's fetch door runs for a tape read): each lane, by its lane key, names the tape its planned instance reads, or
9983
+ * none when the plan holds no instance of it. Written only while the run is the overlay's (`isCurrent`); a host that
9984
+ * binds no writer keeps no stamp. A sheet that declares no `stocks` lane loads nothing.
9985
+ */
9986
+ async function syncWrunStocksLaneProvenance(chartIndex, indicatorId, metadata, rowLanes, isCurrent) {
9987
+ const lanes = new Map();
9988
+ for (const input of metadata.inputs) {
9989
+ const lane = wrunRowLaneOfClass(metadata.inputSources[input.name]?.source);
9990
+ if (lane?.governed === 'stocks')
9991
+ lanes.set(lane.laneKey, lane);
9992
+ }
9993
+ if (lanes.size === 0)
9994
+ return;
9995
+ try {
9996
+ const provenance = await wrunChartHostEnv().chart.loadOptionsOverlayProvenance();
9997
+ if (provenance.setOverlayStockTapeProvenance === undefined || !isCurrent())
9998
+ return;
9999
+ for (const lane of lanes.values()) {
10000
+ const instance = rowLanes.find((candidate) => candidate.laneKey === lane.laneKey);
10001
+ provenance.setOverlayStockTapeProvenance(chartIndex, indicatorId, lane.laneKey, instance === undefined ? null : wrunRowLaneStocksTapeOf(lane, instance.extras));
10002
+ }
10003
+ }
10004
+ catch {
10005
+ // The stamp stands until a later run can write it: withholding is the safe direction.
10006
+ }
10007
+ }
8864
10008
  /** A run target whose sheet is the sheet on the chart's market (wrunChartSizeUnit): a lane's
8865
10009
  * `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) {
10010
+ * whose `needed_by` leaves the market's size unit out, or names a setting whose value `settings` do
10011
+ * not list (C-COINS item 1), is not demanded (wrunSheetWithLaneDemand), and neither is a `candles`
10012
+ * lane its `chart_interval_below` gates off on the chart's interval (wrunSheetWithLaneGate, the kit's
10013
+ * rule off the shared host, which the caller loads first; an unknown interval gates nothing). The
10014
+ * target itself when none of them changes the sheet. */
10015
+ function wrunRunTargetOnMarket(target, chartMetadata, settings, coinLegs) {
8871
10016
  const sizeUnit = wrunChartSizeUnit(chartMetadata);
8872
- const metadata = wrunSheetWithLaneGate(wrunSheetWithLaneDemand(wrunSheetWithLaneCurrencies(wrunSheetWithCoinLegs(target.metadata, coinLegs), sizeUnit), sizeUnit), wrunChartIntervalMsOf(chartMetadata?.interval));
10017
+ const metadata = wrunSheetWithLaneGate(wrunSheetWithLaneDemand(wrunSheetWithLaneCurrencies(wrunSheetWithCoinLegs(target.metadata, coinLegs), sizeUnit), sizeUnit, settings), wrunChartIntervalMsOf(chartMetadata?.interval));
8873
10018
  return metadata === target.metadata ? target : { ...target, metadata };
8874
10019
  }
8875
10020
  /**
@@ -8888,7 +10033,7 @@ async function resolveWrunCoinLegs(sheet, chartMetadata, settings) {
8888
10033
  if (wrunCoinLegVenues(sheet).length === 0)
8889
10034
  return undefined;
8890
10035
  const values = wrunParamValuesFromSettings(sheet, settings);
8891
- const read = Object.entries(wrunSheetWithLaneDemand(sheet, wrunChartSizeUnit(chartMetadata)).inputSources).filter(([, source]) => source !== undefined &&
10036
+ const read = Object.entries(wrunSheetWithLaneDemand(sheet, wrunChartSizeUnit(chartMetadata), settings).inputSources).filter(([, source]) => source !== undefined &&
8892
10037
  source.undemanded !== true &&
8893
10038
  wrunInputGateOn(source, typeof source.when === 'string' ? values[source.when] : undefined));
8894
10039
  const venues = wrunCoinLegVenues({ inputSources: Object.fromEntries(read) });
@@ -9186,6 +10331,13 @@ applied) {
9186
10331
  catch (error) {
9187
10332
  console.warn(`[wrun] latest values publish failed for '${indicatorId}' (chart ${chartIndex}):`, error);
9188
10333
  }
10334
+ // A viewer's nothing-drawn note stands until the chart draws: this integrate's rows lower it when they do.
10335
+ try {
10336
+ lowerWrunNothingDrawnOnDraw(chartIndex, indicatorId, metadata, outputRows);
10337
+ }
10338
+ catch (error) {
10339
+ console.warn(`[wrun] nothing-drawn note failed for '${indicatorId}' (chart ${chartIndex}):`, error);
10340
+ }
9189
10341
  // The run reached the chart: a registry Indicator is marked seen (never throws, a set lookup once noted).
9190
10342
  wrunChartHostEnv().diagnostics.noteRegistryRun(chartIndex, indicatorId, settings);
9191
10343
  }
@@ -9415,6 +10567,8 @@ async function reintegrateWrunSession(indicatorId, context, fill, current, optio
9415
10567
  indicatorId,
9416
10568
  metadata: context.metadata,
9417
10569
  outputRows: context.outputRows,
10570
+ // The session's own picture: a refine or a style repaint redraws what the session computed.
10571
+ pictureIdentity: wrunPictureIdentityOf(context),
9418
10572
  title: context.title,
9419
10573
  position: context.position,
9420
10574
  axis: context.axis,
@@ -9422,7 +10576,7 @@ async function reintegrateWrunSession(indicatorId, context, fill, current, optio
9422
10576
  fills: context.fills,
9423
10577
  candles: context.candles,
9424
10578
  chartNames,
9425
- legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
10579
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, undefined, context.cmeDelayed),
9426
10580
  ...wrunResultMarketUnits(context.market),
9427
10581
  ...(runSession
9428
10582
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
@@ -9467,27 +10621,28 @@ async function reintegrateWrunSession(indicatorId, context, fill, current, optio
9467
10621
  * A repaint of the mounted session under a new sheet: the style-only save's
9468
10622
  * door (wrun-style-patch.util) for the paint its in-place plot patch cannot
9469
10623
  * 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
10624
+ * from the frames snapshot the session's rows carry, or leaves it out: the
10625
+ * module writes its frames whatever the sheet hides, and a slot it never wrote
10626
+ * builds nothing, as a run of it would), the colour of a level, a renderer or
10627
+ * a batched section, a band, a fill, a box, a segment, and every look the
10628
+ * adapter derives from an output's colour. The caller swaps the new sheet into
10629
+ * the context first (`context.metadata`); this integrates the session's own
10630
+ * rows and buffers under it with the canvas fill the session was drawn with
10631
+ * (no worker call, no fetch: reintegrateWrunSession) and presents the result
10632
+ * as a republish, under the overlay's session lock. A full run in flight
9478
10633
  * replaces the session when it lands, so the repaint stands down and the
9479
10634
  * save's rerun joins that run. False (the save keeps its rerun): no live
9480
10635
  * session, the context replaced or suspended, a full run in flight, the
9481
10636
  * 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.
10637
+ * pause, the market), no candle to land on, or a failed integrate (the session
10638
+ * then owes its repaint, as after a failed tick). `preview` (a settings
10639
+ * gesture's frame, under the previewed sheet) writes nothing to the overlay's
10640
+ * settings. A replay session stands down too: only its lane bounds its candles
10641
+ * at the replay's cutoff (the run and the tick paths), so the save reruns
10642
+ * there. A session whose row source holds its own session (a cloud run)
10643
+ * repaints with the cells that source keeps (`cellRowsOf`, as its full run and
10644
+ * its frames read them); a sheet drawing price canvases whose cells neither
10645
+ * such a source nor the context's lane buffers hold stands down.
9491
10646
  */
9492
10647
  export async function repaintWrunSessionUnderSheet(indicatorId, context, options = {}) {
9493
10648
  const standing = () => getWrunOverlayLiveContext(indicatorId) === context && !isWrunOverlayFullRerunInFlight(indicatorId);
@@ -9524,6 +10679,383 @@ export async function repaintWrunSessionUnderSheet(indicatorId, context, options
9524
10679
  }
9525
10680
  });
9526
10681
  }
10682
+ // ---------------------------------------------------------------------------
10683
+ // The warm switch's park and re-attach (SWITCH-COST U1)
10684
+ // ---------------------------------------------------------------------------
10685
+ /**
10686
+ * Park one overlay's live session at a warm workspace switch's teardown (the registry loader's capture door, while the
10687
+ * outgoing chart still stands): the picture its chart shows (`wrunMountedRunResultOf`, the stand-in capture's read)
10688
+ * goes with the session to the park (wrun-overlay-park.util parkWrunOverlayLiveSession), which keeps the worker's
10689
+ * series and the context and releases everything chart-bound. Undefined, with nothing released, when the chart shows no whole
10690
+ * picture of the session (no result known to show, a page) or the drivers refuse it.
10691
+ */
10692
+ export function parkWrunOverlayForSwitch(chartIndex, indicatorId) {
10693
+ const tc = wrunChartHostEnv().chart.instance(chartIndex);
10694
+ const meta = tc?.metadata?.find((candidate) => candidate.id === indicatorId);
10695
+ if (!tc || !meta)
10696
+ return undefined;
10697
+ const shown = wrunMountedRunResultOf(indicatorId, meta);
10698
+ if (shown === undefined || shown.window?.partial === true)
10699
+ return undefined;
10700
+ const bars = wrunParkedBarsOf(wrunChartCandleRows(tc));
10701
+ if (bars === undefined)
10702
+ return undefined;
10703
+ // 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
10704
+ // the authorisation it was parked under: its adoption takes nothing back once the gate closed or the epoch moved.
10705
+ const readCme = getWrunOverlayLiveContext(indicatorId)?.cmeRead === true ||
10706
+ meta.settings?.metaCmeExchange === 'CME';
10707
+ return parkWrunOverlayLiveSession(indicatorId, shown, bars, Date.now(), readCme ? captureCmeStudyAuth() : undefined);
10708
+ }
10709
+ /** A chart's bars as a park and its adoption compare them: the first, the newest closed (the one before the newest)
10710
+ * and the newest. Undefined while the chart holds none. */
10711
+ function wrunParkedBarsOf(rows) {
10712
+ if (rows.length === 0)
10713
+ return undefined;
10714
+ return {
10715
+ firstTs: Number(rows[0][0]),
10716
+ lastClosedTs: rows.length > 1 ? Number(rows[rows.length - 2][0]) : null,
10717
+ lastTs: Number(rows[rows.length - 1][0]),
10718
+ };
10719
+ }
10720
+ /** Cut an adopted session to the chart's rows from `firstTs` on: its first row and its output rows, and every fact a
10721
+ * prefix run would read about the bars before (its guest evaluated them: no prefix proof stands over the cut). */
10722
+ function trimWrunAdoptedSession(context, firstTs) {
10723
+ // By timestamp, the run-level attachments (the handle set, the frames, the strategy, the draw skips, the live
10724
+ // block's accounting) carried to the cut rows: a filtered copy is a new array the WeakMap attachments never follow.
10725
+ context.outputRows = wrunLandedOutputRows(context.outputRows, firstTs);
10726
+ context.firstRowTs = firstTs;
10727
+ // It holds every bar the chart shows now: no budget clamps it.
10728
+ delete context.retained;
10729
+ context.prefixCapable = false;
10730
+ delete context.prefixOwner;
10731
+ delete context.candleEvidence;
10732
+ delete context.warmupHead;
10733
+ delete context.warmRun;
10734
+ delete context.laneWarmupHead;
10735
+ }
10736
+ /** The overlay provenance writers (the env's loader), or undefined when they cannot load. */
10737
+ async function wrunProvenanceWritersOrNone() {
10738
+ try {
10739
+ return await wrunChartHostEnv().chart.loadOptionsOverlayProvenance();
10740
+ }
10741
+ catch {
10742
+ return undefined;
10743
+ }
10744
+ }
10745
+ function ringWrunParkAdopt(target, fields) {
10746
+ if (!wrunChartHostEnv().diagnostics.debugEnabled())
10747
+ return;
10748
+ wrunChartHostEnv().diagnostics.debug('wrun-run-park-adopt', { ...target, ...fields });
10749
+ }
10750
+ /** Whether the overlay's mount still stands on the chart the adoption read: the same engine at its index, holding the
10751
+ * same meta. */
10752
+ function wrunAdoptMountStands(chartIndex, tc, meta) {
10753
+ const metadata = tc?.metadata;
10754
+ return wrunChartHostEnv().chart.instance(chartIndex) === tc && Array.isArray(metadata) && metadata.includes(meta);
10755
+ }
10756
+ /**
10757
+ * The warm switch's re-attach: the overlay's first run on the chart that mounts it again takes its parked live session
10758
+ * back (wrun-overlay-park.util parkWrunOverlayLiveSession) in place of running the package over the whole history.
10759
+ * The registry loader calls it from the run its driver's first request starts (the executor's single flight, so a wave
10760
+ * meanwhile waits for it, and the executor counts its success as the run's: the good result, the coverage the next
10761
+ * same-rows wave skips on, the attempt and the settings settle).
10762
+ *
10763
+ * Judged on the chart, the host and the session as they stand (`refusalNow`): once before the waits (the hold reads,
10764
+ * the session lock) for an early answer, and again under the lock right before the install, with no await between that
10765
+ * judgment and the install, since a settings save, a symbol switch, a pause, a teardown or the worker can move while
10766
+ * the adoption waits. The mount stands; the worker still holds the series under the parked epoch; the chart's newest
10767
+ * closed bar is the one it was at the park (no bar closed since: the forming bar may differ, the live tick covers it)
10768
+ * and the session covers the chart's rows (its first bar no later than the chart's first; a chart that came back with
10769
+ * fewer bars than it lazy-loaded before the park, the cached boot window, is covered); the market and the settings
10770
+ * revision are the session's; a session that read CME may still read it under the authorisation of its park (the gate
10771
+ * open to the run, the epoch unmoved: no picture computed from CME returns past a closed gate); nothing holds the
10772
+ * overlay (a pause, a trip, replay). Any refusal ends the parked series and answers why; the caller then runs the
10773
+ * package as today.
10774
+ *
10775
+ * A session that covers more bars than the chart shows is cut to the chart's rows before it is adopted
10776
+ * (`trimWrunAdoptedSession`, the run-level attachments riding the cut rows): its first row becomes the chart's, the
10777
+ * output rows before it go, and it plans no prefix run (its guest evaluated the bars before its new first row, so no
10778
+ * prefix proof stands over it), so older bars the chart lazy-loads later go through the history path a fresh run's
10779
+ * would. Its picture is then built again over the rows it kept.
10780
+ *
10781
+ * Adopted, the session is the overlay's again, as if it had never left: the context goes back into the registry under
10782
+ * this chart and a fresh generation (the series keeps its epoch), with its history as-of pins, and a session that read
10783
+ * CME gets back the CME stamp its run's fetch door put on the overlay (both settings copies, before its picture
10784
+ * installs: the remount shed it; by the doors' rule, so a first-party run on a CME chart stays unstamped); its picture
10785
+ * integrates through the route a first run takes (`integrateWrunRunThroughRoute`, reason 'initial': the remount,
10786
+ * `mode: 'metadata'`, the mount memo written), prebuilt (the result the chart showed, built already: no build) when it
10787
+ * was not cut, carries no child overlays and runs at the chart's interval, else built again from the session's own
10788
+ * rows and buffers (`reintegrateWrunSession`, the style repaint's door). Then, still under the lock and with no await
10789
+ * in between, what a first run settles with its picture: the stand-in it replaces retracts (`replaced`), the retained
10790
+ * range, the overlay's live and poll channels open again, a `session-start` gap mark has the first drain reconcile
10791
+ * every lane over the time the tab was away and then tick the kept worker series, and the run settles under the
10792
+ * settings revision the session computed. A teardown, a pause or another switch after that closes what opened here.
10793
+ * The canvas notices, the Strategy Tester payload, the run health and the refusal verdicts publish after the lock,
10794
+ * each only while the session is still this chart's under the generation it was installed with.
10795
+ */
10796
+ export async function adoptWrunParkedLiveSession(parked, target) {
10797
+ const { chartIndex, indicatorId } = target;
10798
+ const startedAt = wrunHostClockMs();
10799
+ const taken = parked.indicatorId === indicatorId ? takeWrunParkedLiveSession(parked) : undefined;
10800
+ if (taken === undefined) {
10801
+ ringWrunParkAdopt(target, { adopted: false, reason: 'not-parked' });
10802
+ return { adopted: false, reason: 'not-parked' };
10803
+ }
10804
+ const { context, shown, historyAsOf } = taken;
10805
+ // Every refusal past the take ends the series the handle held: nothing will tick it again.
10806
+ const refuse = (reason) => {
10807
+ endWrunParkedLiveSeries(parked);
10808
+ ringWrunParkAdopt(target, { adopted: false, reason, parkedForMs: Date.now() - parked.parkedAt });
10809
+ return { adopted: false, reason };
10810
+ };
10811
+ // The attempt this run answers (the loader opened it at the mount): its first run starts here, as a run's does.
10812
+ const attempt = wrunChartHostEnv().diagnostics.liveAttemptToken(chartIndex, indicatorId);
10813
+ if (attempt)
10814
+ wrunChartHostEnv().diagnostics.markAttemptRunStart(attempt);
10815
+ const tc = wrunChartHostEnv().chart.instance(chartIndex);
10816
+ const meta = tc?.metadata?.find((candidate) => candidate.id === indicatorId);
10817
+ if (!tc || !meta)
10818
+ return refuse('chart-gone');
10819
+ // The chart's first bar when the session covers it (see the header), else undefined. The session covers the chart
10820
+ // from its first row on; one its run budget clamped (`retained`: it never held the chart's oldest bars) also covers
10821
+ // the window it was clamped in, the chart's first bar at the park.
10822
+ const coveredFirstTs = () => {
10823
+ const bars = wrunParkedBarsOf(wrunChartCandleRows(tc));
10824
+ if (bars === undefined || bars.lastClosedTs !== parked.bars.lastClosedTs || context.lastRowTs > bars.lastTs) {
10825
+ return undefined;
10826
+ }
10827
+ const covered = bars.firstTs >= context.firstRowTs || (context.retained !== undefined && bars.firstTs === parked.bars.firstTs);
10828
+ return covered ? bars.firstTs : undefined;
10829
+ };
10830
+ const chartFirstTs = coveredFirstTs();
10831
+ // Why the session cannot be adopted on the chart as it stands now, null when it can (see the header). Synchronous,
10832
+ // so the read under the lock is the one the install acts on.
10833
+ const refusalNow = () => {
10834
+ if (!wrunAdoptMountStands(chartIndex, tc, meta))
10835
+ return 'chart-gone';
10836
+ if (!getWrunBrowserHost().holdsLiveSeries(indicatorId, parked.epoch))
10837
+ return 'session-lost';
10838
+ if (chartFirstTs === undefined || coveredFirstTs() !== chartFirstTs)
10839
+ return 'bars-moved';
10840
+ const chartMetadata = wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata;
10841
+ if ((context.marketIdentity !== undefined && context.marketIdentity !== wrunChartMarketIdentity(chartMetadata)) ||
10842
+ kScriptSettingsRevision(meta.settings) !== (context.settingsRevision ?? 0)) {
10843
+ return 'identity-changed';
10844
+ }
10845
+ if (parked.cmeAuth !== undefined &&
10846
+ (!isCmeStudyAuthCurrent(parked.cmeAuth) ||
10847
+ !isCmeReadableKScriptRun(meta.settings))) {
10848
+ return 'cme-access';
10849
+ }
10850
+ if (wrunChartHostEnv().chart.isReplaying(chartIndex) ||
10851
+ wrunChartHostEnv().chart.chartStore().isKScriptOverlayPaused?.(chartIndex, indicatorId) === true ||
10852
+ wrunChartHostEnv().chart.isOverlayTripped(overlayExecutionGuardKey(chartIndex, indicatorId))) {
10853
+ return 'held';
10854
+ }
10855
+ return null;
10856
+ };
10857
+ const early = refusalNow();
10858
+ if (early !== null || chartFirstTs === undefined)
10859
+ return refuse(early ?? 'bars-moved');
10860
+ // A first run's hold read (it pauses a tripped overlay) and the user's pause.
10861
+ const held = await isWrunOverlayHeldForRun(chartIndex, indicatorId).catch(() => null);
10862
+ if (held || (await isWrunOverlayPaused(chartIndex, indicatorId)))
10863
+ return refuse('held');
10864
+ // The provenance writers for a session that read CME, loaded before the lock (the install restores its CME stamp); a
10865
+ // load that fails adopts nothing that read CME (`cme-access` under the lock).
10866
+ const provenance = parked.cmeAuth === undefined ? undefined : await wrunProvenanceWritersOrNone();
10867
+ // A child overlay or a run interval rebuilds from the session's rows; a sheet whose canvases' cells the context does
10868
+ // not hold could only rebuild them empty (the style repaint's rule).
10869
+ const runSession = wrunRunIntervalSessionOf(context);
10870
+ // The chart shows fewer bars than the session covers: the session is cut to them (a run at another interval keeps
10871
+ // its own bars and is never cut: it runs again).
10872
+ const trim = chartFirstTs > context.firstRowTs;
10873
+ if (trim && runSession !== undefined)
10874
+ return refuse('bars-moved');
10875
+ const rebuild = trim || runSession !== undefined || (shown.runResult.childOverlays?.length ?? 0) > 0;
10876
+ if (rebuild && wrunSheetDrawsCanvases(context.metadata) && !wrunHoldsCanvasCells(context)) {
10877
+ return refuse('integrate-failed');
10878
+ }
10879
+ // The session is this chart's while it is the registered context under the generation it was installed with, on the
10880
+ // mount the adoption read. A teardown, a pause or another switch takes it away; whoever took it holds the overlay.
10881
+ let installed = Number.NaN;
10882
+ const owned = () => getWrunOverlayLiveContext(indicatorId) === context &&
10883
+ context.generation === installed &&
10884
+ wrunAdoptMountStands(chartIndex, tc, meta);
10885
+ // Why a session taken away while its picture landed answers: a pause or a trip leaves the mount standing.
10886
+ const left = () => (wrunAdoptMountStands(chartIndex, tc, meta) ? 'held' : 'chart-gone');
10887
+ const adopted = await withWrunOverlaySessionLock(indicatorId, async () => {
10888
+ if (getWrunOverlayLiveContext(indicatorId) !== undefined)
10889
+ return 'integrate-failed';
10890
+ // Judged again on the chart as it stands after the waits; nothing awaits from here to the install.
10891
+ const late = refusalNow();
10892
+ if (late !== null)
10893
+ return late;
10894
+ // The stamp the fetch door gave what the session drew (cme-overlay-provenance.util: a CME user study's on any
10895
+ // chart, any run's CME read off a CME chart), on both settings copies before its picture installs: the remount
10896
+ // shed it, and no fetch door runs for an adopted session. A host that cannot write it adopts nothing that read
10897
+ // CME.
10898
+ const chartExchangeNow = wrunChartHostEnv().chart.chartStore().mergedAllCharts[chartIndex]?.metadata?.exchange;
10899
+ if (parked.cmeAuth !== undefined &&
10900
+ (isCmeUserScriptRun(meta.settings) ||
10901
+ !payloadTouchesCmeVenue(chartExchangeNow))) {
10902
+ if (provenance?.setOverlayCmeProvenance === undefined)
10903
+ return 'cme-access';
10904
+ provenance.setOverlayCmeProvenance(chartIndex, indicatorId, true);
10905
+ }
10906
+ if (trim)
10907
+ trimWrunAdoptedSession(context, chartFirstTs);
10908
+ // The session is this chart's now, under a fresh generation: frames and drains of its old chart are discarded.
10909
+ // The worker's series keeps the epoch it was opened under, which a later park names it by.
10910
+ context.chartIndex = chartIndex;
10911
+ context.seriesEpoch = parked.epoch;
10912
+ context.generation = nextWrunOverlayLiveGeneration(indicatorId);
10913
+ installed = context.generation;
10914
+ context.liveApplied = undefined;
10915
+ context.rebuildHandoffShape = undefined;
10916
+ if (historyAsOf !== undefined)
10917
+ restoreWrunHistoryAsOf(indicatorId, historyAsOf);
10918
+ setWrunOverlayLiveContext(context);
10919
+ let runResult;
10920
+ try {
10921
+ if (rebuild) {
10922
+ // The row builder reads the shared host, as the style repaint's rebuild does.
10923
+ const hostLoading = ensureWrunChartHostSharedHost();
10924
+ if (hostLoading)
10925
+ await hostLoading;
10926
+ const fill = wrunSessionCanvasFillOf(context) ?? (await wrunCanvasHostFillFor(context.metadata, context.market));
10927
+ if (!(await reintegrateWrunSession(indicatorId, context, fill, owned))) {
10928
+ if (!owned())
10929
+ return left();
10930
+ throw new Error('not rebuilt');
10931
+ }
10932
+ runResult = wrunMountedRunResultOf(indicatorId, meta)?.runResult ?? shown.runResult;
10933
+ }
10934
+ else {
10935
+ const integration = integrateWrunRunThroughRoute({
10936
+ tc,
10937
+ meta,
10938
+ chartIndex,
10939
+ indicatorId,
10940
+ metadata: context.metadata,
10941
+ outputRows: context.outputRows,
10942
+ // The parked session's own picture (the adoption refused a session whose identity moved).
10943
+ pictureIdentity: wrunPictureIdentityOf(context),
10944
+ prebuilt: shown.runResult,
10945
+ title: context.title,
10946
+ position: context.position,
10947
+ axis: context.axis,
10948
+ colors: context.colors,
10949
+ fills: context.fills,
10950
+ candles: context.candles,
10951
+ integration: { reason: 'initial', hasGoodResult: false, identityLeft: false, settingsStale: false },
10952
+ });
10953
+ if (!integration.applied)
10954
+ throw new Error(`not applied (${integration.route.action})`);
10955
+ // A result that names its children (none here, at most an empty list) settles their mount as a run's does.
10956
+ if (integration.runResult.childOverlays !== undefined &&
10957
+ !(await awaitWrunChildOverlays(tc, indicatorId))) {
10958
+ throw new Error('children not mounted');
10959
+ }
10960
+ if (!owned())
10961
+ return left();
10962
+ presentWrunIntegration(chartIndex, indicatorId, context.metadata, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), undefined, 'run', { emptyTargets: integration.runResult.emptyTargets, partial: false });
10963
+ context.paintedThroughTs = context.lastRowTs;
10964
+ context.repaintOwed = false;
10965
+ runResult = integration.runResult;
10966
+ }
10967
+ }
10968
+ catch (error) {
10969
+ // The picture did not land: the context leaves again (a pause's release, which also ends the series), and
10970
+ // the caller's run computes the overlay as a first mount does.
10971
+ console.warn(`[wrun] the parked session of '${indicatorId}' was not adopted (running it):`, error);
10972
+ if (getWrunOverlayLiveContext(indicatorId) === context)
10973
+ suspendWrunOverlayLiveSession(indicatorId);
10974
+ return 'integrate-failed';
10975
+ }
10976
+ if (!owned())
10977
+ return left();
10978
+ // The picture is the chart's: what a first run settles with it, before any further await (see the header). The
10979
+ // adopted picture replaces the stand-in the switch back painted.
10980
+ wrunChartHostEnv().chart.retractStandIn(chartIndex, indicatorId, 'replaced', tc);
10981
+ noteWrunRunRetained(tc, indicatorId, context.retained ?? null);
10982
+ // Live again: the overlay's own channels and its poll lanes' streams, and one reconcile over the time away.
10983
+ void subscribeWrunOverlayLiveFeed(indicatorId, meta.settings, chartIndex);
10984
+ openWrunPollLaneLiveChannels(context);
10985
+ markWrunLiveGap(indicatorId, 'session-start');
10986
+ // The drain that mark wakes can meet this run still in flight (the executor counts the adoption as the
10987
+ // overlay's first run until its publications end) and be turned away: re-armed, it drains again on the cadence
10988
+ // until it gets past that gate, so a quiet market's reconcile never waits for the next frame.
10989
+ rearmWrunLiveTick(chartIndex, indicatorId);
10990
+ markWrunOverlayComputeSucceeded(indicatorId);
10991
+ // The run computed the settings revision the session holds (judged the mount's own above, under this lock).
10992
+ noteWrunOverlayRunSettle(indicatorId, { generation: context.settingsRevision ?? 0, outcome: 'applied' });
10993
+ return runResult;
10994
+ });
10995
+ if (typeof adopted === 'string')
10996
+ return refuse(adopted);
10997
+ // What a first run publishes beside its picture, each only while the session is still this chart's: whoever took
10998
+ // it during one of them (a teardown, a pause, another switch) holds the overlay, and the rest is theirs.
10999
+ const publications = [
11000
+ () => publishWrunSessionCanvasNotices(context, adopted, { isCurrent: owned }),
11001
+ () => publishWrunStrategyRunResult(chartIndex, indicatorId, adopted, { tc, meta }),
11002
+ async () => {
11003
+ // The overlay's health follows the session by the full run's rule (a reseed's: its context read only when
11004
+ // every bar was warm-up).
11005
+ const health = wrunSessionRunHealth(context, meta.settings, context.outputRows);
11006
+ const nothingReady = health.bars > 0 && health.ready === 0
11007
+ ? wrunNothingReadyRefusal(health, await wrunRefusalContextFor({
11008
+ title: context.title,
11009
+ metadata: context.metadata,
11010
+ settings: meta.settings,
11011
+ chartMetadata: await wrunChartMetadataFor(chartIndex),
11012
+ }))
11013
+ : null;
11014
+ if (!owned())
11015
+ return;
11016
+ context.runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, context.draft === true, nothingReady), { isCurrent: owned });
11017
+ // The viewer's nothing-drawn note follows the adopted session's whole window like a reseed's (FB27).
11018
+ if (!owned())
11019
+ return;
11020
+ await publishWrunNothingDrawn(chartIndex, indicatorId, {
11021
+ draft: context.draft === true,
11022
+ settled: context.window?.partial !== true && wrunSessionSourceAbsent.get(context) !== true,
11023
+ metadata: context.metadata,
11024
+ rows: context.outputRows,
11025
+ drawings: wrunHandlesOf(context.outputRows)?.length,
11026
+ runIntervalMs: wrunRunIntervalSessionOf(context)?.run.intervalMs ?? context.intervalMs,
11027
+ }, async () => wrunRefusalContextFor({
11028
+ title: context.title,
11029
+ metadata: context.metadata,
11030
+ settings: meta.settings,
11031
+ chartMetadata: await wrunChartMetadataFor(chartIndex),
11032
+ }), { isCurrent: owned });
11033
+ },
11034
+ () => {
11035
+ noteWrunWholeWindowDrawnSafely(indicatorId);
11036
+ return settleWrunRefusalsOnReseed(chartIndex, indicatorId, owned);
11037
+ },
11038
+ () => void clearWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, owned),
11039
+ ];
11040
+ for (const publish of publications) {
11041
+ if (!owned())
11042
+ break;
11043
+ await publish();
11044
+ }
11045
+ const ownerLeft = !owned();
11046
+ wrunChartHostEnv().diagnostics.settleAttempt(attempt, { ok: true });
11047
+ const path = rebuild ? 'rebuilt' : 'prebuilt';
11048
+ ringWrunParkAdopt(target, {
11049
+ adopted: true,
11050
+ path,
11051
+ ...(trim ? { trimmedToTs: chartFirstTs } : {}),
11052
+ ...(ownerLeft ? { ownerLeft: true } : {}),
11053
+ rows: context.outputRows.length,
11054
+ parkedForMs: Date.now() - parked.parkedAt,
11055
+ ms: Math.round(wrunHostClockMs() - startedAt),
11056
+ });
11057
+ return { adopted: true, path };
11058
+ }
9527
11059
  /** Drop an overlay's canvas run state (its refine latches, its run serial):
9528
11060
  * called from the live tick lane's teardown hook beside the canvas cache. */
9529
11061
  export function forgetWrunOverlayCanvasState(indicatorId) {
@@ -9891,7 +11423,7 @@ function wrunIntegrationErrorOf(diagnostics) {
9891
11423
  * carried a window (a pan wave's, clamped or the whole loaded range) hands it as the
9892
11424
  * `historyWindow`: a mounted heatmap then merges the run's rows inside that window and keeps the
9893
11425
  * rest (wrun-panel-mount.util), so a pan-back page lands. */
9894
- function mergeWrunChildOverlays(tc, indicatorId, runResult, projection, priceDigits, childMount, chartIndex, historyWindow) {
11426
+ function mergeWrunChildOverlays(tc, indicatorId, runResult, projection, priceDigits, childMount, pictureIdentity, chartIndex, historyWindow) {
9895
11427
  const children = runResult.childOverlays;
9896
11428
  if (children === undefined)
9897
11429
  return;
@@ -9929,6 +11461,7 @@ function mergeWrunChildOverlays(tc, indicatorId, runResult, projection, priceDig
9929
11461
  replaceFrames: false,
9930
11462
  ...(historyWindow ? { historyWindow } : {}),
9931
11463
  ...(projection ? { projection } : {}),
11464
+ ...(pictureIdentity !== undefined ? { pictureIdentity } : {}),
9932
11465
  ...(priceDigits ? { priceDigits } : {}),
9933
11466
  onMainThreadMs: (ms) => {
9934
11467
  childMount.applyMs += ms;
@@ -10027,17 +11560,21 @@ function integrateWrunRunThroughRouteOnce(options, childMount) {
10027
11560
  // selection text and the children print with them.
10028
11561
  const priceDigits = options.priceDigits ?? wrunChartPriceDigits(options.chartIndex);
10029
11562
  // 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
- });
11563
+ // (the run's init() arguments derive from them the same way). An adoption hands the picture its session showed.
11564
+ const runResult = options.prebuilt ??
11565
+ buildWrunOverlayRunResult({
11566
+ ...options,
11567
+ params: options.params ?? wrunParamValuesFromSettings(options.metadata, options.meta.settings),
11568
+ texts: options.texts ?? wrunTextParamValuesFromSettings(options.metadata, options.meta.settings),
11569
+ // An editor draft's legend says it is one (and only in this browser); the tick repeats it.
11570
+ legendNote: options.legendNote ?? wrunDraftLegendNote(options.meta.settings),
11571
+ // A built-in's port names its lines in its built-in's words (wrun-output-words.util): builtinPortOf, the
11572
+ // resolver the alert words and the settings page read (the `builtinTwinOf` stamp, else the package's port).
11573
+ builtIn: builtinPortOf(options.meta.settings),
11574
+ ...(options.projection ? { runTimeline: true } : {}),
11575
+ ...(priceDigits !== undefined ? { priceDigits } : {}),
11576
+ overlayId: options.overlayId ?? options.indicatorId,
11577
+ });
10041
11578
  if (runResult.failureReason !== undefined)
10042
11579
  throw new WrunIntegrationError(runResult.failureReason);
10043
11580
  const { tc, meta, indicatorId, projection, chartIndex } = options;
@@ -10125,6 +11662,7 @@ function integrateWrunRunThroughRouteOnce(options, childMount) {
10125
11662
  runResult,
10126
11663
  ...(partialSpan ? { historyWindow: partialSpan } : {}),
10127
11664
  ...(projection ? { projection } : {}),
11665
+ ...(options.pictureIdentity !== undefined ? { pictureIdentity: options.pictureIdentity } : {}),
10128
11666
  ...(childPriceDigits ? { priceDigits: childPriceDigits } : {}),
10129
11667
  onMainThreadMs: (ms) => {
10130
11668
  childMount.applyMs += ms;
@@ -10153,7 +11691,7 @@ function integrateWrunRunThroughRouteOnce(options, childMount) {
10153
11691
  if (!refresh.ok)
10154
11692
  throw wrunIntegrationErrorOf(refresh.diagnostics);
10155
11693
  if (refresh.applied) {
10156
- mergeWrunChildOverlays(tc, indicatorId, runResult, projection, childPriceDigits, childMount, options.chartIndex, runSpan);
11694
+ mergeWrunChildOverlays(tc, indicatorId, runResult, projection, childPriceDigits, childMount, options.pictureIdentity, options.chartIndex, runSpan);
10157
11695
  render();
10158
11696
  return true;
10159
11697
  }
@@ -10310,12 +11848,14 @@ function wrunWarmupStampCorroborated(module, sheet) {
10310
11848
  wrunStampCorroborated(module) &&
10311
11849
  wrunWarmupSheetRefusal(sheet) === undefined);
10312
11850
  }
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:
11851
+ /** A torn warm-up stamp (4b): the sheet's `history_warmup` is no record at all, or a record of kind "exact" or
11852
+ * "converges" that no frozen shape reads off (a term whose multiplier is not a number, a window without its terms
11853
+ * list; a converging one with another tolerance, another corpus, a count below its floor or no gate:
10315
11854
  * `wrunWarmupStampOf` reads none). Named `warmup-invalid` by the full run's verdict, the plan's admission (its skip
10316
11855
  * reason) and the capability line, where it used to read as no stamp at all (the roster's silent `not-audited`); it
10317
11856
  * 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`). */
11857
+ * of another kind is a later round's stamp and reads as no stamp, as it always has (`wrunHistoryWarmupOf`), and so
11858
+ * does a converging one while its flag is off: every caller asks `wrunConvergingStampDark` first (R2-13). */
10319
11859
  function wrunWarmupStampTorn(sheet) {
10320
11860
  if (sheet === null || typeof sheet !== 'object')
10321
11861
  return false;
@@ -10324,7 +11864,48 @@ function wrunWarmupStampTorn(sheet) {
10324
11864
  return false;
10325
11865
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
10326
11866
  return true;
10327
- return raw.kind === 'exact' && wrunWarmupStampOf(sheet) === undefined;
11867
+ const kind = raw.kind;
11868
+ return (kind === 'exact' || kind === 'converges') && wrunWarmupStampOf(sheet) === undefined;
11869
+ }
11870
+ /** Whether the chart honors a converging warm-up stamp (`FeatureFlag.WrunConvergingPrefix`, STAMPS round A, default
11871
+ * off); a host whose flag store is not up reads off. */
11872
+ function wrunConvergingPrefixOn() {
11873
+ try {
11874
+ return wrunChartHostEnv().user.isFeatureOn(FeatureFlag.WrunConvergingPrefix);
11875
+ }
11876
+ catch {
11877
+ return false;
11878
+ }
11879
+ }
11880
+ /** Whether a sheet's `history_warmup` is a record of kind "converges", whatever else it holds. */
11881
+ function wrunWarmupStampConverges(sheet) {
11882
+ const raw = sheet !== null && typeof sheet === 'object' ? sheet.history_warmup : undefined;
11883
+ return (raw !== null && typeof raw === 'object' && !Array.isArray(raw) && raw.kind === 'converges');
11884
+ }
11885
+ /** A converging stamp its flag leaves unread (STAMPS round A, R2-13): while `wrun-converging-prefix` is off, a
11886
+ * `converges` record of ANY shape reads as no stamp, exactly as an unknown kind always has (never torn, never
11887
+ * planned, never admitted), so the run, its head, its rows and its admission are today's. Asked first by every reader
11888
+ * that plans or admits on a stamp, before any other reading of it (the torn check included). */
11889
+ function wrunConvergingStampDark(sheet) {
11890
+ return wrunWarmupStampConverges(sheet) && !wrunConvergingPrefixOn();
11891
+ }
11892
+ /** A converging stamp's tolerance as the plan and the admission carry it (`{ tolerance }`), none for an exact stamp. */
11893
+ function wrunWarmupToleranceOf(sheet) {
11894
+ const stamp = wrunWarmupStampOf(sheet);
11895
+ return stamp?.kind === 'converges' ? { tolerance: stamp.tolerance } : {};
11896
+ }
11897
+ /** The first candle of a hidden head with a field that is not finite (open, high, low, close or volume), else
11898
+ * undefined: a converging session's W counts ACCEPTED inputs (its recursions skip a non-finite input without
11899
+ * advancing, Codex 5), so a head holding one gives its guest fewer than W and the running start falls short of the
11900
+ * bound the gate certified (`warmup-gaps`). */
11901
+ function wrunWarmupHeadGapAt(rows) {
11902
+ for (const row of rows) {
11903
+ for (let column = 1; column <= 5; column += 1) {
11904
+ if (!Number.isFinite(Number(row[column])))
11905
+ return Number(row[0]);
11906
+ }
11907
+ }
11908
+ return undefined;
10328
11909
  }
10329
11910
  /** The settings W is sized from (4b): the ones the package computes with. A run at another interval and a built-in
10330
11911
  * twin whose Timeframe is at or below the chart's (`chartArm`) run their chart arm, the Timeframe forced to the chart
@@ -10361,12 +11942,16 @@ function wrunWarmupBarsOf(sheet, settings) {
10361
11942
  return { miss: answer.refusal };
10362
11943
  return answer.bars > WRUN_HISTORY_WARMUP_MAX_BARS ? { miss: 'warmup-cap' } : { bars: answer.bars };
10363
11944
  }
10364
- /** The exact warm-up verdict (D4): a torn stamp first (`warmup-invalid`, 4b), then corroborated
11945
+ /** The warm-up verdict (D4): a converging stamp its flag leaves unread first (null before anything else reads it,
11946
+ * R2-13: no head is planned or fetched), a torn stamp (`warmup-invalid`, 4b), then corroborated
10365
11947
  * (`wrunWarmupStampCorroborated`, else null), candles-only (`warmup-lanes`), W from the settings the package
10366
11948
  * 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`). */
11949
+ * head can join (`warmup-mode`: a replay run, a run at another interval). The plan is W, and a converging stamp's
11950
+ * tolerance beside it (STAMPS round A; an exact plan is what it always was). Whether the chart's candles are asked as
11951
+ * a plain time window is the head request's question (`wrunWarmupHeadRequestOf`). */
10369
11952
  function wrunWarmupVerdictOf(input) {
11953
+ if (wrunConvergingStampDark(input.sheet))
11954
+ return null;
10370
11955
  if (wrunWarmupStampTorn(input.sheet))
10371
11956
  return { miss: 'warmup-invalid' };
10372
11957
  if (!wrunWarmupStampCorroborated(input.module, input.sheet))
@@ -10380,7 +11965,7 @@ function wrunWarmupVerdictOf(input) {
10380
11965
  return { miss: bars.miss };
10381
11966
  if (input.replay || input.runInterval)
10382
11967
  return { miss: 'warmup-mode' };
10383
- return { plan: { bars: bars.bars } };
11968
+ return { plan: { bars: bars.bars, ...wrunWarmupToleranceOf(input.sheet) } };
10384
11969
  }
10385
11970
  /** The main candle lane, loaded lazily (data-fetching.util's graph pulls in the live feed and, through it, this
10386
11971
  * lane); null when an export is missing (a spec's partial module) or the load failed. */
@@ -10962,19 +12547,27 @@ function wrunSandboxLandedRows(prepared, rows) {
10962
12547
  : rows;
10963
12548
  }
10964
12549
  /**
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.
12550
+ * A session's warm-up admission at a plan (D4, per guest): null for a converging stamp its flag leaves unread (asked
12551
+ * first, R2-13), `warmup-invalid` for a torn stamp (4b, the skip reason the roster's `not-audited` used to hide), null
12552
+ * when the sheet carries no stamp the module and the sheet corroborate (the per-bar stamp and the roster decide), the
12553
+ * W when every warm-up rule holds and the LIVE guest's warmth record matches the live generation, the settings
12554
+ * generation and the W the settings ask now (a guest warm at a history wall matches any W) with its head and evidence
12555
+ * held, else the reason: `warmup-lanes` (an input beyond the chart's candles), `warmup-cap`, `warmup-unresolved`, the
12556
+ * install's miss (`warmup-mode`, `warmup-short`) or `warmup-cold` (the guest ran no head under these settings, as
12557
+ * after a reseed that could not take one). W reads the settings the package computes with (`wrunWarmupSettings`), as
12558
+ * the install's warmth record did. A converging session (STAMPS round A) is admitted with its tolerance, and only
12559
+ * while its held head (`warmupHead`: the candles before its first landed row, which the next reseed runs first; the
12560
+ * full run's head, or once a page landed that page's own head, which its prepare already held to the same rule)
12561
+ * holds no candle field that is not finite (`warmup-gaps`: W counts accepted inputs, so a gap there leaves the
12562
+ * session's first landed rows short of the bound, and their overlap with a page would then fail as the module's
12563
+ * fault).
10973
12564
  */
10974
12565
  function wrunPrefixWarmupAdmission(context, meta) {
10975
12566
  const seed = context.sessionSeed;
10976
12567
  if (seed === undefined)
10977
12568
  return null;
12569
+ if (wrunConvergingStampDark(context.metadata))
12570
+ return null;
10978
12571
  if (wrunWarmupStampTorn(context.metadata))
10979
12572
  return 'warmup-invalid';
10980
12573
  if (!wrunWarmupStampCorroborated(seed.module, context.metadata))
@@ -10995,7 +12588,11 @@ function wrunPrefixWarmupAdmission(context, meta) {
10995
12588
  (warm.wall !== true && warm.warmupBars !== bars.bars)) {
10996
12589
  return context.warmupMiss ?? 'warmup-cold';
10997
12590
  }
10998
- return { bars: bars.bars };
12591
+ const tolerance = wrunWarmupToleranceOf(context.metadata);
12592
+ if (tolerance.tolerance !== undefined && wrunWarmupHeadGapAt(context.warmupHead.rows) !== undefined) {
12593
+ return 'warmup-gaps';
12594
+ }
12595
+ return { bars: bars.bars, ...tolerance };
10999
12596
  }
11000
12597
  /** Whether a warm-up admission admits the session (`wrunPrefixWarmupAdmission`'s W). */
11001
12598
  function isWrunWarmAdmission(admission) {
@@ -11055,9 +12652,13 @@ function latchWrunPrefixRefusal(indicatorId, identityKey) {
11055
12652
  }
11056
12653
  latched.add(identityKey);
11057
12654
  }
11058
- /** Whether the sheet paints a heatmap over book cells (a book-cells heatmap child). */
12655
+ /** Whether the sheet paints a heatmap over book cells (a book-cells heatmap child). A banded book input's block is
12656
+ * band sums, which no canvas paints (`isWrunBandedBookSource`). */
11059
12657
  function wrunSheetPaintsBookCells(sheet) {
11060
- return (sheet.heatmaps ?? []).some((heatmap) => heatmap.cells !== undefined && sheet.inputSources?.[heatmap.cells]?.source === 'book');
12658
+ return (sheet.heatmaps ?? []).some((heatmap) => {
12659
+ const source = heatmap.cells === undefined ? undefined : sheet.inputSources?.[heatmap.cells];
12660
+ return source?.source === 'book' && !isWrunBandedBookSource(source);
12661
+ });
11061
12662
  }
11062
12663
  /** Whether a book row (`[ts, price, size, ...]`) holds a level the module reads as a cell: a pair
11063
12664
  * of finite numbers (the host's book cells keep exactly those, a zero size included). */
@@ -11101,6 +12702,43 @@ function wrunPrefixClosedBookObserved(context) {
11101
12702
  }
11102
12703
  return false;
11103
12704
  }
12705
+ /** The sheet sections a converging session refuses in round A (`unsupported-outputs:converging-drawings`, Codex 2):
12706
+ * batched drawings (`marks`, `spans`, `rays`, `flags`: every batched kind), batched records (`boxes`, `segments`:
12707
+ * their `when` gates read an output discretely, and a 1e-6 slack on their `start` and `end` epoch fields is about
12708
+ * 28 minutes), canvas children
12709
+ * (`heatmaps`, `profiles`, `matrices`) and handles or drawings (`handles`, `handle_defaults`, `drawings`). Present
12710
+ * means not undefined, the stamp's own sheet-fact rule: an empty section refuses too. */
12711
+ const WRUN_CONVERGING_REFUSED_SHEET_KEYS = [
12712
+ ...WRUN_BATCHED_MARKS_KINDS,
12713
+ 'boxes',
12714
+ 'segments',
12715
+ 'heatmaps',
12716
+ 'profiles',
12717
+ 'matrices',
12718
+ 'handles',
12719
+ 'handle_defaults',
12720
+ 'drawings',
12721
+ ];
12722
+ /** Whether a sheet declares a batched drawing or record, a canvas child or a handle
12723
+ * (`WRUN_CONVERGING_REFUSED_SHEET_KEYS`). */
12724
+ function wrunSheetDeclaresConvergingDrawings(sheet) {
12725
+ const record = sheet;
12726
+ return WRUN_CONVERGING_REFUSED_SHEET_KEYS.some((key) => record[key] !== undefined);
12727
+ }
12728
+ /** The share of a whole run's work at or past which a converging page runs whole (`prefix-costlier`): a measured
12729
+ * performance heuristic (Codex 15), never a correctness threshold. */
12730
+ const WRUN_CONVERGING_PREFIX_COST_SHARE = 0.9;
12731
+ /** Whether a converging page costs about what the whole run it stands in for does (`prefix-costlier`, Codex 15): its
12732
+ * hidden head and the rows it walks over its window (the page, the overlap of up to 32 session rows, the missing
12733
+ * 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
12734
+ * range). Rows are walked rows (`wrunChartWalkedRows`), the run budget's own count, so a gap costs what it costs a
12735
+ * run. `loadedRows` is the chart's `wrunChartCandleRows` array (its recorded missing bars ride its identity). */
12736
+ function wrunConvergingPrefixCostlier(loadedRows, window, warmupBars) {
12737
+ const rows = loadedRows;
12738
+ const page = warmupBars + wrunChartWalkedRows(wrunChartCandleRowsWithin(rows, window.fromMs, window.toMs));
12739
+ const whole = warmupBars + wrunChartWalkedRows(rows);
12740
+ return page >= WRUN_CONVERGING_PREFIX_COST_SHARE * whole;
12741
+ }
11104
12742
  /**
11105
12743
  * The candidate rules but the backward extension and its owner (C1 v3), null when they hold: no
11106
12744
  * replay, no refused proof (the session's own or the latched one), no clamped window, the chart's
@@ -11116,9 +12754,13 @@ function wrunPrefixClosedBookObserved(context) {
11116
12754
  * may carry state across bars, a corroborated stamp proves the module carries none, or none past its
11117
12755
  * running start). A full run's install stamps the answer as `prefixCapable` (the live tick leaves a page
11118
12756
  * in front of a capable session to its pan wave for a grace), and the planner checks it again against
11119
- * the chart now.
12757
+ * the chart now. A session admitted on a converging stamp (STAMPS round A: its admission carries a tolerance) answers
12758
+ * two rules more: no batched drawing or record, canvas child or handle on its sheet
12759
+ * (`unsupported-outputs:converging-drawings`, Codex 2: their rows hold timed endpoints, gates, packed records and cells
12760
+ * the proof compares exactly, never a level a recursion converges on), and, given the planned `window`, a page that
12761
+ * costs nearly what the whole run it stands in for does (`prefix-costlier`, Codex 15).
11120
12762
  */
11121
- function wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup = null) {
12763
+ function wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup = null, window) {
11122
12764
  if (context.replay === true || wrunChartHostEnv().chart.isReplaying(context.chartIndex))
11123
12765
  return 'replay';
11124
12766
  const identity = wrunPrefixPackageIdentity(context, meta);
@@ -11155,12 +12797,21 @@ function wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup =
11155
12797
  if (!admission.safe)
11156
12798
  return typeof warmup === 'string' ? warmup : admission.reason;
11157
12799
  }
12800
+ // A converging session (STAMPS round A) lands rows within its tolerance of a whole run, never equal to one: no
12801
+ // drawing rides it in round A, and a page that costs about what the whole run does runs whole (exact, and no dearer).
12802
+ if (isWrunWarmAdmission(warmup) && warmup.tolerance !== undefined) {
12803
+ if (wrunSheetDeclaresConvergingDrawings(context.metadata))
12804
+ return 'unsupported-outputs:converging-drawings';
12805
+ if (window !== undefined && wrunConvergingPrefixCostlier(loadedRows, window, warmup.bars))
12806
+ return 'prefix-costlier';
12807
+ }
11158
12808
  // The mounted picture is what this lane applied last; a mount it never applied cannot be judged.
11159
12809
  const mounted = wrunMountMemos.get(meta)?.lastResult;
11160
12810
  if (mounted === undefined)
11161
12811
  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)
12812
+ // Frames ride the rows by index: an older bar in front would shift every one of them. The sheet's slots say whether
12813
+ // the module writes any (its every run answers them), never the rows' attachment, which a copy of the rows drops.
12814
+ if ((context.metadata.frames?.length ?? 0) > 0)
11164
12815
  return 'unsupported-outputs:frames';
11165
12816
  const cohort = wrunPrefixMountedCohort(context, mounted);
11166
12817
  if (!cohort.supported)
@@ -11191,7 +12842,18 @@ function wrunPrefixCapability(context, meta, loadedRows) {
11191
12842
  }
11192
12843
  else if (admission !== null) {
11193
12844
  const bars = wrunWarmupBarsOf(context.metadata, wrunSessionWarmupSettings(context, meta.settings));
11194
- warmup = { warmup: { kind: 'exact', bars: bars !== null && 'bars' in bars ? bars.bars : null } };
12845
+ const counted = bars !== null && 'bars' in bars ? bars.bars : null;
12846
+ const { tolerance } = wrunWarmupToleranceOf(context.metadata);
12847
+ warmup = {
12848
+ warmup: tolerance !== undefined ? { kind: 'converges', bars: counted, tolerance } : { kind: 'exact', bars: counted },
12849
+ };
12850
+ }
12851
+ else if (wrunConvergingStampDark(context.metadata)) {
12852
+ // A converging stamp its flag leaves unread (R2-13): the line names the kind and the tolerance it carries, no W.
12853
+ const stamp = wrunWarmupStampOf(context.metadata);
12854
+ if (stamp?.kind === 'converges') {
12855
+ warmup = { warmup: { kind: 'converges', bars: null, tolerance: stamp.tolerance } };
12856
+ }
11195
12857
  }
11196
12858
  const refusal = wrunPrefixIncapacity(context, meta, loadedRows, corroborated, admission);
11197
12859
  return { capable: refusal === null, reason: refusal ?? 'ok', ...identity, stamp, corroborated, ...warmup };
@@ -11231,7 +12893,7 @@ function planWrunPrefixRun(chartIndex, indicatorId) {
11231
12893
  return skip('not-backward-extension');
11232
12894
  const corroborated = wrunPrefixStampCorroborated(context, wrunHistoryStampOf(context.metadata));
11233
12895
  const warmup = corroborated ? null : wrunPrefixWarmupAdmission(context, meta);
11234
- const incapacity = wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup);
12896
+ const incapacity = wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup, decision.window);
11235
12897
  if (incapacity !== null)
11236
12898
  return skip(incapacity);
11237
12899
  // The options chain lands its snapshot on the build's last row: a window reaching the session's live row would land
@@ -11278,9 +12940,29 @@ function loadWrunLiveTickModule() {
11278
12940
  });
11279
12941
  return liveTickModule;
11280
12942
  }
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) {
12943
+ /** An owner change of the host's session the installed context's rows never read: owed from `fromTs` at once (the
12944
+ * drain's late-point mark), and as the revised closed bar's obligation once the tick lane is loaded
12945
+ * (reviseWrunOverlayLiveFrom: the next drain reseeds as soon as the budget allows). */
12946
+ function oweWrunCompositionRevision(context, fromTs) {
12947
+ if (!Number.isFinite(fromTs))
12948
+ return;
12949
+ context.dirtyFromTs = context.dirtyFromTs === null ? fromTs : Math.min(context.dirtyFromTs, fromTs);
12950
+ const { chartIndex, indicatorId } = context;
12951
+ void loadWrunLiveTickModule()
12952
+ .then((tick) => {
12953
+ const revise = readOptionalExport(() => tick.reviseWrunOverlayLiveFrom);
12954
+ if (typeof revise === 'function' && getWrunOverlayLiveContext(indicatorId) === context) {
12955
+ revise(chartIndex, indicatorId, fromTs);
12956
+ }
12957
+ })
12958
+ .catch((error) => {
12959
+ console.warn(`[wrun] composition revision unavailable for '${indicatorId}':`, error);
12960
+ });
12961
+ }
12962
+ /** The live tick drain's re-arm (C7): after a prefix outcome, and after an adoption's session start, whose drain can
12963
+ * meet the adoption's own run still in flight. Reached lazily: the tick lane imports this module (and the chart
12964
+ * store), so a static import would close that loop. */
12965
+ function rearmWrunLiveTick(chartIndex, indicatorId) {
11284
12966
  void loadWrunLiveTickModule()
11285
12967
  .then((tick) => {
11286
12968
  const rearm = readOptionalExport(() => tick.rearmWrunLiveTickDrain);
@@ -11420,7 +13102,7 @@ function dropWrunPrefixRequest(chartIndex, indicatorId, tag, why) {
11420
13102
  if (!pendingHere && why !== 'covered' && !replaced)
11421
13103
  return;
11422
13104
  ringWrunPrefix('wrun-prefix-run-dropped', { chartIndex, indicatorId, requestId: tag.requestId, reason: why });
11423
- rearmWrunLiveTickAfterPrefix(chartIndex, indicatorId);
13105
+ rearmWrunLiveTick(chartIndex, indicatorId);
11424
13106
  }
11425
13107
  /**
11426
13108
  * A rejected prefix's full run (C1 v3), for the surviving owner only: the session the prefix was
@@ -11428,12 +13110,14 @@ function dropWrunPrefixRequest(chartIndex, indicatorId, tag, why) {
11428
13110
  * queued as a full pan wave. A newer plan that took the owner is queued already (it replans when it
11429
13111
  * starts), and a newer session's run computed the rows it stands on. True when queued.
11430
13112
  */
11431
- function queueWrunPrefixFallbackRun(indicatorId, context, requestId, fallback) {
13113
+ function queueWrunPrefixFallbackRun(indicatorId, context, requestId, fallback, gestureHeldMs = 0) {
11432
13114
  if (getWrunOverlayLiveContext(indicatorId) !== context || context.prefixOwner?.requestId !== requestId)
11433
13115
  return false;
11434
13116
  const work = rerunWrunOverlayForChartWave(indicatorId, {
11435
13117
  reason: 'lazy-range-refresh',
11436
13118
  ...(fallback ? { window: fallback } : {}),
13119
+ // One ceiling per episode (WRUN-PANBACK A1): the whole run holds only what the page left of it.
13120
+ ...(gestureHeldMs > 0 ? { gestureHeldMs } : {}),
11437
13121
  });
11438
13122
  return work !== undefined;
11439
13123
  }
@@ -11576,13 +13260,16 @@ function wrunPrefixBatchedGapRows(mountedMetas, context, sheet, child, childId,
11576
13260
  * reconcile). Packed only: the session the candidate rules admitted rode it, and a decline hands
11577
13261
  * the page to the full run.
11578
13262
  */
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,
13263
+ async function fetchWrunPrefixBookRows(context, meta, fromTs, toTs, meter,
13264
+ // A pinned book (U9e) asks its own market under its own lane id, with its own recorded acquisition.
13265
+ lane = 'book') {
13266
+ const { preferPackedOrderbookWorker: _packed, ...acquisition } = (context.acquisition[lane] ?? {});
13267
+ 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
13268
  // The full run stamped the legend; a prefix page never restamps it.
11583
13269
  { preferPackedOrderbookWorker: true, silentLegend: true, meter }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun prefix source fetch 'orderbook' for '${context.fetchKey}'`);
13270
+ // The page's book keeps the worker's block, as the whole run's does (WRUN-PANBACK-2 S2).
11584
13271
  if (isPackedOhlcvRows(fetched))
11585
- return unpackOhlcvRows(fetched);
13272
+ return wrunPackedLaneRows('orderbook', fetched, context);
11586
13273
  if (Array.isArray(fetched))
11587
13274
  return fetched;
11588
13275
  throw new Error('the packed orderbook lane declined the prefix window');
@@ -11629,11 +13316,25 @@ function wrunPrefixDegradedPageDetail(lane, outcome) {
11629
13316
  * asks the days before its buffer from its lookback before the page (none when the buffer reaches back that far), an
11630
13317
  * asked row lane the page's host bars through the lane's own host-grid read; each degrades on an empty answer only
11631
13318
  * 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).
13319
+ * whole run's older bars do). A trades leg on the chart's own grid (wrun-prefix-lanes.util `planWrunPrefixLanes`,
13320
+ * WRUN-PANBACK C) asks its market over the page with the request the whole run asks it with (wrun-trades-lane.util
13321
+ * `planWrunTradeLegAsk`: its payload extras, `pinnedMarket` among them) under its own fetch key
13322
+ * (`<fetchKey>-prefix-<lane id>`), quiet like the whole run's leg; a leg the planner asks at a tier on the chart now
13323
+ * declines the page (a page asks no tier).
11633
13324
  */
11634
- async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata, meter) {
13325
+ export async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata, meter) {
11635
13326
  const pages = new Map();
11636
- if (plan.builtin.length === 0 && plan.poll.length === 0 && plan.daily.length === 0 && plan.rows.length === 0) {
13327
+ // A page's own fetches take one signal, before the page's awaits, bound to the chart's dataset.
13328
+ const prefixLaneSignal = wrunLaneFetchSignal(context.indicatorId, {
13329
+ chartIndex: context.chartIndex,
13330
+ generation: getChartDataFetchGeneration(context.chartIndex),
13331
+ });
13332
+ if (plan.builtin.length === 0 &&
13333
+ plan.legs.length === 0 &&
13334
+ plan.pinned.length === 0 &&
13335
+ plan.poll.length === 0 &&
13336
+ plan.daily.length === 0 &&
13337
+ plan.rows.length === 0) {
11637
13338
  return { pages };
11638
13339
  }
11639
13340
  const toTs = beforeTs - 1;
@@ -11677,6 +13378,35 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
11677
13378
  return required ? refuseEmpty(type, rows) : rows;
11678
13379
  };
11679
13380
  }
13381
+ // A trades leg on the chart's own grid: its market over the page, the whole run's request (`planWrunTradeLegAsk` on
13382
+ // 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
13383
+ // now (the chart's grid moved under the plan) declines the page: a tier ask is the whole run's.
13384
+ thunks.tradeLegs = plan.legs.map((lane) => {
13385
+ const run = async () => {
13386
+ const legAsk = planWrunTradeLegAsk(lane, { intervalMs: context.intervalMs, venue: chartMetadata }, { fromMs, toMs: toTs });
13387
+ if (legAsk === undefined || legAsk.tier !== null) {
13388
+ throw new WrunLaneEmptyAnswer('declined', `the ${lane} source lane is asked at a tier on the chart now`);
13389
+ }
13390
+ return ask(legAsk.type, lane, legAsk.extras, undefined, { fromTs: legAsk.fromMs, toTs: legAsk.toMs });
13391
+ };
13392
+ return [lane, run];
13393
+ });
13394
+ // A pinned lane (U9e): its market over the page with the session's recorded acquisition under its own key
13395
+ // (`<fetchKey>-prefix-<lane id>`), quiet like the whole run's (a required funding lane's empty page degrades); a pinned
13396
+ // book through the packed worker its whole run rode (a decline is no page), as the chart's own book's page.
13397
+ thunks.pinnedLanes = plan.pinned.map((lane) => {
13398
+ const run = async () => {
13399
+ const pinned = wrunPinnedLaneOf(lane);
13400
+ if (pinned.cls === 'book')
13401
+ return fetchWrunPrefixBookRows(context, meta, fromMs, toTs, meter, lane);
13402
+ const { type } = WRUN_PINNED_LANE_SPECS[pinned.cls];
13403
+ const rows = await ask(type, lane, context.acquisition[lane] ?? wrunPinnedLaneExtras(lane));
13404
+ return pinned.cls === 'funding' && wrunFundingLaneRequired(context.metadata, lane)
13405
+ ? refuseEmpty(type, rows)
13406
+ : rows;
13407
+ };
13408
+ return [lane, run];
13409
+ });
11680
13410
  // A lane's own fetch (a relay feed) over a window, whole only when it says so (`onComplete`).
11681
13411
  const ownPage = async (fetch, kType, extras, window) => {
11682
13412
  let whole;
@@ -11688,6 +13418,7 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
11688
13418
  onComplete: (complete) => {
11689
13419
  whole = complete;
11690
13420
  },
13421
+ signal: prefixLaneSignal,
11691
13422
  }), WRUN_SOURCE_FETCH_DEADLINE_MS, deadlineLabel(kType)), kType);
11692
13423
  if (whole !== true) {
11693
13424
  throw new WrunLaneEmptyAnswer('declined', `the ${kType} source answered the page short of its end`);
@@ -11754,7 +13485,7 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
11754
13485
  barOpens: liveBucketStartsInRange(fromMs, toTs, context.intervalMs, barGrid),
11755
13486
  intervalMs: context.intervalMs,
11756
13487
  barGrid,
11757
- nowMs: Date.now(),
13488
+ nowMs: serverNowMs(),
11758
13489
  };
11759
13490
  thunks.rowLanes = plan.rows.map((instance) => {
11760
13491
  const run = async () => {
@@ -12101,7 +13832,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12101
13832
  const store = useChartStore();
12102
13833
  const chartMetadata = store.mergedAllCharts[chartIndex]?.metadata;
12103
13834
  // 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).
13835
+ // session's chart has none); a page builds a same-grid trades leg only (`planWrunPrefixLanes`, 2026-11-01); pinned legs stay refused.
12105
13836
  const formingBarTs = context.replay !== true && wrunLandsLegsOnBars(context.pinnedLegs, Object.keys(context.tradeLegRows ?? {}))
12106
13837
  ? await wrunFormingBarTsOf(chartIndex, context.intervalMs, chartMetadata)
12107
13838
  : null;
@@ -12143,6 +13874,9 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12143
13874
  }
12144
13875
  const warmSession = isWrunWarmAdmission(admission);
12145
13876
  const warmupBars = warmSession ? admission.bars : 0;
13877
+ // A converging session's tolerance (STAMPS round A): the page's own head is held to the gaps rule below and its
13878
+ // overlap proof compares the row outputs within it; an exact session has none and is proven as it always was.
13879
+ const convergingTolerance = warmSession ? admission.tolerance : undefined;
12146
13880
  let headRows = [];
12147
13881
  let head;
12148
13882
  if (warmSession) {
@@ -12163,6 +13897,18 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12163
13897
  warmupRows: 0,
12164
13898
  });
12165
13899
  }
13900
+ // A converging page's running start must hold W ACCEPTED inputs (the gaps rule the admission holds the session's
13901
+ // held head to; once this page lands, its head is that held head): a head candle with a field that is not finite
13902
+ // would leave the page's first rows short of the bound, and the overlap proof never reads them. The data's, never
13903
+ // the module's: no latch, the full run follows.
13904
+ const gapAt = convergingTolerance !== undefined ? wrunWarmupHeadGapAt(acquired.rows) : undefined;
13905
+ if (gapAt !== undefined) {
13906
+ return wrunPrefixRejected('warmup-gaps', `the running start holds a candle field that is not finite at ${gapAt}`, {
13907
+ firstMismatchTs: null,
13908
+ warmupBars,
13909
+ warmupRows: acquired.rows.length,
13910
+ });
13911
+ }
12166
13912
  head = acquired;
12167
13913
  headRows = acquired.rows;
12168
13914
  if (headRows.length > 0)
@@ -12192,7 +13938,14 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12192
13938
  return wrunPrefixRejected('stale', lanePages.degraded);
12193
13939
  const laneWindow = wrunPrefixFeedWindowLanes(context, lanePlan, lanePages.pages, firstRowTs, window.toMs);
12194
13940
  const chartExchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : undefined;
12195
- const clock = { intervalMs: context.intervalMs, nowMs: Date.now() };
13941
+ // The session's as-of beside the page's now (wrun-history-as-of.util): the lanes rule admits no declared depth into a
13942
+ // page today (`lanes:legs`, `tape-history`), so it splits nothing, and a page that one day reads one counts it back
13943
+ // from the session's instant, as the whole run it stands in for does.
13944
+ const clock = {
13945
+ intervalMs: context.intervalMs,
13946
+ nowMs: serverNowMs(),
13947
+ historyAsOfMs: context.historyAsOfMs,
13948
+ };
12196
13949
  const sourceRows = {
12197
13950
  ohlcvRows: windowRows,
12198
13951
  ...(bookRows !== undefined ? { bookRows } : {}),
@@ -12205,8 +13958,15 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12205
13958
  venue: wrunBarVenueOf(chartMetadata, clock.intervalMs),
12206
13959
  formingBarTs,
12207
13960
  };
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);
13961
+ // Only the row builder sees the head: the canvases' rows and every landing read the window's own. A page is every
13962
+ // bar before the session's first row, so the host session's composition (wrun-session-composition.util) answers
13963
+ // its OpenMarket rows there; it is read here all the same, so no read point of the lanes skips it.
13964
+ const rows = buildWrunInputRows(context.metadata, composeWrunSessionSources({
13965
+ chartIndex: context.chartIndex,
13966
+ indicatorId: context.indicatorId,
13967
+ intervalMs: clock.intervalMs,
13968
+ lanes: wrunSessionLanesOfContext(context),
13969
+ }, headRows.length > 0 ? { ...sourceRows, ohlcvRows: computeRows } : sourceRows).sources, clock);
12210
13970
  if (rows.length === 0)
12211
13971
  return wrunPrefixRejected('stale', 'the window holds no input rows');
12212
13972
  // An exact warm-up session's evaluated candles, fingerprinted in the same synchronous block as the guest's input
@@ -12248,7 +14008,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12248
14008
  title: runTarget.title,
12249
14009
  params: paramValues,
12250
14010
  texts: wrunTextParamValuesFromSettings(sheetNow, meta.settings),
12251
- legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
14011
+ legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, undefined, context.cmeDelayed),
12252
14012
  position: runTarget.position,
12253
14013
  axis: runTarget.axis ?? true,
12254
14014
  colors: runTarget.colors,
@@ -12263,6 +14023,8 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12263
14023
  ...withPriceTick(hostFill.tickSize),
12264
14024
  ...withCanvasHostFill(wrunSessionCanvasFillOf(context)),
12265
14025
  overlayId: indicatorId,
14026
+ // The words the full run's integrate names a built-in port's lines by, so the landed window reads the same.
14027
+ builtIn: builtinPortOf(meta.settings),
12266
14028
  };
12267
14029
  let runResult = buildWrunOverlayRunResult(resultOptions);
12268
14030
  if (runResult.failureReason !== undefined)
@@ -12389,6 +14151,21 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
12389
14151
  ...(warmup !== undefined
12390
14152
  ? { candleEvidence: { warmupBars, prefix: warmup.evaluated, mounted: context.candleEvidence } }
12391
14153
  : {}),
14154
+ // The one place a converging session hands its tolerance over (STAMPS round A): the row outputs alone compare
14155
+ // within it, every selector column (an output any `*_by` or `*_where` field, a `where` gate, `badges` or a hover
14156
+ // block's `output` names, and a barcolor output, on the stamped sheet or the one the settings paint) exactly, and
14157
+ // so does everything else the proof reads.
14158
+ ...(convergingTolerance !== undefined
14159
+ ? {
14160
+ outputTolerance: {
14161
+ tolerance: convergingTolerance,
14162
+ exactColumns: new Set([
14163
+ ...wrunHistoryStampExactColumns(context.metadata),
14164
+ ...wrunHistoryStampExactColumns(sheetNow),
14165
+ ]),
14166
+ },
14167
+ }
14168
+ : {}),
12392
14169
  });
12393
14170
  // Whether the mounted rows over the overlap may rest on inputs the session's buffers no longer hold (a lane row a
12394
14171
  // reconcile revised since they were computed, an owed reseed, a chain snapshot stamped inside it): no mismatch there
@@ -12651,9 +14428,10 @@ function wrunPrefixStaleReason(prepared, tc, meta, chartOwner, indicatorId) {
12651
14428
  * the same way, each prepared heatmap landing, and the session extended (its first row, its rows
12652
14429
  * and book prefixed, its lanes' start, its window gone, the owner landed). A failure after the
12653
14430
  * parent applied puts the overlay's own rows back (an owner-scoped rollback) and the landings that
12654
- * did not commit are discarded.
14431
+ * did not commit are discarded. `beforeApply` runs right before the first chart write, once every validation passed
14432
+ * (the install ring, WRUN-PANBACK A1).
12655
14433
  */
12656
- function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
14434
+ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId, beforeApply) {
12657
14435
  const commitStartedAt = wrunHostClockMs();
12658
14436
  const stale = wrunPrefixStaleReason(prepared, tc, meta, chartOwner, indicatorId);
12659
14437
  if (stale !== null) {
@@ -12712,6 +14490,7 @@ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
12712
14490
  };
12713
14491
  const span = { fromMs: window.fromMs, toMs: window.toMs };
12714
14492
  let parentApplied = false;
14493
+ beforeApply?.();
12715
14494
  try {
12716
14495
  withWrunOverlayExecutionMeasure(chartIndex, indicatorId, 'wrun-integrate', () => {
12717
14496
  const refresh = wrunChartHostEnv().chart.refreshMountedRows({
@@ -12828,6 +14607,8 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12828
14607
  const landings = [];
12829
14608
  let prepared;
12830
14609
  let outcome;
14610
+ // How long the page held for the gesture (WRUN-PANBACK A1): a whole run it falls back to holds only the rest.
14611
+ let gestureHeldMs = 0;
12831
14612
  try {
12832
14613
  const ready = await prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt, computed);
12833
14614
  if (ready.kind === 'rejected') {
@@ -12835,12 +14616,29 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12835
14616
  }
12836
14617
  else {
12837
14618
  prepared = ready;
12838
- outcome = await withWrunOverlaySessionLock(indicatorId, () => {
14619
+ // The page waits for the gesture's idle edge before the session lock, then commits synchronously at the grant
14620
+ // (a gesture that started again while the lock waited holds it again outside the lock, while the budget lasts).
14621
+ const reason = runTarget.reason ?? 'loaded-range-refresh';
14622
+ const committed = await commitWrunPrefixAtGestureEdge(chartIndex, indicatorId, reason, { ceilingMs: wrunInstallGestureCeilingMs(runTarget.gestureHeldMs) }, (heldMs, pacedMs) => {
14623
+ gestureHeldMs = heldMs;
12839
14624
  // A CME chart study's page lands only under the authorisation its head captured (a refusal here goes to the
12840
14625
  // full run, which judges the wall again).
12841
14626
  assertWrunCmeStudyAuthCurrent(computed, indicatorId);
12842
- return commitWrunPrefixRun(ready, tc, meta, owner, indicatorId);
14627
+ return commitWrunPrefixRun(ready, tc, meta, owner, indicatorId, () => ringWrunInstallApplied(chartIndex, indicatorId, reason, heldMs, pacedMs));
12843
14628
  });
14629
+ if (committed.kind === 'committed') {
14630
+ outcome = committed.value;
14631
+ }
14632
+ else {
14633
+ // A user run queued during the hold replaces the session: the page is dropped as superseded, quietly (no full
14634
+ // run follows it), and the queued run proceeds.
14635
+ gestureHeldMs = committed.heldMs;
14636
+ wrunChartHostEnv().diagnostics.debug('wrun-install-yielded', { chartIndex, indicatorId, reason });
14637
+ outcome = wrunPrefixRejected('stale', 'a run a person asked for is queued (yielded at the gesture hold)', {
14638
+ firstMismatchTs: null,
14639
+ quiet: true,
14640
+ });
14641
+ }
12844
14642
  }
12845
14643
  }
12846
14644
  catch (error) {
@@ -12883,9 +14681,9 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12883
14681
  });
12884
14682
  }
12885
14683
  if (!outcome.quiet && context !== undefined) {
12886
- queueWrunPrefixFallbackRun(indicatorId, context, window.prefix.requestId, window.prefix.fallback);
14684
+ queueWrunPrefixFallbackRun(indicatorId, context, window.prefix.requestId, window.prefix.fallback, (runTarget.gestureHeldMs ?? 0) + gestureHeldMs);
12887
14685
  }
12888
- rearmWrunLiveTickAfterPrefix(chartIndex, indicatorId);
14686
+ rearmWrunLiveTick(chartIndex, indicatorId);
12889
14687
  return;
12890
14688
  }
12891
14689
  if (wrunChartHostEnv().diagnostics.debugEnabled()) {
@@ -12911,7 +14709,7 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12911
14709
  : {}),
12912
14710
  });
12913
14711
  }
12914
- rearmWrunLiveTickAfterPrefix(chartIndex, indicatorId);
14712
+ rearmWrunLiveTick(chartIndex, indicatorId);
12915
14713
  if (prepared === undefined)
12916
14714
  return;
12917
14715
  // One apply sample for the host's main-thread work, the full run's integrate's rule (G3a).
@@ -12935,6 +14733,17 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
12935
14733
  catch (error) {
12936
14734
  console.warn(`[wrun] run health after a prefix run failed for '${indicatorId}':`, error);
12937
14735
  }
14736
+ // The viewer's nothing-drawn note over the session's rows with the older bars (FB27), held for the warm-up ask
14737
+ // below like a full run's: a page it buys reruns the overlay first.
14738
+ const warmupPage = wrunWarmupPageVerdict();
14739
+ await publishWrunNothingDrawn(chartIndex, indicatorId, {
14740
+ draft: context.draft === true,
14741
+ settled: context.window?.partial !== true && wrunSessionSourceAbsent.get(context) !== true,
14742
+ metadata: sheetNow,
14743
+ rows: context.outputRows,
14744
+ drawings: wrunHandlesOf(context.outputRows)?.length,
14745
+ runIntervalMs: context.intervalMs,
14746
+ }, () => refusal.ctx, { warmup: warmupPage, isCurrent: () => isWrunRunMountOnChart(chartIndex, { tc, meta }) });
12938
14747
  const chartInterval = typeof prepared.chartMetadata?.interval === 'string' ? prepared.chartMetadata.interval : '';
12939
14748
  askWrunWarmupBackfillIfOwed({
12940
14749
  chartIndex,
@@ -12957,12 +14766,29 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
12957
14766
  lookbackBars: wrunTwinLookbackBars(meta.settings) ?? (await wrunTwinOriginalLookbackBars(meta.settings, context.intervalMs)),
12958
14767
  unsettledLanes: new Set(),
12959
14768
  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
- },
14769
+ // Where the history the session read begins: every lane its acquisitions name and every leg, from its first row.
14770
+ historySources: { lanes: wrunSessionHistoryLanesOf(context), askedFromMs: context.firstRowTs },
14771
+ onNoPage: warmupPage.noPage,
14772
+ });
14773
+ }
14774
+ /** A session's lanes (its acquisitions name each) and legs, with the rows it keeps by lane id; a built-in lane names
14775
+ * no reach, so it reads as unknown whatever its buffer holds. */
14776
+ function wrunSessionHistoryLanesOf(context) {
14777
+ const lanes = Object.keys(context.acquisition).map((lane) => ({
14778
+ lane,
14779
+ rows: isWrunRowLaneId(lane)
14780
+ ? context.rowLaneRows?.[lane]
14781
+ : isWrunTradesLegLane(lane)
14782
+ ? context.tradeLegRows?.[lane]
14783
+ : isWrunPinnedLaneId(lane)
14784
+ ? context.pinnedLaneRows?.[lane]
14785
+ : context.pollLaneRows?.[lane],
14786
+ }));
14787
+ return wrunRunHistoryLanesOf({
14788
+ lanes,
14789
+ rowLanes: context.rowLanes ?? [],
14790
+ pollLanes: context.pollLanes ?? [],
14791
+ legs: context.pinnedLegs ?? [],
14792
+ legRows: (fetchKey) => context.pinnedCandleRows?.[fetchKey] ?? context.intrabarRows?.[fetchKey],
12967
14793
  });
12968
14794
  }