@orangecharts/wrun-chart-host 0.8.0 → 0.9.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 (145) hide show
  1. package/README.md +2 -1
  2. package/dist/constants/feature-flags.constants.d.ts +4 -0
  3. package/dist/constants/feature-flags.constants.js +27 -0
  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 +14 -0
  7. package/dist/constants/opra-compliance.constants.js +14 -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/host-env.d.ts +10 -4
  11. package/dist/host-ports.types.d.ts +39 -3
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +1 -0
  14. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  15. package/dist/interfaces/opra-realtime.interface.js +10 -10
  16. package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
  17. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +53 -10
  18. package/dist/kscript-data/controls/live-trades-merge.util.js +81 -16
  19. package/dist/market-data/billing.interface.d.ts +138 -17
  20. package/dist/market-data/billing.interface.js +25 -8
  21. package/dist/market-data/venues/index.d.ts +3 -3
  22. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  23. package/dist/market-data/venues/opra.d.ts +3 -3
  24. package/dist/market-data/venues/opra.js +5 -4
  25. package/dist/replay/replayLadder.js +3 -1
  26. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  27. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  28. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  29. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  30. package/dist/utility/chart/index-mode.util.js +23 -13
  31. package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
  32. package/dist/utility/chart/kscript-venue-policy.util.js +30 -24
  33. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  34. package/dist/utility/chart/marketKind.util.js +17 -7
  35. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  36. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  37. package/dist/utility/chart/om-panel.util.js +6 -6
  38. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  39. package/dist/utility/chart/profile-block-size.util.js +7 -0
  40. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  41. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  42. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
  43. package/dist/utility/chart/wrun-run-result.util.js +4 -1
  44. package/dist/utility/common/transformations.util.d.ts +7 -0
  45. package/dist/utility/common/transformations.util.js +11 -0
  46. package/dist/utility/options/option-venue.util.d.ts +3 -3
  47. package/dist/utility/options/option-venue.util.js +3 -3
  48. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
  49. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
  50. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  51. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  52. package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
  53. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  54. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
  55. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +11 -0
  56. package/dist/utility/wrun/sources/row-lanes/option_prints.js +63 -9
  57. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +8 -0
  58. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +12 -0
  59. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
  60. package/dist/utility/wrun/sources/row-lanes/option_surface.js +5 -2
  61. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +11 -5
  62. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +31 -10
  63. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +33 -1
  64. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +95 -6
  65. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
  66. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +55 -18
  67. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +146 -40
  68. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  69. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  70. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  71. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  72. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  73. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  74. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  75. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
  76. package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
  77. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  78. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  79. package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
  80. package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
  81. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  82. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  83. package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
  84. package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
  85. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
  86. package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
  87. package/dist/utility/wrun/wrun-frames.js +5 -5
  88. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  89. package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
  90. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
  91. package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
  92. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  93. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  94. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  95. package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
  96. package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
  97. package/dist/utility/wrun/wrun-live-tick.util.js +91 -38
  98. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  99. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  100. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +166 -48
  101. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +216 -33
  102. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
  103. package/dist/utility/wrun/wrun-market-size-defaults.util.js +314 -56
  104. package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
  105. package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
  106. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +3 -0
  107. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +3 -0
  108. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +23 -0
  109. package/dist/utility/wrun/wrun-option-strike-flow.util.js +55 -0
  110. package/dist/utility/wrun/wrun-option-views.util.d.ts +51 -7
  111. package/dist/utility/wrun/wrun-option-views.util.js +151 -28
  112. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  113. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  114. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  115. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  116. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  117. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
  118. package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
  119. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  120. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  121. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
  122. package/dist/utility/wrun/wrun-overlay-run.util.js +416 -171
  123. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
  124. package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
  125. package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
  126. package/dist/utility/wrun/wrun-pack.util.js +20 -9
  127. package/dist/utility/wrun/wrun-panel-style.util.d.ts +27 -15
  128. package/dist/utility/wrun/wrun-panel-style.util.js +42 -20
  129. package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
  130. package/dist/utility/wrun/wrun-param-map.util.js +8 -5
  131. package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
  132. package/dist/utility/wrun/wrun-param-values.util.js +2 -0
  133. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  134. package/dist/utility/wrun/wrun-refusal.util.js +10 -1
  135. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +7 -0
  136. package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
  137. package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
  138. package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
  139. package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
  140. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  141. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  142. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  143. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  144. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  145. package/package.json +11 -11
@@ -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,7 @@ 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';
159
160
  import { clearedColorCustomizationFlags } from '../chart/color-customization.leaf.js';
160
161
  import { WRUN_LATEST_HISTORY_LENGTH } from './wrun-latest-history.leaf.js';
161
162
  import { resolveChartPricePrecision } from '../chart/price-precision.util.js';
@@ -166,20 +167,21 @@ import { kScriptSettingsRevision } from '../chart/kscript-settings-revision.leaf
166
167
  import { getChartMountEpoch } from '../chart/chart-mount-epoch.util.js';
167
168
  import { checkIsIndexMode } from '../chart/index-mode.util.js';
168
169
  import { checkIsCryptoIndex } from '../chart/crypto-index.leaf.js';
170
+ import { checkIsQuotePerp } from '../chart/quote-perp.leaf.js';
169
171
  import { buildMixedModeContext, getFirstTokenMode } from '../chart/mixed-mode.util.js';
170
172
  import { inferPriceTickFromRows } from '../chart/footprint-band.util.js';
171
173
  import { getMarketKind } from '../chart/marketKind.util.js';
172
174
  import { isCmeGoverned } from '../chart/cme-realtime.util.js';
173
- import { wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
175
+ import { wrunBarSessionFactsResolver, wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
176
+ import { wrunPresentIsPartial } from './wrun-present-bits.util.js';
174
177
  import { assertWrunPinnedLegVenues, partitionWrunLegsByVenue, wrunLegFetchedRowReaders, wrunLegRidesNativeRows, wrunPinnedLegRefusalOf, wrunPinVenueVerdict, } from './wrun-pin-venues.util.js';
175
178
  import { annotateWrunErrorFailureRow, annotateWrunErrorIndicatorId, isWrunOverlayPausedError, isWrunQuarantinedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunDeadlineError, WrunIntegrationError, WrunNoBarsError, WrunOverlayPausedError, WrunSourceDataUnavailableError, WrunVenueBlockedError, } from './wrun-registry-errors.util.js';
176
- 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';
179
+ import { createKScriptVenueBlockedError, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptRun, } from '../chart/kscript-venue-policy.util.js';
178
180
  import { governedMarketDataTier, governedOptionSummaryTier } from '../v2/governed-tier.leaf.js';
179
181
  import { awaitWrunChildOverlays, mountWrunChildOverlays, prepareWrunHeatmapWindowLanding, WrunStaleLandingError, } from './wrun-panel-mount.util.js';
180
182
  import { planWrunFormingPreRoll, planWrunIntrabarLegFetch, planWrunLegFetch, wrunClampedLegDiagnostics, wrunIntrabarServedNotes, wrunLegFetchReads, } from './wrun-leg-fetch.util.js';
181
183
  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';
184
+ 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
185
  import { wrunChartSession, wrunLegCandleClose, wrunPrimaryRowBounds } from './wrun-leg-close.util.js';
184
186
  import { isWrunRowSourceTransientError, wrunRowBatchDeliveredSheet, wrunRowSourceSettingsLeftBy, } from './wrun-row-source.js';
185
187
  import { wrunOverlayOpraStamped } from './wrun-cloud-opra-stamp.util.js';
@@ -188,7 +190,7 @@ import { __resetWrunSocketSessionLossesForTests, noteWrunSocketSessionLoss, wrun
188
190
  import { isWrunRunMountOnChart, raiseWrunSandboxLoading, wrunRowBatchCellRows, } from './wrun-sandbox-row-source.js';
189
191
  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
192
  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';
193
+ 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
194
  import { adoptWrunLiveIntakeGeneration, markWrunLiveGap, noteWrunLiveIntakeEvent, wrunPushEligible, } from './wrun-live-intake.util.js';
193
195
  import { openWrunPollLaneLiveChannels } from './wrun-series-stream.util.js';
194
196
  import { serverNowMs } from '../auth/server-clock.util.js';
@@ -206,9 +208,21 @@ import { attachWrunLive, wrunLiveOf, } from '../../interfaces/wrun-runtime.inter
206
208
  import { normalizeRuntimeDiagnostics, shouldNoticeWrunRefusal, WRUN_RUN_FAILURE_ROW_CODES, WRUN_RUN_TIMEOUT_CODE, wrunAbortRuntimeDiagnostic, wrunRunFailureRuntimeDiagnostic, } from '../scriptEditor/wrun-runtime-diagnostics.leaf.js';
207
209
  import { buildWrunOverlayRunResult, withCanvasHostFill, } from './wrun-overlay-result.util.js';
208
210
  import { applyWrunIntegrationBudgetPolicy, wrunIntegratedRowsView } from './wrun-integration-budget.util.js';
209
- import { cmeOptionsContract } from '../options/cme-options-root.util.js';
210
211
  // The result build lives in wrun-overlay-result.util (the result reader core); its importers keep this path.
211
212
  export { buildWrunOverlayRunResult };
213
+ /**
214
+ * The chart market's units a result build reads, together: its size unit (`wrunChartSizeUnit`: an output whose
215
+ * `visible_by` leaves it out mounts nothing) and its dollar unit when proven (`wrunMarketDollarUnit`: the CME registry's
216
+ * point value of the contract, NQ 20; 1 on crypto and US stocks), which the batched marks' `units` caption and hover
217
+ * divide a record's dollar value by. Synchronous over the facts the run head warmed. Every build spreads it (the full
218
+ * run, the row-source run, the reseed, the refine, the prefix landing and the live tick), so a tail or a reseed never
219
+ * hands the children a size unit without the dollar unit: a tail without it would re-register the hover in dollars.
220
+ * tests/utility/wrun/wrun-big-trades-size-shown-as.spec.ts fails on a build that names a size unit by hand.
221
+ */
222
+ export function wrunResultMarketUnits(market) {
223
+ const dollars = wrunMarketDollarUnit(market);
224
+ return { sizeUnit: wrunChartSizeUnit(market), ...(dollars.kind === 'dollars' ? { valuePerUnit: dollars.unit } : {}) };
225
+ }
212
226
  // The integration budget's pure policy lives in wrun-integration-budget.util; its view keeps this path too.
213
227
  export { wrunIntegratedRowsView };
214
228
  /** The number of closed bars whose evaluated OHLCV the context retains for
@@ -365,6 +379,14 @@ export async function runWrunOverlayOnChart(target) {
365
379
  // reports it as not applied.
366
380
  const computed = { generation: 0, stage: 'head' };
367
381
  let integrated = false;
382
+ // The run's download (its meter, once its window made one) goes to the add's open attempt once, when the run ends.
383
+ let downloadNoted = false;
384
+ const noteDownload = () => {
385
+ if (downloadNoted || !attempt || computed.download === undefined)
386
+ return;
387
+ downloadNoted = true;
388
+ wrunChartHostEnv().diagnostics.noteAttemptDownload(attempt, computed.download.summary());
389
+ };
368
390
  // The run is still the overlay's own: the chart and the overlay it computed for stand, and the
369
391
  // attempt it resolved is still the live one (a teardown, a restore or a later request retires it).
370
392
  const isCurrent = () => mount.tc !== undefined &&
@@ -432,30 +454,20 @@ export async function runWrunOverlayOnChart(target) {
432
454
  chartMetadata,
433
455
  });
434
456
  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".
457
+ // A run reading options that list on OPRA waits, bounded, for the `opra` flag the plane and its stop
458
+ // reasons are judged by (FE-REASON-CHIPS review): a restore can run before the map hydrates, and
459
+ // unhydrated, the map would read the plane closed and the lanes "not on your account". No run waits for
460
+ // the `opra-user-scripts` flag: no OPRA wall honours it any more (the compliance round, plan row D3), so
461
+ // a user run on an OPRA chart is refused at once, whatever the map says.
442
462
  const readsOpraOptions = target.metadata.inputs.some((input) => target.metadata.inputSources[input.name]?.source === 'options_chain') ||
443
463
  wrunSheetReadsOpraLane(target.metadata);
444
- const opraWallAhead = payloadTouchesOpraVenue(chartExchange) ||
445
- (typeof chartExchange === 'string' && OPRA_UNDERLYING_EXCHANGES.includes(chartExchange) && readsOpraOptions);
446
- if (readsOpraOptions || opraWallAhead) {
464
+ if (readsOpraOptions) {
447
465
  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
- }
466
+ const waitsOpra = opraGate.opraFlagDecidesChartOptions({
467
+ exchange: typeof chartExchange === 'string' ? chartExchange : undefined,
468
+ });
469
+ if (waitsOpra)
470
+ await opraGate.awaitOpraFlagHydration();
459
471
  }
460
472
  if (isKScriptDisplayBlockedOnExchange(chartExchange, provenance)) {
461
473
  throw new WrunVenueBlockedError(createKScriptVenueBlockedError(String(chartExchange)).message);
@@ -522,7 +534,7 @@ export async function runWrunOverlayOnChart(target) {
522
534
  chartIndex: target.chartIndex,
523
535
  mountEpoch,
524
536
  tc,
525
- });
537
+ }, computed);
526
538
  }
527
539
  finally {
528
540
  hold.lower();
@@ -548,7 +560,13 @@ export async function runWrunOverlayOnChart(target) {
548
560
  // surfaceWrunRunFailureOnLegend): only a success clears it.
549
561
  void clearWrunRuntimeTrapDiagnostic(target.chartIndex, target.indicatorId);
550
562
  }
551
- wrunChartHostEnv().diagnostics.settleAttempt(attempt, { ok: true });
563
+ // The run's download joins the add's before the settle reads it (a first slice's older asks are still out).
564
+ noteDownload();
565
+ // A first-slice picture settles the attempt too (the time to the first result), and says it was one.
566
+ wrunChartHostEnv().diagnostics.settleAttempt(attempt, {
567
+ ok: true,
568
+ ...(computed.firstSlice === true ? { firstSlice: true } : {}),
569
+ });
552
570
  }
553
571
  catch (rejection) {
554
572
  // What the run computed for, judged now (C4): a run its overlay's own newer intent superseded (a
@@ -597,6 +615,8 @@ export async function runWrunOverlayOnChart(target) {
597
615
  // cell cap's too-big) settles `refused` with its class, as the lane row reads it. A dropped run
598
616
  // settles nothing (C4): the attempt stays live for the run that replaces it, and a mount that
599
617
  // leaves settles it `cancelled` (the removal's abandon, the loader's first-run settle).
618
+ // A dropped run's download counts toward the add too: the run that replaces it settles the attempt.
619
+ noteDownload();
600
620
  if (!(error instanceof WrunChartGoneError))
601
621
  wrunChartHostEnv().diagnostics.settleAttempt(attempt, { ok: false, error });
602
622
  if (sourceHold) {
@@ -1395,7 +1415,9 @@ const WRUN_BUILTIN_LANE_REFUSED_ANSWERS = {
1395
1415
  params: {
1396
1416
  max: TRADES_HISTORY_MAX_CELLS,
1397
1417
  setting: wrunTapeFloorSettingWords(metadata),
1398
- min: tape?.minSize ?? 0,
1418
+ // The floor in its own unit: the raw number under `min_size` (as it always was), a dollar amount under
1419
+ // `min_value` ($500,000).
1420
+ min: tape?.minValue === undefined ? (tape?.minSize ?? 0) : wrunTapeFloorWords(tape),
1399
1421
  n: tape === undefined ? 0 : Math.round((tape.historySeconds / 86_400) * 10) / 10,
1400
1422
  },
1401
1423
  out: { kind: 'open-settings' },
@@ -1789,6 +1811,32 @@ export function wrunSessionRespelledSheet(context, sheet, settings) {
1789
1811
  const pins = wrunSessionRespelledPins.get(context);
1790
1812
  return pins === undefined ? undefined : wrunSheetWithRespelledPins(wrunSheetWithSettings(sheet, settings), pins);
1791
1813
  }
1814
+ /**
1815
+ * The run head's refusal of a sheet that reads the market's dollar multiplier (kit 0.95.0) on a market whose dollar
1816
+ * unit is not proven (wrunMarketDollarUnit), by name and before any fetch: a unit no read can ever prove (no point
1817
+ * value for its contracts, a quote that is no dollar) reads as the dollar tape's own refusal does (`feed-missing`,
1818
+ * the market has no tape to value), and one a later read can still prove as a source that did not answer
1819
+ * (`service-no-answer`, Retry; the reads retry on their own windows), so the module never runs over a 0 it would
1820
+ * keep for the session.
1821
+ */
1822
+ function wrunDollarMultiplierRefusal(metadata, chartMetadata, unit, tape) {
1823
+ const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
1824
+ const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
1825
+ const param = metadata.params.find((candidate) => candidate.host_fill === WRUN_DOLLAR_MULTIPLIER_FILL)?.name;
1826
+ const why = unit.transient
1827
+ ? unit.reason === 'point-value'
1828
+ ? "the instrument registry's point value for it has not been read yet"
1829
+ : 'its quote has not been read yet'
1830
+ : unit.reason === 'point-value'
1831
+ ? 'no point value is known for its contracts'
1832
+ : 'it is not quoted in US dollars or a dollar stablecoin';
1833
+ // The tape's own feed where the run asks one (Big Trades), else the trades the fact values.
1834
+ const params = { feed: tape !== undefined ? 'tape' : 'trades' };
1835
+ return attachWrunRefusal(new Error(`WRUN ${metadata.id}: ${WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE}: param '${param ?? 'market_dollar_multiplier'}' ` +
1836
+ `reads market.dollar_multiplier() on ${exchange}:${symbol}, and ${why}, so no trade can be valued`), unit.transient
1837
+ ? { cls: 'service-no-answer', variant: 'lane', params, severity: 'paused' }
1838
+ : { cls: 'feed-missing', variant: 'market-paused', params, severity: 'paused' });
1839
+ }
1792
1840
  /**
1793
1841
  * The browser lane's lanes for one window, the sandbox row source's `prepare` (contract C7,
1794
1842
  * wrun-sandbox-row-source.ts): everything the run reads before the engine worker. The first run's
@@ -1898,6 +1946,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
1898
1946
  if (chartRows.length === 0) {
1899
1947
  throw new WrunChartGoneError(`wrun overlay '${target.indicatorId}': its run window holds no chart rows (superseded)`);
1900
1948
  }
1949
+ // What the run downloads, from its first ask on, against the budget of its window's bars.
1950
+ const download = createWrunDownloadMeter(chartRows.length);
1951
+ computed.download = download;
1901
1952
  // The replay's completed chart bars (the head rows join the compute rows below).
1902
1953
  const replayChartRows = chartRows;
1903
1954
  // A clamped window short of the chart's newest bar is a page panned back
@@ -1929,6 +1980,43 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
1929
1980
  if (tape !== undefined) {
1930
1981
  await assertWrunTapeServedOnInterval(target.metadata, tape.inputNames[0], typeof chartMetadata?.interval === 'string' ? chartMetadata.interval : '');
1931
1982
  }
1983
+ // A dollar tape (C-DOLLAR) prices its live prints in its history's unit: the dollar unit of the market's own facts
1984
+ // (wrunMarketDollarUnit: a CME contract's registry point value, else the point value on a market quoted in dollars).
1985
+ // Its reads are the directory row's quote and the instrument registry's units, each waited on once
1986
+ // (warmWrunMarketDollarFacts never rejects). A unit no read can ever prove (a quote that is no dollar, a venue or a
1987
+ // contract with no point value) refuses the tape by name before any fetch, the daemon's `wrun_tape_value_unproven`:
1988
+ // none of its live prints could fold, so it never draws silently stopped. A unit a later read can still prove is
1989
+ // never frozen into the acquisition: the payload carries no `valuePerUnit`, and the live intake resolves it again on
1990
+ // its prints (wrun-live-intake.util `wrunTapeLiveFloorOf`).
1991
+ let tapeValuePerUnit;
1992
+ if (tape?.minValue !== undefined) {
1993
+ await warmWrunMarketDollarFacts(chartMetadata);
1994
+ const unit = wrunMarketDollarUnit(chartMetadata);
1995
+ tapeValuePerUnit = unit.kind === 'dollars' ? unit.unit : undefined;
1996
+ if (unit.kind === 'unproven' && !unit.transient) {
1997
+ const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
1998
+ const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
1999
+ const why = unit.reason === 'point-value'
2000
+ ? 'no point value is known for its contracts'
2001
+ : 'it is not quoted in US dollars or a dollar stablecoin';
2002
+ // The host's words lead with the code (`<code>: <sentence>`), as every host refusal reads.
2003
+ throw attachWrunRefusal(new Error(`WRUN ${target.metadata.id}: ${WRUN_TAPE_VALUE_UNPROVEN_CODE}: input '${tape.inputNames[0]}' (tape) floors ` +
2004
+ `${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' });
2005
+ }
2006
+ }
2007
+ // A package that reads the market's dollar multiplier (kit 0.95.0, `market.dollar_multiplier()`: Big Trades 0.8.0
2008
+ // values a CME contracts tape's fills with it) reads the same unit the dollar tape prices its live prints with and
2009
+ // the batched captions read (wrunMarketDollarUnit, wrunResultMarketUnits): one number for the module, the caption
2010
+ // and the hover. The module takes it once, at init(), so the run never computes over a unit it could not prove (0
2011
+ // values no trade): its reads are waited on here, a unit no read can ever prove refuses by name before any fetch,
2012
+ // and one a later read can still prove (a failed registry read, a continuous chart's lead not known yet) refuses as
2013
+ // a source that did not answer (retried, `service-no-answer`), never frozen into the session this run installs.
2014
+ if (wrunReadsDollarMultiplier(target.metadata)) {
2015
+ await warmWrunMarketDollarFacts(chartMetadata);
2016
+ const unit = wrunMarketDollarUnit(chartMetadata);
2017
+ if (unit.kind === 'unproven')
2018
+ throw wrunDollarMultiplierRefusal(target.metadata, chartMetadata, unit, tape);
2019
+ }
1932
2020
  // The market the run computes for: the integrate drops a result the chart moved off meanwhile.
1933
2021
  const marketIdentity = wrunChartMarketIdentity(chartMetadata);
1934
2022
  // A package that declares a fact the directory row answers (`market.kind()`,
@@ -2015,7 +2103,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2015
2103
  // before the chart's first bar ride the K_OHLCV lane the kScript engine fetches them on (a run at
2016
2104
  // another interval warms up on its run bars, the live rule).
2017
2105
  const replayHeadRows = replay && !run && replay.fromMs < chartRows[0][0]
2018
- ? await fetchWrunReplayHeadRows(target, view, replay.fromMs, chartRows[0][0])
2106
+ ? await fetchWrunReplayHeadRows(target, view, replay.fromMs, chartRows[0][0], download)
2019
2107
  : [];
2020
2108
  // Joined ahead of the chart's bars with their missing bars kept (a spread drops them).
2021
2109
  chartRows = wrunChartCandleRowsAfterHead(replayHeadRows, chartRows);
@@ -2114,9 +2202,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2114
2202
  // The run clock: the run interval when there is one (the venue facts, the host fill, the leg
2115
2203
  // plan, the poll plans and the push eligibility read it), else the chart's. A replay run's
2116
2204
  // `now` is the end its lanes are fetched through: every row's as-of read stays at its own close.
2205
+ // The now is the server's: the lanes plan their windows over the gateway's bars.
2117
2206
  const clock = {
2118
2207
  intervalMs: run ? run.intervalMs : chartIntervalMs,
2119
- nowMs: replay ? Math.min(Date.now(), Math.max(replay.toMs, chartLastTs + chartIntervalMs)) : Date.now(),
2208
+ nowMs: replay ? Math.min(serverNowMs(), Math.max(replay.toMs, chartLastTs + chartIntervalMs)) : serverNowMs(),
2120
2209
  };
2121
2210
  const { legs: plannedLegs, wires: plannedWires } = planWrunPinnedWires(target.metadata, clock.intervalMs);
2122
2211
  // The chart's head store for this run's first bar (wrun-warmup-head-store.util): one per chart, so every overlay
@@ -2157,6 +2246,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2157
2246
  intervalMs: chartIntervalMs,
2158
2247
  held: heldHeadsUsable ? heldContext.warmupHead : undefined,
2159
2248
  store: headStore,
2249
+ meter: download,
2160
2250
  }
2161
2251
  : undefined;
2162
2252
  // A chart whose candles are not asked as a plain time window (index mode, a mixed transformation) answers its exact
@@ -2184,6 +2274,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2184
2274
  beforeTs: chartFirstTs,
2185
2275
  held: heldHeadsUsable ? heldContext.laneWarmupHead : undefined,
2186
2276
  store: headStore,
2277
+ meter: download,
2187
2278
  }
2188
2279
  : undefined;
2189
2280
  const laneHeadTake = laneHeadArgs !== undefined
@@ -2590,6 +2681,20 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2590
2681
  })
2591
2682
  : null;
2592
2683
  if (own !== null) {
2684
+ // The chart's own rows answer the ask: it downloaded nothing.
2685
+ download.charge({
2686
+ key: `${target.fetchKey}-${key}`,
2687
+ kType: type,
2688
+ verdict: {
2689
+ complete: true,
2690
+ servedEmpty: false,
2691
+ source: 'main-rows',
2692
+ wireBytes: 0,
2693
+ wireFrames: 0,
2694
+ wirePoints: 0,
2695
+ },
2696
+ ...wrunDownloadAnswerSize(own.rows),
2697
+ });
2593
2698
  fetchOptions?.onSourceVerdict?.({ complete: true, servedEmpty: false, source: 'main-rows' });
2594
2699
  return own.rows;
2595
2700
  }
@@ -2607,12 +2712,16 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2607
2712
  // A run at another interval: a source naming no interval of its own rides the run interval
2608
2713
  // (the kScript engine's rule, runIntervalForSource), one naming its own keeps it.
2609
2714
  run && fetchOptions?.interval === undefined
2610
- ? { ...fetchOptions, interval: run.interval, ...sendNotices }
2611
- : { ...fetchOptions, ...sendNotices });
2715
+ ? { ...fetchOptions, interval: run.interval, ...sendNotices, meter: download }
2716
+ : { ...fetchOptions, ...sendNotices, meter: download });
2612
2717
  const label = `wrun source fetch '${type}' for '${target.fetchKey}'`;
2613
2718
  const fetched = await (request === undefined
2614
2719
  ? withWrunDeadline(asked, WRUN_SOURCE_FETCH_DEADLINE_MS, label)
2615
2720
  : raceWrunSendDeadline(asked, request.bound, label));
2721
+ // A relay feed's own fetch rides no chart transport and no stamp measures it: its rows are charged their cell bytes.
2722
+ if (fetchOptions?.ownFetch) {
2723
+ download.charge({ key: `${target.fetchKey}-${key}`, kType: type, ...wrunDownloadAnswerSize(fetched) });
2724
+ }
2616
2725
  // Packed-lane SUCCESS arrives as the packed transport object (only the
2617
2726
  // kScript engine worker consumes it un-unpacked); unpack it here, or a
2618
2727
  // real success misclassifies as a decline and re-fetches on the plain
@@ -3097,13 +3206,52 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3097
3206
  }
3098
3207
  return hostGridMemo;
3099
3208
  };
3209
+ // A full run's FIRST PAINT (`drawFirst`: nothing of this overlay computed or on screen, a stand-in included, no
3210
+ // strategy, no replay, the whole loaded window; and live at the chart's edge): a row lane whose first-paint slice
3211
+ // split its asks hands the slice's rows over before its older bars land (`runWrunSourceLanes` early rows), the older
3212
+ // bars read partial until the source ladder's rung adopts the whole answer (wrun-overlay-recovery.util). Every other
3213
+ // run waits for the whole window, as it always did: a run over a picture already drawn never trades it for a
3214
+ // partial one.
3215
+ const firstSlicePaint = live && drawFirst;
3216
+ // The chart's trade date of a bar (its `time.trade_date`): every run cuts a row lane's first-paint slice on a
3217
+ // session's first bar when it can, so a first paint's asks and every later run's ask the same windows (one cache).
3218
+ let tradeDateMemo;
3219
+ const chartTradeDateOf = () => {
3220
+ if (tradeDateMemo === undefined) {
3221
+ const venue = wrunBarVenueOf(chartMetadata, clock.intervalMs);
3222
+ if (venue === undefined)
3223
+ return undefined;
3224
+ const facts = wrunBarSessionFactsResolver(venue);
3225
+ tradeDateMemo = (barOpenMs) => facts(barOpenMs).tradeDateSec;
3226
+ }
3227
+ return tradeDateMemo;
3228
+ };
3229
+ // Each row lane that drew its first slice alone, by the slice's first bar: the live session's reconcile never lands
3230
+ // rows before it until the fill (`rowLaneFilling`, wrun-live-tick.util `mergeWrunReconcileAnswer`).
3231
+ const firstSliceFrom = new Map();
3232
+ // A first slice's shape in the debug ring (`wrun-row-lane-first-slice`): where the slice starts, how many bars it drew
3233
+ // from data and how many it holds back as partial until the fill.
3234
+ const ringFirstSlice = (lane, rows, sliceFromTs) => {
3235
+ if (!wrunChartHostEnv().diagnostics.debugEnabled())
3236
+ return;
3237
+ const drawn = rows.filter((row) => row.slice(1).some((cell) => Array.isArray(cell) && !wrunPresentIsPartial(Number(cell[cell.length - 1]))));
3238
+ wrunChartHostEnv().diagnostics.debug('wrun-row-lane-first-slice', {
3239
+ chartIndex: target.chartIndex,
3240
+ indicatorId: target.indicatorId,
3241
+ lane,
3242
+ sliceFromTs,
3243
+ drawnBars: drawn.length,
3244
+ heldBars: rows.length - drawn.length,
3245
+ });
3246
+ };
3100
3247
  // A row lane instance's rows (sources/row-lane-registry.ts): its asks over the window (a flow or snapshot lane's
3101
3248
  // under the tier rule on the host bars, landed on them with the partial bars marked; a latest lane's once), the
3102
3249
  // K type its descriptor names with the instance's acquisition (a governed lane's on the native-rows path, naming
3103
3250
  // the plane and its routed tier; a chain lane's on the native-rows path naming what its instance's plane names,
3104
3251
  // `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) => {
3252
+ // answer rows unless every input reading it declares `missing: "empty"`; a flow's empty window is quiet. On a first
3253
+ // paint (`firstSlicePaint`) the lane runner's `early` takes the first-paint slice's rows before the older bars land.
3254
+ const fetchRowLaneRows = async (instance, early) => {
3107
3255
  const lane = wrunRowLaneByKey(instance.laneKey);
3108
3256
  if (lane === undefined)
3109
3257
  return [];
@@ -3111,7 +3259,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3111
3259
  ? { ...instance.extras, ...wrunOpraLanePayloadFields(governedMarketDataTier('OPRA')) }
3112
3260
  : wrunRowLaneChainAsk(lane, instance.extras, governedMarketDataTier);
3113
3261
  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
3262
+ const tradeDateOf = chartTradeDateOf();
3263
+ const rows = await fetchWrunRowLaneRows(lane, extras, tradeDateOf === undefined ? hostGridWindow() : { ...hostGridWindow(), tradeDateOf }, { fromTs: from, toTs: to }, async (askExtras, fromTs, toTs) => ((await fetchLane(lane.kType, instance.key, laneFetch
3115
3264
  ? {
3116
3265
  ownFetch: async (askFrom, askTo) => (await laneFetch({
3117
3266
  extras: askExtras,
@@ -3120,7 +3269,18 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3120
3269
  intervalMs: clock.intervalMs,
3121
3270
  })),
3122
3271
  }
3123
- : wrunRowLaneFetchOptions(lane), { ...askExtras }, fromTs, toTs)) ?? []));
3272
+ : wrunRowLaneFetchOptions(lane), { ...askExtras }, fromTs, toTs)) ?? []),
3273
+ // The slice's own rows always hold one with data (an empty slice has no early answer), so a lane that must
3274
+ // answer rows never paints off an empty one.
3275
+ tradeDateOf === undefined || early === undefined || !firstSlicePaint
3276
+ ? undefined
3277
+ : {
3278
+ onFirstSlice: (sliceRows, sliceFromTs) => {
3279
+ firstSliceFrom.set(instance.key, sliceFromTs);
3280
+ ringFirstSlice(instance.key, sliceRows, sliceFromTs);
3281
+ early(sliceRows);
3282
+ },
3283
+ });
3124
3284
  const laneRows = rows;
3125
3285
  return wrunRowLaneRequired(target.metadata, instance)
3126
3286
  ? requireDegradableRows(lane.kType, lane.label, laneRows, instance.key)
@@ -3314,19 +3474,18 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3314
3474
  // The options_chain lane dispatches in its own group, once its identity resolved (below).
3315
3475
  etf_flow: etfLanePlan !== undefined ? () => fetchEtfFlowRows(etfLanePlan) : undefined,
3316
3476
  // 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.
3477
+ // TRADE_LARGE type) at the acquisition's facets, the one floor pushed down to the gateway
3478
+ // (`minSize` as `minAmount`, a dollar `minValue` as `minQuoteAmount`, C-DOLLAR) and `history`
3479
+ // passed as declared: the control serves the history start aligned to the bar inside the
3480
+ // chart's window, clamped to the table's 90-day retention. A history of "0" answers EMPTY by
3481
+ // contract (the live edge only) and a quiet filtered window answers empty on a clean wire, so an
3482
+ // empty answer computes (present empty blocks on every bar), a quiet lane like trades; a lane
3483
+ // error (the worker's 300k-cell cap, a refused stream) degrades it. The payload stays the lane's
3484
+ // acquisition: the live fold's floor (a dollar floor with the market's `valuePerUnit`, the
3485
+ // market facts' dollar unit, so a live print is priced in the history's unit, never guessed)
3486
+ // and the reconcile's re-ask.
3324
3487
  tape: tape !== undefined
3325
- ? async () => (await fetchLane('trades', 'tp', undefined, {
3326
- minSize: tape.minSize,
3327
- history: tape.history,
3328
- large: true,
3329
- })) ?? []
3488
+ ? async () => (await fetchLane('trades', 'tp', undefined, wrunTapeLaneExtras(tape, tapeValuePerUnit))) ?? []
3330
3489
  : undefined,
3331
3490
  // The trades leg lanes (kit 0.77.0), one thunk per (quote, market): K_BUY_SELL_VOLUME asked on
3332
3491
  // the leg's market in its quote, under the lane id as its fetch key (its own cache entry and
@@ -3405,13 +3564,27 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3405
3564
  landedBefore: hasGoodResult,
3406
3565
  });
3407
3566
  },
3408
- onLate: (lane, answer) => noteWrunLateRead({
3409
- indicatorId: target.indicatorId,
3410
- lane,
3411
- identity: lateReadIdentity,
3412
- answer,
3413
- acquisition: () => acquisitionByLane[lane],
3414
- }),
3567
+ // A read the run stopped waiting for: its lane's budget ran out (`budget`), or the lane drew its first-paint slice
3568
+ // and the rest of its window is still out (`first-slice`). Either is noted the same way, so the ladder's rung joins
3569
+ // or adopts it and never asks it again.
3570
+ onLate: (lane, answer, why) => {
3571
+ if (wrunChartHostEnv().diagnostics.debugEnabled()) {
3572
+ wrunChartHostEnv().diagnostics.debug('wrun-late-read-noted', {
3573
+ chartIndex: target.chartIndex,
3574
+ indicatorId: target.indicatorId,
3575
+ lane,
3576
+ why,
3577
+ reason,
3578
+ });
3579
+ }
3580
+ noteWrunLateRead({
3581
+ indicatorId: target.indicatorId,
3582
+ lane,
3583
+ identity: lateReadIdentity,
3584
+ answer,
3585
+ acquisition: () => acquisitionByLane[lane],
3586
+ });
3587
+ },
3415
3588
  };
3416
3589
  // A lane whose read an earlier run left out under this run's identity joins that read (still out) or adopts its
3417
3590
  // answer: the lane sends no second ask. The acquisition the earlier run recorded is the lane's here.
@@ -3468,7 +3641,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3468
3641
  // The registry poll lanes and the row lanes, one thunk per planned instance, after the row builder's own lanes in
3469
3642
  // declaration order: those whose plan read no chain dispatch with the lanes known now.
3470
3643
  const pollThunksOf = (lanes) => lanes.map((instance) => [instance.key, () => fetchPollLaneRows(instance)]);
3471
- const rowThunksOf = (lanes) => lanes.map((instance) => [instance.key, () => fetchRowLaneRows(instance)]);
3644
+ const rowThunksOf = (lanes) => lanes.map((instance) => [instance.key, (_abandoned, early) => fetchRowLaneRows(instance, early)]);
3472
3645
  schedule.add(localPlanned.then(({ poll, row }) => {
3473
3646
  laneInstances.push(...poll.lanes, ...row.lanes);
3474
3647
  return wrunJoinLateReads({ ...laneThunks, pollLanes: pollThunksOf(poll.lanes), rowLanes: rowThunksOf(row.lanes) }, joinLateRead);
@@ -3614,6 +3787,19 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3614
3787
  if (outcome.kind === 'rows')
3615
3788
  wrunChartHostEnv().chart.markSourceRecovered(guardKey, lane);
3616
3789
  }
3790
+ // The row lanes that answered their first-paint slice alone (`firstSlicePaint`): their older bars are still out, a
3791
+ // late read the source ladder's rung adopts (cause `filling`: a planned fill, no failure). Like a degraded lane each
3792
+ // leaves the warm-up evidence unsettled, so a picture over partial bars never buys older candles.
3793
+ const fillingLanes = laneRun.outcomes.flatMap(({ lane, outcome }) => outcome.kind === 'rows' && outcome.filling === true
3794
+ ? [{ lane, ...wrunLaneSourceOf(lane, laneInstances), cause: 'filling', retryable: true }]
3795
+ : []);
3796
+ for (const entry of fillingLanes)
3797
+ unsettledLanes.add(entry.lane);
3798
+ // Each filling lane's slice start, for the session the integrate installs (`rowLaneFilling`).
3799
+ const fillingFrom = Object.fromEntries(fillingLanes.flatMap(({ lane }) => {
3800
+ const fromTs = firstSliceFrom.get(lane);
3801
+ return fromTs === undefined ? [] : [[lane, fromTs]];
3802
+ }));
3617
3803
  for (const entry of degraded) {
3618
3804
  unsettledLanes.add(entry.lane);
3619
3805
  wrunChartHostEnv().chart.markSourceDegraded(guardKey,
@@ -3714,7 +3900,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3714
3900
  // no chip of its own: the registry's chip says what it waits for), keeping
3715
3901
  // whatever the overlay shows, and the source ladder reruns it.
3716
3902
  if (holding.length > 0) {
3717
- armWrunSourceRecovery(target.chartIndex, target.indicatorId, degraded);
3903
+ // The ladder watches the filling lanes' reads too: one rung adopts them all.
3904
+ armWrunSourceRecovery(target.chartIndex, target.indicatorId, [...degraded, ...fillingLanes]);
3718
3905
  // A lane another screen's session stopped names the hold: its record (Resume here) rides the rejection, so a
3719
3906
  // caller reading it (the editor console, the run's own catch) offers the take-back, never a Retry that cannot
3720
3907
  // serve it.
@@ -3857,7 +4044,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3857
4044
  tapeRows,
3858
4045
  // The plan resolves a param-bound tape floor from the settings it is handed: the floor the
3859
4046
  // lane was asked at (the param's current value).
3860
- ...(tape !== undefined ? { settings: wrunTapeFloorSettings(target.metadata, tape.minSize) } : {}),
4047
+ ...(tape !== undefined ? { settings: wrunTapeFloorSettings(target.metadata, wrunTapeFloorOf(tape)) } : {}),
3861
4048
  ...(pollLanes.length > 0 ? { pollLanes, pollLaneRows } : {}),
3862
4049
  ...(rowLanes.length > 0 ? { rowLanes, rowLaneRows } : {}),
3863
4050
  ...(Object.keys(tradeLegRows).length > 0
@@ -4019,6 +4206,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4019
4206
  etfFlowRows,
4020
4207
  evaluatedCandles,
4021
4208
  fetchedRunBars,
4209
+ fillingFrom,
4210
+ fillingLanes,
4022
4211
  formingPreRoll,
4023
4212
  from,
4024
4213
  fundingRateRows,
@@ -4734,7 +4923,11 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4734
4923
  await integrateWrunRowSourceBatch(runTarget, tc, meta, refusal, computed, owner, head, ask, batch);
4735
4924
  return;
4736
4925
  }
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;
4926
+ 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, } = prepared;
4927
+ // The filling chip (`fillingLanes`, a first-slice picture): raised right before the integrate, lowered if the run
4928
+ // fails after it.
4929
+ const fillingGuardKey = overlayExecutionGuardKey(target.chartIndex, target.indicatorId);
4930
+ let fillingRaised = false;
4738
4931
  try {
4739
4932
  // The module's rows, the batch's own array (its frames, handles and strategy ride on it). A hidden head's rows
4740
4933
  // are cut by timestamp here (D4), where the pass receives them from the row source, before the integrate, the
@@ -4785,8 +4978,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4785
4978
  chartNames,
4786
4979
  // The draft's word and an OPRA chain's served tier (wrun-draft-legend-note.util); every tick repeats it.
4787
4980
  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),
4981
+ // The market's size unit (an output its `visible_by` leaves out here mounts nothing) and its dollar unit (the
4982
+ // batched marks' `units`).
4983
+ ...wrunResultMarketUnits(chartMetadata),
4790
4984
  ...(projection ? { projection } : {}),
4791
4985
  // WRUN-STYLE g6: the canvases' cells, the batch's (the run's source rows, shared, never
4792
4986
  // copied, with the profile children's context); the chart index above hands the price
@@ -4805,6 +4999,19 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4805
4999
  (generation !== undefined && currentWrunOverlayLiveGeneration(target.indicatorId) !== generation)) {
4806
5000
  throw new WrunOverlayPausedError('paused');
4807
5001
  }
5002
+ // A first-slice picture: each filling lane's chip says its older bars are still loading, raised in this turn so
5003
+ // the integrate's own diagnostics write carries it (still text, never a spinner: the registry's filling class). The
5004
+ // rung's run that adopts the whole answer lowers it with its lanes' verdict; a failure from here on lowers it in the
5005
+ // catch below.
5006
+ for (const entry of fillingLanes) {
5007
+ wrunChartHostEnv().chart.markSourcePending(fillingGuardKey, {
5008
+ sourceName: entry.lane,
5009
+ sourceType: entry.kType,
5010
+ landedBefore: true,
5011
+ filling: true,
5012
+ });
5013
+ fillingRaised = true;
5014
+ }
4808
5015
  const runSerial = nextWrunCanvasRunSerial(target.indicatorId);
4809
5016
  const integration = integrateWrunRunThroughRoute({
4810
5017
  ...integrateOptions,
@@ -4828,6 +5035,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4828
5035
  throw new WrunChartGoneError(`wrun overlay '${target.indicatorId}' was superseded during its run (${route.reason})`);
4829
5036
  }
4830
5037
  const runResult = integration.runResult;
5038
+ // The picture drew a row lane's first slice alone (its older bars still out): the attempt says so at its settle.
5039
+ if (fillingLanes.length > 0 && integration.applied)
5040
+ computed.firstSlice = true;
4831
5041
  // The first accepted integrate replaces a proven twin's or a pinned
4832
5042
  // package's stand-in (D3 B5); a no-op for an overlay no stand-in stands for.
4833
5043
  if (integration.applied) {
@@ -4956,7 +5166,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4956
5166
  }
4957
5167
  // A proven twin's or a pinned package's whole result is the stand-in the
4958
5168
  // next reload or switch paints (D3 B5); a merge lands a page, never a
4959
- // stand-in.
5169
+ // stand-in, and a first-slice picture (older bars still loading) is no
5170
+ // whole result: the fill's run stores it.
4960
5171
  if (route.action === 'apply-remount' && integration.applied) {
4961
5172
  await writeWrunStandIn({
4962
5173
  chartIndex: target.chartIndex,
@@ -4967,6 +5178,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4967
5178
  chartMetadata,
4968
5179
  window,
4969
5180
  executedVersion: target.version,
5181
+ firstSlice: fillingLanes.length > 0,
4970
5182
  });
4971
5183
  }
4972
5184
  if (live && generation !== undefined && rows.length > 0) {
@@ -5049,6 +5261,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5049
5261
  ? {
5050
5262
  rowLanes,
5051
5263
  rowLaneRows: Object.fromEntries(Object.entries(rowLaneRows).map(([key, rows]) => [key, [...rows]])),
5264
+ // Lanes whose rows hold their first slice alone, by its first bar: no prefix page stands on them and
5265
+ // no reconcile lands rows before that bar until the fill.
5266
+ ...(Object.keys(fillingFrom).length > 0 ? { rowLaneFilling: fillingFrom } : {}),
5052
5267
  }
5053
5268
  : {}),
5054
5269
  // The trades leg lanes the run asked (kit 0.77.0): a copy of each one's rows by lane id. The
@@ -5277,6 +5492,11 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5277
5492
  // instead of ticking a session it does not own); the session lock and the load signals go.
5278
5493
  // A page or a save on the held source ends nothing more of the overlay's live session.
5279
5494
  releaseWrunRowSourceAsk(runTarget, ask, { epoch: generation, land: wrunTickOwnedFrames });
5495
+ // A filling chip this run raised says nothing once the run failed: lowered with it (data-loading rule 3).
5496
+ if (fillingRaised) {
5497
+ for (const entry of fillingLanes)
5498
+ wrunChartHostEnv().chart.markSourceRecovered(fillingGuardKey, entry.lane);
5499
+ }
5280
5500
  throw error;
5281
5501
  }
5282
5502
  // The batch landed: a live run hands its session to the overlay (the source lets the session
@@ -5290,10 +5510,12 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5290
5510
  source.teardown();
5291
5511
  }
5292
5512
  // 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);
5513
+ // recovery rungs, each a whole rerun riding the fetch cache), and so do the lanes that drew their first slice
5514
+ // alone (their older bars' read, adopted by the rung the moment it lands); a run that landed every lane whole
5515
+ // retires it.
5516
+ const unfinished = [...degraded, ...fillingLanes];
5517
+ if (unfinished.length > 0)
5518
+ armWrunSourceRecovery(target.chartIndex, target.indicatorId, unfinished);
5297
5519
  else
5298
5520
  retireWrunSourceRecovery(target.indicatorId, 'recovered');
5299
5521
  }
@@ -5657,8 +5879,9 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
5657
5879
  fills: runTarget.fills,
5658
5880
  candles: runTarget.candles,
5659
5881
  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),
5882
+ // The market's size unit (an output its `visible_by` leaves out here mounts nothing) and its dollar unit, as on
5883
+ // the own run.
5884
+ ...wrunResultMarketUnits(chartMetadata),
5662
5885
  // The canvases' cells: the batch's own lanes when it carries them, else the cells the source keeps.
5663
5886
  cellRows: wrunRowBatchCellRows(batch) ?? source.cellRowsOf(chartRows),
5664
5887
  intervalMs: chartIntervalMs,
@@ -6079,7 +6302,7 @@ function askWrunWarmupBackfillIfOwed(args) {
6079
6302
  declaredWarmupEndTs: declaredWarmupBars === null
6080
6303
  ? null
6081
6304
  : wrunDeclaredWarmupEndTs(runRows, declaredWarmupBars, intervalMs, creditedBars),
6082
- sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: Date.now() }),
6305
+ sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: serverNowMs() }),
6083
6306
  }),
6084
6307
  requestOlderHistory: wrunWarmupPageRequester(chartIndex, indicatorId, tc, isCurrent, ringDetails),
6085
6308
  ringDetails,
@@ -6348,8 +6571,8 @@ function assertWrunRunMayPaint(chartIndex, indicatorId, replay) {
6348
6571
  /** The kScript replay window's warm-up candles before the chart's first bar,
6349
6572
  * on the K_OHLCV lane the kScript engine fetches them on (deadline-raced like
6350
6573
  * 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}'`);
6574
+ async function fetchWrunReplayHeadRows(target, meta, fromMs, beforeMs, meter) {
6575
+ 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
6576
  const rows = isPackedOhlcvRows(fetched)
6354
6577
  ? unpackOhlcvRows(fetched)
6355
6578
  : Array.isArray(fetched)
@@ -6439,6 +6662,8 @@ async function writeWrunStandIn(args) {
6439
6662
  return refuse('template');
6440
6663
  if (args.window?.partial)
6441
6664
  return refuse('window-partial');
6665
+ if (args.firstSlice === true)
6666
+ return refuse('first-slice');
6442
6667
  if (args.executedVersion !== undefined && args.executedVersion !== identity.version) {
6443
6668
  return refuse('version-mismatch');
6444
6669
  }
@@ -6854,9 +7079,9 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
6854
7079
  outputs: context.metadata.outputs.length,
6855
7080
  });
6856
7081
  }
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() };
7082
+ // The reseed's own clock: the legs re-align as-of the server's now over the
7083
+ // buffers (a candle that closed since the last build is admitted by it).
7084
+ const clock = { intervalMs: context.intervalMs, nowMs: serverNowMs() };
6860
7085
  const sourceRows = {
6861
7086
  ohlcvRows,
6862
7087
  bookRows: context.bookRows,
@@ -6872,7 +7097,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
6872
7097
  optionsChainRows: context.optionsChainRows,
6873
7098
  etfFlowRows: context.etfFlowRows,
6874
7099
  tapeRows: context.tapeRows,
6875
- settings: wrunTapeFloorSettings(context.metadata, context.acquisition.tape?.minSize),
7100
+ settings: wrunTapeFloorSettings(context.metadata, wrunTapeAcquisitionFloor(context.acquisition.tape)),
6876
7101
  pollLanes: context.pollLanes,
6877
7102
  pollLaneRows: context.pollLaneRows,
6878
7103
  rowLanes: context.rowLanes,
@@ -7099,7 +7324,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7099
7324
  candles: context.candles,
7100
7325
  chartNames,
7101
7326
  legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
7102
- sizeUnit: wrunChartSizeUnit(context.market),
7327
+ ...wrunResultMarketUnits(context.market),
7103
7328
  ...(runSession
7104
7329
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
7105
7330
  : {}),
@@ -7362,18 +7587,20 @@ function wrunDegradedLaneOutcome(error) {
7362
7587
  * poll lanes (`thunks.pollLanes`, one thunk per planned instance) dispatch with
7363
7588
  * them, after the row builder's own lanes; their rows come back under
7364
7589
  * `tradeLegRows` and `pollLaneRows`, keyed by lane id and instance id.
7590
+ *
7591
+ * 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
7592
+ * first paint): when they come before the whole answer and before the budget, the lane settles on them (outcome
7593
+ * rows, `filling`) and its whole answer goes on as a late read (`onLate`, `first-slice`), exactly as a read its budget
7594
+ * abandoned does, so the source ladder adopts it and nothing asks it twice. Early rows after the budget change
7595
+ * nothing: the budget's late read is the whole answer already.
7365
7596
  */
7366
7597
  export async function runWrunSourceLanes(thunks, policy = {}) {
7367
7598
  const builtin = WRUN_SOURCE_LANE_ORDER.flatMap((lane) => {
7368
7599
  const run = thunks[lane];
7369
7600
  return typeof run === 'function' ? [[lane, run]] : [];
7370
7601
  });
7371
- const declared = [
7372
- ...builtin,
7373
- ...(thunks.tradeLegs ?? []),
7374
- ...(thunks.pollLanes ?? []),
7375
- ...(thunks.rowLanes ?? []),
7376
- ];
7602
+ const declared = [...builtin, ...(thunks.tradeLegs ?? []), ...(thunks.pollLanes ?? []), ...(thunks.rowLanes ?? [])];
7603
+ const filling = new Set();
7377
7604
  const settled = await Promise.allSettled(declared.map(([lane, run]) => {
7378
7605
  const laneBudgetMs = typeof policy.budgetMs === 'function' ? policy.budgetMs(lane) : policy.budgetMs;
7379
7606
  const deadline = wrunLaneSendDeadline(laneBudgetMs ?? 0, policy.capMs);
@@ -7381,27 +7608,49 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
7381
7608
  // Raised when the lane's budget runs out: its run no longer waits on it, so a lane asked in pieces asks no
7382
7609
  // further piece (`wrunAskWirePieces`); the asks already out finish into the fetch's cache.
7383
7610
  const abandon = new AbortController();
7611
+ // The lane's first rows (`early`), if it hands any over before its whole answer: the first call wins.
7612
+ let landEarly = () => undefined;
7613
+ const early = new Promise((resolve) => {
7614
+ let landed = false;
7615
+ landEarly = (rows) => {
7616
+ if (landed)
7617
+ return;
7618
+ landed = true;
7619
+ resolve({ rows, whole: false });
7620
+ };
7621
+ });
7384
7622
  let answer;
7385
7623
  try {
7386
- answer = run(abandon.signal);
7624
+ answer = run(abandon.signal, (rows) => landEarly(rows));
7387
7625
  }
7388
7626
  catch (error) {
7389
7627
  answer = Promise.reject(error);
7390
7628
  }
7391
- if (laneBudgetMs === undefined)
7392
- return answer;
7629
+ const first = Promise.race([answer.then((rows) => ({ rows, whole: true })), early]);
7393
7630
  // One phase per send notice, each racing what is left of the deadline the notice moved to
7394
7631
  // (`wrunLaneSendDeadline`). Only the budget's own expiry abandons the read and hands it on as a late read: an
7395
7632
  // 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);
7633
+ const answered = laneBudgetMs === undefined
7634
+ ? first
7635
+ : raceWrunSendDeadline(first, deadline, `wrun source lane '${lane}'`, (expired) => {
7636
+ abandon.abort(expired);
7637
+ policy.onLate?.(lane, answer, 'budget');
7638
+ });
7639
+ return answered.then(({ rows, whole }) => {
7640
+ if (!whole) {
7641
+ // The lane drew its first rows alone: the rest of its window is the late read the ladder adopts.
7642
+ filling.add(lane);
7643
+ policy.onLate?.(lane, answer, 'first-slice');
7644
+ }
7645
+ return rows;
7399
7646
  });
7400
7647
  }));
7401
7648
  const run = { results: {}, outcomes: [], degraded: [] };
7402
7649
  declared.forEach(([lane], at) => {
7403
7650
  const answer = settled[at];
7404
- const outcome = answer.status === 'fulfilled' ? { kind: 'rows', rows: answer.value } : wrunDegradedLaneOutcome(answer.reason);
7651
+ const outcome = answer.status === 'fulfilled'
7652
+ ? { kind: 'rows', rows: answer.value, ...(filling.has(lane) ? { filling: true } : {}) }
7653
+ : wrunDegradedLaneOutcome(answer.reason);
7405
7654
  run.outcomes.push({ lane, outcome });
7406
7655
  if (outcome.kind === 'degraded')
7407
7656
  run.degraded.push({ lane, outcome });
@@ -7463,6 +7712,10 @@ function wrunUnservedLaneReason(type, exchange, coin, service) {
7463
7712
  if (checkIsCryptoIndex(exchange)) {
7464
7713
  return `the ${type} source lane answers nothing on ${market} (a crypto index market serves its value candles only)`;
7465
7714
  }
7715
+ if (checkIsQuotePerp(exchange)) {
7716
+ return (`the ${type} source lane answers nothing on ${market} (a quote-priced perpetual market serves its quote ` +
7717
+ 'candles, funding and open interest only)');
7718
+ }
7466
7719
  return (`the ${type} source lane answers nothing on ${market} (a forex or commodity market serves no volume ` +
7467
7720
  'profile, buy/sell volume, order book, implied volatility or skew)');
7468
7721
  case 'coin':
@@ -7587,9 +7840,7 @@ function wrunOptionsChainExtrasGoverned(extras) {
7587
7840
  * provenance (the wall's door read it): `auto` reads an OPRA chain for an
7588
7841
  * OpenMarket package, and for a run `opraUserScripts` says the
7589
7842
  * `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
7843
+ * the tier the viewer is served now (`governedOptionSummaryTier`, the
7593
7844
  * routing's own rule: the lane's acquisition names it and the legend follows
7594
7845
  * it). Returns the lane's payload extras (`chain*` fields).
7595
7846
  *
@@ -7601,9 +7852,18 @@ function wrunOptionsChainExtrasGoverned(extras) {
7601
7852
  * `chainMaxContracts`, O2: the gateway sizes B on its page, so no expiry
7602
7853
  * directory is read here or in the worker); the chain's inputs read views all,
7603
7854
  * or none, and its view inputs one expiries word (one block B for the lane).
7855
+ *
7856
+ * OPTLOAD W3 FE-CHAIN: a governed chain whose inputs declare no views asks the
7857
+ * gateway's WHOLE view of B through the implicit view
7858
+ * (`wrunOptionsChainImplicitViewFields`: `chainViews: "whole"` and the same
7859
+ * scope inputs), so the gateway sizes B on its page by the lane scope's own
7860
+ * rule and no expiry directory is read before the ask; the worker sizes
7861
+ * today's scope itself only for an answer that is not B's rows. A crypto
7862
+ * chain keeps its plain reader (OPTLOAD W3 decision 1): its payload is
7863
+ * today's, byte for byte.
7604
7864
  */
7605
7865
  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([
7866
+ const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues }, { WRUN_OPTION_VIEWS_ONE_ASK_CODE, WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE, wrunHeldOpraPlaneChain, wrunOptionsChainImplicitViewFields, wrunOptionViewLaneFields, wrunOptionViewsOfSource, wrunOptionViewsUnion, },] = await Promise.all([
7607
7867
  import('./sources/opra-option-lanes.util.js'),
7608
7868
  wrunChartHostEnv().market.loadDeribitOptions(),
7609
7869
  wrunChartHostEnv().market.loadOptionsChainVenues(),
@@ -7673,6 +7933,17 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
7673
7933
  `one options_chain lane, one through views and one whole (${WRUN_OPTION_VIEWS_ONE_ASK_CODE}): declare ` +
7674
7934
  'views on both, or on neither'), wrunAuthorRuleSeed(WRUN_OPTION_VIEWS_ONE_ASK_CODE));
7675
7935
  }
7936
+ // The gateway sizes B on its page from the inputs' expiries word (their `nearest:N` when every input declares one;
7937
+ // none when one reads every expiry) and budget (the smallest max_cells), for a view ask and the implicit WHOLE alike
7938
+ // (O2): the lane scope's own inputs (`wrunOptionsChainLaneScope`), so B is the block today's scoped page builds.
7939
+ const nearest = laneInputs.flatMap((input) => (input.expiries?.kind === 'nearest' ? [input.expiries.count] : []));
7940
+ const budgets = laneInputs
7941
+ .map((input) => Number(input.maxCells))
7942
+ .filter((cells) => Number.isFinite(cells) && cells > 0);
7943
+ const gatewayScope = {
7944
+ ...(nearest.length === laneInputs.length ? { nearestExpiries: Math.max(...nearest) } : {}),
7945
+ ...(budgets.length > 0 ? { maxContracts: Math.floor(Math.min(...budgets)) } : {}),
7946
+ };
7676
7947
  if (firstWithViews >= 0) {
7677
7948
  // One block B for the lane, built for one expiries word: view inputs of two words would read views of one B, so
7678
7949
  // the lane refuses by name (the SDK asks each word apart; one acquisition per word would serve them).
@@ -7689,27 +7960,24 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
7689
7960
  `(${WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE}): declare the same expiries on every view input of one ` +
7690
7961
  'options_chain lane (this host builds one block for the lane)'), wrunAuthorRuleSeed(WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE));
7691
7962
  }
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
- });
7963
+ // A view ask on any chain, its one expiries word the gateway's scope input.
7964
+ const viewFields = wrunOptionViewLaneFields('options_chain', wrunOptionViewsUnion(viewSets.filter((views) => views !== undefined)), gatewayScope);
7702
7965
  const viewIdentity = identity.venue === 'cme' || identity.venue === 'opra'
7703
7966
  ? { ...identity, servedTier: governedOptionSummaryTier(identity.exchange) }
7704
7967
  : identity;
7705
7968
  return { ...wrunOptionsChainLaneExtras(viewIdentity), ...viewFields };
7706
7969
  }
7970
+ // A crypto chain keeps its plain reader (OPTLOAD W3 decision 1): the gateway's B prices an expiry at its page's one
7971
+ // underlying, where the crypto read takes each contract's own sample.
7707
7972
  if (identity.venue !== 'cme' && identity.venue !== 'opra')
7708
7973
  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) });
7974
+ // A governed chain whose inputs declare no views reads B whole through the implicit view (OPTLOAD W3 FE-CHAIN): ONE
7975
+ // summary read of the gateway's WHOLE view, sized on its page, with no expiry directory before it (the inputs apply
7976
+ // their own expiries words to B as they land, as they did to today's scoped page).
7977
+ return {
7978
+ ...wrunOptionsChainLaneExtras({ ...identity, servedTier: governedOptionSummaryTier(identity.exchange) }),
7979
+ ...wrunOptionsChainImplicitViewFields(gatewayScope),
7980
+ };
7713
7981
  }
7714
7982
  /**
7715
7983
  * One run's OPRA provenance writer (options-overlay-provenance.util `setOptionsOverlayOpraProvenance`, both
@@ -7741,54 +8009,6 @@ async function wrunOpraProvenanceWriter(chartIndex, indicatorId, ownership) {
7741
8009
  return true;
7742
8010
  };
7743
8011
  }
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
8012
  /** A run target whose sheet is the sheet on the chart's market (wrunChartSizeUnit): a lane's
7793
8013
  * `currency: "Auto"` reads the unit it resolves to there (wrunSheetWithLaneCurrencies), an input
7794
8014
  * whose `needed_by` leaves the market's size unit out is not demanded (wrunSheetWithLaneDemand), and
@@ -8283,7 +8503,7 @@ async function reintegrateWrunSessionCanvases(indicatorId, context, fill, curren
8283
8503
  candles: context.candles,
8284
8504
  chartNames,
8285
8505
  legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition),
8286
- sizeUnit: wrunChartSizeUnit(context.market),
8506
+ ...wrunResultMarketUnits(context.market),
8287
8507
  ...(runSession
8288
8508
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
8289
8509
  : {}),
@@ -9241,7 +9461,7 @@ let wrunWarmupHeadPageSerial = 0;
9241
9461
  * 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
9462
  * session's (`wrun-warmup-head`) or the cloud's warm-up head (`wrun-lane-warmup`, row 53).
9243
9463
  */
9244
- async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane = 'wrun-warmup-head') {
9464
+ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, meter, lane = 'wrun-warmup-head') {
9245
9465
  wrunWarmupHeadPageSerial += 1;
9246
9466
  const ovId = `${lane}-${wrunWarmupHeadPageSerial}`;
9247
9467
  const from = Math.floor(fromTs / 1000);
@@ -9258,6 +9478,8 @@ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane =
9258
9478
  // head store would keep the gap as walked.
9259
9479
  let served = false;
9260
9480
  let failed = false;
9481
+ // The page's completion (its own request, never shared): what it downloaded is the run's.
9482
+ const heard = { completed: false };
9261
9483
  const controller = new AbortController();
9262
9484
  try {
9263
9485
  await withWrunDeadline(request.transport.fetchData('OHLCV', payload, chartIndex, {
@@ -9273,6 +9495,8 @@ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane =
9273
9495
  },
9274
9496
  onComplete: (info) => {
9275
9497
  served = info?.completedOnWire === true && info.embargoed !== true;
9498
+ heard.completed = true;
9499
+ heard.info = info;
9276
9500
  },
9277
9501
  signal: controller.signal,
9278
9502
  shareable: false,
@@ -9283,6 +9507,22 @@ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, lane =
9283
9507
  controller.abort();
9284
9508
  return null;
9285
9509
  }
9510
+ if (heard.completed) {
9511
+ const { info } = heard;
9512
+ meter.charge({
9513
+ key: ovId,
9514
+ kType: 'OHLCV',
9515
+ verdict: {
9516
+ complete: served,
9517
+ servedEmpty: info?.servedEmpty === true,
9518
+ source: 'wire',
9519
+ ...(typeof info?.wireBytes === 'number'
9520
+ ? { wireBytes: info.wireBytes, wireFrames: info.wireFrames ?? 0, wirePoints: info.wirePoints ?? 0 }
9521
+ : {}),
9522
+ },
9523
+ ...wrunDownloadAnswerSize(replied),
9524
+ });
9525
+ }
9286
9526
  if (failed || !served)
9287
9527
  return null;
9288
9528
  request.lane.stripMainCandleRows(replied, 0);
@@ -9430,7 +9670,7 @@ async function acquireWrunWarmupHead(args) {
9430
9670
  if (getChartDataFetchGeneration(args.chartIndex) !== dataGen)
9431
9671
  break;
9432
9672
  pages += 1;
9433
- const answered = await fetchWrunWarmupHeadPage(args.chartIndex, request, fromTs, toTs);
9673
+ const answered = await fetchWrunWarmupHeadPage(args.chartIndex, request, fromTs, toTs, args.meter);
9434
9674
  if (answered === null)
9435
9675
  break;
9436
9676
  const page = [];
@@ -9547,7 +9787,7 @@ async function acquireWrunLaneWarmupHead(args) {
9547
9787
  if (getChartDataFetchGeneration(args.chartIndex) !== dataGen)
9548
9788
  break;
9549
9789
  pages += 1;
9550
- const answered = await fetchWrunWarmupHeadPage(args.chartIndex, args.request, fromTs, toTs, 'wrun-lane-warmup');
9790
+ const answered = await fetchWrunWarmupHeadPage(args.chartIndex, args.request, fromTs, toTs, args.meter, 'wrun-lane-warmup');
9551
9791
  if (answered === null)
9552
9792
  break;
9553
9793
  const page = [];
@@ -10311,11 +10551,11 @@ function wrunPrefixBatchedGapRows(mountedMetas, context, sheet, child, childId,
10311
10551
  * reconcile). Packed only: the session the candidate rules admitted rode it, and a decline hands
10312
10552
  * the page to the full run.
10313
10553
  */
10314
- async function fetchWrunPrefixBookRows(context, meta, fromTs, toTs) {
10554
+ async function fetchWrunPrefixBookRows(context, meta, fromTs, toTs, meter) {
10315
10555
  const { preferPackedOrderbookWorker: _packed, ...acquisition } = (context.acquisition.book ?? {});
10316
10556
  const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, 'orderbook', { symbol: 'currentSymbol', exchange: 'currentExchange', ...acquisition }, fromTs, toTs, meta, `${context.fetchKey}-prefix-ob`, false,
10317
10557
  // 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}'`);
10558
+ { preferPackedOrderbookWorker: true, silentLegend: true, meter }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun prefix source fetch 'orderbook' for '${context.fetchKey}'`);
10319
10559
  if (isPackedOhlcvRows(fetched))
10320
10560
  return unpackOhlcvRows(fetched);
10321
10561
  if (Array.isArray(fetched))
@@ -10366,7 +10606,7 @@ function wrunPrefixDegradedPageDetail(lane, outcome) {
10366
10606
  * 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
10607
  * whole run's older bars do).
10368
10608
  */
10369
- async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata) {
10609
+ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata, meter) {
10370
10610
  const pages = new Map();
10371
10611
  if (plan.builtin.length === 0 && plan.poll.length === 0 && plan.daily.length === 0 && plan.rows.length === 0) {
10372
10612
  return { pages };
@@ -10384,6 +10624,7 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs,
10384
10624
  {
10385
10625
  ...fetchOptions,
10386
10626
  silentLegend: true,
10627
+ meter,
10387
10628
  onSourceVerdict: (heard) => {
10388
10629
  verdict = heard;
10389
10630
  },
@@ -10817,7 +11058,7 @@ function wrunPrefixSnapshotsStale(prepared, tc, meta, indicatorId) {
10817
11058
  * parent payload for the merge route, and every heatmap child's window landing (C6). Every await of the
10818
11059
  * run is here; the commit reads what this returns and awaits nothing.
10819
11060
  */
10820
- async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt) {
11061
+ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt, computed) {
10821
11062
  const { chartIndex, indicatorId } = runTarget;
10822
11063
  const requestId = window.prefix.requestId;
10823
11064
  // The session the executor planned the window against, still the overlay's (a newer pan wave may
@@ -10863,6 +11104,9 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10863
11104
  if (windowRows.length === 0 || windowRows[0][0] !== window.fromMs) {
10864
11105
  return wrunPrefixRejected('stale', 'the window is no longer loaded');
10865
11106
  }
11107
+ // What the page downloads, from its first ask on, against the budget of its window's bars.
11108
+ const download = createWrunDownloadMeter(windowRows.length);
11109
+ computed.download = download;
10866
11110
  // The admission again, the plan's rule (O8f): an exact warm-up session admitted on its warm guest runs from W
10867
11111
  // candles before the window, its hidden head asked through the main candle request; a session the roster admits
10868
11112
  // 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 +11128,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10884
11128
  beforeTs: window.fromMs,
10885
11129
  bars: warmupBars,
10886
11130
  intervalMs: context.intervalMs,
11131
+ meter: download,
10887
11132
  });
10888
11133
  ringWrunWarmupHead(chartIndex, indicatorId, 'prefix', warmupBars, acquired);
10889
11134
  if ('miss' in acquired) {
@@ -10912,9 +11157,9 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10912
11157
  // other lane's page at once: a book the capability rule never dispatched reads empty, as the session's does.
10913
11158
  const [bookRows, lanePages] = await Promise.all([
10914
11159
  context.acquisition.book !== undefined
10915
- ? fetchWrunPrefixBookRows(context, meta, window.fromMs, window.toMs)
11160
+ ? fetchWrunPrefixBookRows(context, meta, window.fromMs, window.toMs, download)
10916
11161
  : Promise.resolve(context.bookRows !== undefined ? [] : undefined),
10917
- acquireWrunPrefixLanePages(context, meta, lanePlan, window.fromMs, firstRowTs, chartMetadata),
11162
+ acquireWrunPrefixLanePages(context, meta, lanePlan, window.fromMs, firstRowTs, chartMetadata, download),
10918
11163
  ]);
10919
11164
  // A lane whose page could not be had (declined, failed, out of budget, or empty where the full run degrades it):
10920
11165
  // the data, never the module. Nothing staged lands; the wave's full run follows.
@@ -10983,7 +11228,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10983
11228
  candles: runTarget.candles,
10984
11229
  ...(chartNames !== undefined ? { chartNames } : {}),
10985
11230
  ...(priceDigits !== undefined ? { priceDigits } : {}),
10986
- sizeUnit: wrunChartSizeUnit(chartMetadata),
11231
+ ...wrunResultMarketUnits(chartMetadata),
10987
11232
  cellRows: wrunCellRowsOf(context.metadata, sourceRows),
10988
11233
  intervalMs: clock.intervalMs,
10989
11234
  ...(chartExchange !== undefined ? { exchange: chartExchange } : {}),
@@ -11548,7 +11793,7 @@ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
11548
11793
  * (C7). Never throws: the executor sees a settled run either way, and a prefix never words a failure.
11549
11794
  * The commit boundary is `withWrunOverlaySessionLock` around `commitWrunPrefixRun`.
11550
11795
  */
11551
- async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner) {
11796
+ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner, computed) {
11552
11797
  const { chartIndex, indicatorId } = runTarget;
11553
11798
  const startedAt = wrunHostClockMs();
11554
11799
  const planned = getWrunOverlayLiveContext(indicatorId);
@@ -11556,7 +11801,7 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner)
11556
11801
  let prepared;
11557
11802
  let outcome;
11558
11803
  try {
11559
- const ready = await prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt);
11804
+ const ready = await prepareWrunPrefixRun(runTarget, tc, meta, window, landings, startedAt, computed);
11560
11805
  if (ready.kind === 'rejected') {
11561
11806
  outcome = ready;
11562
11807
  }