@orangecharts/wrun-chart-host 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +67 -4
  4. package/dist/constants/governed-exchanges.constants.d.ts +12 -0
  5. package/dist/constants/governed-exchanges.constants.js +16 -0
  6. package/dist/constants/option-venues.constants.d.ts +2 -2
  7. package/dist/host-env.d.ts +1 -9
  8. package/dist/host-ports.types.d.ts +36 -7
  9. package/dist/index.d.ts +6 -1
  10. package/dist/index.js +6 -1
  11. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  12. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  13. package/dist/interfaces/cme-realtime.interface.js +6 -3
  14. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  15. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  16. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  17. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  18. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  19. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
  20. package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
  21. package/dist/market-data/billing.interface.d.ts +86 -12
  22. package/dist/market-data/billing.interface.js +23 -4
  23. package/dist/market-data/venue.d.ts +65 -2
  24. package/dist/market-data/venues/index.d.ts +135 -5
  25. package/dist/market-data/venues/index.js +2 -1
  26. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  27. package/dist/market-data/venues/opra.d.ts +2 -2
  28. package/dist/market-data/venues/opra.js +5 -2
  29. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  30. package/dist/market-data/venues/stocks.d.ts +130 -0
  31. package/dist/market-data/venues/stocks.js +117 -0
  32. package/dist/settings-templates/footprint-rows.js +35 -2
  33. package/dist/settings-templates/form-rows.d.ts +2 -1
  34. package/dist/settings-templates/indicator-fields.js +34 -4
  35. package/dist/settings-templates/tool-rules.d.ts +12 -5
  36. package/dist/settings-templates/tool-rules.js +11 -5
  37. package/dist/settings-templates/tool-tables.generated.js +4 -0
  38. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  39. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  40. package/dist/utility/chart/cme-realtime.util.js +10 -0
  41. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  42. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  43. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  44. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  45. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  46. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  47. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  48. package/dist/utility/chart/index-host-tier.util.js +7 -2
  49. package/dist/utility/chart/index-mode-admission.util.js +25 -11
  50. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  51. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
  52. package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
  53. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  54. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  55. package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
  56. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  57. package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
  58. package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
  59. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  60. package/dist/utility/chart/live-bucket.util.js +85 -27
  61. package/dist/utility/chart/marketKind.util.js +5 -0
  62. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  63. package/dist/utility/chart/mixed-mode.util.js +14 -0
  64. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  65. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  66. package/dist/utility/chart/rth-session.util.d.ts +9 -8
  67. package/dist/utility/chart/rth-session.util.js +23 -20
  68. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  69. package/dist/utility/chart/trading-day.util.js +59 -0
  70. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  71. package/dist/utility/chart/window-owner.leaf.js +45 -3
  72. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  73. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  74. package/dist/utility/intl-locale.util.js +5 -0
  75. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  76. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  77. package/dist/utility/v2/gate-plane.util.js +30 -4
  78. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  79. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  80. package/dist/utility/v2/stocks-governed.util.js +34 -0
  81. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  82. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  83. package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
  84. package/dist/utility/wrun/derived-roots.util.js +3 -23
  85. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
  86. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  87. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  88. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
  89. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
  90. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
  91. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
  92. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
  93. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  94. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
  95. package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
  96. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  97. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  98. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  99. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  100. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  101. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  102. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  103. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  104. package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
  105. package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
  106. package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
  107. package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
  108. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  109. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  110. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
  111. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
  112. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  113. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  114. package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
  115. package/dist/utility/wrun/wrun-option-views.util.js +391 -50
  116. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  117. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  118. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
  119. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  120. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  121. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
  122. package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
  123. package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
  124. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  125. package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
  126. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  127. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  128. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  129. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  130. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  131. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  132. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  133. package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
  134. package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
  135. package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
  136. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
  137. package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
  138. package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
  139. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  140. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  141. package/dist/workers/constants/socket-slots.d.ts +91 -6
  142. package/dist/workers/constants/socket-slots.js +85 -6
  143. package/package.json +11 -11
  144. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
  145. package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
@@ -1,16 +1,27 @@
1
1
  /**
2
- * CME licensing allows governed market data in first-party display features
3
- * only: user-authored kScript scripts must not consume it, while the built-in
2
+ * CME governed market data feeds first-party display features by default:
3
+ * user-authored kScript scripts must not consume it, while the built-in
4
4
  * technical scripts, the converted-script corpus and OpenMarket's own official
5
- * Indicator packages (all first-party) keep working. The OPRA licence (US
6
- * equity and index options) covers user-authored scripting too, in the
7
- * browser and on OpenMarket's servers (Kyle 2026-10-27, the signed set),
8
- * behind the `opra-user-scripts` flag: while it is lit, a user run the
9
- * browser executes reads OPRA like a first-party one (`isOpraUserScriptRun`,
10
- * ONE decision for the display wall, the data wall and the engine policy; the
11
- * CME plane never reads it). The data tier belongs to the viewer, never to the
12
- * script: the browser lane reads through the viewer's own gate sockets. This
13
- * module is the single decider for both planes.
5
+ * Indicator packages (all first-party) keep working. The CME plane has its own
6
+ * gate, `cme-user-scripts` (cme-user-scripts-gate.util): while it is open (the
7
+ * flag lit AND the viewer entitled to CME data), a user run the browser
8
+ * executes reads CME like a first-party one (`isCmeUserScriptRun`, ONE
9
+ * decision for the display wall, the data wall and the engine policy), the
10
+ * browser lane only: never a hosted (Cloud) run or a protected script, and
11
+ * never read server-side (kscript-backend denies CME to every user run
12
+ * whatever the gate says). The OPRA licence (US equity and index options) covers
13
+ * user-authored scripting too, in the browser and on OpenMarket's servers
14
+ * (Kyle 2026-10-27, the signed set), behind the `opra-user-scripts` flag:
15
+ * while it is lit, a user run the browser executes reads OPRA like a
16
+ * first-party one (`isOpraUserScriptRun`, the same three doors). The US stocks
17
+ * tape is open to user-authored indicators too, in the browser and on the
18
+ * cloud lane (Kyle 2026-10-29), on the tapes STOCKS_TAPE_SCRIPTING_VENUES
19
+ * lists, the one compliance switch (`isStocksTapeReadableKScriptRun`); a tape
20
+ * it leaves out (NASDAQ_TAPE until the UTP derived-data answer) stays
21
+ * first-party only. Each plane reads its own gate alone: no plane's decision
22
+ * opens another. The data tier belongs to the viewer, never to the script: the
23
+ * browser lane reads through the viewer's own gate sockets. This module is the
24
+ * single decider for every plane.
14
25
  * Every run door (add, mount, protected fetch, cache paint, alerts arm,
15
26
  * editor Run), the per-payload data guard in titan-charts dataFetch, and the
16
27
  * engine policy descriptor consult it; nothing else may re-derive provenance
@@ -21,8 +32,9 @@
21
32
  */
22
33
  import { CME_GOVERNED_EXCHANGES } from '../../interfaces/cme-realtime.interface.js';
23
34
  import { OPRA_GOVERNED_EXCHANGES } from '../../interfaces/opra-realtime.interface.js';
35
+ import { STOCKS_GOVERNED_EXCHANGES, STOCKS_TAPE_SCRIPTING_VENUES } from '../../interfaces/stocks-realtime.interface.js';
24
36
  import { isCmeFuturesPolicyActive } from './marketKind.util.js';
25
- import { isOpraGoverned } from '../v2/gate-plane.util.js';
37
+ import { isOpraGoverned, isStocksTapeGoverned } from '../v2/gate-plane.util.js';
26
38
  import { isConvertedScriptId } from '../../constants/scriptEditor/converted-script-id.leaf.js';
27
39
  import { isTempScriptId } from '../scriptEditor/temp-script-id.util.js';
28
40
  import { TECHNICAL_INDICATOR_SCRIPT_KEY_SET } from '../../constants/scriptEditor/technicalIndicatorScriptKeys.constants.js';
@@ -34,6 +46,8 @@ import { isWrunOfficialPackage } from '../wrun/wrun-official-scope.leaf.js';
34
46
  import { builtinIdentityOf } from './builtin-identity.util.js';
35
47
  // Dependency-free: the flag store hands the flag's live readers to it (no store import here).
36
48
  import { isOpraUserScriptsFlagOn } from './opra-user-scripts-gate.util.js';
49
+ // Dependency-free too: the flag store and the web's CME entitlement hand their live readers to it.
50
+ import { isCmeUserScriptsFlagOn, isCmeUserScriptsGateOpen } from './cme-user-scripts-gate.util.js';
37
51
  // Leaf module (no imports): the row source a record runs on (a Cloud record rides the socket source).
38
52
  import { wrunRowSourceKindOf } from '../wrun/wrun-overlay-identity.util.js';
39
53
  // Near-leaf (the identity leaf only): the migration on read of a record persisted before lane parity wave 3. The
@@ -152,16 +166,18 @@ export function isFirstPartyKScriptRun(settings) {
152
166
  return isCmeFirstPartyOfficialDocId(settings?.customScriptId);
153
167
  }
154
168
  /**
155
- * The lane a user run reads OPRA on, if any: the browser's (`browser`: a script or Indicator draft the viewer wrote, a
156
- * community document or package, anything unrecognized, run in this browser) or the hosted Cloud lane's (`cloud`: the
157
- * record on the socket row source, `wrunRowSourceKindOf`, read through the migration on read, `wrunCloudRecordOf`, so
158
- * the wave-3 record, `wrunRunTarget: 'cloud'` with no `wrunRef`, and a record persisted before wave 3, `wrunRef`,
159
- * alike). Undefined for a first-party run and for a protected script (the engine lane has no actor path). The record is
169
+ * The lane a user run reads a gate plane on (OPRA, the US stocks tape), if any: the browser's (`browser`: a script or
170
+ * Indicator draft the viewer wrote, a community document or package, anything unrecognized, run in this browser) or
171
+ * the hosted Cloud lane's (`cloud`: the record on the socket row source, `wrunRowSourceKindOf`, read through the
172
+ * migration on read, `wrunCloudRecordOf`, so the wave-3 record, `wrunRunTarget: 'cloud'` with no `wrunRef`, and a
173
+ * record persisted before wave 3, `wrunRef`, alike). Undefined for a first-party run and for a protected script (the engine lane has no actor path). The record is
160
174
  * read through that migration before the protected flag: a record persisted before wave 3 still carries the wave-2
161
175
  * hosted mount's keys (`isProtectedScript: true` beside `wrunRef`, wrun-cloud-row-compat.util) until its adoption, and
162
- * the migration takes the flag off, so it reads as the Cloud record it is, never a protected script.
176
+ * the migration takes the flag off, so it reads as the Cloud record it is, never a protected script. Both planes read
177
+ * this one lane read (the CME plane's candidate is its `browser` answer too, `isCmeUserScriptCandidate`), so the lane
178
+ * predicates stay counted once (src/utility/wrun/wrun-lane-predicates.allowlist.json).
163
179
  */
164
- function opraUserRunLane(settings) {
180
+ function userRunLane(settings) {
165
181
  if (!settings || isFirstPartyKScriptRun(settings))
166
182
  return undefined;
167
183
  const record = wrunCloudRecordOf(settings) ?? settings;
@@ -170,13 +186,13 @@ function opraUserRunLane(settings) {
170
186
  return wrunRowSourceKindOf(record) === 'socket' ? 'cloud' : 'browser';
171
187
  }
172
188
  /**
173
- * A user run the browser executes (`opraUserRunLane` `browser`): neither a hosted Cloud run nor a protected script,
189
+ * A user run the browser executes (`userRunLane` `browser`): neither a hosted Cloud run nor a protected script,
174
190
  * which run on a server lane that reads governed data through its own gate identity (UW-PARITY H3), so a browser flag
175
191
  * never opens a plane to them. The runs the `opra-user-scripts` flag opens the OPRA plane to (`isOpraUserScriptRun`);
176
192
  * read without the flag where a door must know a decision waits on it (the flag's hydration).
177
193
  */
178
194
  export function isOpraUserScriptCandidate(settings) {
179
- return opraUserRunLane(settings) === 'browser';
195
+ return userRunLane(settings) === 'browser';
180
196
  }
181
197
  /**
182
198
  * Whether a hosted (Cloud) user run's lane reads the OPRA chain of a US stock or ETF chart (contract
@@ -186,7 +202,7 @@ export function isOpraUserScriptCandidate(settings) {
186
202
  * stays refused by the display wall) and never a stock twin's chain (the cloud reads the chart's own market).
187
203
  */
188
204
  export function isOpraCloudChainRun(settings) {
189
- return isOpraUserScriptsFlagOn() && opraUserRunLane(settings) === 'cloud';
205
+ return isOpraUserScriptsFlagOn() && userRunLane(settings) === 'cloud';
190
206
  }
191
207
  /** The words the OPRA contract-chart wall shows a user run it refuses (web locale keys, `opraContractChartWallKey`). */
192
208
  export const OPRA_USER_SCRIPT_WALL_KEY = 'indicators.opra.userScriptNotSupported';
@@ -199,7 +215,7 @@ export const OPRA_CLOUD_CONTRACT_CHART_WALL_KEY = 'indicators.opra.cloudOnContra
199
215
  * is the walls' decision (`isKScriptDisplayBlockedOnExchange`, `isOpraReadableKScriptRun`).
200
216
  */
201
217
  export function opraContractChartWallKey(settings) {
202
- return opraUserRunLane(settings) === 'cloud' ? OPRA_CLOUD_CONTRACT_CHART_WALL_KEY : OPRA_USER_SCRIPT_WALL_KEY;
218
+ return userRunLane(settings) === 'cloud' ? OPRA_CLOUD_CONTRACT_CHART_WALL_KEY : OPRA_USER_SCRIPT_WALL_KEY;
203
219
  }
204
220
  /**
205
221
  * Whether the OPRA plane is open to this user run. The ONE decision every OPRA door reads, directly or through the
@@ -222,6 +238,72 @@ export function isOpraUserScriptRun(settings) {
222
238
  export function isOpraReadableKScriptRun(settings) {
223
239
  return mayReadOpra({ official: isFirstPartyKScriptRun(settings), opraUserScripts: isOpraUserScriptRun(settings) });
224
240
  }
241
+ /**
242
+ * Whether a run may read a US stocks tape open to user scripting (`STOCKS_TAPE_SCRIPTING_VENUES`): every first-party
243
+ * run, a user run the browser executes and a hosted (Cloud) user run (`userRunLane`), the lanes Kyle opened on
244
+ * 2026-10-29, like OPRA since its launch and on the cloud lane too. A protected script keeps its lane's rule: the
245
+ * engine lane has no actor path, so a user's protected script stays refused as on every gate plane. The tier is the
246
+ * gate's per socket (delayed 905 s for everyone today), never the script's, and no alert reads the tape whatever this
247
+ * answers (opra-alert-door.util `stocks-closed`). A tape the list leaves out never reads this: it stays first-party
248
+ * only.
249
+ */
250
+ export function isStocksTapeReadableKScriptRun(settings) {
251
+ return isFirstPartyKScriptRun(settings) || userRunLane(settings) !== undefined;
252
+ }
253
+ /**
254
+ * A user run the browser executes (`userRunLane` `browser`, the OPRA plane's candidate too): the runs the
255
+ * `cme-user-scripts` gate opens the CME plane to (`isCmeUserScriptRun`). A hosted (Cloud) record and a protected script
256
+ * never qualify, whatever the gate says: CME chart studies run in the browser alone, and the server
257
+ * lanes deny CME to every user run. Read without the gate where a door must know a decision waits on it (the flag's
258
+ * hydration, the lifecycle that stops a running study).
259
+ */
260
+ export function isCmeUserScriptCandidate(settings) {
261
+ return userRunLane(settings) === 'browser';
262
+ }
263
+ /**
264
+ * Whether the CME plane is open to this user run. The ONE decision every CME door reads, directly or through the walls
265
+ * below: the display wall, the data wall (the dataFetch door, the protected pre-flight, the cache paint) and the engine
266
+ * policy. The OPRA plane never reads it.
267
+ *
268
+ * Open to a browser user run (`isCmeUserScriptCandidate`) while the `cme-user-scripts` gate is open: the flag lit AND
269
+ * the viewer entitled to CME data (cme-user-scripts-gate.util, both read live). The tier follows the viewer, never the
270
+ * run: the browser lane reads through the viewer's own gate sockets. The gate is read first: while it is closed (the
271
+ * default, and every worker, guest and store-less context) no record is read at all.
272
+ */
273
+ export function isCmeUserScriptRun(settings) {
274
+ return isCmeUserScriptsGateOpen() && isCmeUserScriptCandidate(settings);
275
+ }
276
+ /** Whether a run may consume the CME plane's data: every first-party run, and a user run the `cme-user-scripts` gate
277
+ * opened it to (`isCmeUserScriptRun`). */
278
+ export function isCmeReadableKScriptRun(settings) {
279
+ return isFirstPartyKScriptRun(settings) || isCmeUserScriptRun(settings);
280
+ }
281
+ /** The words a door shows a user run the CME wall refuses (web locale keys, `cmeUserScriptWallKey`), and the
282
+ * lifecycle's words for a study a closing gate stopped in place, its source kept (`CME_STUDY_STOPPED_KEY`: the
283
+ * viewer's access moved; `CME_STUDIES_OFF_KEY`: the flag went dark). */
284
+ export const CME_USER_SCRIPT_WALL_KEY = 'indicators.errors.CME_USER_SCRIPT_NOT_SUPPORTED';
285
+ export const CME_CLOUD_WALL_KEY = 'indicators.cme.cloudNotSupported';
286
+ export const CME_ENTITLEMENT_REQUIRED_KEY = 'indicators.cme.termsRequired';
287
+ export const CME_STUDY_STOPPED_KEY = 'indicators.cme.studyStopped';
288
+ export const CME_STUDIES_OFF_KEY = 'indicators.cme.studiesOff';
289
+ /**
290
+ * The words every door that refuses a user run on CME shows (the add toast, Door A; the chip, Door H; the editor's
291
+ * Run), picked by the run's lane like `opraContractChartWallKey`. While the flag is dark every lane reads today's words
292
+ * (`CME_USER_SCRIPT_WALL_KEY`): the feature does not exist for that viewer, so no door names a browser lane it cannot
293
+ * offer. Under a lit flag a hosted (Cloud) record or a protected script has no CME path (`CME_CLOUD_WALL_KEY`: CME chart
294
+ * studies run in the browser), and a run the browser executes is refused only for the viewer's
295
+ * entitlement (`CME_ENTITLEMENT_REQUIRED_KEY`: the CME data terms). A first-party run is never this wall's (the doors
296
+ * word the curation themselves) and reads today's words. Words only: whether the door opens is the walls' decision
297
+ * (`isKScriptDisplayBlockedOnExchange`, `isCmeReadableKScriptRun`).
298
+ */
299
+ export function cmeUserScriptWallKey(settings) {
300
+ if (!isCmeUserScriptsFlagOn())
301
+ return CME_USER_SCRIPT_WALL_KEY;
302
+ const lane = userRunLane(settings);
303
+ if (lane === 'browser')
304
+ return CME_ENTITLEMENT_REQUIRED_KEY;
305
+ return lane === 'cloud' || !isFirstPartyKScriptRun(settings) ? CME_CLOUD_WALL_KEY : CME_USER_SCRIPT_WALL_KEY;
306
+ }
225
307
  /** BLOCKING semantics over a source exchange (string, or the array form with .some()). */
226
308
  function payloadTouches(exchange, governed) {
227
309
  if (Array.isArray(exchange))
@@ -236,9 +318,29 @@ export function payloadTouchesCmeVenue(exchange) {
236
318
  export function payloadTouchesOpraVenue(exchange) {
237
319
  return payloadTouches(exchange, isOpraGoverned);
238
320
  }
321
+ /** Whether a payload names a US stocks tape venue (NYSE_TAPE, NYSE_ARCA_TAPE, NASDAQ_TAPE: the stocks gate's plane;
322
+ * a listing venue's plain code, NASDAQ, is the free lane and never one). */
323
+ export function payloadTouchesStocksTapeVenue(exchange) {
324
+ return payloadTouches(exchange, isStocksTapeGoverned);
325
+ }
326
+ /** The tapes open to user scripting (the compliance switch), as normalized codes. */
327
+ const STOCKS_TAPE_SCRIPTING_SET = new Set(STOCKS_TAPE_SCRIPTING_VENUES);
328
+ /** Whether an exchange is a tape still closed to user scripting (governed, and not in STOCKS_TAPE_SCRIPTING_VENUES). */
329
+ function isClosedStocksTape(code) {
330
+ return isStocksTapeGoverned(code) && !STOCKS_TAPE_SCRIPTING_SET.has(code.toUpperCase());
331
+ }
332
+ /**
333
+ * Whether a payload names a US stocks tape still closed to user scripting: NASDAQ_TAPE (Tape C) until the UTP
334
+ * derived-data answer adds it to STOCKS_TAPE_SCRIPTING_VENUES. Every user run is refused there, as on CME; the provenance-blind
335
+ * doors (the editor's paused Run) read it beside the CME predicate.
336
+ */
337
+ export function payloadTouchesClosedStocksTapeVenue(exchange) {
338
+ return payloadTouches(exchange, isClosedStocksTape);
339
+ }
239
340
  /**
240
341
  * Whether a source exchange (string or the multi-exchange array form) touches
241
- * a governed venue on any gate plane (CME futures, OPRA options).
342
+ * a governed venue on any gate plane (CME futures, OPRA options, the US
343
+ * stocks tape).
242
344
  * Deliberately NOT governed-route.util's isGovernedExchange /
243
345
  * isGovernedReaderPayload: their array form uses .every() because that is
244
346
  * ROUTING semantics (a mixed multi-exchange metadata query must keep the
@@ -246,7 +348,7 @@ export function payloadTouchesOpraVenue(exchange) {
246
348
  * governed leg must block, so the array form is .some().
247
349
  */
248
350
  export function payloadTouchesGovernedVenue(exchange) {
249
- return payloadTouchesCmeVenue(exchange) || payloadTouchesOpraVenue(exchange);
351
+ return (payloadTouchesCmeVenue(exchange) || payloadTouchesOpraVenue(exchange) || payloadTouchesStocksTapeVenue(exchange));
250
352
  }
251
353
  /**
252
354
  * DATA-wall door predicate: user-authored run targeting a governed venue.
@@ -255,12 +357,24 @@ export function payloadTouchesGovernedVenue(exchange) {
255
357
  * first-party officials legitimately pass. The OPERATIONAL doors (add, mount,
256
358
  * teardown, resubscribe, self-heal, suite/layout/copy apply) consult
257
359
  * isKScriptDisplayBlockedOnExchange below instead, which is a strict superset
258
- * of this predicate. Per plane: a CME leg blocks every user run; an OPRA leg
259
- * blocks a user run unless the `opra-user-scripts` flag opened the plane to it
260
- * (`isOpraReadableKScriptRun`).
360
+ * of this predicate. Per plane, each by its own decision: a CME leg blocks a
361
+ * user run unless the `cme-user-scripts` gate opened the plane to it
362
+ * (`isCmeReadableKScriptRun`); an OPRA leg blocks a user run unless the
363
+ * `opra-user-scripts` flag opened the plane to it (`isOpraReadableKScriptRun`);
364
+ * a US stocks tape leg blocks a protected user script on a tape open to user
365
+ * scripting (`isStocksTapeReadableKScriptRun`) and every user run on a tape
366
+ * still closed to it (NASDAQ_TAPE). A mixed payload is served only when every
367
+ * plane it touches is open to the run.
261
368
  */
262
369
  export function isUserKScriptBlockedOnExchange(exchange, settings) {
263
- if (payloadTouchesCmeVenue(exchange) && !isFirstPartyKScriptRun(settings))
370
+ if (payloadTouchesCmeVenue(exchange) && !isCmeReadableKScriptRun(settings))
371
+ return true;
372
+ // The US stocks tape (Kyle 2026-10-29): user-authored indicators read the tapes STOCKS_TAPE_SCRIPTING_VENUES lists,
373
+ // in the browser and on the cloud lane; a tape it leaves out (NASDAQ_TAPE, the UTP derived-data answer pending)
374
+ // stays first-party only. A mixed payload is judged per leg (.some): one closed tape refuses it.
375
+ if (payloadTouchesClosedStocksTapeVenue(exchange) && !isFirstPartyKScriptRun(settings))
376
+ return true;
377
+ if (payloadTouchesStocksTapeVenue(exchange) && !isStocksTapeReadableKScriptRun(settings))
264
378
  return true;
265
379
  return payloadTouchesOpraVenue(exchange) && !isOpraReadableKScriptRun(settings);
266
380
  }
@@ -290,12 +404,19 @@ export function isUserKScriptBlockedOnExchange(exchange, settings) {
290
404
  * the add route mounts on a governed venue; a twin of any other built-in
291
405
  * carried there (an in-place symbol switch, a restore, a paste or copy) is
292
406
  * blocked. User-provenance
293
- * runs are never venue-approved, so this is a strict superset of
294
- * isUserKScriptBlockedOnExchange. Fail-closed both ways: an unrecognized
407
+ * runs are never venue-approved by the curation, so this is a strict superset
408
+ * of isUserKScriptBlockedOnExchange. Fail-closed both ways: an unrecognized
295
409
  * official blocks, and provenance spoofing via script-input names is already
296
410
  * neutralized upstream by KSCRIPT_RESERVED_PROVENANCE_KEYS (a spoofed run
297
411
  * classifies 'user' and is never approved regardless of claimed keys).
298
412
  *
413
+ * CME user studies: a user run the `cme-user-scripts` gate opened the CME
414
+ * plane to (`isCmeUserScriptRun`, the data wall's own per-plane verdict, so
415
+ * the two walls read one decision) draws on a CME chart, and the curation
416
+ * never applies to it: the official allow-list is CME evidence for
417
+ * first-party docs alone, never a list a user run must join. A hosted (Cloud)
418
+ * record and a protected script stay blocked on CME whatever the gate says.
419
+ *
299
420
  * OPRA (no CME leg): every first-party run is explicitly venue-approved, the
300
421
  * built-ins, the converted corpus, the official docs and the official
301
422
  * packages alike, and every user run is blocked unless the
@@ -305,15 +426,25 @@ export function isUserKScriptBlockedOnExchange(exchange, settings) {
305
426
  * blocked on an OPRA contract chart either way. The CME per-script curation
306
427
  * is CME evidence and does not apply there; a book-reading official is
307
428
  * refused by the options mode (OPRA has no book), not by this wall.
429
+ *
430
+ * The US stocks tape (no CME leg) follows the data wall the same way: every
431
+ * first-party run is venue-approved, a user run in the browser or on the cloud
432
+ * lane draws on a tape open to user scripting (STOCKS_TAPE_SCRIPTING_VENUES),
433
+ * and a protected user script, or any user run on a tape still closed to user
434
+ * scripting (NASDAQ_TAPE), is blocked. The CME curation does not apply there either.
308
435
  */
309
436
  export function isKScriptDisplayBlockedOnExchange(exchange, settings) {
310
437
  if (!payloadTouchesGovernedVenue(exchange))
311
438
  return false;
312
439
  if (isUserKScriptBlockedOnExchange(exchange, settings))
313
440
  return true;
314
- // Past the data wall a CME leg means a first-party run: its curation decides.
315
441
  if (!payloadTouchesCmeVenue(exchange))
316
442
  return false;
443
+ // Past the data wall a CME leg means a first-party run or a user run the `cme-user-scripts` gate opened the plane
444
+ // to. A user run is never curated (the allow-list below is first-party evidence alone): it draws.
445
+ if (isCmeUserScriptRun(settings))
446
+ return false;
447
+ // A first-party run: its curation decides.
317
448
  const builtin = builtinIdentityOf(settings);
318
449
  if (builtin?.kind === 'twin')
319
450
  return !isCmeProvenTwinBuiltIn(builtin.key);
@@ -333,25 +464,48 @@ export function isKScriptDisplayBlockedOnExchange(exchange, settings) {
333
464
  * rejections, and a policy block is a standing state, not an incident.
334
465
  */
335
466
  export function shouldBlockKScriptSourcePayload(args) {
336
- // The data wall's per-plane verdict: an OPRA source a flag-opened user run declares is served (`isOpraUserScriptRun`).
467
+ // The data wall's per-plane verdict: a CME source asked by a user run the `cme-user-scripts` gate opened the plane to
468
+ // (`isCmeUserScriptRun`), and an OPRA source a flag-opened user run declares (`isOpraUserScriptRun`), are served.
337
469
  const blocked = isUserKScriptBlockedOnExchange(args.payloadExchange, args.settings) ||
338
470
  (payloadReadsOpraPlane(args.payload) && !isOpraReadableKScriptRun(args.settings));
339
471
  if (!blocked)
340
472
  return 'allow';
341
473
  return args.isPolling ? 'deny-silent' : 'deny-throw';
342
474
  }
343
- /** Every gate plane's exchanges: the set a user run is denied (the CME family and OPRA). */
475
+ /** The tapes still closed to user scripting, in the gate release's order: a user run's denied set holds these alone
476
+ * of the US stocks tape (the open ones, STOCKS_TAPE_SCRIPTING_VENUES, are read at the viewer's tier). */
477
+ const ENGINE_CLOSED_STOCKS_TAPES = STOCKS_GOVERNED_EXCHANGES.filter(isClosedStocksTape);
478
+ /** The set a user run is denied: the CME family, OPRA and the tapes still closed to user scripting. */
344
479
  const ENGINE_GOVERNED_EXCHANGES = Object.freeze([
345
480
  ...CME_GOVERNED_EXCHANGES,
346
481
  ...OPRA_GOVERNED_EXCHANGES,
482
+ ...ENGINE_CLOSED_STOCKS_TAPES,
483
+ ]);
484
+ /** Every denied plane but OPRA: the set a user run the `opra-user-scripts` flag opened OPRA to is still denied (the
485
+ * CME family and the closed tapes). */
486
+ const ENGINE_CME_GOVERNED_EXCHANGES = Object.freeze([
487
+ ...CME_GOVERNED_EXCHANGES,
488
+ ...ENGINE_CLOSED_STOCKS_TAPES,
489
+ ]);
490
+ /** Every denied plane but CME: the set a user run the `cme-user-scripts` gate opened CME to is still denied (OPRA
491
+ * and the closed tapes). */
492
+ const ENGINE_OPRA_GOVERNED_EXCHANGES = Object.freeze([
493
+ ...OPRA_GOVERNED_EXCHANGES,
494
+ ...ENGINE_CLOSED_STOCKS_TAPES,
347
495
  ]);
348
- /** The CME family alone: the set a user run the `opra-user-scripts` flag opened OPRA to is denied. */
349
- const ENGINE_CME_GOVERNED_EXCHANGES = Object.freeze([...CME_GOVERNED_EXCHANGES]);
496
+ /** The closed tapes alone: the set a user run both the OPRA and the CME plane are open to is still denied. */
497
+ const ENGINE_CLOSED_TAPES_GOVERNED_EXCHANGES = Object.freeze([...ENGINE_CLOSED_STOCKS_TAPES]);
350
498
  export function buildKScriptDataAccessPolicy(settings) {
351
- return {
352
- governedExchanges: isOpraUserScriptRun(settings) ? ENGINE_CME_GOVERNED_EXCHANGES : ENGINE_GOVERNED_EXCHANGES,
353
- firstPartyRun: isFirstPartyKScriptRun(settings),
354
- };
499
+ const opraOpen = isOpraUserScriptRun(settings);
500
+ const cmeOpen = isCmeUserScriptRun(settings);
501
+ const governedExchanges = opraOpen
502
+ ? cmeOpen
503
+ ? ENGINE_CLOSED_TAPES_GOVERNED_EXCHANGES
504
+ : ENGINE_CME_GOVERNED_EXCHANGES
505
+ : cmeOpen
506
+ ? ENGINE_OPRA_GOVERNED_EXCHANGES
507
+ : ENGINE_GOVERNED_EXCHANGES;
508
+ return { governedExchanges, firstPartyRun: isFirstPartyKScriptRun(settings) };
355
509
  }
356
510
  /**
357
511
  * Cross-repo error contract: every venue-policy denial, FE-thrown or
@@ -12,14 +12,21 @@
12
12
  * 1st, quarters and halves from January, January 1; calendar-interval.util),
13
13
  * never the average-length floor;
14
14
  * 2. weekly: the CME trade-date week on a CME venue, else `findMonday`;
15
- * 3. chart RTH above the 30m grid: the bucket anchored at the venue's RTH
16
- * open (09:30 New York, 09:00 on NYMEX; rth-session.util);
15
+ * 3. chart RTH: above the 30m grid the bucket anchored at the venue's RTH
16
+ * open (09:30 New York, 09:00 on NYMEX; rth-session.util), at 30m and
17
+ * finer the UTC floor whose start the RTH window holds (the gateway keeps
18
+ * a whole bucket by its start, so the 16:00 New York 30m bucket stays);
19
+ * either only while the product trades by its schedule (no Saturday bars);
17
20
  * 4. regular-session US equities: the 09:30 anchored bucket from 45m to 12h,
18
- * the three-trade-date group at 3d;
21
+ * the three-trade-date group at 3d, at 30m and finer the UTC floor of a
22
+ * cash-session bar (`isUsEquityRegularSessionBarMs`);
19
23
  * 5. a CME venue on the Chicago session lattice (45m to 12h, 1d, 3d:
20
24
  * cme-session-bucket.util);
21
25
  * 6. everything else: the UTC floor.
22
- * Null means the frame has no bucket (off-session under 3 or 4): drop it.
26
+ * Null means the frame has no bucket (off-session under 3 or 4): the chart
27
+ * holds no bar there, so drop it. At 30m and finer the session grids share
28
+ * the UTC floor's lattice, never its bars: a regular-session chart holds none
29
+ * between its close and its next open.
23
30
  */
24
31
  export interface LiveBucketVenue {
25
32
  exchange?: unknown;
@@ -56,12 +63,21 @@ export declare function plainBucketStartMs(tsMs: number, intervalMs: number): nu
56
63
  */
57
64
  export declare function cmeSessionLatticeBucketMs(tsMs: number, intervalMs: number, venue: LiveBucketVenue | null | undefined): number | null;
58
65
  export declare function liveBucketStartMs(tsMs: number, intervalMs: number, venue?: LiveBucketVenue | null): number | null;
66
+ /**
67
+ * Whether the venue's bars at `intervalMs` are stamped with a LABEL rather than their open: the CME trade-date lattice
68
+ * from a day up (a bar labelled 00:00Z of its trade date opens at the 17:00 Chicago open the evening before) and a
69
+ * regular-session stock's three-trade-date 3d group (one label over three sessions and the nights between them). A
70
+ * bar there does not span [its stamp, the next bar's stamp), so only the bucket function says which bar holds an
71
+ * instant (host-bar-placement.util's sweep reads it so).
72
+ */
73
+ export declare function liveBucketBarsAreLabels(intervalMs: number, venue?: LiveBucketVenue | null): boolean;
59
74
  /**
60
75
  * The starts of the venue's bars that open inside `[fromMs, toMs]`, ascending, each keyed by
61
76
  * `liveBucketStartMs`: a regular-session stock chart's hourly columns sit on its 13:30Z (EDT) candles,
62
- * a CME chart's on its session lattice, and an off-session instant contributes none. The bar holding
63
- * `fromMs` counts only when it opens inside the range. A probe still inside the last bar (a lattice
64
- * bar the fall-back Sunday stretches) or off session steps forward a quarter hour at most; on a
65
- * regular-session stock grid it steps session to session (`resumeProbeMs`) onto the same probes.
77
+ * a CME chart's on its session lattice (in RTH, its RTH bars alone), and an off-session instant
78
+ * contributes none. The bar holding `fromMs` counts only when it opens inside the range. A probe still
79
+ * inside the last bar (a lattice bar the fall-back Sunday stretches) or off session steps forward a
80
+ * quarter hour at most; on a regular-session stock grid and a chart-RTH grid at 30m and finer it steps
81
+ * session to session (`resumeProbeMs`) onto the same probes.
66
82
  */
67
83
  export declare function liveBucketStartsInRange(fromMs: number, toMs: number, intervalMs: number, venue?: LiveBucketVenue | null): number[];
@@ -12,14 +12,21 @@
12
12
  * 1st, quarters and halves from January, January 1; calendar-interval.util),
13
13
  * never the average-length floor;
14
14
  * 2. weekly: the CME trade-date week on a CME venue, else `findMonday`;
15
- * 3. chart RTH above the 30m grid: the bucket anchored at the venue's RTH
16
- * open (09:30 New York, 09:00 on NYMEX; rth-session.util);
15
+ * 3. chart RTH: above the 30m grid the bucket anchored at the venue's RTH
16
+ * open (09:30 New York, 09:00 on NYMEX; rth-session.util), at 30m and
17
+ * finer the UTC floor whose start the RTH window holds (the gateway keeps
18
+ * a whole bucket by its start, so the 16:00 New York 30m bucket stays);
19
+ * either only while the product trades by its schedule (no Saturday bars);
17
20
  * 4. regular-session US equities: the 09:30 anchored bucket from 45m to 12h,
18
- * the three-trade-date group at 3d;
21
+ * the three-trade-date group at 3d, at 30m and finer the UTC floor of a
22
+ * cash-session bar (`isUsEquityRegularSessionBarMs`);
19
23
  * 5. a CME venue on the Chicago session lattice (45m to 12h, 1d, 3d:
20
24
  * cme-session-bucket.util);
21
25
  * 6. everything else: the UTC floor.
22
- * Null means the frame has no bucket (off-session under 3 or 4): drop it.
26
+ * Null means the frame has no bucket (off-session under 3 or 4): the chart
27
+ * holds no bar there, so drop it. At 30m and finer the session grids share
28
+ * the UTC floor's lattice, never its bars: a regular-session chart holds none
29
+ * between its close and its next open.
23
30
  */
24
31
  import { findMonday, TimeIntervalConstant } from './titan-constants.pin.js';
25
32
  import { cmeSessionBucketMs, isCmeSessionLatticeExchange, isCmeSessionLatticeIntervalMs, } from './cme-session-bucket.util.js';
@@ -28,10 +35,12 @@ import { calendarBarStartMs, calendarMonthsOfMs } from './calendar-interval.util
28
35
  import { formulaCalendarPlan, formulaLegExchange } from './formula-calendar.util.js';
29
36
  import { checkIsEconomic } from './marketKind.util.js';
30
37
  import { extractTokensFromTransformations, parsedTransformations } from '../common/transformations.util.js';
31
- import { isChartRthActive, isFootprintRthFoldTfMs, isRthBucketExactIntervalMs, rthAnchoredBucketStartMs, } from './rth-session.util.js';
32
- import { isEquityRegularSessionGated, usEquityAnchoredBucketStartMs, usEquitySessionGridBucketStartMs, } from './us-equities-session.util.js';
38
+ import { isGovernedFuturesSymbolOpenAt } from './market-session-schedule.util.js';
39
+ import { isChartRthActive, isFootprintRthFoldTfMs, isRthBucketExactIntervalMs, isWithinRthWindow, nextRthSessionOpenMs, rthAnchoredBucketStartMs, } from './rth-session.util.js';
40
+ import { isEquityRegularSessionGated, isUsEquityRegularSessionBarMs, usEquityAnchoredBucketStartMs, usEquitySessionGridBucketStartMs, } from './us-equities-session.util.js';
33
41
  import { nyNextRegularOpenAfterMs } from './ny-calendar.util.js';
34
42
  const THREE_DAYS_MS = Intervals.map_unit['3d'];
43
+ const ONE_DAY_MS = Intervals.map_unit['1d'];
35
44
  /**
36
45
  * A chart's bar-grid identity as a worker reads it (plain, cloneable fields only): the venue a worker
37
46
  * keys its rows by, so they land on the chart's own candles (`liveBucketStartMs`).
@@ -118,20 +127,34 @@ function liveBucketGrid(intervalMs, venue) {
118
127
  if (calendarMonthsOfMs(intervalMs) !== null || intervalMs === TimeIntervalConstant.week) {
119
128
  return isCmeSessionLatticeVenue(venue) ? 'cme-session' : 'plain';
120
129
  }
121
- if (venue && !isRthBucketExactIntervalMs(intervalMs)) {
122
- if (isChartRthActive(venue.exchange, venue.symbol, venue.sessionType, intervalMs))
123
- return 'rth-anchored';
124
- if (isEquityRegularSessionGated(venue.exchange, venue.sessionType)) {
125
- if (isFootprintRthFoldTfMs(intervalMs))
126
- return 'equity-anchored';
127
- if (intervalMs === THREE_DAYS_MS)
128
- return 'equity-session-group';
129
- }
130
- if (isCmeSessionLatticeIntervalMs(intervalMs) && isCmeSessionLatticeVenue(venue))
131
- return 'cme-session';
130
+ if (!venue)
131
+ return 'utc-floor';
132
+ // The 30m bucket-exact widths share the UTC floor's lattice, not its bars: a session-gated chart holds a
133
+ // bar there only inside its session, so the grid asks the session every time (a lattice that coincides is
134
+ // no off-session drop).
135
+ const exact = isRthBucketExactIntervalMs(intervalMs);
136
+ if (isChartRthActive(venue.exchange, venue.symbol, venue.sessionType, intervalMs)) {
137
+ return exact ? 'rth-floor' : 'rth-anchored';
138
+ }
139
+ if (isEquityRegularSessionGated(venue.exchange, venue.sessionType)) {
140
+ if (exact)
141
+ return 'equity-floor';
142
+ if (isFootprintRthFoldTfMs(intervalMs))
143
+ return 'equity-anchored';
144
+ if (intervalMs === THREE_DAYS_MS)
145
+ return 'equity-session-group';
132
146
  }
147
+ if (!exact && isCmeSessionLatticeIntervalMs(intervalMs) && isCmeSessionLatticeVenue(venue))
148
+ return 'cme-session';
133
149
  return 'utc-floor';
134
150
  }
151
+ /** The UTC floor of `tsMs`, the 30m bucket-exact grids' lattice. */
152
+ const utcFloorMs = (tsMs, intervalMs) => tsMs - (tsMs % intervalMs);
153
+ /** A chart-RTH bucket starting at `startMs` exists only while the product trades by its schedule (an RTH window
154
+ * is a wall-clock filter with bounds on every calendar day; ES holds no Saturday bar, an always-on root does). */
155
+ function rthBucketOrNull(symbol, startMs) {
156
+ return startMs !== null && isGovernedFuturesSymbolOpenAt(symbol, startMs) ? startMs : null;
157
+ }
135
158
  function bucketStartOnGrid(grid, tsMs, intervalMs, venue) {
136
159
  switch (grid) {
137
160
  case 'cme-session':
@@ -139,18 +162,38 @@ function bucketStartOnGrid(grid, tsMs, intervalMs, venue) {
139
162
  case 'plain':
140
163
  return plainBucketStartMs(tsMs, intervalMs);
141
164
  case 'rth-anchored':
142
- return rthAnchoredBucketStartMs(venue?.symbol, tsMs, intervalMs);
165
+ return rthBucketOrNull(venue?.symbol, rthAnchoredBucketStartMs(venue?.symbol, tsMs, intervalMs));
166
+ case 'rth-floor': {
167
+ // The gateway keeps a whole bucket by its START: the 16:00 New York 30m bucket of a 16:15 close stays.
168
+ const floor = utcFloorMs(tsMs, intervalMs);
169
+ return rthBucketOrNull(venue?.symbol, isWithinRthWindow(venue?.symbol, floor) ? floor : null);
170
+ }
143
171
  case 'equity-anchored':
144
172
  return usEquityAnchoredBucketStartMs(tsMs, intervalMs);
173
+ case 'equity-floor': {
174
+ const floor = utcFloorMs(tsMs, intervalMs);
175
+ return isUsEquityRegularSessionBarMs(floor, intervalMs) ? floor : null;
176
+ }
145
177
  case 'equity-session-group':
146
178
  return usEquitySessionGridBucketStartMs(tsMs);
147
179
  default:
148
- return tsMs - (tsMs % intervalMs);
180
+ return utcFloorMs(tsMs, intervalMs);
149
181
  }
150
182
  }
151
183
  export function liveBucketStartMs(tsMs, intervalMs, venue) {
152
184
  return bucketStartOnGrid(liveBucketGrid(intervalMs, venue), tsMs, intervalMs, venue);
153
185
  }
186
+ /**
187
+ * Whether the venue's bars at `intervalMs` are stamped with a LABEL rather than their open: the CME trade-date lattice
188
+ * from a day up (a bar labelled 00:00Z of its trade date opens at the 17:00 Chicago open the evening before) and a
189
+ * regular-session stock's three-trade-date 3d group (one label over three sessions and the nights between them). A
190
+ * bar there does not span [its stamp, the next bar's stamp), so only the bucket function says which bar holds an
191
+ * instant (host-bar-placement.util's sweep reads it so).
192
+ */
193
+ export function liveBucketBarsAreLabels(intervalMs, venue) {
194
+ const grid = liveBucketGrid(intervalMs, venue);
195
+ return grid === 'equity-session-group' || (grid === 'cme-session' && intervalMs >= ONE_DAY_MS);
196
+ }
154
197
  /** The probe step through an off-session gap: every open the anchored grids sit on is on the quarter hour. */
155
198
  const OFF_SESSION_PROBE_MS = 15 * 60_000;
156
199
  /**
@@ -158,22 +201,37 @@ const OFF_SESSION_PROBE_MS = 15 * 60_000;
158
201
  * regular-session stock grid opens bars only inside the cash session, and its 3d bar spans whole
159
202
  * sessions, so every probe before the next regular open would come back empty: the walk lands on
160
203
  * the first probe of the same quarter-hour run at or after that open, one New York calendar lookup
161
- * per trade date, and ends when no open comes by `toMs`. Every other grid steps a quarter hour.
204
+ * per trade date, and ends when no open comes by `toMs`. The session floor grids at 30m and finer
205
+ * (a regular-session stock's, a chart-RTH one's) open bars only inside the session, the first on
206
+ * the first interval boundary at or after the open (a 4m grid's 13:32Z: the 13:28Z bucket opened
207
+ * before it), so an off-session probe resumes at its next boundary when a session opened inside
208
+ * its bucket, else at the next open's first boundary (a non-trading day's RTH window opens nothing
209
+ * and resumes again). Every other grid steps a quarter hour (at most its own interval).
162
210
  */
163
- function resumeProbeMs(grid, probeMs, stepMs, offSession, toMs) {
164
- if (grid === 'equity-session-group' || (grid === 'equity-anchored' && offSession)) {
211
+ function resumeProbeMs(grid, probeMs, stepMs, offSession, toMs, venue, intervalMs) {
212
+ if (grid === 'equity-session-group' || (offSession && grid === 'equity-anchored')) {
165
213
  const openMs = nyNextRegularOpenAfterMs(probeMs, toMs);
166
214
  return openMs === null ? Number.POSITIVE_INFINITY : probeMs + Math.ceil((openMs - probeMs) / stepMs) * stepMs;
167
215
  }
216
+ if (offSession && (grid === 'equity-floor' || grid === 'rth-floor')) {
217
+ const nextBoundaryMs = utcFloorMs(probeMs, intervalMs) + intervalMs;
218
+ if (bucketStartOnGrid(grid, nextBoundaryMs, intervalMs, venue) !== null)
219
+ return nextBoundaryMs;
220
+ const openMs = grid === 'equity-floor' ? nyNextRegularOpenAfterMs(probeMs, toMs) : nextRthSessionOpenMs(venue?.symbol, probeMs);
221
+ if (openMs === null)
222
+ return Number.POSITIVE_INFINITY;
223
+ return Math.max(nextBoundaryMs, Math.ceil(openMs / intervalMs) * intervalMs);
224
+ }
168
225
  return probeMs + stepMs;
169
226
  }
170
227
  /**
171
228
  * The starts of the venue's bars that open inside `[fromMs, toMs]`, ascending, each keyed by
172
229
  * `liveBucketStartMs`: a regular-session stock chart's hourly columns sit on its 13:30Z (EDT) candles,
173
- * a CME chart's on its session lattice, and an off-session instant contributes none. The bar holding
174
- * `fromMs` counts only when it opens inside the range. A probe still inside the last bar (a lattice
175
- * bar the fall-back Sunday stretches) or off session steps forward a quarter hour at most; on a
176
- * regular-session stock grid it steps session to session (`resumeProbeMs`) onto the same probes.
230
+ * a CME chart's on its session lattice (in RTH, its RTH bars alone), and an off-session instant
231
+ * contributes none. The bar holding `fromMs` counts only when it opens inside the range. A probe still
232
+ * inside the last bar (a lattice bar the fall-back Sunday stretches) or off session steps forward a
233
+ * quarter hour at most; on a regular-session stock grid and a chart-RTH grid at 30m and finer it steps
234
+ * session to session (`resumeProbeMs`) onto the same probes.
177
235
  */
178
236
  export function liveBucketStartsInRange(fromMs, toMs, intervalMs, venue) {
179
237
  const starts = [];
@@ -185,7 +243,7 @@ export function liveBucketStartsInRange(fromMs, toMs, intervalMs, venue) {
185
243
  for (let probe = fromMs; probe <= toMs;) {
186
244
  const start = bucketStartOnGrid(grid, probe, intervalMs, venue);
187
245
  if (start === null || start <= last) {
188
- probe = resumeProbeMs(grid, probe, stepMs, start === null, toMs);
246
+ probe = resumeProbeMs(grid, probe, stepMs, start === null, toMs, venue, intervalMs);
189
247
  continue;
190
248
  }
191
249
  last = start;
@@ -38,6 +38,11 @@ const EXCHANGE_TO_KIND = {
38
38
  NASDAQ_PHILADELPHIA: 'tradfi',
39
39
  NASDAQ_PSX: 'tradfi',
40
40
  NASDAQ_INT: 'tradfi',
41
+ // The US consolidated tape's three SIP tapes, by the app's tape codes (stocks-realtime.interface.ts): the same
42
+ // listings as the free lane, delayed, through the stocks entitlement gate.
43
+ NYSE_TAPE: 'tradfi',
44
+ NYSE_ARCA_TAPE: 'tradfi',
45
+ NASDAQ_TAPE: 'tradfi',
41
46
  CBOE: 'tradfi',
42
47
  CBOE_EDGA: 'tradfi',
43
48
  CBOE_EDGX: 'tradfi',
@@ -123,6 +123,13 @@ export declare const INDEX_FETCH_EXTRA_BAR = 1;
123
123
  * - Mixed timestamp-first: Main token is crypto, others include stocks (BTC + NVDA)
124
124
  * - Mixed index-first: Main token is stock, others include crypto (NVDA + BTC)
125
125
  *
126
+ * **Per-token sessions** (`tokenSessionTypes`, the worker resolves each leg's `tradingHour` from its entry, else the
127
+ * chart's `sessionType`): a Polygon leg rides the chart's session (regular unless extended); a leg with an RTH window
128
+ * that is not the chart's own market takes the comparison-leg rule (chart-rth.util `kOhlcvSessionPayloadFields`):
129
+ * 'regular' only while the CHART is RTH-active (`isChartRthActive` at the chart interval), else 'extended'. A crypto or
130
+ * equities chart stamps a meaningless 'regular' it has no control to change, which must never filter a CME leg of its
131
+ * formula to the cash session; the chart's own market reads the chart's session as before.
132
+ *
126
133
  * @param metadata - Chart metadata containing transformations and session settings
127
134
  * @param transformations - Expression string (e.g., "BINANCE|BTCUSDT + POLYGON|NVDA")
128
135
  * @returns Context object with token modes, session types, and mixed-mode flags