@orangecharts/wrun-chart-host 0.6.0 → 0.7.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 (142) hide show
  1. package/README.md +14 -5
  2. package/dist/constants/marketCapabilities.constants.d.ts +5 -0
  3. package/dist/constants/marketCapabilities.constants.js +16 -0
  4. package/dist/host-ports.types.d.ts +35 -3
  5. package/dist/index.d.ts +11 -1
  6. package/dist/index.js +11 -1
  7. package/dist/indicators/controls/tpo-session.util.js +42 -18
  8. package/dist/market-data/billing.interface.d.ts +2 -1
  9. package/dist/settings-templates/index.d.ts +2 -0
  10. package/dist/settings-templates/index.js +19 -5
  11. package/dist/settings-templates/indicator-fields.d.ts +2 -0
  12. package/dist/settings-templates/indicator-fields.js +10 -0
  13. package/dist/settings-templates/tool-rules.d.ts +12 -2
  14. package/dist/settings-templates/tool-rules.js +9 -2
  15. package/dist/settings-templates/tool-tables.generated.js +9 -0
  16. package/dist/utility/chart/crypto-index.leaf.d.ts +16 -0
  17. package/dist/utility/chart/crypto-index.leaf.js +19 -0
  18. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  19. package/dist/utility/chart/index-mode.util.d.ts +11 -5
  20. package/dist/utility/chart/index-mode.util.js +22 -10
  21. package/dist/utility/chart/kscript-source-answer-budget.leaf.d.ts +36 -0
  22. package/dist/utility/chart/kscript-source-answer-budget.leaf.js +39 -0
  23. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +38 -1
  24. package/dist/utility/chart/kscript-source-degrade.leaf.js +39 -1
  25. package/dist/utility/chart/live-bucket.util.d.ts +2 -1
  26. package/dist/utility/chart/live-bucket.util.js +47 -15
  27. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +15 -1
  28. package/dist/utility/chart/local-kscript-warmup-depth.util.js +9 -0
  29. package/dist/utility/chart/market-session-schedule.util.d.ts +3 -1
  30. package/dist/utility/chart/market-session-schedule.util.js +24 -2
  31. package/dist/utility/chart/marketKind.util.d.ts +12 -7
  32. package/dist/utility/chart/marketKind.util.js +15 -5
  33. package/dist/utility/chart/ny-calendar.util.d.ts +104 -0
  34. package/dist/utility/chart/ny-calendar.util.js +346 -0
  35. package/dist/utility/chart/om-panel.util.d.ts +14 -2
  36. package/dist/utility/chart/om-panel.util.js +108 -40
  37. package/dist/utility/chart/rth-session.util.d.ts +10 -7
  38. package/dist/utility/chart/rth-session.util.js +17 -22
  39. package/dist/utility/chart/trading-day.util.js +90 -18
  40. package/dist/utility/chart/us-equities-session.util.js +20 -67
  41. package/dist/utility/chart/wrun-bar-session-facts.util.js +14 -1
  42. package/dist/utility/common/time.util.d.ts +7 -1
  43. package/dist/utility/common/time.util.js +11 -41
  44. package/dist/utility/number-format.util.d.ts +17 -7
  45. package/dist/utility/number-format.util.js +18 -8
  46. package/dist/utility/options/option-symbol.util.js +13 -2
  47. package/dist/utility/symbol-selection/contract-expiry.util.js +9 -1
  48. package/dist/utility/watchlist/import/import-request.leaf.d.ts +4 -1
  49. package/dist/utility/watchlist/import/import-request.leaf.js +5 -2
  50. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +25 -4
  51. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +62 -4
  52. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +19 -0
  53. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +57 -0
  54. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +23 -0
  55. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +90 -0
  56. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.d.ts +39 -0
  57. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.js +60 -0
  58. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +77 -0
  59. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +195 -0
  60. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +56 -0
  61. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +70 -0
  62. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +53 -0
  63. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +239 -0
  64. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +16 -0
  65. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +14 -0
  66. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +43 -18
  67. package/dist/utility/wrun/sources/lanes/options_flow.js +209 -72
  68. package/dist/utility/wrun/sources/lanes/token_supply.js +5 -31
  69. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -18
  70. package/dist/utility/wrun/sources/opra-option-lanes.util.js +12 -57
  71. package/dist/utility/wrun/sources/row-lane-registry.d.ts +1 -1
  72. package/dist/utility/wrun/sources/row-lane-registry.js +22 -8
  73. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +61 -0
  74. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +103 -8
  75. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +5 -0
  76. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +24 -12
  77. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +55 -0
  78. package/dist/utility/wrun/sources/row-lanes/option_prints.js +95 -18
  79. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +15 -1
  80. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +23 -8
  81. package/dist/utility/wrun/sources/row-lanes/option_surface.js +11 -11
  82. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +14 -2
  83. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +6 -3
  84. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +43 -8
  85. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +77 -11
  86. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -16
  87. package/dist/utility/wrun/sources/wrun-row-lane.types.js +2 -0
  88. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +52 -12
  89. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +110 -46
  90. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +10 -0
  91. package/dist/utility/wrun/wrun-browser-sources.leaf.js +12 -0
  92. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +3 -3
  93. package/dist/utility/wrun/wrun-coin-lane-live.util.js +53 -18
  94. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -0
  95. package/dist/utility/wrun/wrun-color-settings.util.js +45 -0
  96. package/dist/utility/wrun/wrun-draft-overlay.util.js +14 -8
  97. package/dist/utility/wrun/wrun-failure-cause.d.ts +1 -1
  98. package/dist/utility/wrun/wrun-failure-cause.js +14 -0
  99. package/dist/utility/wrun/wrun-frames.js +6 -2
  100. package/dist/utility/wrun/wrun-host.service.d.ts +26 -18
  101. package/dist/utility/wrun/wrun-host.service.js +49 -52
  102. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
  103. package/dist/utility/wrun/wrun-hosted-wire-caps.js +2 -0
  104. package/dist/utility/wrun/wrun-input-requirements.leaf.js +7 -4
  105. package/dist/utility/wrun/wrun-kit-run-tables.util.d.ts +24 -0
  106. package/dist/utility/wrun/wrun-kit-run-tables.util.js +87 -0
  107. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +2 -1
  108. package/dist/utility/wrun/wrun-live-tick.util.d.ts +8 -2
  109. package/dist/utility/wrun/wrun-live-tick.util.js +35 -16
  110. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +40 -13
  111. package/dist/utility/wrun/wrun-opra-flow.leaf.js +39 -12
  112. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +70 -21
  113. package/dist/utility/wrun/wrun-option-contract-flow.util.js +257 -112
  114. package/dist/utility/wrun/wrun-option-prints.util.d.ts +62 -22
  115. package/dist/utility/wrun/wrun-option-prints.util.js +148 -46
  116. package/dist/utility/wrun/wrun-option-views.util.d.ts +262 -0
  117. package/dist/utility/wrun/wrun-option-views.util.js +356 -0
  118. package/dist/utility/wrun/wrun-options-chain.util.d.ts +23 -2
  119. package/dist/utility/wrun/wrun-options-chain.util.js +37 -3
  120. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +18 -3
  121. package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -7
  122. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -3
  123. package/dist/utility/wrun/wrun-overlay-recovery.util.js +146 -18
  124. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +50 -6
  125. package/dist/utility/wrun/wrun-overlay-run.util.js +816 -243
  126. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +5 -0
  127. package/dist/utility/wrun/wrun-pin-spelling.util.js +28 -12
  128. package/dist/utility/wrun/wrun-pin-venues.util.js +4 -6
  129. package/dist/utility/wrun/wrun-present-bits.util.d.ts +9 -0
  130. package/dist/utility/wrun/wrun-present-bits.util.js +39 -0
  131. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +3 -2
  132. package/dist/utility/wrun/wrun-refusal-surface.util.js +5 -4
  133. package/dist/utility/wrun/wrun-refusal.util.d.ts +66 -6
  134. package/dist/utility/wrun/wrun-refusal.util.js +335 -40
  135. package/dist/utility/wrun/wrun-source-rows.util.js +11 -0
  136. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +28 -3
  137. package/dist/utility/wrun/wrun-tier-grid.util.js +79 -19
  138. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +14 -3
  139. package/dist/utility/wrun/wrun-transient-rerun.util.js +33 -8
  140. package/package.json +5 -5
  141. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +0 -12
  142. package/dist/utility/wrun/wrun-opra-underlying.util.js +0 -1
@@ -75,7 +75,7 @@ import { normalizeKScriptRunResultForTitanCharts } from '../chart/kscript-run-re
75
75
  import { KSCRIPT_LIVE_REFRESH_DELETE_IF_ABSENT_KEYS, KSCRIPT_LIVE_REFRESH_RENDER_META_KEYS, } from '../chart/kscript-titancharts-render-keys.constants.js';
76
76
  import { releaseOffchartForcedFillPane } from '../chart/kscript-titancharts-preparation.util.js';
77
77
  import { kscriptRunResultsRenderEqual } from '../chart/kscript-run-result-equality.util.js';
78
- import { resolveSecondarySourceBudgetMs } from '../chart/kscript-source-degrade.leaf.js';
78
+ import { resolveSecondarySourceBudgetMs, resolveSecondarySourceDeadlineMs } from '../chart/kscript-source-degrade.leaf.js';
79
79
  import { standInIdentityOf, wrunStandInTag, } from '../chart/kscript-standin-identity.leaf.js';
80
80
  import { isWrunOverlayHeldForRun, requestWrunOverlayRerun, withWrunOverlayExecutionMeasure, } from './wrun-overlay-lifecycle.util.js';
81
81
  import { armWrunSourceRecovery, requestWrunCasualtyRebuilds, retireWrunSourceRecovery, wrunOverlayHold, } from './wrun-overlay-recovery.util.js';
@@ -94,17 +94,22 @@ import { overlayExecutionGuardKey } from '../chart/overlay-execution-guard-key.l
94
94
  import { resolveLocalTechnicalScriptPrefixWindow, resolveLocalTechnicalScriptReplayRange, } from '../chart/local-technical-script-range.leaf.js';
95
95
  import { isWrunPrefixSafePackage, wrunPrefixCohort } from './wrun-prefix-cohort.util.js';
96
96
  import { prependWrunCandleEvidence, proveWrunCandleEvidence, proveWrunCandleEvidenceAgainstChart, proveWrunPrefixOverlap, proveWrunPrefixRunSnapshots, proveWrunPrefixSparseMount, wrunCandleFingerprintsOf, wrunLastFiniteOutput, wrunPrefixDerivedStyleOf, wrunPrefixMismatchLatches, wrunPrefixStyleBindingsOf, } from './wrun-prefix-proof.util.js';
97
- import { applyWrunPrefixLaneSplice, planWrunPrefixLanes, WRUN_PREFIX_ASK_LANES, wrunPrefixHeldLanes, wrunPrefixLaneClauseOf, wrunPrefixLaneSplice, wrunPrefixLiveRowRefused, wrunPrefixOverlapUnproven, wrunPrefixPageRows, wrunPrefixPollSuffix, wrunPrefixWindowLanes, } from './wrun-prefix-lanes.util.js';
97
+ import { WRUN_PREFIX_ASK_LANES, wrunPrefixOverlapUnproven, wrunPrefixPageRows, wrunPrefixPollSuffix, } from './wrun-prefix-lanes.util.js';
98
+ import { applyWrunPrefixFeedSplice, planWrunPrefixFeeds, wrunPrefixDailyHeldFirstTs, wrunPrefixFeedClauseOf, wrunPrefixFeedHeldLanes, wrunPrefixFeedsLiveRowRefused, wrunPrefixFeedSplice, wrunPrefixFeedWindowLanes, wrunPrefixRowSuffix, } from './run-schedule/wrun-prefix-feeds.util.js';
98
99
  import { isRecord, kScriptRunOutputFor } from '../chart/kscript-run-result-shape.util.js';
99
100
  import { wrunModuleReadsBarCount, wrunStampCorroborated, wrunStampSheetRefusal, wrunWarmupSheetReadsCandlesOnly, wrunWarmupSheetRefusal, wrunWarmupStampOf, } from './wrun-bar-count.util.js';
100
101
  import { recordKScriptPerfVolumeExtras } from '../chart/kscript-perf-tracker.util.js';
101
102
  import { applyWrunOutputVisibility, wrunRunNoticesOf, wrunOutputVisibleState, wrunRangePlotKey, wrunSeriesChildId, } from '../chart/wrun-run-result.util.js';
102
103
  import { attachWrunStrategy, isWrunStrategySheet, wrunStrategyOf } from './wrun-box-segment.util.js';
103
104
  import { withWrunDeadline, WRUN_SOURCE_FETCH_DEADLINE_MS } from './wrun-deadline.util.js';
105
+ import { noteWrunLateRead, takeWrunLateRead, wrunJoinLateReads } from './run-schedule/wrun-late-reads.util.js';
106
+ import { scheduleWrunLaneGroups } from './run-schedule/wrun-lane-groups.util.js';
107
+ import { serveWrunOwnCandles } from './run-schedule/wrun-own-candles.util.js';
108
+ import { wrunPollClassReadsChain, wrunRowClassReadsChain } from './run-schedule/wrun-gate-reader-warm.util.js';
104
109
  import { wrunPollLaneByKey, wrunPollLanesOfClass } from './sources/registry.js';
105
110
  import { wrunRowLaneByKey, wrunRowLaneOfClass } from './sources/row-lane-registry.js';
106
111
  import { isWrunRowLaneId } from './sources/wrun-row-lane.types.js';
107
- import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, } from './sources/wrun-row-lanes.util.js';
112
+ import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, wrunRunSourceReachFromMs, } from './sources/wrun-row-lanes.util.js';
108
113
  import { wrunOpraLanePayloadFields } from './wrun-opra-lane.util.js';
109
114
  import { wrunLaneRefusedCodeOf } from './wrun-lane-refusal.leaf.js';
110
115
  import { warmWrunEarningsFacts, wrunEarningsFactsFor, wrunReadsEarningsFacts, } from './wrun-earnings-facts.util.js';
@@ -137,7 +142,7 @@ import { wrunFollowsCoin, wrunInputGateOn, wrunRowVisibleHere } from './wrun-mar
137
142
  import { rememberWrunSessionChartNames, resolveWrunChartNames, wrunSessionChartNamesOf, } from './wrun-chart-context-names.util.js';
138
143
  import { assertWrunBrowserSources, getWrunBrowserHost, } from './wrun-host.service.js';
139
144
  import { applyWrunInertLegendState } from './wrun-inert-legend.util.js';
140
- import { annotateWrunErrorRefusal, attachWrunRefusal, serializeWrunRefusal, wrunLeftOutRefusalSeed, wrunOptionsStopSeed, wrunOverlayEditable, wrunRefusalFor, wrunRefusalOf, wrunRefusalSeedFor, wrunRefusalSeedOf, WRUN_REFUSAL_EVENT_MARKET_KEY, } from './wrun-refusal.util.js';
145
+ import { annotateWrunErrorRefusal, attachWrunRefusal, serializeWrunRefusal, stampWrunRefusalTelemetry, wrunAuthorRuleSeed, wrunLeftOutRefusalSeed, wrunOptionsStopSeed, wrunOverlayEditable, wrunRefusalFor, wrunRefusalOf, wrunRefusalSeedFor, wrunRefusalSeedOf, WRUN_REFUSAL_EVENT_MARKET_KEY, } from './wrun-refusal.util.js';
141
146
  import { claimWrunRefusalNotice, emitWrunRefusalChange, liveWrunRefusalAttempt, projectWrunRefusal, retractWrunRefusal, } from './wrun-refusal-surface.util.js';
142
147
  import { WRUN_ETF_COVERED_COINS, wrunInputReadsFillOverEmptyLane, wrunInputRequirements, wrunUnservedLanes, } from './wrun-input-requirements.leaf.js';
143
148
  import { getWrunOverlayMetadata, rememberWrunOverlayMetadata } from './wrun-overlay-metadata.util.js';
@@ -157,6 +162,7 @@ import { protectedKScriptMountedRowCount } from '../chart/protected-kscript-empt
157
162
  import { kScriptSettingsRevision } from '../chart/kscript-settings-revision.leaf.js';
158
163
  import { getChartMountEpoch } from '../chart/chart-mount-epoch.util.js';
159
164
  import { checkIsIndexMode } from '../chart/index-mode.util.js';
165
+ import { checkIsCryptoIndex } from '../chart/crypto-index.leaf.js';
160
166
  import { buildMixedModeContext, getFirstTokenMode } from '../chart/mixed-mode.util.js';
161
167
  import { inferPriceTickFromRows } from '../chart/footprint-band.util.js';
162
168
  import { getMarketKind } from '../chart/marketKind.util.js';
@@ -179,7 +185,7 @@ import { __resetWrunSocketSessionLossesForTests, noteWrunSocketSessionLoss, wrun
179
185
  import { isWrunRunMountOnChart, raiseWrunSandboxLoading, wrunRowBatchCellRows, } from './wrun-sandbox-row-source.js';
180
186
  import { advanceWrunInputCarry, buildWrunInitArgs, buildWrunInputRows, emptyWrunInputCarry, planWrunPinnedWires, wrunChartIntervalKeyOf, wrunDeclaredSourceLanes, wrunDemandedSourceClass, wrunFormingBucketStart, WrunWirePiecesIncomplete, wrunAskWirePieces, wrunPinnedLegFetchSuffix, wrunSourceLane, wrunPinnedLegTierMs, wrunSourceVerdictWhole, wrunTradeLegIntervals, wrunWireRowPieces, wrunChartCandleRows, wrunChartCandleRowsAfterHead, wrunChartRowsOffIntervalGrid, wrunChartCandleRowsWithin, } from './wrun-source-rows.util.js';
181
187
  import { ringWrunRunRetained, wrunChartWalkedRows, wrunRetainedCanvasSources, wrunRunBlockRowsCap, wrunRunRetainedHeadFits, wrunRunRetainedRowsCap, wrunRunRetainedWindowOf, } from './wrun-run-retained.util.js';
182
- import { isWrunOptionsChainCryptoVenueWord, wrunOptionsChainExpiries, wrunOptionsChainIdentityKey, wrunOptionsChainLaneExtras, wrunOptionsChainLaneScope, wrunOptionsChainOneVenueRefusal, } from './wrun-options-chain.util.js';
188
+ import { isWrunOptionsChainCryptoVenueWord, WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, WRUN_OPTIONS_CHAIN_VENUE_CODE, wrunOptionsChainExpiries, wrunOptionsChainIdentityKey, wrunOptionsChainLaneExtras, wrunOptionsChainLaneScope, wrunOptionsChainOneVenueRefusal, } from './wrun-options-chain.util.js';
183
189
  import { adoptWrunLiveIntakeGeneration, markWrunLiveGap, noteWrunLiveIntakeEvent, wrunPushEligible, } from './wrun-live-intake.util.js';
184
190
  import { openWrunPollLaneLiveChannels } from './wrun-series-stream.util.js';
185
191
  import { serverNowMs } from '../auth/server-clock.util.js';
@@ -353,7 +359,7 @@ export async function runWrunOverlayOnChart(target) {
353
359
  // for the executor's settle report (a run over a partial window is never reported: it computed its
354
360
  // rows only). `integrated`: the result reached the chart, so a later bookkeeping failure never
355
361
  // reports it as not applied.
356
- const computed = { generation: 0 };
362
+ const computed = { generation: 0, stage: 'head' };
357
363
  let integrated = false;
358
364
  // The run is still the overlay's own: the chart and the overlay it computed for stand, and the
359
365
  // attempt it resolved is still the live one (a teardown, a restore or a later request retires it).
@@ -486,6 +492,7 @@ export async function runWrunOverlayOnChart(target) {
486
492
  // signals (U15 routes the page through the source's `range`). The envelope never settles from
487
493
  // this edge: the lower runs before the adapter's verdict is known to the caller.
488
494
  if (prefixWindow !== undefined) {
495
+ computed.stage = 'prefix';
489
496
  const hold = await raiseWrunSandboxLoading(target.chartIndex, target.indicatorId, { tc, meta });
490
497
  try {
491
498
  await runWrunPrefixOverlay(marketTarget, tc, meta, prefixWindow, refusal, {
@@ -502,6 +509,7 @@ export async function runWrunOverlayOnChart(target) {
502
509
  await computeWrunOverlayOverLiveContext(marketTarget, (runTarget) => computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, computed, { chartIndex: target.chartIndex, mountEpoch, tc }, { chartMetadata, isCurrent, official, opraUserScripts }));
503
510
  }
504
511
  integrated = true;
512
+ computed.stage = 'applied';
505
513
  noteWrunOverlayRunSettle(target.indicatorId, { generation: computed.generation, outcome: 'applied' });
506
514
  // A prefix run computed older bars only (or handed its page to a full run): the session's
507
515
  // verdicts stand, the next full run settles them.
@@ -554,6 +562,10 @@ export async function runWrunOverlayOnChart(target) {
554
562
  annotateWrunErrorRefusal(error, wrunRunFailureRefusal(error, refusal.ctx, { outputNames }));
555
563
  }
556
564
  }
565
+ // A failed run rings once with its stage and its words (a superseded run and a hold ring nothing here).
566
+ if (wrunRunSettleOf(error).outcome === 'failed') {
567
+ ringWrunRunFailed(target, computed.stage ?? 'head', error, integrated);
568
+ }
557
569
  // A run another screen's session stopped (its hold, or a chain its plan stopped before any read): the take-back
558
570
  // runs it again, and the live session it keeps drains nothing until then (holdWrunOverlayOnSessionStop).
559
571
  if (!(error instanceof WrunChartGoneError))
@@ -655,6 +667,29 @@ function wrunRunRejectionAsSettled(error, run) {
655
667
  dropped.cause = WRUN_SUPERSEDED_RUN_CAUSE;
656
668
  return dropped;
657
669
  }
670
+ /**
671
+ * The run's failure in the debug ring (`wrun-run-failed`, retained past the ring's cap as an anomaly): the overlay, the
672
+ * run's reason, the stage it failed in and the error as it reads (its class, its message: a frame the host refused
673
+ * names the row and why there, wrun-frames.ts; its refusal class when the run pass annotated one). Every rejection the
674
+ * run settles as failed rings it once, whoever started the run (the add's first run after its pane mounted, a
675
+ * recompute the drivers asked for, a rung); a superseded run (dropped) and a hold (a pause, the venue wall, a source
676
+ * hold) are no failure and ring nothing here.
677
+ */
678
+ function ringWrunRunFailed(target, stage, error, integrated) {
679
+ if (!wrunChartHostEnv().diagnostics.debugEnabled())
680
+ return;
681
+ const refusal = wrunRefusalOf(error);
682
+ wrunChartHostEnv().diagnostics.debug('wrun-run-failed', {
683
+ chartIndex: target.chartIndex,
684
+ indicatorId: target.indicatorId,
685
+ reason: target.reason ?? 'loaded-range-refresh',
686
+ stage,
687
+ error: error instanceof Error ? error.name : typeof error,
688
+ message: error instanceof Error ? error.message : String(error),
689
+ ...(refusal !== undefined ? { refusal: refusal.cls } : {}),
690
+ integrated,
691
+ });
692
+ }
658
693
  /** How a failed run left the overlay's requested settings (C1's outcomes): superseded (a newer
659
694
  * compute save, another chart, overlay or replay; the run that follows computes for the current
660
695
  * ones) is dropped; a pause or a trip, the venue wall and a source hold are held, each with its own
@@ -861,13 +896,45 @@ const WRUN_CRYPTO_VENUE_KINDS = new Set(['crypto', 'dex', 'hip3', 'hip4']);
861
896
  * chain lane of either kind (its chain lists on OPRA on a US stock or OPRA contract chart). The run head's flag wait,
862
897
  * the OPRA-plane predicate a lane's admission and wall read, and the OPRA provenance writer follow it. */
863
898
  function wrunSheetReadsOpraLane(metadata) {
864
- return metadata.inputs.some((input) => {
865
- const sourceClass = metadata.inputSources[input.name]?.source;
866
- const rowLane = wrunRowLaneOfClass(sourceClass);
867
- return (rowLane?.governed === 'opra' ||
868
- rowLane?.chain !== undefined ||
869
- wrunPollLanesOfClass(sourceClass).some((lane) => lane.opra === true || lane.chain !== undefined));
870
- });
899
+ return wrunPollPlanReadsChain(metadata) || wrunRowPlanReadsChain(metadata);
900
+ }
901
+ // The class rules (`wrunPollClassReadsChain`, `wrunRowClassReadsChain`) live beside the door's gate reader warm
902
+ // (run-schedule/wrun-gate-reader-warm.util), which dials the plane these lanes read before the run plans them.
903
+ function wrunPollPlanReadsChain(metadata) {
904
+ return metadata.inputs.some((input) => wrunPollClassReadsChain(metadata.inputSources[input.name]?.source));
905
+ }
906
+ function wrunRowPlanReadsChain(metadata) {
907
+ return metadata.inputs.some((input) => wrunRowClassReadsChain(metadata.inputSources[input.name]?.source));
908
+ }
909
+ /**
910
+ * The sheet one planner pass plans a GROUP of its lanes over: the inputs of the planner's classes (`ofPlanner`) that
911
+ * the group holds (`inGroup`) stay demanded, the planner's other inputs read as undemanded (a planner skips those), and
912
+ * every input of another planner is left as it is. Null when the group holds no demanded input: no pass is run. The
913
+ * run plans the lanes that read the chart's options chain apart from those that do not, so a lane whose plan reads
914
+ * nothing on the network never waits inside one pass on another lane's chain read.
915
+ */
916
+ function wrunSheetForLaneGroup(metadata, ofPlanner, inGroup) {
917
+ let demanded = false;
918
+ const inputSources = { ...metadata.inputSources };
919
+ for (const input of metadata.inputs) {
920
+ const entry = metadata.inputSources[input.name];
921
+ if (entry === undefined || entry.undemanded === true || !ofPlanner(entry.source))
922
+ continue;
923
+ if (inGroup(entry.source))
924
+ demanded = true;
925
+ else
926
+ inputSources[input.name] = { ...entry, undemanded: true };
927
+ }
928
+ return demanded ? { ...metadata, inputSources } : null;
929
+ }
930
+ /** A planner's two passes (`wrunSheetForLaneGroup`) as one plan: the instances in declaration order (each by the first
931
+ * input it serves, the order one pass inserts them in), the feed notes of both. */
932
+ function mergeWrunLanePlans(a, b) {
933
+ const firstInput = (instance) => Math.min(...instance.inputIndexes);
934
+ return {
935
+ lanes: [...a.lanes, ...b.lanes].sort((left, right) => firstInput(left) - firstInput(right)),
936
+ missingFeeds: [...a.missingFeeds, ...b.missingFeeds],
937
+ };
871
938
  }
872
939
  /** The OPRA-plane predicate an OPRA lane's admission reads (`governedOptionPlane(metadata) === 'opra'`: a US stock or
873
940
  * ETF chart under either venue spelling while the `opra` flag is lit, an OPRA contract chart) and, beside it, the
@@ -993,9 +1060,11 @@ async function wrunOverlayRefusalContextOf(chartIndex, indicatorId) {
993
1060
  });
994
1061
  }
995
1062
  /** The completed record of a seed with the raiser's technical words as its details (the attached
996
- * seed wins in `wrunRefusalFor`), the idiom the health builders use. */
997
- function wrunSeededRefusal(seed, details, ctx) {
998
- return wrunRefusalFor(attachWrunRefusal(new Error(details), seed), ctx);
1063
+ * seed wins in `wrunRefusalFor`), the idiom the health builders use; `stamp` is what the raiser
1064
+ * knows of the failure (its cause rides the record's `telemetry.cause`). */
1065
+ function wrunSeededRefusal(seed, details, ctx, stamp) {
1066
+ const raised = attachWrunRefusal(new Error(details), seed);
1067
+ return wrunRefusalFor(stamp === undefined ? raised : stampWrunRefusalTelemetry(raised, stamp), ctx);
999
1068
  }
1000
1069
  /** The note rows a run owns (its legs, its health, its skipped draw calls, its respelled pins): a failed run drops
1001
1070
  * them with its verdict. */
@@ -1117,7 +1186,7 @@ export function wrunOptionsChainRefusalSeed(refusal) {
1117
1186
  severity: 'paused',
1118
1187
  ...(refusal.plane !== undefined ? { plane: refusal.plane } : {}),
1119
1188
  })
1120
- : { cls: 'run-failed', variant: 'generic' };
1189
+ : wrunAuthorRuleSeed(WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE);
1121
1190
  case 'flag-off':
1122
1191
  return { cls: 'no-options', variant: 'flag-off', params: { ...venue, ...coin } };
1123
1192
  case 'venue-not-listed':
@@ -1135,7 +1204,7 @@ export function wrunOptionsChainRefusalSeed(refusal) {
1135
1204
  case 'opra-directory':
1136
1205
  return { cls: 'service-no-answer', variant: 'opra-directory' };
1137
1206
  default:
1138
- return { cls: 'run-failed', variant: 'generic' };
1207
+ return wrunAuthorRuleSeed(refusal.reason === 'one-venue' ? WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE : WRUN_OPTIONS_CHAIN_VENUE_CODE);
1139
1208
  }
1140
1209
  }
1141
1210
  /** A refused options-chain decision as the error the run fails with: its technical words, its
@@ -1262,16 +1331,33 @@ function setWrunTerminalDegradeWatch(guardKey, target, lanes) {
1262
1331
  }
1263
1332
  return watch;
1264
1333
  }
1334
+ /** What a lane the source ladder gave up on says it was (the terminal record's code and cause): its
1335
+ * budget ran out, its read failed, or its source declined the chart's market (an empty or declined
1336
+ * answer, or a refusal by name its lane words no record for). */
1337
+ const WRUN_SOURCE_GIVEN_UP = {
1338
+ budget: { code: 'wrun_source_budget', cause: 'source-budget' },
1339
+ failed: { code: 'wrun_source_failed', cause: 'source-failed' },
1340
+ declined: { code: 'wrun_source_declined', cause: 'source-declined' },
1341
+ };
1342
+ /** The verdict of a degraded lane the ladder gave up on, by its outcome. */
1343
+ function wrunSourceGivenUpOf(outcome) {
1344
+ if (outcome.cause === 'empty' || outcome.cause === 'declined' || wrunLaneRefusedCodeOf(outcome.error) !== undefined) {
1345
+ return WRUN_SOURCE_GIVEN_UP.declined;
1346
+ }
1347
+ return outcome.cause === 'budget' ? WRUN_SOURCE_GIVEN_UP.budget : WRUN_SOURCE_GIVEN_UP.failed;
1348
+ }
1265
1349
  /**
1266
- * The record a degraded lane shows once the source ladder gives up on it: `service-no-answer`,
1267
- * `global` for a lane naming its own subject (economic, token supply, an asset's treasury), else
1268
- * `lane` with the chart's market; a note when the run drew around the lane, paused when it held on
1269
- * it; its details today's words for the lane (the hold's sentence).
1350
+ * The record a degraded lane shows once the source ladder gives up on it: the code of what it was
1351
+ * (`wrunSourceGivenUpOf`: `wrun_source_budget`, `wrun_source_failed`, `wrun_source_declined`) in the
1352
+ * author-rule seed, which the record words as its `service-no-answer` variant, with the feed it names
1353
+ * and the matching cause stamped (`telemetry.cause`: `source-budget`, `source-failed`,
1354
+ * `source-declined`), so the record and `wrun_failure_shown` tell a slow source from a broken or an
1355
+ * absent one; a note when the run drew around the lane, paused when it held on it; its details
1356
+ * today's words for the lane (the hold's sentence).
1270
1357
  */
1271
1358
  function wrunTerminalDegradeRefusalFor(args) {
1272
1359
  const instance = args.pollLanes.find((candidate) => candidate.key === args.lane);
1273
1360
  const pollLane = instance === undefined ? undefined : wrunPollLaneByKey(instance.laneKey);
1274
- const global = pollLane?.global === true;
1275
1361
  // A trades leg lane is its quote's buy/sell feed.
1276
1362
  const feed = instance?.laneKey ?? wrunTradesLegOf(args.lane)?.lane ?? args.lane;
1277
1363
  const severity = args.held ? 'paused' : 'note';
@@ -1287,9 +1373,9 @@ function wrunTerminalDegradeRefusalFor(args) {
1287
1373
  if (declared !== undefined) {
1288
1374
  return wrunSeededRefusal({ ...declared, params: { feed, ...declared.params }, severity }, wrunLaneDegradeMessage(args.title, wrunLaneSourceOf(args.lane, args.pollLanes), args.outcome), args.ctx);
1289
1375
  }
1290
- return wrunSeededRefusal(global
1291
- ? { cls: 'service-no-answer', variant: 'global', params: { feed }, severity }
1292
- : { cls: 'service-no-answer', variant: 'lane', params: { feed }, severity }, wrunLaneDegradeMessage(args.title, wrunLaneSourceOf(args.lane, args.pollLanes), args.outcome), args.ctx);
1376
+ const givenUp = wrunSourceGivenUpOf(args.outcome);
1377
+ const seed = wrunAuthorRuleSeed(givenUp.code);
1378
+ return wrunSeededRefusal({ ...seed, params: { ...seed.params, feed }, severity }, wrunLaneDegradeMessage(args.title, wrunLaneSourceOf(args.lane, args.pollLanes), args.outcome), args.ctx, { cause: givenUp.cause });
1293
1379
  }
1294
1380
  /**
1295
1381
  * A successful run's refusals: every owner's verdict retracted (while the chart instance the run
@@ -1648,7 +1734,21 @@ export function wrunSessionRespelledSheet(context, sheet, settings) {
1648
1734
  * request, the pass's word before the session opens, the facts the render charge prints with, the
1649
1735
  * canvases' cells) beside the session's own facts the pass integrates and installs with.
1650
1736
  */
1737
+ const wrunMountSerials = new WeakMap();
1738
+ let wrunMountSerial = 0;
1739
+ /** One number per mounted overlay record (the chart's meta object): the late-read identity's mount, so a remount, or
1740
+ * another overlay mounted under the same id, never joins a read the record before it left out. */
1741
+ function wrunMountSerialOf(meta) {
1742
+ let serial = wrunMountSerials.get(meta);
1743
+ if (serial === undefined) {
1744
+ wrunMountSerial += 1;
1745
+ serial = wrunMountSerial;
1746
+ wrunMountSerials.set(meta, serial);
1747
+ }
1748
+ return serial;
1749
+ }
1651
1750
  async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, owner, head, rowWindow, _record) {
1751
+ computed.stage = 'lanes';
1652
1752
  const module = passTarget.module;
1653
1753
  if (module === null) {
1654
1754
  throw new Error(`wrun overlay '${passTarget.indicatorId}': its row source holds no module for the browser lanes`);
@@ -1688,12 +1788,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
1688
1788
  // one, a paint-only save none (it reruns nothing).
1689
1789
  const generationAtStart = kScriptSettingsRevision(view.settings);
1690
1790
  computed.generation = generationAtStart;
1691
- // Every declared source class is checked against the kit's daemon-only Set
1692
- // (WRUN_DAEMON_ONLY_SOURCES) before any lane fetch or worker call: a source
1693
- // the tab cannot serve refuses here by name (`Input '<name>' (<source>):
1694
- // computed on your daemon, not in the tab`), never after a lane round trip
1695
- // or inside the row builder. Chart-served classes settle synchronously.
1696
- await assertWrunBrowserSources(target.metadata);
1791
+ // Every declared source class is checked against the kit's daemon-only table
1792
+ // (its import-free copy, wrun-kit-run-tables.util) before any lane fetch
1793
+ // or worker call: a source the tab cannot serve refuses here by name
1794
+ // (`Input '<name>' (<source>): computed on your daemon, not in the tab`),
1795
+ // never after a lane round trip or inside the row builder. Synchronous: no
1796
+ // kit loads on this thread for it.
1797
+ assertWrunBrowserSources(target.metadata);
1697
1798
  // The shared host the leg planner, the row builder and the packer read, loaded once before
1698
1799
  // their first synchronous use (host.js stays out of the boot graph).
1699
1800
  const hostLoading = ensureWrunChartHostSharedHost();
@@ -2061,40 +2162,102 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2061
2162
  // the planner sits on the row builder's import graph. An input of a lane the chart never serves
2062
2163
  // that declared a missing fill is dropped and named in `missingFeeds` (its feed-missing note).
2063
2164
  const pickText = (value) => (typeof value === 'string' ? value : '');
2165
+ // The lane plans that may wait on the network (a lane reading the chart's options chain resolves it: an OPRA lane its
2166
+ // underlying, a chain lane the chain, the options chain lane its identity and its expiry directory) START here and
2167
+ // run side by side; none is awaited before the lanes whose inputs are known now dispatch (run scheduling,
2168
+ // 2026-10-20: the first source request left a median 2.2 s after the add, a leg or a poll lane waiting out another
2169
+ // lane's chain read). Each planner is run once per group of its lanes, the lanes that read the chain apart from
2170
+ // those that do not (`wrunSheetForLaneGroup`), so a lane never waits on another lane's plan inside one planner pass.
2171
+ // Each group dispatches the moment its own plan resolves (`scheduleWrunLaneGroups` below); a plan's refusal still
2172
+ // fails the run by name, judged in the order the plans were read (the local plans, then the chain-reading poll
2173
+ // lanes, row lanes and the options chain), and retracts what the run already dispatched.
2064
2174
  // The run's OPRA facts reach every lane's plan (`ctx.official`, `ctx.opraUserScripts`): an OPRA lane is refused
2065
2175
  // by name before its plan for a run that may not read the plane (`mayReadOpra`, opra-official-only:<class>).
2066
2176
  // The OPRA-plane predicate an OPRA lane is admitted by (loaded only when the sheet reads one).
2067
- const opraPlane = await wrunOpraPlaneFacts(target.metadata);
2068
- const isOpraPlaneExchange = opraPlane?.isOpraPlaneExchange;
2177
+ const opraPlaneFacts = wrunOpraPlaneFacts(target.metadata);
2069
2178
  const opraFacts = { official: head.official, opraUserScripts: head.opraUserScripts };
2070
2179
  // The chart's category rides along: a chain poll lane resolves the chart's chain with it, as the row lanes do.
2071
- const { lanes: pollLanes, missingFeeds: pollMissingFeeds } = await planWrunPollLanes(target.metadata, {
2072
- coin: pickText(chartMetadata?.coin),
2073
- exchange: pickText(chartMetadata?.exchange),
2074
- symbol: pickText(chartMetadata?.symbol),
2075
- category: chartMetadata?.category,
2076
- intervalMs: clock.intervalMs,
2077
- }, checkIsIndexMode, isWrunCryptoVenueExchange, { ...opraFacts, ...(opraPlane !== undefined ? opraPlane : {}) });
2078
- // The row lanes' plan (sources/row-lane-registry.ts: one celled descriptor per class), before any fetch,
2180
+ const planPollLanes = (readsChain) => {
2181
+ const sheet = wrunSheetForLaneGroup(target.metadata, (sourceClass) => wrunPollLanesOfClass(sourceClass).length > 0, (sourceClass) => wrunPollClassReadsChain(sourceClass) === readsChain);
2182
+ if (sheet === null)
2183
+ return Promise.resolve({ lanes: [], missingFeeds: [] });
2184
+ return opraPlaneFacts.then((opraPlane) => planWrunPollLanes(sheet, {
2185
+ coin: pickText(chartMetadata?.coin),
2186
+ exchange: pickText(chartMetadata?.exchange),
2187
+ symbol: pickText(chartMetadata?.symbol),
2188
+ category: chartMetadata?.category,
2189
+ intervalMs: clock.intervalMs,
2190
+ }, checkIsIndexMode, isWrunCryptoVenueExchange, { ...opraFacts, ...(opraPlane !== undefined ? opraPlane : {}) }));
2191
+ };
2192
+ // The row lanes' plan (sources/row-lane-registry.ts: one celled descriptor per class), before any of its fetches,
2079
2193
  // beside the poll lanes': the OPRA wall, the chart's admission (a governed OPRA lane where the chart's
2080
2194
  // options ride the plane, either spelling of a stock venue or an OPRA contract chart; any other lane off
2081
2195
  // index-mode charts), the lane's identity and each input's facets, grouped into instances; an input of a
2082
2196
  // lane the chart never serves that declared `missing: "empty"` is dropped and named in `missingFeeds`.
2083
2197
  // The chart's category rides along: a chain lane resolves the chart's chain with it, as the options chain lane does.
2084
2198
  const chartCategory = chartMetadata?.category;
2085
- const { lanes: rowLanes, missingFeeds: rowMissingFeeds } = await planWrunRowLanes(target.metadata, {
2086
- coin: pickText(chartMetadata?.coin),
2087
- exchange: pickText(chartMetadata?.exchange),
2088
- symbol: pickText(chartMetadata?.symbol),
2089
- ...(typeof chartCategory === 'number' ? { category: chartCategory } : {}),
2090
- intervalMs: clock.intervalMs,
2091
- isIndexModeExchange: checkIsIndexMode,
2092
- isCryptoVenueExchange: isWrunCryptoVenueExchange,
2093
- isOpraPlaneExchange,
2094
- opraPlaneStop: opraPlane?.opraPlaneStop,
2095
- }, opraFacts);
2199
+ const planRowLanes = (readsChain) => {
2200
+ const sheet = wrunSheetForLaneGroup(target.metadata, (sourceClass) => wrunRowLaneOfClass(sourceClass) !== undefined, (sourceClass) => wrunRowClassReadsChain(sourceClass) === readsChain);
2201
+ if (sheet === null)
2202
+ return Promise.resolve({ lanes: [], missingFeeds: [] });
2203
+ return opraPlaneFacts.then((opraPlane) => planWrunRowLanes(sheet, {
2204
+ coin: pickText(chartMetadata?.coin),
2205
+ exchange: pickText(chartMetadata?.exchange),
2206
+ symbol: pickText(chartMetadata?.symbol),
2207
+ ...(typeof chartCategory === 'number' ? { category: chartCategory } : {}),
2208
+ intervalMs: clock.intervalMs,
2209
+ isIndexModeExchange: checkIsIndexMode,
2210
+ isCryptoVenueExchange: isWrunCryptoVenueExchange,
2211
+ isOpraPlaneExchange: opraPlane?.isOpraPlaneExchange,
2212
+ opraPlaneStop: opraPlane?.opraPlaneStop,
2213
+ }, opraFacts));
2214
+ };
2215
+ const pollPlannedLocal = planPollLanes(false);
2216
+ const rowPlannedLocal = planRowLanes(false);
2217
+ const pollPlannedChain = planPollLanes(true);
2218
+ const rowPlannedChain = planRowLanes(true);
2219
+ // The classes the inputs demand a lane for: an input this market does not need (its `needed_by`
2220
+ // leaves the market out, wrunSheetWithLaneDemand) asks none, so its lane is never dispatched and
2221
+ // its rows stay absent.
2222
+ const declaredClasses = new Set(target.metadata.inputs.map((input) => wrunDemandedSourceClass(target.metadata.inputSources[input.name])));
2223
+ // The options_chain lane's identity (wrunOptionsChainLaneExtrasFor), decided before its own fetch like every plan:
2224
+ // a refusal by name fails the run, never reads as a degraded lane.
2225
+ const optionsChainPlanned = declaredClasses.has('options_chain')
2226
+ ? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts)
2227
+ : Promise.resolve(undefined);
2228
+ // The OPRA provenance the native options overlays carry (`settings.metaExchange`, the field the chart read
2229
+ // withholds an overlay by and the tier moves refetch it by, options-overlay-provenance.util): every OPRA lane
2230
+ // stamps both copies of the overlay's settings before its group's first fetch, so nothing it draws is ever
2231
+ // readable unstamped; a result read off another source sheds it once it replaced the rows (integrateWrunRunAsk).
2232
+ // A refused decision changes nothing: what the overlay drew keeps its provenance. The writer writes only while the
2233
+ // run still owns its overlay (`wrunOpraProvenanceWriter`): a run whose chain resolved after a workspace or market
2234
+ // switch stands down, the replacement overlay unstamped. The writer exists whenever the sheet declares an OPRA lane
2235
+ // or a chain (a switch off the stock chart sheds the stamp).
2236
+ const opraProvenanceWriter = declaredClasses.has('options_chain') || wrunSheetReadsOpraLane(target.metadata)
2237
+ ? wrunOpraProvenanceWriter(target.chartIndex, target.indicatorId, { owner, tc, meta, marketIdentity })
2238
+ : Promise.resolve(undefined);
2239
+ // The lanes known now wait for the plans that settle without the network (the poll and row lanes that read no options
2240
+ // chain, read in that order), so a refusal by name there still leaves zero fetches; a plan that reads the chain waits
2241
+ // on its summary read (seconds on the wire) and holds no lane but its own group's. Every early dispatch below (the
2242
+ // legs, the run bars, the forming pre-roll, the row builder's own lanes, those local poll and row lanes) waits on it.
2243
+ const localPlanned = pollPlannedLocal.then((poll) => rowPlannedLocal.then((row) => ({ poll, row })));
2244
+ const lanesKnown = localPlanned.then(() => undefined);
2245
+ // Read later (in their own group's order, or at the settle): never an unhandled rejection meanwhile.
2246
+ for (const pending of [
2247
+ pollPlannedLocal,
2248
+ rowPlannedLocal,
2249
+ pollPlannedChain,
2250
+ rowPlannedChain,
2251
+ optionsChainPlanned,
2252
+ opraProvenanceWriter,
2253
+ localPlanned,
2254
+ lanesKnown,
2255
+ ]) {
2256
+ void pending.catch(() => undefined);
2257
+ }
2096
2258
  // Every source-lane instance a degrade names (a poll lane's or a row lane's): the chips, the holds, the records.
2097
- const laneInstances = [...pollLanes, ...rowLanes];
2259
+ // Filled as the plans resolve, in the plans' order once both did.
2260
+ const laneInstances = [];
2098
2261
  // The pinned legs by venue (wrun-pin-venues.util), before any fetch: a pin
2099
2262
  // on a CME Group venue refuses by name with the sheet contract's own words
2100
2263
  // (the chart's own market may still be one, the display wall decides that
@@ -2213,52 +2376,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2213
2376
  // A replay run's lanes reach the window's end (the replay's forward runway, as the kScript
2214
2377
  // engine's sources do), so its steps read them without a fetch; its bars stop at the cutoff.
2215
2378
  const to = replay ? Math.max(chartLastTs, replay.toMs) : chartLastTs;
2216
- // The classes the inputs demand a lane for: an input this market does not need (its `needed_by`
2217
- // leaves the market out, wrunSheetWithLaneDemand) asks none, so its lane is never dispatched and
2218
- // its rows stay absent.
2219
- const declaredClasses = new Set(target.metadata.inputs.map((input) => wrunDemandedSourceClass(target.metadata.inputSources[input.name])));
2220
- // The lanes those classes read: a trades input asking `currency: "USD"` reads the buy/sell
2379
+ // The lanes the demanded classes read: a trades input asking `currency: "USD"` reads the buy/sell
2221
2380
  // lane asked in dollars (`trades_usd`), any other the coin lane (`trades`), so a sheet with a
2222
2381
  // units setting fetches each unit it declares, once.
2223
2382
  const declaredLanes = wrunDeclaredSourceLanes(target.metadata);
2224
- // The options_chain lane's identity (wrunOptionsChainLaneExtrasFor), decided
2225
- // before any fetch like every plan above: a refusal by name fails the run,
2226
- // never reads as a degraded lane.
2227
- const optionsChainExtras = declaredClasses.has('options_chain')
2228
- ? await wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts)
2229
- : undefined;
2230
- // A governed chain (CME, OPRA) rides its own plane's reader on the fetch's native-rows path, never the
2231
- // chart market's fetch shape: the admission below serves it on an index-mode stock or ETF chart.
2232
- const governedChain = wrunOptionsChainExtrasGoverned(optionsChainExtras);
2233
- // The OPRA provenance the native options overlays carry (`settings.metaExchange`, the field the chart read
2234
- // withholds an overlay by and the tier moves refetch it by, options-overlay-provenance.util): a chain read on
2235
- // the OPRA plane stamps both copies of the overlay's settings now, before the lane's first fetch, so nothing it
2236
- // draws is ever readable unstamped; a result read off another source sheds it once it replaced the rows
2237
- // (integrateWrunRunAsk). A refused decision changes nothing: what the overlay drew keeps its provenance. The
2238
- // writer writes only while the run still owns its overlay (`wrunOpraProvenanceWriter`): a run whose chain
2239
- // resolved after a workspace or market switch stands down here, the replacement overlay unstamped.
2240
- const readsOpraChain = optionsChainExtras?.chainVenue === 'opra';
2241
- // Any other OPRA source lane the plans kept (a poll lane's `opra`, a row lane's `governed: 'opra'`, a chain lane's
2242
- // instance of either kind whose chain lists on OPRA) reads the plane too: the same stamp before its first fetch, the
2243
- // same shedding once a result read off another source replaced the rows. A chain read off a CME or crypto chain
2244
- // stamps nothing. The writer exists whenever the sheet declares one (a switch off the stock chart sheds the stamp).
2245
- const readsOpraPlane = readsOpraChain ||
2246
- pollLanes.some((instance) => {
2247
- const lane = wrunPollLaneByKey(instance.laneKey);
2248
- return lane !== undefined && wrunPollLaneInstanceReadsOpra(lane, instance.extras);
2249
- }) ||
2250
- rowLanes.some((instance) => {
2251
- const lane = wrunRowLaneByKey(instance.laneKey);
2252
- return lane !== undefined && wrunRowLaneInstanceReadsOpra(lane, instance.extras);
2253
- });
2254
- const writeOpraProvenance = optionsChainExtras !== undefined || wrunSheetReadsOpraLane(target.metadata)
2255
- ? await wrunOpraProvenanceWriter(target.chartIndex, target.indicatorId, { owner, tc, meta, marketIdentity })
2256
- : undefined;
2257
- if (readsOpraPlane && writeOpraProvenance?.(true) !== true) {
2258
- throw new WrunChartGoneError(`wrun overlay '${target.indicatorId}' left its chart before its OPRA provenance was stamped (superseded)`);
2259
- }
2260
2383
  // The capability rule (WRUN-REFUSALS U3a step 5, `wrunUnservedLanes`: the one rule the picker's
2261
- // verdict reads too), before any fetch: a row-builder lane the chart's fetch never serves on this
2384
+ // verdict reads too), before a lane's dispatch: a row-builder lane the chart's fetch never serves on this
2262
2385
  // market (`wrunLaneServiceOnMarket`: the dispatcher's own index-mode admission, the market-kind
2263
2386
  // table (forex and commodities serve no volume profile, buy/sell volume, order book, implied
2264
2387
  // volatility or skew) and the coin table (the option summary serves BTC and ETH), never an empty
@@ -2268,58 +2391,52 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2268
2391
  // switch-market way out, never Retry: feed-missing, or coin-outside-feed for a coin the lane does
2269
2392
  // not serve. Every other reader draws over the empty lane, and the lane joins the feed-missing
2270
2393
  // notes beside the poll planner's. An admitted lane answering empty keeps the degrade below.
2271
- const missingFeeds = [...pollMissingFeeds, ...rowMissingFeeds];
2394
+ const capabilityFeeds = [];
2272
2395
  const unservedLanes = [];
2273
2396
  // The trades leg lanes the rule judged unserved on their own market: never dispatched.
2274
2397
  const unservedTradeLegs = new Set();
2275
- for (const { lane, type, service, holding, inputNames: readers, market } of wrunUnservedLanes(target.metadata, { exchange: chartExchange, coin: chartCoin },
2276
- // A governed chain, and every governed or chain row lane the plan admitted, rides its plane's rows on the
2277
- // native-rows path.
2278
- {
2279
- nativeLanes: [
2280
- ...(governedChain ? ['options_chain'] : []),
2281
- ...rowLanes
2282
- .filter((instance) => {
2283
- const lane = wrunRowLaneByKey(instance.laneKey);
2284
- return lane !== undefined && wrunRowLaneFetchOptions(lane)?.nativeRows === true;
2285
- })
2286
- .map((instance) => instance.sourceClass),
2287
- ],
2288
- })) {
2289
- const reason = wrunUnservedLaneReason(type, market?.exchange ?? chartExchange, chartCoin, service);
2290
- if (holding !== undefined) {
2291
- const fill = holding.celled ? 'empty' : 'nan';
2292
- // A leg stream reads its leg or nothing (it declares no fill): the market's lane is its only source.
2293
- const noFill = isWrunLegStreamClass(lane) ? '' : `, and it declares no missing: "${fill}" fill to read instead`;
2294
- throw attachWrunRefusal(new Error(`Input '${holding.name}' (${lane}) is not served on this chart: ${reason}${noFill}`), service.reason === 'coin'
2295
- ? { ...wrunPollCoinGateSeed(lane, service.coins, chartCoin.toUpperCase()), severity: 'paused' }
2296
- : {
2297
- cls: 'feed-missing',
2298
- variant: cryptoVenue ? 'market-paused' : 'crypto-only',
2299
- params: { feed: lane },
2300
- severity: 'paused',
2301
- });
2302
- }
2303
- // Every lane the rule judges is one of the row builder's own, or a trades leg lane on the
2304
- // market it judged (its readers' leg lanes).
2305
- if (market === undefined)
2306
- unservedLanes.push(lane);
2307
- else {
2308
- for (const name of readers) {
2309
- const legLane = wrunSourceLane(target.metadata.inputSources[name]);
2310
- if (legLane !== undefined)
2311
- unservedTradeLegs.add(legLane);
2398
+ const judgeLaneService = (verdicts) => {
2399
+ for (const { lane, type, service, holding, inputNames: readers, market } of verdicts) {
2400
+ const reason = wrunUnservedLaneReason(type, market?.exchange ?? chartExchange, chartCoin, service);
2401
+ if (holding !== undefined) {
2402
+ const fill = holding.celled ? 'empty' : 'nan';
2403
+ // A leg stream reads its leg or nothing (it declares no fill): the market's lane is its only source.
2404
+ const noFill = isWrunLegStreamClass(lane) ? '' : `, and it declares no missing: "${fill}" fill to read instead`;
2405
+ throw attachWrunRefusal(new Error(`Input '${holding.name}' (${lane}) is not served on this chart: ${reason}${noFill}`), service.reason === 'coin'
2406
+ ? { ...wrunPollCoinGateSeed(lane, service.coins, chartCoin.toUpperCase()), severity: 'paused' }
2407
+ : {
2408
+ cls: 'feed-missing',
2409
+ variant: cryptoVenue ? 'market-paused' : 'crypto-only',
2410
+ params: { feed: lane },
2411
+ severity: 'paused',
2412
+ });
2312
2413
  }
2414
+ // Every lane the rule judges is one of the row builder's own, or a trades leg lane on the
2415
+ // market it judged (its readers' leg lanes).
2416
+ if (market === undefined)
2417
+ unservedLanes.push(lane);
2418
+ else {
2419
+ for (const name of readers) {
2420
+ const legLane = wrunSourceLane(target.metadata.inputSources[name]);
2421
+ if (legLane !== undefined)
2422
+ unservedTradeLegs.add(legLane);
2423
+ }
2424
+ }
2425
+ capabilityFeeds.push({
2426
+ inputNames: readers,
2427
+ feed: lane,
2428
+ variant: cryptoVenue ? 'market' : 'crypto-only',
2429
+ details: readers
2430
+ .map((name) => `Input '${name}' (${lane}) is not served on this chart: ${reason}; it reads its missing fill`)
2431
+ .join('\n'),
2432
+ });
2313
2433
  }
2314
- missingFeeds.push({
2315
- inputNames: readers,
2316
- feed: lane,
2317
- variant: cryptoVenue ? 'market' : 'crypto-only',
2318
- details: readers
2319
- .map((name) => `Input '${name}' (${lane}) is not served on this chart: ${reason}; it reads its missing fill`)
2320
- .join('\n'),
2321
- });
2322
- }
2434
+ };
2435
+ // Every lane but the options chain is judged now, before the first lane dispatches: no plan that may wait on the
2436
+ // network decides its verdict (a row lane's class is no admission lane, so the row plan's native classes change no
2437
+ // verdict). The options chain's verdict waits for its identity (a governed chain rides its plane's rows on the
2438
+ // native-rows path) and is judged right before the chain lane dispatches.
2439
+ judgeLaneService(wrunUnservedLanes(target.metadata, { exchange: chartExchange, coin: chartCoin }).filter((verdict) => verdict.lane !== 'options_chain'));
2323
2440
  // Each declared source class rides the SAME kScript fetch lane the local
2324
2441
  // engine uses for the original script, so A/B comparisons see one data set.
2325
2442
  // Deadline-raced: a source lane resolves only when its V2 stream completes
@@ -2331,6 +2448,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2331
2448
  // folds land in the history lane's units (coins by default for trades,
2332
2449
  // the quote guard for the profile, the ladder identity for the book).
2333
2450
  const acquisitionByLane = {};
2451
+ // Per dispatched secondary lane, its send anchor (`lanePolicy.onDispatch`): `fetchLane` hands the transport its
2452
+ // notice, so the lane's budget and the fetch's deadline count from the send once one is heard (runWrunSourceLanes).
2453
+ const laneSendAnchors = new Map();
2334
2454
  // A settings save computes over the lanes its live session holds (wrun-held-lanes.util): each
2335
2455
  // lane that session asked the same way, from this window's start or earlier, on this market and
2336
2456
  // clock, answers from its buffer with no ask, and the new session inherits its coverage.
@@ -2377,14 +2497,49 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2377
2497
  const held = fromTs === from && toTs === to ? takeHeldLane(lane, payload) : undefined;
2378
2498
  if (held !== undefined)
2379
2499
  return held;
2380
- const fetched = await withWrunDeadline(fetchOptions?.ownFetch
2500
+ // The chart's own series at the chart's interval, over bars the chart holds, answers from the chart's rows with no
2501
+ // ask (run-schedule/wrun-own-candles.util).
2502
+ const own = fetchOptions?.ownFetch === undefined
2503
+ ? serveWrunOwnCandles({
2504
+ type,
2505
+ ...(payloadExtras !== undefined ? { payloadExtras } : {}),
2506
+ interval: run && fetchOptions?.interval === undefined ? run.interval : fetchOptions?.interval,
2507
+ replay: replay !== undefined,
2508
+ fromTs,
2509
+ toTs,
2510
+ chart: {
2511
+ exchange: chartExchange,
2512
+ symbol: chartSymbol,
2513
+ interval: chartInterval,
2514
+ intervalMs: chartIntervalMs,
2515
+ rows: loadedRows,
2516
+ },
2517
+ })
2518
+ : null;
2519
+ if (own !== null) {
2520
+ fetchOptions?.onSourceVerdict?.({ complete: true, servedEmpty: false, source: 'main-rows' });
2521
+ return own.rows;
2522
+ }
2523
+ // A secondary lane's request rides its send anchor (runWrunSourceLanes, `wrunLaneFetchRequest`): the notice it hands
2524
+ // the transport, fired once the request is on the wire, re-anchors the lane's budget there (a request queued on the
2525
+ // main thread, behind the socket's open or in the worker's queue spends none of it) and the fetch's own deadline
2526
+ // with it, which never ends before the lane's own deadline and keeps a read the budget abandoned adoptable. A relay
2527
+ // feed's own fetch leaves at once: its budget and its deadline stay counted from the dispatch.
2528
+ const anchor = fetchOptions?.ownFetch === undefined && lane !== undefined ? laneSendAnchors.get(lane) : undefined;
2529
+ const request = anchor === undefined ? undefined : wrunLaneFetchRequest(anchor, WRUN_SOURCE_FETCH_DEADLINE_MS);
2530
+ const sendNotices = request === undefined ? {} : { onDispatched: request.sent, onSent: request.sent };
2531
+ const asked = fetchOptions?.ownFetch
2381
2532
  ? fetchOptions.ownFetch(fromTs, toTs)
2382
2533
  : wrunChartHostEnv().transport.fetchSource(target.chartIndex, type, payload, fromTs, toTs, view, `${target.fetchKey}-${key}`, false,
2383
2534
  // A run at another interval: a source naming no interval of its own rides the run interval
2384
2535
  // (the kScript engine's rule, runIntervalForSource), one naming its own keeps it.
2385
2536
  run && fetchOptions?.interval === undefined
2386
- ? { ...fetchOptions, interval: run.interval }
2387
- : (fetchOptions ?? {})), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun source fetch '${type}' for '${target.fetchKey}'`);
2537
+ ? { ...fetchOptions, interval: run.interval, ...sendNotices }
2538
+ : { ...fetchOptions, ...sendNotices });
2539
+ const label = `wrun source fetch '${type}' for '${target.fetchKey}'`;
2540
+ const fetched = await (request === undefined
2541
+ ? withWrunDeadline(asked, WRUN_SOURCE_FETCH_DEADLINE_MS, label)
2542
+ : raceWrunSendDeadline(asked, request.bound, label));
2388
2543
  // Packed-lane SUCCESS arrives as the packed transport object (only the
2389
2544
  // kScript engine worker consumes it un-unpacked); unpack it here, or a
2390
2545
  // real success misclassifies as a decline and re-fetches on the plain
@@ -2769,7 +2924,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2769
2924
  });
2770
2925
  const formingPreRollPromise = formingPreRollFrom === undefined
2771
2926
  ? Promise.resolve(undefined)
2772
- : fetchLane('ohlcv', 'forming-preroll', undefined, undefined, formingPreRollFrom, from).then((rows) => ({
2927
+ : lanesKnown.then(() => fetchLane('ohlcv', 'forming-preroll', undefined, undefined, formingPreRollFrom, from).then((rows) => ({
2773
2928
  fromTs: formingPreRollFrom,
2774
2929
  rows: (rows ?? []).filter((row) => {
2775
2930
  const ts = Number(row[0]);
@@ -2779,7 +2934,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2779
2934
  console.warn(`[wrun] forming pre-roll unavailable for '${target.fetchKey}':`, error);
2780
2935
  unsettledLanes.add('forming-preroll');
2781
2936
  return undefined;
2782
- });
2937
+ }));
2938
+ // A plan's refusal reaches it before any fetch: read only once every plan resolved.
2939
+ void formingPreRollPromise.catch(() => undefined);
2783
2940
  // The ETF lane: one K_ETF_FLOW ask per ticker at the lane's own DAY interval
2784
2941
  // (the gateway serves ETF_FLOW_AGG at DAY only; dataFetch judges the
2785
2942
  // restriction table at that interval), the window opened at the first row's
@@ -2930,7 +3087,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2930
3087
  }
2931
3088
  return requireDegradableRows(type, label, zipWrunOptionSummaryRows(plan, rowsByAsk));
2932
3089
  };
2933
- const legRowsPromise = Promise.all(legs.map((leg) => fetchLegRows(leg).then((rows) => [leg.fetchKey, rows])));
3090
+ const legRowsPromise = lanesKnown.then(() => Promise.all(legs.map((leg) => fetchLegRows(leg).then((rows) => [leg.fetchKey, rows]))));
2934
3091
  // The legs' and the run bars' failures surface through the first-failure
2935
3092
  // rule: the lanes settle first, then the legs' and the run bars' outcomes
2936
3093
  // are awaited (their seeded refusals thrown inside their asks).
@@ -2940,13 +3097,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
2940
3097
  // KEPT in the session's buffer (live-folded like the chart's own forming bar, computed with wait
2941
3098
  // for close off), cut at the chart's newest bar (an answer may already hold the next bucket).
2942
3099
  const runRowsPromise = run && runRowsPlan?.held === undefined
2943
- ? fetchRequiredLane('ohlcv', `main-${run.interval}`, `${run.interval} candle`, {
3100
+ ? lanesKnown.then(() => fetchRequiredLane('ohlcv', `main-${run.interval}`, `${run.interval} candle`, {
2944
3101
  cls: 'service-no-answer',
2945
3102
  variant: 'lane',
2946
3103
  params: { feed: 'ohlcv' },
2947
3104
  ...(chartMarket !== undefined ? { market: chartMarket } : {}),
2948
3105
  severity: 'paused',
2949
- }, undefined, { interval: run.interval }, from, to).then((rows) => wrunRunIntervalRowsThrough(run, rows, to))
3106
+ }, undefined, { interval: run.interval }, from, to).then((rows) => wrunRunIntervalRowsThrough(run, rows, to)))
2950
3107
  : undefined;
2951
3108
  runRowsPromise?.catch(() => undefined);
2952
3109
  // The degrade registry the legend chips derive from (kScript's, keyed by the
@@ -3081,30 +3238,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3081
3238
  ? () => fetchOptionSummaryRows('implied_volatility', impliedVolatilityPlan)
3082
3239
  : undefined,
3083
3240
  skew: declaredClasses.has('skew') ? () => fetchOptionSummaryRows('skew', skewPlan) : undefined,
3084
- // The options_chain lane (K_OPTIONS_CHAIN): ONE chain per package, its
3085
- // identity (the venue knob against the chart: a CME root, an OPRA ticker
3086
- // for an OpenMarket package, a Deribit coin, a flagged crypto venue)
3087
- // decided on the main thread BEFORE the fetch and refused by name there
3088
- // (`optionsChainExtras` above); the identity rides the lane's payload
3089
- // extras, which the acquisition record keeps for the poll reconcile. A
3090
- // governed chain asks on the native-rows path (its rows are its plane's,
3091
- // never the index-mode market's), and its acquisition records it so the
3092
- // reconcile asks the same way. The worker answers one snapshot row (the
3093
- // latest chain); an empty answer degrades like every state lane (a
3094
- // resolved venue always lists contracts).
3095
- options_chain: optionsChainExtras !== undefined
3096
- ? async () => {
3097
- try {
3098
- return await fetchDegradableLane('options_chain', 'chain', 'Options chain', optionsChainExtras, governedChain ? { nativeRows: true } : undefined);
3099
- }
3100
- finally {
3101
- // Recorded whatever the answer: the reconcile re-asks the lane the way the run did.
3102
- if (governedChain) {
3103
- acquisitionByLane.options_chain = { ...acquisitionByLane.options_chain, nativeRows: true };
3104
- }
3105
- }
3106
- }
3107
- : undefined,
3241
+ // The options_chain lane dispatches in its own group, once its identity resolved (below).
3108
3242
  etf_flow: etfLanePlan !== undefined ? () => fetchEtfFlowRows(etfLanePlan) : undefined,
3109
3243
  // The trade tape (C2): the K_TRADES lane asked for the large-print table (`large: true`, the
3110
3244
  // TRADE_LARGE type) at the acquisition's facets, `minSize` pushed down to the gateway as
@@ -3130,11 +3264,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3130
3264
  tradeLegs: tradeLegLanes
3131
3265
  .filter((lane) => !softRefusedTradeLegs.has(lane) && !unservedTradeLegs.has(lane))
3132
3266
  .map((lane) => [lane, (abandoned) => fetchTradeLegRows(lane, abandoned)]),
3133
- // The registry poll lanes, one thunk per planned instance, after the row
3134
- // builder's own lanes in declaration order.
3135
- pollLanes: pollLanes.map((instance) => [instance.key, () => fetchPollLaneRows(instance)]),
3136
- // The row lanes, one thunk per planned instance, after the poll lanes.
3137
- rowLanes: rowLanes.map((instance) => [instance.key, () => fetchRowLaneRows(instance)]),
3267
+ // The registry poll lanes and the row lanes dispatch in their own groups, once their plans resolved (below).
3138
3268
  };
3139
3269
  // A lane the chart's fetch never serves here is not dispatched (the capability rule above).
3140
3270
  for (const lane of unservedLanes)
@@ -3174,33 +3304,201 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3174
3304
  historySeconds: tape?.historySeconds,
3175
3305
  });
3176
3306
  }
3177
- // A degrade entry of a lane this run does not dispatch is settled before the dispatch: a trades leg
3178
- // the coin switch moved, or a lane a setting gate, a unit pick, `needed_by` or the capability rule
3179
- // dropped. No later run of this sheet asks that lane again, so its chip would stand over a picture
3180
- // that never reads it; only a teardown would clear it.
3181
- const dispatchedLanes = wrunDispatchedLaneIds(laneThunks);
3307
+ // The ask this run makes of every lane (run-schedule/wrun-late-reads.util): equal identities ask the same rows, so a
3308
+ // read a lane's budget abandoned is joined or adopted by a later run asking the same, never asked twice. The mount
3309
+ // is part of it: a remount (or another overlay under the same id) never joins the reads of the record it replaced.
3310
+ const lateReadIdentity = [
3311
+ wrunMountSerialOf(meta),
3312
+ target.fetchKey,
3313
+ planGeneration,
3314
+ marketIdentity,
3315
+ from,
3316
+ to,
3317
+ clock.intervalMs,
3318
+ run?.interval ?? '',
3319
+ generationAtStart,
3320
+ ].join('|');
3321
+ // The policy every group's lanes ride: the budget, counted from each lane's dispatch until its send re-anchors it (its
3322
+ // anchor goes to `fetchLane`, which hands it to the transport), the pending mark at dispatch (the degrade registry the
3323
+ // legend chips derive from: the budget stays the chip's authority), and the read a lane's budget abandoned, noted for
3324
+ // the source ladder with the acquisition the run records for the lane.
3325
+ const lanePolicy = {
3326
+ budgetMs: (lane) => (lane === 'tape' ? tapeBudgetMs : (tradeLegBudgetMs.get(lane) ?? chartBudgetMs)),
3327
+ onDispatch: (lane, anchor) => {
3328
+ laneSendAnchors.set(lane, anchor);
3329
+ wrunChartHostEnv().chart.markSourcePending(guardKey, {
3330
+ sourceName: lane,
3331
+ sourceType: wrunLaneSourceOf(lane, laneInstances).kType,
3332
+ landedBefore: hasGoodResult,
3333
+ });
3334
+ },
3335
+ onLate: (lane, answer) => noteWrunLateRead({
3336
+ indicatorId: target.indicatorId,
3337
+ lane,
3338
+ identity: lateReadIdentity,
3339
+ answer,
3340
+ acquisition: () => acquisitionByLane[lane],
3341
+ }),
3342
+ };
3343
+ // A lane whose read an earlier run left out under this run's identity joins that read (still out) or adopts its
3344
+ // answer: the lane sends no second ask. The acquisition the earlier run recorded is the lane's here.
3345
+ const joinLateRead = (lane) => {
3346
+ const taken = takeWrunLateRead(target.indicatorId, lane, lateReadIdentity);
3347
+ if (taken === undefined)
3348
+ return undefined;
3349
+ if (wrunChartHostEnv().diagnostics.debugEnabled()) {
3350
+ wrunChartHostEnv().diagnostics.debug('wrun-late-read-taken', {
3351
+ chartIndex: target.chartIndex,
3352
+ indicatorId: target.indicatorId,
3353
+ lane,
3354
+ kind: taken.kind,
3355
+ reason,
3356
+ });
3357
+ }
3358
+ return taken.rows.then((rows) => {
3359
+ const acquisition = taken.acquisition();
3360
+ if (acquisition !== undefined && acquisitionByLane[lane] === undefined) {
3361
+ acquisitionByLane[lane] = acquisition;
3362
+ }
3363
+ return rows;
3364
+ });
3365
+ };
3366
+ // A group's OPRA lanes stamp the overlay's provenance before the group's first fetch (the writer above); a run that
3367
+ // lost its overlay meanwhile is superseded.
3368
+ const stampWrunOpraProvenance = async (reads) => {
3369
+ if (!reads)
3370
+ return;
3371
+ const write = await opraProvenanceWriter;
3372
+ if (write?.(true) !== true) {
3373
+ throw new WrunChartGoneError(`wrun overlay '${target.indicatorId}' left its chart before its OPRA provenance was stamped (superseded)`);
3374
+ }
3375
+ };
3376
+ const pollInstanceReadsOpra = (instance) => {
3377
+ const lane = wrunPollLaneByKey(instance.laneKey);
3378
+ return lane !== undefined && wrunPollLaneInstanceReadsOpra(lane, instance.extras);
3379
+ };
3380
+ const rowInstanceReadsOpra = (instance) => {
3381
+ const lane = wrunRowLaneByKey(instance.laneKey);
3382
+ return lane !== undefined && wrunRowLaneInstanceReadsOpra(lane, instance.extras);
3383
+ };
3384
+ // Every declared lane is dispatched the moment its own inputs are known (run-schedule/wrun-lane-groups.util), each
3385
+ // group through one lane runner under the policy above, settled together: the lanes known now (the row builder's,
3386
+ // the trades legs), then each lane group as its plan resolves. The gate's close verdict (gate-session-latch.util,
3387
+ // wrun-options-stop.util): a lane on a gate plane whose one session another screen holds is never sent (its reader
3388
+ // dials nothing until the session is taken back here), so it answers at once with its typed stop instead of waiting
3389
+ // out its budget.
3390
+ const schedule = scheduleWrunLaneGroups({
3391
+ run: (thunks) => runWrunSourceLanes(thunks, lanePolicy),
3392
+ lanesOf: wrunDispatchedLaneIds,
3393
+ merge: mergeWrunSourceLaneRuns,
3394
+ });
3395
+ // The registry poll lanes and the row lanes, one thunk per planned instance, after the row builder's own lanes in
3396
+ // declaration order: those whose plan read no chain dispatch with the lanes known now.
3397
+ const pollThunksOf = (lanes) => lanes.map((instance) => [instance.key, () => fetchPollLaneRows(instance)]);
3398
+ const rowThunksOf = (lanes) => lanes.map((instance) => [instance.key, () => fetchRowLaneRows(instance)]);
3399
+ schedule.add(localPlanned.then(({ poll, row }) => {
3400
+ laneInstances.push(...poll.lanes, ...row.lanes);
3401
+ return wrunJoinLateReads({ ...laneThunks, pollLanes: pollThunksOf(poll.lanes), rowLanes: rowThunksOf(row.lanes) }, joinLateRead);
3402
+ }));
3403
+ // The poll lanes whose plan read the chain, each instance stamped first when it reads OPRA.
3404
+ schedule.add(pollPlannedChain.then(async ({ lanes }) => {
3405
+ laneInstances.push(...lanes);
3406
+ if (lanes.length === 0)
3407
+ return undefined;
3408
+ await stampWrunOpraProvenance(lanes.some(pollInstanceReadsOpra));
3409
+ return wrunGateLatchedThunks(wrunJoinLateReads({ pollLanes: pollThunksOf(lanes) }, joinLateRead), wrunLaneGatePlanes({ pollLanes: lanes, rowLanes: [] }), gateSessionHeldElsewhere);
3410
+ }));
3411
+ // The row lanes whose plan read the chain, the same way.
3412
+ schedule.add(rowPlannedChain.then(async ({ lanes }) => {
3413
+ laneInstances.push(...lanes);
3414
+ if (lanes.length === 0)
3415
+ return undefined;
3416
+ await stampWrunOpraProvenance(lanes.some(rowInstanceReadsOpra));
3417
+ return wrunGateLatchedThunks(wrunJoinLateReads({ rowLanes: rowThunksOf(lanes) }, joinLateRead), wrunLaneGatePlanes({ pollLanes: [], rowLanes: lanes }), gateSessionHeldElsewhere);
3418
+ }));
3419
+ // The options_chain lane (K_OPTIONS_CHAIN): ONE chain per package, its identity (the venue knob against the chart: a
3420
+ // CME root, an OPRA ticker for an OpenMarket package, a Deribit coin, a flagged crypto venue) decided on the main
3421
+ // thread BEFORE its fetch and refused by name there (`optionsChainPlanned` above); the identity rides the lane's
3422
+ // payload extras, which the acquisition record keeps for the poll reconcile. A governed chain (CME, OPRA) rides its
3423
+ // own plane's reader on the fetch's native-rows path, never the chart market's fetch shape (the capability rule
3424
+ // serves it on an index-mode stock or ETF chart), and its acquisition records it so the reconcile asks the same way.
3425
+ // The worker answers one snapshot row (the latest chain); an empty answer degrades like every state lane (a resolved
3426
+ // venue always lists contracts).
3427
+ schedule.add(optionsChainPlanned.then(async (extras) => {
3428
+ if (extras === undefined)
3429
+ return undefined;
3430
+ const governed = wrunOptionsChainExtrasGoverned(extras);
3431
+ judgeLaneService(wrunUnservedLanes(target.metadata, { exchange: chartExchange, coin: chartCoin }, { nativeLanes: governed ? ['options_chain'] : [] }).filter((verdict) => verdict.lane === 'options_chain'));
3432
+ if (unservedLanes.includes('options_chain'))
3433
+ return undefined;
3434
+ await stampWrunOpraProvenance(extras.chainVenue === 'opra');
3435
+ const askOptionsChain = (payload) => fetchDegradableLane('options_chain', 'chain', 'Options chain', payload, governed ? { nativeRows: true } : undefined);
3436
+ const thunks = {
3437
+ options_chain: async () => {
3438
+ try {
3439
+ // Hinted views (OPTLOAD G5) cover the closes inside the band around the close they were asked at: the ask
3440
+ // carries the chart's close now, and a run whose close left the band asks again before it reads.
3441
+ const marginPct = Number(extras.chainSpotMarginPct);
3442
+ if (!(marginPct > 0))
3443
+ return await askOptionsChain(extras);
3444
+ const { wrunChartLastClose, wrunOptionViewHintCovers } = await import('./wrun-option-views.util.js');
3445
+ const closeNow = () => wrunChartLastClose(wrunChartHostEnv().chart.instance(target.chartIndex)?.metadata?.[0]?.rawData);
3446
+ const hint = closeNow();
3447
+ const rows = await askOptionsChain(hint === undefined ? extras : { ...extras, chainSpotHint: hint });
3448
+ const close = closeNow();
3449
+ if (hint === undefined || close === undefined || wrunOptionViewHintCovers(hint, marginPct, close))
3450
+ return rows;
3451
+ return await askOptionsChain({ ...extras, chainSpotHint: close });
3452
+ }
3453
+ finally {
3454
+ // Recorded whatever the answer: the reconcile re-asks the lane the way the run did.
3455
+ if (governed) {
3456
+ acquisitionByLane.options_chain = { ...acquisitionByLane.options_chain, nativeRows: true };
3457
+ }
3458
+ }
3459
+ },
3460
+ };
3461
+ return wrunGateLatchedThunks(wrunJoinLateReads(thunks, joinLateRead), wrunLaneGatePlanes({ pollLanes: [], rowLanes: [], optionsChainExtras: extras }), gateSessionHeldElsewhere);
3462
+ }));
3463
+ // Every plan resolved (a refusal by name fails the run here, retracting the lanes already sent): the lanes'
3464
+ // instances in the plans' order, the feed notes, the OPRA facts the integrate reads.
3465
+ await schedule.planned((lane) => wrunChartHostEnv().chart.markSourceRecovered(guardKey, lane));
3466
+ // Each planner's two passes as one plan: its instances in declaration order (by the first input each serves).
3467
+ const { lanes: pollLanes, missingFeeds: pollMissingFeeds } = mergeWrunLanePlans(await pollPlannedLocal, await pollPlannedChain);
3468
+ const { lanes: rowLanes, missingFeeds: rowMissingFeeds } = mergeWrunLanePlans(await rowPlannedLocal, await rowPlannedChain);
3469
+ const optionsChainExtras = await optionsChainPlanned;
3470
+ laneInstances.splice(0, laneInstances.length, ...pollLanes, ...rowLanes);
3471
+ const missingFeeds = [...pollMissingFeeds, ...rowMissingFeeds, ...capabilityFeeds];
3472
+ const chainDispatched = optionsChainExtras !== undefined && !unservedLanes.includes('options_chain');
3473
+ // A chain read on the OPRA plane, and any other OPRA source lane the plans kept (a poll lane's `opra`, a row lane's
3474
+ // `governed: 'opra'`, a chain lane's instance of either kind whose chain lists on OPRA), stamped the provenance before
3475
+ // its group's first fetch; a chain read off a CME or crypto chain stamps nothing.
3476
+ const readsOpraPlane = optionsChainExtras?.chainVenue === 'opra' ||
3477
+ pollLanes.some(pollInstanceReadsOpra) ||
3478
+ rowLanes.some(rowInstanceReadsOpra);
3479
+ const writeOpraProvenance = await opraProvenanceWriter;
3480
+ // A degrade entry of a lane this run does not dispatch is settled now: a trades leg the coin switch moved, or a lane
3481
+ // a setting gate, a unit pick, `needed_by` or the capability rule dropped. No later run of this sheet asks that lane
3482
+ // again, so its chip would stand over a picture that never reads it; only a teardown would clear it.
3483
+ const dispatchedLanes = new Set([
3484
+ ...wrunDispatchedLaneIds(laneThunks),
3485
+ ...pollLanes.map((instance) => instance.key),
3486
+ ...rowLanes.map((instance) => instance.key),
3487
+ ...(chainDispatched ? ['options_chain'] : []),
3488
+ ]);
3182
3489
  for (const { sourceName } of wrunChartHostEnv().chart.sourceDegradeEntries(guardKey)) {
3183
3490
  if (!dispatchedLanes.has(sourceName))
3184
3491
  wrunChartHostEnv().chart.markSourceRecovered(guardKey, sourceName);
3185
3492
  }
3186
- // The gate's close verdict (gate-session-latch.util, wrun-options-stop.util): a lane on a gate plane whose one
3187
- // session another screen holds is never sent (its reader dials nothing until the session is taken back here), so it
3188
- // answers at once with its typed stop instead of waiting out its budget. The planes the lanes read are noted, so each
3189
- // edge of a plane's latch runs this overlay again (wrun-overlay-recovery.util `rerunWrunGatePlaneReaders`).
3493
+ // The planes the lanes read are noted, so each edge of a plane's latch runs this overlay again
3494
+ // (wrun-overlay-recovery.util `rerunWrunGatePlaneReaders`).
3190
3495
  const laneGatePlanes = wrunLaneGatePlanes({
3191
3496
  pollLanes,
3192
3497
  rowLanes,
3193
- ...(laneThunks.options_chain !== undefined && optionsChainExtras !== undefined ? { optionsChainExtras } : {}),
3498
+ ...(chainDispatched && optionsChainExtras !== undefined ? { optionsChainExtras } : {}),
3194
3499
  });
3195
3500
  noteWrunGatePlanesRead(target.chartIndex, target.indicatorId, laneGatePlanes.values());
3196
- const laneRun = await runWrunSourceLanes(wrunGateLatchedThunks(laneThunks, laneGatePlanes, gateSessionHeldElsewhere), {
3197
- budgetMs: (lane) => (lane === 'tape' ? tapeBudgetMs : (tradeLegBudgetMs.get(lane) ?? chartBudgetMs)),
3198
- onDispatch: (lane) => wrunChartHostEnv().chart.markSourcePending(guardKey, {
3199
- sourceName: lane,
3200
- sourceType: wrunLaneSourceOf(lane, laneInstances).kType,
3201
- landedBefore: hasGoodResult,
3202
- }),
3203
- });
3501
+ const laneRun = await schedule.settled();
3204
3502
  // A degraded lane on a plane another screen holds (stopped at dispatch, or the latch came while its read was out)
3205
3503
  // stopped for that reason: it says so, and no ladder re-asks it (only the take-back serves it).
3206
3504
  const gateStops = new Map(laneRun.degraded.flatMap(({ lane, outcome }) => {
@@ -3572,6 +3870,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
3572
3870
  // A Retry or a settings run may dispatch a package the host quarantined
3573
3871
  // after a timeout (C5); every other run respects the quarantine.
3574
3872
  const overrideQuarantine = reason === 'retry' || reason === 'settings';
3873
+ computed.stage = 'compute';
3575
3874
  return {
3576
3875
  // The plan the sandbox row source runs.
3577
3876
  live,
@@ -4330,6 +4629,8 @@ async function computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, comp
4330
4629
  * preparation the run's host holds when the browser lanes prepared it. */
4331
4630
  async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner, head, host, ask) {
4332
4631
  const { source } = ask;
4632
+ // The source computes the batch (the browser lanes' preparation moves the stage to its lanes, then back).
4633
+ computed.stage = 'compute';
4333
4634
  const batch = await ask.call().catch((error) => {
4334
4635
  // An ask the source merged nothing from (no reply: a laundered kick, a socket that is not open, a
4335
4636
  // failed worker) is a cause a second run gets past: the run fails with Retry, the heal ladder's
@@ -4344,6 +4645,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4344
4645
  }
4345
4646
  throw error;
4346
4647
  });
4648
+ computed.stage = 'integrate';
4347
4649
  const prepared = host.prepared;
4348
4650
  if (prepared === undefined) {
4349
4651
  await integrateWrunRowSourceBatch(runTarget, tc, meta, refusal, computed, owner, head, ask, batch);
@@ -4501,6 +4803,12 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
4501
4803
  lookbackBars: wrunTwinLookbackBars(meta.settings) ?? (await wrunTwinOriginalLookbackBars(meta.settings, chartIntervalMs)),
4502
4804
  unsettledLanes,
4503
4805
  planGeneration,
4806
+ // Where the history the run read begins: its row lanes', unless it read another source beside the candles (a
4807
+ // pinned leg, or any lane that is no row lane: none of those names its reach).
4808
+ historySources: {
4809
+ rowLanes,
4810
+ readsOtherSources: legs.length > 0 || laneRun.outcomes.some(({ lane }) => !isWrunRowLaneId(lane)),
4811
+ },
4504
4812
  });
4505
4813
  // The presentation that follows every integrate (the parent and its
4506
4814
  // lower-pane children mounted): nested output visibility from the sheet
@@ -5685,6 +5993,7 @@ function askWrunWarmupBackfillIfOwed(args) {
5685
5993
  declaredWarmupEndTs: declaredWarmupBars === null
5686
5994
  ? null
5687
5995
  : wrunDeclaredWarmupEndTs(runRows, declaredWarmupBars, intervalMs, creditedBars),
5996
+ sourceReachFromTs: wrunRunSourceReachFromMs({ ...args.historySources, nowMs: Date.now() }),
5688
5997
  }),
5689
5998
  requestOlderHistory: wrunWarmupPageRequester(chartIndex, indicatorId, tc, isCurrent, ringDetails),
5690
5999
  ringDetails,
@@ -6800,6 +7109,42 @@ function wrunDispatchedLaneIds(thunks) {
6800
7109
  }
6801
7110
  return lanes;
6802
7111
  }
7112
+ /** A lane's place in declaration order: the row builder's own lanes in their order, then the trades leg lanes, the
7113
+ * registry poll lanes and the row lanes. */
7114
+ function wrunSourceLaneRank(lane) {
7115
+ const builtin = WRUN_SOURCE_LANE_ORDER.indexOf(lane);
7116
+ if (builtin >= 0)
7117
+ return builtin;
7118
+ if (isWrunTradesLegLane(lane))
7119
+ return WRUN_SOURCE_LANE_ORDER.length;
7120
+ return WRUN_SOURCE_LANE_ORDER.length + (isWrunRowLaneId(lane) ? 2 : 1);
7121
+ }
7122
+ /**
7123
+ * The lane runs of one run's groups (`scheduleWrunLaneGroups`: the lanes known at the plan, then each group as its
7124
+ * plan resolved) as the one run a single dispatch reports: every result, and every outcome in declaration order (a
7125
+ * stable sort, so each group keeps its own order), the degraded ones beside them in the same order. The order names a
7126
+ * hold and the records exactly as before the dispatch was split.
7127
+ */
7128
+ export function mergeWrunSourceLaneRuns(runs) {
7129
+ const merged = { results: {}, outcomes: [], degraded: [] };
7130
+ for (const run of runs) {
7131
+ const { tradeLegRows, pollLaneRows, rowLaneRows, ...builtin } = run.results;
7132
+ Object.assign(merged.results, builtin);
7133
+ if (tradeLegRows !== undefined)
7134
+ merged.results.tradeLegRows = { ...merged.results.tradeLegRows, ...tradeLegRows };
7135
+ if (pollLaneRows !== undefined)
7136
+ merged.results.pollLaneRows = { ...merged.results.pollLaneRows, ...pollLaneRows };
7137
+ if (rowLaneRows !== undefined)
7138
+ merged.results.rowLaneRows = { ...merged.results.rowLaneRows, ...rowLaneRows };
7139
+ }
7140
+ merged.outcomes = runs
7141
+ .flatMap((run) => run.outcomes)
7142
+ .map((entry, at) => ({ entry, at }))
7143
+ .sort((a, b) => wrunSourceLaneRank(a.entry.lane) - wrunSourceLaneRank(b.entry.lane) || a.at - b.at)
7144
+ .map(({ entry }) => entry);
7145
+ merged.degraded = merged.outcomes.flatMap(({ lane, outcome }) => outcome.kind === 'degraded' ? [{ lane, outcome }] : []);
7146
+ return merged;
7147
+ }
6803
7148
  /** A degradable lane's empty (or declined) answer, thrown inside its thunk:
6804
7149
  * runWrunSourceLanes records the lane degraded with this answer as the cause,
6805
7150
  * and its message is the hold's when the run holds on the lane. */
@@ -6811,6 +7156,109 @@ class WrunLaneEmptyAnswer extends Error {
6811
7156
  this.answer = answer;
6812
7157
  }
6813
7158
  }
7159
+ /** The moves of a send-anchored deadline: `moved()` settles on the next `move()`. */
7160
+ function wrunDeadlineMoves() {
7161
+ let settleMoved = () => undefined;
7162
+ const nextMove = () => new Promise((resolve) => {
7163
+ settleMoved = () => resolve(undefined);
7164
+ });
7165
+ let moved = nextMove();
7166
+ return {
7167
+ move: () => {
7168
+ const settle = settleMoved;
7169
+ moved = nextMove();
7170
+ settle();
7171
+ },
7172
+ moved: () => moved,
7173
+ };
7174
+ }
7175
+ /**
7176
+ * One lane's deadline under the send anchor: the budget from the dispatch until a send notice arrives, then the budget
7177
+ * from that send, never past the cap from the dispatch (kscript-source-degrade.leaf `resolveSecondarySourceDeadlineMs`,
7178
+ * the rule the kScript engine lane counts the same budget by once its request is on the wire). A notice only ever moves
7179
+ * it later. Pure state: the race's `withWrunDeadline` is the one timer.
7180
+ */
7181
+ function wrunLaneSendDeadline(budgetMs, capMs) {
7182
+ const startedAtMs = Date.now();
7183
+ let sentAtMs = null;
7184
+ let anchoredBy;
7185
+ const moves = wrunDeadlineMoves();
7186
+ const anchor = {
7187
+ request: () => {
7188
+ if (anchoredBy !== undefined)
7189
+ return undefined;
7190
+ const request = {};
7191
+ return () => {
7192
+ if (anchoredBy !== undefined && anchoredBy !== request)
7193
+ return;
7194
+ anchoredBy = request;
7195
+ sentAtMs = Date.now();
7196
+ moves.move();
7197
+ };
7198
+ },
7199
+ sentAtMs: () => sentAtMs,
7200
+ nextSend: moves.moved,
7201
+ };
7202
+ return {
7203
+ anchor,
7204
+ atMs: () => sentAtMs === null
7205
+ ? startedAtMs + budgetMs
7206
+ : resolveSecondarySourceDeadlineMs({ startedAtMs, dispatchedAtMs: sentAtMs, budgetMs, capMs }),
7207
+ moved: moves.moved,
7208
+ };
7209
+ }
7210
+ /**
7211
+ * One request of a secondary lane handed to the chart's transport under the lane's send anchor (`fetchLane`): its send
7212
+ * notice (`sent`, the transport's `onDispatched` and `onSent`), which re-anchors the lane's budget when the request owns
7213
+ * the anchor and always its own bound, and that bound (`WrunSendDeadline`): `boundMs` (the fetch deadline,
7214
+ * `WRUN_SOURCE_FETCH_DEADLINE_MS`) from the latest of the request's dispatch, its own send and the lane's send. The
7215
+ * lane's deadline is its budget from the same send, or from its dispatch, and every budget is below the fetch deadline
7216
+ * (`KSCRIPT_SECONDARY_SOURCE_BUDGET_MAX_MS`, 40 s), so the bound never ends before the lane's own deadline, and a read
7217
+ * the lane's budget abandoned stays out until it answers or its bound from its send ends: the late read the source
7218
+ * ladder adopts (`WrunSourceLanePolicy.onLate`) can still land.
7219
+ */
7220
+ function wrunLaneFetchRequest(anchor, boundMs) {
7221
+ // The request's own anchor: its dispatch, then its latest send notice.
7222
+ let ownAnchorMs = Date.now();
7223
+ const laneNotice = anchor.request();
7224
+ const moves = wrunDeadlineMoves();
7225
+ return {
7226
+ sent: () => {
7227
+ ownAnchorMs = Date.now();
7228
+ laneNotice?.();
7229
+ moves.move();
7230
+ },
7231
+ bound: {
7232
+ atMs: () => Math.max(ownAnchorMs, anchor.sentAtMs() ?? ownAnchorMs) + boundMs,
7233
+ moved: () => Promise.race([moves.moved(), anchor.nextSend()]),
7234
+ },
7235
+ };
7236
+ }
7237
+ /**
7238
+ * `answer`, or a WrunDeadlineError once its send-anchored deadline passes first: one phase per move (`moved()`), each
7239
+ * racing what is left of the deadline the move set (`atMs()`). `onExpired` hears the deadline's own expiry, never the
7240
+ * answer's failure, which rejects as it is (a fetch's own deadline included), so only an answer still out is handed on
7241
+ * as a late read.
7242
+ */
7243
+ async function raceWrunSendDeadline(answer, deadline, label, onExpired) {
7244
+ const answered = answer.then((value) => ({ value }), (error) => ({ error }));
7245
+ for (;;) {
7246
+ let phase;
7247
+ try {
7248
+ phase = await withWrunDeadline(Promise.race([answered, deadline.moved()]), Math.max(0, deadline.atMs() - Date.now()), label);
7249
+ }
7250
+ catch (expired) {
7251
+ // The answer's own failure arrives as a phase: only the deadline rejects here.
7252
+ onExpired?.(expired);
7253
+ throw expired;
7254
+ }
7255
+ if (phase === undefined)
7256
+ continue;
7257
+ if ('error' in phase)
7258
+ throw phase.error;
7259
+ return phase.value;
7260
+ }
7261
+ }
6814
7262
  function wrunDegradedLaneOutcome(error) {
6815
7263
  const cause = error instanceof WrunLaneEmptyAnswer ? error.answer : error instanceof WrunDeadlineError ? 'budget' : 'error';
6816
7264
  // A named data-plane refusal is terminal: the chip says the source is missing, and nothing re-asks it in a loop.
@@ -6841,7 +7289,9 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
6841
7289
  ...(thunks.rowLanes ?? []),
6842
7290
  ];
6843
7291
  const settled = await Promise.allSettled(declared.map(([lane, run]) => {
6844
- policy.onDispatch?.(lane);
7292
+ const laneBudgetMs = typeof policy.budgetMs === 'function' ? policy.budgetMs(lane) : policy.budgetMs;
7293
+ const deadline = wrunLaneSendDeadline(laneBudgetMs ?? 0, policy.capMs);
7294
+ policy.onDispatch?.(lane, deadline.anchor);
6845
7295
  // Raised when the lane's budget runs out: its run no longer waits on it, so a lane asked in pieces asks no
6846
7296
  // further piece (`wrunAskWirePieces`); the asks already out finish into the fetch's cache.
6847
7297
  const abandon = new AbortController();
@@ -6852,13 +7302,14 @@ export async function runWrunSourceLanes(thunks, policy = {}) {
6852
7302
  catch (error) {
6853
7303
  answer = Promise.reject(error);
6854
7304
  }
6855
- const budgetMs = typeof policy.budgetMs === 'function' ? policy.budgetMs(lane) : policy.budgetMs;
6856
- if (budgetMs === undefined)
7305
+ if (laneBudgetMs === undefined)
6857
7306
  return answer;
6858
- return withWrunDeadline(answer, budgetMs, `wrun source lane '${lane}'`).catch((error) => {
6859
- if (error instanceof WrunDeadlineError)
6860
- abandon.abort(error);
6861
- throw error;
7307
+ // One phase per send notice, each racing what is left of the deadline the notice moved to
7308
+ // (`wrunLaneSendDeadline`). Only the budget's own expiry abandons the read and hands it on as a late read: an
7309
+ // answer that failed (its fetch's own deadline included) is no read to join or adopt.
7310
+ return raceWrunSendDeadline(answer, deadline, `wrun source lane '${lane}'`, (expired) => {
7311
+ abandon.abort(expired);
7312
+ policy.onLate?.(lane, answer);
6862
7313
  });
6863
7314
  }));
6864
7315
  const run = { results: {}, outcomes: [], degraded: [] };
@@ -6923,6 +7374,9 @@ function wrunUnservedLaneReason(type, exchange, coin, service) {
6923
7374
  case 'index-mode':
6924
7375
  return `the ${type} source lane answers nothing on ${market} (an index-mode market serves candles and buy/sell volume only)`;
6925
7376
  case 'market-kind':
7377
+ if (checkIsCryptoIndex(exchange)) {
7378
+ return `the ${type} source lane answers nothing on ${market} (a crypto index market serves its value candles only)`;
7379
+ }
6926
7380
  return (`the ${type} source lane answers nothing on ${market} (a forex or commodity market serves no volume ` +
6927
7381
  'profile, buy/sell volume, order book, implied volatility or skew)');
6928
7382
  case 'coin':
@@ -7052,12 +7506,22 @@ function wrunOptionsChainExtrasGoverned(extras) {
7052
7506
  * and the tier the viewer is served now (`governedOptionSummaryTier`, the
7053
7507
  * routing's own rule: the lane's acquisition names it and the legend follows
7054
7508
  * it). Returns the lane's payload extras (`chain*` fields).
7509
+ *
7510
+ * OPTLOAD G5 (OPTLOAD-CHAIN-PLAN section 8): on the OPRA plane the chart's
7511
+ * chain is the plane's own by coin (`wrunHeldOpraPlaneChain`, O1: no chain
7512
+ * directory is read before the lane's ask). Inputs that declare views
7513
+ * (wrun-option-views.util) ask their union of the gateway on every chain, with
7514
+ * the gateway's scope inputs in place of a scope (`chainNearestExpiries`,
7515
+ * `chainMaxContracts`, O2: the gateway sizes B on its page, so no expiry
7516
+ * directory is read here or in the worker); the chain's inputs read views all,
7517
+ * or none.
7055
7518
  */
7056
7519
  async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts) {
7057
- const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues },] = await Promise.all([
7520
+ const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues }, { WRUN_OPTION_VIEWS_ONE_ASK_CODE, wrunHeldOpraPlaneChain, wrunOptionViewLaneFields, wrunOptionViewsOfSource, wrunOptionViewsUnion, },] = await Promise.all([
7058
7521
  import('./sources/opra-option-lanes.util.js'),
7059
7522
  wrunChartHostEnv().market.loadDeribitOptions(),
7060
7523
  wrunChartHostEnv().market.loadOptionsChainVenues(),
7524
+ import('./wrun-option-views.util.js'),
7061
7525
  ]);
7062
7526
  const market = chartMetadata;
7063
7527
  const pick = (value) => (typeof value === 'string' ? value : undefined);
@@ -7070,8 +7534,10 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
7070
7534
  // over the chart's own metadata, its category included: `option_surface` reads the same one). A chain directory's
7071
7535
  // own failure on a chart its plane governs (CME futures; a US stock, ETF or OPRA contract chart under the opra flag)
7072
7536
  // is the decision's evidence for `cme-directory` or `opra-directory` (a service that did not answer, Retry), never a
7073
- // guess at another chain; any other resolver failure fails the run as before.
7074
- const chain = await resolveWrunChartChain(chartMetadata);
7537
+ // guess at another chain; any other resolver failure fails the run as before. On the OPRA plane the chain is the
7538
+ // plane's own by coin, read off the plane itself (O1): no directory read stands before the lane's ask.
7539
+ const held = await wrunHeldOpraPlaneChain(chartMarket.exchange, chartMarket.coin);
7540
+ const chain = held ?? (await resolveWrunChartChain(chartMetadata));
7075
7541
  const { chartSource } = chain;
7076
7542
  const marketLabel = `${pick(market?.exchange) ?? 'currentExchange'}/${pick(market?.symbol) ?? 'currentSymbol'}`;
7077
7543
  const chainInputs = metadata.inputs.filter((input) => metadata.inputSources[input.name]?.source === 'options_chain');
@@ -7108,14 +7574,40 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
7108
7574
  if (resolved === undefined)
7109
7575
  throw new Error(`WRUN ${metadata.id}: no options_chain input to resolve a chain for`);
7110
7576
  const { identity } = resolved;
7577
+ const laneInputs = chainInputs.map((input) => ({
7578
+ expiries: wrunOptionsChainExpiries(metadata.inputSources[input.name]?.expiries),
7579
+ maxCells: input.max_cells,
7580
+ }));
7581
+ // The views each input declares (refused by name before any fetch); one lane reads views for all, or for none.
7582
+ const viewSets = chainInputs.map((input) => wrunOptionViewsOfSource(metadata.inputSources[input.name], { inputName: input.name, sourceClass: 'options_chain' }, 'options_chain'));
7583
+ const firstWithViews = viewSets.findIndex((views) => views !== undefined);
7584
+ const firstWithout = viewSets.findIndex((views) => views === undefined);
7585
+ if (firstWithViews >= 0 && firstWithout >= 0) {
7586
+ throw attachWrunRefusal(new Error(`WRUN ${metadata.id}: inputs '${chainInputs[firstWithViews].name}' and '${chainInputs[firstWithout].name}' read ` +
7587
+ `one options_chain lane, one through views and one whole (${WRUN_OPTION_VIEWS_ONE_ASK_CODE}): declare ` +
7588
+ 'views on both, or on neither'), wrunAuthorRuleSeed(WRUN_OPTION_VIEWS_ONE_ASK_CODE));
7589
+ }
7590
+ if (firstWithViews >= 0) {
7591
+ // A view ask on any chain: the gateway sizes B on its page from the inputs' expiries word (the largest
7592
+ // `nearest:N`, none when one input reads every expiry) and budget (the smallest max_cells) (O2).
7593
+ const nearest = laneInputs.flatMap((input) => (input.expiries?.kind === 'nearest' ? [input.expiries.count] : []));
7594
+ const budgets = laneInputs
7595
+ .map((input) => Number(input.maxCells))
7596
+ .filter((cells) => Number.isFinite(cells) && cells > 0);
7597
+ const viewFields = wrunOptionViewLaneFields('options_chain', wrunOptionViewsUnion(viewSets.filter((views) => views !== undefined)), {
7598
+ ...(nearest.length === laneInputs.length ? { nearestExpiries: Math.max(...nearest) } : {}),
7599
+ ...(budgets.length > 0 ? { maxContracts: Math.floor(Math.min(...budgets)) } : {}),
7600
+ });
7601
+ const viewIdentity = identity.venue === 'cme' || identity.venue === 'opra'
7602
+ ? { ...identity, servedTier: governedOptionSummaryTier(identity.exchange) }
7603
+ : identity;
7604
+ return { ...wrunOptionsChainLaneExtras(viewIdentity), ...viewFields };
7605
+ }
7111
7606
  if (identity.venue !== 'cme' && identity.venue !== 'opra')
7112
7607
  return wrunOptionsChainLaneExtras(identity);
7113
7608
  // A governed chain asks the scope the package's declared appetite fits (`wrunOptionsChainLaneScope`: the smallest
7114
7609
  // max_cells over its chain inputs), sized on the chain's live expiry count.
7115
- const scope = wrunOptionsChainLaneScope(chainInputs.map((input) => ({
7116
- expiries: wrunOptionsChainExpiries(metadata.inputSources[input.name]?.expiries),
7117
- maxCells: input.max_cells,
7118
- })), await wrunGovernedLiveExpiryCount(identity));
7610
+ const scope = wrunOptionsChainLaneScope(laneInputs, await wrunGovernedLiveExpiryCount(identity));
7119
7611
  return wrunOptionsChainLaneExtras({ ...identity, scope, servedTier: governedOptionSummaryTier(identity.exchange) });
7120
7612
  }
7121
7613
  /**
@@ -9279,7 +9771,7 @@ function wrunPrefixIncapacity(context, meta, loadedRows, corroborated, warmup =
9279
9771
  }
9280
9772
  if (wrunRunIntervalSessionOf(context) !== undefined)
9281
9773
  return 'htf';
9282
- const laneClause = wrunPrefixLaneClauseOf(context);
9774
+ const laneClause = wrunPrefixFeedClauseOf(context);
9283
9775
  if (laneClause !== null)
9284
9776
  return `lanes:${laneClause}`;
9285
9777
  const seed = context.sessionSeed;
@@ -9377,7 +9869,7 @@ function planWrunPrefixRun(chartIndex, indicatorId) {
9377
9869
  return skip(incapacity);
9378
9870
  // The options chain lands its snapshot on the build's last row: a window reaching the session's live row would land
9379
9871
  // it there, where the empty build a page reads cannot (the lanes rule's clause the window decides).
9380
- if (wrunPrefixLiveRowRefused(context, decision.window.toMs))
9872
+ if (wrunPrefixFeedsLiveRowRefused(context, decision.window.toMs))
9381
9873
  return skip('lanes:live-row');
9382
9874
  // An exact warm-up session's whole retained evidence against the chart's candles as they stand (C4): a candle the
9383
9875
  // chart revised anywhere its rows rest on hands the page to the whole run, which heals the stale rows too.
@@ -9766,19 +10258,26 @@ function wrunPrefixDegradedPageDetail(lane, outcome) {
9766
10258
  * answer, a row-cache hit whose provenance is not read back, a relay page that still names more) is declined, never
9767
10259
  * landed as a quiet stretch. Nothing is written here: the pages are staged for the commit, every one or none. A
9768
10260
  * degraded lane rejects the prefix without a latch (the data, never the module) and the wave's full run follows.
10261
+ * The daily poll lanes and the row lanes (run-schedule/wrun-prefix-feeds.util) ride the same machinery: a daily lane
10262
+ * asks the days before its buffer from its lookback before the page (none when the buffer reaches back that far), an
10263
+ * asked row lane the page's host bars through the lane's own host-grid read; each degrades on an empty answer only
10264
+ * when the session's buffer holds none either (the page of an old stretch, a lane's horizon past it, reads empty as a
10265
+ * whole run's older bars do).
9769
10266
  */
9770
- async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs) {
10267
+ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs, chartMetadata) {
9771
10268
  const pages = new Map();
9772
- if (plan.builtin.length === 0 && plan.poll.length === 0)
10269
+ if (plan.builtin.length === 0 && plan.poll.length === 0 && plan.daily.length === 0 && plan.rows.length === 0) {
9773
10270
  return { pages };
10271
+ }
9774
10272
  const toTs = beforeTs - 1;
9775
10273
  const deadlineLabel = (type) => `wrun prefix source fetch '${type}' for '${context.fetchKey}'`;
9776
10274
  // A page lands only on an answer the wire completed whole: a synthetic completion (a kicked session, a connection that
9777
10275
  // could not open), a history refusal served empty or a trimmed answer resolves with rows that look like data (none,
9778
10276
  // or the ones collected so far), so the chart's fetch reports its verdict and an incomplete one declines the page.
9779
- const ask = async (type, suffix, payloadExtras, fetchOptions) => {
10277
+ // A window of its own: a daily lane's days, a row lane's tier piece; else the page `[fromMs, beforeTs - 1]`.
10278
+ const ask = async (type, suffix, payloadExtras, fetchOptions, window = { fromTs: fromMs, toTs }) => {
9780
10279
  let verdict;
9781
- const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, type, { symbol: 'currentSymbol', exchange: 'currentExchange', ...payloadExtras }, fromMs, toTs, meta, `${context.fetchKey}-prefix-${suffix}`, false,
10280
+ const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, type, { symbol: 'currentSymbol', exchange: 'currentExchange', ...payloadExtras }, window.fromTs, window.toTs, meta, `${context.fetchKey}-prefix-${suffix}`, false,
9782
10281
  // The full run stamped the legend; a prefix page never restamps it.
9783
10282
  {
9784
10283
  ...fetchOptions,
@@ -9810,29 +10309,30 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs)
9810
10309
  return required ? refuseEmpty(type, rows) : rows;
9811
10310
  };
9812
10311
  }
10312
+ // A lane's own fetch (a relay feed) over a window, whole only when it says so (`onComplete`).
10313
+ const ownPage = async (fetch, kType, extras, window) => {
10314
+ let whole;
10315
+ const answer = wrunPrefixPageAnswerRows(await withWrunDeadline(fetch({
10316
+ extras,
10317
+ fromTs: window.fromTs,
10318
+ toTs: window.toTs,
10319
+ intervalMs: context.intervalMs,
10320
+ onComplete: (complete) => {
10321
+ whole = complete;
10322
+ },
10323
+ }), WRUN_SOURCE_FETCH_DEADLINE_MS, deadlineLabel(kType)), kType);
10324
+ if (whole !== true) {
10325
+ throw new WrunLaneEmptyAnswer('declined', `the ${kType} source answered the page short of its end`);
10326
+ }
10327
+ return answer;
10328
+ };
9813
10329
  thunks.pollLanes = plan.poll.map((instance) => {
9814
10330
  const run = async () => {
9815
10331
  const lane = wrunPollLaneByKey(instance.laneKey);
9816
10332
  const extras = context.acquisition[instance.key] ?? instance.extras;
9817
10333
  const laneFetch = lane.fetch;
9818
- const ownPage = async (fetch) => {
9819
- let whole;
9820
- const answer = wrunPrefixPageAnswerRows(await withWrunDeadline(fetch({
9821
- extras,
9822
- fromTs: fromMs,
9823
- toTs,
9824
- intervalMs: context.intervalMs,
9825
- onComplete: (complete) => {
9826
- whole = complete;
9827
- },
9828
- }), WRUN_SOURCE_FETCH_DEADLINE_MS, deadlineLabel(lane.kType)), lane.kType);
9829
- if (whole !== true) {
9830
- throw new WrunLaneEmptyAnswer('declined', `the ${lane.kType} source answered the page short of its end`);
9831
- }
9832
- return answer;
9833
- };
9834
10334
  const rows = laneFetch
9835
- ? await ownPage(laneFetch)
10335
+ ? await ownPage(laneFetch, lane.kType, extras, { fromTs: fromMs, toTs })
9836
10336
  : await ask(lane.kType, wrunPrefixPollSuffix(instance), extras, wrunPollLaneFetchOptions(lane));
9837
10337
  if (!wrunPollLaneRequired(context.metadata, instance))
9838
10338
  return rows;
@@ -9844,9 +10344,75 @@ async function acquireWrunPrefixLanePages(context, meta, plan, fromMs, beforeTs)
9844
10344
  };
9845
10345
  return [instance.key, run];
9846
10346
  });
10347
+ // A daily lane: the days the session's buffer does not hold yet, from the lane's lookback before the page's first bar
10348
+ // (a whole run's own ask start for the wider window) up to the buffer's first row, cut strictly before it; nothing when
10349
+ // the buffer reaches back that far. Its empty and valueless rules read what the window reads: the page and the buffer.
10350
+ thunks.pollLanes = [
10351
+ ...thunks.pollLanes,
10352
+ ...plan.daily.map((instance) => {
10353
+ const run = async () => {
10354
+ const lane = wrunPollLaneByKey(instance.laneKey);
10355
+ const extras = context.acquisition[instance.key] ?? instance.extras;
10356
+ const heldFirstTs = wrunPrefixDailyHeldFirstTs(context, instance);
10357
+ const window = {
10358
+ fromTs: wrunPollLaneFetchFrom(lane, fromMs),
10359
+ toTs: Number.isFinite(heldFirstTs) ? heldFirstTs - 1 : toTs,
10360
+ };
10361
+ const laneFetch = lane.fetch;
10362
+ const answered = window.fromTs > window.toTs
10363
+ ? []
10364
+ : laneFetch
10365
+ ? await ownPage(laneFetch, lane.kType, extras, window)
10366
+ : await ask(lane.kType, wrunPrefixPollSuffix(instance), extras, wrunPollLaneFetchOptions(lane), window);
10367
+ const rows = Number.isFinite(heldFirstTs) ? answered.filter((row) => Number(row[0]) < heldFirstTs) : answered;
10368
+ if (!wrunPollLaneRequired(context.metadata, instance))
10369
+ return rows;
10370
+ const read = [...rows, ...(context.pollLaneRows?.[instance.key] ?? [])];
10371
+ refuseEmpty(lane.kType, read);
10372
+ const valueless = wrunPollLaneValuelessInput(context.metadata, instance, lane, read);
10373
+ return valueless === undefined
10374
+ ? rows
10375
+ : refuseEmpty(lane.kType, [], `answered no value for field '${valueless.field}'`);
10376
+ };
10377
+ return [instance.key, run];
10378
+ }),
10379
+ ];
10380
+ // An asked row lane: the page's host bars through the lane's own host-grid read (the tier rule, the horizon and the
10381
+ // partial bars decide per bar at the clock, as a whole run's asks do), with the acquisition a whole run plans now (the
10382
+ // instance's extras, the plane's routed tier). A lane whose empty answer is broken degrades only when the session's
10383
+ // buffer holds no row either.
10384
+ const barGrid = liveBucketVenueOf(chartMetadata);
10385
+ const pageGrid = {
10386
+ barOpens: liveBucketStartsInRange(fromMs, toTs, context.intervalMs, barGrid),
10387
+ intervalMs: context.intervalMs,
10388
+ barGrid,
10389
+ nowMs: Date.now(),
10390
+ };
10391
+ thunks.rowLanes = plan.rows.map((instance) => {
10392
+ const run = async () => {
10393
+ const lane = wrunRowLaneByKey(instance.laneKey);
10394
+ if (lane === undefined)
10395
+ throw new WrunLaneEmptyAnswer('declined', `the row lane ${instance.laneKey} is unknown`);
10396
+ const extras = lane.governed === 'opra'
10397
+ ? { ...instance.extras, ...wrunOpraLanePayloadFields(governedMarketDataTier('OPRA')) }
10398
+ : wrunRowLaneChainAsk(lane, instance.extras, governedMarketDataTier);
10399
+ const laneFetch = lane.fetch;
10400
+ const landed = (await fetchWrunRowLaneRows(lane, extras, pageGrid, { fromTs: fromMs, toTs: beforeTs }, async (askExtras, askFrom, askTo) => (laneFetch
10401
+ ? await ownPage(laneFetch, lane.kType, askExtras, { fromTs: askFrom, toTs: askTo })
10402
+ : await ask(lane.kType, wrunPrefixRowSuffix(instance), askExtras, wrunRowLaneFetchOptions(lane), {
10403
+ fromTs: askFrom,
10404
+ toTs: askTo,
10405
+ }))));
10406
+ const required = wrunRowLaneRequired(context.metadata, instance);
10407
+ return required && (context.rowLaneRows?.[instance.key]?.length ?? 0) === 0
10408
+ ? refuseEmpty(lane.kType, landed)
10409
+ : landed;
10410
+ };
10411
+ return [instance.key, run];
10412
+ });
9847
10413
  // A page lane on a gate plane another screen holds is never sent (wrun-options-stop.util): the page declines at once
9848
10414
  // instead of waiting out its budget, and the wave's full run follows, which says why.
9849
- const gatedThunks = wrunGateLatchedThunks(thunks, wrunLaneGatePlanes({ pollLanes: plan.poll, rowLanes: [] }), gateSessionHeldElsewhere);
10415
+ const gatedThunks = wrunGateLatchedThunks(thunks, wrunLaneGatePlanes({ pollLanes: [...plan.poll, ...plan.daily], rowLanes: plan.rows }), gateSessionHeldElsewhere);
9850
10416
  const laneRun = await runWrunSourceLanes(gatedThunks, {
9851
10417
  budgetMs: resolveSecondarySourceBudgetMs({ fromMs, toMs: beforeTs, intervalMs: context.intervalMs }),
9852
10418
  });
@@ -10167,7 +10733,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10167
10733
  const store = useChartStore();
10168
10734
  const chartMetadata = store.mergedAllCharts[chartIndex]?.metadata;
10169
10735
  // The chart's forming bar on the server clock when the session lands a leg on the chart's bars (a replay
10170
- // session's chart has none); a page builds no leg today (`planWrunPrefixLanes` refuses them).
10736
+ // session's chart has none); a page builds no leg today (`planWrunPrefixFeeds` refuses them).
10171
10737
  const formingBarTs = context.replay !== true && wrunLandsLegsOnBars(context.pinnedLegs, Object.keys(context.tradeLegRows ?? {}))
10172
10738
  ? await wrunFormingBarTsOf(chartIndex, context.intervalMs, chartMetadata)
10173
10739
  : null;
@@ -10233,7 +10799,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10233
10799
  // The rows the guest evaluates: the head, then the window (the chart's missing bars kept inside it).
10234
10800
  const computeRows = wrunChartCandleRowsAfterHead(headRows, windowRows);
10235
10801
  // The lanes rule again over the session as it stands (the plan's): what the page asks besides the book.
10236
- const laneVerdict = planWrunPrefixLanes(context);
10802
+ const laneVerdict = planWrunPrefixFeeds(context);
10237
10803
  if ('refused' in laneVerdict) {
10238
10804
  return wrunPrefixRejected('stale', `the lanes rule refuses the session now (lanes:${laneVerdict.refused})`);
10239
10805
  }
@@ -10246,13 +10812,13 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10246
10812
  context.acquisition.book !== undefined
10247
10813
  ? fetchWrunPrefixBookRows(context, meta, window.fromMs, window.toMs)
10248
10814
  : Promise.resolve(context.bookRows !== undefined ? [] : undefined),
10249
- acquireWrunPrefixLanePages(context, meta, lanePlan, window.fromMs, firstRowTs),
10815
+ acquireWrunPrefixLanePages(context, meta, lanePlan, window.fromMs, firstRowTs, chartMetadata),
10250
10816
  ]);
10251
10817
  // A lane whose page could not be had (declined, failed, out of budget, or empty where the full run degrades it):
10252
10818
  // the data, never the module. Nothing staged lands; the wave's full run follows.
10253
10819
  if ('degraded' in lanePages)
10254
10820
  return wrunPrefixRejected('stale', lanePages.degraded);
10255
- const laneWindow = wrunPrefixWindowLanes(context, lanePlan, lanePages.pages, firstRowTs, window.toMs);
10821
+ const laneWindow = wrunPrefixFeedWindowLanes(context, lanePlan, lanePages.pages, firstRowTs, window.toMs);
10256
10822
  const chartExchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : undefined;
10257
10823
  const clock = { intervalMs: context.intervalMs, nowMs: Date.now() };
10258
10824
  const sourceRows = {
@@ -10426,7 +10992,7 @@ async function prepareWrunPrefixRun(runTarget, tc, meta, window, landings, start
10426
10992
  ...(context.bookRows !== undefined
10427
10993
  ? { book: context.bookRows }
10428
10994
  : {}),
10429
- lanes: wrunPrefixHeldLanes(context, lanePlan),
10995
+ lanes: wrunPrefixFeedHeldLanes(context, lanePlan),
10430
10996
  children: rowCanvases.map((child) => ({ childId: childIdOf(child), rows: mountedChildRows(child) })),
10431
10997
  handles: mountedCohort.snapshot,
10432
10998
  };
@@ -10757,7 +11323,7 @@ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
10757
11323
  return snapshotsStale;
10758
11324
  // Every lane the page asked, spliced in front of the session's rows as its buffers stand now: decided before anything
10759
11325
  // applies, all or none (a page landing without one lane's rows would be computed without them at the next reseed).
10760
- const laneSplice = wrunPrefixLaneSplice(context, prepared.lanePlan, prepared.lanePages, prepared.firstRowTs);
11326
+ const laneSplice = wrunPrefixFeedSplice(context, prepared.lanePlan, prepared.lanePages, prepared.firstRowTs);
10761
11327
  if (laneSplice === null) {
10762
11328
  return wrunPrefixRejected('stale', 'a lane the page asked has no session buffer to splice', {
10763
11329
  firstMismatchTs: null,
@@ -10830,7 +11396,7 @@ function commitWrunPrefixRun(prepared, tc, meta, chartOwner, indicatorId) {
10830
11396
  // Every other lane the page asked: its page, then the session's rows from the session's first row on (the window
10831
11397
  // split's boundary). The tape and the options chain asked nothing and keep the session's rows; the reconcile's
10832
11398
  // watermarks (`coveredThroughTs`) stay as they are (they speak for the live edge, never for a page).
10833
- applyWrunPrefixLaneSplice(context, laneSplice);
11399
+ applyWrunPrefixFeedSplice(context, laneSplice);
10834
11400
  if (warmup !== undefined && landedEvidence !== undefined) {
10835
11401
  // The evidence follows the guests that computed the landed rows.
10836
11402
  context.candleEvidence = landedEvidence;
@@ -11009,5 +11575,12 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
11009
11575
  lookbackBars: wrunTwinLookbackBars(meta.settings) ?? (await wrunTwinOriginalLookbackBars(meta.settings, context.intervalMs)),
11010
11576
  unsettledLanes: new Set(),
11011
11577
  planGeneration: prepared.planGeneration,
11578
+ // Where the history the session read begins: its row lanes', unless it read another source beside the candles (a
11579
+ // pinned leg, or any lane its acquisitions name that is no row lane).
11580
+ historySources: {
11581
+ rowLanes: context.rowLanes ?? [],
11582
+ readsOtherSources: (context.pinnedLegs?.length ?? 0) > 0 ||
11583
+ Object.keys(context.acquisition).some((lane) => !isWrunRowLaneId(lane)),
11584
+ },
11012
11585
  });
11013
11586
  }