@orangecharts/wrun-chart-host 0.14.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 (197) 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 +11 -0
  5. package/dist/constants/feature-flags.constants.js +56 -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 +24 -0
  18. package/dist/host-env.js +22 -0
  19. package/dist/host-ports.types.d.ts +11 -0
  20. package/dist/index.d.ts +4 -0
  21. package/dist/index.js +4 -0
  22. package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
  23. package/dist/interfaces/wrun-runtime.interface.d.ts +107 -4
  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/market-data/venues/index.d.ts +2 -2
  30. package/dist/market-data/venues/opra.js +3 -3
  31. package/dist/market-data/venues/stocks.contract.copy.json +3 -2
  32. package/dist/market-data/venues/stocks.d.ts +2 -2
  33. package/dist/market-data/venues/stocks.js +10 -9
  34. package/dist/replay/replayLadder.js +7 -4
  35. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  36. package/dist/settings-templates/footprint-rows.js +6 -0
  37. package/dist/settings-templates/frvp-fields.js +14 -0
  38. package/dist/settings-templates/indicator-fields.js +46 -0
  39. package/dist/settings-templates/tool-tables.generated.js +19 -1
  40. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  41. package/dist/utility/chart/cache-alignment.util.d.ts +65 -0
  42. package/dist/utility/chart/cache-alignment.util.js +124 -24
  43. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  44. package/dist/utility/chart/calendar-interval.util.js +152 -4
  45. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  46. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  47. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  48. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  49. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  50. package/dist/utility/chart/feed-interval.util.js +5 -2
  51. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  52. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  53. package/dist/utility/chart/footprint-band.util.d.ts +21 -5
  54. package/dist/utility/chart/footprint-band.util.js +53 -14
  55. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  56. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  57. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  58. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  59. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  60. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  61. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  62. package/dist/utility/chart/history-wall.util.js +11 -4
  63. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  64. package/dist/utility/chart/interval-ladder.util.js +44 -4
  65. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  66. package/dist/utility/chart/interval-registry.util.js +50 -2
  67. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  68. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  69. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  70. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  71. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  72. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  73. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  74. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  75. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  76. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  77. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  78. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  79. package/dist/utility/chart/live-bucket.util.js +45 -12
  80. package/dist/utility/chart/market-session.util.d.ts +62 -10
  81. package/dist/utility/chart/market-session.util.js +93 -13
  82. package/dist/utility/chart/marketKind.util.d.ts +1 -7
  83. package/dist/utility/chart/marketKind.util.js +6 -8
  84. package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
  85. package/dist/utility/chart/om-target.util.js +6 -4
  86. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  87. package/dist/utility/chart/price-precision.util.js +34 -7
  88. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  89. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  90. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  91. package/dist/utility/chart/rth-session.util.js +3 -1
  92. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  93. package/dist/utility/chart/script-source-session.util.js +61 -0
  94. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  95. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  96. package/dist/utility/chart/wrun-run-result.util.d.ts +9 -1
  97. package/dist/utility/chart/wrun-run-result.util.js +8 -2
  98. package/dist/utility/common/transformations.util.d.ts +6 -0
  99. package/dist/utility/common/transformations.util.js +28 -4
  100. package/dist/utility/number-format.util.d.ts +14 -1
  101. package/dist/utility/number-format.util.js +22 -4
  102. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  103. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
  104. package/dist/utility/v2/v2-enums.leaf.js +3 -0
  105. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +15 -5
  106. package/dist/utility/wrun/wrun-batched-marks.util.js +70 -20
  107. package/dist/utility/wrun/wrun-canvases.util.d.ts +28 -9
  108. package/dist/utility/wrun/wrun-canvases.util.js +99 -39
  109. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  110. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  111. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  112. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  113. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
  114. package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
  115. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  116. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  117. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  118. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  119. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  120. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  121. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  122. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  123. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  124. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  125. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  126. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  127. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  128. package/dist/utility/wrun/wrun-frames.js +2 -2
  129. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  130. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  131. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  132. package/dist/utility/wrun/wrun-host.service.js +44 -2
  133. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  134. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  135. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  136. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  137. package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
  138. package/dist/utility/wrun/wrun-hover.util.js +24 -13
  139. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  140. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  141. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  142. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  143. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  144. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  145. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  146. package/dist/utility/wrun/wrun-live-tick.util.js +81 -19
  147. package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
  148. package/dist/utility/wrun/wrun-output-words.util.js +51 -0
  149. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +41 -0
  150. package/dist/utility/wrun/wrun-overlay-drivers.util.js +35 -0
  151. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
  152. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  153. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +23 -2
  154. package/dist/utility/wrun/wrun-overlay-run.util.js +305 -51
  155. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +10 -2
  156. package/dist/utility/wrun/wrun-panel-mount.util.js +144 -18
  157. package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
  158. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  159. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  160. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  161. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  162. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  163. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  164. package/dist/utility/wrun/wrun-run-health.util.d.ts +6 -3
  165. package/dist/utility/wrun/wrun-run-health.util.js +5 -2
  166. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  167. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  168. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +25 -8
  169. package/dist/utility/wrun/wrun-script-inputs.util.js +145 -45
  170. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  171. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  172. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  173. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  174. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  175. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  176. package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
  177. package/dist/utility/wrun/wrun-style-names.util.js +74 -0
  178. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  179. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  180. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  181. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  182. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  183. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  184. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  185. package/dist/utility/wrun-display-name.util.js +21 -0
  186. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  187. package/dist/utils/replay/replay-buffer-math.js +2 -0
  188. package/dist/workers/constants/socket-slots.d.ts +1 -1
  189. package/dist/workers/utils/time.worker.util.js +2 -2
  190. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  191. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  192. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  193. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  194. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  195. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  196. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  197. package/package.json +11 -11
@@ -40,7 +40,9 @@ import { isWrunStyleTargetHidden } from './wrun-color-settings.util.js';
40
40
  import { isWrunBandedBookSource } from './wrun-book-bands.leaf.js';
41
41
  import { WRUN_MAX_ROWS_PER_PERIOD, WRUN_ROW_CAP_MAX_DOUBLINGS, wrunAutoRowUnit } from './wrun-auto-row.util.js';
42
42
  import { WRUN_FOOTPRINT_CELL_METRIC_DEFAULT, WRUN_FOOTPRINT_MODE_DEFAULT } from './wrun-footprint-modes.util.js';
43
- import { formatWrunNumber, resolveWrunColorWord, wrunFontFamilyCss, } from './wrun-style-words.util.js';
43
+ // Bound before the fallback palette below reads the mark colours (off the boot path).
44
+ import './wrun-colour-tone.util.js';
45
+ import { formatWrunNumber, resolveWrunColorWord, wrunColorThemeOf, wrunFontFamilyCss, } from './wrun-style-words.util.js';
44
46
  import { buildWrunTpoRows, WRUN_TPO_MAX_ROWS_PER_BAR, } from './wrun-tpo-rows.util.js';
45
47
  import { wrunVolumeProfileChild } from './wrun-volume-profile.util.js';
46
48
  import { invalidWrunFrame, parseWrunMatrixFrame } from './wrun-frames.js';
@@ -51,17 +53,10 @@ const CHILD_PLOT = {
51
53
  profile: 'profile',
52
54
  matrix: 'priceMatrix',
53
55
  };
54
- /** The default dark palette (wrun-style-words.util 2.3): what a child's own
55
- * rows resolve against before the mount hands the chart's theme over. */
56
- export const WRUN_CANVAS_FALLBACK_THEME = Object.freeze({
57
- up: '#26a69a',
58
- down: '#ef5350',
59
- text: '#d1d4dc',
60
- muted: 'rgba(209, 212, 220, 0.55)',
61
- bg: '#131722',
62
- grid: '#2a2e39',
63
- accent: '#ff4608',
64
- });
56
+ /** The default dark palette (wrun-style-words.util 2.3, the palette a chart
57
+ * without a theme answers): what a child's own rows resolve against before
58
+ * the mount hands the chart's theme over. */
59
+ export const WRUN_CANVAS_FALLBACK_THEME = Object.freeze(wrunColorThemeOf(undefined));
65
60
  /** The colour-scale defaults (PT-heatmap): the sequential ramp, the
66
61
  * diverging ramp around a centre, the quantile of the auto bounds. */
67
62
  export const WRUN_HEATMAP_DEFAULT_PALETTE = Object.freeze([
@@ -245,6 +240,18 @@ function nthZeroOf(values, index) {
245
240
  * zero pick re-reads the zero at its rank in that order.
246
241
  */
247
242
  export function wrunCanvasScaleOf(words, values, options) {
243
+ return pickCanvasScale(words, values, options).scale;
244
+ }
245
+ /**
246
+ * `wrunCanvasScaleOf`'s pick, and whether the sample gave every bound left to it (`spread`). It did not when it held
247
+ * no finite cell, or when the quantiles it was read at meet (every cell at the zero floor, a declared bound or the
248
+ * centre, or at least the quantile's share of them): the bounds are then stand-ins (`[floor, floor + 1]`,
249
+ * `centre +- 1`), chosen for want of a scale, never one the cells chose. A mounted heatmap holds only a scale its
250
+ * sample gave (wrun-panel-mount.util `holdsHeatmapScale`, `wrunHeatmapScaleDecided`): a stand-in held through the
251
+ * passes after it would saturate every cell the next rows bring. Bounds all declared take nothing from the sample
252
+ * and read as given.
253
+ */
254
+ function pickCanvasScale(words, values, options) {
248
255
  const q = finite(words.auto_quantile) ? words.auto_quantile : WRUN_CANVAS_DEFAULT_QUANTILE;
249
256
  const scale = words.scale ?? 'linear';
250
257
  const diverging = options.diverging || finite(words.center);
@@ -260,11 +267,13 @@ export function wrunCanvasScaleOf(words, values, options) {
260
267
  deviations[count++] = Math.abs(value - center);
261
268
  }
262
269
  let reach = count === 0 ? 0 : selectKth(deviations, count, quantileRank(count, q));
263
- if (!(reach > 0))
270
+ const reached = reach > 0;
271
+ if (!reached)
264
272
  reach = 1;
265
273
  const min = finite(words.min) ? words.min : center - reach;
266
274
  const max = finite(words.max) ? words.max : center + reach;
267
- return { min, max: max > min ? max : min + 1, center, scale };
275
+ const given = finite(words.min) && finite(words.max);
276
+ return { scale: { min, max: max > min ? max : min + 1, center, scale }, spread: given || (reached && max > min) };
268
277
  }
269
278
  const work = new Float64Array(values.length);
270
279
  let count = 0;
@@ -289,7 +298,8 @@ export function wrunCanvasScaleOf(words, values, options) {
289
298
  };
290
299
  const min = finite(words.min) ? words.min : options.zeroFloor ? 0 : count === 0 ? 0 : pick(1 - q);
291
300
  const max = finite(words.max) ? words.max : count === 0 ? min + 1 : pick(q);
292
- return { min, max: max > min ? max : min + 1, scale };
301
+ const given = finite(words.max) && (finite(words.min) || options.zeroFloor === true);
302
+ return { scale: { min, max: max > min ? max : min + 1, scale }, spread: given || (count > 0 && max > min) };
293
303
  }
294
304
  /** A value's position (0..1) on the scale: the diverging ramp sits its
295
305
  * centre at 0.5, `sqrt` lifts the small values, `log` (sequential only)
@@ -667,8 +677,13 @@ function heatmapSensitivityRule(sheet, heatmap, index) {
667
677
  const rule = heatmapScaleRule(sheet, heatmap);
668
678
  if (rule === null)
669
679
  return null;
670
- const fromQuantile = !finite(heatmap.max) || (!finite(heatmap.min) && !rule.zeroFloor);
671
- return fromQuantile && !quantileBoundByParam(sheet, heatmap, index) ? rule : null;
680
+ return boundFromSample(heatmap, rule) && !quantileBoundByParam(sheet, heatmap, index) ? rule : null;
681
+ }
682
+ /** A bound of the heatmap's colour scale comes from the cell sample (`wrunCanvasScaleOf`): `max` undeclared, or
683
+ * `min` undeclared where the word has no zero floor (a diverging heatmap never has one). Both declared (or `max`
684
+ * declared over a zero floor) and the sample decides nothing. */
685
+ function boundFromSample(heatmap, rule) {
686
+ return !finite(heatmap.max) || (!finite(heatmap.min) && !rule.zeroFloor);
672
687
  }
673
688
  /** The author's scale words as declared (absent words stay absent). */
674
689
  function heatmapScaleWords(heatmap) {
@@ -680,21 +695,56 @@ function heatmapScaleWords(heatmap) {
680
695
  ...(heatmap.scale !== undefined ? { scale: heatmap.scale } : {}),
681
696
  };
682
697
  }
683
- /** The scale sample a heatmap child was built with, kept beside it (keyed by
684
- * the child's own rows array, a fresh array per child): a Sensitivity re-pick
685
- * needs only a new selection, never another walk of the window. */
698
+ /**
699
+ * The scale sample a heatmap child's bounds were picked from, kept beside it, keyed by the child's own
700
+ * `settings` object (a fresh object per child per build, holding the bounds the sample gave): a Sensitivity
701
+ * re-pick needs only a new selection, never another walk of the window. The key is the settings and never the
702
+ * rows: every seam that keeps a mounted record (a live merge adopting the engine's rows, a cell-budget trim, a
703
+ * windowed landing, a retranslate, a blank) copies the child as `{ ...child, data }`, which shares the settings,
704
+ * so the sample stays with the bounds it gave while the rows move under them. Keyed by the rows (as it was until
705
+ * 2026-11-07), the first live merge or trim lost it and the next re-pick sampled whatever rows the canvas held
706
+ * then. Kept whenever a bound comes from the sample (`boundFromSample`), with or without a Sensitivity row, beside
707
+ * whether the sample gave the bounds it was read for (`pickCanvasScale`'s `spread`): the mount's scale hold reads it
708
+ * (`wrunHeatmapScaleDecided`).
709
+ */
686
710
  const heatmapSamples = new WeakMap();
687
711
  /**
688
- * A windowed landing (wrun-panel-mount.util: a pan-back page or a prefix run landed inside its history
689
- * window) keeps the colour scale its heatmap was drawn with; only a full run samples again. The rows it lands
690
- * take the sample the mounted rows' bounds were picked from, so a Sensitivity re-pick afterwards reads that
691
- * sample instead of walking the landed rows into another basis. A child with no kept sample (one that
692
- * crossed a copy or a trim) still walks its rows on the next re-pick, as before.
712
+ * The colour scale a heatmap child was decided with, carried onto another child: `to` takes the sample `from`'s
713
+ * bounds were picked from, so a Sensitivity re-pick on `to` reads that sample instead of walking `to`'s rows into
714
+ * another basis. The mount's scale hold calls it when a pass of the same picture brings new rows
715
+ * (wrun-panel-mount.util `carryHeatmapScale`: the held child is the pass's own with the decided bounds). A child
716
+ * with no kept sample (one that crossed a copy) still walks its rows on the next re-pick, as before.
693
717
  */
694
718
  export function keepWrunHeatmapScaleSample(from, to) {
695
- const sample = heatmapSamples.get(from);
696
- if (sample !== undefined && from !== to)
697
- heatmapSamples.set(to, sample);
719
+ const sample = heatmapSamples.get(from.settings);
720
+ if (sample !== undefined && from.settings !== to.settings)
721
+ heatmapSamples.set(to.settings, sample);
722
+ }
723
+ /** Whether a heatmap child's colour bounds were picked from a sample kept beside it (`heatmapSamples`), whatever it
724
+ * gave: false for a child whose bounds were all declared and for one that crossed a copy. A mount's merge keeps
725
+ * such a scale on its record, as the engine keeps it on screen. */
726
+ export function wrunHeatmapScaleKept(child) {
727
+ return heatmapSamples.has(child.settings);
728
+ }
729
+ /**
730
+ * Whether the colour bounds a heatmap child shows were given by its kept sample, judged on the sample at the
731
+ * quantile they are read at (`pickCanvasScale`'s `spread`, never the bound numbers): its own bounds at the
732
+ * author's quantile, or, with the viewer's Sensitivity on a child with scale words, the re-pick at that position's
733
+ * quantile. False for a sample with no finite cell, one whose cells all sit at the zero floor, a declared bound or
734
+ * the centre (a grid writing 0 until a late input lands, a window of zero-volume buckets), one where at least the
735
+ * quantile's share of them does, a child with no kept sample, and one whose bounds were all declared: the bounds
736
+ * are then stand-ins or the author's, never a scale the cells chose. The mount holds a scale only when this is true
737
+ * (wrun-panel-mount.util `holdsHeatmapScale`); anything else is decided again by the next pass.
738
+ */
739
+ export function wrunHeatmapScaleDecided(child, sensitivity) {
740
+ const kept = heatmapSamples.get(child.settings);
741
+ if (kept === undefined)
742
+ return false;
743
+ const inputs = child.scale;
744
+ if (child.kind !== 'heatmap' || inputs === undefined || !finite(sensitivity))
745
+ return kept.spread;
746
+ const words = { ...inputs.words, auto_quantile: heatmapSensitivityQuantile(sensitivity) };
747
+ return pickCanvasScale(words, kept.values, { diverging: inputs.diverging, zeroFloor: inputs.zeroFloor }).spread;
698
748
  }
699
749
  /** The newest `tailRows` rows of a source (a live tick's tail), else all of them. */
700
750
  function newestRows(rows, tailRows) {
@@ -722,15 +772,16 @@ function heatmapChild(sheet, heatmap, index, cellRows, outputRows, tailRows) {
722
772
  data = newestRows((layout === 'book' ? cellRows?.bookRows : cellRows?.volumeProfileRows) ?? [], tailRows).map(wrunPlainCanvasRow);
723
773
  // A tick's tail samples no scale and keeps no Sensitivity inputs: its rows
724
774
  // only merge into a mounted canvas, which keeps the bounds (and the sample a
725
- // Sensitivity re-pick reads) of the full run that mounted it.
775
+ // Sensitivity re-pick reads) of the pass that decided them.
726
776
  let scale;
777
+ let sample;
727
778
  let sensitivity = null;
728
779
  if (tailRows === undefined) {
729
- const sample = sampleCellValues(layout, valueField, data);
730
- scale = wrunCanvasScaleOf(heatmap, sample, { diverging, zeroFloor });
780
+ const values = sampleCellValues(layout, valueField, data);
781
+ const picked = pickCanvasScale(heatmap, values, { diverging, zeroFloor });
782
+ scale = picked.scale;
783
+ sample = { values, spread: picked.spread };
731
784
  sensitivity = heatmapSensitivityRule(sheet, heatmap, index);
732
- if (sensitivity !== null)
733
- heatmapSamples.set(data, sample);
734
785
  }
735
786
  const format = numberFormatOf(heatmap);
736
787
  const rowHeight = heatmap.row_height ?? (layout === 'book' ? bookGroupingOf(data) : undefined);
@@ -762,6 +813,9 @@ function heatmapChild(sheet, heatmap, index, cellRows, outputRows, tailRows) {
762
813
  valueFormat: format,
763
814
  hoverReadout: heatmap.tooltip !== undefined,
764
815
  };
816
+ // The sample beside the settings holding the bounds it gave (heatmapSamples), whenever a bound came from it.
817
+ if (sample !== undefined && boundFromSample(heatmap, rule))
818
+ heatmapSamples.set(settings, sample);
765
819
  const readout = heatmap.tooltip !== undefined
766
820
  ? { kind: 'heatmap', label: heatmap.label ?? wrunCanvasNameWords(heatmap.name), tooltip: heatmap.tooltip, format }
767
821
  : undefined;
@@ -815,20 +869,26 @@ export function wrunHeatmapSensitivityRows(sheet) {
815
869
  * re-picked from the child's own scale sample at the position's quantile
816
870
  * (the options heatmap's map); the child's own bounds, the author's exactly,
817
871
  * when no position is set or the child carries no scale words. The centre
818
- * never depends on the quantile, so only `min` and `max` move.
872
+ * never depends on the quantile, so only `min` and `max` move. A mounted
873
+ * record's own bounds and sample are its decided scale's (the mount's scale
874
+ * hold), so a re-pick never reads the rows the canvas holds now.
819
875
  */
820
876
  export function wrunHeatmapSensitivityBounds(child, sensitivity) {
821
877
  const own = { min: child.settings.min, max: child.settings.max };
822
878
  const inputs = child.scale;
823
879
  if (child.kind !== 'heatmap' || inputs === undefined || !finite(sensitivity))
824
880
  return own;
825
- let sample = heatmapSamples.get(child.data);
826
- if (sample === undefined) {
881
+ // The sample the child's own bounds were picked from (kept beside its settings, heatmapSamples): on a mounted
882
+ // record that is the decided scale's, whatever rows the record holds now.
883
+ let kept = heatmapSamples.get(child.settings);
884
+ if (kept === undefined) {
827
885
  // A child that crossed a copy (no kept sample) walks its rows again.
828
- sample = sampleCellValues(inputs.layout, inputs.valueField, child.data);
829
- heatmapSamples.set(child.data, sample);
886
+ const values = sampleCellValues(inputs.layout, inputs.valueField, child.data);
887
+ const rule = { diverging: inputs.diverging, zeroFloor: inputs.zeroFloor };
888
+ kept = { values, spread: pickCanvasScale(inputs.words, values, rule).spread };
889
+ heatmapSamples.set(child.settings, kept);
830
890
  }
831
- const scale = wrunCanvasScaleOf({ ...inputs.words, auto_quantile: heatmapSensitivityQuantile(sensitivity) }, sample, {
891
+ const scale = wrunCanvasScaleOf({ ...inputs.words, auto_quantile: heatmapSensitivityQuantile(sensitivity) }, kept.values, {
832
892
  diverging: inputs.diverging,
833
893
  zeroFloor: inputs.zeroFloor,
834
894
  });
@@ -12,6 +12,11 @@ export interface WrunDrawingsBudget {
12
12
  /** Increases with every budgeted result: the door never lets an older revision overwrite a newer row. */
13
13
  revision: number;
14
14
  }
15
+ /** Notes `next`'s drawings token: `previous`'s when the caller proved the two sets equal (pass `undefined` when it
16
+ * did not), else a new one. Returns the token, undefined when `next` is no array. */
17
+ export declare function noteWrunDrawingsSameAs(next: unknown, previous: unknown): number | undefined;
18
+ /** The token the live tick noted on a drawings array (undefined when none was noted: the door then runs in full). */
19
+ export declare function wrunDrawingsToken(drawings: unknown): number | undefined;
15
20
  /** The context a result's drawings carry: the result's own field, else the one keyed by its
16
21
  * drawings array (a live batch rebuilt around the array). */
17
22
  export declare function wrunDrawingsBudgetOf(output: unknown): WrunDrawingsBudget | undefined;
@@ -29,6 +29,29 @@ import { wrunChartHostEnv, } from '../../host-env.js';
29
29
  const UNTRIMMED_DRAWING_KINDS = new Set(['table', 'card', 'feed', 'meter', 'ladder']);
30
30
  const budgetsByDrawings = new WeakMap();
31
31
  let revisions = 0;
32
+ /**
33
+ * The live tick's drawings verdict, as a number per drawings array: a live result whose drawings equal the ones the
34
+ * tick last applied (and whose budget counts match) inherits that array's token, any other result gets a new one.
35
+ * The drawing door holds the token of its last full pass, so an equal token on the next live call means the same
36
+ * records reach it again and the pass can be skipped. A number, never a reference to the previous array: a chain of
37
+ * arrays would keep every old drawings set reachable for as long as the newest lives.
38
+ */
39
+ const drawingsTokens = new WeakMap();
40
+ let drawingsTokenSeq = 0;
41
+ /** Notes `next`'s drawings token: `previous`'s when the caller proved the two sets equal (pass `undefined` when it
42
+ * did not), else a new one. Returns the token, undefined when `next` is no array. */
43
+ export function noteWrunDrawingsSameAs(next, previous) {
44
+ if (!Array.isArray(next))
45
+ return undefined;
46
+ const inherited = Array.isArray(previous) ? drawingsTokens.get(previous) : undefined;
47
+ const token = inherited ?? (drawingsTokenSeq += 1);
48
+ drawingsTokens.set(next, token);
49
+ return token;
50
+ }
51
+ /** The token the live tick noted on a drawings array (undefined when none was noted: the door then runs in full). */
52
+ export function wrunDrawingsToken(drawings) {
53
+ return Array.isArray(drawings) ? drawingsTokens.get(drawings) : undefined;
54
+ }
32
55
  function isRecord(value) {
33
56
  return typeof value === 'object' && value !== null && !Array.isArray(value);
34
57
  }
@@ -62,7 +62,7 @@ export type WrunWidgetEngineControls = Exclude<WrunWidgetControls, 'none'>;
62
62
  */
63
63
  export declare function wrunWidgetEngineControls(word: WrunWidgetControls | undefined): WrunWidgetEngineControls | undefined;
64
64
  /** The frozen colour-word message (the foundation's, 2.1). */
65
- 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";
65
+ export declare const WRUN_COLOR_WORD_MESSAGE: string;
66
66
  /**
67
67
  * DW04: what `chrome: "plain"` stands for, in the sheet's words: no state
68
68
  * text, no stripe, no border, a muted title, glyphs on hover. A word declared
@@ -30,7 +30,7 @@
30
30
  * `controls: "none"` reaches the engine as `hover` (wrunWidgetEngineControls),
31
31
  * so a widget never loses the viewer's hide control.
32
32
  */
33
- import { formatWrunNumber, isWrunColorWord, WRUN_FONT_FAMILIES, WRUN_FONT_WEIGHTS, WRUN_MAX_VALUE_DECIMALS, WRUN_MAX_VALUE_UNIT_CHARS, WRUN_VALUE_FORMATS, wrunFontFamilyCss, } from './wrun-style-words.util.js';
33
+ import { formatWrunNumber, isWrunColorWord, WRUN_FONT_FAMILIES, WRUN_FONT_WEIGHTS, WRUN_MAX_VALUE_DECIMALS, WRUN_MAX_VALUE_UNIT_CHARS, WRUN_THEME_TOKEN_WORDS_TEXT, WRUN_VALUE_FORMATS, wrunFontFamilyCss, } from './wrun-style-words.util.js';
34
34
  // Bounds (the kit's, restated per X22; D1 for the corner radius).
35
35
  export const WRUN_WIDGET_CORNER_RADIUS_MAX_PX = 32;
36
36
  export const WRUN_WIDGET_PADDING_MAX_PX = 24;
@@ -71,7 +71,7 @@ const WRUN_TEXT_ALIGNS = ['left', 'center', 'right'];
71
71
  const WRUN_FEED_TIME_FORMATS = ['HH:mm:ss', 'HH:mm', 'MM-dd HH:mm', 'none'];
72
72
  const WRUN_CARD_VALUE_FORMAT_WORDS = [...WRUN_VALUE_FORMATS, 'pct'];
73
73
  /** The frozen colour-word message (the foundation's, 2.1). */
74
- 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';
74
+ export const WRUN_COLOR_WORD_MESSAGE = `a colour must be #rrggbb, #rrggbbaa or one of ${WRUN_THEME_TOKEN_WORDS_TEXT}`;
75
75
  /**
76
76
  * DW04: what `chrome: "plain"` stands for, in the sheet's words: no state
77
77
  * text, no stripe, no border, a muted title, glyphs on hover. A word declared
@@ -331,6 +331,14 @@ export declare function wrunMarketFactsSettled(market: WrunFactsMarket | undefin
331
331
  * warmWrunMarketDollarFacts settled; 0 while it is not proven). Every word is
332
332
  * written on every market, 0 included, so the block keeps one shape. */
333
333
  export declare function wrunMarketFactsFor(market: WrunFactsMarket | undefined): WrunMarketFacts & WrunOptionFacts & WrunDollarFacts;
334
+ /**
335
+ * THE point value a strategy package's broker takes for `market` (`WrunStrategyRunInput.pointValue`, carried to the
336
+ * kit's `WrunStrategyHost` as its `pointValue`): the same fact `market.point_value()` reads (wrunMarketFactsFor), when
337
+ * it is a positive number other than 1. Undefined on a market with no point value (1: coins, shares; 0: unknown), so
338
+ * the broker keeps 1 there and its output carries no `declared.pointValue`. A size is then in contracts and every
339
+ * money figure the broker returns is price x size x this value.
340
+ */
341
+ export declare function wrunStrategyPointValue(market: WrunFactsMarket | undefined): number | undefined;
334
342
  /**
335
343
  * What the instrument registry (StreamRegistryMetadatas, the metadata service's `getSymbolMetadata`) proves about one
336
344
  * market's prices on every wire it rides, so the chart prices a print by the server's own facts, never by a table of
@@ -69,6 +69,7 @@ import { wrunChartHostEnv } from '../../host-env.js';
69
69
  import { isCmeGoverned } from '../chart/cme-realtime.util.js';
70
70
  import { isContinuousSymbol } from '../chart/continuous-contracts.util.js';
71
71
  import { governedContractCoin } from '../chart/governed-contract-coin.util.js';
72
+ import { PUBLISHER_ONLY_EXCHANGES } from '../../constants/economic.constants.js';
72
73
  import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
73
74
  import { optionsMarketUnderlyingVenue, optionVenueForExchange } from '../options/option-venue.util.js';
74
75
  import { isPlainOptionContract } from '../options/option-trade-units.util.js';
@@ -762,7 +763,7 @@ class DirectoryIncomplete extends Error {
762
763
  * the caller retries those after a minute, never settles them as absent. */
763
764
  async function findDirectoryRow(venue, symbol) {
764
765
  const exchange = Exchange[venue];
765
- if (typeof exchange !== 'number')
766
+ if (typeof exchange !== 'number' || PUBLISHER_ONLY_EXCHANGES.has(venue))
766
767
  return null;
767
768
  const [{ default: metadataService }, { normalizeMarketSymbols }] = await Promise.all([
768
769
  wrunChartHostEnv().market.loadMetadataService(),
@@ -836,6 +837,17 @@ export function wrunMarketFactsFor(market) {
836
837
  dollarMultiplier: dollars.kind === 'dollars' ? dollars.unit : 0,
837
838
  };
838
839
  }
840
+ /**
841
+ * THE point value a strategy package's broker takes for `market` (`WrunStrategyRunInput.pointValue`, carried to the
842
+ * kit's `WrunStrategyHost` as its `pointValue`): the same fact `market.point_value()` reads (wrunMarketFactsFor), when
843
+ * it is a positive number other than 1. Undefined on a market with no point value (1: coins, shares; 0: unknown), so
844
+ * the broker keeps 1 there and its output carries no `declared.pointValue`. A size is then in contracts and every
845
+ * money figure the broker returns is price x size x this value.
846
+ */
847
+ export function wrunStrategyPointValue(market) {
848
+ const { pointValue } = wrunMarketFactsFor(market);
849
+ return Number.isFinite(pointValue) && pointValue > 0 && pointValue !== 1 ? pointValue : undefined;
850
+ }
839
851
  /** A registry field that is a finite number above zero, else null (absent, zero, negative or unreadable). */
840
852
  function positiveUnit(value) {
841
853
  const number = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : Number.NaN;
@@ -11,3 +11,13 @@ export declare function wrunChildOverlayParentId(id: string): string | null;
11
11
  export declare function wrunChildHiddenRowKey(id: string): string | null;
12
12
  /** True for a key wrunChildHiddenRowKey mints (a viewer row, never a param). */
13
13
  export declare function isWrunChildHiddenRowKey(key: string): boolean;
14
+ /** The viewer row that keeps the height a reader dragged a child's pane to: `<kind>:<name>:gridHeight` on the OWNING
15
+ * Indicator's settings (`series:lower:gridHeight`), the pane's share of the chart. A child has no workspace row, so
16
+ * the one height writer (the store's saveGridHeights) writes it there and the child mount reads it back whenever it
17
+ * mounts the child (a layout or tab switch, a reload). Keyed past the owner id, which a draft swap may change. Null
18
+ * for any id that is no pane-owning child's. */
19
+ export declare function wrunChildPaneHeightRowKey(id: string): string | null;
20
+ /** True for a key wrunChildPaneHeightRowKey mints (a viewer row, never a param). */
21
+ export declare function isWrunChildPaneHeightRowKey(key: string): boolean;
22
+ /** The child overlay id a pane height row names under `overlayId`, null for any other key. */
23
+ export declare function wrunChildPaneHeightRowChildId(overlayId: string, key: string): string | null;
@@ -43,3 +43,27 @@ export function wrunChildHiddenRowKey(id) {
43
43
  export function isWrunChildHiddenRowKey(key) {
44
44
  return CHILD_HIDDEN_ROW_PATTERN.test(key);
45
45
  }
46
+ /** The child kinds that own a pane below the chart a reader can drag: the mount sizes exactly these from a plan
47
+ * (wrun-panel-mount.util `ctx.planned`), so exactly these remember a dragged height. */
48
+ const CHILD_PANE_KIND_WORDS = { panel: true, series: true };
49
+ const CHILD_PANE_KINDS = `(?:${Object.keys(CHILD_PANE_KIND_WORDS).join('|')})`;
50
+ const CHILD_PANE_ID_PARTS = new RegExp(`^.+::(${CHILD_PANE_KINDS}:.+)$`);
51
+ const CHILD_PANE_HEIGHT_ROW_PATTERN = new RegExp(`^(${CHILD_PANE_KINDS}:.+):gridHeight$`);
52
+ /** The viewer row that keeps the height a reader dragged a child's pane to: `<kind>:<name>:gridHeight` on the OWNING
53
+ * Indicator's settings (`series:lower:gridHeight`), the pane's share of the chart. A child has no workspace row, so
54
+ * the one height writer (the store's saveGridHeights) writes it there and the child mount reads it back whenever it
55
+ * mounts the child (a layout or tab switch, a reload). Keyed past the owner id, which a draft swap may change. Null
56
+ * for any id that is no pane-owning child's. */
57
+ export function wrunChildPaneHeightRowKey(id) {
58
+ const child = CHILD_PANE_ID_PARTS.exec(id)?.[1];
59
+ return child === undefined ? null : `${child}:gridHeight`;
60
+ }
61
+ /** True for a key wrunChildPaneHeightRowKey mints (a viewer row, never a param). */
62
+ export function isWrunChildPaneHeightRowKey(key) {
63
+ return CHILD_PANE_HEIGHT_ROW_PATTERN.test(key);
64
+ }
65
+ /** The child overlay id a pane height row names under `overlayId`, null for any other key. */
66
+ export function wrunChildPaneHeightRowChildId(overlayId, key) {
67
+ const child = CHILD_PANE_HEIGHT_ROW_PATTERN.exec(key)?.[1];
68
+ return child === undefined ? null : `${overlayId}::${child}`;
69
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The CME provenance of a hosted (Cloud) run, the twin of the OPRA mark (wrun-cloud-opra-stamp.util). One rule never
3
+ * opens with the governed-lanes cutover: no CME data reaches Kata or any AI feature, so every row a run derives from
4
+ * CME data carries the CME stamp (`settings.metaCmeExchange = 'CME'`, the key the hosted chart read, the MCP withhold
5
+ * and the governed-source inventory read), whatever lane or author produced it.
6
+ *
7
+ * A browser run is stamped by the chart's fetch door when it admits a CME source. A hosted run fetches nothing in the
8
+ * browser, so its result batch is stamped here before any of its rows lands (`integrateWrunRowSourceBatch`), by two
9
+ * readings joined (`wrunHostedRunReadsCme`):
10
+ *
11
+ * - the head mark: the chart is on the CME plane, or the sheet the run reads pins a CME market (the run head's
12
+ * `wrunSheetPinsCme`), read from the sheet and the chart alone;
13
+ * - the server mark: the reply's `output.wrunGoverned.cme` (the hosted wire's `wrunGoverned`, `readWrunGovernedMark`),
14
+ * which the batch carries as `governed` (`wrunBatchGovernedOf`): what the server knows the run read, even where the
15
+ * sheet shows no CME.
16
+ *
17
+ * Lane-blind and author-blind: a first-party hosted run that reads CME is stamped too. Fail closed: a host that binds
18
+ * no CME writer (`setOverlayCmeProvenance`), a writer that throws, a run that no longer owns its overlay, or a stamp the
19
+ * mounted overlay does not read back all fail the batch, so no unstamped CME row is integrated. The stamp is sticky for
20
+ * the mount, as the browser's is (cme-overlay-provenance.util): no result sheds it.
21
+ */
22
+ import { type WrunGovernedMark } from './wrun-hosted-wire.util.js';
23
+ /** A batch as the stamp reads it: the server's governed-plane mark, when the source carries it. */
24
+ export interface WrunGovernedBatchFields {
25
+ /** The reply's `output.wrunGoverned`, as `readWrunGovernedMark` read it. */
26
+ governed?: WrunGovernedMark;
27
+ }
28
+ /** Whether a mounted overlay's settings carry the CME provenance stamp (cme-overlay-provenance.leaf
29
+ * `overlayCarriesCmeStamp`). */
30
+ export declare function wrunOverlayCmeStamped(meta: {
31
+ settings?: unknown;
32
+ } | null | undefined): boolean;
33
+ /** The server's governed-plane mark a batch carries, if any. */
34
+ export declare function wrunBatchGovernedOf(batch: object): WrunGovernedMark | undefined;
35
+ /** Whether the server's mark names the CME plane. */
36
+ export declare function wrunGovernedReadsCme(governed: WrunGovernedMark | undefined): boolean;
37
+ /**
38
+ * Carry the overlay's sticky governed-plane mark on a failure the socket row source rejects with (hidden, like a
39
+ * refusal record): the run pass reads it back (`wrunFailureGovernedOf`) so a failed run that read CME surfaces marked.
40
+ * A non-object failure, or no mark, is returned as it is.
41
+ */
42
+ export declare function markWrunFailureGoverned<T>(error: T, mark: WrunGovernedMark | undefined): T;
43
+ /**
44
+ * The governed-plane mark a failure carries: the sticky mark the source attached (`markWrunFailureGoverned`), else the
45
+ * error frame's relayed `details.wrunGoverned` (wrun-hosted-wire-caps `wrunGovernedDetailsOfText`) read by the one
46
+ * fail-closed reader (`wrunGovernedMarkOf`), on the failure or any `cause` it wraps. Undefined: no mark anywhere.
47
+ */
48
+ export declare function wrunFailureGovernedOf(error: unknown): WrunGovernedMark | undefined;
49
+ /**
50
+ * Read a failure's governed-plane mark (`wrunFailureGovernedOf`), then take the relayed governed trailer off the text
51
+ * of the failure and every `cause` it wraps, so every reader past it (the trap row, the refusal records, the console)
52
+ * reads the frame's words as before. Answers the mark.
53
+ */
54
+ export declare function takeWrunFailureGoverned(error: unknown): WrunGovernedMark | undefined;
55
+ /**
56
+ * Whether a hosted run's result read CME: the chart is on the CME plane, the sheet pins a CME market (`sheetPinsCme`,
57
+ * the run head's reading), or the server's mark names CME. Never the run's author or lane.
58
+ */
59
+ export declare function wrunHostedRunReadsCme(args: {
60
+ chartExchange: unknown;
61
+ sheetPinsCme: boolean;
62
+ governed: WrunGovernedMark | undefined;
63
+ }): boolean;
64
+ /**
65
+ * Stamp the overlay a hosted run's CME result lands on, through the host's CME writer (`setOverlayCmeProvenance`, both
66
+ * settings copies), then read the stamp back off the mounted overlay. `owns` judges, in the same task as the write,
67
+ * that the run still owns its overlay (a replacement mounted under the same id is another overlay, never written).
68
+ * Answers whether the overlay carries the stamp now; false fails the batch (fail closed). Never clears.
69
+ */
70
+ export declare function stampWrunHostedCme(chartIndex: number, indicatorId: string, meta: {
71
+ settings?: unknown;
72
+ }, owns: () => boolean): Promise<boolean>;
@@ -0,0 +1,151 @@
1
+ /**
2
+ * The CME provenance of a hosted (Cloud) run, the twin of the OPRA mark (wrun-cloud-opra-stamp.util). One rule never
3
+ * opens with the governed-lanes cutover: no CME data reaches Kata or any AI feature, so every row a run derives from
4
+ * CME data carries the CME stamp (`settings.metaCmeExchange = 'CME'`, the key the hosted chart read, the MCP withhold
5
+ * and the governed-source inventory read), whatever lane or author produced it.
6
+ *
7
+ * A browser run is stamped by the chart's fetch door when it admits a CME source. A hosted run fetches nothing in the
8
+ * browser, so its result batch is stamped here before any of its rows lands (`integrateWrunRowSourceBatch`), by two
9
+ * readings joined (`wrunHostedRunReadsCme`):
10
+ *
11
+ * - the head mark: the chart is on the CME plane, or the sheet the run reads pins a CME market (the run head's
12
+ * `wrunSheetPinsCme`), read from the sheet and the chart alone;
13
+ * - the server mark: the reply's `output.wrunGoverned.cme` (the hosted wire's `wrunGoverned`, `readWrunGovernedMark`),
14
+ * which the batch carries as `governed` (`wrunBatchGovernedOf`): what the server knows the run read, even where the
15
+ * sheet shows no CME.
16
+ *
17
+ * Lane-blind and author-blind: a first-party hosted run that reads CME is stamped too. Fail closed: a host that binds
18
+ * no CME writer (`setOverlayCmeProvenance`), a writer that throws, a run that no longer owns its overlay, or a stamp the
19
+ * mounted overlay does not read back all fail the batch, so no unstamped CME row is integrated. The stamp is sticky for
20
+ * the mount, as the browser's is (cme-overlay-provenance.util): no result sheds it.
21
+ */
22
+ import { wrunChartHostEnv } from '../../host-env.js';
23
+ import { payloadTouchesCmeVenue } from '../chart/kscript-venue-policy.util.js';
24
+ import { wrunGovernedDetailsOfText, wrunTextWithoutGovernedTrailer } from './wrun-hosted-wire-caps.js';
25
+ import { wrunGovernedMarkOf } from './wrun-hosted-wire.util.js';
26
+ /** The provenance word a CME-stamped overlay carries (cme-overlay-provenance.leaf `CME_PROVENANCE`). */
27
+ const CME_PROVENANCE = 'CME';
28
+ /** Whether a mounted overlay's settings carry the CME provenance stamp (cme-overlay-provenance.leaf
29
+ * `overlayCarriesCmeStamp`). */
30
+ export function wrunOverlayCmeStamped(meta) {
31
+ const settings = meta?.settings;
32
+ return (typeof settings === 'object' &&
33
+ settings !== null &&
34
+ settings.metaCmeExchange === CME_PROVENANCE);
35
+ }
36
+ /** The server's governed-plane mark a batch carries, if any. */
37
+ export function wrunBatchGovernedOf(batch) {
38
+ const governed = batch.governed;
39
+ return typeof governed === 'object' && governed !== null ? governed : undefined;
40
+ }
41
+ /** Whether the server's mark names the CME plane. */
42
+ export function wrunGovernedReadsCme(governed) {
43
+ return governed?.cme !== undefined;
44
+ }
45
+ /** The key a failed ask's error carries its overlay's sticky governed-plane mark under (`markWrunFailureGoverned`). */
46
+ const FAILURE_GOVERNED_KEY = 'wrunGovernedFailureMark';
47
+ /** How deep a failure's `cause` chain is read for the mark (a transport wraps the frame's error once or twice). */
48
+ const FAILURE_CAUSE_DEPTH = 8;
49
+ /**
50
+ * Carry the overlay's sticky governed-plane mark on a failure the socket row source rejects with (hidden, like a
51
+ * refusal record): the run pass reads it back (`wrunFailureGovernedOf`) so a failed run that read CME surfaces marked.
52
+ * A non-object failure, or no mark, is returned as it is.
53
+ */
54
+ export function markWrunFailureGoverned(error, mark) {
55
+ if (mark === undefined || typeof error !== 'object' || error === null)
56
+ return error;
57
+ try {
58
+ Object.defineProperty(error, FAILURE_GOVERNED_KEY, {
59
+ value: mark,
60
+ enumerable: false,
61
+ configurable: true,
62
+ writable: true,
63
+ });
64
+ }
65
+ catch {
66
+ // A frozen failure keeps its text: the reader below still reads the relayed trailer off it.
67
+ }
68
+ return error;
69
+ }
70
+ /**
71
+ * The governed-plane mark a failure carries: the sticky mark the source attached (`markWrunFailureGoverned`), else the
72
+ * error frame's relayed `details.wrunGoverned` (wrun-hosted-wire-caps `wrunGovernedDetailsOfText`) read by the one
73
+ * fail-closed reader (`wrunGovernedMarkOf`), on the failure or any `cause` it wraps. Undefined: no mark anywhere.
74
+ */
75
+ export function wrunFailureGovernedOf(error) {
76
+ let at = error;
77
+ for (let depth = 0; depth < FAILURE_CAUSE_DEPTH && at !== undefined && at !== null; depth += 1) {
78
+ if (typeof at === 'string')
79
+ return wrunGovernedMarkOf(wrunGovernedDetailsOfText(at));
80
+ if (typeof at !== 'object')
81
+ return undefined;
82
+ const held = at[FAILURE_GOVERNED_KEY];
83
+ if (typeof held === 'object' && held !== null)
84
+ return held;
85
+ const message = at.message;
86
+ const relayed = typeof message === 'string' ? wrunGovernedMarkOf(wrunGovernedDetailsOfText(message)) : undefined;
87
+ if (relayed !== undefined)
88
+ return relayed;
89
+ at = at.cause;
90
+ }
91
+ return undefined;
92
+ }
93
+ /**
94
+ * Read a failure's governed-plane mark (`wrunFailureGovernedOf`), then take the relayed governed trailer off the text
95
+ * of the failure and every `cause` it wraps, so every reader past it (the trap row, the refusal records, the console)
96
+ * reads the frame's words as before. Answers the mark.
97
+ */
98
+ export function takeWrunFailureGoverned(error) {
99
+ const mark = wrunFailureGovernedOf(error);
100
+ let at = error;
101
+ for (let depth = 0; depth < FAILURE_CAUSE_DEPTH && typeof at === 'object' && at !== null; depth += 1) {
102
+ const message = at.message;
103
+ if (typeof message === 'string') {
104
+ const stripped = wrunTextWithoutGovernedTrailer(message);
105
+ if (stripped !== message) {
106
+ try {
107
+ at.message = stripped;
108
+ }
109
+ catch {
110
+ // A read-only message keeps its text: the mark is read already.
111
+ }
112
+ }
113
+ }
114
+ at = at.cause;
115
+ }
116
+ return mark;
117
+ }
118
+ /**
119
+ * Whether a hosted run's result read CME: the chart is on the CME plane, the sheet pins a CME market (`sheetPinsCme`,
120
+ * the run head's reading), or the server's mark names CME. Never the run's author or lane.
121
+ */
122
+ export function wrunHostedRunReadsCme(args) {
123
+ return payloadTouchesCmeVenue(args.chartExchange) || args.sheetPinsCme || wrunGovernedReadsCme(args.governed);
124
+ }
125
+ /**
126
+ * Stamp the overlay a hosted run's CME result lands on, through the host's CME writer (`setOverlayCmeProvenance`, both
127
+ * settings copies), then read the stamp back off the mounted overlay. `owns` judges, in the same task as the write,
128
+ * that the run still owns its overlay (a replacement mounted under the same id is another overlay, never written).
129
+ * Answers whether the overlay carries the stamp now; false fails the batch (fail closed). Never clears.
130
+ */
131
+ export async function stampWrunHostedCme(chartIndex, indicatorId, meta, owns) {
132
+ let write;
133
+ try {
134
+ write = (await wrunChartHostEnv().chart.loadOptionsOverlayProvenance()).setOverlayCmeProvenance;
135
+ }
136
+ catch (error) {
137
+ console.warn(`[wrun] the CME writer for '${indicatorId}' did not load; its hosted result is dropped:`, error);
138
+ return false;
139
+ }
140
+ if (write === undefined || !owns())
141
+ return false;
142
+ // Written even over a stamped mount: both copies carry it after (the writer is idempotent).
143
+ try {
144
+ write(chartIndex, indicatorId, true);
145
+ }
146
+ catch (error) {
147
+ console.warn(`[wrun] the CME stamp of '${indicatorId}' was not written; its hosted result is dropped:`, error);
148
+ return false;
149
+ }
150
+ return wrunOverlayCmeStamped(meta);
151
+ }
@@ -37,9 +37,9 @@ export declare function isWrunHudViewerRowKey(key: string): boolean;
37
37
  export declare const WRUN_HEATMAP_SENSITIVITY_ROW_RE: RegExp;
38
38
  export declare function isWrunHeatmapSensitivityRowKey(key: string): boolean;
39
39
  /** Every viewer row of a browser-run Indicator (a HUD's rows, a heatmap's
40
- * Sensitivity, a child the reader hid on its own legend row):
41
- * overlay settings that persist by key and are never a sheet param, an alert
42
- * param or a host param. */
40
+ * Sensitivity, a child the reader hid on its own legend row, the height a
41
+ * reader dragged a child's pane to): overlay settings that persist by key and
42
+ * are never a sheet param, an alert param or a host param. */
43
43
  export declare function isWrunViewerRowKey(key: string): boolean;
44
44
  /** `((r * 256 + g) * 256 + b) * 1024 + round(alpha * 1000)`, arithmetic
45
45
  * (the value outgrows 32-bit bitwise ops). */