@orangecharts/wrun-chart-host 0.15.0 → 0.17.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 (202) hide show
  1. package/README.md +2 -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 +13 -5
  5. package/dist/constants/feature-flags.constants.js +76 -35
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +104 -24
  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/marketCapabilities.constants.d.ts +9 -0
  12. package/dist/constants/marketCapabilities.constants.js +39 -11
  13. package/dist/constants/typed-indicator-source.leaf.d.ts +7 -0
  14. package/dist/constants/typed-indicator-source.leaf.js +47 -0
  15. package/dist/constants/typed-session-history-venue.leaf.d.ts +7 -0
  16. package/dist/constants/typed-session-history-venue.leaf.js +9 -0
  17. package/dist/constants/typed-width-fold.leaf.d.ts +52 -0
  18. package/dist/constants/typed-width-fold.leaf.js +101 -0
  19. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  20. package/dist/constants/typed-width-source.leaf.js +126 -0
  21. package/dist/constants/typed-width.leaf.d.ts +57 -0
  22. package/dist/constants/typed-width.leaf.js +78 -0
  23. package/dist/host-env.d.ts +10 -0
  24. package/dist/host-env.js +7 -0
  25. package/dist/host-ports.types.d.ts +23 -17
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +4 -0
  28. package/dist/interfaces/kscript-diagnostics.interface.d.ts +35 -0
  29. package/dist/interfaces/wrun-runtime.interface.d.ts +66 -3
  30. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  31. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  32. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  33. package/dist/market-data/billing.interface.d.ts +12 -45
  34. package/dist/market-data/billing.interface.js +2 -2
  35. package/dist/replay/replayLadder.js +7 -4
  36. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  37. package/dist/settings-templates/footprint-rows.js +6 -0
  38. package/dist/settings-templates/frvp-fields.js +14 -0
  39. package/dist/settings-templates/indicator-fields.js +36 -0
  40. package/dist/settings-templates/tool-tables.generated.js +19 -1
  41. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  42. package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
  43. package/dist/utility/chart/cache-alignment.util.js +88 -18
  44. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  45. package/dist/utility/chart/calendar-interval.util.js +152 -4
  46. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  47. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  48. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  49. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  50. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  51. package/dist/utility/chart/feed-interval.util.js +5 -2
  52. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  53. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  54. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  55. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  56. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  57. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  58. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  59. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  60. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  61. package/dist/utility/chart/history-wall.util.js +11 -4
  62. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  63. package/dist/utility/chart/index-mode.util.d.ts +2 -2
  64. package/dist/utility/chart/index-mode.util.js +12 -6
  65. package/dist/utility/chart/index-otc.leaf.d.ts +37 -0
  66. package/dist/utility/chart/index-otc.leaf.js +68 -0
  67. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  68. package/dist/utility/chart/interval-ladder.util.js +44 -4
  69. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  70. package/dist/utility/chart/interval-registry.util.js +50 -2
  71. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  72. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  73. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  74. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  75. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  76. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  77. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  78. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  79. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  80. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  81. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  82. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  83. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  84. package/dist/utility/chart/live-bucket.util.js +45 -12
  85. package/dist/utility/chart/market-session-schedule.util.d.ts +19 -0
  86. package/dist/utility/chart/market-session-schedule.util.js +2 -1
  87. package/dist/utility/chart/market-session.util.d.ts +62 -10
  88. package/dist/utility/chart/market-session.util.js +93 -13
  89. package/dist/utility/chart/marketKind.util.d.ts +11 -12
  90. package/dist/utility/chart/marketKind.util.js +45 -13
  91. package/dist/utility/chart/mixed-mode.util.d.ts +18 -0
  92. package/dist/utility/chart/om-target.util.js +6 -4
  93. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  94. package/dist/utility/chart/price-precision.util.js +34 -7
  95. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  96. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  97. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  98. package/dist/utility/chart/rth-session.util.js +3 -1
  99. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  100. package/dist/utility/chart/script-source-session.util.js +61 -0
  101. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  102. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  103. package/dist/utility/common/transformations.util.d.ts +6 -0
  104. package/dist/utility/common/transformations.util.js +28 -4
  105. package/dist/utility/market-events/market-events.util.js +3 -0
  106. package/dist/utility/number-format.util.d.ts +14 -1
  107. package/dist/utility/number-format.util.js +22 -4
  108. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  109. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +115 -0
  110. package/dist/utility/v2/v2-enums.leaf.js +5 -0
  111. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +2 -1
  112. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +4 -3
  113. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +13 -3
  114. package/dist/utility/wrun/wrun-batched-marks.util.js +96 -17
  115. package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
  116. package/dist/utility/wrun/wrun-canvases.util.js +7 -12
  117. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  118. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  119. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  120. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  121. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +23 -8
  122. package/dist/utility/wrun/wrun-chart-market-facts.util.js +24 -9
  123. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  124. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  125. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  126. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  127. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +10 -6
  128. package/dist/utility/wrun/wrun-cme-root-specs.util.js +19 -13
  129. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  130. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  131. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  132. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  133. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  134. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  135. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  136. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  137. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  138. package/dist/utility/wrun/wrun-frames.js +2 -2
  139. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  140. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  141. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  142. package/dist/utility/wrun/wrun-host.service.js +44 -2
  143. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  144. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  145. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  146. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  147. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  148. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  149. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  150. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  151. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  152. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  153. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  154. package/dist/utility/wrun/wrun-live-tick.util.js +64 -5
  155. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +40 -6
  156. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +2 -2
  157. package/dist/utility/wrun/wrun-market-size-defaults.util.js +10 -8
  158. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  159. package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
  160. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +17 -0
  161. package/dist/utility/wrun/wrun-overlay-run.util.js +318 -55
  162. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
  163. package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
  164. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +3 -2
  165. package/dist/utility/wrun/wrun-pin-venues.util.js +11 -4
  166. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  167. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  168. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  169. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  170. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  171. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  172. package/dist/utility/wrun/wrun-run-health.util.js +1 -1
  173. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  174. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  175. package/dist/utility/wrun/wrun-session-composition.util.d.ts +3 -2
  176. package/dist/utility/wrun/wrun-session-composition.util.js +3 -2
  177. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  178. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  179. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  180. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  181. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  182. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  183. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  184. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  185. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  186. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  187. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  188. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  189. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  190. package/dist/utility/wrun-display-name.util.js +21 -0
  191. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  192. package/dist/utils/replay/replay-buffer-math.js +2 -0
  193. package/dist/workers/constants/socket-slots.d.ts +1 -1
  194. package/dist/workers/utils/time.worker.util.js +2 -2
  195. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  196. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  197. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  198. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  199. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  200. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  201. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  202. package/package.json +11 -11
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The mark side colour behind `theme.up_mark` / `theme.down_mark` (the Big
3
+ * Trades looks round): the candle colour stepped one tone in OKLab lightness
4
+ * away from the chart's background, so a mark stands off a candle of its own
5
+ * colour on every theme.
6
+ *
7
+ * Off the pre-candle path: `wrun-style-words.util` (a boot module) reaches it
8
+ * only through its door (`wrun-colour-tone.lazy`), which this module binds as
9
+ * it evaluates. Every surface that paints a mark colour imports it statically
10
+ * (the batched marks build, the canvases and HUD fallbacks, the settings
11
+ * dialog's swatches), so it is bound before any of them resolves a token.
12
+ * Main-thread and worker safe (no vue, no DOM, no titan, no kit).
13
+ *
14
+ * The reference is the round's approved mock (its `lab`, `unlab`, `tone` and
15
+ * `sideColour` at amount 0.20 and direction auto), ported step for step so
16
+ * the spec's goldens match it.
17
+ */
18
+ import { bindWrunMarkSideColour } from './wrun-colour-tone.lazy.js';
19
+ import { parseWrunCssColor } from './wrun-style-words.util.js';
20
+ function wrunLinear(channel) {
21
+ const c = channel / 255;
22
+ return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
23
+ }
24
+ function wrunGamma(c) {
25
+ return c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
26
+ }
27
+ /** A colour in OKLab. */
28
+ function wrunLabOf(parts) {
29
+ const r = wrunLinear(parts.r);
30
+ const g = wrunLinear(parts.g);
31
+ const b = wrunLinear(parts.b);
32
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
33
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
34
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
35
+ return [
36
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
37
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
38
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
39
+ ];
40
+ }
41
+ /** OKLab back to `#rrggbb` (lowercase). The hue is kept and the chroma
42
+ * reduced in steps of 4% only as far as needed to land inside sRGB (the
43
+ * mock's loop, its small tolerance included); grey when no step lands. */
44
+ function wrunHexOfLab(L, A, B) {
45
+ for (let k = 1; k >= 0; k -= 0.04) {
46
+ const a = A * k;
47
+ const b = B * k;
48
+ const l3 = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
49
+ const m3 = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
50
+ const s3 = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
51
+ const out = [
52
+ 4.0767416621 * l3 - 3.3077115913 * m3 + 0.2309699292 * s3,
53
+ -1.2684380046 * l3 + 2.6097574011 * m3 - 0.3413193965 * s3,
54
+ -0.0041960863 * l3 - 0.7034186147 * m3 + 1.707614701 * s3,
55
+ ];
56
+ if (out.every((v) => v >= -0.002 && v <= 1.002)) {
57
+ return ('#' +
58
+ out
59
+ .map((v) => Math.round(Math.min(1, Math.max(0, wrunGamma(Math.min(1, Math.max(0, v))))) * 255)
60
+ .toString(16)
61
+ .padStart(2, '0'))
62
+ .join(''));
63
+ }
64
+ }
65
+ return '#808080';
66
+ }
67
+ /** How far a mark side colour steps from its candle colour, in OKLab lightness. */
68
+ export const WRUN_MARK_SIDE_STEP = 0.2;
69
+ /** A background darker than this OKLab lightness is a dark chart. */
70
+ const WRUN_DARK_GROUND_L = 0.5;
71
+ /** On a dark chart a step that would pass this lightness goes down instead. */
72
+ const WRUN_MARK_TOP_L = 0.93;
73
+ /** On a light chart a step that would fall under this lightness goes up instead. */
74
+ const WRUN_MARK_FLOOR_L = 0.12;
75
+ /** The lightness a stepped colour is held to. */
76
+ const WRUN_MARK_MIN_L = 0.05;
77
+ const WRUN_MARK_MAX_L = 0.985;
78
+ /** Stepped colours already worked out, by candle and background (a theme
79
+ * has a handful; the map is emptied when it grows past the cap). */
80
+ const wrunMarkSideCache = new Map();
81
+ const WRUN_MARK_SIDE_CACHE_CAP = 64;
82
+ /**
83
+ * The colour a mark of one side draws in (`theme.up_mark`, `theme.down_mark`):
84
+ * the candle colour stepped {@link WRUN_MARK_SIDE_STEP} in OKLab lightness away
85
+ * from the background, hue and chroma kept (chroma reduced only to stay in
86
+ * sRGB). A background whose lightness is under 0.5 is dark: the step goes up,
87
+ * unless it would pass 0.93 (a near-white candle steps down instead); on a
88
+ * light background the step goes down, unless it would fall under 0.12. The
89
+ * result is held to 0.05..0.985. `#rrggbb` (lowercase); a candle colour with
90
+ * an alpha under 1 keeps it as `rgba(r, g, b, a)`. A colour that does not
91
+ * parse (either one) returns the candle colour unchanged.
92
+ */
93
+ export function markSideColour(candleHex, backgroundHex) {
94
+ const key = `${candleHex}|${backgroundHex}`;
95
+ const known = wrunMarkSideCache.get(key);
96
+ if (known !== undefined)
97
+ return known;
98
+ const candle = parseWrunCssColor(candleHex);
99
+ const ground = parseWrunCssColor(backgroundHex);
100
+ if (candle === undefined || ground === undefined)
101
+ return candleHex;
102
+ const [L, A, B] = wrunLabOf(candle);
103
+ const darkGround = wrunLabOf(ground)[0] < WRUN_DARK_GROUND_L;
104
+ let up = darkGround;
105
+ if (darkGround && L + WRUN_MARK_SIDE_STEP > WRUN_MARK_TOP_L)
106
+ up = false;
107
+ if (!darkGround && L - WRUN_MARK_SIDE_STEP < WRUN_MARK_FLOOR_L)
108
+ up = true;
109
+ const stepped = Math.min(WRUN_MARK_MAX_L, Math.max(WRUN_MARK_MIN_L, L + (up ? WRUN_MARK_SIDE_STEP : -WRUN_MARK_SIDE_STEP)));
110
+ const hex = wrunHexOfLab(stepped, A, B);
111
+ const out = Number(candle.a.toFixed(3)) >= 1
112
+ ? hex
113
+ : `rgba(${parseInt(hex.slice(1, 3), 16)}, ${parseInt(hex.slice(3, 5), 16)}, ${parseInt(hex.slice(5, 7), 16)}, ${Number(candle.a.toFixed(3))})`;
114
+ if (wrunMarkSideCache.size >= WRUN_MARK_SIDE_CACHE_CAP)
115
+ wrunMarkSideCache.clear();
116
+ wrunMarkSideCache.set(key, out);
117
+ return out;
118
+ }
119
+ bindWrunMarkSideColour(markSideColour);
@@ -46,5 +46,6 @@ export declare function wrunDarkPoolIdentity(ctx: WrunRowLaneContext): Promise<R
46
46
  export declare function wrunDarkPoolRows(read: WrunDarkPoolRead, ask: Pick<WrunPollLaneFetchAsk, 'fromTs' | 'toTs' | 'intervalMs' | 'hostBars'>): unknown[][];
47
47
  /** The lane's own fetch: the chart port's window read over the ask from the lane's horizon on (its tape market, the
48
48
  * identity's fields, the horizon as its floor), let go of with the overlay (`ask.signal`), as the lane's rows. The read
49
- * answers its whole window (the edge and a capped day are in its rows), never a part with more to follow. */
50
- export declare function fetchWrunDarkPoolRows(ask: WrunPollLaneFetchAsk): Promise<unknown[][]>;
49
+ * answers its whole window (the edge, a capped day, a date not kept and a date its budget left unread are in its
50
+ * rows), never a part with more to follow. `horizonSpanMs` is the lane's constant; a spec names a wider one. */
51
+ export declare function fetchWrunDarkPoolRows(ask: WrunPollLaneFetchAsk, horizonSpanMs?: number): Promise<unknown[][]>;
@@ -99,15 +99,16 @@ export function wrunDarkPoolRows(read, ask) {
99
99
  }
100
100
  /** The lane's own fetch: the chart port's window read over the ask from the lane's horizon on (its tape market, the
101
101
  * identity's fields, the horizon as its floor), let go of with the overlay (`ask.signal`), as the lane's rows. The read
102
- * answers its whole window (the edge and a capped day are in its rows), never a part with more to follow. */
103
- export async function fetchWrunDarkPoolRows(ask) {
102
+ * answers its whole window (the edge, a capped day, a date not kept and a date its budget left unread are in its
103
+ * rows), never a part with more to follow. `horizonSpanMs` is the lane's constant; a spec names a wider one. */
104
+ export async function fetchWrunDarkPoolRows(ask, horizonSpanMs = WRUN_DARK_POOL_HORIZON_MS) {
104
105
  const { exchange, symbol, coin } = ask.extras;
105
106
  if (typeof exchange !== 'string' || typeof symbol !== 'string' || exchange === '' || symbol === '') {
106
107
  throw new Error(`wrun row lane '${LANE_KEY}' was asked with no tape market`);
107
108
  }
108
109
  // The plan starts a bar's ask at its open, and a yearly bar opens long before the horizon: the source keeps nothing
109
- // older, so the read starts at the horizon (at most three trade dates); the plan keeps that bar partial.
110
- const horizonMs = (ask.nowMs ?? serverNowMs()) - WRUN_DARK_POOL_HORIZON_MS;
110
+ // older, so the read starts at the horizon; the plan keeps that bar partial.
111
+ const horizonMs = (ask.nowMs ?? serverNowMs()) - horizonSpanMs;
111
112
  const fromMs = Math.max(ask.fromTs, horizonMs);
112
113
  if (fromMs >= ask.toTs) {
113
114
  ask.onComplete?.(true);
@@ -66,7 +66,7 @@ export declare const WRUN_PANEL_MAX_KEY_CHARS = 64;
66
66
  export declare const WRUN_PANEL_MIN_MARKER_WIDTH = 0.5;
67
67
  export declare const WRUN_PANEL_MAX_MARKER_WIDTH = 4;
68
68
  /** The kit's colour-word refusal (wrun-style-words.ts `WRUN_COLOR_WORD_MESSAGE`). */
69
- export declare const WRUN_COLOR_WORD_MESSAGE = "a colour must be #rrggbb, #rrggbbaa or one of theme.up, theme.down, theme.text, theme.muted, theme.bg, theme.grid, theme.accent";
69
+ export declare const WRUN_COLOR_WORD_MESSAGE: string;
70
70
  /** The pane dock frame (span "pane", the default): today's three keys plus
71
71
  * the g2 fields. `colors[i]` keeps its string type (any colour form is
72
72
  * honoured or falls back to the level colour, never refused). */
@@ -1,6 +1,6 @@
1
1
  import { isPanelClearFrame, parseSetPanelData } from '../chart/om-panel.util.js';
2
2
  import { wrunChartHostEnv } from '../../host-env.js';
3
- import { isWrunColorWord, WRUN_FONT_WEIGHTS } from './wrun-style-words.util.js';
3
+ import { isWrunColorWord, WRUN_FONT_WEIGHTS, WRUN_THEME_TOKEN_WORDS_TEXT } from './wrun-style-words.util.js';
4
4
  import { wrunPlainText } from './wrun-text-params.util.js';
5
5
  import { parseWrunRowMarkets, wrunRowMarketsLengthMessage } from './wrun-row-market.util.js';
6
6
  export const WRUN_FRAME_DEFAULT_MAX_BYTES = 98_304;
@@ -46,7 +46,7 @@ export const WRUN_PANEL_MAX_KEY_CHARS = 64;
46
46
  export const WRUN_PANEL_MIN_MARKER_WIDTH = 0.5;
47
47
  export const WRUN_PANEL_MAX_MARKER_WIDTH = 4;
48
48
  /** The kit's colour-word refusal (wrun-style-words.ts `WRUN_COLOR_WORD_MESSAGE`). */
49
- export const WRUN_COLOR_WORD_MESSAGE = 'a colour must be #rrggbb, #rrggbbaa or one of theme.up, theme.down, theme.text, theme.muted, theme.bg, theme.grid, theme.accent';
49
+ export const WRUN_COLOR_WORD_MESSAGE = `a colour must be #rrggbb, #rrggbbaa or one of ${WRUN_THEME_TOKEN_WORDS_TEXT}`;
50
50
  const LINE_STYLE_WORDS = ['solid', 'dashed', 'dotted'];
51
51
  /** C3: "point" pins the label at (x, y) or on a declared series. */
52
52
  const MARKER_VALIGN_WORDS = ['top', 'middle', 'point'];
@@ -400,7 +400,7 @@ export declare const WRUN_HANDLE_DEFAULTS: {
400
400
  label: WrunHandleLabelBase;
401
401
  polyline: WrunHandlePolylineBase;
402
402
  };
403
- /** The freeze's 2.1 message for a "theme." word that is not one of the seven. */
403
+ /** The freeze's 2.1 message for a "theme." word that is not one of the tokens. */
404
404
  export declare const WRUN_THEME_TOKEN_MESSAGE: string;
405
405
  /** The messages g4 names (DW07, DW16, DW34). */
406
406
  export declare const WRUN_DRAWING_PRICE_LABEL_MESSAGE = "price_label is a plot look; a drawing label takes box";
@@ -556,7 +556,7 @@ const MAX_SHEET_COLOR_CHARS = 64;
556
556
  * and (TH-theme-tokens) the seven theme tokens. */
557
557
  const BOX_FILL_COLOR_RE = /^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*\d+(?:\.\d+)?\s*,\s*\d+(?:\.\d+)?\s*,\s*\d+(?:\.\d+)?\s*(?:,[^)]*)?\)|hsla?\(\s*-?\d+(?:\.\d+)?(?:deg)?\s*,\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%\s*(?:,[^)]*)?\))$/i;
558
558
  const WRUN_THEME_TOKEN_PREFIX = 'theme.';
559
- /** The freeze's 2.1 message for a "theme." word that is not one of the seven. */
559
+ /** The freeze's 2.1 message for a "theme." word that is not one of the tokens. */
560
560
  export const WRUN_THEME_TOKEN_MESSAGE = `colour token must be one of ${WRUN_THEME_COLOR_TOKENS.map((token) => `theme.${token}`).join(', ')}`;
561
561
  /** The messages g4 names (DW07, DW16, DW34). */
562
562
  export const WRUN_DRAWING_PRICE_LABEL_MESSAGE = 'price_label is a plot look; a drawing label takes box';
@@ -68,7 +68,7 @@
68
68
  * carries the engine's StrategyOutput, which rides beside the rows
69
69
  * (`attachWrunStrategy`) exactly like the handle set.
70
70
  */
71
- import type { WrunIndicatorMetadata, WrunModuleHandle, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
71
+ import type { WrunIndicatorMetadata, WrunModuleHandle, WrunOutputRow, WrunWorkerResponse } from '../../interfaces/wrun-runtime.interface.js';
72
72
  import { attachWrunLive, WrunLiveOrderError, wrunLiveOf } from '../../interfaces/wrun-runtime.interface.js';
73
73
  import { type WrunInputRow } from './wrun-pack.util.js';
74
74
  import { WrunWorkerPoisonError } from './wrun-registry-errors.util.js';
@@ -99,6 +99,9 @@ export declare const WRUN_WORKER_RESPAWN_WINDOW_MS = 60000;
99
99
  /** How many module handles the host keeps (loadModule): every package version, draft Run and REPL compile mints a
100
100
  * key, and the engine worker keeps an LRU of the same size of the compiled modules behind them. */
101
101
  export declare const WRUN_MODULE_CACHE_CAPACITY = 16;
102
+ /** A failed run as its caller reads it: an Error with the worker's words exactly (other readers match on them), and
103
+ * the trap record the worker sent, when any, beside it (`wrunTrapOf`). */
104
+ export declare function wrunRunFailureError(response: Pick<WrunWorkerFailure, 'error' | 'trap'>): Error;
102
105
  /** Why the shared worker died: the run timeout, or the Worker's error event (the worker factory's death test). */
103
106
  export type WrunHostDeathReason = WrunWorkerPoisonError['reason'];
104
107
  /** A package the host refuses to dispatch until `until` (epoch ms): the one
@@ -116,6 +119,10 @@ export interface WrunHostQuarantine {
116
119
  * per-overlay key would let the second instance spin the worker again). An
117
120
  * unpinned sheet (dev loader, REPL) keys by id alone. */
118
121
  export declare function wrunHostQuarantineKey(metadata: Pick<WrunIndicatorMetadata, 'id' | 'wasm_sha256'>): string;
122
+ /** A refusal the worker answered. */
123
+ type WrunWorkerFailure = Extract<WrunWorkerResponse, {
124
+ ok: false;
125
+ }>;
119
126
  /** One bar of the broker feed: the primary lane's candle for an input row. */
120
127
  export interface WrunStrategyBarInput {
121
128
  open: number;
@@ -132,7 +139,13 @@ export interface WrunStrategyRunInput {
132
139
  bars: ReadonlyArray<WrunStrategyBarInput>;
133
140
  intervalMs?: number;
134
141
  title?: string;
142
+ /** The chart market's point value, from `wrunStrategyPointValue` alone (undefined: the broker keeps 1). Required,
143
+ * so no builder of a strategy run can leave the market out by forgetting it. */
144
+ pointValue: number | undefined;
135
145
  }
146
+ /** A live tick's strategy half: the tail rows' broker feed alone (the config, the point value included, rides the
147
+ * session the live start opened). A full run's input is one too, which the packer reads. */
148
+ export type WrunStrategyTickInput = Pick<WrunStrategyRunInput, 'bars'> & Partial<Omit<WrunStrategyRunInput, 'bars'>>;
136
149
  /** A live tick was asked of a session the worker no longer holds (never
137
150
  * started, disposed, dropped after a failed tick, or lost to a worker
138
151
  * poison/respawn). Callers rebuild via a fresh full run instead of treating
@@ -257,6 +270,23 @@ export declare class WrunBrowserHost {
257
270
  * save); a success clears the quarantine. */
258
271
  overrideQuarantine?: boolean;
259
272
  }): Promise<WrunOutputRow[]>;
273
+ /**
274
+ * The editor's trap replay: one whole run of a TRACE build (unoptimised, with names and a source map) over the
275
+ * failed run's own rows, on this host's worker. The trace bytes ride with their own sha256 (the worker checks
276
+ * them, never a sheet pin, never its module cache); no quarantine is read or written, no live session opens. A
277
+ * private host (`new WrunBrowserHost()`) runs it, never the shared one: `destroy()` ends it. Resolves when the
278
+ * run did not trap; rejects with the worker's words and the trap record, frames included (`wrunTrapOf`).
279
+ */
280
+ traceSeries(input: {
281
+ traceBytes: Uint8Array;
282
+ traceSha256: string;
283
+ metadata: WrunIndicatorMetadata;
284
+ rows: readonly WrunInputRow[];
285
+ initArgs: readonly number[];
286
+ textParams?: Readonly<Record<number, Uint8Array>>;
287
+ mode: 'historical' | 'live';
288
+ strategy?: WrunStrategyRunInput;
289
+ }): Promise<WrunOutputRow[]>;
260
290
  /** Full run that also opens (or replaces) a live forming-bar session under
261
291
  * `sessionKey` in the worker: the guest stays instantiated, so later
262
292
  * `runLiveRows` ticks execute only the new/revised rows. `epoch` is the
@@ -293,7 +323,7 @@ export declare class WrunBrowserHost {
293
323
  sessionKey: string;
294
324
  metadata: WrunIndicatorMetadata;
295
325
  rows: readonly WrunInputRow[];
296
- strategy?: WrunStrategyRunInput;
326
+ strategy?: WrunStrategyTickInput;
297
327
  /** Dispatch although the package is quarantined; a success clears it. */
298
328
  overrideQuarantine?: boolean;
299
329
  }): Promise<WrunOutputRow[]>;
@@ -69,7 +69,7 @@
69
69
  * (`attachWrunStrategy`) exactly like the handle set.
70
70
  */
71
71
  import { ensureWrunChartHostSharedHost, wrunChartHostEnv } from '../../host-env.js';
72
- import { abiAtLeast, attachWrunLive, WrunLiveOrderError, wrunLiveOf, wrunModuleKey, } from '../../interfaces/wrun-runtime.interface.js';
72
+ import { abiAtLeast, attachWrunLive, attachWrunTrap, WrunLiveOrderError, wrunLiveOf, wrunModuleKey, } from '../../interfaces/wrun-runtime.interface.js';
73
73
  import { LOCAL_ENGINE_SELF_HEAL_RESET_GRACE_MS, localEngineSelfHealDelayMs, } from '../chart/local-engine-self-heal-backoff.util.js';
74
74
  import { attachWrunStrategy, readWrunStrategySheet, wrunStrategyParamsOf } from './wrun-box-segment.util.js';
75
75
  import { WRUN_DAEMON_ONLY_SOURCE_DISCLOSURES } from './wrun-kit-run-tables.util.js';
@@ -184,6 +184,14 @@ function wrunModuleLoadError(response, metadata) {
184
184
  return new WebAssembly.CompileError(response.error);
185
185
  return new Error(response.error);
186
186
  }
187
+ /** A failed run as its caller reads it: an Error with the worker's words exactly (other readers match on them), and
188
+ * the trap record the worker sent, when any, beside it (`wrunTrapOf`). */
189
+ export function wrunRunFailureError(response) {
190
+ const error = new Error(response.error);
191
+ if (response.trap !== undefined)
192
+ attachWrunTrap(error, response.trap);
193
+ return error;
194
+ }
187
195
  /** The quarantine key of a package: its metadata id plus the wasm digest the
188
196
  * metadata pins, so a republished build (new digest) starts clean while every
189
197
  * overlay of the same build shares one hold (two charts, two instances: a
@@ -278,6 +286,7 @@ function packWrunRunRequest(metadata, rows, initArgs, strategy, configure, textP
278
286
  request.strategy = {
279
287
  config: resolution.config,
280
288
  ...(strategy.intervalMs !== undefined ? { intervalMs: strategy.intervalMs } : {}),
289
+ ...(strategy.pointValue !== undefined ? { pointValue: strategy.pointValue } : {}),
281
290
  };
282
291
  }
283
292
  return { request, transfer: [...packed.transfer, strategyBars.buffer] };
@@ -505,6 +514,39 @@ export class WrunBrowserHost {
505
514
  this.ringRunDone('series', input, rows.length, startedAt);
506
515
  return rows;
507
516
  }
517
+ /**
518
+ * The editor's trap replay: one whole run of a TRACE build (unoptimised, with names and a source map) over the
519
+ * failed run's own rows, on this host's worker. The trace bytes ride with their own sha256 (the worker checks
520
+ * them, never a sheet pin, never its module cache); no quarantine is read or written, no live session opens. A
521
+ * private host (`new WrunBrowserHost()`) runs it, never the shared one: `destroy()` ends it. Resolves when the
522
+ * run did not trap; rejects with the worker's words and the trap record, frames included (`wrunTrapOf`).
523
+ */
524
+ async traceSeries(input) {
525
+ assertWrunBrowserSources(input.metadata);
526
+ const hostLoading = ensureWrunChartHostSharedHost();
527
+ if (hostLoading)
528
+ await hostLoading;
529
+ const { request: packed, transfer } = packWrunRunRequest(input.metadata, input.rows, input.initArgs, input.strategy, true, input.textParams);
530
+ const id = ++this.requestSeq;
531
+ const request = {
532
+ kind: 'trace-run',
533
+ id,
534
+ mode: input.mode,
535
+ traceBytes: input.traceBytes,
536
+ traceSha256: input.traceSha256,
537
+ ...packed,
538
+ };
539
+ const lane = { quarantineKey: `trace|${input.traceSha256}`, overrideQuarantine: true };
540
+ const response = await new Promise((resolve, reject) => {
541
+ this.post(request, transfer, {
542
+ ...lane,
543
+ kind: 'run',
544
+ reject,
545
+ settle: (answer, entry) => this.settleRun(entry, answer, resolve, reject),
546
+ });
547
+ });
548
+ return this.unpack(response, input.metadata, input.rows);
549
+ }
508
550
  /** Full run that also opens (or replaces) a live forming-bar session under
509
551
  * `sessionKey` in the worker: the guest stays instantiated, so later
510
552
  * `runLiveRows` ticks execute only the new/revised rows. `epoch` is the
@@ -791,7 +833,7 @@ export class WrunBrowserHost {
791
833
  // never replaces the session already open under its key.
792
834
  if (session && !session.opens)
793
835
  this.liveSessionKeys.delete(session.key);
794
- reject(new Error(response.error));
836
+ reject(wrunRunFailureError(response));
795
837
  }
796
838
  }
797
839
  ensureWorker() {
@@ -98,12 +98,32 @@ export interface WrunFrameRefusal {
98
98
  * every reader past it reads codes only (row 37: the same `waiting` record as the browser lane's no
99
99
  * bars). Retired once the backend codes the answer. */
100
100
  export declare const WRUN_NO_CANDLES_CODE = "wrun_no_candles";
101
+ /** Every governed plane's refusal code, spelled out (`cme_entitlement_required`, `stocks_tier_changed`): an explicit
102
+ * allow-set, never a pattern, so a code no server lane sends (`cme_something_else`) is never a code. */
103
+ export declare const WRUN_GOVERNED_REFUSAL_CODES: ReadonlySet<string>;
101
104
  /**
102
105
  * The trailer the kScript socket worker appends to an error frame's rethrown message when the frame's
103
106
  * `details.wrunRefusal` names a coded refusal: ` (wrun-refusal: {"code":...})`, the details' known keys
104
107
  * as JSON (wrunFrameRefusalOf reads it back); '' for any other frame.
105
108
  */
106
109
  export declare function wrunRefusalTrailer(details: unknown): string;
110
+ /**
111
+ * The trailer the kScript socket worker appends to an error frame's rethrown message when the frame's
112
+ * `details.wrunGoverned` holds anything but nothing (`undefined`, `null`, `false`): ` (wrun-governed: <json>)`, the value
113
+ * as JSON (a value JSON cannot write rides as the unreadable mark); '' for any other frame.
114
+ */
115
+ export declare function wrunGovernedTrailer(details: unknown): string;
116
+ /**
117
+ * The error frame's `details.wrunGoverned` a rethrown text carries (`wrunGovernedTrailer`), as the record the mark reader
118
+ * reads (`{ wrunGoverned }`); undefined when the text carries no governed trailer. A trailer that does not read back
119
+ * (cut, not JSON) stands for the unreadable mark: fail closed.
120
+ */
121
+ export declare function wrunGovernedDetailsOfText(text: string): {
122
+ wrunGoverned: unknown;
123
+ } | undefined;
124
+ /** The text without its governed trailer (the refusal trailer after it kept): what every reader past the mark's own
125
+ * reads, so the frame's words (a trap's position, a sentence a reader matches to its end) read exactly as before. */
126
+ export declare function wrunTextWithoutGovernedTrailer(text: string): string;
107
127
  /** The own code of a wrun error frame (`[BAD_REQUEST]`, `[SOURCE_UNSUPPORTED]`, `[INTERNAL]`), or
108
128
  * undefined for a text that is no wrun frame (a frame that names no package, the connection's
109
129
  * instance cap among them, is none). */
@@ -112,8 +112,29 @@ function isRecord(value) {
112
112
  * every reader past it reads codes only (row 37: the same `waiting` record as the browser lane's no
113
113
  * bars). Retired once the backend codes the answer. */
114
114
  export const WRUN_NO_CANDLES_CODE = 'wrun_no_candles';
115
- /** The kit's code spelling: no reader accepts any other word as a code. */
116
- const REFUSAL_CODE = /^wrun_[a-z0-9_]+$/;
115
+ /** The kit's code spelling. */
116
+ const WRUN_REFUSAL_CODE = /^wrun_[a-z0-9_]+$/;
117
+ /** The governed planes whose server lanes refuse by a code of their own (`<plane>_<reason>`). */
118
+ const WRUN_GOVERNED_REFUSAL_PLANES = ['cme', 'stocks'];
119
+ /** The reasons a governed plane's server lane refuses with (kscript-backend's governed-lanes codes). */
120
+ const WRUN_GOVERNED_REFUSAL_REASONS = [
121
+ 'actor_required',
122
+ 'lane_unavailable',
123
+ 'realtime_required',
124
+ 'grant_refused',
125
+ 'entitlement_changed',
126
+ 'tier_changed',
127
+ 'upstream_unavailable',
128
+ 'entitlement_required',
129
+ ];
130
+ /** Every governed plane's refusal code, spelled out (`cme_entitlement_required`, `stocks_tier_changed`): an explicit
131
+ * allow-set, never a pattern, so a code no server lane sends (`cme_something_else`) is never a code. */
132
+ export const WRUN_GOVERNED_REFUSAL_CODES = new Set(WRUN_GOVERNED_REFUSAL_PLANES.flatMap((plane) => WRUN_GOVERNED_REFUSAL_REASONS.map((reason) => `${plane}_${reason}`)));
133
+ /** The codes a relayed refusal may carry: the kit's spelling, or one of the governed planes' codes. No reader accepts
134
+ * any other word as a code. */
135
+ const REFUSAL_CODE = {
136
+ test: (code) => WRUN_REFUSAL_CODE.test(code) || WRUN_GOVERNED_REFUSAL_CODES.has(code),
137
+ };
117
138
  /** The trailer's opening; the JSON of the details follows, then the closing parenthesis. */
118
139
  const REFUSAL_TRAILER_OPEN = ' (wrun-refusal: ';
119
140
  /** A wrun error frame as the socket worker rethrows it (`[<frame code>] WRUN <package>@<version>:
@@ -166,6 +187,68 @@ function trailerRefusalOf(text) {
166
187
  return undefined;
167
188
  }
168
189
  }
190
+ // ── The governed-plane mark off an error frame ─────────────────────────────────────────────────
191
+ //
192
+ // FROZEN CONTRACT with kscript-backend (the governed-lanes cutover): every error or refusal frame of a run whose plan
193
+ // includes a governed source carries `details.wrunGoverned = { <plane>: { tier, delaySeconds } }` (plane `cme` and/or
194
+ // `stocks`; the tier may be the word "unknown"), beside `details.wrunRefusal`. Only text crosses the worker boundary,
195
+ // so the kScript socket worker relays the value as a trailer of its own (`wrunGovernedTrailer`), written BEFORE the
196
+ // refusal trailer so the refusal's reader (its trailer last) reads as before. The value rides raw: what it means is
197
+ // the one fail-closed mark reader's (wrun-hosted-wire.util `wrunGovernedMarkOf`), never this leaf's.
198
+ /** The governed trailer's opening; the JSON of `details.wrunGoverned` follows, then the closing parenthesis. */
199
+ const GOVERNED_TRAILER_OPEN = ' (wrun-governed: ';
200
+ /** What a governed trailer stands for when it cannot be read back: a present mark the chart cannot read (the mark
201
+ * reader reads a non-record value as naming every plane). */
202
+ const GOVERNED_UNREADABLE_VALUE = true;
203
+ /**
204
+ * The trailer the kScript socket worker appends to an error frame's rethrown message when the frame's
205
+ * `details.wrunGoverned` holds anything but nothing (`undefined`, `null`, `false`): ` (wrun-governed: <json>)`, the value
206
+ * as JSON (a value JSON cannot write rides as the unreadable mark); '' for any other frame.
207
+ */
208
+ export function wrunGovernedTrailer(details) {
209
+ if (!isRecord(details) || !Object.hasOwn(details, 'wrunGoverned'))
210
+ return '';
211
+ const raw = details.wrunGoverned;
212
+ if (raw === undefined || raw === null || raw === false)
213
+ return '';
214
+ let json;
215
+ try {
216
+ json = JSON.stringify(raw);
217
+ }
218
+ catch {
219
+ json = undefined;
220
+ }
221
+ return `${GOVERNED_TRAILER_OPEN}${json ?? JSON.stringify(GOVERNED_UNREADABLE_VALUE)})`;
222
+ }
223
+ /**
224
+ * The error frame's `details.wrunGoverned` a rethrown text carries (`wrunGovernedTrailer`), as the record the mark reader
225
+ * reads (`{ wrunGoverned }`); undefined when the text carries no governed trailer. A trailer that does not read back
226
+ * (cut, not JSON) stands for the unreadable mark: fail closed.
227
+ */
228
+ export function wrunGovernedDetailsOfText(text) {
229
+ const at = text.lastIndexOf(GOVERNED_TRAILER_OPEN);
230
+ if (at < 0)
231
+ return undefined;
232
+ const refusalAt = text.indexOf(REFUSAL_TRAILER_OPEN, at + GOVERNED_TRAILER_OPEN.length);
233
+ const body = text.slice(at + GOVERNED_TRAILER_OPEN.length, refusalAt >= 0 ? refusalAt : text.length);
234
+ if (!body.endsWith(')'))
235
+ return { wrunGoverned: GOVERNED_UNREADABLE_VALUE };
236
+ try {
237
+ return { wrunGoverned: JSON.parse(body.slice(0, -1)) };
238
+ }
239
+ catch {
240
+ return { wrunGoverned: GOVERNED_UNREADABLE_VALUE };
241
+ }
242
+ }
243
+ /** The text without its governed trailer (the refusal trailer after it kept): what every reader past the mark's own
244
+ * reads, so the frame's words (a trap's position, a sentence a reader matches to its end) read exactly as before. */
245
+ export function wrunTextWithoutGovernedTrailer(text) {
246
+ const at = text.lastIndexOf(GOVERNED_TRAILER_OPEN);
247
+ if (at < 0)
248
+ return text;
249
+ const refusalAt = text.indexOf(REFUSAL_TRAILER_OPEN, at + GOVERNED_TRAILER_OPEN.length);
250
+ return text.slice(0, at) + (refusalAt >= 0 ? text.slice(refusalAt) : '');
251
+ }
169
252
  /** The own code of a wrun error frame (`[BAD_REQUEST]`, `[SOURCE_UNSUPPORTED]`, `[INTERNAL]`), or
170
253
  * undefined for a text that is no wrun frame (a frame that names no package, the connection's
171
254
  * instance cap among them, is none). */
@@ -42,8 +42,45 @@ export interface WrunHostedRunLevel {
42
42
  wrunOpraTier?: 'realtime' | 'delayed';
43
43
  /** That tier's delay in seconds (`wrunOpraDelaySeconds`, a finite number from 0), read only beside a tier. */
44
44
  wrunOpraDelaySeconds?: number;
45
+ /** The reply's governed-plane mark (the governed-lanes cutover's cross-repo contract, `output.wrunGoverned`): one
46
+ * entry per governed plane the run's plan read, each the receipt of the rows the frame was computed from (the
47
+ * server folds the most delayed one). Read by `readWrunGovernedMark`: a plane is present whenever the reply names
48
+ * it, whatever its receipt holds (the mark withholds, so a malformed receipt still marks). */
49
+ wrunGoverned?: WrunGovernedMark;
45
50
  }
51
+ /** One governed plane's receipt as the server sends it (`output.wrunGoverned.<plane>`). */
52
+ export interface WrunGovernedReceipt {
53
+ tier: string;
54
+ delaySeconds: number;
55
+ }
56
+ /** The wire shape of `output.wrunGoverned` (frozen cross-repo contract). */
57
+ export interface WrunGovernedWire {
58
+ cme?: WrunGovernedReceipt;
59
+ stocks?: WrunGovernedReceipt;
60
+ }
61
+ /** The governed planes the mark names. */
62
+ export type WrunGovernedPlane = keyof WrunGovernedWire;
63
+ /** A plane's receipt as the chart reads it: the plane's presence is the mark; each receipt field only when it is well
64
+ * formed (a tier word that is a non-empty string, a delay that is a finite number from 0). */
65
+ export type WrunGovernedPlaneRead = Partial<WrunGovernedReceipt>;
66
+ /** `output.wrunGoverned` as the chart reads it: one entry per plane the reply names. */
67
+ export type WrunGovernedMark = Partial<Record<WrunGovernedPlane, WrunGovernedPlaneRead>>;
68
+ /**
69
+ * Read a reply's `wrunGoverned` mark: undefined when the reply carries no such record or it names no plane. A plane is
70
+ * named by an own key holding anything but `undefined`, `null` or `false` (fail closed: the mark withholds, so a
71
+ * receipt the chart cannot read still marks its plane); its receipt fields ride only when well formed.
72
+ */
73
+ export declare function readWrunGovernedMark(value: unknown): WrunGovernedMark | undefined;
46
74
  /** Read a reply's run-level keys beside the wire: each own key exactly as the reply carries it (the OPRA mark only as
47
75
  * the boolean `true`, its receipt only beside it), never a key inside `wrunHost`. A reply that is not a record
48
76
  * carries none. */
49
77
  export declare function readWrunHostedRunLevel(output: unknown): WrunHostedRunLevel;
78
+ /**
79
+ * THE one fail-closed reader of a governed run's server mark, for every reader of a cloud answer (the socket row
80
+ * source's replies and live frames, its error frames' relayed details, the Cloud test's reply and error frame): the
81
+ * `wrunGoverned` key of `container` (a reply's `output`, or an error frame's `details`). A key holding anything but
82
+ * nothing (`undefined`, `null`, `false`) or a record is a mark the chart cannot read, and names every plane
83
+ * (`WRUN_GOVERNED_UNREADABLE`: a `true`, a word, a number, an array). A record naming no plane is no mark. Lane-blind and
84
+ * author-blind: the mark alone decides.
85
+ */
86
+ export declare function wrunGovernedMarkOf(container: unknown): WrunGovernedMark | undefined;
@@ -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"];