@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
@@ -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;
@@ -44,6 +44,16 @@ export declare function isCmeAlwaysOnSymbol(symbol: unknown): boolean;
44
44
  export declare function cmeAlwaysOnSinceMs(symbol: unknown): number | null;
45
45
  /** The always-on schedule: open except inside the Saturday maintenance window. */
46
46
  export declare function getAlwaysOnScheduleStatus(nowMs: number): GovernedFuturesScheduleStatus;
47
+ /**
48
+ * Whether a governed symbol's product trades at `tMs` by its schedule, at any
49
+ * instant of its history: an always-on root from its launch instant
50
+ * (`cmeAlwaysOnSinceMs`) everywhere but the Saturday 02:00-04:00 CT
51
+ * maintenance window, before it and for every other root the Globex weekly
52
+ * cycle. Holidays read open (module doc). For readers that judge past bars (the
53
+ * option reads' bar proofs, which may drop only an instant the product holds no
54
+ * trading at); a status asks `getGovernedFuturesScheduleStatusForSymbol`.
55
+ */
56
+ export declare function isGovernedFuturesSymbolOpenAt(symbol: unknown, tMs: number): boolean;
47
57
  /**
48
58
  * Schedule status for a specific governed symbol: always-on roots get the
49
59
  * 24/7 schedule, everything else the Globex weekly cycle. Callers that have a
@@ -251,6 +251,22 @@ export function getAlwaysOnScheduleStatus(nowMs) {
251
251
  // Unreachable: a 7-day sweep always contains a Saturday.
252
252
  return { open: true, nextOpenMs: null, nextCloseMs: null };
253
253
  }
254
+ /**
255
+ * Whether a governed symbol's product trades at `tMs` by its schedule, at any
256
+ * instant of its history: an always-on root from its launch instant
257
+ * (`cmeAlwaysOnSinceMs`) everywhere but the Saturday 02:00-04:00 CT
258
+ * maintenance window, before it and for every other root the Globex weekly
259
+ * cycle. Holidays read open (module doc). For readers that judge past bars (the
260
+ * option reads' bar proofs, which may drop only an instant the product holds no
261
+ * trading at); a status asks `getGovernedFuturesScheduleStatusForSymbol`.
262
+ */
263
+ export function isGovernedFuturesSymbolOpenAt(symbol, tMs) {
264
+ const sinceMs = cmeAlwaysOnSinceMs(symbol);
265
+ if (sinceMs === null || tMs < sinceMs)
266
+ return isGovernedFuturesScheduleOpen(tMs);
267
+ const mow = minutesOfWeek(wallClockPartsAt(tMs));
268
+ return mow < ALWAYS_ON_MAINTENANCE_START_MIN || mow >= ALWAYS_ON_MAINTENANCE_END_MIN;
269
+ }
254
270
  /**
255
271
  * Schedule status for a specific governed symbol: always-on roots get the
256
272
  * 24/7 schedule, everything else the Globex weekly cycle. Callers that have a
@@ -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
@@ -18,6 +18,7 @@
18
18
  import { getExchangeFromSymbol } from '../../helpers/data.helpers.js';
19
19
  import { extractTokensFromTransformations } from '../common/transformations.util.js';
20
20
  import { checkIsIndexMode, checkIsPolygon } from './index-mode.util.js';
21
+ import { chartIntervalToMs, hasRthWindow, isChartRthActive } from './rth-session.util.js';
21
22
  // ============================================================================
22
23
  // CONSTANTS
23
24
  // ============================================================================
@@ -50,6 +51,13 @@ export const INDEX_FETCH_EXTRA_BAR = 1;
50
51
  * - Mixed timestamp-first: Main token is crypto, others include stocks (BTC + NVDA)
51
52
  * - Mixed index-first: Main token is stock, others include crypto (NVDA + BTC)
52
53
  *
54
+ * **Per-token sessions** (`tokenSessionTypes`, the worker resolves each leg's `tradingHour` from its entry, else the
55
+ * chart's `sessionType`): a Polygon leg rides the chart's session (regular unless extended); a leg with an RTH window
56
+ * that is not the chart's own market takes the comparison-leg rule (chart-rth.util `kOhlcvSessionPayloadFields`):
57
+ * 'regular' only while the CHART is RTH-active (`isChartRthActive` at the chart interval), else 'extended'. A crypto or
58
+ * equities chart stamps a meaningless 'regular' it has no control to change, which must never filter a CME leg of its
59
+ * formula to the cash session; the chart's own market reads the chart's session as before.
60
+ *
53
61
  * @param metadata - Chart metadata containing transformations and session settings
54
62
  * @param transformations - Expression string (e.g., "BINANCE|BTCUSDT + POLYGON|NVDA")
55
63
  * @returns Context object with token modes, session types, and mixed-mode flags
@@ -58,6 +66,7 @@ export function buildMixedModeContext(metadata, transformations) {
58
66
  const tokens = extractTokensFromTransformations(transformations);
59
67
  const tokenSessionTypes = {};
60
68
  const tokenExchanges = {};
69
+ let chartRthActive;
61
70
  const tokenModes = tokens.map((token) => {
62
71
  const resolvedExchange = getExchangeFromSymbol(token.exchange ?? '', token.symbol ?? '');
63
72
  const isIndex = checkIsIndexMode(resolvedExchange);
@@ -67,6 +76,11 @@ export function buildMixedModeContext(metadata, transformations) {
67
76
  const resolvedSessionType = metadata.sessionType ?? 'regular';
68
77
  tokenSessionTypes[token.token] = resolvedSessionType;
69
78
  }
79
+ else if (hasRthWindow(token.symbol, resolvedExchange) &&
80
+ !(resolvedExchange === metadata?.exchange && token.symbol === metadata?.symbol)) {
81
+ chartRthActive ??= isChartRthActive(metadata?.exchange, metadata?.symbol, metadata?.sessionType, chartIntervalToMs(metadata?.interval));
82
+ tokenSessionTypes[token.token] = chartRthActive ? 'regular' : 'extended';
83
+ }
70
84
  return {
71
85
  tokenKey: token.token,
72
86
  isIndex,
@@ -2,9 +2,11 @@
2
2
  * The ONE answer to "may this run read the OPRA plane" (UW-PARITY source contract v2, global rule 6):
3
3
  * an official run (an OpenMarket package, any first-party run) always; a draft or community run only
4
4
  * while the `opra-user-scripts` flag opened the plane to it (`isOpraUserScriptRun`,
5
- * kscript-venue-policy.util). Every OPRA door reads it: the data wall and Door C through
6
- * `isOpraReadableKScriptRun`, the wrun run head, the options chain decision, each source lane's
7
- * refusal (`opra-official-only:<class>`) and the poll and row lanes' plan context.
5
+ * kscript-venue-policy.util: the OPRA licence covers user-authored scripting, Kyle 2026-10-27). Every
6
+ * OPRA door reads it: the data wall and Door C through `isOpraReadableKScriptRun`, the wrun run head,
7
+ * the options chain decision, each source lane's refusal (`opra-official-only:<class>`) and the poll
8
+ * and row lanes' plan context. Who may read is all it answers: the tier a read rides is the viewer's,
9
+ * decided by the gate per socket, never by this answer.
8
10
  *
9
11
  * A LEAF on purpose (no imports): the poll-lane and row-lane planners sit on the row builder's import
10
12
  * graph, and the venue policy is worker-safe; both read this without reaching each other.
@@ -2,9 +2,11 @@
2
2
  * The ONE answer to "may this run read the OPRA plane" (UW-PARITY source contract v2, global rule 6):
3
3
  * an official run (an OpenMarket package, any first-party run) always; a draft or community run only
4
4
  * while the `opra-user-scripts` flag opened the plane to it (`isOpraUserScriptRun`,
5
- * kscript-venue-policy.util). Every OPRA door reads it: the data wall and Door C through
6
- * `isOpraReadableKScriptRun`, the wrun run head, the options chain decision, each source lane's
7
- * refusal (`opra-official-only:<class>`) and the poll and row lanes' plan context.
5
+ * kscript-venue-policy.util: the OPRA licence covers user-authored scripting, Kyle 2026-10-27). Every
6
+ * OPRA door reads it: the data wall and Door C through `isOpraReadableKScriptRun`, the wrun run head,
7
+ * the options chain decision, each source lane's refusal (`opra-official-only:<class>`) and the poll
8
+ * and row lanes' plan context. Who may read is all it answers: the tier a read rides is the viewer's,
9
+ * decided by the gate per socket, never by this answer.
8
10
  *
9
11
  * A LEAF on purpose (no imports): the poll-lane and row-lane planners sit on the row builder's import
10
12
  * graph, and the venue policy is worker-safe; both read this without reaching each other.
@@ -1,19 +1,14 @@
1
1
  /**
2
- * The `opra-user-scripts` runtime flag as the venue policy reads it (kscript-venue-policy.util, the one decider of
3
- * the governed walls). Dependency-free on purpose, the shape of exchange-visibility.util and telemetryGates: the
4
- * venue policy stays worker-safe and store-free, so the feature-flags store hands it readers instead.
5
- *
6
- * Two readers, one answer: the store registers its override-aware `isOn` as the fallback when it is created, and
7
- * publishes its reader again after every successful fetch. Until a fetch publishes, the fallback answers, so the dev
8
- * and internal `kiyo.flag-overrides` lens reaches the walls before the map lands and through a failed fetch, exactly
9
- * as it reaches `opraUserScriptsEnabled` (opra-options-gate.util) and the editor's Run wall: the walls and the
10
- * surfaces never disagree, and a restore that skipped the hydration wait on an override judges by that override. In
11
- * any context neither reached (a worker, a guest-less spec), the gate reads closed: fail dark, today's wall.
2
+ * The `opra-user-scripts` gate as the venue policy reads it (kscript-venue-policy.util, the one decider of the
3
+ * governed walls). LAUNCHED 2026-10-27 (Kyle: ship it directly): the OPRA licence covers user-authored scripting,
4
+ * so the gate answers open on every build, in every context (the main thread, a worker, a spec). The runtime flag
5
+ * record `opra-user-scripts` is retired: the feature-flags store still calls the two setters below after it is
6
+ * created and after every fetch, and they keep nothing, so a flipped record changes nothing. Rollback is a revert of
7
+ * this file and opra-options-gate.util, picked to production.
12
8
  */
13
- /** Called by the feature-flags store after a successful fetch (and by tests); null unpublishes. */
14
- export declare function publishOpraUserScriptsFlag(next: (() => boolean) | null): void;
15
- /** Called by the feature-flags store when it is created: its override-aware `isOn`, read until a fetch publishes. */
16
- export declare function setOpraUserScriptsFlagFallback(next: (() => boolean) | null): void;
17
- /** Whether the `opra-user-scripts` flag is on for this session: the published answer, else the store's own; closed
18
- * when neither can tell. */
9
+ /** Retired: the feature-flags store's publish after a fetch; the gate keeps no reader. */
10
+ export declare function publishOpraUserScriptsFlag(_next: (() => boolean) | null): void;
11
+ /** Retired: the feature-flags store's override-aware fallback; the gate keeps no reader. */
12
+ export declare function setOpraUserScriptsFlagFallback(_next: (() => boolean) | null): void;
13
+ /** Whether a user run may read the OPRA plane at the viewer's tier: always, since the launch. */
19
14
  export declare function isOpraUserScriptsFlagOn(): boolean;
@@ -1,32 +1,16 @@
1
1
  /**
2
- * The `opra-user-scripts` runtime flag as the venue policy reads it (kscript-venue-policy.util, the one decider of
3
- * the governed walls). Dependency-free on purpose, the shape of exchange-visibility.util and telemetryGates: the
4
- * venue policy stays worker-safe and store-free, so the feature-flags store hands it readers instead.
5
- *
6
- * Two readers, one answer: the store registers its override-aware `isOn` as the fallback when it is created, and
7
- * publishes its reader again after every successful fetch. Until a fetch publishes, the fallback answers, so the dev
8
- * and internal `kiyo.flag-overrides` lens reaches the walls before the map lands and through a failed fetch, exactly
9
- * as it reaches `opraUserScriptsEnabled` (opra-options-gate.util) and the editor's Run wall: the walls and the
10
- * surfaces never disagree, and a restore that skipped the hydration wait on an override judges by that override. In
11
- * any context neither reached (a worker, a guest-less spec), the gate reads closed: fail dark, today's wall.
2
+ * The `opra-user-scripts` gate as the venue policy reads it (kscript-venue-policy.util, the one decider of the
3
+ * governed walls). LAUNCHED 2026-10-27 (Kyle: ship it directly): the OPRA licence covers user-authored scripting,
4
+ * so the gate answers open on every build, in every context (the main thread, a worker, a spec). The runtime flag
5
+ * record `opra-user-scripts` is retired: the feature-flags store still calls the two setters below after it is
6
+ * created and after every fetch, and they keep nothing, so a flipped record changes nothing. Rollback is a revert of
7
+ * this file and opra-options-gate.util, picked to production.
12
8
  */
13
- let published = null;
14
- let fallback = null;
15
- /** Called by the feature-flags store after a successful fetch (and by tests); null unpublishes. */
16
- export function publishOpraUserScriptsFlag(next) {
17
- published = next;
18
- }
19
- /** Called by the feature-flags store when it is created: its override-aware `isOn`, read until a fetch publishes. */
20
- export function setOpraUserScriptsFlagFallback(next) {
21
- fallback = next;
22
- }
23
- /** Whether the `opra-user-scripts` flag is on for this session: the published answer, else the store's own; closed
24
- * when neither can tell. */
9
+ /** Retired: the feature-flags store's publish after a fetch; the gate keeps no reader. */
10
+ export function publishOpraUserScriptsFlag(_next) { }
11
+ /** Retired: the feature-flags store's override-aware fallback; the gate keeps no reader. */
12
+ export function setOpraUserScriptsFlagFallback(_next) { }
13
+ /** Whether a user run may read the OPRA plane at the viewer's tier: always, since the launch. */
25
14
  export function isOpraUserScriptsFlagOn() {
26
- try {
27
- return (published ?? fallback)?.() === true;
28
- }
29
- catch {
30
- return false;
31
- }
15
+ return true;
32
16
  }
@@ -28,14 +28,15 @@ export declare function futuresRootOf(symbol: unknown): string | null;
28
28
  */
29
29
  export declare function getRthWindowForSymbol(symbol: unknown): Readonly<RthWindow> | null;
30
30
  /**
31
- * The RTH window the kScript engine's venue-sessions table gives a symbol:
32
- * the platform window for every mapped root, NYMEX included (engine 3.0.94).
33
- * Script-facing session facts read this one (wrun `time.session`,
34
- * wrun-bar-session-facts.util), so a browser run of an indicator agrees with
35
- * its cloud run and with the engine's `inSession` / `vwap(session="rth")`;
36
- * every chart gate reads `getRthWindowForSymbol`. It moves to the exchange
37
- * windows only in a coordinated change of the engine, the WRUN-SESSIONS C3
38
- * golden and the cloud lanes. Null for an unmapped root.
31
+ * The RTH window the script-facing session facts read for a symbol (wrun
32
+ * `time.session`, wrun-bar-session-facts.util): the root's own window, the one
33
+ * every chart gate reads (`getRthWindowForSymbol`: 09:00 to 14:30 New York on
34
+ * the NYMEX energy roots, 09:30 to 16:15 on every other mapped root), so an
35
+ * indicator's session reads the bars the chart's RTH mode keeps. The shared
36
+ * host's venue layer (om session-facts-venues.ts) reads the same windows and
37
+ * the WRUN-SESSIONS C3 golden pins them, so the browser and cloud runs agree.
38
+ * The kScript engine's uniform table (the platform window on every root) is
39
+ * being retired and binds nothing. Null for an unmapped root.
39
40
  */
40
41
  export declare function engineRthWindowForSymbol(symbol: unknown): Readonly<RthWindow> | null;
41
42
  export declare const SESSION_HOURS_ETH: "eth";
@@ -236,13 +237,14 @@ export declare function rthSessionCloseMs(symbol: unknown, tsMs: number): number
236
237
  /**
237
238
  * The instant a FOLDED footprint bucket stops changing, on either fold grid:
238
239
  * anchored buckets end at `min(start + tf, session close)`
239
- * (`rthAnchoredBucketEndMs`); utc-grid buckets nominally end at `start + tf`
240
+ * (`rthAnchoredBucketEndMs`); 'eth'-grid buckets (the market's own full-session
241
+ * grid, whose starts the caller keys) nominally end at `start + tf`
240
242
  * but the RTH filter stops feeding them at the session close, so the bucket
241
243
  * holding the close is complete at 20:15Z, not at the top of the next hour.
242
244
  * Forming/closed classification (the poll-apply gate) must use this end or a
243
245
  * closed stub/close-straddling row would count as forming long after it froze.
244
246
  */
245
- export declare function footprintFoldBucketEndMs(symbol: unknown, bucketStartMs: number, tfMs: number, bucketMode: 'anchored' | 'utc'): number | null;
247
+ export declare function footprintFoldBucketEndMs(symbol: unknown, bucketStartMs: number, tfMs: number, bucketMode: 'anchored' | 'eth'): number | null;
246
248
  /**
247
249
  * Does the bucket `[bucketStartMs, bucketStartMs + tfMs)` overlap its venue
248
250
  * day's RTH session at all? The live gate for FOLDED footprints on the utc
@@ -18,19 +18,21 @@
18
18
  * rows through `isWithinRthWindow`, the live-feed service gates merges).
19
19
  *
20
20
  * The ROOT SET mirrors the engine's venue-sessions module
21
- * (`@orangecharts/kscript` `dist/kscript/venue-sessions.d.ts`): when a root
22
- * is added there, add it here in the same wave (and vice versa). The
23
- * published package ships ONLY the .d.ts for that subpath (the implementation
24
- * is bundled and mangled inside `dist/kscript-engine.js` and not re-exported
21
+ * (`@orangecharts/kscript` `dist/kscript/venue-sessions.d.ts`) and the shared
22
+ * host's venue layer (om `packages/sdk/src/wrun-host/session-facts-venues.ts`
23
+ * `RTH_ROOT_EXCHANGES`, the same root to listing-exchange table): when a root
24
+ * is added to one, add it to the others in the same wave. The published
25
+ * engine package ships ONLY the .d.ts for that subpath (the implementation is
26
+ * bundled and mangled inside `dist/kscript-engine.js` and not re-exported
25
27
  * from the main entry), so the runtime import cannot resolve; `futuresRootOf`
26
28
  * below is a verbatim mirror of the engine source. The WINDOWS follow the
27
- * wire, not the engine: the engine table (3.0.94) still gives the NYMEX
28
- * energy roots the uniform 09:30-16:15 window, so `inSession(session="rth")`
29
- * and `vwap(session="rth")` on those roots disagree with the chart until the
30
- * engine adopts the energy window; the wrun session facts stay on the
31
- * engine's table through `engineRthWindowForSymbol` so browser and cloud runs
32
- * agree. Swap these exports for re-exports of the engine subpath once a
33
- * release emits the module as importable JS and carries the same windows.
29
+ * wire, not the engine: the engine table (3.0.94) gives the NYMEX energy
30
+ * roots the uniform 09:30-16:15 window, and that table is being retired, so it
31
+ * binds nothing here. Every reader takes the root's own window from this
32
+ * table: the chart's gates (`getRthWindowForSymbol`) and the script-facing
33
+ * session facts (`engineRthWindowForSymbol`, wrun `time.session`), the energy
34
+ * pit session on NYMEX included, and the shared host's venue layer reads the
35
+ * same windows, so a browser run and a cloud run of one indicator agree.
34
36
  */
35
37
  import dayjs from 'dayjs';
36
38
  import timezone from 'dayjs/plugin/timezone.js';
@@ -190,17 +192,18 @@ export function getRthWindowForSymbol(symbol) {
190
192
  return root ? (RTH_WINDOW_BY_ROOT.get(root) ?? null) : null;
191
193
  }
192
194
  /**
193
- * The RTH window the kScript engine's venue-sessions table gives a symbol:
194
- * the platform window for every mapped root, NYMEX included (engine 3.0.94).
195
- * Script-facing session facts read this one (wrun `time.session`,
196
- * wrun-bar-session-facts.util), so a browser run of an indicator agrees with
197
- * its cloud run and with the engine's `inSession` / `vwap(session="rth")`;
198
- * every chart gate reads `getRthWindowForSymbol`. It moves to the exchange
199
- * windows only in a coordinated change of the engine, the WRUN-SESSIONS C3
200
- * golden and the cloud lanes. Null for an unmapped root.
195
+ * The RTH window the script-facing session facts read for a symbol (wrun
196
+ * `time.session`, wrun-bar-session-facts.util): the root's own window, the one
197
+ * every chart gate reads (`getRthWindowForSymbol`: 09:00 to 14:30 New York on
198
+ * the NYMEX energy roots, 09:30 to 16:15 on every other mapped root), so an
199
+ * indicator's session reads the bars the chart's RTH mode keeps. The shared
200
+ * host's venue layer (om session-facts-venues.ts) reads the same windows and
201
+ * the WRUN-SESSIONS C3 golden pins them, so the browser and cloud runs agree.
202
+ * The kScript engine's uniform table (the platform window on every root) is
203
+ * being retired and binds nothing. Null for an unmapped root.
201
204
  */
202
205
  export function engineRthWindowForSymbol(symbol) {
203
- return getRthWindowForSymbol(symbol) === null ? null : CME_PLATFORM_RTH;
206
+ return getRthWindowForSymbol(symbol);
204
207
  }
205
208
  /** Root of a `<ROOT>1!` continuous symbol, mirroring the engine's fallback. */
206
209
  function continuousRthRootOf(symbol) {
@@ -659,7 +662,8 @@ export function rthSessionCloseMs(symbol, tsMs) {
659
662
  /**
660
663
  * The instant a FOLDED footprint bucket stops changing, on either fold grid:
661
664
  * anchored buckets end at `min(start + tf, session close)`
662
- * (`rthAnchoredBucketEndMs`); utc-grid buckets nominally end at `start + tf`
665
+ * (`rthAnchoredBucketEndMs`); 'eth'-grid buckets (the market's own full-session
666
+ * grid, whose starts the caller keys) nominally end at `start + tf`
663
667
  * but the RTH filter stops feeding them at the session close, so the bucket
664
668
  * holding the close is complete at 20:15Z, not at the top of the next hour.
665
669
  * Forming/closed classification (the poll-apply gate) must use this end or a
@@ -61,6 +61,23 @@ export type TradingDayPeriod = 'Session' | 'Week' | 'Month' | 'Year';
61
61
  * at the reopen print, with no venue holiday knowledge needed.
62
62
  */
63
63
  export declare function getTradingDayPeriodStartSec(timestampSec: number, period: TradingDayPeriod, anchor: TradingDayAnchor): number;
64
+ /** The calendar units a session period can run on trading dates. */
65
+ export type TradingPeriodUnit = 'week' | 'month';
66
+ /**
67
+ * The open (ms) of the `count`-unit calendar period holding the TRADING date
68
+ * of `tsMs`: weeks on the ISO Monday lattice, months from January 1970 (so 3
69
+ * is the calendar quarter and 12 the year), grouped as titan groups them
70
+ * (utils/tradingDay.ts calendarGroupIndex), opening with the trading day
71
+ * labeled by the period's first calendar date (Sunday 17:00 America/Chicago
72
+ * for a CME Monday). Titan's `tradingPeriodStartMs`, the grid a session
73
+ * profile folds its weekly and monthly cells on under `calendarPeriodAnchor:
74
+ * 'tradingDay'` (src/renderers/profile/sessionGrid.ts); the fetch-head decider
75
+ * and the history trim mirror it here. `getTradingDayPeriodStartSec` is the
76
+ * same rule for one week, one month and one year, in seconds.
77
+ */
78
+ export declare function tradingPeriodStartMs(tsMs: number, anchor: TradingDayAnchor, unit: TradingPeriodUnit, count: number): number;
79
+ /** The first period open strictly after `tsMs` (the end of the period holding it). */
80
+ export declare function nextTradingPeriodStartMs(tsMs: number, anchor: TradingDayAnchor, unit: TradingPeriodUnit, count: number): number;
64
81
  /**
65
82
  * The TPO custom-time-range projection of an anchor, or undefined when the
66
83
  * anchor is absent, invalid, or has no wire-expressible projection. The CME