@orangecharts/wrun-chart-host 0.9.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 (252) hide show
  1. package/README.md +2 -0
  2. package/dist/constants/feature-flags.constants.d.ts +15 -1
  3. package/dist/constants/feature-flags.constants.js +130 -24
  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/opra-compliance.constants.d.ts +3 -2
  7. package/dist/constants/opra-compliance.constants.js +3 -2
  8. package/dist/constants/option-venues.constants.d.ts +2 -2
  9. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  10. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  11. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  12. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  13. package/dist/constants/venue-presets.constants.d.ts +20 -20
  14. package/dist/constants/venue-presets.constants.js +24 -26
  15. package/dist/host-env.d.ts +21 -5
  16. package/dist/host-env.js +6 -0
  17. package/dist/host-ports.types.d.ts +102 -19
  18. package/dist/index.d.ts +18 -0
  19. package/dist/index.js +18 -0
  20. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  21. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  22. package/dist/interfaces/cme-realtime.interface.js +6 -3
  23. package/dist/interfaces/kscript-diagnostics.interface.d.ts +12 -0
  24. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  25. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  26. package/dist/interfaces/replay.interface.d.ts +8 -0
  27. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  28. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  29. package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
  30. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +62 -94
  31. package/dist/kscript-data/controls/live-trades-merge.util.js +106 -171
  32. package/dist/market-data/billing.interface.d.ts +174 -36
  33. package/dist/market-data/billing.interface.js +58 -8
  34. package/dist/market-data/venue.d.ts +152 -7
  35. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  36. package/dist/market-data/venues/cme.d.ts +126 -0
  37. package/dist/market-data/venues/cme.js +133 -0
  38. package/dist/market-data/venues/index.d.ts +294 -7
  39. package/dist/market-data/venues/index.js +49 -6
  40. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  41. package/dist/market-data/venues/opra.d.ts +2 -2
  42. package/dist/market-data/venues/opra.js +5 -2
  43. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  44. package/dist/market-data/venues/stocks.d.ts +130 -0
  45. package/dist/market-data/venues/stocks.js +117 -0
  46. package/dist/settings-templates/footprint-rows.js +35 -2
  47. package/dist/settings-templates/form-rows.d.ts +2 -1
  48. package/dist/settings-templates/index.js +7 -3
  49. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  50. package/dist/settings-templates/indicator-fields.js +79 -10
  51. package/dist/settings-templates/tool-rules.d.ts +32 -15
  52. package/dist/settings-templates/tool-rules.js +33 -11
  53. package/dist/settings-templates/tool-tables.generated.js +95 -31
  54. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  55. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  56. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  57. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  58. package/dist/utility/chart/cme-realtime.util.js +10 -0
  59. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  60. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  61. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  62. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  63. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  64. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  65. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  66. package/dist/utility/chart/index-host-tier.util.js +7 -2
  67. package/dist/utility/chart/index-mode-admission.util.js +30 -3
  68. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  69. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  70. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  71. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +9 -7
  72. package/dist/utility/chart/kscript-live-coalesce.util.js +13 -8
  73. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  74. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  75. package/dist/utility/chart/kscript-provenance-keys.util.js +13 -0
  76. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +5 -1
  77. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  78. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  79. package/dist/utility/chart/kscript-venue-policy.util.d.ts +156 -43
  80. package/dist/utility/chart/kscript-venue-policy.util.js +249 -59
  81. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  82. package/dist/utility/chart/live-bucket.util.js +85 -27
  83. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  84. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  85. package/dist/utility/chart/marketKind.util.js +5 -0
  86. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  87. package/dist/utility/chart/mixed-mode.util.js +14 -0
  88. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  89. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  90. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  91. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  92. package/dist/utility/chart/rth-session.util.d.ts +12 -10
  93. package/dist/utility/chart/rth-session.util.js +25 -21
  94. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  95. package/dist/utility/chart/trading-day.util.js +59 -0
  96. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  97. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  98. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  99. package/dist/utility/chart/window-owner.leaf.js +45 -3
  100. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  101. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  102. package/dist/utility/chart/wrun-run-result.util.d.ts +12 -0
  103. package/dist/utility/chart/wrun-run-result.util.js +141 -6
  104. package/dist/utility/intl-locale.util.js +5 -0
  105. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  106. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  107. package/dist/utility/options/option-venue.util.d.ts +18 -0
  108. package/dist/utility/options/option-venue.util.js +27 -0
  109. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +4 -0
  110. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  111. package/dist/utility/v2/gate-plane.util.js +30 -4
  112. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  113. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  114. package/dist/utility/v2/stocks-governed.util.js +34 -0
  115. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  116. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  117. package/dist/utility/wrun/derived-roots.util.d.ts +205 -0
  118. package/dist/utility/wrun/derived-roots.util.js +451 -0
  119. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +43 -7
  120. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  121. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  122. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  123. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -2
  124. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
  125. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  126. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  127. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  128. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  129. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  130. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  131. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  132. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
  133. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
  134. package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
  135. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  136. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
  137. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
  138. package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
  139. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  140. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
  141. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +41 -10
  142. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +111 -0
  143. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +133 -0
  144. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +15 -3
  145. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
  146. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
  147. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +197 -13
  148. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +761 -27
  149. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  150. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  151. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  152. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +60 -16
  153. package/dist/utility/wrun/wrun-chart-market-facts.util.js +113 -61
  154. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  155. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  156. package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
  157. package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
  158. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  159. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  160. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  161. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  162. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  163. package/dist/utility/wrun/wrun-frames.js +73 -10
  164. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  165. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  166. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  167. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  168. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +18 -4
  169. package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
  170. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  171. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  172. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  173. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  174. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  175. package/dist/utility/wrun/wrun-live-intake.util.d.ts +35 -15
  176. package/dist/utility/wrun/wrun-live-intake.util.js +243 -126
  177. package/dist/utility/wrun/wrun-live-tick.util.d.ts +13 -5
  178. package/dist/utility/wrun/wrun-live-tick.util.js +279 -99
  179. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  180. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  181. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +60 -11
  182. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +70 -5
  183. package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
  184. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  185. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  186. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  187. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  188. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  189. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  190. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +23 -6
  191. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
  192. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
  193. package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
  194. package/dist/utility/wrun/wrun-option-views.util.d.ts +323 -28
  195. package/dist/utility/wrun/wrun-option-views.util.js +484 -71
  196. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  197. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  198. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  199. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  200. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +32 -2
  201. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  202. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  203. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  204. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  205. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +160 -42
  206. package/dist/utility/wrun/wrun-overlay-run.util.js +1244 -209
  207. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  208. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  209. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  210. package/dist/utility/wrun/wrun-panel-mount.util.js +114 -19
  211. package/dist/utility/wrun/wrun-panel-style.util.d.ts +10 -9
  212. package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
  213. package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
  214. package/dist/utility/wrun/wrun-param-map.util.js +10 -5
  215. package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
  216. package/dist/utility/wrun/wrun-param-values.util.js +4 -0
  217. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  218. package/dist/utility/wrun/wrun-pin-spelling.util.js +39 -14
  219. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  220. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  221. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  222. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  223. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  224. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  225. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  226. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  227. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  228. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  229. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  230. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  231. package/dist/utility/wrun/wrun-run-interval.util.d.ts +43 -9
  232. package/dist/utility/wrun/wrun-run-interval.util.js +58 -15
  233. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +45 -1
  234. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  235. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  236. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  237. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  238. package/dist/utility/wrun/wrun-socket-row-source.js +118 -8
  239. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -18
  240. package/dist/utility/wrun/wrun-source-rows.util.js +61 -27
  241. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  242. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  243. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  244. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  245. package/dist/utility/wrun/wrun-tape-per-order.util.js +7 -0
  246. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  247. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  248. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  249. package/dist/utils/replay/replay-buffer-math.js +227 -20
  250. package/dist/workers/constants/socket-slots.d.ts +91 -6
  251. package/dist/workers/constants/socket-slots.js +85 -6
  252. package/package.json +5 -5
@@ -1,18 +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, Kyle 2026-10-14) draws the same line: chart-only
7
- * first-party indicators are display use, user-authored scripting waits for
8
- * OPRA's confirmation. Kyle 2026-10-17 assumed that confirmation behind the
9
- * `opra-user-scripts` flag; since 2026-10-22 (the OPRA gate compliance round,
10
- * plan row D3) the policy no longer reads it: `isOpraUserScriptRun`, ONE
11
- * decision for the display wall, the data wall and the engine policy, refuses
12
- * every user run, so a lit flag reads exactly like a dark one. A scope
13
- * assessment with OPRA (the filing's Non-Display Declaration, Exhibit A Q8,
14
- * Q12, Q13) must come before it opens again. This module is the single
15
- * 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.
16
25
  * Every run door (add, mount, protected fetch, cache paint, alerts arm,
17
26
  * editor Run), the per-payload data guard in titan-charts dataFetch, and the
18
27
  * engine policy descriptor consult it; nothing else may re-derive provenance
@@ -23,8 +32,9 @@
23
32
  */
24
33
  import { CME_GOVERNED_EXCHANGES } from '../../interfaces/cme-realtime.interface.js';
25
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';
26
36
  import { isCmeFuturesPolicyActive } from './marketKind.util.js';
27
- import { isOpraGoverned } from '../v2/gate-plane.util.js';
37
+ import { isOpraGoverned, isStocksTapeGoverned } from '../v2/gate-plane.util.js';
28
38
  import { isConvertedScriptId } from '../../constants/scriptEditor/converted-script-id.leaf.js';
29
39
  import { isTempScriptId } from '../scriptEditor/temp-script-id.util.js';
30
40
  import { TECHNICAL_INDICATOR_SCRIPT_KEY_SET } from '../../constants/scriptEditor/technicalIndicatorScriptKeys.constants.js';
@@ -34,6 +44,10 @@ import { isWrunDraftScriptId } from '../wrun/wrun-draft-overlay.util.js';
34
44
  import { isWrunOfficialPackage } from '../wrun/wrun-official-scope.leaf.js';
35
45
  // Worker-safe too: it reads the twin stamp, the registry ref and the built-in keys alone.
36
46
  import { builtinIdentityOf } from './builtin-identity.util.js';
47
+ // Dependency-free: the flag store hands the flag's live readers to it (no store import here).
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,41 +166,144 @@ export function isFirstPartyKScriptRun(settings) {
152
166
  return isCmeFirstPartyOfficialDocId(settings?.customScriptId);
153
167
  }
154
168
  /**
155
- * A user run the browser executes: not first-party (a script or Indicator draft the viewer wrote, a community
156
- * document or package, anything unrecognized), and neither a hosted Cloud run nor a protected script: those run on a
157
- * server lane, which reads governed data through its own gate identity (UW-PARITY H3), so a browser flag never opens
158
- * a plane to them. A Cloud run is the record on the socket row source (`wrunRowSourceKindOf`), read through the
159
- * migration on read (`wrunCloudRecordOf`): the wave-3 record (`wrunRunTarget: 'cloud'`, no `wrunRef`) and a record
160
- * persisted before wave 3 (`wrunRef`) alike. The runs the `opra-user-scripts` flag opened the OPRA plane to while it
161
- * was honoured (`isOpraUserScriptRun`); read without the flag where a door must know a decision waits on it (the
162
- * flag's hydration).
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
174
+ * read through that migration before the protected flag: a record persisted before wave 3 still carries the wave-2
175
+ * hosted mount's keys (`isProtectedScript: true` beside `wrunRef`, wrun-cloud-row-compat.util) until its adoption, and
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
- export function isOpraUserScriptCandidate(settings) {
180
+ function userRunLane(settings) {
165
181
  if (!settings || isFirstPartyKScriptRun(settings))
166
- return false;
167
- if (wrunRowSourceKindOf(wrunCloudRecordOf(settings) ?? settings) === 'socket')
168
- return false;
169
- return settings.isProtectedScript !== true;
182
+ return undefined;
183
+ const record = wrunCloudRecordOf(settings) ?? settings;
184
+ if (record.isProtectedScript === true)
185
+ return undefined;
186
+ return wrunRowSourceKindOf(record) === 'socket' ? 'cloud' : 'browser';
187
+ }
188
+ /**
189
+ * A user run the browser executes (`userRunLane` `browser`): neither a hosted Cloud run nor a protected script,
190
+ * which run on a server lane that reads governed data through its own gate identity (UW-PARITY H3), so a browser flag
191
+ * never opens a plane to them. The runs the `opra-user-scripts` flag opens the OPRA plane to (`isOpraUserScriptRun`);
192
+ * read without the flag where a door must know a decision waits on it (the flag's hydration).
193
+ */
194
+ export function isOpraUserScriptCandidate(settings) {
195
+ return userRunLane(settings) === 'browser';
196
+ }
197
+ /**
198
+ * Whether a hosted (Cloud) user run's lane reads the OPRA chain of a US stock or ETF chart (contract
199
+ * opra-server-lanes H3, the cloud lane, which admits the run's owner by the same `opra-user-scripts` flag and serves
200
+ * the owner's own tier): the lane capability the works-on list reads for a Cloud record, apart from the browser
201
+ * decision above. Never an OPRA contract chart (the cloud lane has no candle path with an actor: a Cloud run there
202
+ * stays refused by the display wall) and never a stock twin's chain (the cloud reads the chart's own market).
203
+ */
204
+ export function isOpraCloudChainRun(settings) {
205
+ return isOpraUserScriptsFlagOn() && userRunLane(settings) === 'cloud';
206
+ }
207
+ /** The words the OPRA contract-chart wall shows a user run it refuses (web locale keys, `opraContractChartWallKey`). */
208
+ export const OPRA_USER_SCRIPT_WALL_KEY = 'indicators.opra.userScriptNotSupported';
209
+ export const OPRA_CLOUD_CONTRACT_CHART_WALL_KEY = 'indicators.opra.cloudOnContractChartNotSupported';
210
+ /**
211
+ * The words every door that refuses a user run on an OPRA contract chart shows (the add toast, Door A; the chip, Door
212
+ * H), picked by the run's lane and never by the flag: a hosted (Cloud) record has no path on a contract chart whatever
213
+ * the `opra-user-scripts` flag says (its own sentence); a run the browser executes is refused there only while the
214
+ * flag is dark, and a protected script always (the user-script sentence). It names words only: whether the door opens
215
+ * is the walls' decision (`isKScriptDisplayBlockedOnExchange`, `isOpraReadableKScriptRun`).
216
+ */
217
+ export function opraContractChartWallKey(settings) {
218
+ return userRunLane(settings) === 'cloud' ? OPRA_CLOUD_CONTRACT_CHART_WALL_KEY : OPRA_USER_SCRIPT_WALL_KEY;
170
219
  }
171
220
  /**
172
221
  * Whether the OPRA plane is open to this user run. The ONE decision every OPRA door reads, directly or through the
173
222
  * walls below: the display wall, the data wall (the dataFetch door, the protected pre-flight, the cache paint), the
174
223
  * engine policy, and the wrun chain decision. The CME plane never reads it.
175
224
  *
176
- * Always false (2026-10-22, the OPRA gate compliance round, plan row D3): the `opra-user-scripts` flag (Kyle
177
- * 2026-10-17: the OPRA permission for user-authored scripts assumed) opened the plane to a browser user run
178
- * (`isOpraUserScriptCandidate`) while lit; it is no longer honoured, and stays defined only so nothing that names it
179
- * breaks. OPRA's approval covers web display only: user-authored scripting over OPRA data stays refused until a scope
180
- * assessment with OPRA (the filing's Non-Display Declaration, Exhibit A Q8, Q12, Q13) allows it.
225
+ * Open to a browser user run (`isOpraUserScriptCandidate`) while the `opra-user-scripts` flag is lit: the OPRA
226
+ * licence covers user-authored scripting (Kyle 2026-10-27). The tier follows the viewer, never the run: the browser
227
+ * lane reads through the viewer's own gate sockets (the gate's tier frame for the session picks the real-time or the
228
+ * delayed socket), so the same script reads real-time rows for a paying viewer and delayed rows for every other one.
229
+ * A hosted (Cloud) record and a protected script stay out of this decision: a Cloud run on an OPRA contract chart has
230
+ * no server path yet (the cloud lane reads the chain of a US stock or ETF chart only), and a protected script has no
231
+ * actor path on the engine lane. The flag is read first: while it is dark (the default) no record is read at all.
181
232
  */
182
- export function isOpraUserScriptRun(_settings) {
183
- return false;
233
+ export function isOpraUserScriptRun(settings) {
234
+ return isOpraUserScriptsFlagOn() && isOpraUserScriptCandidate(settings);
184
235
  }
185
- /** Whether a run may consume the OPRA plane's data: every first-party run, and no user run (`isOpraUserScriptRun`;
186
- * `mayReadOpra`, the one decision the wrun run head and every source lane read too). */
236
+ /** Whether a run may consume the OPRA plane's data: every first-party run, and a user run the flag opened it to
237
+ * (`isOpraUserScriptRun`; `mayReadOpra`, the one decision the wrun run head and every source lane read too). */
187
238
  export function isOpraReadableKScriptRun(settings) {
188
239
  return mayReadOpra({ official: isFirstPartyKScriptRun(settings), opraUserScripts: isOpraUserScriptRun(settings) });
189
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
+ }
190
307
  /** BLOCKING semantics over a source exchange (string, or the array form with .some()). */
191
308
  function payloadTouches(exchange, governed) {
192
309
  if (Array.isArray(exchange))
@@ -201,9 +318,29 @@ export function payloadTouchesCmeVenue(exchange) {
201
318
  export function payloadTouchesOpraVenue(exchange) {
202
319
  return payloadTouches(exchange, isOpraGoverned);
203
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
+ }
204
340
  /**
205
341
  * Whether a source exchange (string or the multi-exchange array form) touches
206
- * 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).
207
344
  * Deliberately NOT governed-route.util's isGovernedExchange /
208
345
  * isGovernedReaderPayload: their array form uses .every() because that is
209
346
  * ROUTING semantics (a mixed multi-exchange metadata query must keep the
@@ -211,7 +348,7 @@ export function payloadTouchesOpraVenue(exchange) {
211
348
  * governed leg must block, so the array form is .some().
212
349
  */
213
350
  export function payloadTouchesGovernedVenue(exchange) {
214
- return payloadTouchesCmeVenue(exchange) || payloadTouchesOpraVenue(exchange);
351
+ return (payloadTouchesCmeVenue(exchange) || payloadTouchesOpraVenue(exchange) || payloadTouchesStocksTapeVenue(exchange));
215
352
  }
216
353
  /**
217
354
  * DATA-wall door predicate: user-authored run targeting a governed venue.
@@ -220,12 +357,24 @@ export function payloadTouchesGovernedVenue(exchange) {
220
357
  * first-party officials legitimately pass. The OPERATIONAL doors (add, mount,
221
358
  * teardown, resubscribe, self-heal, suite/layout/copy apply) consult
222
359
  * isKScriptDisplayBlockedOnExchange below instead, which is a strict superset
223
- * of this predicate. Per plane: a CME leg blocks every user run; an OPRA leg
224
- * blocks every user run too (`isOpraReadableKScriptRun`: the flag that could
225
- * open the plane is no longer honoured, see `isOpraUserScriptRun`).
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.
226
368
  */
227
369
  export function isUserKScriptBlockedOnExchange(exchange, settings) {
228
- 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))
229
378
  return true;
230
379
  return payloadTouchesOpraVenue(exchange) && !isOpraReadableKScriptRun(settings);
231
380
  }
@@ -255,28 +404,47 @@ export function isUserKScriptBlockedOnExchange(exchange, settings) {
255
404
  * the add route mounts on a governed venue; a twin of any other built-in
256
405
  * carried there (an in-place symbol switch, a restore, a paste or copy) is
257
406
  * blocked. User-provenance
258
- * runs are never venue-approved, so this is a strict superset of
259
- * 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
260
409
  * official blocks, and provenance spoofing via script-input names is already
261
410
  * neutralized upstream by KSCRIPT_RESERVED_PROVENANCE_KEYS (a spoofed run
262
411
  * classifies 'user' and is never approved regardless of claimed keys).
263
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
+ *
264
420
  * OPRA (no CME leg): every first-party run is explicitly venue-approved, the
265
421
  * built-ins, the converted corpus, the official docs and the official
266
- * packages alike (chart-only display use under the OPRA licence), and every
267
- * user run is blocked (the data wall's own per-plane verdict, so the two walls
268
- * read one decision, `isOpraUserScriptRun`). The CME per-script curation is CME evidence and does not apply
269
- * there; a book-reading official is refused by the options mode (OPRA has no
270
- * book), not by this wall.
422
+ * packages alike, and every user run is blocked unless the
423
+ * `opra-user-scripts` flag opened the plane to it (the data wall's own
424
+ * per-plane verdict, so the two walls read one decision,
425
+ * `isOpraUserScriptRun`): a hosted (Cloud) record and a protected script stay
426
+ * blocked on an OPRA contract chart either way. The CME per-script curation
427
+ * is CME evidence and does not apply there; a book-reading official is
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.
271
435
  */
272
436
  export function isKScriptDisplayBlockedOnExchange(exchange, settings) {
273
437
  if (!payloadTouchesGovernedVenue(exchange))
274
438
  return false;
275
439
  if (isUserKScriptBlockedOnExchange(exchange, settings))
276
440
  return true;
277
- // Past the data wall a CME leg means a first-party run: its curation decides.
278
441
  if (!payloadTouchesCmeVenue(exchange))
279
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.
280
448
  const builtin = builtinIdentityOf(settings);
281
449
  if (builtin?.kind === 'twin')
282
450
  return !isCmeProvenTwinBuiltIn(builtin.key);
@@ -296,26 +464,48 @@ export function isKScriptDisplayBlockedOnExchange(exchange, settings) {
296
464
  * rejections, and a policy block is a standing state, not an incident.
297
465
  */
298
466
  export function shouldBlockKScriptSourcePayload(args) {
299
- // The data wall's per-plane verdict: an OPRA source is served to a first-party run only (`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.
300
469
  const blocked = isUserKScriptBlockedOnExchange(args.payloadExchange, args.settings) ||
301
470
  (payloadReadsOpraPlane(args.payload) && !isOpraReadableKScriptRun(args.settings));
302
471
  if (!blocked)
303
472
  return 'allow';
304
473
  return args.isPolling ? 'deny-silent' : 'deny-throw';
305
474
  }
306
- /** 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. */
307
479
  const ENGINE_GOVERNED_EXCHANGES = Object.freeze([
308
480
  ...CME_GOVERNED_EXCHANGES,
309
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,
310
495
  ]);
311
- /** The CME family alone: the set a user run OPRA is open to would be denied (none while `isOpraUserScriptRun` is
312
- * closed). */
313
- 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]);
314
498
  export function buildKScriptDataAccessPolicy(settings) {
315
- return {
316
- governedExchanges: isOpraUserScriptRun(settings) ? ENGINE_CME_GOVERNED_EXCHANGES : ENGINE_GOVERNED_EXCHANGES,
317
- firstPartyRun: isFirstPartyKScriptRun(settings),
318
- };
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) };
319
509
  }
320
510
  /**
321
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[];