@orangecharts/wrun-chart-host 0.15.0 → 0.16.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 (175) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/economic.constants.d.ts +2 -0
  3. package/dist/constants/economic.constants.js +2 -0
  4. package/dist/constants/feature-flags.constants.d.ts +10 -0
  5. package/dist/constants/feature-flags.constants.js +52 -4
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +98 -20
  8. package/dist/constants/interval.constants.js +5 -0
  9. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
  10. package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
  11. package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
  12. package/dist/constants/typed-width-fold.leaf.js +99 -0
  13. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  14. package/dist/constants/typed-width-source.leaf.js +126 -0
  15. package/dist/constants/typed-width.leaf.d.ts +57 -0
  16. package/dist/constants/typed-width.leaf.js +78 -0
  17. package/dist/host-env.d.ts +10 -0
  18. package/dist/host-env.js +7 -0
  19. package/dist/host-ports.types.d.ts +11 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +3 -0
  22. package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
  23. package/dist/interfaces/wrun-runtime.interface.d.ts +63 -3
  24. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  25. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  26. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  27. package/dist/market-data/billing.interface.d.ts +12 -45
  28. package/dist/market-data/billing.interface.js +2 -2
  29. package/dist/replay/replayLadder.js +7 -4
  30. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  31. package/dist/settings-templates/footprint-rows.js +6 -0
  32. package/dist/settings-templates/frvp-fields.js +14 -0
  33. package/dist/settings-templates/indicator-fields.js +31 -0
  34. package/dist/settings-templates/tool-tables.generated.js +19 -1
  35. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  36. package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
  37. package/dist/utility/chart/cache-alignment.util.js +88 -18
  38. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  39. package/dist/utility/chart/calendar-interval.util.js +152 -4
  40. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  41. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  42. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  43. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  44. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  45. package/dist/utility/chart/feed-interval.util.js +5 -2
  46. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  47. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  48. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  49. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  50. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  51. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  52. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  53. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  54. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  55. package/dist/utility/chart/history-wall.util.js +11 -4
  56. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  57. package/dist/utility/chart/interval-ladder.util.js +44 -4
  58. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  59. package/dist/utility/chart/interval-registry.util.js +50 -2
  60. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  61. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  62. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  63. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  64. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  65. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  66. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  67. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  68. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  69. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  70. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  71. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  72. package/dist/utility/chart/live-bucket.util.js +45 -12
  73. package/dist/utility/chart/market-session.util.d.ts +62 -10
  74. package/dist/utility/chart/market-session.util.js +93 -13
  75. package/dist/utility/chart/marketKind.util.d.ts +1 -7
  76. package/dist/utility/chart/marketKind.util.js +6 -8
  77. package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
  78. package/dist/utility/chart/om-target.util.js +6 -4
  79. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  80. package/dist/utility/chart/price-precision.util.js +34 -7
  81. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  82. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  83. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  84. package/dist/utility/chart/rth-session.util.js +3 -1
  85. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  86. package/dist/utility/chart/script-source-session.util.js +61 -0
  87. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  88. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  89. package/dist/utility/common/transformations.util.d.ts +6 -0
  90. package/dist/utility/common/transformations.util.js +28 -4
  91. package/dist/utility/number-format.util.d.ts +14 -1
  92. package/dist/utility/number-format.util.js +22 -4
  93. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  94. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
  95. package/dist/utility/v2/v2-enums.leaf.js +3 -0
  96. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +9 -3
  97. package/dist/utility/wrun/wrun-batched-marks.util.js +65 -17
  98. package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
  99. package/dist/utility/wrun/wrun-canvases.util.js +7 -12
  100. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  101. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  102. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  103. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  104. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
  105. package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
  106. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  107. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  108. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  109. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  110. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  111. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  112. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  113. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  114. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  115. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  116. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  117. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  118. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  119. package/dist/utility/wrun/wrun-frames.js +2 -2
  120. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  121. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  122. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  123. package/dist/utility/wrun/wrun-host.service.js +44 -2
  124. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  125. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  126. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  127. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  128. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  129. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  130. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  131. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  132. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  133. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  134. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  135. package/dist/utility/wrun/wrun-live-tick.util.js +59 -4
  136. package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
  137. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +15 -0
  138. package/dist/utility/wrun/wrun-overlay-run.util.js +274 -47
  139. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
  140. package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
  141. package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
  142. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  143. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  144. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  145. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  146. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  147. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  148. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  149. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  150. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  151. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  152. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  153. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  154. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  155. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  156. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  157. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  158. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  159. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  160. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  161. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  162. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  163. package/dist/utility/wrun-display-name.util.js +21 -0
  164. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  165. package/dist/utils/replay/replay-buffer-math.js +2 -0
  166. package/dist/workers/constants/socket-slots.d.ts +1 -1
  167. package/dist/workers/utils/time.worker.util.js +2 -2
  168. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  169. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  170. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  171. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  172. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  173. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  174. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  175. package/package.json +11 -11
@@ -6,6 +6,34 @@ export async function readWrunHostedWire(output) {
6
6
  const { decodeWrunHostedWire } = await wrunChartHostEnv().loadSharedHost();
7
7
  return decodeWrunHostedWire(output);
8
8
  }
9
+ const WRUN_GOVERNED_PLANES = ['cme', 'stocks'];
10
+ /**
11
+ * Read a reply's `wrunGoverned` mark: undefined when the reply carries no such record or it names no plane. A plane is
12
+ * named by an own key holding anything but `undefined`, `null` or `false` (fail closed: the mark withholds, so a
13
+ * receipt the chart cannot read still marks its plane); its receipt fields ride only when well formed.
14
+ */
15
+ export function readWrunGovernedMark(value) {
16
+ if (!isRecord(value))
17
+ return undefined;
18
+ const mark = {};
19
+ for (const plane of WRUN_GOVERNED_PLANES) {
20
+ if (!Object.hasOwn(value, plane))
21
+ continue;
22
+ const entry = value[plane];
23
+ if (entry === undefined || entry === null || entry === false)
24
+ continue;
25
+ const read = {};
26
+ if (isRecord(entry)) {
27
+ if (typeof entry.tier === 'string' && entry.tier.length > 0)
28
+ read.tier = entry.tier;
29
+ const delay = entry.delaySeconds;
30
+ if (typeof delay === 'number' && Number.isFinite(delay) && delay >= 0)
31
+ read.delaySeconds = delay;
32
+ }
33
+ mark[plane] = read;
34
+ }
35
+ return Object.keys(mark).length > 0 ? mark : undefined;
36
+ }
9
37
  /** Read a reply's run-level keys beside the wire: each own key exactly as the reply carries it (the OPRA mark only as
10
38
  * the boolean `true`, its receipt only beside it), never a key inside `wrunHost`. A reply that is not a record
11
39
  * carries none. */
@@ -32,8 +60,34 @@ export function readWrunHostedRunLevel(output) {
32
60
  level.wrunOpraDelaySeconds = delay;
33
61
  }
34
62
  }
63
+ const governed = Object.hasOwn(output, 'wrunGoverned') ? readWrunGovernedMark(output.wrunGoverned) : undefined;
64
+ if (governed !== undefined)
65
+ level.wrunGoverned = governed;
35
66
  return level;
36
67
  }
68
+ /** A mark that names every governed plane with no receipt: what a mark the chart cannot read stands for. */
69
+ const WRUN_GOVERNED_UNREADABLE = Object.freeze({ cme: {}, stocks: {} });
70
+ /**
71
+ * THE one fail-closed reader of a governed run's server mark, for every reader of a cloud answer (the socket row
72
+ * source's replies and live frames, its error frames' relayed details, the Cloud test's reply and error frame): the
73
+ * `wrunGoverned` key of `container` (a reply's `output`, or an error frame's `details`). A key holding anything but
74
+ * nothing (`undefined`, `null`, `false`) or a record is a mark the chart cannot read, and names every plane
75
+ * (`WRUN_GOVERNED_UNREADABLE`: a `true`, a word, a number, an array). A record naming no plane is no mark. Lane-blind and
76
+ * author-blind: the mark alone decides.
77
+ */
78
+ export function wrunGovernedMarkOf(container) {
79
+ if (typeof container !== 'object' || container === null)
80
+ return undefined;
81
+ const read = readWrunHostedRunLevel(container).wrunGoverned;
82
+ if (read !== undefined)
83
+ return read;
84
+ if (!Object.hasOwn(container, 'wrunGoverned'))
85
+ return undefined;
86
+ const raw = container.wrunGoverned;
87
+ if (raw === undefined || raw === null || raw === false)
88
+ return undefined;
89
+ return isRecord(raw) ? undefined : WRUN_GOVERNED_UNREADABLE;
90
+ }
37
91
  function isRecord(value) {
38
92
  return typeof value === 'object' && value !== null && !Array.isArray(value);
39
93
  }
@@ -22,6 +22,7 @@
22
22
  */
23
23
  import type { WrunGaugeDraw, WrunHoverBlock, WrunHud, WrunHudChrome, WrunHudLook, WrunIndicatorMetadata, WrunMeterDraw, WrunPillDraw, WrunSparkDraw, WrunTextCase } from '../../interfaces/wrun-runtime.interface.js';
24
24
  import type { WrunLatestSnapshot } from './wrun-latest-snapshot.js';
25
+ import './wrun-colour-tone.util.js';
25
26
  import { type WrunColorTheme, type WrunFontFamily, type WrunFontWeight } from './wrun-style-words.util.js';
26
27
  /** LK01: the looks, the rows of the look table. */
27
28
  export declare const WRUN_HUD_LOOKS: readonly ["default", "glass", "stage", "signal", "terminal", "broadsheet", "chart_desk", "dial", "grid", "cockpit", "phosphor", "classic"];
@@ -1,4 +1,6 @@
1
- import { WRUN_FONT_FAMILIES, isWrunColorWord, resolveWrunColorWord, wrunFontFamilyCss, wrunFontWeightCss, } from './wrun-style-words.util.js';
1
+ // Bound before the fallback palette below reads the mark colours (off the boot path).
2
+ import './wrun-colour-tone.util.js';
3
+ import { WRUN_FONT_FAMILIES, isWrunColorWord, resolveWrunColorWord, wrunColorThemeOf, wrunFontFamilyCss, wrunFontWeightCss, } from './wrun-style-words.util.js';
2
4
  // ── Word lists (the om kit's `wrun-style/widgets.ts`, restated) ──────────────
3
5
  /** LK01: the looks, the rows of the look table. */
4
6
  export const WRUN_HUD_LOOKS = [
@@ -534,16 +536,9 @@ export function resolveWrunHudLook(entry, options = {}) {
534
536
  css,
535
537
  };
536
538
  }
537
- /** The dark-chart palette a resolver without a chart answers `theme.down` with. */
538
- const FALLBACK_THEME = {
539
- up: '#26a69a',
540
- down: '#ef5350',
541
- text: '#d1d4dc',
542
- muted: 'rgba(209, 212, 220, 0.55)',
543
- bg: '#131722',
544
- grid: '#2a2e39',
545
- accent: '#ff4608',
546
- };
539
+ /** The dark-chart palette a resolver without a chart answers `theme.down` with
540
+ * (the palette a chart without a theme answers). */
541
+ const FALLBACK_THEME = wrunColorThemeOf(undefined);
547
542
  /**
548
543
  * The defaults the look in force gives a tile of `kind` (undefined fields
549
544
  * keep the kit's own drawing). `cardMark` is the card's first meter mark, the
@@ -12,6 +12,30 @@ import type { WrunRunReason } from './wrun-lifecycle.contract.js';
12
12
  /** The core's `owedFullIntegration` for a wrun run: one of the reasons above,
13
13
  * or no good result on the overlay yet. */
14
14
  export declare function wrunRunOwesFullIntegration(reason: WrunRunReason, hasGoodResult: boolean): boolean;
15
+ /** What a run's drawings do to the overlay's mounted drawing set. */
16
+ export type WrunRunDrawingsPlan = 'replace' | 'keep-mounted';
17
+ /**
18
+ * The drawings rule of a wrun run, beside its row route (both apply routes, the rows merge and the remount, read it).
19
+ * A script's handles make and delete drawings over the whole history it ran on (a session level deleted after 13
20
+ * sessions, a gap mitigated weeks later), so only a whole-range run can produce the set the newest bar should show. A
21
+ * partial window (the pan wave's clamped span, a prefix page) answers rows inside that window only: its rows apply on
22
+ * their route, but its drawings never replace the mounted set, which stays until a whole-range result lands. A run that
23
+ * owes a full integration (no good result yet, or a reason that asks a new question: new settings, another market, a
24
+ * resume) replaces whatever its window, since the mounted set answers an old question or nothing. A redraw of the live
25
+ * session's own computation (its reseed, its style repaint, its TPO block refine) replaces too: the session's set is
26
+ * what every live tick mounts (wrun-live-tick.util hands the tick's whole result to the drawing door), so a redraw that
27
+ * kept the older set would leave the old look until the next tick, and on a quiet market until a whole-range run.
28
+ * 'keep-mounted' means the mounted set is LEFT ALONE: the adapter is handed no drawings and told so
29
+ * (`keepMountedDrawings`), never handed the mounted set back as input.
30
+ */
31
+ export declare function wrunRunDrawingsPlan(input: {
32
+ /** The run computed a window narrower than the loaded range (`WrunRunWindow.partial`). */
33
+ partialWindow: boolean;
34
+ /** `wrunRunOwesFullIntegration` for the run. */
35
+ owedFullIntegration: boolean;
36
+ /** The result redraws the overlay's live session's own computation (`WrunIntegrateOptions.sessionRedraw`). */
37
+ sessionRedraw: boolean;
38
+ }): WrunRunDrawingsPlan;
15
39
  export interface WrunIntegrationRouteInput {
16
40
  reason: WrunRunReason;
17
41
  /** The overlay shows a result an earlier run of this lane integrated. */
@@ -25,6 +25,25 @@ const WRUN_FULL_INTEGRATION_REASONS = new Set([
25
25
  export function wrunRunOwesFullIntegration(reason, hasGoodResult) {
26
26
  return !hasGoodResult || WRUN_FULL_INTEGRATION_REASONS.has(reason);
27
27
  }
28
+ /**
29
+ * The drawings rule of a wrun run, beside its row route (both apply routes, the rows merge and the remount, read it).
30
+ * A script's handles make and delete drawings over the whole history it ran on (a session level deleted after 13
31
+ * sessions, a gap mitigated weeks later), so only a whole-range run can produce the set the newest bar should show. A
32
+ * partial window (the pan wave's clamped span, a prefix page) answers rows inside that window only: its rows apply on
33
+ * their route, but its drawings never replace the mounted set, which stays until a whole-range result lands. A run that
34
+ * owes a full integration (no good result yet, or a reason that asks a new question: new settings, another market, a
35
+ * resume) replaces whatever its window, since the mounted set answers an old question or nothing. A redraw of the live
36
+ * session's own computation (its reseed, its style repaint, its TPO block refine) replaces too: the session's set is
37
+ * what every live tick mounts (wrun-live-tick.util hands the tick's whole result to the drawing door), so a redraw that
38
+ * kept the older set would leave the old look until the next tick, and on a quiet market until a whole-range run.
39
+ * 'keep-mounted' means the mounted set is LEFT ALONE: the adapter is handed no drawings and told so
40
+ * (`keepMountedDrawings`), never handed the mounted set back as input.
41
+ */
42
+ export function wrunRunDrawingsPlan(input) {
43
+ if (input.sessionRedraw)
44
+ return 'replace';
45
+ return input.partialWindow && !input.owedFullIntegration ? 'keep-mounted' : 'replace';
46
+ }
28
47
  /**
29
48
  * In order: the identity check, the unchanged-result skip (never over stale
30
49
  * settings or an owed full integration), then the core. Its inputs: stale
@@ -76,6 +76,8 @@ import { FUNDING_INTERVAL_MAP } from '../../constants/overlay-data.constants.js'
76
76
  import { liveCandleAtInterval, mergeLiveOhlcvDataPoint } from '../../kscript-data/controls/live-ohlcv-merge.util.js';
77
77
  import { liveTradeOfPoint, mergeLiveTradesDataPoint, readLiveTradePrint, tradesBarStartMs, tradesTapeCellSize, tradesTapeFloorValuesPrints, } from '../../kscript-data/controls/live-trades-merge.util.js';
78
78
  import { liveAmountUsd, peekOptionTradeUnits } from '../options/option-trade-units.util.js';
79
+ import { profileFrameLastInstantMs } from '../chart/profile-frame-window.util.js';
80
+ import { isInScriptSourceSession, isVolumeProfileLiveFrameInSession, tapeSourceSessionHours, } from '../chart/script-source-session.util.js';
79
81
  import { parseWrunTapeHistory, wrunTapeHistoryOf } from './wrun-tape-source.util.js';
80
82
  import { noteWrunCoinTapePrice } from './wrun-tape-coins.util.js';
81
83
  import { wrunDollarUnitReader } from './wrun-dollar-unit-port.leaf.js';
@@ -695,7 +697,16 @@ rowMarket = market) {
695
697
  */
696
698
  export function wrunTapeHostBarResolver(intervalMs, market, rowMarket = market) {
697
699
  const grids = wrunLaneHostGridsOf('trades', intervalMs, market, rowMarket);
698
- return grids && hostBucketResolverFor(intervalMs, grids.hostBar);
700
+ const hostBarOf = grids && hostBucketResolverFor(intervalMs, grids.hostBar);
701
+ const sessionHours = tapeSourceSessionHours(market, intervalMs, rowMarket);
702
+ if (sessionHours === undefined || !rowMarket)
703
+ return hostBarOf;
704
+ // The history worker serves no print outside the candle's session (script-source-session.util): no bar holds one live.
705
+ return (instantMs) => !isInScriptSourceSession(sessionHours, rowMarket.exchange, rowMarket.symbol, instantMs)
706
+ ? null
707
+ : hostBarOf
708
+ ? hostBarOf(instantMs)
709
+ : tradesBarStartMs(instantMs, intervalMs, rowMarket.exchange);
699
710
  }
700
711
  /** The bar a tape print folds into (`wrunTapeHostBarResolver`'s host bar, else its own grid's): the fold, the queue's
701
712
  * loss marks and the reconcile's drops key a print here, so they name one bar. Null: no chart bar holds it. */
@@ -834,6 +845,11 @@ function foldVpPoint(rows, rowIndexOf, point, intervalMs, acquisition, market) {
834
845
  if (!(gridHeight > 0))
835
846
  return null;
836
847
  const precision = getDecimalPlaces(gridHeight);
848
+ // A day-plus bar of a regular stock chart reads its session's ladder only (script-source-session.util), judged at
849
+ // the last instant inside the frame's window: its stamp is the window's end.
850
+ const lastInstantMs = profileFrameLastInstantMs(vpa);
851
+ if (lastInstantMs !== null && !isVolumeProfileLiveFrameInSession(market, intervalMs, lastInstantMs))
852
+ return null;
837
853
  const bucket = wrunLiveBucketTs('volume_profile', tsMs, intervalMs, market);
838
854
  if (bucket === null)
839
855
  return null;
@@ -54,7 +54,12 @@ export declare function wrunLiveValuesEqual(a: unknown, b: unknown): boolean;
54
54
  * differs from its set's first row (stamped among unstamped, or the reverse)
55
55
  * is structural.
56
56
  */
57
- export declare function diffWrunLiveResults(applied: WrunRunResult, next: WrunRunResult): WrunLiveResultChange;
57
+ export declare function diffWrunLiveResults(applied: WrunRunResult, next: WrunRunResult,
58
+ /** Filled with the drawings half of the verdict: whether the drawings or the drawing budget's counts changed
59
+ * (true whenever the diff stopped before comparing them). */
60
+ out?: {
61
+ drawingsChanged?: boolean;
62
+ }): WrunLiveResultChange;
58
63
  /** The chart's bars and the run clock a result applies on. */
59
64
  export declare function wrunLiveChartBarsOf(rows: ReadonlyArray<ArrayLike<number>>, clock: {
60
65
  runMs: number;
@@ -130,7 +130,12 @@ function budgetCounts(budget) {
130
130
  * differs from its set's first row (stamped among unstamped, or the reverse)
131
131
  * is structural.
132
132
  */
133
- export function diffWrunLiveResults(applied, next) {
133
+ export function diffWrunLiveResults(applied, next,
134
+ /** Filled with the drawings half of the verdict: whether the drawings or the drawing budget's counts changed
135
+ * (true whenever the diff stopped before comparing them). */
136
+ out) {
137
+ if (out)
138
+ out.drawingsChanged = true;
134
139
  const before = applied;
135
140
  const after = next;
136
141
  const ownKeys = (record) => Object.keys(record).filter((key) => !WRUN_LIVE_DIFF_OWN_FIELDS.has(key));
@@ -141,9 +146,10 @@ export function diffWrunLiveResults(applied, next) {
141
146
  for (const key of afterKeys)
142
147
  if (!wrunLiveValuesEqual(before[key], after[key]))
143
148
  return STRUCTURAL;
144
- let changed = !wrunLiveValuesEqual(before.drawings, after.drawings);
145
- if (!wrunLiveValuesEqual(budgetCounts(before.drawingsBudget), budgetCounts(after.drawingsBudget)))
146
- changed = true;
149
+ let changed = !wrunLiveValuesEqual(before.drawings, after.drawings) ||
150
+ !wrunLiveValuesEqual(budgetCounts(before.drawingsBudget), budgetCounts(after.drawingsBudget));
151
+ if (out)
152
+ out.drawingsChanged = changed;
147
153
  const beforeOutputs = before.outputs;
148
154
  const afterOutputs = after.outputs;
149
155
  if (beforeOutputs === undefined && afterOutputs === undefined)
@@ -176,7 +176,7 @@ import { ensureWrunChartHostSharedHost, wrunChartHostEnv } from '../../host-env.
176
176
  import { isPackedOhlcvRows, unpackOhlcvRows } from '../../instances/script-engine-worker-ohlcv-transfer.js';
177
177
  import { findMonday } from '../chart/titan-constants.pin.js';
178
178
  import { Intervals } from '../../constants/interval.constants.js';
179
- import { barEndMs, barStartMs, prevBarStartMs } from '../chart/calendar-interval.util.js';
179
+ import { barEndMs, barStartMs, fixedGridFloorDivMs, prevBarStartMs } from '../chart/calendar-interval.util.js';
180
180
  import { isRealChartTimeRangeMs } from '../chart/chart-time-domain.util.js';
181
181
  import { resolveV2LiveEffectiveMinIntervalMs, V2_TECHNICAL_SCRIPT_LIVE_UPDATE_MIN_MS, } from '../chart/live-cadence.util.js';
182
182
  import { noteWrunLiveHiddenHold, noteWrunLiveHiddenReturnDrains, noteWrunLiveHiddenRun, } from './wrun-live-hidden-hold.util.js';
@@ -249,7 +249,7 @@ import { wrunLaneRefusalLeavesWindowOwed, wrunLaneRefusedCodeOf } from './wrun-l
249
249
  import { WRUN_RUN_INTERVAL_ROWS_KEY, wrunRunIntervalComputeRows, wrunRunIntervalProjectionOf, wrunRunIntervalRowsThrough, wrunRunIntervalSentRow, wrunRunIntervalSessionOf, } from './wrun-run-interval-session.util.js';
250
250
  import { WRUN_NO_READY_ROWS_CODE, wrunNothingReadyRefusal, wrunRunHealthDiagnostics } from './wrun-run-health.util.js';
251
251
  import { attachWrunRefusal, serializeWrunRefusal, wrunOverlayEditable, wrunRefusalFor, } from './wrun-refusal.util.js';
252
- import { noteWrunRunRetained, trimWrunRunDrawings } from './wrun-cap-notice.util.js';
252
+ import { noteWrunDrawingsSameAs, noteWrunRunRetained, trimWrunRunDrawings } from './wrun-cap-notice.util.js';
253
253
  import { evictWrunRetainedOutputRows, ringWrunRunRetained, trimWrunRetainedCanvasLanes, wrunRetainedCanvasSources, wrunStrategyOnRows, } from './wrun-run-retained.util.js';
254
254
  import { projectWrunRefusal, retractWrunRefusal, wrunRefusalRetractionCount } from './wrun-refusal-surface.util.js';
255
255
  import { advanceWrunInputCarry, buildWrunInputTailRows, planWrunPinnedWires, wrunDeclaredSourceLanes, wrunDemandedSourceClass, wrunFormingBucketStart, wrunAskWirePieces, wrunChartIntervalKeyOf, wrunPinnedLegTierMs, wrunSourceVerdictWhole, wrunLaneAcquisitionIntervalMs, wrunLegRowHostBar, wrunLegRowVenue, wrunPinnedLegFetchSuffix, wrunTradeLegIntervals, wrunWireRowPieces, wrunChartCandleRows, wrunChartCandleRowsWithin, } from './wrun-source-rows.util.js';
@@ -1407,7 +1407,7 @@ function wrunPinnedLegCloseAt(leg, context, atMs) {
1407
1407
  const { market } = context;
1408
1408
  const settleMs = wrunLegCloseSettleMs(leg, market?.exchange, market?.sessionType);
1409
1409
  const fromMs = atMs - settleMs;
1410
- const open = leg.legMs === Intervals.WEEK ? findMonday(fromMs) : Math.floor(fromMs / leg.legMs) * leg.legMs;
1410
+ const open = leg.legMs === Intervals.WEEK ? findMonday(fromMs) : fixedGridFloorDivMs(fromMs, leg.legMs);
1411
1411
  const closeMs = wrunLegBarCloseAt(leg, market?.exchange, fromMs, market?.sessionType, market?.symbol, context.intervalMs);
1412
1412
  return (closeMs ?? open + leg.legMs) + settleMs;
1413
1413
  }
@@ -1853,6 +1853,38 @@ async function extendWrunReplayRowLanes(context, owed, cursorTs) {
1853
1853
  ledger.inFlight = false;
1854
1854
  }
1855
1855
  }
1856
+ /**
1857
+ * Whether a socket row source's live frame was computed over CME data: its governed mark (`WrunRowFrame.governed`, the
1858
+ * reply's `wrunGoverned`) names the CME plane. Fail closed: a frame carrying a mark that is not a record reads as
1859
+ * marked. A frame with no mark reads unmarked (the source carries a run's mark onto every later frame itself).
1860
+ */
1861
+ function wrunLiveFrameReadsCme(frame) {
1862
+ if (!Object.hasOwn(frame, 'governed'))
1863
+ return false;
1864
+ const governed = frame.governed;
1865
+ if (governed === undefined || governed === null)
1866
+ return false;
1867
+ if (typeof governed !== 'object' || Array.isArray(governed))
1868
+ return true;
1869
+ return governed.cme !== undefined;
1870
+ }
1871
+ /**
1872
+ * Stamp the overlay a CME-marked live frame lands on (wrun-cloud-cme-stamp.util `stampWrunHostedCme`), unless its
1873
+ * result stamped it already. False when the stamp's module does not load or the stamp cannot be written: the frame is
1874
+ * skipped (fail closed).
1875
+ */
1876
+ async function stampWrunLiveFrameCme(chartIndex, indicatorId, meta, owns) {
1877
+ try {
1878
+ const { stampWrunHostedCme, wrunOverlayCmeStamped } = await import('./wrun-cloud-cme-stamp.util.js');
1879
+ if (wrunOverlayCmeStamped(meta))
1880
+ return true;
1881
+ return await stampWrunHostedCme(chartIndex, indicatorId, meta, owns);
1882
+ }
1883
+ catch (error) {
1884
+ console.warn(`[wrun] the CME stamp of '${indicatorId}' did not load; its live frame is skipped:`, error);
1885
+ return false;
1886
+ }
1887
+ }
1856
1888
  /**
1857
1889
  * A socket row source's live frames (WRUN-PARITY-PLAN C7, plan row 18), the drain's integrate of every
1858
1890
  * frame folded since the last one (`queueWrunSourceLiveFrame`): the bars the cloud moved enter the live
@@ -1911,6 +1943,24 @@ export async function integrateWrunOverlayLiveFrame(indicatorId, frame, cellRows
1911
1943
  return;
1912
1944
  if (!wrunLiveTickEligible(context, generation))
1913
1945
  return;
1946
+ // The CME twin (wrun-cloud-cme-stamp.util, the AI boundary that never opens): a frame the cloud computed over CME
1947
+ // (its governed mark names the plane, or a mark that cannot be read) is stamped before anything of it lands,
1948
+ // whoever wrote the script and whatever lane ran it, and a frame whose stamp cannot be written is skipped (fail
1949
+ // closed). An overlay its result stamped already is not written again. A frame never clears the stamp.
1950
+ // The stamp's module loads only for a marked frame (a frame of a run that reads no CME never pulls it in); one
1951
+ // that does not load fails the frame like a stamp that cannot be written.
1952
+ const readsCme = wrunLiveFrameReadsCme(frame);
1953
+ if (readsCme) {
1954
+ const owns = () => wrunLiveTickEligible(context, generation) &&
1955
+ tc.metadata?.includes(meta) === true;
1956
+ if (!(await stampWrunLiveFrameCme(context.chartIndex, indicatorId, meta, owns)))
1957
+ return;
1958
+ if (!wrunLiveTickEligible(context, generation))
1959
+ return;
1960
+ }
1961
+ // The session reads CME from here: its debug lines and its exports state it (the console provenance).
1962
+ if (readsCme)
1963
+ context.cmeRead = true;
1914
1964
  // A frame with the mark names the receipt of the rows it carries (contract opra-server-lanes C4): the legend's
1915
1965
  // served word follows it from this tick on, and a frame naming no tier leaves none (never the account's tier).
1916
1966
  // The session reads OPRA from here: its debug lines state it (the console provenance).
@@ -3151,7 +3201,12 @@ function applyWrunLiveRunResult(context, tc, meta, runResult, projection) {
3151
3201
  const bars = wrunLiveChartBarsOf(chartRows, clock);
3152
3202
  const outcome = withWrunOverlayExecutionMeasure(chartIndex, indicatorId, 'wrun-live-tick', () => {
3153
3203
  const applied = context.repaintOwed ? undefined : context.liveApplied;
3154
- const change = applied && bars ? diffWrunLiveResults(applied.result, runResult) : undefined;
3204
+ const verdict = {};
3205
+ const change = applied && bars ? diffWrunLiveResults(applied.result, runResult, verdict) : undefined;
3206
+ // The drawings verdict travels with the drawings array as a token (wrun-cap-notice.util): equal drawings
3207
+ // under no owed repaint inherit the applied set's token, so the drawing door can skip its pass; anything else
3208
+ // gets a new token and the door runs in full.
3209
+ noteWrunDrawingsSameAs(runResult.drawings, applied && bars && verdict.drawingsChanged === false ? applied.result.drawings : undefined);
3155
3210
  if (applied && bars && change?.kind === 'unchanged' && wrunLiveChartBarsEqual(applied.bars, bars)) {
3156
3211
  return 'unchanged';
3157
3212
  }
@@ -84,6 +84,7 @@ import { closeWrunRefusalAttempts, concludeWrunRefusalAttempt, liveWrunRefusalAt
84
84
  import { attachWrunRefusal, stampWrunRefusalTelemetry } from './wrun-refusal.util.js';
85
85
  import { wrunRunFailedIdentityOf } from './wrun-cap-notice.util.js';
86
86
  import { __resetWrunHistoryAsOfForTests, forgetWrunHistoryAsOf } from './wrun-history-as-of.util.js';
87
+ import { releaseWrunTrapSeedsFor } from './wrun-trap-replay.util.js';
87
88
  import { effectiveChartSessionType } from '../chart/effective-chart-session.util.js';
88
89
  import { wrunMainCandleSourceOf } from './run-schedule/wrun-own-candles.util.js';
89
90
  import { hasWrunChartHostEnv, wrunChartHostEnv } from '../../host-env.js';
@@ -617,6 +618,8 @@ function releaseWrunOverlayLiveSession(indicatorId, mode) {
617
618
  drivers.delete(indicatorId);
618
619
  // The overlay's history session goes with it: an overlay mounted again pins its lanes afresh.
619
620
  forgetWrunHistoryAsOf(indicatorId);
621
+ // A trap replay seed the overlay parked goes with it: nothing replays an overlay that left its chart.
622
+ releaseWrunTrapSeedsFor(indicatorId);
620
623
  // The overlay's refusal attempts and verdicts go with it: a settlement
621
624
  // landing after this claims nothing, and a later tenant starts clean.
622
625
  if (chartIndex !== undefined)
@@ -235,6 +235,14 @@ export interface WrunRunComputedFor {
235
235
  * type. Synchronous over what it reads, so the caller judges in the same task as the act the verdict guards.
236
236
  */
237
237
  export declare function wrunRunSupersededReason(run: WrunRunComputedFor): WrunRunSupersededReason | undefined;
238
+ /** The trap row of an editor draft run that carried a replay seed (wrun-trap-replay.util: a full run or a live start
239
+ * that trapped in the sandbox): the seed parks under a token the row carries in `details.trap.token`, which the
240
+ * editor's replay controller takes it by. Any other row (a published Indicator, an app layer, no seed) as it is, and
241
+ * nothing parks for it. */
242
+ export declare function wrunTrapRowWithReplayToken(trap: RuntimeDiagnostic, error: unknown, overlay: {
243
+ indicatorId: string;
244
+ settings: unknown;
245
+ }): RuntimeDiagnostic;
238
246
  /**
239
247
  * Where a run stands when it fails (the `stage` of `wrun-run-failed`): its head (the holds, the walls, the market
240
248
  * reads), its lanes (the plans and the fetches of the browser lanes), the compute (the sandbox worker, or the row
@@ -1169,6 +1177,13 @@ export type WrunIntegrateOptions = Omit<WrunOverlayResultOptions, 'builtIn'> & {
1169
1177
  pictureIdentity: WrunPictureIdentity | undefined;
1170
1178
  /** The full run's route facts; absent, the result remounts (a reseed, a direct caller). */
1171
1179
  integration?: WrunIntegrationFacts;
1180
+ /** The drawings rule's facts for a caller without route facts that integrates a run's own rows again (the TPO block
1181
+ * refine of a run no live session owns): that run's reason and good-result fact, so the refine keeps or replaces
1182
+ * the mounted drawings exactly as its run did (wrunRunDrawingsPlan). */
1183
+ drawingsRun?: Pick<WrunIntegrationFacts, 'reason' | 'hasGoodResult'>;
1184
+ /** The result redraws the live session's own computation (its reseed, its style repaint, its TPO block refine:
1185
+ * the set every live tick mounts): its drawings replace the mounted set whatever its window (wrunRunDrawingsPlan). */
1186
+ sessionRedraw?: boolean;
1172
1187
  /** A settings gesture's preview (the style patch's session repaint, wrun-style-preview.util): the overlay's
1173
1188
  * settings are never written (no legend palette, no stats strip stamp), so nothing a preview paints reaches its
1174
1189
  * engine copy; the gesture's commit or the cancel's repaint stamps them. */