@orangecharts/wrun-chart-host 0.10.0 → 0.11.1

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 (152) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +67 -4
  4. package/dist/constants/governed-exchanges.constants.d.ts +12 -0
  5. package/dist/constants/governed-exchanges.constants.js +16 -0
  6. package/dist/constants/option-venues.constants.d.ts +2 -2
  7. package/dist/host-env.d.ts +1 -9
  8. package/dist/host-ports.types.d.ts +36 -7
  9. package/dist/index.d.ts +7 -1
  10. package/dist/index.js +7 -1
  11. package/dist/indicators/controls/tpo-session.util.d.ts +36 -13
  12. package/dist/indicators/controls/tpo-session.util.js +217 -236
  13. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  14. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  15. package/dist/interfaces/cme-realtime.interface.js +6 -3
  16. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  17. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  18. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  19. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  20. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  21. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
  22. package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
  23. package/dist/market-data/billing.interface.d.ts +86 -12
  24. package/dist/market-data/billing.interface.js +23 -4
  25. package/dist/market-data/venue.d.ts +65 -2
  26. package/dist/market-data/venues/index.d.ts +135 -5
  27. package/dist/market-data/venues/index.js +2 -1
  28. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  29. package/dist/market-data/venues/opra.d.ts +2 -2
  30. package/dist/market-data/venues/opra.js +5 -2
  31. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  32. package/dist/market-data/venues/stocks.d.ts +130 -0
  33. package/dist/market-data/venues/stocks.js +117 -0
  34. package/dist/settings-templates/footprint-rows.js +35 -2
  35. package/dist/settings-templates/form-rows.d.ts +2 -1
  36. package/dist/settings-templates/indicator-fields.js +34 -4
  37. package/dist/settings-templates/tool-rules.d.ts +12 -5
  38. package/dist/settings-templates/tool-rules.js +11 -5
  39. package/dist/settings-templates/tool-tables.generated.js +4 -0
  40. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  41. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  42. package/dist/utility/chart/cme-realtime.util.js +10 -0
  43. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  44. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  45. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  46. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  47. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  48. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  49. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  50. package/dist/utility/chart/index-host-tier.util.js +7 -2
  51. package/dist/utility/chart/index-mode-admission.util.js +25 -11
  52. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  53. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
  54. package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
  55. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  56. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  57. package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
  58. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  59. package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
  60. package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
  61. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  62. package/dist/utility/chart/live-bucket.util.js +85 -27
  63. package/dist/utility/chart/market-sessions.util.d.ts +83 -0
  64. package/dist/utility/chart/market-sessions.util.js +220 -0
  65. package/dist/utility/chart/marketKind.util.js +5 -0
  66. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  67. package/dist/utility/chart/mixed-mode.util.js +14 -0
  68. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  69. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  70. package/dist/utility/chart/rth-session.util.d.ts +9 -8
  71. package/dist/utility/chart/rth-session.util.js +23 -20
  72. package/dist/utility/chart/session-interval.util.d.ts +2 -1
  73. package/dist/utility/chart/session-interval.util.js +1 -3
  74. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  75. package/dist/utility/chart/trading-day.util.js +59 -0
  76. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  77. package/dist/utility/chart/window-owner.leaf.js +45 -3
  78. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  79. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  80. package/dist/utility/intl-locale.util.js +5 -0
  81. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  82. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  83. package/dist/utility/v2/gate-plane.util.js +30 -4
  84. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  85. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  86. package/dist/utility/v2/stocks-governed.util.js +34 -0
  87. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  88. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  89. package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
  90. package/dist/utility/wrun/derived-roots.util.js +3 -23
  91. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
  92. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  93. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  94. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
  95. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
  96. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
  97. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
  98. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
  99. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  100. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
  101. package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
  102. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  103. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  104. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  105. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  106. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  107. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  108. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  109. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  110. package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
  111. package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
  112. package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
  113. package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
  114. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  115. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  116. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
  117. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
  118. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  119. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  120. package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
  121. package/dist/utility/wrun/wrun-option-views.util.js +391 -50
  122. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  123. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  124. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
  125. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  126. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  127. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
  128. package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
  129. package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
  130. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  131. package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
  132. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  133. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  134. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  135. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  136. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  137. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  138. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  139. package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
  140. package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
  141. package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
  142. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
  143. package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
  144. package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
  145. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  146. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  147. package/dist/utility/wrun/wrun-volume-profile.util.js +37 -29
  148. package/dist/workers/constants/socket-slots.d.ts +91 -6
  149. package/dist/workers/constants/socket-slots.js +85 -6
  150. package/package.json +5 -5
  151. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
  152. package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
@@ -69,6 +69,7 @@ import { isWrunBatchedMarksKind, readWrunBatchedSections, wrunBatchedChildId, wr
69
69
  import { isPackedOhlcvRows, unpackOhlcvRows } from '../../instances/script-engine-worker-ohlcv-transfer.js';
70
70
  import { Intervals } from '../../constants/interval.constants.js';
71
71
  import { mountedPlotSetMatchesRunResult } from '../chart/kscript-mounted-plot-set.leaf.js';
72
+ import { isPredictionExchangeName } from '../chart/prediction-identity.util.js';
72
73
  import { resolveLazyMergePlan } from '../chart/kscript-integration-decision.leaf.js';
73
74
  import { KSCRIPT_CONTAINER_OUTPUT_KEY } from '../chart/kscript-titancharts-container.util.js';
74
75
  import { normalizeKScriptRunResultForTitanCharts } from '../chart/kscript-run-result-normalize.util.js';
@@ -80,12 +81,14 @@ import { standInIdentityOf, wrunStandInTag, } from '../chart/kscript-standin-ide
80
81
  import { isWrunOverlayHeldForRun, requestWrunOverlayRerun, withWrunOverlayExecutionMeasure, } from './wrun-overlay-lifecycle.util.js';
81
82
  import { armWrunSourceRecovery, requestWrunCasualtyRebuilds, retireWrunSourceRecovery, wrunOverlayHold, } from './wrun-overlay-recovery.util.js';
82
83
  import { gateSessionHeldElsewhere } from '../v2/gate-session-latch.util.js';
84
+ import { isStocksTapeGoverned } from '../v2/stocks-governed.util.js';
83
85
  import { noteWrunGatePlaneStopped, noteWrunGatePlanesRead } from './wrun-gate-plane-readers.util.js';
84
86
  import { wrunGateLatchedThunks, wrunLaneGatePlanes, wrunLaneGateStopOf, wrunSessionStopPlaneOf, } from './wrun-options-stop.util.js';
85
87
  import { annotateWrunRunFailedIdentity, noteWrunRunRetained, wrunRunIdentityOf } from './wrun-cap-notice.util.js';
86
88
  import { wrunIntegrationRoute } from './wrun-integration-route.util.js';
87
89
  import { placeWrunTablesOnChart } from './wrun-table-chrome.util.js';
88
90
  import { projectKScriptRunResultOntoChartBars } from '../chart/kscript-run-interval-projection.util.js';
91
+ import { runBarSpan } from '../chart/indicator-run-interval.util.js';
89
92
  import { GESTURE_LINGER_MS, HEAVY_APPLY_GESTURE_CEILING_MS } from '../chart/gesture-timing.leaf.js';
90
93
  import { getChartDataFetchGeneration } from '../chart/chart-data-fetch-generation.util.js';
91
94
  import { isWrunWindowOwner } from '../chart/window-owner.leaf.js';
@@ -104,7 +107,7 @@ import { attachWrunStrategy, isWrunStrategySheet, wrunStrategyOf } from './wrun-
104
107
  import { withWrunDeadline, WRUN_SOURCE_FETCH_DEADLINE_MS } from './wrun-deadline.util.js';
105
108
  import { noteWrunLateRead, takeWrunLateRead, wrunJoinLateReads } from './run-schedule/wrun-late-reads.util.js';
106
109
  import { scheduleWrunLaneGroups } from './run-schedule/wrun-lane-groups.util.js';
107
- import { serveWrunOwnCandles } from './run-schedule/wrun-own-candles.util.js';
110
+ import { serveWrunOwnCandles, wrunChartCandleVenue, wrunMainCandleSourceOf, } from './run-schedule/wrun-own-candles.util.js';
108
111
  import { wrunPollClassReadsChain, wrunRowClassReadsChain } from './run-schedule/wrun-gate-reader-warm.util.js';
109
112
  import { wrunPollLaneByKey, wrunPollLanesOfClass } from './sources/registry.js';
110
113
  import { wrunRowLaneByKey, wrunRowLaneOfClass, wrunRowLanes } from './sources/row-lane-registry.js';
@@ -118,7 +121,7 @@ import { liveBucketStartsInRange, liveBucketVenueOf } from '../chart/live-bucket
118
121
  import { hostBucketResolverFor } from '../chart/host-bar-placement.util.js';
119
122
  import { indexHostFetchTierMs, sourceRowsStraddleHostBars } from '../chart/index-host-tier.util.js';
120
123
  import { isWrunPollLaneId, wrunPollCoinGateSeed, } from './sources/wrun-poll-lane.types.js';
121
- import { fetchWrunPollLaneHostGridRows, planWrunPollLanes, resolveWrunOptionSettingKnobs, wrunChainLaneContext, wrunLaneRowsRequired, wrunPollLaneChainAsk, wrunPollLaneFetchFrom, wrunPollLaneFetchOptions, wrunPollLaneFetchTo, wrunPollLaneInstanceReadsOpra, wrunPollLaneRequired, wrunPollLaneValuelessInput, } from './sources/wrun-poll-lanes.util.js';
124
+ import { assertWrunLaneChainPlaneReadable, fetchWrunPollLaneHostGridRows, planWrunPollLanes, resolveWrunOptionSettingKnobs, wrunChainLaneContext, wrunLaneRowsRequired, wrunPollLaneChainAsk, wrunPollLaneFetchFrom, wrunPollLaneFetchOptions, wrunPollLaneFetchTo, wrunPollLaneInstanceReadsOpra, wrunPollLaneRequired, wrunPollLaneValuelessInput, } from './sources/wrun-poll-lanes.util.js';
122
125
  import { wrunDailyLaneFetchFrom, wrunDailyLaneFetchTo } from './wrun-daily-lane.util.js';
123
126
  import { assertWrunEtfFlowCoin, planWrunEtfFlowColumns, planWrunEtfFlowLane, resolveWrunEtfFlowTickers, WRUN_ETF_FLOW_INTERVAL_KEY, wrunEtfFlowAnswer, zipWrunEtfFlowRows, } from './wrun-etf-flow-lane.util.js';
124
127
  import { planWrunOptionSummaryLane, WRUN_OPTION_SUMMARY_LANES, wrunOptionSummaryAskExtras, wrunOptionSummaryAskKey, zipWrunOptionSummaryRows, } from './wrun-option-summary-lane.util.js';
@@ -147,7 +150,7 @@ import { assertWrunBrowserSources, getWrunBrowserHost, } from './wrun-host.servi
147
150
  import { applyWrunInertLegendState } from './wrun-inert-legend.util.js';
148
151
  import { annotateWrunErrorRefusal, attachWrunRefusal, serializeWrunRefusal, stampWrunRefusalTelemetry, wrunAuthorRuleSeed, wrunLeftOutRefusalSeed, wrunOptionsStopSeed, wrunOverlayEditable, wrunRefusalFor, wrunRefusalOf, wrunRefusalSeedFor, wrunRefusalSeedOf, WRUN_REFUSAL_EVENT_MARKET_KEY, } from './wrun-refusal.util.js';
149
152
  import { claimWrunRefusalNotice, emitWrunRefusalChange, liveWrunRefusalAttempt, projectWrunRefusal, retractWrunRefusal, } from './wrun-refusal-surface.util.js';
150
- import { WRUN_ETF_COVERED_COINS, wrunInputReadsFillOverEmptyLane, wrunInputRequirements, wrunUnservedLanes, } from './wrun-input-requirements.leaf.js';
153
+ import { WRUN_ETF_COVERED_COINS, wrunInputReadsFillOverEmptyLane, wrunInputRequirements, wrunPredictionMarketWalledInput, wrunRunMarketReadOfFetchType, wrunSheetReadsRunMarket, wrunUnservedLanes, } from './wrun-input-requirements.leaf.js';
151
154
  import { getWrunOverlayMetadata, rememberWrunOverlayMetadata } from './wrun-overlay-metadata.util.js';
152
155
  import { setWrunOverlayAlertOutputs } from './wrun-alert-outputs.registry.js';
153
156
  import { buildWrunScriptInputs, wrunParamValuesFromSettings, wrunRunOverlayPalette, } from './wrun-script-inputs.util.js';
@@ -162,7 +165,7 @@ import { FeatureFlag } from '../../constants/feature-flags.constants.js';
162
165
  import { clearedColorCustomizationFlags } from '../chart/color-customization.leaf.js';
163
166
  import { WRUN_LATEST_HISTORY_LENGTH } from './wrun-latest-history.leaf.js';
164
167
  import { resolveChartPricePrecision } from '../chart/price-precision.util.js';
165
- import { currentWrunOverlayLiveGeneration, getWrunOverlayLiveContext, isWrunOverlayReplacementPending, markWrunOverlayComputeSucceeded, nextWrunOverlayLiveGeneration, noteWrunOverlayRunSettle, noteWrunOverlayWholeWindowDrawn, onWrunOverlayLiveTeardown, rerunWrunOverlayForChartWave, setWrunOverlayLiveContext, setWrunPrefixRuntime, setWrunUnansweredDropSurface, suspendWrunOverlayLiveSession, withWrunOverlaySessionLock, wrunChartMarketIdentity, } from './wrun-overlay-drivers.util.js';
168
+ import { currentWrunOverlayLiveGeneration, getWrunOverlayLiveContext, isWrunOverlayFullRerunInFlight, isWrunOverlayReplacementPending, markWrunOverlayComputeSucceeded, nextWrunOverlayLiveGeneration, noteWrunOverlayRunSettle, noteWrunOverlayWholeWindowDrawn, onWrunOverlayLiveTeardown, rerunWrunOverlayForChartWave, setWrunOverlayLiveContext, setWrunPrefixRuntime, setWrunUnansweredDropSurface, suspendWrunOverlayLiveSession, withWrunOverlaySessionLock, wrunChartMarketIdentity, } from './wrun-overlay-drivers.util.js';
166
169
  import { claimWrunWarmupHead, readWrunWarmupHeadBars, readWrunWarmupHeadSpan, storeWrunWarmupHeadSpan, wrunWarmupHeadStored, } from './wrun-warmup-head-store.util.js';
167
170
  import { protectedKScriptMountedRowCount } from '../chart/protected-kscript-empty-output.util.js';
168
171
  import { kScriptSettingsRevision } from '../chart/kscript-settings-revision.leaf.js';
@@ -177,9 +180,10 @@ import { isCmeGoverned } from '../chart/cme-realtime.util.js';
177
180
  import { wrunBarSessionFactsResolver, wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
178
181
  import { wrunPresentIsPartial } from './wrun-present-bits.util.js';
179
182
  import { assertWrunPinnedLegVenues, partitionWrunLegsByVenue, wrunLegFetchedRowReaders, wrunLegRidesNativeRows, wrunPinMarketsOf, wrunPinnedLegRefusalOf, wrunPinVenueVerdict, } from './wrun-pin-venues.util.js';
180
- import { annotateWrunErrorFailureRow, annotateWrunErrorIndicatorId, isWrunOverlayPausedError, isWrunQuarantinedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunDeadlineError, WrunIntegrationError, WrunNoBarsError, WrunOverlayPausedError, WrunSourceDataUnavailableError, WrunVenueBlockedError, } from './wrun-registry-errors.util.js';
181
- import { createKScriptVenueBlockedError, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptCandidate, isOpraUserScriptRun, payloadTouchesOpraVenue, } from '../chart/kscript-venue-policy.util.js';
183
+ import { annotateWrunErrorFailureRow, annotateWrunErrorIndicatorId, isWrunOverlayPausedError, isWrunQuarantinedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunDeadlineError, WrunIntegrationError, WrunNoBarsError, WrunOverlayPausedError, WrunPredictionMarketBlockedError, WrunSourceDataUnavailableError, WrunStrategyVenueBlockedError, WrunVenueBlockedError, } from './wrun-registry-errors.util.js';
184
+ import { createKScriptVenueBlockedError, isCmeUserScriptCandidate, isCmeUserScriptRun, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptCandidate, isOpraUserScriptRun, payloadTouchesCmeVenue, payloadTouchesOpraVenue, } from '../chart/kscript-venue-policy.util.js';
182
185
  import { isOpraUserScriptsFlagOn } from '../chart/opra-user-scripts-gate.util.js';
186
+ import { captureCmeStudyAuth, cmeStudyStopReason, isCmeStudyAuthCurrent, isCmeUserScriptsFlagOn, } from '../chart/cme-user-scripts-gate.util.js';
183
187
  import { governedMarketDataTier, governedOptionSummaryTier } from '../v2/governed-tier.leaf.js';
184
188
  import { awaitWrunChildOverlays, mountWrunChildOverlays, prepareWrunHeatmapWindowLanding, WrunStaleLandingError, } from './wrun-panel-mount.util.js';
185
189
  import { planWrunFormingPreRoll, planWrunIntrabarLegFetch, planWrunLegFetch, wrunClampedLegDiagnostics, wrunIntrabarServedNotes, wrunLegFetchReads, } from './wrun-leg-fetch.util.js';
@@ -199,7 +203,6 @@ import { isWrunOptionsChainCryptoVenueWord, WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE, W
199
203
  import { adoptWrunLiveIntakeGeneration, markWrunLiveGap, noteWrunLiveIntakeEvent, wrunPushEligible, } from './wrun-live-intake.util.js';
200
204
  import { openWrunPollLaneLiveChannels } from './wrun-series-stream.util.js';
201
205
  import { serverNowMs } from '../auth/server-clock.util.js';
202
- import { aggregateOhlcvRows } from '../../utils/replay/replay-buffer-math.js';
203
206
  import { isWrunReplayRunCurrent, noteWrunReplayRun, wrunReplayRunPlanOf, } from './wrun-replay-lane.util.js';
204
207
  import { cutWrunReplayRowsAfterApply } from './wrun-replay-rows.util.js';
205
208
  import { builtinPortOf } from './wrun-builtin-twin.util.js';
@@ -243,6 +246,12 @@ export const WRUN_ODDS_SEED_LEG_BARS = 1440;
243
246
  * Cold, the gateway answered a 290-bar Polymarket window in 2.6 to 4.6 s and
244
247
  * the serial 1440-bar seed that followed it in up to 12.5 s. */
245
248
  export const WRUN_ODDS_SHORT_SEED_LEG_BARS = 250;
249
+ /** A candle ask's rows market when the chart's rows came from another (the full run's door and the tick's agree). */
250
+ export function wrunCandleAskSource(chartMetadata, provenance) {
251
+ // A reader that threw reads as the chart's own, as the walls read it (wrunChartCandleVenue).
252
+ const source = wrunMainCandleSourceOf(chartMetadata) ?? null;
253
+ return { source, walled: source !== null && isKScriptDisplayBlockedOnExchange(source.exchange, provenance) };
254
+ }
246
255
  /**
247
256
  * A pinned leg's fetch payload extras over the current-market placeholders:
248
257
  * its market (absent = the chart's own), plus the K_OHLCV prediction flag
@@ -351,6 +360,19 @@ function wrunLiveLaneOfFetchKey(key) {
351
360
  return (WRUN_LIVE_LANE_OF_FETCH_KEY[key] ??
352
361
  (isWrunPollLaneId(key) || isWrunRowLaneId(key) || isWrunTradesLegLane(key) ? key : undefined));
353
362
  }
363
+ /** THE run market: where the chart's trades print for this run (a Trades chart's tape), null for the chart's own. */
364
+ async function decideWrunRunMarket(chartMetadata, settings) {
365
+ try {
366
+ const port = (await wrunChartHostEnv().chart.loadTitanCharts());
367
+ const market = (await port.kscriptStockTapeTradesMarket?.(chartMetadata, settings)) ?? null;
368
+ const chart = chartMetadata;
369
+ // The chart's own market back (a miss, a failed lookup, a run the venue policy keeps off the tape) moves nothing.
370
+ return market !== null && (market.exchange !== chart?.exchange || market.symbol !== chart?.symbol) ? market : null;
371
+ }
372
+ catch {
373
+ return null;
374
+ }
375
+ }
354
376
  /** Recompute one mounted WRUN overlay over the chart's CURRENT loaded rows
355
377
  * and integrate the result through the shared adapter path. */
356
378
  export async function runWrunOverlayOnChart(target) {
@@ -392,12 +414,15 @@ export async function runWrunOverlayOnChart(target) {
392
414
  downloadNoted = true;
393
415
  wrunChartHostEnv().diagnostics.noteAttemptDownload(attempt, computed.download.summary());
394
416
  };
395
- // The run is still the overlay's own: the chart and the overlay it computed for stand, and the
396
- // attempt it resolved is still the live one (a teardown, a restore or a later request retires it).
417
+ // The run is still the overlay's own: the chart and the overlay it computed for stand, the
418
+ // attempt it resolved is still the live one (a teardown, a restore or a later request retires it),
419
+ // and a CME chart study still computes under the authorisation its head captured (`computed.cmeAuth`:
420
+ // a move of the viewer's access since retires it, the superseded path's `not-current`).
397
421
  const isCurrent = () => mount.tc !== undefined &&
398
422
  mount.meta !== undefined &&
399
423
  isWrunRunMountOnChart(target.chartIndex, mount) &&
400
- wrunRefusalAttemptStands(target.chartIndex, target.indicatorId, refusalAttempt);
424
+ wrunRefusalAttemptStands(target.chartIndex, target.indicatorId, refusalAttempt) &&
425
+ wrunCmeStudyAuthStands(computed);
401
426
  // The market this run computes for (C4), set once the head read it: with the data generation and
402
427
  // the compute revision above, what a failure is judged against (wrunRunSupersededReason).
403
428
  let market;
@@ -463,6 +488,10 @@ export async function runWrunOverlayOnChart(target) {
463
488
  // chart reads OPRA candles whatever its lanes read.
464
489
  if (payloadTouchesOpraVenue(chartExchange))
465
490
  computed.opra = true;
491
+ // The same on a CME chart (`computed.cme`): every run there reads CME candles, an OpenMarket package's too (the mark
492
+ // is the output's provenance, never a permission).
493
+ if (payloadTouchesCmeVenue(chartExchange))
494
+ computed.cme = true;
466
495
  // A run reading options decides its ONE options market here (derived-roots.util `decideWrunRunOptionsMarket`):
467
496
  // where the options list on OPRA (a stock, an OPRA contract, a known stock twin) or the overlay's last read was
468
497
  // OPRA's (its provenance stamp), it waits, bounded, for the `opra` flag the plane and its stop reasons are judged
@@ -497,9 +526,58 @@ export async function runWrunOverlayOnChart(target) {
497
526
  if (!isOpraUserScriptsFlagOn())
498
527
  gate?.armOpraUserScriptsRejudge?.();
499
528
  }
500
- if (isKScriptDisplayBlockedOnExchange(chartExchange, provenance)) {
501
- throw new WrunVenueBlockedError(createKScriptVenueBlockedError(String(chartExchange)).message);
502
- }
529
+ // A run the `cme-user-scripts` gate may open the CME plane to (a browser run the viewer wrote or added) that the
530
+ // CME display wall refuses on this chart waits, bounded, for the flag map (the port's
531
+ // `awaitCmeUserScriptsFlagHydration`), and the wall is asked again below: a restore can run before the map
532
+ // hydrates, and an unhydrated map reads closed. Every other run never waits on the map. The bound ran out with the
533
+ // flag still dark: the wall refuses this run now, and a gate that opens later judges the walled CME studies again
534
+ // (`armCmeUserScriptsRejudge`). A host that binds neither port judges by the map as it stands.
535
+ if (isCmeUserScriptCandidate(provenance) &&
536
+ payloadTouchesCmeVenue(chartExchange) &&
537
+ isKScriptDisplayBlockedOnExchange(chartExchange, provenance)) {
538
+ const gate = await wrunChartHostEnv()
539
+ .market.loadOptionsGate()
540
+ .then(async (loaded) => {
541
+ await loaded.awaitCmeUserScriptsFlagHydration?.();
542
+ return loaded;
543
+ })
544
+ .catch(() => undefined);
545
+ if (!isCmeUserScriptsFlagOn())
546
+ gate?.armCmeUserScriptsRejudge?.();
547
+ }
548
+ // The market the candles came from: a chart riding a tape walls what that tape's own chart walls.
549
+ const candleVenue = wrunChartCandleVenue(chartMetadata);
550
+ if (isKScriptDisplayBlockedOnExchange(candleVenue, provenance)) {
551
+ throw withCmeStudyStopSeed(new WrunVenueBlockedError(createKScriptVenueBlockedError(String(candleVenue)).message), target.chartIndex, target.indicatorId, candleVenue);
552
+ }
553
+ // Strategy testing is no CME chart study (Kyle 2026-10-29): on a CME chart every strategy sheet is refused, an
554
+ // OpenMarket package's included, here at the head before the loader is raised, a lane is asked or the sandbox is
555
+ // touched (the broker feed, `wrunStrategyRunInputFor`, is never built), on every lane. A venue refusal held like
556
+ // the wall's, with its own record on the legend (`cme-wall` `strategy`: no wall painter stands behind it).
557
+ if (payloadTouchesCmeVenue(chartExchange) && isWrunStrategySheet(target.metadata)) {
558
+ throw attachWrunRefusal(new WrunStrategyVenueBlockedError(createKScriptVenueBlockedError(String(chartExchange)).message), WRUN_CME_STRATEGY_REFUSAL_SEED);
559
+ }
560
+ // The prediction-market wall (Kyle 2026-10-29: options indicators on a Polymarket chart make no sense): on a
561
+ // Polymarket or HIP4 chart an input read by the chart's coin (the options chain and its lanes, a provider lane, a
562
+ // coin leg) would read another market under the odds (wrunPredictionMarketWalledInput: the coin is no asset the
563
+ // price follows), so the sheet is refused here at the head, before the loader is raised or a lane is asked,
564
+ // whatever fill it declares. Judged on the sheet the run reads there: its settings applied (a `when` setting that
565
+ // is off leaves its input undemanded) and its lane demand at the market's size unit (`needed_by`). Held like the
566
+ // strategy refusal, with its own record (`cme-wall` `prediction`): the run after the chart leaves the prediction
567
+ // market computes.
568
+ const predictionWalled = typeof chartExchange === 'string' && isPredictionExchangeName(chartExchange)
569
+ ? wrunPredictionMarketWalledInput(wrunSheetWithLaneDemand(wrunSheetWithSettings(target.metadata, meta.settings), wrunChartSizeUnit(chartMetadata)), chartExchange)
570
+ : undefined;
571
+ if (predictionWalled !== undefined) {
572
+ throw attachWrunRefusal(new WrunPredictionMarketBlockedError(`Input '${predictionWalled.name}' (${predictionWalled.sourceClass}) reads by the chart's coin, which ${String(chartExchange)} does not have`), WRUN_PREDICTION_MARKET_REFUSAL_SEED);
573
+ }
574
+ // A CME chart study (`isCmeUserScriptRun`: the gate opened the CME plane to this browser run) computes under the
575
+ // authorisation the wall just read, captured in the same task (cme-user-scripts-gate.util `captureCmeStudyAuth`):
576
+ // a move of the viewer's access since (the account, the CME data terms, the served access, the flag, the session)
577
+ // retires the run (`isCurrent`), and its answer never lands (`assertWrunCmeStudyAuthCurrent`). An OpenMarket
578
+ // package reads CME as first-party: the mark alone, no token.
579
+ if (computed.cme === true && isCmeUserScriptRun(provenance))
580
+ computed.cmeAuth = captureCmeStudyAuth();
503
581
  // The package's provenance, read once beside the wall's door: an OpenMarket package reads the US
504
582
  // options chain of a stock, ETF or OPRA contract chart, and so does a package the viewer wrote or
505
583
  // added from the community while the `opra-user-scripts` flag opens the plane to it
@@ -569,7 +647,14 @@ export async function runWrunOverlayOnChart(target) {
569
647
  }
570
648
  }
571
649
  else {
572
- await computeWrunOverlayOverLiveContext(marketTarget, (runTarget) => computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, computed, { chartIndex: target.chartIndex, mountEpoch, tc }, { chartMetadata, isCurrent, official, opraUserScripts, ...(options !== undefined ? { options } : {}) }));
650
+ await computeWrunOverlayOverLiveContext(marketTarget, (runTarget) => computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, computed, { chartIndex: target.chartIndex, mountEpoch, tc }, {
651
+ chartMetadata,
652
+ isCurrent,
653
+ official,
654
+ opraUserScripts,
655
+ ...(isCmeUserScriptCandidate(provenance) ? { cmeUserStudy: true } : {}),
656
+ ...(options !== undefined ? { options } : {}),
657
+ }));
573
658
  }
574
659
  integrated = true;
575
660
  computed.stage = 'applied';
@@ -656,6 +741,7 @@ export async function runWrunOverlayOnChart(target) {
656
741
  await surfaceWrunRunFailureOnLegend(target.chartIndex, target.indicatorId, error, {
657
742
  outputNames,
658
743
  opra: computed.opra === true,
744
+ cme: computed.cme === true,
659
745
  refusalContext: refusal.ctx,
660
746
  token: refusalAttempt,
661
747
  isCurrent,
@@ -739,6 +825,74 @@ function wrunRunRejectionAsSettled(error, run) {
739
825
  dropped.cause = WRUN_SUPERSEDED_RUN_CAUSE;
740
826
  return dropped;
741
827
  }
828
+ /** The record seed of a strategy sheet the run head refuses on a CME chart (`WrunStrategyVenueBlockedError`): the CME
829
+ * wall's `strategy` variant ("Strategy testing isn't available on CME markets"), its way out the class's own (switch
830
+ * the market, or the works-on list). */
831
+ const WRUN_CME_STRATEGY_REFUSAL_SEED = Object.freeze({ cls: 'cme-wall', variant: 'strategy' });
832
+ /** The record seed of a sheet the run head refuses on a prediction market (`WrunPredictionMarketBlockedError`, the rule
833
+ * wrunPredictionMarketWalls): the wall family's `prediction` variant, its way out the class's own (switch the market,
834
+ * or the works-on list). */
835
+ const WRUN_PREDICTION_MARKET_REFUSAL_SEED = Object.freeze({ cls: 'cme-wall', variant: 'prediction' });
836
+ /** The `cme-wall` record row of a study the gate's lifecycle stopped in place, by the stopped-study register's reason
837
+ * (cme-user-scripts-gate.util `cmeStudyStopReason`): `stopped` (the viewer's access moved) or `studies-off` (the flag
838
+ * went dark). */
839
+ const WRUN_CME_STOP_VARIANT = Object.freeze({
840
+ 'access-changed': 'stopped',
841
+ 'studies-off': 'studies-off',
842
+ });
843
+ /**
844
+ * The display wall's refusal at the run head for a CME chart study the lifecycle stopped in place: it carries the
845
+ * stopped row's seed (`WRUN_CME_STOP_VARIANT`), the words Door H paints over the same study, so a rerun (a pan, an
846
+ * interval change, an access recheck) reads why it stopped wherever its record is made (the editor console, the
847
+ * loader's catch), never today's wall. Any other wall refusal rides no seed: every reader words it as the wall, as
848
+ * before. The register is main-thread state; a study it holds no row for has none.
849
+ */
850
+ function withCmeStudyStopSeed(error, chartIndex, indicatorId, exchange) {
851
+ if (!payloadTouchesCmeVenue(exchange))
852
+ return error;
853
+ const reason = cmeStudyStopReason(chartIndex, indicatorId);
854
+ return reason === undefined
855
+ ? error
856
+ : attachWrunRefusal(error, { cls: 'cme-wall', variant: WRUN_CME_STOP_VARIANT[reason] });
857
+ }
858
+ /** Whether a run still computes under the authorisation its head captured: always for a run that captured none (every
859
+ * run but a CME chart study), else while the gate's epoch has not moved (`isCmeStudyAuthCurrent`). */
860
+ function wrunCmeStudyAuthStands(computed) {
861
+ return computed.cmeAuth === undefined || isCmeStudyAuthCurrent(computed.cmeAuth);
862
+ }
863
+ /** A CME chart study's answer lands only under the authorisation its head captured: asserted in the task that lands it
864
+ * (the integrate, a prefix page's commit), so an answer from before a move of the viewer's access is dropped as
865
+ * superseded (the quiet WrunChartGoneError: no chip, no toast, nothing applied). A no-op for every other run. */
866
+ function assertWrunCmeStudyAuthCurrent(computed, indicatorId) {
867
+ if (!wrunCmeStudyAuthStands(computed)) {
868
+ throw new WrunChartGoneError(`wrun overlay '${indicatorId}' was superseded during its run (cme-auth)`);
869
+ }
870
+ }
871
+ /** The console provenance a run's outputs carry (`setIndicatorPrintOutputs`): its OPRA fact always, its CME fact only
872
+ * when set, so an output of a run that read no CME reads exactly as before. */
873
+ function wrunRunOutputProvenance(computed) {
874
+ return { opra: computed.opra === true, ...(computed.cme === true ? { cme: true } : {}) };
875
+ }
876
+ /** Whether a venue refusal is the display wall's (its painter stamped the one standing legend message, so the run
877
+ * adds no record, chip or console row of its own): every `WrunVenueBlockedError` but the strategy and the
878
+ * prediction-market refusals, which no painter stands behind and which project their own records (`cme-wall`
879
+ * `strategy`, `prediction`). */
880
+ function isWrunVenueWallPainted(error) {
881
+ return (error instanceof WrunVenueBlockedError &&
882
+ !(error instanceof WrunStrategyVenueBlockedError) &&
883
+ !(error instanceof WrunPredictionMarketBlockedError));
884
+ }
885
+ /** A run's runtime trap row with the run's console provenance on it (`RuntimeDiagnostic.opra` and `.cme`): the row as
886
+ * it is for a run that read neither plane. */
887
+ function wrunTrapRowWithProvenance(trap, provenance) {
888
+ if (provenance.opra !== true && provenance.cme !== true)
889
+ return trap;
890
+ return {
891
+ ...trap,
892
+ ...(provenance.opra === true ? { opra: true } : {}),
893
+ ...(provenance.cme === true ? { cme: true } : {}),
894
+ };
895
+ }
742
896
  /**
743
897
  * The run's failure in the debug ring (`wrun-run-failed`, retained past the ring's cap as an anomaly): the overlay, the
744
898
  * run's reason, the stage it failed in and the error as it reads (its class, its message: a frame the host refused
@@ -786,10 +940,11 @@ function wrunRunSettleOf(error) {
786
940
  }
787
941
  /** Whether a failed run's rejection carries a refusal record: every one but the quiet rejections
788
942
  * whose surface is elsewhere (a chart that is gone or a superseded run, the venue wall's painter,
789
- * the Paused state, a source hold's degrade chip). */
943
+ * the Paused state, a source hold's degrade chip). The strategy refusal on a CME chart carries one:
944
+ * no painter stands behind it (`isWrunVenueWallPainted`). */
790
945
  function wrunRunFailureCarriesRefusal(error) {
791
946
  return (!(error instanceof WrunChartGoneError) &&
792
- !(error instanceof WrunVenueBlockedError) &&
947
+ !isWrunVenueWallPainted(error) &&
793
948
  !isWrunOverlayPausedError(error) &&
794
949
  !isWrunSourceHold(error));
795
950
  }
@@ -817,8 +972,9 @@ export async function surfaceWrunRunFailureOnLegend(chartIndex, indicatorId, err
817
972
  return;
818
973
  // The venue wall's painter already put its standing message on this
819
974
  // legend (and hid the plot): the refusal adds no chip, no console row and
820
- // no Retry of its own, so that message stays the only one.
821
- if (error instanceof WrunVenueBlockedError)
975
+ // no Retry of its own, so that message stays the only one. The strategy
976
+ // refusal on a CME chart has no painter behind it: its record goes on.
977
+ if (isWrunVenueWallPainted(error))
822
978
  return;
823
979
  // The same for a paused overlay (the legend shows Paused) and a source
824
980
  // hold (the degrade registry's chip, FE_SOURCE_LOADING / FE_SOURCE_DEGRADED,
@@ -841,8 +997,8 @@ export async function surfaceWrunRunFailureOnLegend(chartIndex, indicatorId, err
841
997
  if (trap && WRUN_RUN_FAILURE_ROW_CODES.has(trap.code)) {
842
998
  // The write waits on the store's module, so the rejection can outrun it: it rides the error, and the
843
999
  // editor's Run awaits it before it reads the row (wrunErrorFailureRowWritten). The author's abort text can
844
- // carry what the run computed: a run over OPRA data marks the row (every console export strips it).
845
- const written = publishWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, context.opra === true ? { ...trap, opra: true } : trap);
1000
+ // carry what the run computed: a run over OPRA or CME data marks the row (every console export strips it).
1001
+ const written = publishWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, wrunTrapRowWithProvenance(trap, context));
846
1002
  annotateWrunErrorFailureRow(error, written);
847
1003
  await written;
848
1004
  if (isCurrent())
@@ -983,6 +1139,13 @@ function wrunPinReadsOpra(market) {
983
1139
  return false;
984
1140
  return wrunPinMarketsOf(market.exchange ?? '', market.symbol ?? '').some((leg) => payloadTouchesOpraVenue(leg.exchange));
985
1141
  }
1142
+ /** Whether a pin names a market on the CME plane (`wrunPinReadsOpra`'s twin): only a CME chart's own family admits one
1143
+ * (the kit refuses a CME pin from any other chart, whoever wrote the package). */
1144
+ function wrunPinReadsCme(market) {
1145
+ if (market === undefined)
1146
+ return false;
1147
+ return wrunPinMarketsOf(market.exchange ?? '', market.symbol ?? '').some((leg) => payloadTouchesCmeVenue(leg.exchange));
1148
+ }
986
1149
  function wrunSheetReadsOpraLane(metadata) {
987
1150
  return wrunPollPlanReadsChain(metadata) || wrunRowPlanReadsChain(metadata);
988
1151
  }
@@ -1475,11 +1638,14 @@ const WRUN_SERIES_LANE_FETCH_KEYS = new Map([
1475
1638
  * its ask (never a declined one, `unsettled`), one feed-missing note per lane naming its readers.
1476
1639
  * The run publishes them only when an output went silent over the window.
1477
1640
  */
1478
- function wrunEmptySeriesFeeds(laneRun, unsettled, metadata, cryptoVenue, exchange) {
1641
+ function wrunEmptySeriesFeeds(laneRun, unsettled, metadata, cryptoVenue,
1642
+ // The market each lane was asked on (its acquisition's: the run market on a Trades chart), else the chart's.
1643
+ exchangeOf) {
1479
1644
  return laneRun.outcomes.flatMap(({ lane, outcome }) => {
1480
1645
  const key = WRUN_SERIES_LANE_FETCH_KEYS.get(lane);
1481
1646
  if (key === undefined || outcome.kind !== 'rows' || outcome.rows.length > 0 || unsettled.has(key))
1482
1647
  return [];
1648
+ const exchange = exchangeOf(lane);
1483
1649
  // The lane's own readers: a trades input pinned to another market reads its leg lane instead.
1484
1650
  const readers = wrunInputNamesOfClass(metadata, lane, (source) => !isWrunTradesLegLane(wrunSourceLane(source)));
1485
1651
  const type = WRUN_BUILTIN_LANE_FETCH_TYPES[lane];
@@ -1758,6 +1924,8 @@ async function settleWrunRefusalsOnSuccess(guardKey, target, refusal, chartStand
1758
1924
  try {
1759
1925
  if (chartStands)
1760
1926
  await retractWrunRefusal(target, 'all');
1927
+ if (refusal.superseded)
1928
+ return;
1761
1929
  const watch = setWrunTerminalDegradeWatch(guardKey, target, refusal.degraded);
1762
1930
  const terminal = watch ? wrunTerminalDegradeRefusalOf(guardKey, watch) : undefined;
1763
1931
  if (terminal)
@@ -1775,6 +1943,8 @@ async function settleWrunRefusalsOnSuccess(guardKey, target, refusal, chartStand
1775
1943
  */
1776
1944
  async function settleWrunRefusalsOnHold(guardKey, target, refusal, token, isCurrent) {
1777
1945
  try {
1946
+ if (refusal.superseded)
1947
+ return;
1778
1948
  const watch = setWrunTerminalDegradeWatch(guardKey, target, refusal.degraded);
1779
1949
  const terminal = watch ? wrunTerminalDegradeRefusalOf(guardKey, watch) : undefined;
1780
1950
  if (terminal) {
@@ -2211,6 +2381,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2211
2381
  // The open-interest lane's units (`currency` on the `oi` inputs, wrun-oi-lane.util): "Coin" asks the lane in the
2212
2382
  // market's native units, USD asks it exactly as before (no extras); two units refuse by name here.
2213
2383
  const oiLane = wrunOiLaneExtras(target.metadata);
2384
+ // Asked again before the rows leave: a flip onto a tape since the head must not hand that tape's bars over.
2385
+ const candleSource = wrunMainCandleSourceOf(head.chartMetadata);
2386
+ const provenance = view.settings;
2387
+ if (candleSource && isKScriptDisplayBlockedOnExchange(candleSource.exchange, provenance)) {
2388
+ throw new WrunVenueBlockedError(createKScriptVenueBlockedError(candleSource.exchange).message);
2389
+ }
2214
2390
  const loadedRows = wrunChartCandleRows(tc);
2215
2391
  if (loadedRows.length === 0)
2216
2392
  throw new WrunNoBarsError('chart has no candle rows yet');
@@ -2266,6 +2442,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2266
2442
  if (tape !== undefined) {
2267
2443
  await assertWrunTapeServedOnInterval(target.metadata, tape.inputNames[0], typeof chartMetadata?.interval === 'string' ? chartMetadata.interval : '');
2268
2444
  }
2445
+ // The ONE run market, asked only by a sheet over the chart's trades (no other run waits on a ticker's tape answer).
2446
+ const runMarketDecided = wrunSheetReadsRunMarket(target.metadata)
2447
+ ? decideWrunRunMarket(chartMetadata, view.settings)
2448
+ : Promise.resolve(null);
2269
2449
  // A dollar tape (C-DOLLAR) prices its live prints in its history's unit: the dollar unit of the market's own facts
2270
2450
  // (wrunMarketDollarUnit: a CME contract's registry point value, else the point value on a market quoted in dollars).
2271
2451
  // Its reads are the directory row's quote and the instrument registry's units, each waited on once
@@ -2382,14 +2562,16 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2382
2562
  // Timeframe is coarser than the chart computes AT it, on that interval's candles fetched with a
2383
2563
  // warm-up below the chart's first bar, its rows projected onto the chart's bars by the adapter.
2384
2564
  // Read ONCE here: the clock, the rows, the init args, the integrate and the session this run
2385
- // installs (its ticks and reseeds) all follow this stamp. Null keeps the chart's own bars.
2565
+ // installs (its ticks and reseeds) all follow this stamp. Null keeps the chart's own bars. A replay
2566
+ // run reads it too where the run bars ride a session calendar (the chart's session, its symbol and
2567
+ // session type: isWrunRunIntervalSessionMarket), so a twin computes on the live run's bars.
2386
2568
  const chartTransformations = typeof chartMetadata?.transformations === 'string' ? chartMetadata.transformations : undefined;
2387
- const run = overlayWrunRunInterval(target.chartIndex, view, chartInterval, chartExchange, chartTransformations);
2569
+ const run = overlayWrunRunInterval(target.chartIndex, view, chartInterval, chartExchange, chartTransformations, chartMetadata);
2388
2570
  // A replay run on the chart's own bars starts where the kScript replay window does: the candles
2389
2571
  // before the chart's first bar ride the K_OHLCV lane the kScript engine fetches them on (a run at
2390
2572
  // another interval warms up on its run bars, the live rule).
2391
2573
  const replayHeadRows = replay && !run && replay.fromMs < chartRows[0][0]
2392
- ? await fetchWrunReplayHeadRows(target, view, replay.fromMs, chartRows[0][0], download)
2574
+ ? await fetchWrunReplayHeadRows(target, view, replay.fromMs, chartRows[0][0], download, candleSource ?? undefined)
2393
2575
  : [];
2394
2576
  // Joined ahead of the chart's bars with their missing bars kept (a spread drops them).
2395
2577
  chartRows = wrunChartCandleRowsAfterHead(replayHeadRows, chartRows);
@@ -2684,7 +2866,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2684
2866
  // The options_chain lane's identity (wrunOptionsChainLaneExtrasFor), decided before its own fetch like every plan:
2685
2867
  // a refusal by name fails the run, never reads as a degraded lane.
2686
2868
  const optionsChainPlanned = declaredClasses.has('options_chain')
2687
- ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts, laneParamValues, head.options)
2869
+ ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts, laneParamValues, head.options, head.cmeUserStudy === true)
2688
2870
  : Promise.resolve(undefined);
2689
2871
  // The OPRA provenance the native options overlays carry (`settings.metaExchange`, the field the chart read
2690
2872
  // withholds an overlay by and the tier moves refetch it by, options-overlay-provenance.util): every OPRA lane
@@ -2828,6 +3010,11 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2828
3010
  tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsOpra(wrunTradesLegOf(lane)))) {
2829
3011
  computed.opra = true;
2830
3012
  }
3013
+ // The same for a leg on the CME plane (`computed.cme`): a leg the run admitted reads CME data.
3014
+ if (legs.some((leg) => wrunPinReadsCme(leg.market)) ||
3015
+ tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsCme(wrunTradesLegOf(lane)))) {
3016
+ computed.cme = true;
3017
+ }
2831
3018
  const formingBarTs = live && replay === undefined && wrunLandsLegsOnBars(legs, tradeLegLanes)
2832
3019
  ? await wrunFormingBarTsOf(target.chartIndex, clock.intervalMs, chartMetadata)
2833
3020
  : null;
@@ -2949,8 +3136,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2949
3136
  // The trades leg lanes the rule judged unserved on their own market: never dispatched.
2950
3137
  const unservedTradeLegs = new Set();
2951
3138
  const judgeLaneService = (verdicts) => {
2952
- for (const { lane, type, service, holding, inputNames: readers, market } of verdicts) {
2953
- const reason = wrunUnservedLaneReason(type, market?.exchange ?? chartExchange, chartCoin, service);
3139
+ for (const { lane, type, service, holding, inputNames: readers, market, judgedExchange } of verdicts) {
3140
+ // Named by the market the lane was judged on: a leg's own, the run market (a Trades chart's tape), the chart's.
3141
+ const reason = wrunUnservedLaneReason(type, market?.exchange ?? judgedExchange ?? chartExchange, chartCoin, service);
2954
3142
  if (holding !== undefined) {
2955
3143
  const fill = holding.celled ? 'empty' : 'nan';
2956
3144
  // A leg stream reads its leg or nothing (it declares no fill): the market's lane is its only source.
@@ -2989,7 +3177,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2989
3177
  // network decides its verdict (a row lane's class is no admission lane, so the row plan's native classes change no
2990
3178
  // verdict). The options chain's verdict waits for its identity (a governed chain rides its plane's rows on the
2991
3179
  // native-rows path) and is judged right before the chain lane dispatches.
2992
- judgeLaneService(wrunUnservedLanes(target.metadata, { exchange: chartExchange, coin: chartCoin }).filter((verdict) => verdict.lane !== 'options_chain'));
3180
+ // Awaited once here: a class over the chart's trades is judged and asked where they print, never the stored market.
3181
+ const runMarket = await runMarketDecided;
3182
+ judgeLaneService(wrunUnservedLanes(target.metadata, { exchange: chartExchange, coin: chartCoin }, { runMarket }).filter((verdict) => verdict.lane !== 'options_chain'));
2993
3183
  // Each declared source class rides the SAME kScript fetch lane the local
2994
3184
  // engine uses for the original script, so A/B comparisons see one data set.
2995
3185
  // Deadline-raced: a source lane resolves only when its V2 stream completes
@@ -3018,7 +3208,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3018
3208
  fromTs: from,
3019
3209
  window,
3020
3210
  ...(reason === 'settings' && declaredClasses.has('volume_profile')
3021
- ? { volumeProfileGrid: await resolveWrunVolumeProfileGrid(target.chartIndex) }
3211
+ ? { volumeProfileGrid: await resolveWrunVolumeProfileGrid(target.chartIndex, runMarket) }
3022
3212
  : {}),
3023
3213
  });
3024
3214
  const heldCoverage = {};
@@ -3033,6 +3223,24 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3033
3223
  heldCoverage[lane] = held.coveredThroughTs;
3034
3224
  return held.rows;
3035
3225
  };
3226
+ // The market an ask naming no pin of its own reads, by its fetch type (WRUN_RUN_MARKET_READS): nothing else moves.
3227
+ const askMarketOf = (type, payloadExtras) => {
3228
+ if (payloadExtras?.exchange !== undefined || payloadExtras?.symbol !== undefined)
3229
+ return {};
3230
+ const read = wrunRunMarketReadOfFetchType(type);
3231
+ if (read === 'run-market')
3232
+ return runMarket ?? {};
3233
+ if (read !== 'candle-source')
3234
+ return {};
3235
+ const { source, walled } = wrunCandleAskSource(chartMetadata, provenance);
3236
+ if (source === null)
3237
+ return {};
3238
+ // A flip onto a tape the run may not read since the rows handoff walls the ask, as the handoff itself does.
3239
+ if (walled)
3240
+ throw new WrunVenueBlockedError(createKScriptVenueBlockedError(source.exchange).message);
3241
+ // The series ref alone (the main stream's rule): the session, the index mode and the bar grid stay the chart's.
3242
+ return { candleSource: source };
3243
+ };
3036
3244
  const fetchLane = async (type, key, fetchOptions,
3037
3245
  // Lane-specific payload fields beyond the current-market placeholders
3038
3246
  // (the Deribit option-summary lanes key by coin, skew also by delta),
@@ -3047,7 +3255,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3047
3255
  if (downloadPlanned !== undefined)
3048
3256
  await downloadPlanned;
3049
3257
  const meter = fetchOptions?.meter ?? download;
3050
- const payload = { symbol: 'currentSymbol', exchange: 'currentExchange', ...payloadExtras };
3258
+ // The market every ask naming no pin of its own reads (its acquisition keeps it, so the reconcile and live agree).
3259
+ const askExtras = { ...askMarketOf(type, payloadExtras), ...payloadExtras };
3260
+ const payload = { symbol: 'currentSymbol', exchange: 'currentExchange', ...askExtras };
3051
3261
  const lane = wrunLiveLaneOfFetchKey(key);
3052
3262
  if (lane !== undefined)
3053
3263
  acquisitionByLane[lane] = payload;
@@ -3059,12 +3269,15 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3059
3269
  const own = fetchOptions?.ownFetch === undefined
3060
3270
  ? serveWrunOwnCandles({
3061
3271
  type,
3062
- ...(payloadExtras !== undefined ? { payloadExtras } : {}),
3272
+ payloadExtras: askExtras,
3063
3273
  interval: run && fetchOptions?.interval === undefined ? run.interval : fetchOptions?.interval,
3064
3274
  replay: replay !== undefined,
3065
3275
  fromTs,
3066
3276
  toTs,
3067
3277
  chart: {
3278
+ // The host's candle-source reader reads the chart's metadata whole (a US stock's feed decides whether
3279
+ // its rows came from the tape): the market fields below stand on it.
3280
+ ...chartMetadata,
3068
3281
  exchange: chartExchange,
3069
3282
  symbol: chartSymbol,
3070
3283
  interval: chartInterval,
@@ -3381,9 +3594,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3381
3594
  // The native-rows path the leg records (`legs` above): its rows at their own stamps.
3382
3595
  const native = leg.nativeRows === true ? { nativeRows: true } : undefined;
3383
3596
  const { gate, readers } = wrunLegGate(leg, plannedWires);
3384
- // A leg whose bars its venue closes off their open plus the span (a CME session bar) keeps a
3385
- // candle out until its own close.
3386
- const closeMs = wrunLegCandleClose(leg, chartExchange, chartSessionType);
3597
+ // A leg whose bars its venue closes off their open plus the span (a CME session bar, an RTH stub at the session
3598
+ // close) keeps a candle out until its own close.
3599
+ const closeMs = wrunLegCandleClose(leg, chartExchange, chartSessionType, {
3600
+ symbol: chartMetadata?.symbol,
3601
+ interval: clock.intervalMs,
3602
+ });
3387
3603
  const readsLiveCandle = wrunLegReadsLiveCandle(leg, plannedWires);
3388
3604
  // Recorded even for a leg the wall leaves nothing to ask of: the reconcile refreshes the legs it finds here.
3389
3605
  if (readsLiveCandle)
@@ -3405,7 +3621,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3405
3621
  // trade-date label, `wrunPrimaryRowBounds`), so the ask starts there, else at the head.
3406
3622
  const headMs = wrunChartHostEnv()
3407
3623
  .sharedHost()
3408
- .wrunLegRowBoundsMs(from, clock.intervalMs, wrunPrimaryRowBounds(chartExchange, clock.intervalMs)).openMs;
3624
+ .wrunLegRowBoundsMs(from, clock.intervalMs, wrunPrimaryRowBounds(chartExchange, clock.intervalMs, {
3625
+ symbol: chartMetadata?.symbol,
3626
+ sessionType: chartSessionType,
3627
+ })).openMs;
3409
3628
  // kScript's ltf(): the chart's window asked whole, the gateway trimming it at the viewer's
3410
3629
  // wall, and a source that fails or answers nothing stored as no rows while the script runs
3411
3630
  // over empty cells (dataManager's failed fetch: `{ data: [], success: false }`, logged). So
@@ -3707,16 +3926,14 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3707
3926
  }
3708
3927
  },
3709
3928
  ...(laneDownload !== undefined ? { download: laneDownload } : {}),
3710
- // One download budget per add (wrun-row-lane-add-memo.util): a budgeted run leaves the add a memo of what it
3711
- // landed and cut, a later run of the add (a loaded-range refresh) reuses it, a whole run drops it.
3712
- ...(downloadBudgetCut
3713
- ? {
3714
- addMemo: {
3715
- key: wrunRowLaneAddKey(target.chartIndex, target.indicatorId, instance.key),
3716
- role: 'run',
3717
- },
3718
- }
3719
- : {}),
3929
+ // One record per add (wrun-row-lane-add-memo.util), whatever the budget: every run leaves the add a memo of
3930
+ // the bars it landed whole and final, and a later read of the add (a loaded-range refresh, the live start, each
3931
+ // live reconcile) reuses them and asks only the rest. A budgeted run's memo also holds what its budget cut and
3932
+ // spent; a whole run asks the cut bars again. A replay run's read keeps its own memo (`replayCursorMs`).
3933
+ addMemo: {
3934
+ key: wrunRowLaneAddKey(target.chartIndex, target.indicatorId, instance.key),
3935
+ role: 'run',
3936
+ },
3720
3937
  // The slice's own rows always hold one with data (an empty slice has no early answer), so a lane that must
3721
3938
  // answer rows never paints off an empty one.
3722
3939
  ...(tradeDateOf === undefined || early === undefined || !firstSlicePaint
@@ -3884,7 +4101,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3884
4101
  const extras = volumeProfileLane !== undefined ? { ...volumeProfileLane } : undefined;
3885
4102
  const [rows, minimumBarHeight] = await Promise.all([
3886
4103
  fetchDegradableLane('volume_profile', 'vp', 'Volume profile', extras),
3887
- resolveWrunVolumeProfileGrid(target.chartIndex),
4104
+ resolveWrunVolumeProfileGrid(target.chartIndex, runMarket),
3888
4105
  ]);
3889
4106
  if (minimumBarHeight !== undefined) {
3890
4107
  acquisitionByLane.volume_profile = { ...acquisitionByLane.volume_profile, minimumBarHeight };
@@ -3922,7 +4139,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3922
4139
  // The options_chain lane dispatches in its own group, once its identity resolved (below).
3923
4140
  etf_flow: etfLanePlan !== undefined ? () => fetchEtfFlowRows(etfLanePlan) : undefined,
3924
4141
  // The trade tape (C2): the K_TRADES lane asked for the large-print table (`large: true`, the
3925
- // TRADE_LARGE type) at the acquisition's facets, the one floor pushed down to the gateway
4142
+ // TRADE_LARGE type) wherever the table holds the market the tape reads, else for the raw tape (a
4143
+ // CME root the collector does not copy: two hours and the raw live channel, wrunTapeLaneExtras),
4144
+ // at the acquisition's facets, the one floor pushed down to the gateway
3926
4145
  // (`minSize` as `minAmount`, a dollar `minValue` as `minQuoteAmount`, C-DOLLAR) and `history`
3927
4146
  // passed as declared: the control serves the history start aligned to the bar inside the
3928
4147
  // chart's window, clamped to the table's 90-day retention. A history of "0" answers EMPTY by
@@ -3933,7 +4152,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3933
4152
  // market facts' dollar unit, so a live print is priced in the history's unit, never guessed)
3934
4153
  // and the reconcile's re-ask.
3935
4154
  tape: tape !== undefined
3936
- ? async () => (await fetchLane('trades', 'tp', undefined, wrunTapeLaneExtras(tape, tapeValuePerUnit))) ?? []
4155
+ ? async () =>
4156
+ // The lane follows the market the tape reads (the run market fetchLane writes, else the chart's).
4157
+ (await fetchLane('trades', 'tp', undefined, wrunTapeLaneExtras(tape, tapeValuePerUnit, runMarket ?? chartMetadata))) ?? []
3937
4158
  : undefined,
3938
4159
  // The trades leg lanes (kit 0.77.0), one thunk per (quote, market): K_BUY_SELL_VOLUME asked on
3939
4160
  // the leg's market in its quote, under the lane id as its fetch key (its own cache entry and
@@ -4122,7 +4343,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4122
4343
  if (extras === undefined)
4123
4344
  return undefined;
4124
4345
  const governed = wrunOptionsChainExtrasGoverned(extras);
4125
- judgeLaneService(wrunUnservedLanes(target.metadata, { exchange: chartExchange, coin: chartCoin }, { nativeLanes: governed ? ['options_chain'] : [] }).filter((verdict) => verdict.lane === 'options_chain'));
4346
+ judgeLaneService(wrunUnservedLanes(target.metadata, { exchange: chartExchange, coin: chartCoin }, { nativeLanes: governed ? ['options_chain'] : [], runMarket }).filter((verdict) => verdict.lane === 'options_chain'));
4126
4347
  if (unservedLanes.includes('options_chain'))
4127
4348
  return undefined;
4128
4349
  await stampWrunOpraProvenance(extras.chainVenue === 'opra');
@@ -4173,6 +4394,15 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4173
4394
  // The plan reads the OPRA plane: the run's console provenance, set before the module computes (`computed.opra`).
4174
4395
  if (readsOpraPlane)
4175
4396
  computed.opra = true;
4397
+ // A lane the plans kept on the CME plane (a CME root's chain an OpenMarket package reads, whatever the chart: the
4398
+ // chain wall keeps every other run off it) reads CME data: the run's CME provenance too (`computed.cme`).
4399
+ const gatePlanes = wrunLaneGatePlanes({
4400
+ pollLanes,
4401
+ rowLanes,
4402
+ ...(optionsChainExtras !== undefined ? { optionsChainExtras } : {}),
4403
+ });
4404
+ if ([...gatePlanes.values()].includes('cme'))
4405
+ computed.cme = true;
4176
4406
  const writeOpraProvenance = await opraProvenanceWriter;
4177
4407
  // A degrade entry of a lane this run does not dispatch is settled now: a trades leg the coin switch moved, or a lane
4178
4408
  // a setting gate, a unit pick, `needed_by` or the capability rule dropped. No later run of this sheet asks that lane
@@ -4196,6 +4426,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4196
4426
  });
4197
4427
  noteWrunGatePlanesRead(target.chartIndex, target.indicatorId, laneGatePlanes.values());
4198
4428
  const laneRun = await schedule.settled();
4429
+ // A switch keeps the mount and attempt (`isCurrent` stays true) but bumps the data generation; its cancelled reads are no verdict on the new market.
4430
+ const runStands = head.isCurrent() && getChartDataFetchGeneration(target.chartIndex) === planGeneration;
4431
+ if (!runStands)
4432
+ refusal.superseded = true;
4199
4433
  // A degraded lane on a plane another screen holds (stopped at dispatch, or the latch came while its read was out)
4200
4434
  // stopped for that reason: it says so, and no ladder re-asks it (only the take-back serves it).
4201
4435
  const gateStops = new Map(laneRun.degraded.flatMap(({ lane, outcome }) => {
@@ -4235,7 +4469,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4235
4469
  }),
4236
4470
  }));
4237
4471
  for (const { lane, outcome } of laneRun.outcomes) {
4238
- if (outcome.kind === 'rows')
4472
+ if (runStands && outcome.kind === 'rows')
4239
4473
  wrunChartHostEnv().chart.markSourceRecovered(guardKey, lane);
4240
4474
  }
4241
4475
  // The row lanes that answered their first-paint slice alone (`firstSlicePaint`): their older bars are still out, a
@@ -4253,6 +4487,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4253
4487
  }));
4254
4488
  for (const entry of degraded) {
4255
4489
  unsettledLanes.add(entry.lane);
4490
+ if (!runStands)
4491
+ continue;
4256
4492
  wrunChartHostEnv().chart.markSourceDegraded(guardKey,
4257
4493
  // A picture stays up (this run's, or the last good one a hold keeps):
4258
4494
  // the chip says the source is missing from it; with nothing drawn yet
@@ -4305,7 +4541,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4305
4541
  // A replay run's run bars as of its cutoff: the closed ones as fetched, the forming one folded
4306
4542
  // from the completed chart bars in its bucket (the fetched one holds trades past the playhead).
4307
4543
  const runBars = replay && run && fetchedRunBars
4308
- ? wrunReplayRunBars(fetchedRunBars, replayChartRows, replay.cutoffTs, run.intervalMs, chartIntervalMs)
4544
+ ? wrunReplayRunBars(fetchedRunBars, replayChartRows, replay.cutoffTs, run, chartIntervalMs)
4309
4545
  : fetchedRunBars;
4310
4546
  // The primary rows: the chart's candles, or the run bars the package computes over (with wait
4311
4547
  // for close on, the closed ones only: wrunRunIntervalComputeRows). A replay run's newest chart
@@ -4509,7 +4745,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
4509
4745
  // (`wrunSessionClock`: the candle closes and opens of the legs whose venue closes a bar off its
4510
4746
  // open plus the span, CME or a US listing on regular hours, and the bounds of the chart's own
4511
4747
  // CME session rows).
4512
- session: wrunChartSession(chartExchange, chartSessionType),
4748
+ session: wrunChartSession(chartExchange, chartSessionType, {
4749
+ symbol: chartMetadata?.symbol,
4750
+ interval: clock.intervalMs,
4751
+ }),
4513
4752
  // The chart's market at the run's interval: the `time.trade_date` / `time.session` facts are read for it.
4514
4753
  venue: wrunBarVenueOf(chartMetadata, clock.intervalMs),
4515
4754
  // A leg's row still forming past the chart's newest bar lands in the forming bar (a live run's alone).
@@ -5186,6 +5425,25 @@ function stopWrunHeldRowSourceRouting(chartIndex, indicatorId) {
5186
5425
  }
5187
5426
  /** Specs only: forget every held source (none is released), the socket's losses and the pending asks (none is
5188
5427
  * cancelled). */
5428
+ /** The sheet draws price canvases (a heatmap or a profile): their cells are the session's to hand a rebuild. */
5429
+ function wrunSheetDrawsCanvases(metadata) {
5430
+ return (metadata.heatmaps?.length ?? 0) > 0 || (metadata.profiles?.length ?? 0) > 0;
5431
+ }
5432
+ /** The context holds lane buffers a rebuild reads the price canvases' cells from (wrunCellRowsOf). */
5433
+ function wrunHoldsCanvasCells(context) {
5434
+ return (context.bookRows !== undefined || context.volumeProfileRows !== undefined || context.intrabarRows !== undefined);
5435
+ }
5436
+ /** Spec seam: hold `source` as the overlay's row source (as a landed cloud run does), so a spec can reach what
5437
+ * reads the held source without running one. */
5438
+ export function __holdWrunRowSourceForTests(indicatorId, source) {
5439
+ wrunHeldRowSources.set(indicatorId, {
5440
+ source,
5441
+ identity: {},
5442
+ settings: {},
5443
+ slot: { run: {} },
5444
+ routes: true,
5445
+ });
5446
+ }
5189
5447
  export function __resetWrunHeldRowSourcesForTests() {
5190
5448
  wrunHeldRowSources.clear();
5191
5449
  __resetWrunSocketSessionLossesForTests();
@@ -5339,10 +5597,13 @@ async function computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, comp
5339
5597
  // The run produced rows: its debug log reaches the editor console now, before the render
5340
5598
  // verdict, the way a kScript run's print() output does (a refused integrate or render charge
5341
5599
  // still shows the lines that explain it). A hidden head's rows are cut first (D4): the log
5342
- // reads the landed rows, as everything after it does.
5600
+ // reads the landed rows, as everything after it does. A CME chart study whose authorisation moved since its head
5601
+ // publishes nothing: its integrate drops it as superseded (`assertWrunCmeStudyAuthCurrent`).
5343
5602
  answered: (rows) => {
5603
+ if (!wrunCmeStudyAuthStands(computed))
5604
+ return Promise.resolve();
5344
5605
  const ran = host.prepared;
5345
- return publishWrunDebugOutput(runTarget.chartIndex, runTarget.indicatorId, ran.request.metadata, wrunSandboxLandedRows(ran, rows), { opra: computed.opra === true });
5606
+ return publishWrunDebugOutput(runTarget.chartIndex, runTarget.indicatorId, ran.request.metadata, wrunSandboxLandedRows(ran, rows), wrunRunOutputProvenance(computed));
5346
5607
  },
5347
5608
  };
5348
5609
  const record = wrunRowSourceRecordOf(runTarget.metadata, meta);
@@ -5470,6 +5731,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5470
5731
  });
5471
5732
  fillingRaised = true;
5472
5733
  }
5734
+ // A CME chart study lands only under the authorisation its head captured, judged in the task that applies it.
5735
+ assertWrunCmeStudyAuthCurrent(computed, target.indicatorId);
5473
5736
  const runSerial = nextWrunCanvasRunSerial(target.indicatorId);
5474
5737
  const integration = integrateWrunRunThroughRoute({
5475
5738
  ...integrateOptions,
@@ -5581,7 +5844,10 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5581
5844
  // only the outputs a viewer sees are watched, and none while a source the run reads is absent
5582
5845
  // on this market (its own note says so once).
5583
5846
  const draft = isWrunDraftOverlaySettings(meta.settings);
5584
- const emptySeries = wrunEmptySeriesFeeds(laneRun, unsettledLanes, target.metadata, cryptoVenue, chartExchange);
5847
+ const emptySeries = wrunEmptySeriesFeeds(laneRun, unsettledLanes, target.metadata, cryptoVenue, (lane) => {
5848
+ const asked = acquisitionByLane[lane]?.exchange;
5849
+ return typeof asked === 'string' && asked !== 'currentExchange' ? asked : chartExchange;
5850
+ });
5585
5851
  // A source counts as absent only when it says so itself (a feed-missing note, the degrade chip,
5586
5852
  // a leg note, the empty-series note): an empty window with no note of its own (a quiet
5587
5853
  // liquidations window, a loaded-empty ETF day) never hides an unrelated silent output.
@@ -5692,6 +5958,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5692
5958
  indicatorId: target.indicatorId,
5693
5959
  // The run's console provenance: every debug line the session's ticks and reseeds publish states it.
5694
5960
  ...(computed.opra === true ? { opraRead: true } : {}),
5961
+ ...(computed.cme === true ? { cmeRead: true } : {}),
5695
5962
  // The current paint (above): the ticks and the reseeds keep the look.
5696
5963
  metadata: sheetNow,
5697
5964
  title: target.title,
@@ -5941,7 +6208,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
5941
6208
  const session = live ? getWrunOverlayLiveContext(target.indicatorId) : undefined;
5942
6209
  if (session !== undefined) {
5943
6210
  // A live session: its CURRENT rows and buffers (ticks moved them since the run), under its lock.
5944
- await withWrunOverlaySessionLock(target.indicatorId, () => reintegrateWrunSessionCanvases(target.indicatorId, session, fill, () => wrunTpoRefineCurrent(request)));
6211
+ await withWrunOverlaySessionLock(target.indicatorId, () => reintegrateWrunSession(target.indicatorId, session, fill, () => wrunTpoRefineCurrent(request)));
5945
6212
  return;
5946
6213
  }
5947
6214
  // A wrun run never draws over replay rows (the run's own replay lock).
@@ -6444,7 +6711,7 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6444
6711
  ? { emptyTargets: runResult.emptyTargets, partial: window?.partial === true }
6445
6712
  : undefined);
6446
6713
  await publishWrunStrategyRunResult(chartIndex, indicatorId, runResult, { tc, meta });
6447
- await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows, { opra: computed.opra === true });
6714
+ await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows, wrunRunOutputProvenance(computed));
6448
6715
  const draft = isWrunDraftOverlaySettings(meta.settings);
6449
6716
  const { health } = wrunChartRunHealth(sheetNow, meta.settings, outputRows, false, wrunChartSizeUnit(chartMetadata));
6450
6717
  const runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, draft, wrunNothingReadyRefusal(health, refusal.ctx)));
@@ -6555,6 +6822,7 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
6555
6822
  ...withWrunCloudOpraServed(session ?? batch),
6556
6823
  // The run's console provenance: every debug line the session's ticks publish states it.
6557
6824
  ...(computed.opra === true ? { opraRead: true } : {}),
6825
+ ...(computed.cme === true ? { cmeRead: true } : {}),
6558
6826
  carrySeed: emptyWrunInputCarry(),
6559
6827
  fedBuckets: {},
6560
6828
  pushEligible: false,
@@ -7042,10 +7310,11 @@ function wrunChartIntervalMs(chartInterval, ohlcvRows) {
7042
7310
  }
7043
7311
  /** The run-interval state of the overlay's current live session on this chart, the run bars a
7044
7312
  * full run may reuse (planWrunRunIntervalRows); none for a suspended session (its buffers stopped
7045
- * following the market). */
7313
+ * following the market) or a replay one (its forming bar folds the replay's bars as of its cutoff,
7314
+ * and a run after the exit computes on the live run bars, never on that fold). */
7046
7315
  function heldWrunRunIntervalSession(chartIndex, indicatorId) {
7047
7316
  const context = getWrunOverlayLiveContext(indicatorId);
7048
- if (!context || context.chartIndex !== chartIndex || context.liveSuspended)
7317
+ if (!context || context.chartIndex !== chartIndex || context.liveSuspended || context.replay)
7049
7318
  return undefined;
7050
7319
  return wrunRunIntervalSessionOf(context);
7051
7320
  }
@@ -7089,8 +7358,10 @@ function assertWrunRunMayPaint(chartIndex, indicatorId, replay) {
7089
7358
  /** The kScript replay window's warm-up candles before the chart's first bar,
7090
7359
  * on the K_OHLCV lane the kScript engine fetches them on (deadline-raced like
7091
7360
  * every lane): [fromMs, beforeMs). */
7092
- async function fetchWrunReplayHeadRows(target, meta, fromMs, beforeMs, meter) {
7093
- const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(target.chartIndex, 'ohlcv', { symbol: 'currentSymbol', exchange: 'currentExchange' }, fromMs, beforeMs, meta, `${target.fetchKey}-replay-head`, false, { meter }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun replay head for '${target.fetchKey}'`);
7361
+ async function fetchWrunReplayHeadRows(target, meta, fromMs, beforeMs, meter,
7362
+ // The market the chart's rows came from (the rows handoff's walled read): the head joins those rows.
7363
+ candleSource) {
7364
+ const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(target.chartIndex, 'ohlcv', { symbol: 'currentSymbol', exchange: 'currentExchange', ...(candleSource ? { candleSource } : {}) }, fromMs, beforeMs, meta, `${target.fetchKey}-replay-head`, false, { meter }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun replay head for '${target.fetchKey}'`);
7094
7365
  const rows = isPackedOhlcvRows(fetched)
7095
7366
  ? unpackOhlcvRows(fetched)
7096
7367
  : Array.isArray(fetched)
@@ -7107,33 +7378,58 @@ async function fetchWrunReplayHeadRows(target, meta, fromMs, beforeMs, meter) {
7107
7378
  /**
7108
7379
  * A replay run's run bars as of its cutoff (WRUN-PARITY-REST B1): the run
7109
7380
  * bars the window fetched hold every bucket in full, the one the playhead is
7110
- * in included. The bucket holding the newest completed chart bar is folded
7111
- * from the completed chart bars inside it (the replay's own candle fold,
7112
- * `aggregateOhlcvRows`) until the cutoff bar closes it, the buckets before it
7113
- * stay as fetched, and none after it is kept: a run bar shows only what the
7114
- * replay revealed, the live rule (live, the forming run bar folds the candles
7115
- * as they trade and the closed one is the fetched one).
7381
+ * in included. It keeps the bars open by the cutoff bar (the newest completed
7382
+ * chart bar), none after, each span read on the run's calendar (runBarSpan:
7383
+ * an RTH hour opens at its session-anchored stamp, a CME trade date at the
7384
+ * evening open before its 00:00Z stamp). The newest one is folded from the
7385
+ * completed chart bars inside its span until the cutoff bar closes it, and
7386
+ * the bars before it stay as fetched: a run bar shows only what the replay
7387
+ * revealed, the live rule (live, the forming run bar folds the candles as
7388
+ * they trade and the closed one is the fetched one). A forming bar with no
7389
+ * revealed chart bar is left out, as live opens one on its first trade.
7116
7390
  */
7117
- export function wrunReplayRunBars(runBars, chartRows, cutoffTs, runIntervalMs, chartIntervalMs) {
7118
- let formingAt = -1;
7119
- for (let at = 0; at < runBars.length; at += 1) {
7120
- if (Number(runBars[at][0]) <= cutoffTs)
7121
- formingAt = at;
7391
+ export function wrunReplayRunBars(runBars, chartRows, cutoffTs, run, chartIntervalMs) {
7392
+ // The first bar stamped past the cutoff (stamps ascending), then each one after it already open
7393
+ // by the cutoff bar (a session bar opens before its stamp).
7394
+ let lo = 0;
7395
+ let hi = runBars.length;
7396
+ while (lo < hi) {
7397
+ const mid = (lo + hi) >> 1;
7398
+ if (Number(runBars[mid][0]) <= cutoffTs)
7399
+ lo = mid + 1;
7122
7400
  else
7123
- break;
7401
+ hi = mid;
7124
7402
  }
7125
- if (formingAt < 0)
7403
+ let end = lo;
7404
+ while (end < runBars.length && runBarSpan(Number(runBars[end][0]), run).open <= cutoffTs)
7405
+ end += 1;
7406
+ if (end === 0)
7126
7407
  return [];
7127
- const formingTs = Number(runBars[formingAt][0]);
7128
- const kept = runBars.slice(0, formingAt + 1);
7129
- // The cutoff bar is the bucket's last: the bucket closed, as fetched.
7130
- if (formingTs + runIntervalMs <= cutoffTs + chartIntervalMs)
7408
+ const kept = runBars.slice(0, end);
7409
+ const formingTs = Number(kept[end - 1][0]);
7410
+ const span = runBarSpan(formingTs, run);
7411
+ // The cutoff bar is the bar's last: the bar closed, as fetched.
7412
+ if (span.close <= cutoffTs + chartIntervalMs)
7131
7413
  return kept;
7132
- const inBucket = chartRows
7133
- .filter((row) => Number(row[0]) >= formingTs && Number(row[0]) <= cutoffTs)
7134
- .map((row) => Array.from(row));
7135
- const [folded] = aggregateOhlcvRows(inBucket, runIntervalMs, formingTs, cutoffTs, { originMs: formingTs });
7136
7414
  kept.pop();
7415
+ let folded;
7416
+ for (const row of chartRows) {
7417
+ const ts = Number(row[0]);
7418
+ if (ts > cutoffTs)
7419
+ break;
7420
+ if (ts < span.open)
7421
+ continue;
7422
+ const volume = Number(row[5]);
7423
+ const traded = Number.isFinite(volume) ? volume : 0;
7424
+ if (folded === undefined) {
7425
+ folded = [formingTs, Number(row[1]), Number(row[2]), Number(row[3]), Number(row[4]), traded];
7426
+ continue;
7427
+ }
7428
+ folded[2] = Math.max(folded[2], Number(row[2]));
7429
+ folded[3] = Math.min(folded[3], Number(row[3]));
7430
+ folded[4] = Number(row[4]);
7431
+ folded[5] += traded;
7432
+ }
7137
7433
  if (folded)
7138
7434
  kept.push(folded);
7139
7435
  return kept;
@@ -7220,6 +7516,8 @@ async function writeWrunStandIn(args) {
7220
7516
  interval: args.chartMetadata?.interval,
7221
7517
  transformations: args.chartMetadata?.transformations,
7222
7518
  account: wrunChartHostEnv().user.standInAccount(),
7519
+ sessionType: args.chartMetadata?.sessionType,
7520
+ adjusted: args.chartMetadata?.adjusted,
7223
7521
  },
7224
7522
  engineScript: wrunStandInTag(identity.package, identity.version),
7225
7523
  runResult: args.runResult,
@@ -7339,11 +7637,13 @@ function wrunEvaluatedMainTail(ohlcvRows) {
7339
7637
  * (re-bucketed) row geometry, exactly the control's own fallback. Lazy: the
7340
7638
  * metadata service drags the auth and cache graph, which only a profile
7341
7639
  * package needs here. */
7342
- async function resolveWrunVolumeProfileGrid(chartIndex) {
7640
+ async function resolveWrunVolumeProfileGrid(chartIndex,
7641
+ // The run market the profile lane is asked on (a Trades chart's tape): its lattice is that market's, not the chart's.
7642
+ runMarket) {
7343
7643
  try {
7344
7644
  const chartMetadata = await wrunChartMetadataFor(chartIndex);
7345
- const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
7346
- const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
7645
+ const exchange = runMarket?.exchange ?? (typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '');
7646
+ const symbol = runMarket?.symbol ?? (typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '');
7347
7647
  if (!exchange || !symbol)
7348
7648
  return undefined;
7349
7649
  const { default: metadataService } = await wrunChartHostEnv().market.loadMetadataService();
@@ -7630,7 +7930,10 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7630
7930
  intrabarRows: context.intrabarRows,
7631
7931
  formingPreRoll: context.formingPreRoll,
7632
7932
  // The session the run was computed under: the row builder's session calendar answers.
7633
- session: wrunChartSession(context.market?.exchange, context.market?.sessionType),
7933
+ session: wrunChartSession(context.market?.exchange, context.market?.sessionType, {
7934
+ symbol: context.market?.symbol,
7935
+ interval: clock.intervalMs,
7936
+ }),
7634
7937
  // The market the session was computed on (the eligibility gate above matched it to the chart).
7635
7938
  venue: wrunBarVenueOf(context.market, clock.intervalMs),
7636
7939
  formingBarTs,
@@ -7817,6 +8120,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
7817
8120
  // render below owes a repaint, not a console rewrite), under the session's own provenance.
7818
8121
  await publishWrunDebugOutput(context.chartIndex, indicatorId, context.metadata, outputRows, {
7819
8122
  opra: context.opraRead === true,
8123
+ ...(context.cmeRead === true ? { cme: true } : {}),
7820
8124
  });
7821
8125
  try {
7822
8126
  // The canvas fill (G1) for the session's market; a mirror entry that aged
@@ -8236,6 +8540,11 @@ function wrunUnservedLaneReason(type, exchange, coin, service) {
8236
8540
  return (`the ${type} source lane answers nothing on ${market} (a quote-priced perpetual market serves its quote ` +
8237
8541
  'candles, funding and open interest only)');
8238
8542
  }
8543
+ // The kind table's tape row (index-mode-admission.util): the stocks gate serves a tape's trades alone.
8544
+ if (isStocksTapeGoverned(exchange)) {
8545
+ return (`the ${type} source lane answers nothing on ${market} (a US stock tape serves its trades alone: candles, ` +
8546
+ 'buy/sell volume, the volume profile and the size flow, no order book, open interest, liquidations or funding)');
8547
+ }
8239
8548
  // The kind table's US equity row (index-mode-admission.util): a stock print has no aggressor side.
8240
8549
  if (getMarketKind(exchange) === 'tradfi') {
8241
8550
  return (`the ${type} source lane answers nothing on ${market} (a US equity market's prints carry no aggressor ` +
@@ -8399,7 +8708,7 @@ function wrunOptionsChainExtrasGoverned(extras) {
8399
8708
  * user script; a pinned crypto word still reads that venue's chain of the
8400
8709
  * coin). Without a decision the chart's own market reads exactly as before.
8401
8710
  */
8402
- async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts, paramValues, options) {
8711
+ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts, paramValues, options, cmeUserStudy = false) {
8403
8712
  const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues }, { WRUN_OPTION_VIEWS_ONE_ASK_CODE, WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE, wrunHeldOpraPlaneChain, wrunOptionsChainImplicitViewFields, wrunOptionViewLaneFields, wrunOptionViewsOfSource, wrunOptionViewsUnion, }, { wrunUnderlyingOptionsChainDecision },] = await Promise.all([
8404
8713
  import('./sources/opra-option-lanes.util.js'),
8405
8714
  wrunChartHostEnv().market.loadDeribitOptions(),
@@ -8455,6 +8764,14 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
8455
8764
  if (resolved === undefined)
8456
8765
  throw new Error(`WRUN ${metadata.id}: no options_chain input to resolve a chain for`);
8457
8766
  const { identity } = resolved;
8767
+ // The CME chain wall of every chain lane (`assertWrunLaneChainPlaneReadable`), here too: a CME chain is CME options
8768
+ // data, OpenMarket's own whatever the `cme-user-scripts` gate says. Before that gate no run but a first-party one
8769
+ // reached a CME chart's chain (the display wall refused every other at the head); the runs the gate brings there
8770
+ // (`cmeUserStudy`, a browser user run) read their chart's futures data, never CME options data (no implied
8771
+ // expansion), refused by name before any fetch with the wall's own words and record.
8772
+ if (identity.venue === 'cme' && cmeUserStudy) {
8773
+ assertWrunLaneChainPlaneReadable('cme', identity.exchange, { official, opraUserScripts }, { inputName: resolved.inputName, sourceClass: 'options_chain' });
8774
+ }
8458
8775
  const laneInputs = chainInputs.map((input) => ({
8459
8776
  expiries: wrunOptionsChainExpiries(metadata.inputSources[input.name]?.expiries),
8460
8777
  maxCells: input.max_cells,
@@ -9042,35 +9359,42 @@ function wrunCanvasFillWithSessionBlock(fill, metadata, indicatorId, market) {
9042
9359
  return held === undefined ? fill : { ...fill, tpoBlockSize: held };
9043
9360
  }
9044
9361
  /**
9045
- * A live session's CURRENT rows integrated again with a refined canvas fill
9046
- * (the served TPO block answered after the run): the reseed's integrate over
9047
- * the session's own outputs and buffers, no worker call, then the fill is
9048
- * the session's (its ticks build on the refined grid). Called under the
9049
- * overlay's session lock; it applies only while the session is the
9050
- * registered one, live, its run the newest (`current`) and the reseed's gates
9051
- * hold, the complete market identity among them: an interval or market
9052
- * switch while the load or the lock was pending leaves the old context
9053
- * registered until the replacement installs, and that context applies nothing.
9362
+ * A live session's CURRENT rows integrated again, no worker call: the reseed's
9363
+ * integrate over the session's own outputs and buffers, under its context's
9364
+ * sheet (`context.metadata`) and with the canvas fill `fill`, which is the
9365
+ * session's from then on (its ticks build on it). Two callers: the TPO block
9366
+ * refine (the served block answered after the run: a refined fill) and the
9367
+ * style-only save's repaint (repaintWrunSessionUnderSheet: a new sheet, the
9368
+ * fill the session was drawn with). Called under the overlay's session lock;
9369
+ * it applies only while the session is the registered one, live, `current()`
9370
+ * holds and the reseed's gates hold, the complete market identity among them:
9371
+ * an interval or market switch while the load or the lock was pending leaves
9372
+ * the old context registered until the replacement installs, and that context
9373
+ * applies nothing. A replay session's paint keeps to the replay's bars, as the
9374
+ * reseed's does. `keepOverlaySettings` (a gesture's preview) writes nothing to
9375
+ * the overlay's settings; `cellRowsOf` (a session a row source feeds) reads the
9376
+ * price canvases' cells from that source, never from buffers the context holds.
9377
+ * True once the integrate presented; false when it stood down.
9054
9378
  */
9055
- async function reintegrateWrunSessionCanvases(indicatorId, context, fill, current) {
9379
+ async function reintegrateWrunSession(indicatorId, context, fill, current, options = {}) {
9056
9380
  const registered = () => getWrunOverlayLiveContext(indicatorId) === context && !context.liveSuspended && current();
9057
9381
  if (!registered())
9058
- return;
9382
+ return false;
9059
9383
  const tc = wrunChartHostEnv().chart.instance(context.chartIndex);
9060
9384
  const meta = tc?.metadata?.find((candidate) => candidate.id === indicatorId);
9061
9385
  if (!tc || !meta)
9062
- return;
9386
+ return false;
9063
9387
  if (!(await wrunReseedEligible(context, meta, undefined)) || !registered())
9064
- return;
9388
+ return false;
9065
9389
  const chartRows = wrunChartCandleRows(tc);
9066
9390
  if (chartRows.length === 0)
9067
- return;
9391
+ return false;
9068
9392
  // A clamped session keeps the reseed's rule: its rows from its head, the
9069
9393
  // mounted rows outside its window kept by the integrate.
9070
9394
  const clamped = context.window?.partial ? context.window : undefined;
9071
9395
  const sessionRows = clamped ? chartRows.filter((row) => row[0] >= clamped.fromMs) : chartRows;
9072
9396
  if (sessionRows.length === 0)
9073
- return;
9397
+ return false;
9074
9398
  const runSession = wrunRunIntervalSessionOf(context);
9075
9399
  const ohlcvRows = runSession
9076
9400
  ? wrunRunIntervalComputeRows(runSession.run, runSession.rows, chartRows[chartRows.length - 1][0])
@@ -9082,7 +9406,7 @@ async function reintegrateWrunSessionCanvases(indicatorId, context, fill, curren
9082
9406
  volumeProfileRows: context.volumeProfileRows,
9083
9407
  intrabarRows: context.intrabarRows,
9084
9408
  };
9085
- // The refine redraws the session: the tick's applied result no longer describes the mount.
9409
+ // The integrate redraws the session: the tick's applied result no longer describes the mount.
9086
9410
  context.liveApplied = undefined;
9087
9411
  const runResult = integrateWrunOutputRows({
9088
9412
  tc,
@@ -9104,27 +9428,101 @@ async function reintegrateWrunSessionCanvases(indicatorId, context, fill, curren
9104
9428
  ? { projection: wrunRunIntervalProjectionOf(runSession.run, context.chartIndex, context.market?.exchange) }
9105
9429
  : {}),
9106
9430
  // A session holding a retained range (WRUN-MARKS-CONTRACT design 5) refines over the bars it calculated: the
9107
- // chart's older loaded candles and the rows its buffers hold before its first row stay out, as on its ticks.
9108
- cellRows: wrunCellRowsOf(context.metadata, context.retained !== undefined ? wrunRetainedCanvasSources(sessionSources, context.firstRowTs) : sessionSources, context.pinnedLegs ?? []),
9431
+ // chart's older loaded candles and the rows its buffers hold before its first row stay out, as on its ticks. A
9432
+ // session a row source feeds holds no buffers: its cells are the source's, as its full run's and its frames' are.
9433
+ cellRows: options.cellRowsOf !== undefined
9434
+ ? options.cellRowsOf(sessionRows)
9435
+ : wrunCellRowsOf(context.metadata, context.retained !== undefined
9436
+ ? wrunRetainedCanvasSources(sessionSources, context.firstRowTs)
9437
+ : sessionSources, context.pinnedLegs ?? []),
9109
9438
  intervalMs: context.intervalMs,
9110
9439
  ...(context.market?.exchange !== undefined ? { exchange: context.market.exchange } : {}),
9111
9440
  ...withPriceTick(wrunHostFillContextFor(tc, context.market?.exchange, context.intervalMs).tickSize),
9112
9441
  ...withCanvasHostFill(fill),
9113
9442
  ...(clamped ? { window: { fromMs: clamped.fromMs, toMs: context.lastRowTs, partial: true } } : {}),
9443
+ ...(options.keepOverlaySettings === true ? { keepOverlaySettings: true } : {}),
9114
9444
  });
9115
- if (runResult.childOverlays !== undefined && !(await awaitWrunChildOverlays(tc, indicatorId)))
9116
- return;
9445
+ if (context.replay)
9446
+ cutWrunReplayRowsAfterApply(tc, indicatorId);
9447
+ if (runResult.childOverlays !== undefined) {
9448
+ if (!(await awaitWrunChildOverlays(tc, indicatorId)))
9449
+ return false;
9450
+ if (context.replay)
9451
+ cutWrunReplayRowsAfterApply(tc, indicatorId);
9452
+ }
9117
9453
  if (getWrunOverlayLiveContext(indicatorId) !== context)
9118
- return;
9454
+ return false;
9119
9455
  rememberWrunSessionCanvasFill(context, fill);
9120
9456
  await publishWrunSessionCanvasNotices(context, runResult);
9121
9457
  if (getWrunOverlayLiveContext(indicatorId) !== context)
9122
- return;
9458
+ return false;
9123
9459
  presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run,
9124
9460
  // The session's rows again: a full run refused since keeps its snapshot.
9125
9461
  'republish', { emptyTargets: runResult.emptyTargets, partial: clamped !== undefined });
9126
9462
  context.paintedThroughTs = context.lastRowTs;
9127
9463
  context.repaintOwed = false;
9464
+ return true;
9465
+ }
9466
+ /**
9467
+ * A repaint of the mounted session under a new sheet: the style-only save's
9468
+ * door (wrun-style-patch.util) for the paint its in-place plot patch cannot
9469
+ * reach. A `skip` target's Visible row (the selection builds the target again
9470
+ * from the session's rows, whose frames the module writes whatever the sheet
9471
+ * hides, or leaves it out), the colour of a level, a renderer or a batched
9472
+ * section, a band, a fill, a box, a segment, and every look the adapter
9473
+ * derives from an output's colour. The caller swaps the new sheet into the
9474
+ * context first (`context.metadata`); this integrates the session's own rows
9475
+ * and buffers under it with the canvas fill the session was drawn with (no
9476
+ * worker call, no fetch: reintegrateWrunSession) and presents the result as
9477
+ * a republish, under the overlay's session lock. A full run in flight
9478
+ * replaces the session when it lands, so the repaint stands down and the
9479
+ * save's rerun joins that run. False (the save keeps its rerun): no live
9480
+ * session, the context replaced or suspended, a full run in flight, the
9481
+ * reseed's gates refuse the chart (replay, protection, the pane budget, the
9482
+ * pause, the market), no candle to land on, or a failed integrate (the
9483
+ * session then owes its repaint, as after a failed tick). `preview` (a
9484
+ * settings gesture's frame, under the previewed sheet) writes nothing to the
9485
+ * overlay's settings. A replay session stands down too: only its lane bounds
9486
+ * its candles at the replay's cutoff (the run and the tick paths), so the save
9487
+ * reruns there. A session whose row source holds its own session (a cloud
9488
+ * run) repaints with the cells that source keeps (`cellRowsOf`, as its full
9489
+ * run and its frames read them); a sheet drawing price canvases whose cells
9490
+ * neither such a source nor the context's lane buffers hold stands down.
9491
+ */
9492
+ export async function repaintWrunSessionUnderSheet(indicatorId, context, options = {}) {
9493
+ const standing = () => getWrunOverlayLiveContext(indicatorId) === context && !isWrunOverlayFullRerunInFlight(indicatorId);
9494
+ if (!standing() || context.replay === true)
9495
+ return false;
9496
+ return withWrunOverlaySessionLock(indicatorId, async () => {
9497
+ try {
9498
+ // The session's cells (its price canvases' rows), read through the row source interface: a source whose own
9499
+ // session feeds the context keeps them (a cloud run's grids, as its full run and its frames read them); else
9500
+ // the context's lane buffers hold them (a browser run, whose source holds no session of its own). A sheet
9501
+ // drawing price canvases with neither stands down: an empty canvas is never a repaint.
9502
+ const held = wrunHeldRowSources.get(indicatorId);
9503
+ const sessionSource = held !== undefined && held.source.holdsSession() ? held.source : undefined;
9504
+ if (sessionSource === undefined && wrunSheetDrawsCanvases(context.metadata) && !wrunHoldsCanvasCells(context)) {
9505
+ return false;
9506
+ }
9507
+ // The row builder reads the shared host (the run that installed this context loaded it).
9508
+ const hostLoading = ensureWrunChartHostSharedHost();
9509
+ if (hostLoading)
9510
+ await hostLoading;
9511
+ const fill = wrunSessionCanvasFillOf(context) ?? (await wrunCanvasHostFillFor(context.metadata, context.market));
9512
+ return await reintegrateWrunSession(indicatorId, context, fill, standing, {
9513
+ keepOverlaySettings: options.preview === true,
9514
+ ...(sessionSource !== undefined
9515
+ ? { cellRowsOf: (ohlcvRows) => sessionSource.cellRowsOf(ohlcvRows) }
9516
+ : {}),
9517
+ });
9518
+ }
9519
+ catch (error) {
9520
+ if (getWrunOverlayLiveContext(indicatorId) === context)
9521
+ context.repaintOwed = true;
9522
+ console.warn(`[wrun] style repaint failed for '${indicatorId}' (the save reruns):`, error);
9523
+ return false;
9524
+ }
9525
+ });
9128
9526
  }
9129
9527
  /** Drop an overlay's canvas run state (its refine latches, its run serial):
9130
9528
  * called from the live tick lane's teardown hook beside the canvas cache. */
@@ -9678,8 +10076,10 @@ function integrateWrunRunThroughRouteOnce(options, childMount) {
9678
10076
  // Read before any chart mutation: a strip word off the vocabulary refuses the run by name.
9679
10077
  const stripSettings = wrunStatsStripSettings(options.metadata);
9680
10078
  applyWrunIntegrationBudget(runResult, chartIndex, indicatorId);
9681
- syncWrunRunOverlayPalette(tc, indicatorId, meta, options.metadata);
9682
- syncWrunRunStripSettings(tc, indicatorId, meta, stripSettings);
10079
+ if (options.keepOverlaySettings !== true) {
10080
+ syncWrunRunOverlayPalette(tc, indicatorId, meta, options.metadata);
10081
+ syncWrunRunStripSettings(tc, indicatorId, meta, stripSettings);
10082
+ }
9683
10083
  const placed = placeWrunResultTables(tc, indicatorId, meta, runResult, { chartIndex, projection });
9684
10084
  const render = () => {
9685
10085
  tc.renderService?.renderOnce?.();
@@ -10067,8 +10467,14 @@ async function wrunWarmupHeadRequestOf(chart) {
10067
10467
  },
10068
10468
  tokenSessionTypes: lane.mainCandleTokenSessionTypes(context),
10069
10469
  projection: lane.mainCandleRowsProjection(facts),
10470
+ ...wrunWarmupHeadCandleSource(chart),
10070
10471
  };
10071
10472
  }
10473
+ /** The head's `candleSource`: the rows it joins came from there (a reader that threw names none, as the walls read). */
10474
+ function wrunWarmupHeadCandleSource(chart) {
10475
+ const candleSource = wrunMainCandleSourceOf(chart);
10476
+ return candleSource ? { candleSource } : {};
10477
+ }
10072
10478
  /** A head page's transport ids: never a `main<i>` id (no main load state, no main queue rule), one per page. */
10073
10479
  let wrunWarmupHeadPageSerial = 0;
10074
10480
  /**
@@ -10084,6 +10490,8 @@ async function fetchWrunWarmupHeadPage(chartIndex, request, fromTs, toTs, meter,
10084
10490
  const from = Math.floor(fromTs / 1000);
10085
10491
  const payload = {
10086
10492
  ...request.lane.buildMainCandleBasePayload({ ...request.identity, ovId }),
10493
+ // The chart's identity keeps the shape; the rows' own market rides the series ref alone (fetchMainData's rule).
10494
+ ...(request.candleSource ? { candleSource: request.candleSource } : {}),
10087
10495
  period: Math.max(1, Math.ceil(toTs / 1000) - from),
10088
10496
  from,
10089
10497
  ...(request.tokenSessionTypes !== undefined ? { tokenSessionTypes: request.tokenSessionTypes } : {}),
@@ -11790,7 +12198,10 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
11790
12198
  ...(bookRows !== undefined ? { bookRows } : {}),
11791
12199
  // Every other lane field the row builder reads, as the whole run's row build hands them (the window split).
11792
12200
  ...laneWindow.sourceRows,
11793
- session: wrunChartSession(chartExchange, chartMetadata?.sessionType),
12201
+ session: wrunChartSession(chartExchange, chartMetadata?.sessionType, {
12202
+ symbol: chartMetadata?.symbol,
12203
+ interval: clock.intervalMs,
12204
+ }),
11794
12205
  venue: wrunBarVenueOf(chartMetadata, clock.intervalMs),
11795
12206
  formingBarTs,
11796
12207
  };
@@ -12424,7 +12835,12 @@ async function runWrunPrefixOverlay(runTarget, tc, meta, window, refusal, owner,
12424
12835
  }
12425
12836
  else {
12426
12837
  prepared = ready;
12427
- outcome = await withWrunOverlaySessionLock(indicatorId, () => commitWrunPrefixRun(ready, tc, meta, owner, indicatorId));
12838
+ outcome = await withWrunOverlaySessionLock(indicatorId, () => {
12839
+ // A CME chart study's page lands only under the authorisation its head captured (a refusal here goes to the
12840
+ // full run, which judges the wall again).
12841
+ assertWrunCmeStudyAuthCurrent(computed, indicatorId);
12842
+ return commitWrunPrefixRun(ready, tc, meta, owner, indicatorId);
12843
+ });
12428
12844
  }
12429
12845
  }
12430
12846
  catch (error) {