@orangecharts/wrun-chart-host 0.8.0 → 0.10.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 (246) hide show
  1. package/README.md +3 -1
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +86 -16
  4. package/dist/constants/marketCapabilities.constants.d.ts +14 -9
  5. package/dist/constants/marketCapabilities.constants.js +36 -13
  6. package/dist/constants/opra-compliance.constants.d.ts +15 -0
  7. package/dist/constants/opra-compliance.constants.js +15 -0
  8. package/dist/constants/option-venues.constants.d.ts +11 -6
  9. package/dist/constants/option-venues.constants.js +5 -2
  10. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  11. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  12. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  13. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  14. package/dist/constants/venue-presets.constants.d.ts +20 -20
  15. package/dist/constants/venue-presets.constants.js +24 -26
  16. package/dist/host-env.d.ts +39 -9
  17. package/dist/host-env.js +6 -0
  18. package/dist/host-ports.types.d.ts +108 -18
  19. package/dist/index.d.ts +14 -0
  20. package/dist/index.js +14 -0
  21. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  22. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  23. package/dist/interfaces/opra-realtime.interface.js +10 -10
  24. package/dist/interfaces/replay.interface.d.ts +8 -0
  25. package/dist/interfaces/wrun-runtime.interface.d.ts +52 -15
  26. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +94 -14
  27. package/dist/kscript-data/controls/live-trades-merge.util.js +132 -22
  28. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
  29. package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
  30. package/dist/market-data/billing.interface.d.ts +227 -42
  31. package/dist/market-data/billing.interface.js +60 -12
  32. package/dist/market-data/venue.d.ts +88 -6
  33. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  34. package/dist/market-data/venues/cme.d.ts +126 -0
  35. package/dist/market-data/venues/cme.js +133 -0
  36. package/dist/market-data/venues/index.d.ts +165 -8
  37. package/dist/market-data/venues/index.js +48 -6
  38. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  39. package/dist/market-data/venues/opra.d.ts +3 -3
  40. package/dist/market-data/venues/opra.js +5 -4
  41. package/dist/replay/replayLadder.js +3 -1
  42. package/dist/settings-templates/index.js +7 -3
  43. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  44. package/dist/settings-templates/indicator-fields.js +45 -6
  45. package/dist/settings-templates/tool-rules.d.ts +27 -17
  46. package/dist/settings-templates/tool-rules.js +27 -11
  47. package/dist/settings-templates/tool-tables.generated.js +91 -31
  48. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  49. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  50. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  51. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  52. package/dist/utility/chart/index-mode-admission.util.js +24 -3
  53. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  54. package/dist/utility/chart/index-mode.util.js +23 -13
  55. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  56. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  57. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
  58. package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
  59. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  60. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  61. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  62. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  63. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -27
  64. package/dist/utility/chart/kscript-venue-policy.util.js +74 -32
  65. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  66. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  67. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  68. package/dist/utility/chart/marketKind.util.js +17 -7
  69. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  70. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  71. package/dist/utility/chart/om-panel.util.js +6 -6
  72. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  73. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  74. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  75. package/dist/utility/chart/profile-block-size.util.js +7 -0
  76. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  77. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  78. package/dist/utility/chart/rth-session.util.d.ts +3 -2
  79. package/dist/utility/chart/rth-session.util.js +2 -1
  80. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  81. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  82. package/dist/utility/chart/wrun-run-result.util.d.ts +17 -0
  83. package/dist/utility/chart/wrun-run-result.util.js +145 -7
  84. package/dist/utility/common/transformations.util.d.ts +7 -0
  85. package/dist/utility/common/transformations.util.js +11 -0
  86. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  87. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  88. package/dist/utility/options/option-venue.util.d.ts +21 -3
  89. package/dist/utility/options/option-venue.util.js +30 -3
  90. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  91. package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
  92. package/dist/utility/wrun/derived-roots.util.js +471 -0
  93. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
  94. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  95. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  96. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  97. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +5 -3
  98. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +6 -4
  99. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  100. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  101. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  102. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  103. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  104. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  105. package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
  106. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  107. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  108. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +15 -6
  109. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -0
  110. package/dist/utility/wrun/sources/row-lanes/option_prints.js +82 -13
  111. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  112. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -8
  113. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +95 -14
  114. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
  115. package/dist/utility/wrun/sources/row-lanes/option_surface.js +7 -3
  116. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  117. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +35 -14
  118. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +70 -20
  119. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
  120. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
  121. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +45 -1
  122. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +114 -6
  123. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +56 -5
  124. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +224 -26
  125. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +822 -58
  126. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  127. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  128. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  129. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  130. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  131. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  132. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  133. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  134. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  135. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +192 -13
  136. package/dist/utility/wrun/wrun-chart-market-facts.util.js +437 -55
  137. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  138. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  139. package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
  140. package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
  141. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  142. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  143. package/dist/utility/wrun/wrun-download-meter.util.d.ts +107 -0
  144. package/dist/utility/wrun/wrun-download-meter.util.js +134 -0
  145. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  146. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  147. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  148. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  149. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
  150. package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
  151. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  152. package/dist/utility/wrun/wrun-frames.js +78 -15
  153. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  154. package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
  155. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  156. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  157. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +51 -21
  158. package/dist/utility/wrun/wrun-hud-looks.util.js +74 -28
  159. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  160. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  161. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  162. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  163. package/dist/utility/wrun/wrun-live-intake.util.d.ts +19 -9
  164. package/dist/utility/wrun/wrun-live-intake.util.js +213 -45
  165. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
  166. package/dist/utility/wrun/wrun-live-tick.util.js +246 -49
  167. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  168. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  169. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +205 -48
  170. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +277 -34
  171. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
  172. package/dist/utility/wrun/wrun-market-size-defaults.util.js +340 -56
  173. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  174. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  175. package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
  176. package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
  177. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  178. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  179. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +26 -6
  180. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +50 -11
  181. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +109 -19
  182. package/dist/utility/wrun/wrun-option-strike-flow.util.js +222 -61
  183. package/dist/utility/wrun/wrun-option-views.util.d.ts +96 -18
  184. package/dist/utility/wrun/wrun-option-views.util.js +246 -51
  185. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  186. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  187. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  188. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  189. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +20 -0
  190. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  191. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  192. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  193. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  194. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
  195. package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
  196. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  197. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  198. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +134 -37
  199. package/dist/utility/wrun/wrun-overlay-run.util.js +1118 -254
  200. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
  201. package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
  202. package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
  203. package/dist/utility/wrun/wrun-pack.util.js +20 -9
  204. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  205. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  206. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  207. package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
  208. package/dist/utility/wrun/wrun-panel-style.util.d.ts +37 -24
  209. package/dist/utility/wrun/wrun-panel-style.util.js +100 -29
  210. package/dist/utility/wrun/wrun-param-map.util.d.ts +15 -11
  211. package/dist/utility/wrun/wrun-param-map.util.js +13 -5
  212. package/dist/utility/wrun/wrun-param-values.util.d.ts +21 -3
  213. package/dist/utility/wrun/wrun-param-values.util.js +6 -0
  214. package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
  215. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  216. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  217. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  218. package/dist/utility/wrun/wrun-refusal.util.js +10 -1
  219. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  220. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  221. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  222. package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
  223. package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
  224. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +52 -1
  225. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  226. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  227. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  228. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  229. package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
  230. package/dist/utility/wrun/wrun-source-rows.util.d.ts +9 -1
  231. package/dist/utility/wrun/wrun-source-rows.util.js +108 -43
  232. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  233. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  234. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  235. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  236. package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
  237. package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
  238. package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
  239. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  240. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  241. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  242. package/dist/utils/replay/replay-buffer-math.js +227 -20
  243. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  244. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  245. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  246. package/package.json +5 -5
@@ -107,9 +107,9 @@ import { scheduleWrunLaneGroups } from './run-schedule/wrun-lane-groups.util.js'
107
107
  import { serveWrunOwnCandles } from './run-schedule/wrun-own-candles.util.js';
108
108
  import { wrunPollClassReadsChain, wrunRowClassReadsChain } from './run-schedule/wrun-gate-reader-warm.util.js';
109
109
  import { wrunPollLaneByKey, wrunPollLanesOfClass } from './sources/registry.js';
110
- import { wrunRowLaneByKey, wrunRowLaneOfClass } from './sources/row-lane-registry.js';
110
+ import { wrunRowLaneByKey, wrunRowLaneOfClass, wrunRowLanes } from './sources/row-lane-registry.js';
111
111
  import { isWrunRowLaneId } from './sources/wrun-row-lane.types.js';
112
- import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, wrunRunSourceReachFromMs, } from './sources/wrun-row-lanes.util.js';
112
+ import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneAddKey, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, wrunRowLanesReplayBounded, wrunRunSourceReachFromMs, } from './sources/wrun-row-lanes.util.js';
113
113
  import { wrunOpraLanePayloadFields } from './wrun-opra-lane.util.js';
114
114
  import { WRUN_LANE_REFUSED_SETTLE_REASON, wrunLaneRefusedCodeOf } from './wrun-lane-refusal.leaf.js';
115
115
  import { TRADES_HISTORY_MAX_CELLS } from '../../kscript-data/controls/live-trades-merge.util.js';
@@ -118,7 +118,7 @@ import { liveBucketStartsInRange, liveBucketVenueOf } from '../chart/live-bucket
118
118
  import { hostBucketResolverFor } from '../chart/host-bar-placement.util.js';
119
119
  import { indexHostFetchTierMs, sourceRowsStraddleHostBars } from '../chart/index-host-tier.util.js';
120
120
  import { isWrunPollLaneId, wrunPollCoinGateSeed, } from './sources/wrun-poll-lane.types.js';
121
- import { fetchWrunPollLaneHostGridRows, planWrunPollLanes, wrunLaneRowsRequired, wrunPollLaneChainAsk, wrunPollLaneFetchFrom, wrunPollLaneFetchOptions, wrunPollLaneFetchTo, wrunPollLaneInstanceReadsOpra, wrunPollLaneRequired, wrunPollLaneValuelessInput, } from './sources/wrun-poll-lanes.util.js';
121
+ import { fetchWrunPollLaneHostGridRows, planWrunPollLanes, resolveWrunOptionSettingKnobs, wrunChainLaneContext, wrunLaneRowsRequired, wrunPollLaneChainAsk, wrunPollLaneFetchFrom, wrunPollLaneFetchOptions, wrunPollLaneFetchTo, wrunPollLaneInstanceReadsOpra, wrunPollLaneRequired, wrunPollLaneValuelessInput, } from './sources/wrun-poll-lanes.util.js';
122
122
  import { wrunDailyLaneFetchFrom, wrunDailyLaneFetchTo } from './wrun-daily-lane.util.js';
123
123
  import { assertWrunEtfFlowCoin, planWrunEtfFlowColumns, planWrunEtfFlowLane, resolveWrunEtfFlowTickers, WRUN_ETF_FLOW_INTERVAL_KEY, wrunEtfFlowAnswer, zipWrunEtfFlowRows, } from './wrun-etf-flow-lane.util.js';
124
124
  import { planWrunOptionSummaryLane, WRUN_OPTION_SUMMARY_LANES, wrunOptionSummaryAskExtras, wrunOptionSummaryAskKey, zipWrunOptionSummaryRows, } from './wrun-option-summary-lane.util.js';
@@ -138,7 +138,7 @@ import { wrunOiLaneExtras } from './wrun-oi-lane.util.js';
138
138
  import { WRUN_LEG_STREAM_CLASSES, isWrunLegStreamClass, wrunLegStreamPayloadWords } from './wrun-leg-stream-classes.js';
139
139
  import { isWrunTradesLegLane, WRUN_TRADES_LANES, wrunTradesLegExtras, wrunTradesLegOf, } from './wrun-trades-lane.util.js';
140
140
  import { substituteWrunChartNames, wrunChartContextHostFill, wrunChartIntervalMsOf, } from './wrun-chart-context.util.js';
141
- import { warmWrunMarketFacts, wrunChartSizeUnit, wrunLaneDemandNeedsDirectory, wrunMarketFactsFor, wrunMarketFactsNeedDirectory, wrunReadsMarketFacts, wrunCoinLegsOf, wrunCoinLegVenues, wrunSheetWithCoinLegs, wrunSheetWithLaneCurrencies, wrunSheetWithLaneDemand, wrunSheetWithLaneGate, } from './wrun-chart-market-facts.util.js';
141
+ 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';
142
142
  import { wrunFollowsCoin, wrunInputGateOn, wrunRowVisibleHere } from './wrun-market-facts.util.js';
143
143
  import { wrunRowsKeepingMarketDefaults } from './wrun-market-size-defaults.leaf.js';
144
144
  import { reconcileWrunMarketSizeDefaults } from './wrun-market-size-defaults.util.js';
@@ -156,6 +156,9 @@ import { wrunTextParamsForRun, wrunTextParamValuesFromSettings } from './wrun-te
156
156
  import { wrunSheetWithSettings, wrunVisibilityOwnedOutputs } from './wrun-color-settings.util.js';
157
157
  import { wrunSheetDrawsOnlyStatsStrip, wrunStatsStripSettings } from './wrun-stats-strip.util.js';
158
158
  import { planWrunHeldLanes } from './wrun-held-lanes.util.js';
159
+ import { createWrunDownloadMeter, wrunDownloadAnswerSize, } from './wrun-download-meter.util.js';
160
+ import { createWrunLaneDownloadMeter, wrunDownloadKitInterval, wrunDownloadMarketOf, wrunDownloadPlanKeyOf, wrunDownloadPlanReadBytes, wrunRunDownloadMode, wrunRunDownloadReads, } from './wrun-download-plan.util.js';
161
+ import { FeatureFlag } from '../../constants/feature-flags.constants.js';
159
162
  import { clearedColorCustomizationFlags } from '../chart/color-customization.leaf.js';
160
163
  import { WRUN_LATEST_HISTORY_LENGTH } from './wrun-latest-history.leaf.js';
161
164
  import { resolveChartPricePrecision } from '../chart/price-precision.util.js';
@@ -166,36 +169,40 @@ import { kScriptSettingsRevision } from '../chart/kscript-settings-revision.leaf
166
169
  import { getChartMountEpoch } from '../chart/chart-mount-epoch.util.js';
167
170
  import { checkIsIndexMode } from '../chart/index-mode.util.js';
168
171
  import { checkIsCryptoIndex } from '../chart/crypto-index.leaf.js';
172
+ import { checkIsQuotePerp } from '../chart/quote-perp.leaf.js';
169
173
  import { buildMixedModeContext, getFirstTokenMode } from '../chart/mixed-mode.util.js';
170
174
  import { inferPriceTickFromRows } from '../chart/footprint-band.util.js';
171
175
  import { getMarketKind } from '../chart/marketKind.util.js';
172
176
  import { isCmeGoverned } from '../chart/cme-realtime.util.js';
173
- import { wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
174
- import { assertWrunPinnedLegVenues, partitionWrunLegsByVenue, wrunLegFetchedRowReaders, wrunLegRidesNativeRows, wrunPinnedLegRefusalOf, wrunPinVenueVerdict, } from './wrun-pin-venues.util.js';
177
+ import { wrunBarSessionFactsResolver, wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
178
+ import { wrunPresentIsPartial } from './wrun-present-bits.util.js';
179
+ import { assertWrunPinnedLegVenues, partitionWrunLegsByVenue, wrunLegFetchedRowReaders, wrunLegRidesNativeRows, wrunPinMarketsOf, wrunPinnedLegRefusalOf, wrunPinVenueVerdict, } from './wrun-pin-venues.util.js';
175
180
  import { annotateWrunErrorFailureRow, annotateWrunErrorIndicatorId, isWrunOverlayPausedError, isWrunQuarantinedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunDeadlineError, WrunIntegrationError, WrunNoBarsError, WrunOverlayPausedError, WrunSourceDataUnavailableError, WrunVenueBlockedError, } from './wrun-registry-errors.util.js';
176
181
  import { createKScriptVenueBlockedError, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptCandidate, isOpraUserScriptRun, payloadTouchesOpraVenue, } from '../chart/kscript-venue-policy.util.js';
177
- import { OPRA_UNDERLYING_EXCHANGES } from '../../constants/option-venues.constants.js';
182
+ import { isOpraUserScriptsFlagOn } from '../chart/opra-user-scripts-gate.util.js';
178
183
  import { governedMarketDataTier, governedOptionSummaryTier } from '../v2/governed-tier.leaf.js';
179
184
  import { awaitWrunChildOverlays, mountWrunChildOverlays, prepareWrunHeatmapWindowLanding, WrunStaleLandingError, } from './wrun-panel-mount.util.js';
180
185
  import { planWrunFormingPreRoll, planWrunIntrabarLegFetch, planWrunLegFetch, wrunClampedLegDiagnostics, wrunIntrabarServedNotes, wrunLegFetchReads, } from './wrun-leg-fetch.util.js';
181
186
  import { barEndMs, isCalendarIntervalLabel, isCalendarIntervalMs } from '../chart/calendar-interval.util.js';
182
- import { resolveWrunTapeAcquisition, WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE, WRUN_TAPE_TOO_MANY_TRADES_CODE, wrunTapeFloorSettingWords, wrunTapeFloorSettings, } from './wrun-tape-source.util.js';
187
+ 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';
183
188
  import { wrunChartSession, wrunLegCandleClose, wrunPrimaryRowBounds } from './wrun-leg-close.util.js';
184
189
  import { isWrunRowSourceTransientError, wrunRowBatchDeliveredSheet, wrunRowSourceSettingsLeftBy, } from './wrun-row-source.js';
185
190
  import { wrunOverlayOpraStamped } from './wrun-cloud-opra-stamp.util.js';
191
+ // The run's one options market (the row lanes' planner holds the module on this graph already).
192
+ import { decideWrunRunOptionsMarket, noteWrunRunOptionsMarket, wrunDecidedOptionsExchange, } from './derived-roots.util.js';
186
193
  import { wrunRowSourceFor } from './wrun-row-source-factory.js';
187
194
  import { __resetWrunSocketSessionLossesForTests, noteWrunSocketSessionLoss, wrunSocketSessionLossCause, wrunSocketSessionLossCount, } from './wrun-socket-session-losses.util.js';
188
195
  import { isWrunRunMountOnChart, raiseWrunSandboxLoading, wrunRowBatchCellRows, } from './wrun-sandbox-row-source.js';
189
196
  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';
190
197
  import { ringWrunRunRetained, wrunChartWalkedRows, wrunRetainedCanvasSources, wrunRunBlockRowsCap, wrunRunRetainedHeadFits, wrunRunRetainedRowsCap, wrunRunRetainedWindowOf, } from './wrun-run-retained.util.js';
191
- import { isWrunOptionsChainCryptoVenueWord, WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, WRUN_OPTIONS_CHAIN_VENUE_CODE, wrunOptionsChainExpiries, wrunOptionsChainIdentityKey, wrunOptionsChainLaneExtras, wrunOptionsChainLaneScope, wrunOptionsChainOneVenueRefusal, } from './wrun-options-chain.util.js';
198
+ 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';
192
199
  import { adoptWrunLiveIntakeGeneration, markWrunLiveGap, noteWrunLiveIntakeEvent, wrunPushEligible, } from './wrun-live-intake.util.js';
193
200
  import { openWrunPollLaneLiveChannels } from './wrun-series-stream.util.js';
194
201
  import { serverNowMs } from '../auth/server-clock.util.js';
195
202
  import { aggregateOhlcvRows } from '../../utils/replay/replay-buffer-math.js';
196
203
  import { isWrunReplayRunCurrent, noteWrunReplayRun, wrunReplayRunPlanOf, } from './wrun-replay-lane.util.js';
197
204
  import { cutWrunReplayRowsAfterApply } from './wrun-replay-rows.util.js';
198
- import { builtinTwinOf } from './wrun-builtin-twin.util.js';
205
+ import { builtinPortOf } from './wrun-builtin-twin.util.js';
199
206
  import { WRUN_HISTORY_WARMUP_MAX_BARS, wrunDeclaredWarmupBars, wrunDeclaredWarmupEndTs, wrunHistoryWarmupBars, } from './wrun-declared-warmup.util.js';
200
207
  import { wrunLaneWarmupBars, wrunLaneWarmupFromMs } from './wrun-lane-warmup.util.js';
201
208
  import { orderWrunFirstRunHistory } from './wrun-first-run-depth.util.js';
@@ -206,9 +213,21 @@ import { attachWrunLive, wrunLiveOf, } from '../../interfaces/wrun-runtime.inter
206
213
  import { normalizeRuntimeDiagnostics, shouldNoticeWrunRefusal, WRUN_RUN_FAILURE_ROW_CODES, WRUN_RUN_TIMEOUT_CODE, wrunAbortRuntimeDiagnostic, wrunRunFailureRuntimeDiagnostic, } from '../scriptEditor/wrun-runtime-diagnostics.leaf.js';
207
214
  import { buildWrunOverlayRunResult, withCanvasHostFill, } from './wrun-overlay-result.util.js';
208
215
  import { applyWrunIntegrationBudgetPolicy, wrunIntegratedRowsView } from './wrun-integration-budget.util.js';
209
- import { cmeOptionsContract } from '../options/cme-options-root.util.js';
210
216
  // The result build lives in wrun-overlay-result.util (the result reader core); its importers keep this path.
211
217
  export { buildWrunOverlayRunResult };
218
+ /**
219
+ * The chart market's units a result build reads, together: its size unit (`wrunChartSizeUnit`: an output whose
220
+ * `visible_by` leaves it out mounts nothing) and its dollar unit when proven (`wrunMarketDollarUnit`: the CME registry's
221
+ * point value of the contract, NQ 20; 1 on crypto and US stocks), which the batched marks' `units` caption and hover
222
+ * divide a record's dollar value by. Synchronous over the facts the run head warmed. Every build spreads it (the full
223
+ * run, the row-source run, the reseed, the refine, the prefix landing and the live tick), so a tail or a reseed never
224
+ * hands the children a size unit without the dollar unit: a tail without it would re-register the hover in dollars.
225
+ * tests/utility/wrun/wrun-big-trades-size-shown-as.spec.ts fails on a build that names a size unit by hand.
226
+ */
227
+ export function wrunResultMarketUnits(market) {
228
+ const dollars = wrunMarketDollarUnit(market);
229
+ return { sizeUnit: wrunChartSizeUnit(market), ...(dollars.kind === 'dollars' ? { valuePerUnit: dollars.unit } : {}) };
230
+ }
212
231
  // The integration budget's pure policy lives in wrun-integration-budget.util; its view keeps this path too.
213
232
  export { wrunIntegratedRowsView };
214
233
  /** The number of closed bars whose evaluated OHLCV the context retains for
@@ -365,6 +384,14 @@ export async function runWrunOverlayOnChart(target) {
365
384
  // reports it as not applied.
366
385
  const computed = { generation: 0, stage: 'head' };
367
386
  let integrated = false;
387
+ // The run's download (its meter, once its window made one) goes to the add's open attempt once, when the run ends.
388
+ let downloadNoted = false;
389
+ const noteDownload = () => {
390
+ if (downloadNoted || !attempt || computed.download === undefined)
391
+ return;
392
+ downloadNoted = true;
393
+ wrunChartHostEnv().diagnostics.noteAttemptDownload(attempt, computed.download.summary());
394
+ };
368
395
  // The run is still the overlay's own: the chart and the overlay it computed for stand, and the
369
396
  // attempt it resolved is still the live one (a teardown, a restore or a later request retires it).
370
397
  const isCurrent = () => mount.tc !== undefined &&
@@ -432,30 +459,43 @@ export async function runWrunOverlayOnChart(target) {
432
459
  chartMetadata,
433
460
  });
434
461
  const provenance = meta.settings;
435
- // A run the `opra-user-scripts` flag may open the OPRA plane to (a browser run the viewer wrote or
436
- // added) waits, bounded, for the flag map before either OPRA wall reads it, where one can: on an OPRA
437
- // chart (the display wall), or a chain read on a US stock or ETF chart (the chain wall). A restore can
438
- // run before the map hydrates, and an unhydrated map reads closed with no retry for this run; any other
439
- // market never waits on the map. A run reading options that list on OPRA waits the same way for the
440
- // `opra` flag the plane and its stop reasons are judged by (FE-REASON-CHIPS review): unhydrated, the
441
- // map would read the plane closed and the lanes "not on your account".
462
+ // The run's console provenance, captured before anything computes (`computed.opra`): a run on an OPRA contract
463
+ // chart reads OPRA candles whatever its lanes read.
464
+ if (payloadTouchesOpraVenue(chartExchange))
465
+ computed.opra = true;
466
+ // A run reading options decides its ONE options market here (derived-roots.util `decideWrunRunOptionsMarket`):
467
+ // where the options list on OPRA (a stock, an OPRA contract, a known stock twin) or the overlay's last read was
468
+ // OPRA's (its provenance stamp), it waits, bounded, for the `opra` flag the plane and its stop reasons are judged
469
+ // by (FE-REASON-CHIPS review): a restore can run before the map hydrates, and unhydrated, the map would read the
470
+ // plane closed and the lanes "not on your account". Under a lit flag (or the stamp) it waits, bounded, for the
471
+ // chart's stock twin answer, so a twin restored before its answer reads its stock's OPRA chain; then the market,
472
+ // its plane and its stop are read once, and every planner, the options chain lane, the download plan and the host
473
+ // fill of this run read that decision (a run never mixes planes; a later twin answer reruns it).
442
474
  const readsOpraOptions = target.metadata.inputs.some((input) => target.metadata.inputSources[input.name]?.source === 'options_chain') ||
443
475
  wrunSheetReadsOpraLane(target.metadata);
444
- const opraWallAhead = payloadTouchesOpraVenue(chartExchange) ||
445
- (typeof chartExchange === 'string' && OPRA_UNDERLYING_EXCHANGES.includes(chartExchange) && readsOpraOptions);
446
- if (readsOpraOptions || opraWallAhead) {
447
- const opraGate = await wrunChartHostEnv().market.loadOptionsGate();
448
- const waitsOpra = readsOpraOptions &&
449
- opraGate.opraFlagDecidesChartOptions({
450
- exchange: typeof chartExchange === 'string' ? chartExchange : undefined,
451
- });
452
- const waitsUserScripts = opraWallAhead && isOpraUserScriptCandidate(provenance);
453
- if (waitsOpra || waitsUserScripts) {
454
- await Promise.all([
455
- waitsOpra ? opraGate.awaitOpraFlagHydration() : undefined,
456
- waitsUserScripts ? opraGate.awaitOpraUserScriptsFlagHydration() : undefined,
457
- ]);
458
- }
476
+ // A run the `opra-user-scripts` flag may open the OPRA plane to (a browser run the viewer wrote or added) waits,
477
+ // bounded, for the flag map before an OPRA wall reads it, where one stands ahead: on an OPRA contract chart (the
478
+ // display wall), or where the run's options decision rides the OPRA plane (the chain wall: a US stock or ETF
479
+ // chart, a stock twin). A restore can run before the map hydrates, and an unhydrated map reads closed. The wait
480
+ // starts beside the options decision (both ride the one flag fetch); every other run never waits on the map.
481
+ const userScriptsHydration = isOpraUserScriptCandidate(provenance) && (payloadTouchesOpraVenue(chartExchange) || readsOpraOptions)
482
+ ? wrunChartHostEnv()
483
+ .market.loadOptionsGate()
484
+ .then(async (gate) => {
485
+ await gate.awaitOpraUserScriptsFlagHydration();
486
+ return gate;
487
+ })
488
+ .catch(() => undefined)
489
+ : undefined;
490
+ const options = readsOpraOptions
491
+ ? await decideWrunRunOptionsMarket(chartMetadata, wrunOverlayOpraStamped(meta))
492
+ : undefined;
493
+ if (userScriptsHydration !== undefined && (payloadTouchesOpraVenue(chartExchange) || options?.plane === 'opra')) {
494
+ const gate = await userScriptsHydration;
495
+ // The bound ran out with the flag still dark: the walls refuse this run now, and a flag that lands later judges
496
+ // the walled user-script overlays again (web: opra-options-gate.util `armOpraUserScriptsRejudge`).
497
+ if (!isOpraUserScriptsFlagOn())
498
+ gate?.armOpraUserScriptsRejudge?.();
459
499
  }
460
500
  if (isKScriptDisplayBlockedOnExchange(chartExchange, provenance)) {
461
501
  throw new WrunVenueBlockedError(createKScriptVenueBlockedError(String(chartExchange)).message);
@@ -522,14 +562,14 @@ export async function runWrunOverlayOnChart(target) {
522
562
  chartIndex: target.chartIndex,
523
563
  mountEpoch,
524
564
  tc,
525
- });
565
+ }, computed);
526
566
  }
527
567
  finally {
528
568
  hold.lower();
529
569
  }
530
570
  }
531
571
  else {
532
- await computeWrunOverlayOverLiveContext(marketTarget, (runTarget) => computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, computed, { chartIndex: target.chartIndex, mountEpoch, tc }, { chartMetadata, isCurrent, official, opraUserScripts }));
572
+ await computeWrunOverlayOverLiveContext(marketTarget, (runTarget) => computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, computed, { chartIndex: target.chartIndex, mountEpoch, tc }, { chartMetadata, isCurrent, official, opraUserScripts, ...(options !== undefined ? { options } : {}) }));
533
573
  }
534
574
  integrated = true;
535
575
  computed.stage = 'applied';
@@ -548,7 +588,13 @@ export async function runWrunOverlayOnChart(target) {
548
588
  // surfaceWrunRunFailureOnLegend): only a success clears it.
549
589
  void clearWrunRuntimeTrapDiagnostic(target.chartIndex, target.indicatorId);
550
590
  }
551
- wrunChartHostEnv().diagnostics.settleAttempt(attempt, { ok: true });
591
+ // The run's download joins the add's before the settle reads it (a first slice's older asks are still out).
592
+ noteDownload();
593
+ // A first-slice picture settles the attempt too (the time to the first result), and says it was one.
594
+ wrunChartHostEnv().diagnostics.settleAttempt(attempt, {
595
+ ok: true,
596
+ ...(computed.firstSlice === true ? { firstSlice: true } : {}),
597
+ });
552
598
  }
553
599
  catch (rejection) {
554
600
  // What the run computed for, judged now (C4): a run its overlay's own newer intent superseded (a
@@ -597,6 +643,8 @@ export async function runWrunOverlayOnChart(target) {
597
643
  // cell cap's too-big) settles `refused` with its class, as the lane row reads it. A dropped run
598
644
  // settles nothing (C4): the attempt stays live for the run that replaces it, and a mount that
599
645
  // leaves settles it `cancelled` (the removal's abandon, the loader's first-run settle).
646
+ // A dropped run's download counts toward the add too: the run that replaces it settles the attempt.
647
+ noteDownload();
600
648
  if (!(error instanceof WrunChartGoneError))
601
649
  wrunChartHostEnv().diagnostics.settleAttempt(attempt, { ok: false, error });
602
650
  if (sourceHold) {
@@ -607,6 +655,7 @@ export async function runWrunOverlayOnChart(target) {
607
655
  else {
608
656
  await surfaceWrunRunFailureOnLegend(target.chartIndex, target.indicatorId, error, {
609
657
  outputNames,
658
+ opra: computed.opra === true,
610
659
  refusalContext: refusal.ctx,
611
660
  token: refusalAttempt,
612
661
  isCurrent,
@@ -791,8 +840,9 @@ export async function surfaceWrunRunFailureOnLegend(chartIndex, indicatorId, err
791
840
  const trap = wrunRuntimeTrapDiagnostic(error, context);
792
841
  if (trap && WRUN_RUN_FAILURE_ROW_CODES.has(trap.code)) {
793
842
  // The write waits on the store's module, so the rejection can outrun it: it rides the error, and the
794
- // editor's Run awaits it before it reads the row (wrunErrorFailureRowWritten).
795
- const written = publishWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, trap);
843
+ // editor's Run awaits it before it reads the row (wrunErrorFailureRowWritten). The author's abort text can
844
+ // carry what the run computed: a run over OPRA data marks the row (every console export strips it).
845
+ const written = publishWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, context.opra === true ? { ...trap, opra: true } : trap);
796
846
  annotateWrunErrorFailureRow(error, written);
797
847
  await written;
798
848
  if (isCurrent())
@@ -927,6 +977,12 @@ const WRUN_CRYPTO_VENUE_KINDS = new Set(['crypto', 'dex', 'hip3', 'hip4']);
927
977
  /** Whether a sheet reads, or may read, an OPRA source lane: a poll lane's `opra`, a row lane's `governed: 'opra'`, a
928
978
  * chain lane of either kind (its chain lists on OPRA on a US stock or OPRA contract chart). The run head's flag wait,
929
979
  * the OPRA-plane predicate a lane's admission and wall read, and the OPRA provenance writer follow it. */
980
+ /** Whether a pin names a market on the OPRA plane: any market its `exchange|symbol` names (a literal pin is one). */
981
+ function wrunPinReadsOpra(market) {
982
+ if (market === undefined)
983
+ return false;
984
+ return wrunPinMarketsOf(market.exchange ?? '', market.symbol ?? '').some((leg) => payloadTouchesOpraVenue(leg.exchange));
985
+ }
930
986
  function wrunSheetReadsOpraLane(metadata) {
931
987
  return wrunPollPlanReadsChain(metadata) || wrunRowPlanReadsChain(metadata);
932
988
  }
@@ -969,17 +1025,20 @@ function mergeWrunLanePlans(a, b) {
969
1025
  };
970
1026
  }
971
1027
  /** The OPRA-plane predicate an OPRA lane's admission reads (`governedOptionPlane(metadata) === 'opra'`: a US stock or
972
- * ETF chart under either venue spelling while the `opra` flag is lit, an OPRA contract chart) and, beside it, the
973
- * known reason a chart whose options list on OPRA is off the plane (`opraOptionPlaneStop`: the flag check's `flag-off`,
974
- * the plane router's `chart-kind`), which the planners' notes and refusals say instead of "no such feed here". Loaded
975
- * only when the sheet reads such a lane (the gate module reaches the flag store). */
976
- async function wrunOpraPlaneFacts(metadata) {
1028
+ * ETF chart under either venue spelling while the `opra` flag is lit, an OPRA contract chart, a stock twin reading its
1029
+ * stock's chain) and, beside it, the known reason a chart whose options list on OPRA is off the plane
1030
+ * (`opraOptionPlaneStop`: the flag check's `flag-off`, the plane router's `chart-kind`), which the planners' notes and
1031
+ * refusals say instead of "no such feed here". Both judge a market by its exchange and symbol: the run's own chart
1032
+ * market reads the run's one decision (`options`, the head's), never the seam again, and any other market is judged
1033
+ * through the gate. Loaded only when the sheet reads such a lane (the gate module reaches the flag store). */
1034
+ async function wrunOpraPlaneFacts(metadata, options) {
977
1035
  if (!wrunSheetReadsOpraLane(metadata))
978
1036
  return undefined;
979
1037
  const { governedOptionPlane, opraOptionPlaneStop } = await wrunChartHostEnv().market.loadOptionsGate();
1038
+ const decided = (exchange, symbol) => options !== undefined && (options.chart.exchange ?? '') === exchange && (options.chart.symbol ?? '') === symbol;
980
1039
  return {
981
- isOpraPlaneExchange: (exchange) => governedOptionPlane({ exchange }) === 'opra',
982
- opraPlaneStop: (exchange) => opraOptionPlaneStop({ exchange }),
1040
+ isOpraPlaneExchange: (exchange, symbol) => decided(exchange, symbol) ? options?.plane === 'opra' : governedOptionPlane({ exchange, symbol }) === 'opra',
1041
+ opraPlaneStop: (exchange, symbol) => decided(exchange, symbol) ? options?.opraStop : opraOptionPlaneStop({ exchange, symbol }),
983
1042
  };
984
1043
  }
985
1044
  export function isWrunCryptoVenueExchange(exchange) {
@@ -1098,13 +1157,257 @@ function wrunSeededRefusal(seed, details, ctx, stamp) {
1098
1157
  const raised = attachWrunRefusal(new Error(details), seed);
1099
1158
  return wrunRefusalFor(stamp === undefined ? raised : stampWrunRefusalTelemetry(raised, stamp), ctx);
1100
1159
  }
1101
- /** The note rows a run owns (its legs, its health, its skipped draw calls, its respelled pins): a failed run drops
1102
- * them with its verdict. */
1160
+ /** A row lane's read its row budget cut (`onBudgetCut`, wrun-row-lanes.util): the newest bars that fit read whole,
1161
+ * the older ones partial, so the run drew fewer bars of that lane than the chart shows. */
1162
+ export const WRUN_ROW_BUDGET_CUT_CODE = 'WRUN_ROW_BUDGET_CUT';
1163
+ /** The rows the run seam owns for its row budget cuts: replaced by every full run, cleared by a run that cut nothing. */
1164
+ export const WRUN_ROW_BUDGET_ROW_CODES = new Set([WRUN_ROW_BUDGET_CUT_CODE]);
1165
+ /** The legend's localized sentence of a cut over its facts (`{ n }`, the bars kept, its plural choice). */
1166
+ export const WRUN_ROW_BUDGET_CUT_NOTE_KEY = 'wrun.rowBudget.cut';
1167
+ /**
1168
+ * The legend note rows of a run's row budget cuts, one per row lane instance its budget cut: warnings in the run-owned
1169
+ * set `WRUN_ROW_BUDGET_ROW_CODES`, `message` the technical words (Copy details, the console), `details` the facts the
1170
+ * legend's sentence reads (`WRUN_ROW_BUDGET_CUT_NOTE_KEY`: `{ n }`) beside the lane and the cut. A note, never a
1171
+ * refusal: the run drew its newest bars, and without it a package that drew 30 bars of a long chart (Strike
1172
+ * Footprint) said nothing about why. Empty for no cut, which is what clears the rows of an earlier run.
1173
+ */
1174
+ export function wrunRowBudgetCutDiagnostics(cuts) {
1175
+ return [...cuts].map((cut) => ({
1176
+ stage: 'compute',
1177
+ severity: 'warning',
1178
+ code: WRUN_ROW_BUDGET_CUT_CODE,
1179
+ type: 'execution',
1180
+ message: `Row lane '${cut.laneKey}' kept the newest ${cut.keptBars} bars inside its read budget (${cut.maxRows} rows); ` +
1181
+ `${cut.cutBars} older bars read partial, with no cells`,
1182
+ details: {
1183
+ feed: cut.laneKey,
1184
+ n: cut.keptBars,
1185
+ cutBars: cut.cutBars,
1186
+ maxRows: cut.maxRows,
1187
+ ...(cut.keptFromTs !== undefined ? { keptFromTs: cut.keptFromTs } : {}),
1188
+ },
1189
+ }));
1190
+ }
1191
+ /** The indicator download budget's two chips (OPTLOAD W3 R2), the source chip family's run-owned codes
1192
+ * (kscript-source-degrade.util `FE_SOURCE_TRIMMED_CODE`, `FE_SOURCE_HEAVY_CODE`, spelled here because the package
1193
+ * names no web module; tests/utility/wrun/wrun-overlay-run.download-budget.spec.ts pins them equal): replaced by every
1194
+ * full run, cleared by a run that kept its budget. */
1195
+ export const WRUN_DOWNLOAD_TRIMMED_CODE = 'FE_SOURCE_TRIMMED';
1196
+ export const WRUN_DOWNLOAD_HEAVY_CODE = 'FE_SOURCE_HEAVY';
1197
+ export const WRUN_DOWNLOAD_BUDGET_ROW_CODES = new Set([
1198
+ WRUN_DOWNLOAD_TRIMMED_CODE,
1199
+ WRUN_DOWNLOAD_HEAVY_CODE,
1200
+ ]);
1201
+ /** Bytes as the download chips write them, 1,000,000 a MB: "1 MB", "1.2 MB", "17 MB". */
1202
+ export function wrunDownloadMbText(bytes) {
1203
+ const mb = Math.max(0, bytes) / 1_000_000;
1204
+ const text = mb >= 10 ? String(Math.round(mb)) : String(Math.round(mb * 10) / 10);
1205
+ return `${text} MB`;
1206
+ }
1207
+ /** A bar's stamp as the trimmed chip names it, on the UTC clock: "2026-10-22 14:00 UTC". */
1208
+ function wrunDownloadDateText(ts) {
1209
+ const iso = new Date(ts).toISOString();
1210
+ return `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
1211
+ }
1212
+ /**
1213
+ * The download budget's legend rows of one full run (R2), info rows in the run-owned set
1214
+ * `WRUN_DOWNLOAD_BUDGET_ROW_CODES`, still text in the source chip family's coverage group (never a spinner, never a
1215
+ * toast; runtime-diagnostics.util words them from `details`, the feeds by `feedKeys` where a lane has feed words):
1216
+ * - `FE_SOURCE_TRIMMED` ("Newest bars only"), when the budget cut a read: the feeds it cut, the oldest bar all of them
1217
+ * still read (`date`, `keptFromTs`: the newest of the cuts' oldest kept bars) and the budget;
1218
+ * - `FE_SOURCE_HEAVY` ("Large download"), when the run downloaded more than its budget and cut nothing (one snapshot):
1219
+ * the feed that downloaded the most, the size and the budget.
1220
+ * Empty with the flag off, or for a run that kept its budget: what clears an earlier run's rows.
1221
+ */
1222
+ export function wrunDownloadBudgetDiagnostics(args) {
1223
+ if (!args.on)
1224
+ return [];
1225
+ const cuts = [...args.cuts].filter((cut) => cut.budget === 'download' && cut.cutBars > 0);
1226
+ const feedFacts = (feeds) => ({
1227
+ feeds: feeds.map((feed) => feed.label).join(', '),
1228
+ feedKeys: feeds.map((feed) => feed.key ?? feed.label),
1229
+ });
1230
+ if (cuts.length > 0) {
1231
+ const named = new Map(cuts.map((cut) => [cut.laneKey, args.feedOf(cut.laneKey)]));
1232
+ const facts = feedFacts([...named.values()]);
1233
+ const kept = cuts.flatMap((cut) => (cut.keptFromTs !== undefined ? [cut.keptFromTs] : []));
1234
+ const keptFromTs = kept.length > 0 ? Math.max(...kept) : undefined;
1235
+ const cutBars = cuts.reduce((sum, cut) => sum + cut.cutBars, 0);
1236
+ const budgetText = wrunDownloadMbText(args.summary?.budgetBytes ?? 1_000_000);
1237
+ return [
1238
+ {
1239
+ stage: 'fetch',
1240
+ severity: 'info',
1241
+ code: WRUN_DOWNLOAD_TRIMMED_CODE,
1242
+ type: 'execution',
1243
+ message: `${facts.feeds}: ${cutBars} older bars were not loaded` +
1244
+ (keptFromTs !== undefined ? ` (before ${wrunDownloadDateText(keptFromTs)})` : '') +
1245
+ `; loading them would download more than the ${budgetText} one indicator may`,
1246
+ details: {
1247
+ ...facts,
1248
+ budget: budgetText,
1249
+ cutBars,
1250
+ ...(keptFromTs !== undefined ? { keptFromTs, date: wrunDownloadDateText(keptFromTs) } : {}),
1251
+ },
1252
+ },
1253
+ ];
1254
+ }
1255
+ const summary = args.summary;
1256
+ if (summary === undefined || !summary.over)
1257
+ return [];
1258
+ const facts = feedFacts([args.feedOf(summary.topSource ?? '')]);
1259
+ const size = wrunDownloadMbText(summary.bytes);
1260
+ const budgetText = wrunDownloadMbText(summary.budgetBytes);
1261
+ return [
1262
+ {
1263
+ stage: 'fetch',
1264
+ severity: 'info',
1265
+ code: WRUN_DOWNLOAD_HEAVY_CODE,
1266
+ type: 'execution',
1267
+ message: `${facts.feeds} downloaded ${size}, more than the ${budgetText} one indicator should`,
1268
+ details: { ...facts, size, budget: budgetText, bytes: summary.bytes },
1269
+ },
1270
+ ];
1271
+ }
1272
+ /** A feed as the download chips name it: a row lane's (by its key, or the K type it asks) label and feed words (the i18n
1273
+ * key the legend says it in), else the source type in words ("orderbook", "volume profile"). */
1274
+ function wrunDownloadFeedOf(laneKeyOrType) {
1275
+ const lane = wrunRowLaneByKey(laneKeyOrType) ?? wrunRowLanes().find((row) => row.kType === laneKeyOrType);
1276
+ if (lane !== undefined)
1277
+ return { label: lane.label, ...(lane.feedWords !== undefined ? { key: lane.feedWords } : {}) };
1278
+ return { label: laneKeyOrType === '' ? 'sources' : laneKeyOrType.replace(/_/g, ' ') };
1279
+ }
1280
+ /** Whether the download budget's cut is on (`FeatureFlag.WrunDownloadBudgetCut`); a host whose flag store is not up
1281
+ * reads off. */
1282
+ export function wrunDownloadBudgetCutOn() {
1283
+ try {
1284
+ return wrunChartHostEnv().user.isFeatureOn(FeatureFlag.WrunDownloadBudgetCut);
1285
+ }
1286
+ catch {
1287
+ return false;
1288
+ }
1289
+ }
1290
+ /** The chart's own celled classes (the row builder's, not a row lane's): history reads the plan shares the budget with,
1291
+ * asked whole for now (the order-flow templates keep their named exceptions; docs/features/kscript/wrun/
1292
+ * wrun-browser-runtime.md, "The download budget"). */
1293
+ const WRUN_DOWNLOAD_BUILTIN_HISTORY_CLASSES = new Set([
1294
+ 'book',
1295
+ 'volume_profile',
1296
+ 'tape',
1297
+ 'intrabar',
1298
+ 'trade_volume_by_size',
1299
+ ]);
1300
+ /**
1301
+ * The run's download plan before any fetch (R2, wrun-download-plan.util): the reads of every input the market demands,
1302
+ * priced with the kit's rule on the run's window and market; a read whose lane forecasts a browser fold
1303
+ * (`WrunRowLaneDescriptor.download.forecastBytes`, FE-FOLD-CAP) priced at the fold's contract rows beside its declared
1304
+ * read, against the chain the chart's options list on (a CME chart's own exchange, the OPRA plane's on a US stock or
1305
+ * ETF chart and on a stock twin reading its stock's chain, a crypto venue's plain chain): the run head's one decision
1306
+ * (`options`) when it holds one, else the chart market judged through the gate. A forecast a refusal stops (an input
1307
+ * refused by name) prices nothing: the plan refuses it by name later.
1308
+ */
1309
+ async function planWrunRunDownload(args) {
1310
+ const { metadata, window, chart } = args;
1311
+ const inputs = [...metadata.inputs]
1312
+ .sort((a, b) => a.index - b.index)
1313
+ .filter((input) => {
1314
+ const source = metadata.inputSources[input.name];
1315
+ return source !== undefined && source.undemanded !== true && source.source !== 'time';
1316
+ });
1317
+ const reads = wrunRunDownloadReads(metadata, { fromMs: window.fromMs, toMs: window.toMs, intervalMs: window.intervalMs }, inputs.map((input) => input.name), (name) => args.paramValues[name]);
1318
+ const market = wrunDownloadMarketOf({ cme: chart.cme, indexMode: chart.indexMode });
1319
+ const priceWindow = { intervalMs: window.intervalMs, market };
1320
+ // The chain the chart's options list on, for a lane's fold forecast (read once, only when a lane forecasts).
1321
+ let chain;
1322
+ const chainOf = () => {
1323
+ chain ??= (async () => {
1324
+ if (chart.cme)
1325
+ return { chainExchange: chart.exchange, servedTier: governedMarketDataTier(chart.exchange) };
1326
+ const plane = args.options !== undefined
1327
+ ? args.options.plane
1328
+ : (await wrunChartHostEnv().market.loadOptionsGate()).governedOptionPlane({
1329
+ exchange: chart.exchange,
1330
+ symbol: chart.symbol,
1331
+ coin: chart.coin,
1332
+ });
1333
+ if (plane === 'opra')
1334
+ return { chainExchange: 'OPRA', servedTier: governedMarketDataTier('OPRA') };
1335
+ return chart.indexMode ? undefined : { chainExchange: chart.exchange };
1336
+ })();
1337
+ return chain;
1338
+ };
1339
+ const params = metadata.params ?? [];
1340
+ const planReads = [];
1341
+ for (const read of reads) {
1342
+ const lane = wrunRowLaneOfClass(read.class);
1343
+ const history = lane !== undefined ? lane.landing.kind !== 'latest' : WRUN_DOWNLOAD_BUILTIN_HISTORY_CLASSES.has(read.class);
1344
+ let projectedBytes;
1345
+ const forecast = lane?.download?.forecastBytes;
1346
+ const inputName = read.inputs[0];
1347
+ const source = inputName === undefined ? undefined : metadata.inputSources[inputName];
1348
+ if (forecast !== undefined && lane !== undefined && source !== undefined && inputName !== undefined) {
1349
+ try {
1350
+ const found = await chainOf();
1351
+ if (found !== undefined) {
1352
+ const chartCtx = {
1353
+ coin: chart.coin,
1354
+ exchange: chart.exchange,
1355
+ symbol: chart.symbol,
1356
+ ...(chart.category !== undefined ? { category: chart.category } : {}),
1357
+ intervalMs: window.intervalMs,
1358
+ inputName,
1359
+ sourceClass: lane.sourceClass,
1360
+ indexMode: chart.indexMode,
1361
+ cryptoVenue: isWrunCryptoVenueExchange(chart.exchange),
1362
+ official: args.facts.official,
1363
+ opraUserScripts: args.facts.opraUserScripts,
1364
+ };
1365
+ // A chain lane forecasts the chain its plan reads, under the run's one decision (a twin's stock by its ticker).
1366
+ const ctx = lane.chain !== undefined ? wrunChainLaneContext(chartCtx, args.options) : chartCtx;
1367
+ const resolved = resolveWrunOptionSettingKnobs(ctx, source, params, args.paramValues);
1368
+ const folded = await forecast(resolved, ctx, {
1369
+ chainExchange: found.chainExchange,
1370
+ coin: ctx.coin,
1371
+ ...(found.servedTier !== undefined ? { servedTier: found.servedTier } : {}),
1372
+ barOpens: window.barOpens,
1373
+ intervalMs: window.intervalMs,
1374
+ barGrid: window.barGrid,
1375
+ nowMs: window.nowMs,
1376
+ });
1377
+ if (folded !== undefined && folded > 0)
1378
+ projectedBytes = wrunDownloadPlanReadBytes(read, priceWindow) + folded;
1379
+ }
1380
+ }
1381
+ catch {
1382
+ // A knob refused by name prices nothing here: the lane's plan refuses the input by name.
1383
+ }
1384
+ }
1385
+ planReads.push({ ...read, history, ...(projectedBytes !== undefined ? { projectedBytes } : {}) });
1386
+ }
1387
+ const mode = wrunRunDownloadMode(planReads, { bars: args.windowBars, ...priceWindow });
1388
+ const keyOfInput = new Map();
1389
+ const barRows = new Map();
1390
+ const interval = wrunDownloadKitInterval(window.intervalMs);
1391
+ for (const read of planReads) {
1392
+ const key = wrunDownloadPlanKeyOf(read);
1393
+ for (const name of read.inputs)
1394
+ keyOfInput.set(name, key);
1395
+ const cost = wrunChartHostEnv().sharedHost().wrunDownloadReadCost(read, market, interval);
1396
+ const rows = cost.readsPerBar * cost.rowsPerRead;
1397
+ if (Number.isFinite(rows) && rows > 0)
1398
+ barRows.set(key, rows);
1399
+ }
1400
+ return { mode, keyOfInput, barRows };
1401
+ }
1402
+ /** The note rows a run owns (its legs, its health, its skipped draw calls, its respelled pins, its row budget cuts, its
1403
+ * download budget's chips): a failed run drops them with its verdict. */
1103
1404
  const WRUN_REFUSAL_NOTE_ROW_CODES = new Set([
1104
1405
  ...WRUN_LEG_ROW_CODES,
1105
1406
  ...WRUN_RUN_HEALTH_ROW_CODES,
1106
1407
  ...WRUN_DRAW_SKIPPED_ROW_CODES,
1107
1408
  ...WRUN_PIN_ROW_CODES,
1409
+ ...WRUN_ROW_BUDGET_ROW_CODES,
1410
+ ...WRUN_DOWNLOAD_BUDGET_ROW_CODES,
1108
1411
  ]);
1109
1412
  /** Whether an output shows on the chart as the settings paint it: the Style page's Visible row,
1110
1413
  * else the sheet's `visible`, the sheet alone for an output a boolean param owns (`owned`); a
@@ -1395,7 +1698,9 @@ const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1395
1698
  params: {
1396
1699
  max: TRADES_HISTORY_MAX_CELLS,
1397
1700
  setting: wrunTapeFloorSettingWords(metadata),
1398
- min: tape?.minSize ?? 0,
1701
+ // The floor in its own unit: the raw number under `min_size` (as it always was), a dollar amount under
1702
+ // `min_value` ($500,000).
1703
+ min: tape?.minValue === undefined ? (tape?.minSize ?? 0) : wrunTapeFloorWords(tape),
1399
1704
  n: tape === undefined ? 0 : Math.round((tape.historySeconds / 86_400) * 10) / 10,
1400
1705
  },
1401
1706
  out: { kind: 'open-settings' },
@@ -1789,6 +2094,32 @@ export function wrunSessionRespelledSheet(context, sheet, settings) {
1789
2094
  const pins = wrunSessionRespelledPins.get(context);
1790
2095
  return pins === undefined ? undefined : wrunSheetWithRespelledPins(wrunSheetWithSettings(sheet, settings), pins);
1791
2096
  }
2097
+ /**
2098
+ * The run head's refusal of a sheet that reads the market's dollar multiplier (kit 0.95.0) on a market whose dollar
2099
+ * unit is not proven (wrunMarketDollarUnit), by name and before any fetch: a unit no read can ever prove (no point
2100
+ * value for its contracts, a quote that is no dollar) reads as the dollar tape's own refusal does (`feed-missing`,
2101
+ * the market has no tape to value), and one a later read can still prove as a source that did not answer
2102
+ * (`service-no-answer`, Retry; the reads retry on their own windows), so the module never runs over a 0 it would
2103
+ * keep for the session.
2104
+ */
2105
+ function wrunDollarMultiplierRefusal(metadata, chartMetadata, unit, tape) {
2106
+ const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
2107
+ const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
2108
+ const param = metadata.params.find((candidate) => candidate.host_fill === WRUN_DOLLAR_MULTIPLIER_FILL)?.name;
2109
+ const why = unit.transient
2110
+ ? unit.reason === 'point-value'
2111
+ ? "the instrument registry's point value for it has not been read yet"
2112
+ : 'its quote has not been read yet'
2113
+ : unit.reason === 'point-value'
2114
+ ? 'no point value is known for its contracts'
2115
+ : 'it is not quoted in US dollars or a dollar stablecoin';
2116
+ // The tape's own feed where the run asks one (Big Trades), else the trades the fact values.
2117
+ const params = { feed: tape !== undefined ? 'tape' : 'trades' };
2118
+ return attachWrunRefusal(new Error(`WRUN ${metadata.id}: ${WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE}: param '${param ?? 'market_dollar_multiplier'}' ` +
2119
+ `reads market.dollar_multiplier() on ${exchange}:${symbol}, and ${why}, so no trade can be valued`), unit.transient
2120
+ ? { cls: 'service-no-answer', variant: 'lane', params, severity: 'paused' }
2121
+ : { cls: 'feed-missing', variant: 'market-paused', params, severity: 'paused' });
2122
+ }
1792
2123
  /**
1793
2124
  * The browser lane's lanes for one window, the sandbox row source's `prepare` (contract C7,
1794
2125
  * wrun-sandbox-row-source.ts): everything the run reads before the engine worker. The first run's
@@ -1820,6 +2151,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
1820
2151
  if (module === null) {
1821
2152
  throw new Error(`wrun overlay '${passTarget.indicatorId}': its row source holds no module for the browser lanes`);
1822
2153
  }
2154
+ // The browser computes this run under the head's one options market: the facts read beside it follow that decision.
2155
+ if (head.options !== undefined)
2156
+ noteWrunRunOptionsMarket(head.chartMetadata, head.options);
1823
2157
  await orderWrunFirstRunHistoryIfOwed(passTarget, tc, meta, head.chartMetadata, head.isCurrent);
1824
2158
  // The browser lanes read the overlay's own settings, never the record the source holds: a patch it
1825
2159
  // holds carries the same values (the pass derives it from them), and a paint-only save since it
@@ -1898,6 +2232,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
1898
2232
  if (chartRows.length === 0) {
1899
2233
  throw new WrunChartGoneError(`wrun overlay '${target.indicatorId}': its run window holds no chart rows (superseded)`);
1900
2234
  }
2235
+ // What the run downloads, from its first ask on, against the budget of its window's bars.
2236
+ const download = createWrunDownloadMeter(chartRows.length);
2237
+ computed.download = download;
1901
2238
  // The replay's completed chart bars (the head rows join the compute rows below).
1902
2239
  const replayChartRows = chartRows;
1903
2240
  // A clamped window short of the chart's newest bar is a page panned back
@@ -1929,6 +2266,43 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
1929
2266
  if (tape !== undefined) {
1930
2267
  await assertWrunTapeServedOnInterval(target.metadata, tape.inputNames[0], typeof chartMetadata?.interval === 'string' ? chartMetadata.interval : '');
1931
2268
  }
2269
+ // A dollar tape (C-DOLLAR) prices its live prints in its history's unit: the dollar unit of the market's own facts
2270
+ // (wrunMarketDollarUnit: a CME contract's registry point value, else the point value on a market quoted in dollars).
2271
+ // Its reads are the directory row's quote and the instrument registry's units, each waited on once
2272
+ // (warmWrunMarketDollarFacts never rejects). A unit no read can ever prove (a quote that is no dollar, a venue or a
2273
+ // contract with no point value) refuses the tape by name before any fetch, the daemon's `wrun_tape_value_unproven`:
2274
+ // none of its live prints could fold, so it never draws silently stopped. A unit a later read can still prove is
2275
+ // never frozen into the acquisition: the payload carries no `valuePerUnit`, and the live intake resolves it again on
2276
+ // its prints (wrun-live-intake.util `wrunTapeLiveFloorOf`).
2277
+ let tapeValuePerUnit;
2278
+ if (tape?.minValue !== undefined) {
2279
+ await warmWrunMarketDollarFacts(chartMetadata);
2280
+ const unit = wrunMarketDollarUnit(chartMetadata);
2281
+ tapeValuePerUnit = unit.kind === 'dollars' ? unit.unit : undefined;
2282
+ if (unit.kind === 'unproven' && !unit.transient) {
2283
+ const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
2284
+ const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
2285
+ const why = unit.reason === 'point-value'
2286
+ ? 'no point value is known for its contracts'
2287
+ : 'it is not quoted in US dollars or a dollar stablecoin';
2288
+ // The host's words lead with the code (`<code>: <sentence>`), as every host refusal reads.
2289
+ throw attachWrunRefusal(new Error(`WRUN ${target.metadata.id}: ${WRUN_TAPE_VALUE_UNPROVEN_CODE}: input '${tape.inputNames[0]}' (tape) floors ` +
2290
+ `${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' });
2291
+ }
2292
+ }
2293
+ // A package that reads the market's dollar multiplier (kit 0.95.0, `market.dollar_multiplier()`: Big Trades 0.8.0
2294
+ // values a CME contracts tape's fills with it) reads the same unit the dollar tape prices its live prints with and
2295
+ // the batched captions read (wrunMarketDollarUnit, wrunResultMarketUnits): one number for the module, the caption
2296
+ // and the hover. The module takes it once, at init(), so the run never computes over a unit it could not prove (0
2297
+ // values no trade): its reads are waited on here, a unit no read can ever prove refuses by name before any fetch,
2298
+ // and one a later read can still prove (a failed registry read, a continuous chart's lead not known yet) refuses as
2299
+ // a source that did not answer (retried, `service-no-answer`), never frozen into the session this run installs.
2300
+ if (wrunReadsDollarMultiplier(target.metadata)) {
2301
+ await warmWrunMarketDollarFacts(chartMetadata);
2302
+ const unit = wrunMarketDollarUnit(chartMetadata);
2303
+ if (unit.kind === 'unproven')
2304
+ throw wrunDollarMultiplierRefusal(target.metadata, chartMetadata, unit, tape);
2305
+ }
1932
2306
  // The market the run computes for: the integrate drops a result the chart moved off meanwhile.
1933
2307
  const marketIdentity = wrunChartMarketIdentity(chartMetadata);
1934
2308
  // A package that declares a fact the directory row answers (`market.kind()`,
@@ -2015,7 +2389,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2015
2389
  // before the chart's first bar ride the K_OHLCV lane the kScript engine fetches them on (a run at
2016
2390
  // another interval warms up on its run bars, the live rule).
2017
2391
  const replayHeadRows = replay && !run && replay.fromMs < chartRows[0][0]
2018
- ? await fetchWrunReplayHeadRows(target, view, replay.fromMs, chartRows[0][0])
2392
+ ? await fetchWrunReplayHeadRows(target, view, replay.fromMs, chartRows[0][0], download)
2019
2393
  : [];
2020
2394
  // Joined ahead of the chart's bars with their missing bars kept (a spread drops them).
2021
2395
  chartRows = wrunChartCandleRowsAfterHead(replayHeadRows, chartRows);
@@ -2114,9 +2488,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2114
2488
  // The run clock: the run interval when there is one (the venue facts, the host fill, the leg
2115
2489
  // plan, the poll plans and the push eligibility read it), else the chart's. A replay run's
2116
2490
  // `now` is the end its lanes are fetched through: every row's as-of read stays at its own close.
2491
+ // The now is the server's: the lanes plan their windows over the gateway's bars.
2117
2492
  const clock = {
2118
2493
  intervalMs: run ? run.intervalMs : chartIntervalMs,
2119
- nowMs: replay ? Math.min(Date.now(), Math.max(replay.toMs, chartLastTs + chartIntervalMs)) : Date.now(),
2494
+ nowMs: replay ? Math.min(serverNowMs(), Math.max(replay.toMs, chartLastTs + chartIntervalMs)) : serverNowMs(),
2120
2495
  };
2121
2496
  const { legs: plannedLegs, wires: plannedWires } = planWrunPinnedWires(target.metadata, clock.intervalMs);
2122
2497
  // The chart's head store for this run's first bar (wrun-warmup-head-store.util): one per chart, so every overlay
@@ -2157,6 +2532,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2157
2532
  intervalMs: chartIntervalMs,
2158
2533
  held: heldHeadsUsable ? heldContext.warmupHead : undefined,
2159
2534
  store: headStore,
2535
+ meter: download,
2160
2536
  }
2161
2537
  : undefined;
2162
2538
  // A chart whose candles are not asked as a plain time window (index mode, a mixed transformation) answers its exact
@@ -2184,6 +2560,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2184
2560
  beforeTs: chartFirstTs,
2185
2561
  held: heldHeadsUsable ? heldContext.laneWarmupHead : undefined,
2186
2562
  store: headStore,
2563
+ meter: download,
2187
2564
  }
2188
2565
  : undefined;
2189
2566
  const laneHeadTake = laneHeadArgs !== undefined
@@ -2241,8 +2618,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2241
2618
  // The run's OPRA facts reach every lane's plan (`ctx.official`, `ctx.opraUserScripts`): an OPRA lane is refused
2242
2619
  // by name before its plan for a run that may not read the plane (`mayReadOpra`, opra-official-only:<class>).
2243
2620
  // The OPRA-plane predicate an OPRA lane is admitted by (loaded only when the sheet reads one).
2244
- const opraPlaneFacts = wrunOpraPlaneFacts(target.metadata);
2621
+ const opraPlaneFacts = wrunOpraPlaneFacts(target.metadata, head.options);
2245
2622
  const opraFacts = { official: head.official, opraUserScripts: head.opraUserScripts };
2623
+ // Every chain lane plans under the head's one decision: its plane, and a stock twin's lane market (`head.options`).
2624
+ const runOptions = head.options;
2246
2625
  // The overlay's current setting values, read once for both planners: an option knob naming a setting
2247
2626
  // (`min_premium: "@floor"`) asks with the setting's value, and a settings change re-plans with the new one
2248
2627
  // (wrun-poll-lanes.util `resolveWrunOptionSettingKnobs`, before a poll lane's plan and a row lane's facets).
@@ -2258,7 +2637,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2258
2637
  symbol: pickText(chartMetadata?.symbol),
2259
2638
  category: chartMetadata?.category,
2260
2639
  intervalMs: clock.intervalMs,
2261
- }, checkIsIndexMode, isWrunCryptoVenueExchange, { ...opraFacts, ...(opraPlane !== undefined ? opraPlane : {}), paramValues: laneParamValues }));
2640
+ }, checkIsIndexMode, isWrunCryptoVenueExchange, {
2641
+ ...opraFacts,
2642
+ ...(opraPlane !== undefined ? opraPlane : {}),
2643
+ paramValues: laneParamValues,
2644
+ ...(runOptions !== undefined ? { options: runOptions } : {}),
2645
+ }));
2262
2646
  };
2263
2647
  // The row lanes' plan (sources/row-lane-registry.ts: one celled descriptor per class), before any of its fetches,
2264
2648
  // beside the poll lanes': the OPRA wall, the chart's admission (a governed OPRA lane where the chart's
@@ -2283,7 +2667,11 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2283
2667
  isCryptoVenueExchange: isWrunCryptoVenueExchange,
2284
2668
  isOpraPlaneExchange: opraPlane?.isOpraPlaneExchange,
2285
2669
  opraPlaneStop: opraPlane?.opraPlaneStop,
2286
- }, { ...opraFacts, paramValues: laneParamValues }));
2670
+ }, {
2671
+ ...opraFacts,
2672
+ paramValues: laneParamValues,
2673
+ ...(runOptions !== undefined ? { options: runOptions } : {}),
2674
+ }));
2287
2675
  };
2288
2676
  const pollPlannedLocal = planPollLanes(false);
2289
2677
  const rowPlannedLocal = planRowLanes(false);
@@ -2296,7 +2684,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2296
2684
  // The options_chain lane's identity (wrunOptionsChainLaneExtrasFor), decided before its own fetch like every plan:
2297
2685
  // a refusal by name fails the run, never reads as a degraded lane.
2298
2686
  const optionsChainPlanned = declaredClasses.has('options_chain')
2299
- ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts)
2687
+ ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts, laneParamValues, head.options)
2300
2688
  : Promise.resolve(undefined);
2301
2689
  // The OPRA provenance the native options overlays carry (`settings.metaExchange`, the field the chart read
2302
2690
  // withholds an overlay by and the tier moves refetch it by, options-overlay-provenance.util): every OPRA lane
@@ -2433,6 +2821,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2433
2821
  // bars (a grid leg, a trades leg) and opens a live session at the chart's newest bar: a leg's row still forming
2434
2822
  // past that bar lands in it. A replay, a clamped window and a run with no live session have none: their last bar
2435
2823
  // is closed.
2824
+ // A leg pinned to the OPRA plane (an option contract's candles or its trades: a run the flag opened the plane to may
2825
+ // pin one, and the dataFetch door admits it) reads OPRA data like the chart's own market would: the run's console
2826
+ // provenance from here (`computed.opra`), before anything computes. A soft-refused trades leg is never asked.
2827
+ if (legs.some((leg) => wrunPinReadsOpra(leg.market)) ||
2828
+ tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsOpra(wrunTradesLegOf(lane)))) {
2829
+ computed.opra = true;
2830
+ }
2436
2831
  const formingBarTs = live && replay === undefined && wrunLandsLegsOnBars(legs, tradeLegLanes)
2437
2832
  ? await wrunFormingBarTsOf(target.chartIndex, clock.intervalMs, chartMetadata)
2438
2833
  : null;
@@ -2449,6 +2844,91 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2449
2844
  // A replay run's lanes reach the window's end (the replay's forward runway, as the kScript
2450
2845
  // engine's sources do), so its steps read them without a fetch; its bars stop at the cutoff.
2451
2846
  const to = replay ? Math.max(chartLastTs, replay.toMs) : chartLastTs;
2847
+ // The download budget's plan (OPTLOAD W3 R2 and FE-FOLD-CAP, `planWrunRunDownload`), behind
2848
+ // `wrun-download-budget-cut` and decided before any lane fetch (`fetchLane` and the row lanes wait on it): at or under
2849
+ // the run's budget the run is whole, today's asks; over it, each history read takes its share and asks its newest
2850
+ // slice first (`rowLaneDownloadOf`). Off, a replay, or a plan that cannot price the sheet: whole, and nothing waits.
2851
+ const downloadBudgetCut = wrunDownloadBudgetCutOn() && replay === undefined;
2852
+ const downloadPlanned = downloadBudgetCut
2853
+ ? (async () => {
2854
+ const barGrid = liveBucketVenueOf(chartMetadata);
2855
+ return planWrunRunDownload({
2856
+ metadata: target.metadata,
2857
+ window: {
2858
+ fromMs: from,
2859
+ toMs: barEndMs(to, clock.intervalMs),
2860
+ intervalMs: clock.intervalMs,
2861
+ barOpens: liveBucketStartsInRange(from, to, clock.intervalMs, barGrid),
2862
+ barGrid,
2863
+ nowMs: clock.nowMs,
2864
+ },
2865
+ // The meter's window: the run's budget is the meter's.
2866
+ windowBars: download.summary().windowBars,
2867
+ chart: {
2868
+ exchange: chartExchange ?? '',
2869
+ coin: chartCoin,
2870
+ symbol: chartSymbol,
2871
+ ...(typeof chartCategory === 'number' ? { category: chartCategory } : {}),
2872
+ cme: isCmeGoverned(chartExchange),
2873
+ indexMode: checkIsIndexMode(chartExchange ?? ''),
2874
+ },
2875
+ paramValues: laneParamValues,
2876
+ facts: { official: head.official, opraUserScripts: head.opraUserScripts },
2877
+ ...(head.options !== undefined ? { options: head.options } : {}),
2878
+ });
2879
+ })().then((plan) => {
2880
+ if (plan.mode.mode === 'budgeted')
2881
+ download.noteBudget({ budgeted: true });
2882
+ if (wrunChartHostEnv().diagnostics.debugEnabled()) {
2883
+ wrunChartHostEnv().diagnostics.debug('wrun-download-plan', {
2884
+ chartIndex: target.chartIndex,
2885
+ indicatorId: target.indicatorId,
2886
+ mode: plan.mode.mode,
2887
+ projectedBytes: Math.round(plan.mode.projectedBytes),
2888
+ budgetBytes: download.budgetBytes,
2889
+ ...(plan.mode.mode === 'budgeted' ? { shares: Object.fromEntries(plan.mode.shares) } : {}),
2890
+ });
2891
+ }
2892
+ return plan;
2893
+ }, (error) => {
2894
+ // The plan is advisory: a sheet it cannot price runs whole, as with the flag off.
2895
+ if (wrunChartHostEnv().diagnostics.debugEnabled()) {
2896
+ wrunChartHostEnv().diagnostics.debug('wrun-download-plan-failed', {
2897
+ chartIndex: target.chartIndex,
2898
+ indicatorId: target.indicatorId,
2899
+ error: error instanceof Error ? error.message : String(error),
2900
+ });
2901
+ }
2902
+ return undefined;
2903
+ })
2904
+ : undefined;
2905
+ // A budgeted run's hold on one row lane instance (wrun-row-lanes.util `WrunRowLaneDownload`): the shares of the
2906
+ // inputs it serves, the rows a bar they declare, the lane's fold cap and the read's own meter beside the run's.
2907
+ const rowLaneDownloadOf = (instance, plan) => {
2908
+ if (plan === undefined || plan.mode.mode !== 'budgeted')
2909
+ return undefined;
2910
+ const lane = wrunRowLaneByKey(instance.laneKey);
2911
+ if (lane === undefined || lane.landing.kind === 'latest')
2912
+ return undefined;
2913
+ const keys = new Set(instance.inputIndexes.flatMap((index) => {
2914
+ const key = plan.keyOfInput.get(inputNameAt(index));
2915
+ return key === undefined ? [] : [key];
2916
+ }));
2917
+ if (keys.size === 0)
2918
+ return undefined;
2919
+ let share = 0;
2920
+ let barRows = 0;
2921
+ for (const key of keys) {
2922
+ share += plan.mode.shares.get(key) ?? 0;
2923
+ barRows = Math.max(barRows, plan.barRows.get(key) ?? 0);
2924
+ }
2925
+ return {
2926
+ share,
2927
+ meter: createWrunLaneDownloadMeter(download),
2928
+ ...(barRows > 0 ? { declaredBarRows: barRows } : {}),
2929
+ ...(lane.download?.fold !== undefined ? { fold: lane.download.fold } : {}),
2930
+ };
2931
+ };
2452
2932
  // The lanes the demanded classes read: a trades input asking `currency: "USD"` reads the buy/sell
2453
2933
  // lane asked in dollars (`trades_usd`), any other the coin lane (`trades`), so a sheet with a
2454
2934
  // units setting fetches each unit it declares, once.
@@ -2563,6 +3043,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2563
3043
  // intrabar leg's closes one chart bar past the last row (the forming
2564
3044
  // row's finer bars).
2565
3045
  fromTs = from, toTs = to) => {
3046
+ // No ask leaves before the download budget's plan decided the run's mode (R2; absent with the flag off).
3047
+ if (downloadPlanned !== undefined)
3048
+ await downloadPlanned;
3049
+ const meter = fetchOptions?.meter ?? download;
2566
3050
  const payload = { symbol: 'currentSymbol', exchange: 'currentExchange', ...payloadExtras };
2567
3051
  const lane = wrunLiveLaneOfFetchKey(key);
2568
3052
  if (lane !== undefined)
@@ -2590,6 +3074,20 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2590
3074
  })
2591
3075
  : null;
2592
3076
  if (own !== null) {
3077
+ // The chart's own rows answer the ask: it downloaded nothing.
3078
+ meter.charge({
3079
+ key: `${target.fetchKey}-${key}`,
3080
+ kType: type,
3081
+ verdict: {
3082
+ complete: true,
3083
+ servedEmpty: false,
3084
+ source: 'main-rows',
3085
+ wireBytes: 0,
3086
+ wireFrames: 0,
3087
+ wirePoints: 0,
3088
+ },
3089
+ ...wrunDownloadAnswerSize(own.rows),
3090
+ });
2593
3091
  fetchOptions?.onSourceVerdict?.({ complete: true, servedEmpty: false, source: 'main-rows' });
2594
3092
  return own.rows;
2595
3093
  }
@@ -2607,12 +3105,16 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2607
3105
  // A run at another interval: a source naming no interval of its own rides the run interval
2608
3106
  // (the kScript engine's rule, runIntervalForSource), one naming its own keeps it.
2609
3107
  run && fetchOptions?.interval === undefined
2610
- ? { ...fetchOptions, interval: run.interval, ...sendNotices }
2611
- : { ...fetchOptions, ...sendNotices });
3108
+ ? { ...fetchOptions, interval: run.interval, ...sendNotices, meter }
3109
+ : { ...fetchOptions, ...sendNotices, meter });
2612
3110
  const label = `wrun source fetch '${type}' for '${target.fetchKey}'`;
2613
3111
  const fetched = await (request === undefined
2614
3112
  ? withWrunDeadline(asked, WRUN_SOURCE_FETCH_DEADLINE_MS, label)
2615
3113
  : raceWrunSendDeadline(asked, request.bound, label));
3114
+ // A relay feed's own fetch rides no chart transport and no stamp measures it: its rows are charged their cell bytes.
3115
+ if (fetchOptions?.ownFetch) {
3116
+ meter.charge({ key: `${target.fetchKey}-${key}`, kType: type, ...wrunDownloadAnswerSize(fetched) });
3117
+ }
2616
3118
  // Packed-lane SUCCESS arrives as the packed transport object (only the
2617
3119
  // kScript engine worker consumes it un-unpacked); unpack it here, or a
2618
3120
  // real success misclassifies as a decline and re-fetches on the plain
@@ -3097,13 +3599,55 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3097
3599
  }
3098
3600
  return hostGridMemo;
3099
3601
  };
3602
+ // A full run's FIRST PAINT (`drawFirst`: nothing of this overlay computed or on screen, a stand-in included, no
3603
+ // strategy, no replay, the whole loaded window; and live at the chart's edge): a row lane whose first-paint slice
3604
+ // split its asks hands the slice's rows over before its older bars land (`runWrunSourceLanes` early rows), the older
3605
+ // bars read partial until the source ladder's rung adopts the whole answer (wrun-overlay-recovery.util). Every other
3606
+ // run waits for the whole window, as it always did: a run over a picture already drawn never trades it for a
3607
+ // partial one.
3608
+ const firstSlicePaint = live && drawFirst;
3609
+ // The chart's trade date of a bar (its `time.trade_date`): every run cuts a row lane's first-paint slice on a
3610
+ // session's first bar when it can, so a first paint's asks and every later run's ask the same windows (one cache).
3611
+ let tradeDateMemo;
3612
+ const chartTradeDateOf = () => {
3613
+ if (tradeDateMemo === undefined) {
3614
+ const venue = wrunBarVenueOf(chartMetadata, clock.intervalMs);
3615
+ if (venue === undefined)
3616
+ return undefined;
3617
+ const facts = wrunBarSessionFactsResolver(venue);
3618
+ tradeDateMemo = (barOpenMs) => facts(barOpenMs).tradeDateSec;
3619
+ }
3620
+ return tradeDateMemo;
3621
+ };
3622
+ // Each row lane that drew its first slice alone, by the slice's first bar: the live session's reconcile never lands
3623
+ // rows before it until the fill (`rowLaneFilling`, wrun-live-tick.util `mergeWrunReconcileAnswer`).
3624
+ const firstSliceFrom = new Map();
3625
+ // Each row lane instance's read its row budget cut (the latest read's, by instance id): the integrate publishes one
3626
+ // legend note per cut (`wrunRowBudgetCutDiagnostics`).
3627
+ const rowBudgetCuts = new Map();
3628
+ // A first slice's shape in the debug ring (`wrun-row-lane-first-slice`): where the slice starts, how many bars it drew
3629
+ // from data and how many it holds back as partial until the fill.
3630
+ const ringFirstSlice = (lane, rows, sliceFromTs) => {
3631
+ if (!wrunChartHostEnv().diagnostics.debugEnabled())
3632
+ return;
3633
+ const drawn = rows.filter((row) => row.slice(1).some((cell) => Array.isArray(cell) && !wrunPresentIsPartial(Number(cell[cell.length - 1]))));
3634
+ wrunChartHostEnv().diagnostics.debug('wrun-row-lane-first-slice', {
3635
+ chartIndex: target.chartIndex,
3636
+ indicatorId: target.indicatorId,
3637
+ lane,
3638
+ sliceFromTs,
3639
+ drawnBars: drawn.length,
3640
+ heldBars: rows.length - drawn.length,
3641
+ });
3642
+ };
3100
3643
  // A row lane instance's rows (sources/row-lane-registry.ts): its asks over the window (a flow or snapshot lane's
3101
3644
  // under the tier rule on the host bars, landed on them with the partial bars marked; a latest lane's once), the
3102
3645
  // K type its descriptor names with the instance's acquisition (a governed lane's on the native-rows path, naming
3103
3646
  // the plane and its routed tier; a chain lane's on the native-rows path naming what its instance's plane names,
3104
3647
  // `wrunRowLaneChainAsk`), or its own fetch. A lane that degrades on an empty answer (a snapshot's) must
3105
- // answer rows unless every input reading it declares `missing: "empty"`; a flow's empty window is quiet.
3106
- const fetchRowLaneRows = async (instance) => {
3648
+ // answer rows unless every input reading it declares `missing: "empty"`; a flow's empty window is quiet. On a first
3649
+ // paint (`firstSlicePaint`) the lane runner's `early` takes the first-paint slice's rows before the older bars land.
3650
+ const fetchRowLaneRows = async (instance, early) => {
3107
3651
  const lane = wrunRowLaneByKey(instance.laneKey);
3108
3652
  if (lane === undefined)
3109
3653
  return [];
@@ -3111,16 +3655,80 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3111
3655
  ? { ...instance.extras, ...wrunOpraLanePayloadFields(governedMarketDataTier('OPRA')) }
3112
3656
  : wrunRowLaneChainAsk(lane, instance.extras, governedMarketDataTier);
3113
3657
  const laneFetch = lane.fetch;
3114
- const rows = await fetchWrunRowLaneRows(lane, extras, hostGridWindow(), { fromTs: from, toTs: to }, async (askExtras, fromTs, toTs) => ((await fetchLane(lane.kType, instance.key, laneFetch
3115
- ? {
3116
- ownFetch: async (askFrom, askTo) => (await laneFetch({
3117
- extras: askExtras,
3118
- fromTs: askFrom,
3119
- toTs: askTo,
3120
- intervalMs: clock.intervalMs,
3121
- })),
3122
- }
3123
- : wrunRowLaneFetchOptions(lane), { ...askExtras }, fromTs, toTs)) ?? []));
3658
+ const tradeDateOf = chartTradeDateOf();
3659
+ // A budgeted run's hold on the read (R2): its share, its slice's declared rows, its fold cap and its own meter.
3660
+ const laneDownload = downloadPlanned === undefined ? undefined : rowLaneDownloadOf(instance, await downloadPlanned);
3661
+ const rows = await fetchWrunRowLaneRows(lane, extras,
3662
+ // A replay run's per-bar lanes end at the replay's cursor (wrun-row-lanes.util `replayCursorMs`).
3663
+ {
3664
+ ...hostGridWindow(),
3665
+ ...(tradeDateOf !== undefined ? { tradeDateOf } : {}),
3666
+ ...(replay !== undefined ? { replayCursorMs: replay.cutoffTs } : {}),
3667
+ }, { fromTs: from, toTs: to }, async (askExtras, fromTs, toTs, whole) => {
3668
+ // The ask's completion for the read's memo (wrun-row-lanes.util `ask`): the chart fetch's verdict, heard on the
3669
+ // download charge it makes at its answer (the read's meter, always bound); none heard is not whole. A lane's own
3670
+ // fetch rides no chart transport (no synthetic completion): its answer is whole once it resolved.
3671
+ let heard;
3672
+ const own = { answered: false };
3673
+ const meter = laneDownload?.meter ?? download;
3674
+ const verdictMeter = {
3675
+ charge: (charge) => {
3676
+ if (charge.verdict !== undefined)
3677
+ heard = charge.verdict;
3678
+ meter.charge(charge);
3679
+ },
3680
+ };
3681
+ const rows = (await fetchLane(lane.kType, instance.key, laneFetch
3682
+ ? {
3683
+ ownFetch: async (askFrom, askTo) => {
3684
+ const answered = (await laneFetch({
3685
+ extras: askExtras,
3686
+ fromTs: askFrom,
3687
+ toTs: askTo,
3688
+ intervalMs: clock.intervalMs,
3689
+ }));
3690
+ own.answered = true;
3691
+ return answered;
3692
+ },
3693
+ meter: verdictMeter,
3694
+ }
3695
+ : { ...wrunRowLaneFetchOptions(lane), meter: verdictMeter }, { ...askExtras }, fromTs, toTs)) ?? [];
3696
+ whole?.(own.answered || wrunSourceVerdictWhole(heard));
3697
+ return rows;
3698
+ }, {
3699
+ onBudgetCut: (cut) => {
3700
+ rowBudgetCuts.set(instance.key, cut);
3701
+ // The download budget's cut rides the add's attempt (the bars it left unread, the bytes the run spent so far),
3702
+ // and leaves the warm-up evidence unsettled: an output empty over the bars it left unread is no reason to
3703
+ // buy older candles.
3704
+ if (cut.budget === 'download') {
3705
+ download.noteBudget({ cutBars: cut.cutBars, plannedBytes: download.spentBytes() });
3706
+ unsettledLanes.add(instance.key);
3707
+ }
3708
+ },
3709
+ ...(laneDownload !== undefined ? { download: laneDownload } : {}),
3710
+ // One download budget per add (wrun-row-lane-add-memo.util): a budgeted run leaves the add a memo of what it
3711
+ // landed and cut, a later run of the add (a loaded-range refresh) reuses it, a whole run drops it.
3712
+ ...(downloadBudgetCut
3713
+ ? {
3714
+ addMemo: {
3715
+ key: wrunRowLaneAddKey(target.chartIndex, target.indicatorId, instance.key),
3716
+ role: 'run',
3717
+ },
3718
+ }
3719
+ : {}),
3720
+ // The slice's own rows always hold one with data (an empty slice has no early answer), so a lane that must
3721
+ // answer rows never paints off an empty one.
3722
+ ...(tradeDateOf === undefined || early === undefined || !firstSlicePaint
3723
+ ? {}
3724
+ : {
3725
+ onFirstSlice: (sliceRows, sliceFromTs) => {
3726
+ firstSliceFrom.set(instance.key, sliceFromTs);
3727
+ ringFirstSlice(instance.key, sliceRows, sliceFromTs);
3728
+ early(sliceRows);
3729
+ },
3730
+ }),
3731
+ });
3124
3732
  const laneRows = rows;
3125
3733
  return wrunRowLaneRequired(target.metadata, instance)
3126
3734
  ? requireDegradableRows(lane.kType, lane.label, laneRows, instance.key)
@@ -3314,19 +3922,18 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3314
3922
  // The options_chain lane dispatches in its own group, once its identity resolved (below).
3315
3923
  etf_flow: etfLanePlan !== undefined ? () => fetchEtfFlowRows(etfLanePlan) : undefined,
3316
3924
  // The trade tape (C2): the K_TRADES lane asked for the large-print table (`large: true`, the
3317
- // TRADE_LARGE type) at the acquisition's facets, `minSize` pushed down to the gateway as
3318
- // `minAmount` and `history` passed as declared: the control serves the history start aligned
3319
- // to the bar inside the chart's window, clamped to the table's 90-day retention. A history of
3320
- // "0" answers EMPTY by contract (the live edge only) and a quiet filtered window answers empty
3321
- // on a clean wire, so an empty answer computes (present empty blocks on every bar), a quiet
3322
- // lane like trades; a lane error (the worker's 300k-cell cap, a refused stream) degrades it.
3323
- // The payload stays the lane's acquisition: the live fold's floor and the reconcile's re-ask.
3925
+ // TRADE_LARGE type) at the acquisition's facets, the one floor pushed down to the gateway
3926
+ // (`minSize` as `minAmount`, a dollar `minValue` as `minQuoteAmount`, C-DOLLAR) and `history`
3927
+ // passed as declared: the control serves the history start aligned to the bar inside the
3928
+ // chart's window, clamped to the table's 90-day retention. A history of "0" answers EMPTY by
3929
+ // contract (the live edge only) and a quiet filtered window answers empty on a clean wire, so an
3930
+ // empty answer computes (present empty blocks on every bar), a quiet lane like trades; a lane
3931
+ // error (the worker's 300k-cell cap, a refused stream) degrades it. The payload stays the lane's
3932
+ // acquisition: the live fold's floor (a dollar floor with the market's `valuePerUnit`, the
3933
+ // market facts' dollar unit, so a live print is priced in the history's unit, never guessed)
3934
+ // and the reconcile's re-ask.
3324
3935
  tape: tape !== undefined
3325
- ? async () => (await fetchLane('trades', 'tp', undefined, {
3326
- minSize: tape.minSize,
3327
- history: tape.history,
3328
- large: true,
3329
- })) ?? []
3936
+ ? async () => (await fetchLane('trades', 'tp', undefined, wrunTapeLaneExtras(tape, tapeValuePerUnit))) ?? []
3330
3937
  : undefined,
3331
3938
  // The trades leg lanes (kit 0.77.0), one thunk per (quote, market): K_BUY_SELL_VOLUME asked on
3332
3939
  // the leg's market in its quote, under the lane id as its fetch key (its own cache entry and
@@ -3405,13 +4012,27 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3405
4012
  landedBefore: hasGoodResult,
3406
4013
  });
3407
4014
  },
3408
- onLate: (lane, answer) => noteWrunLateRead({
3409
- indicatorId: target.indicatorId,
3410
- lane,
3411
- identity: lateReadIdentity,
3412
- answer,
3413
- acquisition: () => acquisitionByLane[lane],
3414
- }),
4015
+ // A read the run stopped waiting for: its lane's budget ran out (`budget`), or the lane drew its first-paint slice
4016
+ // and the rest of its window is still out (`first-slice`). Either is noted the same way, so the ladder's rung joins
4017
+ // or adopts it and never asks it again.
4018
+ onLate: (lane, answer, why) => {
4019
+ if (wrunChartHostEnv().diagnostics.debugEnabled()) {
4020
+ wrunChartHostEnv().diagnostics.debug('wrun-late-read-noted', {
4021
+ chartIndex: target.chartIndex,
4022
+ indicatorId: target.indicatorId,
4023
+ lane,
4024
+ why,
4025
+ reason,
4026
+ });
4027
+ }
4028
+ noteWrunLateRead({
4029
+ indicatorId: target.indicatorId,
4030
+ lane,
4031
+ identity: lateReadIdentity,
4032
+ answer,
4033
+ acquisition: () => acquisitionByLane[lane],
4034
+ });
4035
+ },
3415
4036
  };
3416
4037
  // A lane whose read an earlier run left out under this run's identity joins that read (still out) or adopts its
3417
4038
  // answer: the lane sends no second ask. The acquisition the earlier run recorded is the lane's here.
@@ -3468,7 +4089,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3468
4089
  // The registry poll lanes and the row lanes, one thunk per planned instance, after the row builder's own lanes in
3469
4090
  // declaration order: those whose plan read no chain dispatch with the lanes known now.
3470
4091
  const pollThunksOf = (lanes) => lanes.map((instance) => [instance.key, () => fetchPollLaneRows(instance)]);
3471
- const rowThunksOf = (lanes) => lanes.map((instance) => [instance.key, () => fetchRowLaneRows(instance)]);
4092
+ const rowThunksOf = (lanes) => lanes.map((instance) => [instance.key, (_abandoned, early) => fetchRowLaneRows(instance, early)]);
3472
4093
  schedule.add(localPlanned.then(({ poll, row }) => {
3473
4094
  laneInstances.push(...poll.lanes, ...row.lanes);
3474
4095
  return wrunJoinLateReads({ ...laneThunks, pollLanes: pollThunksOf(poll.lanes), rowLanes: rowThunksOf(row.lanes) }, joinLateRead);
@@ -3549,6 +4170,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3549
4170
  const readsOpraPlane = optionsChainExtras?.chainVenue === 'opra' ||
3550
4171
  pollLanes.some(pollInstanceReadsOpra) ||
3551
4172
  rowLanes.some(rowInstanceReadsOpra);
4173
+ // The plan reads the OPRA plane: the run's console provenance, set before the module computes (`computed.opra`).
4174
+ if (readsOpraPlane)
4175
+ computed.opra = true;
3552
4176
  const writeOpraProvenance = await opraProvenanceWriter;
3553
4177
  // A degrade entry of a lane this run does not dispatch is settled now: a trades leg the coin switch moved, or a lane
3554
4178
  // a setting gate, a unit pick, `needed_by` or the capability rule dropped. No later run of this sheet asks that lane
@@ -3614,6 +4238,19 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3614
4238
  if (outcome.kind === 'rows')
3615
4239
  wrunChartHostEnv().chart.markSourceRecovered(guardKey, lane);
3616
4240
  }
4241
+ // The row lanes that answered their first-paint slice alone (`firstSlicePaint`): their older bars are still out, a
4242
+ // late read the source ladder's rung adopts (cause `filling`: a planned fill, no failure). Like a degraded lane each
4243
+ // leaves the warm-up evidence unsettled, so a picture over partial bars never buys older candles.
4244
+ const fillingLanes = laneRun.outcomes.flatMap(({ lane, outcome }) => outcome.kind === 'rows' && outcome.filling === true
4245
+ ? [{ lane, ...wrunLaneSourceOf(lane, laneInstances), cause: 'filling', retryable: true }]
4246
+ : []);
4247
+ for (const entry of fillingLanes)
4248
+ unsettledLanes.add(entry.lane);
4249
+ // Each filling lane's slice start, for the session the integrate installs (`rowLaneFilling`).
4250
+ const fillingFrom = Object.fromEntries(fillingLanes.flatMap(({ lane }) => {
4251
+ const fromTs = firstSliceFrom.get(lane);
4252
+ return fromTs === undefined ? [] : [[lane, fromTs]];
4253
+ }));
3617
4254
  for (const entry of degraded) {
3618
4255
  unsettledLanes.add(entry.lane);
3619
4256
  wrunChartHostEnv().chart.markSourceDegraded(guardKey,
@@ -3714,7 +4351,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3714
4351
  // no chip of its own: the registry's chip says what it waits for), keeping
3715
4352
  // whatever the overlay shows, and the source ladder reruns it.
3716
4353
  if (holding.length > 0) {
3717
- armWrunSourceRecovery(target.chartIndex, target.indicatorId, degraded);
4354
+ // The ladder watches the filling lanes' reads too: one rung adopts them all.
4355
+ armWrunSourceRecovery(target.chartIndex, target.indicatorId, [...degraded, ...fillingLanes]);
3718
4356
  // A lane another screen's session stopped names the hold: its record (Resume here) rides the rejection, so a
3719
4357
  // caller reading it (the editor console, the run's own catch) offers the take-back, never a Retry that cannot
3720
4358
  // serve it.
@@ -3857,7 +4495,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3857
4495
  tapeRows,
3858
4496
  // The plan resolves a param-bound tape floor from the settings it is handed: the floor the
3859
4497
  // lane was asked at (the param's current value).
3860
- ...(tape !== undefined ? { settings: wrunTapeFloorSettings(target.metadata, tape.minSize) } : {}),
4498
+ ...(tape !== undefined ? { settings: wrunTapeFloorSettings(target.metadata, wrunTapeFloorOf(tape)) } : {}),
3861
4499
  ...(pollLanes.length > 0 ? { pollLanes, pollLaneRows } : {}),
3862
4500
  ...(rowLanes.length > 0 ? { rowLanes, rowLaneRows } : {}),
3863
4501
  ...(Object.keys(tradeLegRows).length > 0
@@ -3904,7 +4542,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3904
4542
  await marketFactsReady;
3905
4543
  if (earningsFactsReady !== undefined)
3906
4544
  await earningsFactsReady;
3907
- const hostFill = wrunHostFillContextFor(tc, chartMetadata?.exchange, clock.intervalMs, wrunReadsMarketFacts(target.metadata) ? chartMetadata : undefined, wrunReadsEarningsFacts(target.metadata) ? chartMetadata : undefined);
4545
+ const hostFill = wrunHostFillContextFor(tc, chartMetadata?.exchange, clock.intervalMs,
4546
+ // The option multiplier follows the chain this run reads (the head's one options market).
4547
+ wrunReadsMarketFacts(target.metadata) ? wrunRunFactsMarket(chartMetadata, head.options) : undefined, wrunReadsEarningsFacts(target.metadata) ? chartMetadata : undefined);
3908
4548
  // The generation this run computes with (C1): the params, the init args and the text settings
3909
4549
  // are read under it in this synchronous block, after the lanes fetched.
3910
4550
  computed.generation = kScriptSettingsRevision(view.settings);
@@ -4019,6 +4659,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4019
4659
  etfFlowRows,
4020
4660
  evaluatedCandles,
4021
4661
  fetchedRunBars,
4662
+ fillingFrom,
4663
+ fillingLanes,
4022
4664
  formingPreRoll,
4023
4665
  from,
4024
4666
  fundingRateRows,
@@ -4088,6 +4730,11 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4088
4730
  // The pin step's notes and respelled pins: the integrate publishes the notes and lays the pins on its paint.
4089
4731
  pinNotes,
4090
4732
  respelledPins,
4733
+ // The row budget's cuts of this run's row lane reads: the integrate publishes one note per cut (the download
4734
+ // budget's, `budget: 'download'`, as the trimmed chip).
4735
+ rowBudgetCuts,
4736
+ // The download budget's cut was on for this run (R2): the integrate publishes its chips.
4737
+ downloadBudgetCut,
4091
4738
  };
4092
4739
  }
4093
4740
  /** The refusal seed of an ask its row source merged nothing from (`WrunRowSourceTransientError`): the run
@@ -4695,7 +5342,7 @@ async function computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, comp
4695
5342
  // reads the landed rows, as everything after it does.
4696
5343
  answered: (rows) => {
4697
5344
  const ran = host.prepared;
4698
- return publishWrunDebugOutput(runTarget.chartIndex, runTarget.indicatorId, ran.request.metadata, wrunSandboxLandedRows(ran, rows));
5345
+ return publishWrunDebugOutput(runTarget.chartIndex, runTarget.indicatorId, ran.request.metadata, wrunSandboxLandedRows(ran, rows), { opra: computed.opra === true });
4699
5346
  },
4700
5347
  };
4701
5348
  const record = wrunRowSourceRecordOf(runTarget.metadata, meta);
@@ -4734,7 +5381,11 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4734
5381
  await integrateWrunRowSourceBatch(runTarget, tc, meta, refusal, computed, owner, head, ask, batch);
4735
5382
  return;
4736
5383
  }
4737
- const { acquisitionByLane, writeOpraProvenance, readsOpraPlane, bookRows, buySellVolumeRows, buySellVolumeUsdRows, chartExchange, chartFirstTs, chartInterval, chartIntervalMs, chartMetadata, chartNames, chartRows, clampedLegs, clock, computeIdentity, computeSourceRows, cryptoVenue, degraded, emptyLegs, etfFlowRows, evaluatedCandles, fetchedRunBars, 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, } = prepared;
5384
+ 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;
5385
+ // The filling chip (`fillingLanes`, a first-slice picture): raised right before the integrate, lowered if the run
5386
+ // fails after it.
5387
+ const fillingGuardKey = overlayExecutionGuardKey(target.chartIndex, target.indicatorId);
5388
+ let fillingRaised = false;
4738
5389
  try {
4739
5390
  // The module's rows, the batch's own array (its frames, handles and strategy ride on it). A hidden head's rows
4740
5391
  // are cut by timestamp here (D4), where the pass receives them from the row source, before the integrate, the
@@ -4785,8 +5436,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4785
5436
  chartNames,
4786
5437
  // The draft's word and an OPRA chain's served tier (wrun-draft-legend-note.util); every tick repeats it.
4787
5438
  legendNote: wrunOverlayLegendNote(meta.settings, acquisitionByLane.options_chain, acquisitionByLane),
4788
- // The market's size unit: an output its `visible_by` leaves out here mounts nothing.
4789
- sizeUnit: wrunChartSizeUnit(chartMetadata),
5439
+ // The market's size unit (an output its `visible_by` leaves out here mounts nothing) and its dollar unit (the
5440
+ // batched marks' `units`).
5441
+ ...wrunResultMarketUnits(chartMetadata),
4790
5442
  ...(projection ? { projection } : {}),
4791
5443
  // WRUN-STYLE g6: the canvases' cells, the batch's (the run's source rows, shared, never
4792
5444
  // copied, with the profile children's context); the chart index above hands the price
@@ -4805,6 +5457,19 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4805
5457
  (generation !== undefined && currentWrunOverlayLiveGeneration(target.indicatorId) !== generation)) {
4806
5458
  throw new WrunOverlayPausedError('paused');
4807
5459
  }
5460
+ // A first-slice picture: each filling lane's chip says its older bars are still loading, raised in this turn so
5461
+ // the integrate's own diagnostics write carries it (still text, never a spinner: the registry's filling class). The
5462
+ // rung's run that adopts the whole answer lowers it with its lanes' verdict; a failure from here on lowers it in the
5463
+ // catch below.
5464
+ for (const entry of fillingLanes) {
5465
+ wrunChartHostEnv().chart.markSourcePending(fillingGuardKey, {
5466
+ sourceName: entry.lane,
5467
+ sourceType: entry.kType,
5468
+ landedBefore: true,
5469
+ filling: true,
5470
+ });
5471
+ fillingRaised = true;
5472
+ }
4808
5473
  const runSerial = nextWrunCanvasRunSerial(target.indicatorId);
4809
5474
  const integration = integrateWrunRunThroughRoute({
4810
5475
  ...integrateOptions,
@@ -4828,6 +5493,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4828
5493
  throw new WrunChartGoneError(`wrun overlay '${target.indicatorId}' was superseded during its run (${route.reason})`);
4829
5494
  }
4830
5495
  const runResult = integration.runResult;
5496
+ // The picture drew a row lane's first slice alone (its older bars still out): the attempt says so at its settle.
5497
+ if (fillingLanes.length > 0 && integration.applied)
5498
+ computed.firstSlice = true;
4831
5499
  // The first accepted integrate replaces a proven twin's or a pinned
4832
5500
  // package's stand-in (D3 B5); a no-op for an overlay no stand-in stands for.
4833
5501
  if (integration.applied) {
@@ -4897,7 +5565,12 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4897
5565
  // lower-pane children mounted): nested output visibility from the sheet
4898
5566
  // and the Style page, and the latest-values snapshot the HUD, the legend
4899
5567
  // and the hover inspector read.
4900
- presentWrunIntegration(target.chartIndex, target.indicatorId, sheetNow, meta.settings, outputRows, tc, initArgs, chartNames, run);
5568
+ presentWrunIntegration(target.chartIndex, target.indicatorId, sheetNow, meta.settings, outputRows, tc, initArgs, chartNames, run, 'run',
5569
+ // The result the chart shows: applied, or skipped as rendering equal to the mount. Any other skip (a transient
5570
+ // empty answer, nothing to paint) and a sparse run the mounted rows outranked keep the previous picture.
5571
+ integration.applied || (route.action === 'skip' && route.reason === 'render-equal')
5572
+ ? { emptyTargets: runResult.emptyTargets, partial: window?.partial === true }
5573
+ : undefined);
4901
5574
  await publishWrunStrategyRunResult(target.chartIndex, target.indicatorId, runResult, { tc, meta });
4902
5575
  // A run that drew nothing says so: every bar warm-up, or a line NaN on every ready bar,
4903
5576
  // used to print the green check over an empty pane. Published on EVERY run (WRUN-REFUSALS
@@ -4937,6 +5610,19 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4937
5610
  ...wrunEmptyLegDiagnostics(emptyLegs, refusal.ctx),
4938
5611
  ...wrunFeedMissingDiagnostics([...missingFeeds, ...(watched.silentOutputs.length > 0 ? emptySeries : [])], refusal.ctx),
4939
5612
  ]);
5613
+ // A row lane's read its budget cut says so: one note per cut ("Older bars cut by the read budget: showing the
5614
+ // newest N bars"), replaced by every full run and cleared by a run that cut nothing. A read the download budget cut
5615
+ // instead says so through the trimmed chip below (the smaller cut wins, one note per read).
5616
+ const budgetCuts = [...rowBudgetCuts.values()];
5617
+ await publishWrunOwnedDiagnostics(target.chartIndex, target.indicatorId, WRUN_ROW_BUDGET_ROW_CODES, wrunRowBudgetCutDiagnostics(budgetCuts.filter((cut) => cut.budget !== 'download')));
5618
+ // The download budget's chip (R2, behind its flag): "Newest bars only" when it cut a read, "Large download" when
5619
+ // the run passed its budget with nothing to cut; replaced by every full run and cleared by one that kept it.
5620
+ await publishWrunOwnedDiagnostics(target.chartIndex, target.indicatorId, WRUN_DOWNLOAD_BUDGET_ROW_CODES, wrunDownloadBudgetDiagnostics({
5621
+ on: downloadBudgetCut,
5622
+ cuts: budgetCuts,
5623
+ summary: computed.download?.summary(),
5624
+ feedOf: wrunDownloadFeedOf,
5625
+ }));
4940
5626
  // A pinned market the run respelled says so (one note per spelling, the saved value unchanged), replaced by
4941
5627
  // every run and cleared by a run that respelled nothing.
4942
5628
  await publishWrunOwnedDiagnostics(target.chartIndex, target.indicatorId, WRUN_PIN_ROW_CODES, wrunPinRespelledDiagnostics(pinNotes));
@@ -4956,7 +5642,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4956
5642
  }
4957
5643
  // A proven twin's or a pinned package's whole result is the stand-in the
4958
5644
  // next reload or switch paints (D3 B5); a merge lands a page, never a
4959
- // stand-in.
5645
+ // stand-in, and a first-slice picture (older bars still loading) is no
5646
+ // whole result: the fill's run stores it.
4960
5647
  if (route.action === 'apply-remount' && integration.applied) {
4961
5648
  await writeWrunStandIn({
4962
5649
  chartIndex: target.chartIndex,
@@ -4967,6 +5654,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4967
5654
  chartMetadata,
4968
5655
  window,
4969
5656
  executedVersion: target.version,
5657
+ firstSlice: fillingLanes.length > 0,
4970
5658
  });
4971
5659
  }
4972
5660
  if (live && generation !== undefined && rows.length > 0) {
@@ -4985,12 +5673,16 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4985
5673
  // asking its tail while the source ladder owns the window.
4986
5674
  const degradedLanes = new Set(degraded.map((entry) => entry.lane));
4987
5675
  const coveredThroughTs = {};
5676
+ // A replay run read its flow and snapshot row lanes through its cursor (wrun-row-lanes.util `replayCursorMs`):
5677
+ // their coverage is the cursor, and each replay step extends them from there (wrun-live-tick.util).
5678
+ const replayBound = replay === undefined ? undefined : wrunRowLanesReplayBounded(rowLanes);
4988
5679
  for (const lane of Object.keys(acquisitionByLane)) {
4989
5680
  if (degradedLanes.has(lane))
4990
5681
  continue;
4991
5682
  // A held lane keeps its session's watermark (the reconcile re-asks from there).
4992
5683
  const heldThrough = heldCoverage[lane];
4993
- coveredThroughTs[lane] = heldThrough !== undefined ? Math.min(heldThrough, to) : to;
5684
+ const laneTo = replay !== undefined && replayBound?.has(lane) === true ? Math.min(to, replay.cutoffTs) : to;
5685
+ coveredThroughTs[lane] = heldThrough !== undefined ? Math.min(heldThrough, laneTo) : laneTo;
4994
5686
  }
4995
5687
  // A leg's coverage is the clock the run fetched under: every candle
4996
5688
  // closed by then is in the buffer (the forming one is dropped).
@@ -4998,6 +5690,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4998
5690
  const liveContext = {
4999
5691
  chartIndex: target.chartIndex,
5000
5692
  indicatorId: target.indicatorId,
5693
+ // The run's console provenance: every debug line the session's ticks and reseeds publish states it.
5694
+ ...(computed.opra === true ? { opraRead: true } : {}),
5001
5695
  // The current paint (above): the ticks and the reseeds keep the look.
5002
5696
  metadata: sheetNow,
5003
5697
  title: target.title,
@@ -5009,6 +5703,10 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5009
5703
  fetchKey: target.fetchKey,
5010
5704
  outputRows,
5011
5705
  computeIdentity,
5706
+ // The version this run executed and the settings revision it computed with: the switch's stand-in capture
5707
+ // stores the picture only under that pin and while the row still carries that revision.
5708
+ version: target.version,
5709
+ settingsRevision: computed.generation,
5012
5710
  draft,
5013
5711
  runHealthWarned,
5014
5712
  marketIdentity,
@@ -5049,6 +5747,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5049
5747
  ? {
5050
5748
  rowLanes,
5051
5749
  rowLaneRows: Object.fromEntries(Object.entries(rowLaneRows).map(([key, rows]) => [key, [...rows]])),
5750
+ // Lanes whose rows hold their first slice alone, by its first bar: no prefix page stands on them and
5751
+ // no reconcile lands rows before that bar until the fill.
5752
+ ...(Object.keys(fillingFrom).length > 0 ? { rowLaneFilling: fillingFrom } : {}),
5052
5753
  }
5053
5754
  : {}),
5054
5755
  // The trades leg lanes the run asked (kit 0.77.0): a copy of each one's rows by lane id. The
@@ -5265,7 +5966,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5265
5966
  return;
5266
5967
  }
5267
5968
  await publishWrunCanvasNotices(target.chartIndex, target.indicatorId, refined);
5268
- presentWrunIntegration(target.chartIndex, target.indicatorId, sheetAtRefine, mounted.settings, outputRows, chart, initArgs, chartNames, run);
5969
+ presentWrunIntegration(target.chartIndex, target.indicatorId, sheetAtRefine, mounted.settings, outputRows, chart, initArgs, chartNames, run,
5970
+ // A later refine of this run's rows: a full run refused since keeps its snapshot.
5971
+ 'republish', { emptyTargets: refined.emptyTargets, partial: window?.partial === true });
5269
5972
  },
5270
5973
  };
5271
5974
  scheduleWrunTpoBlockRefine(request);
@@ -5277,6 +5980,11 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5277
5980
  // instead of ticking a session it does not own); the session lock and the load signals go.
5278
5981
  // A page or a save on the held source ends nothing more of the overlay's live session.
5279
5982
  releaseWrunRowSourceAsk(runTarget, ask, { epoch: generation, land: wrunTickOwnedFrames });
5983
+ // A filling chip this run raised says nothing once the run failed: lowered with it (data-loading rule 3).
5984
+ if (fillingRaised) {
5985
+ for (const entry of fillingLanes)
5986
+ wrunChartHostEnv().chart.markSourceRecovered(fillingGuardKey, entry.lane);
5987
+ }
5280
5988
  throw error;
5281
5989
  }
5282
5990
  // The batch landed: a live run hands its session to the overlay (the source lets the session
@@ -5290,10 +5998,12 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5290
5998
  source.teardown();
5291
5999
  }
5292
6000
  // End of run: lanes it computed without arm the source ladder (kScript's
5293
- // recovery rungs, each a whole rerun riding the fetch cache); a run that
5294
- // landed every lane retires it.
5295
- if (degraded.length > 0)
5296
- armWrunSourceRecovery(target.chartIndex, target.indicatorId, degraded);
6001
+ // recovery rungs, each a whole rerun riding the fetch cache), and so do the lanes that drew their first slice
6002
+ // alone (their older bars' read, adopted by the rung the moment it lands); a run that landed every lane whole
6003
+ // retires it.
6004
+ const unfinished = [...degraded, ...fillingLanes];
6005
+ if (unfinished.length > 0)
6006
+ armWrunSourceRecovery(target.chartIndex, target.indicatorId, unfinished);
5297
6007
  else
5298
6008
  retireWrunSourceRecovery(target.indicatorId, 'recovered');
5299
6009
  }
@@ -5546,6 +6256,16 @@ async function persistWrunSourceDecidedSide(chartIndex, tc, indicatorId, meta, s
5546
6256
  console.warn(`[wrun] the side of '${indicatorId}' was not persisted on its record:`, error);
5547
6257
  }
5548
6258
  }
6259
+ /** The receipt a cloud batch's legend word reads (contract opra-server-lanes C4): the receipt of the rows the batch was
6260
+ * computed from, only while the batch carries the OPRA mark (a result without it is a re-plan off OPRA: no word). */
6261
+ function wrunBatchOpraServed(batch) {
6262
+ return batch.opra === true ? batch.opraServed : undefined;
6263
+ }
6264
+ /** The context field a Cloud session installs with: its receipt (`wrunBatchOpraServed`), or none. */
6265
+ function withWrunCloudOpraServed(batch) {
6266
+ const served = wrunBatchOpraServed(batch);
6267
+ return served !== undefined ? { cloudOpraServed: { ...served } } : {};
6268
+ }
5549
6269
  /**
5550
6270
  * A batch no browser lane prepared (contract C7: the socket row source's, which the cloud
5551
6271
  * computed) integrates from the batch and the chart alone, through the steps every batch takes:
@@ -5614,7 +6334,9 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
5614
6334
  const delivered = wrunRowBatchDeliveredSheet(batch.sheet ?? runTarget.metadata, batch.refusals, sectionKinds);
5615
6335
  if (wrunReadsMarketFacts(delivered))
5616
6336
  await warmWrunMarketFacts(chartMetadata);
5617
- const hostFill = wrunHostFillContextFor(tc, chartExchange, chartIntervalMs, wrunReadsMarketFacts(delivered) ? chartMetadata : undefined);
6337
+ const hostFill = wrunHostFillContextFor(tc, chartExchange, chartIntervalMs,
6338
+ // No browser lane prepared this batch (contract C7): the cloud computed it off the chart's own market's facts.
6339
+ wrunReadsMarketFacts(delivered) ? wrunCloudFactsMarket(chartMetadata) : undefined);
5618
6340
  const chartNames = await resolveWrunChartNames(chartIndex);
5619
6341
  const canvasFill = wrunCanvasFillWithSessionBlock(await wrunCanvasHostFillFor(delivered, chartMetadata), delivered, indicatorId, chartMetadata);
5620
6342
  const identityLeft = await wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity);
@@ -5639,6 +6361,9 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
5639
6361
  if (batch.opra === true && !(writeOpraProvenance?.(true) === true && wrunOverlayOpraStamped(meta))) {
5640
6362
  throw new WrunChartGoneError(`wrun overlay '${indicatorId}' left its chart before its OPRA provenance was stamped (superseded)`);
5641
6363
  }
6364
+ // The cloud read OPRA for these rows (its mark): the run's console provenance from here (`computed.opra`).
6365
+ if (batch.opra === true)
6366
+ computed.opra = true;
5642
6367
  const heldContext = getWrunOverlayLiveContext(indicatorId);
5643
6368
  const window = runTarget.window;
5644
6369
  nextWrunCanvasRunSerial(indicatorId);
@@ -5657,8 +6382,13 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
5657
6382
  fills: runTarget.fills,
5658
6383
  candles: runTarget.candles,
5659
6384
  chartNames,
5660
- // The market's size unit: an output its `visible_by` leaves out here mounts nothing, as on the own run.
5661
- sizeUnit: wrunChartSizeUnit(chartMetadata),
6385
+ // The legend's served word is the receipt of the rows the cloud computed this batch from (contract
6386
+ // opra-server-lanes C4), as a browser run's is its acquisition records': none for a batch without the mark (a
6387
+ // re-plan off OPRA clears it) or naming no tier, never the account's tier.
6388
+ legendNote: wrunOverlayLegendNote(meta.settings, undefined, undefined, wrunBatchOpraServed(batch)),
6389
+ // The market's size unit (an output its `visible_by` leaves out here mounts nothing) and its dollar unit, as on
6390
+ // the own run.
6391
+ ...wrunResultMarketUnits(chartMetadata),
5662
6392
  // The canvases' cells: the batch's own lanes when it carries them, else the cells the source keeps.
5663
6393
  cellRows: wrunRowBatchCellRows(batch) ?? source.cellRowsOf(chartRows),
5664
6394
  intervalMs: chartIntervalMs,
@@ -5708,16 +6438,21 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
5708
6438
  // The stamp stands until a later result can clear it.
5709
6439
  }
5710
6440
  }
5711
- presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, outputRows, tc, wrunSourceInitArgsOf(sheetNow, paramValues), chartNames, null);
6441
+ presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, outputRows, tc, wrunSourceInitArgsOf(sheetNow, paramValues), chartNames, null, 'run',
6442
+ // The picture the chart shows, as on the browser lane (integrateWrunRunAsk).
6443
+ integration.applied || (route.action === 'skip' && route.reason === 'render-equal')
6444
+ ? { emptyTargets: runResult.emptyTargets, partial: window?.partial === true }
6445
+ : undefined);
5712
6446
  await publishWrunStrategyRunResult(chartIndex, indicatorId, runResult, { tc, meta });
5713
- await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows);
6447
+ await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows, { opra: computed.opra === true });
5714
6448
  const draft = isWrunDraftOverlaySettings(meta.settings);
5715
6449
  const { health } = wrunChartRunHealth(sheetNow, meta.settings, outputRows, false, wrunChartSizeUnit(chartMetadata));
5716
6450
  const runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, draft, wrunNothingReadyRefusal(health, refusal.ctx)));
5717
- // A run computed elsewhere served every leg it read: no leg note of an earlier run stands, and no pin note
5718
- // this lane respelled (the cloud resolves its own pins).
6451
+ // A run computed elsewhere served every leg it read: no leg note of an earlier run stands, no pin note this
6452
+ // lane respelled (the cloud resolves its own pins), and no row budget cut of a browser read.
5719
6453
  await publishWrunUnservedLegDiagnostics(chartIndex, indicatorId, []);
5720
6454
  await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_PIN_ROW_CODES, []);
6455
+ await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_ROW_BUDGET_ROW_CODES, []);
5721
6456
  const indicatorName = typeof delivered.name === 'string' ? delivered.name : '';
5722
6457
  await publishWrunSourceVerdict(chartIndex, indicatorId, meta, batch, indicatorName);
5723
6458
  await publishWrunCanvasNotices(chartIndex, indicatorId, runResult);
@@ -5805,6 +6540,8 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
5805
6540
  fetchKey: runTarget.fetchKey,
5806
6541
  outputRows: sessionRows,
5807
6542
  computeIdentity,
6543
+ version: runTarget.version,
6544
+ settingsRevision: computed.generation,
5808
6545
  draft,
5809
6546
  runHealthWarned,
5810
6547
  marketIdentity,
@@ -5814,6 +6551,10 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
5814
6551
  generation: nextWrunOverlayLiveGeneration(indicatorId),
5815
6552
  intervalMs: chartIntervalMs,
5816
6553
  acquisition: {},
6554
+ // The receipt the session holds now (its newest answer's): every tick's legend word reads it.
6555
+ ...withWrunCloudOpraServed(session ?? batch),
6556
+ // The run's console provenance: every debug line the session's ticks publish states it.
6557
+ ...(computed.opra === true ? { opraRead: true } : {}),
5817
6558
  carrySeed: emptyWrunInputCarry(),
5818
6559
  fedBuckets: {},
5819
6560
  pushEligible: false,
@@ -6050,7 +6791,7 @@ function askWrunWarmupBackfillIfOwed(args) {
6050
6791
  ringDetails.unsettledLanes = [...unsettledLanes];
6051
6792
  const { sheet, paramValues, runRows, intervalMs } = args.declaredWarmup;
6052
6793
  const creditedBars = args.declaredWarmup.creditedBars ?? 0;
6053
- const declaredWarmupBars = builtinTwinOf(meta.settings) === undefined ? wrunDeclaredWarmupBars(sheet, paramValues) : null;
6794
+ const declaredWarmupBars = builtinPortOf(meta.settings) === undefined ? wrunDeclaredWarmupBars(sheet, paramValues) : null;
6054
6795
  if (declaredWarmupBars !== null)
6055
6796
  ringDetails.declaredWarmupBars = declaredWarmupBars;
6056
6797
  if (declaredWarmupBars !== null && creditedBars > 0)
@@ -6079,7 +6820,7 @@ function askWrunWarmupBackfillIfOwed(args) {
6079
6820
  declaredWarmupEndTs: declaredWarmupBars === null
6080
6821
  ? null
6081
6822
  : wrunDeclaredWarmupEndTs(runRows, declaredWarmupBars, intervalMs, creditedBars),
6082
- sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: Date.now() }),
6823
+ sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: serverNowMs() }),
6083
6824
  }),
6084
6825
  requestOlderHistory: wrunWarmupPageRequester(chartIndex, indicatorId, tc, isCurrent, ringDetails),
6085
6826
  ringDetails,
@@ -6348,8 +7089,8 @@ function assertWrunRunMayPaint(chartIndex, indicatorId, replay) {
6348
7089
  /** The kScript replay window's warm-up candles before the chart's first bar,
6349
7090
  * on the K_OHLCV lane the kScript engine fetches them on (deadline-raced like
6350
7091
  * every lane): [fromMs, beforeMs). */
6351
- async function fetchWrunReplayHeadRows(target, meta, fromMs, beforeMs) {
6352
- const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(target.chartIndex, 'ohlcv', { symbol: 'currentSymbol', exchange: 'currentExchange' }, fromMs, beforeMs, meta, `${target.fetchKey}-replay-head`, false, {}), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun replay head for '${target.fetchKey}'`);
7092
+ async function fetchWrunReplayHeadRows(target, meta, fromMs, beforeMs, meter) {
7093
+ const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(target.chartIndex, 'ohlcv', { symbol: 'currentSymbol', exchange: 'currentExchange' }, fromMs, beforeMs, meta, `${target.fetchKey}-replay-head`, false, { meter }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun replay head for '${target.fetchKey}'`);
6353
7094
  const rows = isPackedOhlcvRows(fetched)
6354
7095
  ? unpackOhlcvRows(fetched)
6355
7096
  : Array.isArray(fetched)
@@ -6439,6 +7180,8 @@ async function writeWrunStandIn(args) {
6439
7180
  return refuse('template');
6440
7181
  if (args.window?.partial)
6441
7182
  return refuse('window-partial');
7183
+ if (args.firstSlice === true)
7184
+ return refuse('first-slice');
6442
7185
  if (args.executedVersion !== undefined && args.executedVersion !== identity.version) {
6443
7186
  return refuse('version-mismatch');
6444
7187
  }
@@ -6854,9 +7597,9 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
6854
7597
  outputs: context.metadata.outputs.length,
6855
7598
  });
6856
7599
  }
6857
- // The reseed's own clock: the legs re-align as-of now over the buffers
6858
- // (a candle that closed since the last build is admitted by it).
6859
- const clock = { intervalMs: context.intervalMs, nowMs: Date.now() };
7600
+ // The reseed's own clock: the legs re-align as-of the server's now over the
7601
+ // buffers (a candle that closed since the last build is admitted by it).
7602
+ const clock = { intervalMs: context.intervalMs, nowMs: serverNowMs() };
6860
7603
  const sourceRows = {
6861
7604
  ohlcvRows,
6862
7605
  bookRows: context.bookRows,
@@ -6872,7 +7615,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
6872
7615
  optionsChainRows: context.optionsChainRows,
6873
7616
  etfFlowRows: context.etfFlowRows,
6874
7617
  tapeRows: context.tapeRows,
6875
- settings: wrunTapeFloorSettings(context.metadata, context.acquisition.tape?.minSize),
7618
+ settings: wrunTapeFloorSettings(context.metadata, wrunTapeAcquisitionFloor(context.acquisition.tape)),
6876
7619
  pollLanes: context.pollLanes,
6877
7620
  pollLaneRows: context.pollLaneRows,
6878
7621
  rowLanes: context.rowLanes,
@@ -7071,8 +7814,10 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7071
7814
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'reseed' });
7072
7815
  noteWrunLiveIntakeEvent(indicatorId, { kind: 'session-start', live: wrunLiveOf(outputRows) });
7073
7816
  // The committed rows' debug log, published with the rows (a failed
7074
- // render below owes a repaint, not a console rewrite).
7075
- await publishWrunDebugOutput(context.chartIndex, indicatorId, context.metadata, outputRows);
7817
+ // render below owes a repaint, not a console rewrite), under the session's own provenance.
7818
+ await publishWrunDebugOutput(context.chartIndex, indicatorId, context.metadata, outputRows, {
7819
+ opra: context.opraRead === true,
7820
+ });
7076
7821
  try {
7077
7822
  // The canvas fill (G1) for the session's market; a mirror entry that aged
7078
7823
  // out keeps the block the session was drawn with (same market, same grid).
@@ -7099,7 +7844,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7099
7844
  candles: context.candles,
7100
7845
  chartNames,
7101
7846
  legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
7102
- sizeUnit: wrunChartSizeUnit(context.market),
7847
+ ...wrunResultMarketUnits(context.market),
7103
7848
  ...(runSession
7104
7849
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
7105
7850
  : {}),
@@ -7125,7 +7870,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7125
7870
  cutWrunReplayRowsAfterApply(tc, indicatorId);
7126
7871
  }
7127
7872
  rememberWrunSessionCanvasFill(context, canvasFill);
7128
- presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run);
7873
+ presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run, 'run', { emptyTargets: runResult.emptyTargets, partial: clamped !== undefined });
7129
7874
  // The committed result's canvas notices replace the published ones (none clears them).
7130
7875
  await publishWrunSessionCanvasNotices(context, runResult);
7131
7876
  // The session's retained range on the "Cells capped" row (design 5); a clamped window's session keeps it.
@@ -7362,18 +8107,20 @@ function wrunDegradedLaneOutcome(error) {
7362
8107
  * poll lanes (`thunks.pollLanes`, one thunk per planned instance) dispatch with
7363
8108
  * them, after the row builder's own lanes; their rows come back under
7364
8109
  * `tradeLegRows` and `pollLaneRows`, keyed by lane id and instance id.
8110
+ *
8111
+ * A lane may hand its first rows over before its whole answer (`early`, a row lane's first-paint slice on a full run's
8112
+ * first paint): when they come before the whole answer and before the budget, the lane settles on them (outcome
8113
+ * rows, `filling`) and its whole answer goes on as a late read (`onLate`, `first-slice`), exactly as a read its budget
8114
+ * abandoned does, so the source ladder adopts it and nothing asks it twice. Early rows after the budget change
8115
+ * nothing: the budget's late read is the whole answer already.
7365
8116
  */
7366
8117
  export async function runWrunSourceLanes(thunks, policy = {}) {
7367
8118
  const builtin = WRUN_SOURCE_LANE_ORDER.flatMap((lane) => {
7368
8119
  const run = thunks[lane];
7369
8120
  return typeof run === 'function' ? [[lane, run]] : [];
7370
8121
  });
7371
- const declared = [
7372
- ...builtin,
7373
- ...(thunks.tradeLegs ?? []),
7374
- ...(thunks.pollLanes ?? []),
7375
- ...(thunks.rowLanes ?? []),
7376
- ];
8122
+ const declared = [...builtin, ...(thunks.tradeLegs ?? []), ...(thunks.pollLanes ?? []), ...(thunks.rowLanes ?? [])];
8123
+ const filling = new Set();
7377
8124
  const settled = await Promise.allSettled(declared.map(([lane, run]) => {
7378
8125
  const laneBudgetMs = typeof policy.budgetMs === 'function' ? policy.budgetMs(lane) : policy.budgetMs;
7379
8126
  const deadline = wrunLaneSendDeadline(laneBudgetMs ?? 0, policy.capMs);
@@ -7381,27 +8128,49 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
7381
8128
  // Raised when the lane's budget runs out: its run no longer waits on it, so a lane asked in pieces asks no
7382
8129
  // further piece (`wrunAskWirePieces`); the asks already out finish into the fetch's cache.
7383
8130
  const abandon = new AbortController();
8131
+ // The lane's first rows (`early`), if it hands any over before its whole answer: the first call wins.
8132
+ let landEarly = () => undefined;
8133
+ const early = new Promise((resolve) => {
8134
+ let landed = false;
8135
+ landEarly = (rows) => {
8136
+ if (landed)
8137
+ return;
8138
+ landed = true;
8139
+ resolve({ rows, whole: false });
8140
+ };
8141
+ });
7384
8142
  let answer;
7385
8143
  try {
7386
- answer = run(abandon.signal);
8144
+ answer = run(abandon.signal, (rows) => landEarly(rows));
7387
8145
  }
7388
8146
  catch (error) {
7389
8147
  answer = Promise.reject(error);
7390
8148
  }
7391
- if (laneBudgetMs === undefined)
7392
- return answer;
8149
+ const first = Promise.race([answer.then((rows) => ({ rows, whole: true })), early]);
7393
8150
  // One phase per send notice, each racing what is left of the deadline the notice moved to
7394
8151
  // (`wrunLaneSendDeadline`). Only the budget's own expiry abandons the read and hands it on as a late read: an
7395
8152
  // answer that failed (its fetch's own deadline included) is no read to join or adopt.
7396
- return raceWrunSendDeadline(answer, deadline, `wrun source lane '${lane}'`, (expired) => {
7397
- abandon.abort(expired);
7398
- policy.onLate?.(lane, answer);
8153
+ const answered = laneBudgetMs === undefined
8154
+ ? first
8155
+ : raceWrunSendDeadline(first, deadline, `wrun source lane '${lane}'`, (expired) => {
8156
+ abandon.abort(expired);
8157
+ policy.onLate?.(lane, answer, 'budget');
8158
+ });
8159
+ return answered.then(({ rows, whole }) => {
8160
+ if (!whole) {
8161
+ // The lane drew its first rows alone: the rest of its window is the late read the ladder adopts.
8162
+ filling.add(lane);
8163
+ policy.onLate?.(lane, answer, 'first-slice');
8164
+ }
8165
+ return rows;
7399
8166
  });
7400
8167
  }));
7401
8168
  const run = { results: {}, outcomes: [], degraded: [] };
7402
8169
  declared.forEach(([lane], at) => {
7403
8170
  const answer = settled[at];
7404
- const outcome = answer.status === 'fulfilled' ? { kind: 'rows', rows: answer.value } : wrunDegradedLaneOutcome(answer.reason);
8171
+ const outcome = answer.status === 'fulfilled'
8172
+ ? { kind: 'rows', rows: answer.value, ...(filling.has(lane) ? { filling: true } : {}) }
8173
+ : wrunDegradedLaneOutcome(answer.reason);
7405
8174
  run.outcomes.push({ lane, outcome });
7406
8175
  if (outcome.kind === 'degraded')
7407
8176
  run.degraded.push({ lane, outcome });
@@ -7463,6 +8232,15 @@ function wrunUnservedLaneReason(type, exchange, coin, service) {
7463
8232
  if (checkIsCryptoIndex(exchange)) {
7464
8233
  return `the ${type} source lane answers nothing on ${market} (a crypto index market serves its value candles only)`;
7465
8234
  }
8235
+ if (checkIsQuotePerp(exchange)) {
8236
+ return (`the ${type} source lane answers nothing on ${market} (a quote-priced perpetual market serves its quote ` +
8237
+ 'candles, funding and open interest only)');
8238
+ }
8239
+ // The kind table's US equity row (index-mode-admission.util): a stock print has no aggressor side.
8240
+ if (getMarketKind(exchange) === 'tradfi') {
8241
+ return (`the ${type} source lane answers nothing on ${market} (a US equity market's prints carry no aggressor ` +
8242
+ 'side, so it serves no buy/sell volume)');
8243
+ }
7466
8244
  return (`the ${type} source lane answers nothing on ${market} (a forex or commodity market serves no volume ` +
7467
8245
  'profile, buy/sell volume, order book, implied volatility or skew)');
7468
8246
  case 'coin':
@@ -7587,9 +8365,7 @@ function wrunOptionsChainExtrasGoverned(extras) {
7587
8365
  * provenance (the wall's door read it): `auto` reads an OPRA chain for an
7588
8366
  * OpenMarket package, and for a run `opraUserScripts` says the
7589
8367
  * `opra-user-scripts` flag opened the plane to. A governed identity carries
7590
- * the lane's scope (`wrunOptionsChainLaneScope` over every chain input: the
7591
- * nearest expiries at a bounded strike window the smallest `max_cells` holds)
7592
- * and the tier the viewer is served now (`governedOptionSummaryTier`, the
8368
+ * the tier the viewer is served now (`governedOptionSummaryTier`, the
7593
8369
  * routing's own rule: the lane's acquisition names it and the legend follows
7594
8370
  * it). Returns the lane's payload extras (`chain*` fields).
7595
8371
  *
@@ -7601,29 +8377,52 @@ function wrunOptionsChainExtrasGoverned(extras) {
7601
8377
  * `chainMaxContracts`, O2: the gateway sizes B on its page, so no expiry
7602
8378
  * directory is read here or in the worker); the chain's inputs read views all,
7603
8379
  * or none, and its view inputs one expiries word (one block B for the lane).
8380
+ *
8381
+ * OPTLOAD W3 FE-CHAIN: a governed chain whose inputs declare no views asks the
8382
+ * gateway's WHOLE view of B through the implicit view
8383
+ * (`wrunOptionsChainImplicitViewFields`: `chainViews: "whole"` and the same
8384
+ * scope inputs), so the gateway sizes B on its page by the lane scope's own
8385
+ * rule and no expiry directory is read before the ask; the worker sizes
8386
+ * today's scope itself only for an answer that is not B's rows. A crypto
8387
+ * chain keeps its plain reader (OPTLOAD W3 decision 1): its payload is
8388
+ * today's, byte for byte.
8389
+ *
8390
+ * Contract F: an input whose `underlying` names another root (a setting
8391
+ * naming one read through `paramValues`) reads that root's chain instead
8392
+ * (derived-roots.util `wrunUnderlyingOptionsChainDecision`), its identity
8393
+ * naming the root (`chainUnderlying`).
8394
+ *
8395
+ * A stock twin (`options`, the run head's one decision, derived-roots.util
8396
+ * `decideWrunRunOptionsMarket`): its chain is its stock's, held on the OPRA
8397
+ * plane by the twin's ticker (the lane market, `options.lane`) and decided
8398
+ * over the twin's stock (`auto` reads OPRA, and so meets the OPRA wall for a
8399
+ * user script; a pinned crypto word still reads that venue's chain of the
8400
+ * coin). Without a decision the chart's own market reads exactly as before.
7604
8401
  */
7605
- async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts) {
7606
- const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues }, { WRUN_OPTION_VIEWS_ONE_ASK_CODE, WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE, wrunHeldOpraPlaneChain, wrunOptionViewLaneFields, wrunOptionViewsOfSource, wrunOptionViewsUnion, },] = await Promise.all([
8402
+ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts, paramValues, options) {
8403
+ 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([
7607
8404
  import('./sources/opra-option-lanes.util.js'),
7608
8405
  wrunChartHostEnv().market.loadDeribitOptions(),
7609
8406
  wrunChartHostEnv().market.loadOptionsChainVenues(),
7610
8407
  import('./wrun-option-views.util.js'),
8408
+ import('./derived-roots.util.js'),
7611
8409
  ]);
7612
8410
  const market = chartMetadata;
7613
8411
  const pick = (value) => (typeof value === 'string' ? value : undefined);
7614
- const chartMarket = {
7615
- exchange: pick(market?.exchange) ?? '',
7616
- symbol: pick(market?.symbol) ?? '',
7617
- coin: pick(market?.coin) ?? '',
7618
- };
8412
+ // The market the chain is read as: a stock twin's lane market (its stock on the OPRA plane), else the chart's own.
8413
+ const lane = options?.lane;
8414
+ const chartMarket = lane !== undefined
8415
+ ? { exchange: lane.exchange, symbol: lane.symbol, coin: lane.coin }
8416
+ : { exchange: pick(market?.exchange) ?? '', symbol: pick(market?.symbol) ?? '', coin: pick(market?.coin) ?? '' };
7619
8417
  // The chart's chain by the ONE resolution every chain class reads (opra-option-lanes.util `resolveWrunChartChain`,
7620
- // over the chart's own metadata, its category included: `option_surface` reads the same one). A chain directory's
7621
- // own failure on a chart its plane governs (CME futures; a US stock, ETF or OPRA contract chart under the opra flag)
7622
- // is the decision's evidence for `cme-directory` or `opra-directory` (a service that did not answer, Retry), never a
7623
- // guess at another chain; any other resolver failure fails the run as before. On the OPRA plane the chain is the
7624
- // plane's own by coin, read off the plane itself (O1): no directory read stands before the lane's ask.
7625
- const held = await wrunHeldOpraPlaneChain(chartMarket.exchange, chartMarket.coin);
7626
- const chain = held ?? (await resolveWrunChartChain(chartMetadata));
8418
+ // over the chart's own metadata, its category included: `option_surface` reads the same one, and over the run's one
8419
+ // options market when the head decided it). A chain directory's own failure on a chart its plane governs (CME
8420
+ // futures; a US stock, ETF or OPRA contract chart under the opra flag) is the decision's evidence for `cme-directory`
8421
+ // or `opra-directory` (a service that did not answer, Retry), never a guess at another chain; any other resolver
8422
+ // failure fails the run as before. On the OPRA plane the chain is the plane's own by coin, read off the plane itself
8423
+ // (O1): no directory read stands before the lane's ask. The plane verdict is the head's when it decided one.
8424
+ const held = await wrunHeldOpraPlaneChain(chartMarket.exchange, chartMarket.coin, options !== undefined ? options.plane === 'opra' : undefined, chartMarket.symbol);
8425
+ const chain = held ?? (await resolveWrunChartChain(chartMetadata, options));
7627
8426
  const { chartSource } = chain;
7628
8427
  const marketLabel = `${pick(market?.exchange) ?? 'currentExchange'}/${pick(market?.symbol) ?? 'currentSymbol'}`;
7629
8428
  const chainInputs = metadata.inputs.filter((input) => metadata.inputSources[input.name]?.source === 'options_chain');
@@ -7634,20 +8433,16 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
7634
8433
  .filter(isWrunOptionsChainCryptoVenueWord)),
7635
8434
  ],
7636
8435
  chartSource,
7637
- chartCoin: pick(market?.coin),
8436
+ // A stock twin's crypto venue words ask the listing for its stock's ticker (the lane market's coin).
8437
+ chartCoin: lane?.coin ?? pick(market?.coin),
7638
8438
  });
7639
8439
  let resolved;
7640
8440
  for (const input of chainInputs) {
7641
8441
  const source = metadata.inputSources[input.name];
8442
+ const who = { ...chartMarket, inputName: input.name, official, opraUserScripts, marketLabel };
7642
8443
  // The ONE venue decision every chain class reads (`decideWrunLaneChainIdentity`), so a package reading
7643
- // `option_surface` beside the chain reads one venue.
7644
- const decision = decideWrunLaneChainIdentity({ chain, cryptoVenues, deribitListed: hasDeribitOptions }, source.venue, {
7645
- ...chartMarket,
7646
- inputName: input.name,
7647
- official,
7648
- opraUserScripts,
7649
- marketLabel,
7650
- });
8444
+ // `option_surface` beside the chain reads one venue; over another root's chain for an `underlying` root.
8445
+ const decision = (await wrunUnderlyingOptionsChainDecision(source, who, metadata.params ?? [], paramValues, chain)) ?? decideWrunLaneChainIdentity({ chain, cryptoVenues, deribitListed: hasDeribitOptions }, source.venue, who);
7651
8446
  // The decision's reason picks the record's seed (WRUN-REFUSALS U3a step 6).
7652
8447
  if (!decision.ok)
7653
8448
  throw wrunOptionsChainRefusalError(decision);
@@ -7673,6 +8468,17 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
7673
8468
  `one options_chain lane, one through views and one whole (${WRUN_OPTION_VIEWS_ONE_ASK_CODE}): declare ` +
7674
8469
  'views on both, or on neither'), wrunAuthorRuleSeed(WRUN_OPTION_VIEWS_ONE_ASK_CODE));
7675
8470
  }
8471
+ // The gateway sizes B on its page from the inputs' expiries word (their `nearest:N` when every input declares one;
8472
+ // none when one reads every expiry) and budget (the smallest max_cells), for a view ask and the implicit WHOLE alike
8473
+ // (O2): the lane scope's own inputs (`wrunOptionsChainLaneScope`), so B is the block today's scoped page builds.
8474
+ const nearest = laneInputs.flatMap((input) => (input.expiries?.kind === 'nearest' ? [input.expiries.count] : []));
8475
+ const budgets = laneInputs
8476
+ .map((input) => Number(input.maxCells))
8477
+ .filter((cells) => Number.isFinite(cells) && cells > 0);
8478
+ const gatewayScope = {
8479
+ ...(nearest.length === laneInputs.length ? { nearestExpiries: Math.max(...nearest) } : {}),
8480
+ ...(budgets.length > 0 ? { maxContracts: Math.floor(Math.min(...budgets)) } : {}),
8481
+ };
7676
8482
  if (firstWithViews >= 0) {
7677
8483
  // One block B for the lane, built for one expiries word: view inputs of two words would read views of one B, so
7678
8484
  // the lane refuses by name (the SDK asks each word apart; one acquisition per word would serve them).
@@ -7689,27 +8495,24 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
7689
8495
  `(${WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE}): declare the same expiries on every view input of one ` +
7690
8496
  'options_chain lane (this host builds one block for the lane)'), wrunAuthorRuleSeed(WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE));
7691
8497
  }
7692
- // A view ask on any chain: the gateway sizes B on its page from the inputs' one expiries word (its `nearest:N`,
7693
- // none when they read every expiry) and budget (the smallest max_cells) (O2).
7694
- const nearest = laneInputs.flatMap((input) => (input.expiries?.kind === 'nearest' ? [input.expiries.count] : []));
7695
- const budgets = laneInputs
7696
- .map((input) => Number(input.maxCells))
7697
- .filter((cells) => Number.isFinite(cells) && cells > 0);
7698
- const viewFields = wrunOptionViewLaneFields('options_chain', wrunOptionViewsUnion(viewSets.filter((views) => views !== undefined)), {
7699
- ...(nearest.length === laneInputs.length ? { nearestExpiries: Math.max(...nearest) } : {}),
7700
- ...(budgets.length > 0 ? { maxContracts: Math.floor(Math.min(...budgets)) } : {}),
7701
- });
8498
+ // A view ask on any chain, its one expiries word the gateway's scope input.
8499
+ const viewFields = wrunOptionViewLaneFields('options_chain', wrunOptionViewsUnion(viewSets.filter((views) => views !== undefined)), gatewayScope);
7702
8500
  const viewIdentity = identity.venue === 'cme' || identity.venue === 'opra'
7703
8501
  ? { ...identity, servedTier: governedOptionSummaryTier(identity.exchange) }
7704
8502
  : identity;
7705
8503
  return { ...wrunOptionsChainLaneExtras(viewIdentity), ...viewFields };
7706
8504
  }
8505
+ // A crypto chain keeps its plain reader (OPTLOAD W3 decision 1): the gateway's B prices an expiry at its page's one
8506
+ // underlying, where the crypto read takes each contract's own sample.
7707
8507
  if (identity.venue !== 'cme' && identity.venue !== 'opra')
7708
8508
  return wrunOptionsChainLaneExtras(identity);
7709
- // A governed chain asks the scope the package's declared appetite fits (`wrunOptionsChainLaneScope`: the smallest
7710
- // max_cells over its chain inputs), sized on the chain's live expiry count.
7711
- const scope = wrunOptionsChainLaneScope(laneInputs, await wrunGovernedLiveExpiryCount(identity));
7712
- return wrunOptionsChainLaneExtras({ ...identity, scope, servedTier: governedOptionSummaryTier(identity.exchange) });
8509
+ // A governed chain whose inputs declare no views reads B whole through the implicit view (OPTLOAD W3 FE-CHAIN): ONE
8510
+ // summary read of the gateway's WHOLE view, sized on its page, with no expiry directory before it (the inputs apply
8511
+ // their own expiries words to B as they land, as they did to today's scoped page).
8512
+ return {
8513
+ ...wrunOptionsChainLaneExtras({ ...identity, servedTier: governedOptionSummaryTier(identity.exchange) }),
8514
+ ...wrunOptionsChainImplicitViewFields(gatewayScope),
8515
+ };
7713
8516
  }
7714
8517
  /**
7715
8518
  * One run's OPRA provenance writer (options-overlay-provenance.util `setOptionsOverlayOpraProvenance`, both
@@ -7741,54 +8544,6 @@ async function wrunOpraProvenanceWriter(chartIndex, indicatorId, ownership) {
7741
8544
  return true;
7742
8545
  };
7743
8546
  }
7744
- /**
7745
- * How many expiries a governed chain lists live now: its plane's expiry directory, the one
7746
- * StreamOptionChain read the option chain service caches (`listOptionExpiries`, the same answer the
7747
- * worker's chain store sizes its own reads by), read for the underlying the chain's summary serves
7748
- * (`wrunChainDirectoryUnderlying`) and bounded by the source fetch deadline. Undefined when it cannot
7749
- * be read, its underlying cannot be resolved, or it lists none (a directory that names no live expiry
7750
- * tells nothing): the lane scope then sizes for an unknown count (the most expiries the budget fits at
7751
- * the floor window), never for one. Lazy imports: the service reaches the metadata service and the gate
7752
- * transport.
7753
- */
7754
- async function wrunGovernedLiveExpiryCount(identity) {
7755
- try {
7756
- const [{ default: optionChainService }, { Exchange }] = await Promise.all([
7757
- wrunChartHostEnv().market.loadOptionChainService(),
7758
- import('@orangecharts/orange-v2-pb-common'),
7759
- ]);
7760
- // The wire enum of the chain's exchange (a name this pb-common build lacks reads no listing).
7761
- const exchange = Exchange[identity.exchange.toUpperCase()];
7762
- if (typeof exchange !== 'number')
7763
- return undefined;
7764
- const expiries = await withWrunDeadline((async () => {
7765
- const underlying = await wrunChainDirectoryUnderlying(identity);
7766
- if (underlying === null)
7767
- return [];
7768
- return optionChainService.forVenue(identity.venue).listOptionExpiries({ exchange, underlying });
7769
- })(), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun options chain expiry directory for ${identity.venue}:${identity.exchange}:${identity.underlying}`);
7770
- return expiries.length > 0 ? expiries.length : undefined;
7771
- }
7772
- catch {
7773
- return undefined;
7774
- }
7775
- }
7776
- /**
7777
- * The underlying a governed chain's expiry directory is listed for: the chain's own, or, for a
7778
- * continuous alias (`ES1!`), the outright leading it now through the continuous lead resolver
7779
- * (`getResolvedLead`, the roll rule the gateway's summary path resolves the alias with, fixture-pinned
7780
- * to it, and the one the terminal identity admitted the alias by), as the contract its options list on
7781
- * (`cmeOptionsContract`: MES1! leading on MESZ6 lists MESFZ6's). The directory never resolves an
7782
- * alias: it lists nothing for one. Null when the lead cannot be resolved.
7783
- */
7784
- async function wrunChainDirectoryUnderlying(identity) {
7785
- const { isContinuousSymbol } = await import('../chart/continuous-contracts.util.js');
7786
- if (!isContinuousSymbol(identity.underlying))
7787
- return identity.underlying;
7788
- const { default: continuousContracts } = await wrunChartHostEnv().market.loadContinuousContracts();
7789
- const lead = await continuousContracts.getResolvedLead(identity.exchange, identity.underlying);
7790
- return lead?.symbol ? cmeOptionsContract(lead.symbol) : null;
7791
- }
7792
8547
  /** A run target whose sheet is the sheet on the chart's market (wrunChartSizeUnit): a lane's
7793
8548
  * `currency: "Auto"` reads the unit it resolves to there (wrunSheetWithLaneCurrencies), an input
7794
8549
  * whose `needed_by` leaves the market's size unit out is not demanded (wrunSheetWithLaneDemand), and
@@ -7912,12 +8667,42 @@ function wrunInferredMainTick(tc) {
7912
8667
  * a price unit: it only picks the axis precision here. With `market` (the
7913
8668
  * chart metadata), the market's facts ride too (`kind`, `pointValue`, `zone`,
7914
8669
  * `quoteIsUsd`, `sessionOpen`: wrunMarketFactsFor, over the directory row a
7915
- * run of a package declaring `kind` or `quote_is_usd` awaited first). With
8670
+ * run of a package declaring `kind` or `quote_is_usd` awaited first), the
8671
+ * option multiplier read off the market whose options the chart reads: the
8672
+ * market's own `optionsExchange` when the caller names it (a run's one
8673
+ * decision), else the one the latest run on that chart market decided
8674
+ * (derived-roots.util `wrunDecidedOptionsExchange`: a stock twin reading its
8675
+ * stock's OPRA chain reads 100 on its live ticks too). With
7916
8676
  * `earnings` (the chart metadata, passed for a sheet that declares an
7917
8677
  * earnings fact), the issuer's earnings facts ride too (`earningsNextMs`,
7918
8678
  * `earningsPrevMs`, `earningsSession`: wrunEarningsFactsFor, over the earnings
7919
8679
  * window a run of such a package warmed first).
7920
8680
  */
8681
+ /** A facts market with the exchange its options read (`WrunFactsMarket.optionsExchange`): the caller's when it names
8682
+ * one, else the latest run's decision on that chart market (`wrunDecidedOptionsExchange`), else none (its own). */
8683
+ function wrunFactsMarketWithOptions(market) {
8684
+ if (market.optionsExchange !== undefined)
8685
+ return market;
8686
+ const optionsExchange = wrunDecidedOptionsExchange(market);
8687
+ return optionsExchange === undefined ? market : { ...market, optionsExchange };
8688
+ }
8689
+ /** The chart metadata as the facts read it beside the run's one options market (the head's decision): the exchange the
8690
+ * chart's options read rides along, so `market.option_multiplier()` follows the chain the run reads. */
8691
+ function wrunRunFactsMarket(chartMetadata, options) {
8692
+ const optionsExchange = options?.market.exchange;
8693
+ return chartMetadata === undefined || typeof optionsExchange !== 'string'
8694
+ ? chartMetadata
8695
+ : { ...chartMetadata, optionsExchange };
8696
+ }
8697
+ /** The chart metadata as a batch the cloud computed reads its facts (`integrateWrunRowSourceBatch`): the chart's own
8698
+ * market's, named outright so no browser run's decision on the chart stands in (`wrunDecidedOptionsExchange`). The
8699
+ * server resolves the chain of the chart market it is sent (follow-up: the backend's stock twin rule). */
8700
+ export function wrunCloudFactsMarket(chartMetadata) {
8701
+ const exchange = chartMetadata?.exchange;
8702
+ return chartMetadata === undefined || typeof exchange !== 'string'
8703
+ ? chartMetadata
8704
+ : { ...chartMetadata, optionsExchange: exchange };
8705
+ }
7921
8706
  export function wrunHostFillContextFor(tc, chartExchange, intervalMs, market, earnings) {
7922
8707
  const engine = tc;
7923
8708
  let engineTick;
@@ -7936,7 +8721,7 @@ export function wrunHostFillContextFor(tc, chartExchange, intervalMs, market, ea
7936
8721
  ...(tickSize !== undefined ? { tickSize } : {}),
7937
8722
  pricePrecision,
7938
8723
  ...wrunChartContextHostFill(tc, intervalMs),
7939
- ...(market !== undefined ? wrunMarketFactsFor(market) : {}),
8724
+ ...(market !== undefined ? wrunMarketFactsFor(wrunFactsMarketWithOptions(market)) : {}),
7940
8725
  // The issuer's earnings facts: the browser run's alone (a hosted lane's host fill never carries them).
7941
8726
  ...(earnings !== undefined ? wrunEarningsFactsFor(earnings) : {}),
7942
8727
  };
@@ -8012,16 +8797,35 @@ export function wrunOutputRowsOnChartBars(outputRows, chart, run) {
8012
8797
  }
8013
8798
  return shown;
8014
8799
  }
8800
+ /**
8801
+ * The Style targets the latest-values snapshot names as drawing nothing (WrunLatestSnapshot.emptyTargets, the Style
8802
+ * page's silent lines): the applied result's own, judged over the whole loaded range. A result computed over a
8803
+ * window of it (`partial`) speaks for that window only, and the mount keeps its rows outside, so it can clear a
8804
+ * target (values in the window) but never mark one: the previous snapshot's targets it still finds empty. A
8805
+ * republish that built no result (`applied` absent) carries the previous snapshot's forward.
8806
+ */
8807
+ export function wrunSnapshotEmptyTargets(previous, applied) {
8808
+ if (applied === undefined)
8809
+ return [...(previous ?? [])];
8810
+ const judged = applied.emptyTargets ?? [];
8811
+ if (applied.partial !== true)
8812
+ return [...judged];
8813
+ const kept = new Set(previous ?? []);
8814
+ return judged.filter((target) => kept.has(target));
8815
+ }
8015
8816
  /**
8016
8817
  * What follows every successful integrate, the full run's, the reseed's and
8017
8818
  * the tick's (after the lower-pane children mounted): the nested output
8018
8819
  * visibility the sheet (`visible: false`) and the Style page's Visible rows
8019
8820
  * ask for (U9's `applyWrunOutputVisibility`, parent and children), and the
8020
8821
  * latest-values snapshot the HUD layer, the legend and the hover inspector
8021
- * read (`publishWrunLatestValues`), then the Indicator store's seen note for
8022
- * a registry Indicator (`noteWrunRegistryRun`: once a page and day, the maker's
8023
- * private reach; both row sources pass here). Presentation only: a failure here
8024
- * is logged, never a second failure over a run that rendered.
8822
+ * read (`publishWrunLatestValues`; a republish leaves a refused full run's
8823
+ * snapshot as it is, `WrunLatestPublishOrigin`) with the applied result's
8824
+ * `emptyTargets` (the Style page dims those lines), then the Indicator store's
8825
+ * seen note for a registry Indicator (`noteWrunRegistryRun`: once a page and
8826
+ * day, the maker's private reach; both row sources pass here). Presentation
8827
+ * only: a failure here is logged, never a second failure over a run that
8828
+ * rendered.
8025
8829
  */
8026
8830
  export function presentWrunIntegration(chartIndex, indicatorId, metadata, settings, outputRows, chart, initArgs,
8027
8831
  // The chart names the run's text was integrated with (the session's own):
@@ -8030,7 +8834,10 @@ chartNames,
8030
8834
  // The run's stamp when it ran at another interval than the chart: the
8031
8835
  // snapshot reads the chart's newest bar as the projection shows it (the
8032
8836
  // run bar before the forming one, with wait for close on).
8033
- runInterval) {
8837
+ runInterval, origin = 'run',
8838
+ // What the integrate applied, for the snapshot's `emptyTargets` (wrunSnapshotEmptyTargets): absent for a
8839
+ // republish that built no result (a landed pan page).
8840
+ applied) {
8034
8841
  try {
8035
8842
  // Guarded like the tick lane's seams: a node spec that mocks the adapter
8036
8843
  // module partially leaves the export out (production always has it).
@@ -8042,13 +8849,22 @@ runInterval) {
8042
8849
  console.warn(`[wrun] output visibility failed for '${indicatorId}' (chart ${chartIndex}):`, error);
8043
8850
  }
8044
8851
  try {
8045
- const snapshot = wrunLatestSnapshotOf(metadata, runInterval ? wrunOutputRowsOnChartBars(outputRows, chart, runInterval) : outputRows, chartNames);
8046
- // A tick republish carries the run's init args forward (the args a tick evaluates with are the
8047
- // session seed's, unchanged since the last full run or reseed).
8048
- const carried = initArgs ?? wrunChartHostEnv().chart.latestSnapshot(chartIndex, indicatorId)?.initArgs;
8049
- if (carried)
8050
- snapshot.initArgs = [...carried];
8051
- wrunChartHostEnv().chart.publishLatestValues(chartIndex, indicatorId, snapshot);
8852
+ const shown = wrunChartHostEnv().chart.latestSnapshot(chartIndex, indicatorId);
8853
+ // A refused full run's snapshot stands until a verdict that supersedes it publishes (a full run, a reseed):
8854
+ // a republish would bring back the numbers of the computation the refusal superseded.
8855
+ if (origin === 'run' || shown?.refused === undefined) {
8856
+ const snapshot = wrunLatestSnapshotOf(metadata, runInterval ? wrunOutputRowsOnChartBars(outputRows, chart, runInterval) : outputRows, chartNames);
8857
+ // A tick republish carries the run's init args forward (the args a tick evaluates with are the
8858
+ // session seed's, unchanged since the last full run or reseed).
8859
+ const carried = initArgs ?? shown?.initArgs;
8860
+ if (carried)
8861
+ snapshot.initArgs = [...carried];
8862
+ // The Style targets the chart shows nothing for: the Style page dims their lines.
8863
+ const empty = wrunSnapshotEmptyTargets(shown?.emptyTargets, applied);
8864
+ if (empty.length > 0)
8865
+ snapshot.emptyTargets = empty;
8866
+ wrunChartHostEnv().chart.publishLatestValues(chartIndex, indicatorId, snapshot);
8867
+ }
8052
8868
  }
8053
8869
  catch (error) {
8054
8870
  console.warn(`[wrun] latest values publish failed for '${indicatorId}' (chart ${chartIndex}):`, error);
@@ -8283,7 +9099,7 @@ async function reintegrateWrunSessionCanvases(indicatorId, context, fill, curren
8283
9099
  candles: context.candles,
8284
9100
  chartNames,
8285
9101
  legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
8286
- sizeUnit: wrunChartSizeUnit(context.market),
9102
+ ...wrunResultMarketUnits(context.market),
8287
9103
  ...(runSession
8288
9104
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
8289
9105
  : {}),
@@ -8304,7 +9120,9 @@ async function reintegrateWrunSessionCanvases(indicatorId, context, fill, curren
8304
9120
  await publishWrunSessionCanvasNotices(context, runResult);
8305
9121
  if (getWrunOverlayLiveContext(indicatorId) !== context)
8306
9122
  return;
8307
- presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run);
9123
+ presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run,
9124
+ // The session's rows again: a full run refused since keeps its snapshot.
9125
+ 'republish', { emptyTargets: runResult.emptyTargets, partial: clamped !== undefined });
8308
9126
  context.paintedThroughTs = context.lastRowTs;
8309
9127
  context.repaintOwed = false;
8310
9128
  }
@@ -8405,11 +9223,11 @@ export async function publishWrunStrategyRunResult(chartIndex, indicatorId, runR
8405
9223
  * lines were ever written for it and there is nothing to clear, and the
8406
9224
  * store stays out of every run of a package without a debug log. The store
8407
9225
  * is loaded lazily like the strategy publish. */
8408
- async function publishWrunDebugOutput(chartIndex, indicatorId, metadata, rows) {
9226
+ async function publishWrunDebugOutput(chartIndex, indicatorId, metadata, rows, provenance) {
8409
9227
  if (wrunDebugSlotIndex(metadata) === undefined)
8410
9228
  return;
8411
9229
  const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
8412
- useChartStore().setIndicatorPrintOutputs(chartIndex, indicatorId, selectWrunDebugLines(metadata, rows));
9230
+ useChartStore().setIndicatorPrintOutputs(chartIndex, indicatorId, selectWrunDebugLines(metadata, rows), provenance);
8413
9231
  }
8414
9232
  /**
8415
9233
  * A sheet with colour settings: the overlay palette (the collapsed-legend
@@ -8576,6 +9394,25 @@ function wrunMountMemoOf(meta) {
8576
9394
  }
8577
9395
  return memo;
8578
9396
  }
9397
+ /**
9398
+ * The result a mounted overlay shows now, as it was built, with the window it was computed over (the
9399
+ * workspace switch's stand-in capture stores it, kscript-standin-switch.util): the live tick's last
9400
+ * applied build (`liveApplied`), else the result this lane's last full integrate applied while its
9401
+ * rows are still the ones mounted (the mount memo: a tick's whole integrate, a blank or a stand-in
9402
+ * replaces them), else undefined. While a repaint is owed the chart lags the session, so nothing on
9403
+ * it is known to show: undefined. Nothing is rebuilt or patched here.
9404
+ */
9405
+ export function wrunMountedRunResultOf(indicatorId, meta) {
9406
+ const context = getWrunOverlayLiveContext(indicatorId);
9407
+ if (context?.repaintOwed)
9408
+ return undefined;
9409
+ if (context?.liveApplied)
9410
+ return { runResult: context.liveApplied.result, window: context.window };
9411
+ const memo = wrunMountMemos.get(meta);
9412
+ if (memo?.lastResult === undefined || memo.lastRows !== meta.rawData)
9413
+ return undefined;
9414
+ return { runResult: memo.lastResult, window: memo.lastWindow };
9415
+ }
8579
9416
  /** The result renders equal to the one this lane applied last, and that one is still what the
8580
9417
  * overlay shows: the same window recomputed (a page lands its children's rows inside it, so another
8581
9418
  * window is never the same apply), the parent equal (`kscriptRunResultsRenderEqual`: rows, drawings,
@@ -9241,7 +10078,7 @@ let wrunWarmupHeadPageSerial = 0;
9241
10078
  * unserved (a laundered connection failure, an embargoed window) or rejected page. `lane` names the head in the transport id, the diagnostics and the grid guard: an exact warm-up
9242
10079
  * session's (`wrun-warmup-head`) or the cloud's warm-up head (`wrun-lane-warmup`, row 53).
9243
10080
  */
9244
- async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane = 'wrun-warmup-head') {
10081
+ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, meter, lane = 'wrun-warmup-head') {
9245
10082
  wrunWarmupHeadPageSerial += 1;
9246
10083
  const ovId = `${lane}-${wrunWarmupHeadPageSerial}`;
9247
10084
  const from = Math.floor(fromTs / 1000);
@@ -9258,6 +10095,8 @@ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane =
9258
10095
  // head store would keep the gap as walked.
9259
10096
  let served = false;
9260
10097
  let failed = false;
10098
+ // The page's completion (its own request, never shared): what it downloaded is the run's.
10099
+ const heard = { completed: false };
9261
10100
  const controller = new AbortController();
9262
10101
  try {
9263
10102
  await withWrunDeadline(request.transport.fetchData('OHLCV', payload, chartIndex, {
@@ -9273,6 +10112,8 @@ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane =
9273
10112
  },
9274
10113
  onComplete: (info) => {
9275
10114
  served = info?.completedOnWire === true && info.embargoed !== true;
10115
+ heard.completed = true;
10116
+ heard.info = info;
9276
10117
  },
9277
10118
  signal: controller.signal,
9278
10119
  shareable: false,
@@ -9283,6 +10124,22 @@ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane =
9283
10124
  controller.abort();
9284
10125
  return null;
9285
10126
  }
10127
+ if (heard.completed) {
10128
+ const { info } = heard;
10129
+ meter.charge({
10130
+ key: ovId,
10131
+ kType: 'OHLCV',
10132
+ verdict: {
10133
+ complete: served,
10134
+ servedEmpty: info?.servedEmpty === true,
10135
+ source: 'wire',
10136
+ ...(typeof info?.wireBytes === 'number'
10137
+ ? { wireBytes: info.wireBytes, wireFrames: info.wireFrames ?? 0, wirePoints: info.wirePoints ?? 0 }
10138
+ : {}),
10139
+ },
10140
+ ...wrunDownloadAnswerSize(replied),
10141
+ });
10142
+ }
9286
10143
  if (failed || !served)
9287
10144
  return null;
9288
10145
  request.lane.stripMainCandleRows(replied, 0);
@@ -9430,7 +10287,7 @@ async function acquireWrunWarmupHead(args) {
9430
10287
  if (getChartDataFetchGeneration(args.chartIndex) !== dataGen)
9431
10288
  break;
9432
10289
  pages += 1;
9433
- const answered = await fetchWrunWarmupHeadPage(args.chartIndex, request, fromTs, toTs);
10290
+ const answered = await fetchWrunWarmupHeadPage(args.chartIndex, request, fromTs, toTs, args.meter);
9434
10291
  if (answered === null)
9435
10292
  break;
9436
10293
  const page = [];
@@ -9547,7 +10404,7 @@ async function acquireWrunLaneWarmupHead(args) {
9547
10404
  if (getChartDataFetchGeneration(args.chartIndex) !== dataGen)
9548
10405
  break;
9549
10406
  pages += 1;
9550
- const answered = await fetchWrunWarmupHeadPage(args.chartIndex, args.request, fromTs, toTs, 'wrun-lane-warmup');
10407
+ const answered = await fetchWrunWarmupHeadPage(args.chartIndex, args.request, fromTs, toTs, args.meter, 'wrun-lane-warmup');
9551
10408
  if (answered === null)
9552
10409
  break;
9553
10410
  const page = [];
@@ -10311,11 +11168,11 @@ function wrunPrefixBatchedGapRows(mountedMetas, context, sheet, child, childId,
10311
11168
  * reconcile). Packed only: the session the candidate rules admitted rode it, and a decline hands
10312
11169
  * the page to the full run.
10313
11170
  */
10314
- async function fetchWrunPrefixBookRows(context, meta, fromTs, toTs) {
11171
+ async function fetchWrunPrefixBookRows(context, meta, fromTs, toTs, meter) {
10315
11172
  const { preferPackedOrderbookWorker: _packed, ...acquisition } = (context.acquisition.book ?? {});
10316
11173
  const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, 'orderbook', { symbol: 'currentSymbol', exchange: 'currentExchange', ...acquisition }, fromTs, toTs, meta, `${context.fetchKey}-prefix-ob`, false,
10317
11174
  // The full run stamped the legend; a prefix page never restamps it.
10318
- { preferPackedOrderbookWorker: true, silentLegend: true }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun prefix source fetch 'orderbook' for '${context.fetchKey}'`);
11175
+ { preferPackedOrderbookWorker: true, silentLegend: true, meter }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun prefix source fetch 'orderbook' for '${context.fetchKey}'`);
10319
11176
  if (isPackedOhlcvRows(fetched))
10320
11177
  return unpackOhlcvRows(fetched);
10321
11178
  if (Array.isArray(fetched))
@@ -10366,7 +11223,7 @@ function wrunPrefixDegradedPageDetail(lane, outcome) {
10366
11223
  * when the session's buffer holds none either (the page of an old stretch, a lane's horizon past it, reads empty as a
10367
11224
  * whole run's older bars do).
10368
11225
  */
10369
- async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata) {
11226
+ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata, meter) {
10370
11227
  const pages = new Map();
10371
11228
  if (plan.builtin.length === 0 && plan.poll.length === 0 && plan.daily.length === 0 && plan.rows.length === 0) {
10372
11229
  return { pages };
@@ -10384,6 +11241,7 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
10384
11241
  {
10385
11242
  ...fetchOptions,
10386
11243
  silentLegend: true,
11244
+ meter,
10387
11245
  onSourceVerdict: (heard) => {
10388
11246
  verdict = heard;
10389
11247
  },
@@ -10817,7 +11675,7 @@ function wrunPrefixSnapshotsStale(prepared, tc, meta, indicatorId) {
10817
11675
  * parent payload for the merge route, and every heatmap child's window landing (C6). Every await of the
10818
11676
  * run is here; the commit reads what this returns and awaits nothing.
10819
11677
  */
10820
- async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt) {
11678
+ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt, computed) {
10821
11679
  const { chartIndex, indicatorId } = runTarget;
10822
11680
  const requestId = window.prefix.requestId;
10823
11681
  // The session the executor planned the window against, still the overlay's (a newer pan wave may
@@ -10863,6 +11721,9 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10863
11721
  if (windowRows.length === 0 || windowRows[0][0] !== window.fromMs) {
10864
11722
  return wrunPrefixRejected('stale', 'the window is no longer loaded');
10865
11723
  }
11724
+ // What the page downloads, from its first ask on, against the budget of its window's bars.
11725
+ const download = createWrunDownloadMeter(windowRows.length);
11726
+ computed.download = download;
10866
11727
  // The admission again, the plan's rule (O8f): an exact warm-up session admitted on its warm guest runs from W
10867
11728
  // candles before the window, its hidden head asked through the main candle request; a session the roster admits
10868
11729
  // never needs warmth (a listed package with a cold warm-up stamp runs its page as the roster runs it). A guest no
@@ -10884,6 +11745,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10884
11745
  beforeTs: window.fromMs,
10885
11746
  bars: warmupBars,
10886
11747
  intervalMs: context.intervalMs,
11748
+ meter: download,
10887
11749
  });
10888
11750
  ringWrunWarmupHead(chartIndex, indicatorId, 'prefix', warmupBars, acquired);
10889
11751
  if ('miss' in acquired) {
@@ -10912,9 +11774,9 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10912
11774
  // other lane's page at once: a book the capability rule never dispatched reads empty, as the session's does.
10913
11775
  const [bookRows, lanePages] = await Promise.all([
10914
11776
  context.acquisition.book !== undefined
10915
- ? fetchWrunPrefixBookRows(context, meta, window.fromMs, window.toMs)
11777
+ ? fetchWrunPrefixBookRows(context, meta, window.fromMs, window.toMs, download)
10916
11778
  : Promise.resolve(context.bookRows !== undefined ? [] : undefined),
10917
- acquireWrunPrefixLanePages(context, meta, lanePlan, window.fromMs, firstRowTs, chartMetadata),
11779
+ acquireWrunPrefixLanePages(context, meta, lanePlan, window.fromMs, firstRowTs, chartMetadata, download),
10918
11780
  ]);
10919
11781
  // A lane whose page could not be had (declined, failed, out of budget, or empty where the full run degrades it):
10920
11782
  // the data, never the module. Nothing staged lands; the wave's full run follows.
@@ -10983,7 +11845,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10983
11845
  candles: runTarget.candles,
10984
11846
  ...(chartNames !== undefined ? { chartNames } : {}),
10985
11847
  ...(priceDigits !== undefined ? { priceDigits } : {}),
10986
- sizeUnit: wrunChartSizeUnit(chartMetadata),
11848
+ ...wrunResultMarketUnits(chartMetadata),
10987
11849
  cellRows: wrunCellRowsOf(context.metadata, sourceRows),
10988
11850
  intervalMs: clock.intervalMs,
10989
11851
  ...(chartExchange !== undefined ? { exchange: chartExchange } : {}),
@@ -11548,7 +12410,7 @@ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
11548
12410
  * (C7). Never throws: the executor sees a settled run either way, and a prefix never words a failure.
11549
12411
  * The commit boundary is `withWrunOverlaySessionLock` around `commitWrunPrefixRun`.
11550
12412
  */
11551
- async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner) {
12413
+ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner, computed) {
11552
12414
  const { chartIndex, indicatorId } = runTarget;
11553
12415
  const startedAt = wrunHostClockMs();
11554
12416
  const planned = getWrunOverlayLiveContext(indicatorId);
@@ -11556,7 +12418,7 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner)
11556
12418
  let prepared;
11557
12419
  let outcome;
11558
12420
  try {
11559
- const ready = await prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt);
12421
+ const ready = await prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt, computed);
11560
12422
  if (ready.kind === 'rejected') {
11561
12423
  outcome = ready;
11562
12424
  }
@@ -11647,7 +12509,9 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
11647
12509
  const { chartIndex, indicatorId } = runTarget;
11648
12510
  const { context, sheetNow } = prepared;
11649
12511
  markWrunOverlayComputeSucceeded(indicatorId);
11650
- presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), null);
12512
+ presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), null,
12513
+ // The session's rows with older bars: a full run refused since keeps its snapshot.
12514
+ 'republish');
11651
12515
  try {
11652
12516
  const health = wrunSessionRunHealth(context, meta.settings, context.outputRows);
11653
12517
  context.runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, context.draft === true, wrunNothingReadyRefusal(health, refusal.ctx)));